2023-12-14 16:01:48 +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.base.mapper.RepairMapper" >
2023-12-16 21:12:55 +08:00
<insert id= "addRecord" >
insert into repair_apply_record (task_id,ma_id,type_id,repair_num,scrap_num,repair_type,create_by,create_time,repair_content,company_id,scrap_reason,scrap_type,supplier_id,part_num,part_price,part_type,part_name,repairer)
values (#{taskId},#{maId},#{typeId},#{repairNum},#{scrapNum},#{repairType},#{createBy},now(),#{repairContent},#{companyId},#{scrapReason},#{scrapType},#{supplierId},#{partNum},#{partPrice},#{partType},#{partName},#{repairer});
</insert>
<insert id= "addPart" >
insert into repair_part_details (task_id,ma_id,type_id,part_id,part_num,part_cost,part_type,create_by,create_time,company_id,repair_content)
values (#{taskId},#{maId},#{typeId},#{partId},#{partNum},#{partCost},#{partType},#{createBy},now(),#{companyId},#{repairContent});
</insert>
<insert id= "addTask" useGeneratedKeys= "true" keyProperty= "taskId" >
insert into tm_task (task_status,task_type,code,create_by,create_time,company_id)
values (45,46,#{repairCode},#{createBy},now(),#{companyId});
</insert>
<insert id= "createAgreementTask" >
insert into tm_task_agreement (task_id,agreement_id,create_by,create_time,company_id)
values (#{taskId},#{agreementId},#{createBy},now(),#{companyId});
</insert>
<update id= "updateRepairedNum" >
update repair_apply_details
set repaired_num = #{repairNum},
repairer = #{repairer},
update_by = #{userId},
update_time = now()
where id = #{id}
</update>
<update id= "updateScrapNum" >
update repair_apply_details
set scrap_num = #{scrapNum},
update_by = #{userId},
update_time = now()
where id = #{id}
</update>
<update id= "completeRepair" >
update repair_apply_details
set status = '1',
update_by = #{userId},
update_time = now()
where id in
<foreach item= "id" collection= "ids" open= "(" separator= "," close= ")" >
#{id}
</foreach>
</update>
<update id= "updateTaskStatus" >
update tm_task
set task_status = '44',
update_by = #{userId},
update_time = now()
where task_id in
<foreach item= "task" collection= "taskList" open= "(" separator= "," close= ")" >
#{task.taskId}
</foreach>
</update>
<update id= "updateRepairedNumTwo" >
update repair_apply_details
set repaired_num = #{repairNum},
update_by = #{userId},
update_time = now()
where id = #{id}
</update>
2023-12-14 16:01:48 +08:00
2023-12-14 17:25:17 +08:00
<select id= "getRepairTaskList" resultType= "com.bonus.sgzb.base.domain.RepairTask" >
SELECT
2023-12-16 21:12:55 +08:00
ts.task_id as taskId,
2023-12-14 17:25:17 +08:00
ts.CODE AS repairCode,
bui.unit_name AS backUnit,
2023-12-16 21:12:55 +08:00
bpi.pro_name AS backPro,
su.user_name AS createUser,
2023-12-14 17:25:17 +08:00
ts.create_time AS createTime,
bai.CODE AS backCode,
2023-12-16 21:12:55 +08:00
ts.task_status AS repairStatus,
ts.company_id AS companyId
2023-12-14 17:25:17 +08:00
FROM
tm_task ts
2023-12-16 21:12:55 +08:00
LEFT JOIN repair_apply_details rad ON ts.task_id = rad.task_id
2023-12-14 17:25:17 +08:00
LEFT JOIN back_apply_info bai ON rad.back_id = bai.id
LEFT JOIN tm_task_agreement tta ON bai.task_id = tta.task_id
LEFT JOIN bm_agreement_info bai2 ON tta.agreement_id = bai2.agreement_id
LEFT JOIN bm_unit_info bui ON bai2.unit_id = bui.unit_id
LEFT JOIN bm_project_info bpi ON bai2.project_id = bpi.pro_id
2023-12-16 21:12:55 +08:00
left join sys_user su on rad.create_by = su.user_id
where ts.task_type = '41'
GROUP BY ts.task_id, bui.unit_name,bpi.pro_name,bai.code,su.user_name
<if test= "keyword != null and keyword != ''" >
AND (locate(#{keyword}, su.user_name) > 0
or locate(#{keyword}, ts.CODE) > 0)
</if>
<if test= "backUnit != null and backUnit != ''" >
AND bui.unit_id = #{backUnit}
</if>
<if test= "backPro != null and backPro != ''" >
AND bpi.pro_id = #{backPro}
</if>
<if test= "backCode != null and backCode != ''" >
AND bai.CODE = #{backCode}
</if>
<if test= "repairStatus != null and repairStatus != ''" >
AND ts.task_status = #{repairStatus}
</if>
<if test= "startTime != null and startTime != '' and endTime != null and endTime != ''" >
AND ts.create_time between #{startTime} and #{endTime}
</if>
2023-12-14 17:25:17 +08:00
</select>
2023-12-16 21:12:55 +08:00
<select id= "getRepairMaTypeList" resultType= "com.bonus.sgzb.base.domain.RepairTaskDetails" >
select rad.id as id,
rad.task_id as taskId,
rad.ma_id as maId,
mt.type_name as type,
mm.ma_code as code,
rad.repair_num as repairNum,
rad.repaired_num as repairedNum,
rad.scrap_num as scrapNum,
rad.status as status,
su.user_name as repairer,
rad.update_time as updateTime,
rad.type_id as typeId
from repair_apply_details rad
left join ma_type mt on rad.type_id = mt.type_id
left join ma_machine mm on mm.ma_id = rad.ma_id
left join sys_user su on rad.repairer = su.user_id
where rad.task_id = #{taskId}
</select>
<select id= "getTypeList" resultType= "java.lang.String" >
SELECT
m.type_name
FROM
ma_type m
WHERE
m.type_id IN (
SELECT
mt.parent_id
FROM
ma_type mt
WHERE
mt.type_id IN ( SELECT ad.type_id FROM repair_apply_details ad WHERE ad.task_id = #{taskId}))
GROUP BY
m.type_name
2023-12-14 17:25:17 +08:00
</select>
2023-12-16 21:12:55 +08:00
<select id= "getType" resultType= "java.lang.String" >
SELECT
m.type_name
FROM
ma_type m
WHERE
m.type_id = (
SELECT
mt.parent_id
FROM
ma_type mt
WHERE
mt.type_id = #{typeId})
</select>
<select id= "getById" resultType= "com.bonus.sgzb.base.domain.RepairTaskDetails" >
select rad.id as id,
rad.repair_num as repairNum,
rad.repaired_num as repairedNum,
rad.scrap_num as scrapNum
from repair_apply_details rad
where rad.id = #{id}
</select>
<select id= "selectUserList" resultType= "com.bonus.sgzb.system.api.domain.SysUser" >
select user_id as userId,
nick_name as nickName
from sys_user
</select>
<select id= "getAgreementId" resultType= "java.lang.Long" >
select agreement_id
from tm_task_agreement
where task_id = #{taskId}
</select>
2023-12-14 16:01:48 +08:00
</mapper>