2023-12-17 18:01:20 +08:00
|
|
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
|
|
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
|
|
|
<mapper namespace="com.bonus.sgzb.app.mapper.LeaseOutDetailsMapper">
|
|
|
|
|
|
|
|
|
|
<select id="selectListByParentId" resultType="com.bonus.sgzb.base.api.domain.LeaseOutDetails">
|
|
|
|
|
SELECT
|
|
|
|
|
lod.id,lod.parent_id,lod.type_id,lod.ma_id,lod.out_num,lod.out_type,lod.create_by,
|
|
|
|
|
lod.create_time,lod.update_by,lod.update_time,lod.remark,lod.company_id
|
|
|
|
|
FROM
|
|
|
|
|
lease_out_details lod
|
|
|
|
|
<where>
|
|
|
|
|
<if test="_parameter != null and _parameter != '' ">
|
|
|
|
|
lod.parent_id = #{parentId}
|
|
|
|
|
</if>
|
|
|
|
|
</where>
|
|
|
|
|
</select>
|
2024-01-12 17:11:47 +08:00
|
|
|
<select id="getTaskId" resultType="java.lang.String">
|
|
|
|
|
select task_id
|
|
|
|
|
from lease_apply_info
|
|
|
|
|
where id = #{parentId}
|
|
|
|
|
</select>
|
2024-01-19 10:53:02 +08:00
|
|
|
<select id="getMachineStatus" resultType="java.lang.String">
|
|
|
|
|
select ma_status
|
|
|
|
|
from ma_machine
|
|
|
|
|
where ma_id = #{maId}
|
|
|
|
|
</select>
|
2023-12-17 18:01:20 +08:00
|
|
|
|
2024-01-26 18:38:50 +08:00
|
|
|
<select id="leaseOutRecord" resultType="com.bonus.sgzb.app.domain.LeaseApplyDetails">
|
|
|
|
|
SELECT
|
|
|
|
|
lod.id,
|
|
|
|
|
bui.unit_name as unitName,
|
|
|
|
|
bpl.lot_name as proName,
|
|
|
|
|
mt2.type_name as typeName,
|
|
|
|
|
mt.type_name as typeModelName,
|
|
|
|
|
lod.create_time as createTime,
|
|
|
|
|
lod.out_num as num
|
|
|
|
|
FROM
|
|
|
|
|
lease_out_details lod
|
|
|
|
|
LEFT JOIN lease_apply_info lai on lai.id=lod.parent_id
|
|
|
|
|
LEFT JOIN tm_task_agreement tta on tta.task_id=lai.task_id
|
|
|
|
|
LEFT JOIN bm_agreement_info bai on bai.agreement_id=tta.agreement_id
|
|
|
|
|
LEFT JOIN bm_project_lot bpl on bpl.lot_id=bai.project_id
|
|
|
|
|
LEFT JOIN bm_unit_info bui on bui.unit_id=bai.unit_id
|
|
|
|
|
LEFT JOIN ma_type mt on mt.type_id=lod.type_id
|
|
|
|
|
LEFT JOIN ma_type mt2 on mt2.type_id=mt.parent_id
|
|
|
|
|
where 1=1
|
|
|
|
|
<if test="keyWord != null and keyWord != ''">
|
|
|
|
|
and (bui.unit_name like concat('%', #{keyWord}, '%') or
|
|
|
|
|
bpl.lot_name like concat('%', #{keyWord}, '%') or
|
|
|
|
|
mt2.type_name like concat('%', #{keyWord}, '%') or
|
|
|
|
|
mt.type_name like concat('%', #{keyWord}, '%')
|
|
|
|
|
)
|
|
|
|
|
</if>
|
|
|
|
|
<if test="startTime != null and startTime != '' and endTime != null and endTime != '' " >
|
|
|
|
|
and (lod.create_time like concat('%', #{startTime}, '%') or
|
|
|
|
|
lod.create_time like concat('%', #{endTime}, '%')
|
|
|
|
|
)
|
|
|
|
|
</if>
|
|
|
|
|
ORDER BY lod.create_time DESC
|
|
|
|
|
</select>
|
|
|
|
|
|
2024-02-18 17:31:32 +08:00
|
|
|
<select id="proUseRecord" resultType="com.bonus.sgzb.app.domain.LeaseApplyDetails">
|
|
|
|
|
SELECT
|
|
|
|
|
t1.unitName,
|
|
|
|
|
t1.lotName as proName,
|
|
|
|
|
t1.typeName,
|
|
|
|
|
t1.typeCode as typeModelName,
|
|
|
|
|
t1.outNum as alNum,
|
|
|
|
|
IFNULL(t1.outNum,0) - IFNULL(t2.backNum,0) as num
|
|
|
|
|
FROM
|
|
|
|
|
(SELECT
|
|
|
|
|
bui.unit_name as unitName,
|
|
|
|
|
bpl.lot_name as lotName,
|
|
|
|
|
mt2.type_name as typeName,
|
|
|
|
|
mt.type_name as typeCode,
|
|
|
|
|
SUM(lod.out_num) as outNum,
|
|
|
|
|
bai.unit_id,
|
|
|
|
|
bai.project_id,
|
|
|
|
|
lod.type_id
|
|
|
|
|
FROM
|
|
|
|
|
lease_out_details lod
|
|
|
|
|
LEFT JOIN lease_apply_info lai on lai.id=lod.parent_id
|
|
|
|
|
LEFT JOIN tm_task_agreement tta on tta.task_id=lai.task_id
|
|
|
|
|
LEFT JOIN bm_agreement_info bai on bai.agreement_id=tta.agreement_id
|
|
|
|
|
LEFT JOIN bm_project_lot bpl on bpl.lot_id=bai.project_id
|
|
|
|
|
LEFT JOIN bm_unit_info bui on bui.unit_id=bai.unit_id
|
|
|
|
|
LEFT JOIN ma_type mt on mt.type_id=lod.type_id
|
|
|
|
|
LEFT JOIN ma_type mt2 on mt2.type_id=mt.parent_id
|
|
|
|
|
where 1=1
|
|
|
|
|
<if test="keyWord != null and keyWord != ''">
|
|
|
|
|
and (bui.unit_name like concat('%', #{keyWord}, '%') or
|
|
|
|
|
bpl.lot_name like concat('%', #{keyWord}, '%') or
|
|
|
|
|
mt2.type_name like concat('%', #{keyWord}, '%') or
|
|
|
|
|
mt.type_name like concat('%', #{keyWord}, '%')
|
|
|
|
|
)
|
|
|
|
|
</if>
|
|
|
|
|
GROUP BY bai.unit_id,bai.project_id,lod.type_id) t1
|
|
|
|
|
LEFT JOIN
|
|
|
|
|
(SELECT
|
|
|
|
|
bui.unit_name as unitName,
|
|
|
|
|
bpl.lot_name as lotName,
|
|
|
|
|
mt2.type_name as typeName,
|
|
|
|
|
mt.type_name as typeCode,
|
|
|
|
|
SUM(bcd.back_num) as backNum,
|
|
|
|
|
bai.unit_id,
|
|
|
|
|
bai.project_id,
|
|
|
|
|
bcd.type_id
|
|
|
|
|
FROM
|
|
|
|
|
back_check_details bcd
|
|
|
|
|
LEFT JOIN back_apply_info bapi on bapi.id=bcd.parent_id
|
|
|
|
|
LEFT JOIN tm_task_agreement tta on tta.task_id=bapi.task_id
|
|
|
|
|
LEFT JOIN bm_agreement_info bai on bai.agreement_id=tta.agreement_id
|
|
|
|
|
LEFT JOIN bm_project_lot bpl on bpl.lot_id=bai.project_id
|
|
|
|
|
LEFT JOIN bm_unit_info bui on bui.unit_id=bai.unit_id
|
|
|
|
|
LEFT JOIN ma_type mt on mt.type_id=bcd.type_id
|
|
|
|
|
LEFT JOIN ma_type mt2 on mt2.type_id=mt.parent_id
|
|
|
|
|
where 1=1
|
|
|
|
|
<if test="keyWord != null and keyWord != ''">
|
|
|
|
|
and (bui.unit_name like concat('%', #{keyWord}, '%') or
|
|
|
|
|
bpl.lot_name like concat('%', #{keyWord}, '%') or
|
|
|
|
|
mt2.type_name like concat('%', #{keyWord}, '%') or
|
|
|
|
|
mt.type_name like concat('%', #{keyWord}, '%')
|
|
|
|
|
)
|
|
|
|
|
</if>
|
|
|
|
|
GROUP BY bai.unit_id,bai.project_id,bcd.type_id) t2
|
|
|
|
|
ON
|
|
|
|
|
t1.unit_id = t2.unit_id
|
|
|
|
|
AND t1.project_id = t2.project_id
|
|
|
|
|
AND t1.type_id = t2.type_id
|
|
|
|
|
|
|
|
|
|
</select>
|
|
|
|
|
|
2023-12-17 18:01:20 +08:00
|
|
|
<update id="updateLeaseApplyDetailsOutNum">
|
|
|
|
|
UPDATE
|
|
|
|
|
lease_apply_details
|
|
|
|
|
SET
|
2023-12-24 12:41:46 +08:00
|
|
|
al_num = IF(al_num IS NULL, #{record.outNum}, al_num + #{record.outNum}),
|
2023-12-17 18:01:20 +08:00
|
|
|
<if test="record.updateBy != null and record.updateBy!= '' ">
|
|
|
|
|
update_by = #{record.updateBy},
|
|
|
|
|
</if>
|
|
|
|
|
update_time = now(),
|
|
|
|
|
status = '2'
|
|
|
|
|
WHERE
|
|
|
|
|
parennt_id = #{record.parentId} and type_id = #{record.typeId}
|
|
|
|
|
</update>
|
|
|
|
|
|
|
|
|
|
<insert id="insert">
|
|
|
|
|
insert into lease_out_details(parent_id,type_id,ma_id,out_num,out_type,create_by,create_time,update_by,update_time,remark,company_id)
|
|
|
|
|
values(#{parentId},#{typeId},#{maId},#{outNum},#{outType},#{createBy},now(),#{updateBy},now(),#{remark},#{companyId})
|
|
|
|
|
</insert>
|
|
|
|
|
|
|
|
|
|
<insert id="insertSelective">
|
|
|
|
|
insert into lease_out_details
|
|
|
|
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
|
|
|
|
<if test="parentId!= null">
|
|
|
|
|
parent_id,
|
|
|
|
|
</if>
|
|
|
|
|
<if test="typeId!= null">
|
|
|
|
|
type_id,
|
|
|
|
|
</if>
|
|
|
|
|
<if test="maId!= null">
|
|
|
|
|
ma_id,
|
|
|
|
|
</if>
|
|
|
|
|
<if test="outNum!= null">
|
|
|
|
|
out_num,
|
|
|
|
|
</if>
|
|
|
|
|
<if test="outType!= null">
|
|
|
|
|
out_type,
|
|
|
|
|
</if>
|
|
|
|
|
<if test="createBy!= null">
|
|
|
|
|
create_by,
|
|
|
|
|
</if>
|
|
|
|
|
<if test="updateBy!= null">
|
|
|
|
|
update_by,
|
|
|
|
|
</if>
|
|
|
|
|
<if test="remark!= null">
|
|
|
|
|
remark,
|
|
|
|
|
</if>
|
|
|
|
|
<if test="companyId!= null">
|
|
|
|
|
company_id,
|
|
|
|
|
</if>
|
2024-01-26 13:03:26 +08:00
|
|
|
<if test="carCode!= null">
|
|
|
|
|
car_code,
|
|
|
|
|
</if>
|
2023-12-24 20:44:43 +08:00
|
|
|
create_time,
|
|
|
|
|
update_time
|
2023-12-17 18:01:20 +08:00
|
|
|
</trim>
|
|
|
|
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
|
|
|
|
<if test="parentId!= null">
|
|
|
|
|
#{parentId},
|
|
|
|
|
</if>
|
|
|
|
|
<if test="typeId!= null">
|
|
|
|
|
#{typeId},
|
|
|
|
|
</if>
|
|
|
|
|
<if test="maId!= null">
|
|
|
|
|
#{maId},
|
|
|
|
|
</if>
|
|
|
|
|
<if test="outNum!= null">
|
|
|
|
|
#{outNum},
|
|
|
|
|
</if>
|
|
|
|
|
<if test="outType!= null">
|
|
|
|
|
#{outType},
|
|
|
|
|
</if>
|
|
|
|
|
<if test="createBy!= null">
|
|
|
|
|
#{createBy},
|
|
|
|
|
</if>
|
|
|
|
|
<if test="updateBy!= null">
|
|
|
|
|
#{updateBy},
|
|
|
|
|
</if>
|
|
|
|
|
<if test="remark!= null">
|
|
|
|
|
#{remark},
|
|
|
|
|
</if>
|
|
|
|
|
<if test="companyId!= null">
|
|
|
|
|
#{companyId},
|
|
|
|
|
</if>
|
2024-01-26 13:03:26 +08:00
|
|
|
<if test="carCode!= null">
|
|
|
|
|
#{carCode},
|
|
|
|
|
</if>
|
2023-12-24 20:44:43 +08:00
|
|
|
NOW(),
|
|
|
|
|
NOW()
|
2023-12-17 18:01:20 +08:00
|
|
|
</trim>
|
|
|
|
|
</insert>
|
|
|
|
|
|
|
|
|
|
<update id="updateMaTypeStockNum">
|
|
|
|
|
UPDATE
|
|
|
|
|
ma_type
|
|
|
|
|
SET
|
2023-12-24 20:44:43 +08:00
|
|
|
num = num - #{record.outNum} ,update_time = NOW()
|
2023-12-17 18:01:20 +08:00
|
|
|
WHERE
|
|
|
|
|
type_id = #{record.typeId}
|
|
|
|
|
</update>
|
|
|
|
|
|
|
|
|
|
<update id="updateMaMachineStatus">
|
|
|
|
|
UPDATE
|
|
|
|
|
ma_machine
|
|
|
|
|
SET
|
2023-12-24 20:44:43 +08:00
|
|
|
ma_status = '16' , create_time = NOW()
|
2023-12-17 18:01:20 +08:00
|
|
|
<where>
|
|
|
|
|
type_id = #{record.typeId}
|
|
|
|
|
<if test="record.maId != null and record.maId != ''">
|
|
|
|
|
and ma_id = #{record.maId}
|
|
|
|
|
</if>
|
|
|
|
|
</where>
|
|
|
|
|
</update>
|
2024-01-12 17:11:47 +08:00
|
|
|
<update id="updateTaskStatus">
|
|
|
|
|
update tm_task
|
|
|
|
|
set task_status = #{status}
|
|
|
|
|
where task_id = #{taskId}
|
|
|
|
|
</update>
|
2023-12-17 18:01:20 +08:00
|
|
|
|
|
|
|
|
<insert id="insertAgreementInfo">
|
|
|
|
|
insert into tm_task_agreement
|
|
|
|
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
|
|
|
|
<if test="record.parentId != null">
|
|
|
|
|
task_id,
|
|
|
|
|
</if>
|
|
|
|
|
<if test="record.agreementId!= null">
|
|
|
|
|
agreement_id,
|
|
|
|
|
</if>
|
|
|
|
|
<if test="record.createBy!= null">
|
|
|
|
|
create_by,
|
|
|
|
|
</if>
|
|
|
|
|
<if test="record.updateBy!= null">
|
|
|
|
|
update_by,
|
|
|
|
|
</if>
|
|
|
|
|
<if test="record.remark!= null">
|
|
|
|
|
remark,
|
|
|
|
|
</if>
|
|
|
|
|
<if test="record.companyId!= null">
|
|
|
|
|
company_id,
|
|
|
|
|
</if>
|
|
|
|
|
create_time
|
|
|
|
|
</trim>
|
|
|
|
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
|
|
|
|
<if test="record.parentId != null">
|
|
|
|
|
#{record.parentId},
|
|
|
|
|
</if>
|
|
|
|
|
<if test="record.agreementId != null">
|
|
|
|
|
#{record.typeId},
|
|
|
|
|
</if>
|
|
|
|
|
<if test="record.createBy != null">
|
|
|
|
|
#{record.createBy},
|
|
|
|
|
</if>
|
|
|
|
|
<if test="record.updateBy != null">
|
|
|
|
|
#{record.updateBy},
|
|
|
|
|
</if>
|
|
|
|
|
<if test="record.remark != null">
|
|
|
|
|
#{record.remark},
|
|
|
|
|
</if>
|
|
|
|
|
<if test="record.companyId != null">
|
|
|
|
|
#{record.companyId},
|
|
|
|
|
</if>
|
|
|
|
|
now()
|
|
|
|
|
</trim>
|
|
|
|
|
</insert>
|
|
|
|
|
</mapper>
|