2024-09-27 15:44:11 +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.material.repair.mapper.RepairInputDetailsMapper">
|
2024-12-20 16:39:22 +08:00
|
|
|
<resultMap type="com.bonus.common.biz.domain.repair.RepairInputDetails" id="RepairInputDetailsResult">
|
2024-09-27 15:44:11 +08:00
|
|
|
<result property="id" column="id" />
|
|
|
|
|
<result property="taskId" column="task_id" />
|
|
|
|
|
<result property="auditId" column="audit_id" />
|
|
|
|
|
<result property="repairId" column="repair_id" />
|
|
|
|
|
<result property="maId" column="ma_id" />
|
|
|
|
|
<result property="typeId" column="type_id" />
|
|
|
|
|
<result property="repairNum" column="repair_num" />
|
|
|
|
|
<result property="inputNum" column="input_num" />
|
|
|
|
|
<result property="createBy" column="create_by" />
|
|
|
|
|
<result property="createTime" column="create_time" />
|
|
|
|
|
<result property="updateBy" column="update_by" />
|
|
|
|
|
<result property="updateTime" column="update_time" />
|
|
|
|
|
<result property="status" column="status" />
|
|
|
|
|
<result property="remark" column="remark" />
|
|
|
|
|
<result property="companyId" column="company_id" />
|
|
|
|
|
</resultMap>
|
|
|
|
|
|
|
|
|
|
<sql id="selectRepairInputDetailsVo">
|
|
|
|
|
select id, task_id, audit_id, repair_id, ma_id, type_id, repair_num, input_num, create_by, create_time, update_by, update_time, status, remark, company_id from repair_input_details
|
|
|
|
|
</sql>
|
|
|
|
|
|
2024-12-13 17:25:52 +08:00
|
|
|
|
|
|
|
|
|
2024-12-20 16:39:22 +08:00
|
|
|
<select id="selectRepairInputDetailsList" resultType="com.bonus.common.biz.domain.repair.RepairInputDetails">
|
2024-12-13 17:25:52 +08:00
|
|
|
SELECT
|
|
|
|
|
rd.task_id AS taskId,
|
|
|
|
|
tt1.CODE AS repairCode,
|
|
|
|
|
rd.create_time AS createTime,
|
|
|
|
|
tt.task_status AS taskStatus,
|
|
|
|
|
CASE tt.task_status
|
|
|
|
|
WHEN '0' THEN '入库进行中'
|
|
|
|
|
WHEN '1' THEN '入库完成'
|
|
|
|
|
WHEN '2' THEN '入库驳回'
|
|
|
|
|
ELSE '未知状态'
|
|
|
|
|
END AS statusName,
|
|
|
|
|
rd.remark AS remark,
|
|
|
|
|
bui.unit_name AS backUnit,
|
|
|
|
|
bpi.pro_name AS backPro,
|
|
|
|
|
su.nick_name AS createBy,
|
|
|
|
|
tt.CODE AS inputCode,
|
|
|
|
|
GROUP_CONCAT(DISTINCT mt2.type_name) AS materialType,
|
|
|
|
|
tta.agreement_id as agreementId
|
|
|
|
|
FROM
|
|
|
|
|
repair_input_details rd
|
|
|
|
|
LEFT JOIN ma_type mt on rd.type_id = mt.type_id
|
|
|
|
|
LEFT JOIN ma_type mt2 on mt.parent_id = mt2.type_id
|
|
|
|
|
LEFT JOIN tm_task tt on rd.task_id = tt.task_id
|
|
|
|
|
LEFT JOIN repair_apply_details rad ON rad.id = rd.repair_id
|
|
|
|
|
LEFT JOIN tm_task tt1 on rad.task_id = tt1.task_id
|
|
|
|
|
LEFT JOIN tm_task_agreement tta ON rd.task_id = tta.task_id
|
|
|
|
|
LEFT JOIN bm_agreement_info bai2 ON tta.agreement_id = bai2.agreement_id
|
|
|
|
|
LEFT JOIN bm_unit bui ON bai2.unit_id = bui.unit_id
|
|
|
|
|
LEFT JOIN bm_project bpi ON bai2.project_id = bpi.pro_id and bpi.del_flag = '0'
|
|
|
|
|
left join sys_user su on rd.create_by = su.user_id
|
|
|
|
|
<where>
|
|
|
|
|
<if test="keyword != null and keyword != ''">
|
|
|
|
|
AND (
|
|
|
|
|
locate(#{keyword}, su.nick_name) > 0
|
|
|
|
|
or locate(#{keyword}, tt.CODE) > 0
|
|
|
|
|
or locate(#{keyword}, tt1.CODE) > 0
|
|
|
|
|
or locate(#{keyword}, bui.unit_name) > 0
|
|
|
|
|
or locate(#{keyword}, bpi.pro_name) > 0
|
|
|
|
|
or locate(#{keyword}, su.nick_name) > 0
|
|
|
|
|
)
|
|
|
|
|
</if>
|
|
|
|
|
<if test="taskStatus != null ">
|
|
|
|
|
AND tt.task_status = #{taskStatus}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
|
|
|
|
|
AND rd.create_time BETWEEN CONCAT(#{startTime}, ' 00:00:00') AND CONCAT(#{endTime}, ' 23:59:59')
|
|
|
|
|
</if>
|
2024-09-27 15:44:11 +08:00
|
|
|
</where>
|
2024-12-13 17:25:52 +08:00
|
|
|
GROUP BY rd.task_id
|
|
|
|
|
order by rd.create_time desc
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<select id="selectRepairInputDetailsById" resultType="com.bonus.material.repair.domain.RepairInputInfo">
|
|
|
|
|
select
|
|
|
|
|
rid.id as id,
|
|
|
|
|
rid.task_id as taskId,
|
|
|
|
|
rid.ma_id as maId,
|
|
|
|
|
rid.type_id as typeId,
|
|
|
|
|
SUM(IFNULL(rid.repair_num, 0)) as repairNum,
|
|
|
|
|
SUM(IFNULL(rid.input_num, 0)) as inputNum,
|
|
|
|
|
(SUM(IFNULL(rid.repair_num, 0)) - SUM(IFNULL(rid.input_num, 0)) - SUM(IFNULL(rid.reject_num, 0)))
|
|
|
|
|
AS pendingInputNum,
|
|
|
|
|
SUM(IFNULL(rid.reject_num, 0)) as rejectNum,
|
|
|
|
|
rid.create_by as createBy,
|
|
|
|
|
rid.create_time as createTime,
|
|
|
|
|
rid.remark as remark,
|
|
|
|
|
mt1.type_name AS typeName,
|
|
|
|
|
mt.type_name AS typeModelName,
|
|
|
|
|
mt.unit_name AS unitName,
|
|
|
|
|
mt.unit_value AS unitValue,
|
|
|
|
|
mt.manage_type AS manageType,
|
|
|
|
|
tta.agreement_id as agreementId,
|
|
|
|
|
rid.reject_reason as rejectReason
|
|
|
|
|
from repair_input_details rid
|
|
|
|
|
LEFT JOIN ma_type mt on rid.type_id = mt.type_id and mt.del_flag = '0'
|
|
|
|
|
LEFT JOIN ma_type mt1 on mt.parent_id = mt1.type_id and mt1.del_flag = '0'
|
|
|
|
|
LEFT JOIN tm_task_agreement tta ON rid.task_id = tta.task_id
|
|
|
|
|
where rid.task_id = #{taskId}
|
|
|
|
|
<if test="keyword != null and keyword != ''">
|
|
|
|
|
AND (
|
|
|
|
|
locate(#{keyword}, mt1.type_name) > 0
|
|
|
|
|
or locate(#{keyword}, mt.type_name) > 0
|
|
|
|
|
or locate(#{keyword}, mt.unit_name) > 0
|
|
|
|
|
)
|
|
|
|
|
</if>
|
|
|
|
|
GROUP BY rid.type_id
|
2024-09-27 15:44:11 +08:00
|
|
|
</select>
|
2024-12-13 17:25:52 +08:00
|
|
|
|
|
|
|
|
<select id="selectStatusByTaskId" resultType="java.lang.String">
|
|
|
|
|
select status from repair_input_details where task_id = #{taskId}
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<select id="getCodeList" resultType="com.bonus.material.back.domain.vo.MaCodeVo">
|
|
|
|
|
SELECT
|
|
|
|
|
rid.ma_id as maId,
|
|
|
|
|
mt1.type_name as typeName,
|
|
|
|
|
mt.type_name as materialName,
|
|
|
|
|
mm.ma_code as maCode,
|
|
|
|
|
mm.ma_status as maStatus,
|
|
|
|
|
rid.reject_reason as rejectReason
|
|
|
|
|
FROM
|
|
|
|
|
repair_input_details rid
|
|
|
|
|
LEFT JOIN ma_machine mm ON rid.ma_id = mm.ma_id
|
|
|
|
|
LEFT JOIN ma_type mt ON rid.type_id = mt.type_id
|
|
|
|
|
AND mt.del_flag = '0'
|
|
|
|
|
LEFT JOIN ma_type mt1 ON mt.parent_id = mt1.type_id
|
|
|
|
|
AND mt1.del_flag = '0'
|
|
|
|
|
WHERE
|
|
|
|
|
rid.task_id = #{taskId}
|
|
|
|
|
AND rid.type_id = #{typeId}
|
|
|
|
|
<if test="keyWord != null and keyWord != ''">
|
|
|
|
|
AND (
|
|
|
|
|
locate(#{keyWord}, mt1.type_name) > 0
|
|
|
|
|
or locate(#{keyWord}, mt.type_name) > 0
|
|
|
|
|
or locate(#{keyWord}, mm.ma_code) > 0
|
|
|
|
|
)
|
|
|
|
|
</if>
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<select id="selectRepairDetailsById" resultType="com.bonus.material.repair.domain.RepairInputInfo">
|
|
|
|
|
SELECT
|
|
|
|
|
rd.id as id,
|
|
|
|
|
rd.task_id as taskId,
|
|
|
|
|
rd.repair_id as repairId,
|
|
|
|
|
rd.ma_id as maId,
|
|
|
|
|
rd.type_id as typeId,
|
|
|
|
|
rd.repair_num as repairNum,
|
|
|
|
|
rd.input_num as inputNum,
|
|
|
|
|
(IFNULL(rd.repair_num, 0) - IFNULL(rd.input_num, 0) - IFNULL(rd.reject_num, 0))
|
|
|
|
|
AS pendingInputNum,
|
|
|
|
|
rd.reject_num as rejectNum,
|
|
|
|
|
rd.create_by as createBy,
|
|
|
|
|
rd.create_time as createTime,
|
|
|
|
|
rd.status as status,
|
|
|
|
|
rd.remark as remark,
|
|
|
|
|
mt1.type_name AS typeName,
|
|
|
|
|
mt.type_name AS typeModelName,
|
|
|
|
|
mt.unit_name AS unitName,
|
|
|
|
|
mt.unit_value AS unitValue,
|
|
|
|
|
mt.manage_type AS manageType
|
|
|
|
|
FROM
|
|
|
|
|
repair_input_details rd
|
|
|
|
|
LEFT JOIN ma_type mt on rd.type_id = mt.type_id and mt.del_flag = '0'
|
|
|
|
|
LEFT JOIN ma_type mt1 on mt.parent_id = mt1.type_id and mt1.del_flag = '0'
|
|
|
|
|
WHERE
|
|
|
|
|
rd.task_id = #{taskId}
|
|
|
|
|
<if test="typeId != null">
|
|
|
|
|
and rd.type_id = #{typeId}
|
|
|
|
|
</if>
|
2024-09-27 15:44:11 +08:00
|
|
|
</select>
|
2024-11-25 14:31:54 +08:00
|
|
|
|
2024-12-19 14:48:12 +08:00
|
|
|
<select id="selectBackIdByTaskId" resultType="java.lang.Long">
|
|
|
|
|
SELECT
|
|
|
|
|
rad.back_id
|
|
|
|
|
FROM
|
|
|
|
|
repair_input_details rid
|
|
|
|
|
LEFT JOIN repair_apply_details rad ON rid.repair_id = rad.id
|
|
|
|
|
WHERE
|
|
|
|
|
rid.task_id = #{taskId}
|
|
|
|
|
</select>
|
|
|
|
|
|
2024-12-20 19:46:20 +08:00
|
|
|
<select id="selectRepairDetails" resultType="com.bonus.common.biz.domain.repair.RepairInputDetails">
|
|
|
|
|
SELECT
|
|
|
|
|
rd.task_id AS taskId,
|
|
|
|
|
rd.type_id AS typeId,
|
|
|
|
|
rd.repair_num AS repairNum,
|
|
|
|
|
rd.input_num AS inputNum,
|
|
|
|
|
SUM((
|
|
|
|
|
IFNULL( rd.repair_num, 0 ) - IFNULL( rd.input_num, 0 ) - IFNULL( rd.reject_num, 0 ))) AS pendingInputNum,
|
|
|
|
|
rd.reject_num AS rejectNum,
|
|
|
|
|
mt.manage_type AS manageType,
|
|
|
|
|
GROUP_CONCAT( mm.ma_code ) AS maCode
|
|
|
|
|
FROM
|
|
|
|
|
repair_input_details rd
|
|
|
|
|
LEFT JOIN ma_type mt ON rd.type_id = mt.type_id
|
|
|
|
|
AND mt.del_flag = '0'
|
|
|
|
|
LEFT JOIN ma_type mt1 ON mt.parent_id = mt1.type_id
|
|
|
|
|
AND mt1.del_flag = '0'
|
|
|
|
|
LEFT JOIN ma_machine mm ON mm.ma_id = rd.ma_id
|
|
|
|
|
WHERE
|
|
|
|
|
rd.task_id IN
|
|
|
|
|
<foreach item="id" collection="list" open="(" separator="," close=")">
|
|
|
|
|
#{id}
|
|
|
|
|
</foreach>
|
|
|
|
|
GROUP BY
|
|
|
|
|
mt.type_id
|
|
|
|
|
</select>
|
|
|
|
|
|
2024-12-20 16:39:22 +08:00
|
|
|
<insert id="batchInsertRepairInputDetails" parameterType="com.bonus.common.biz.domain.repair.RepairInputDetails">
|
2024-11-25 14:31:54 +08:00
|
|
|
insert into repair_input_details
|
|
|
|
|
(task_id, audit_id, repair_id, ma_id, type_id, repair_num, input_num, create_by, create_time,
|
|
|
|
|
status, remark, company_id)
|
|
|
|
|
values
|
|
|
|
|
<foreach collection="list" item="item" separator=",">
|
|
|
|
|
(#{item.taskId,jdbcType=INTEGER}, #{item.auditId,jdbcType=INTEGER}, #{item.repairId,jdbcType=INTEGER},
|
|
|
|
|
#{item.maId,jdbcType=INTEGER}, #{item.typeId,jdbcType=INTEGER}, #{item.repairNum,jdbcType=INTEGER},
|
|
|
|
|
#{item.inputNum,jdbcType=INTEGER},
|
|
|
|
|
#{item.createBy,jdbcType=VARCHAR}, NOW(), #{item.status,jdbcType=VARCHAR},
|
|
|
|
|
#{item.remark,jdbcType=VARCHAR}, #{item.companyId,jdbcType=INTEGER})
|
|
|
|
|
</foreach>
|
|
|
|
|
</insert>
|
2024-09-27 15:44:11 +08:00
|
|
|
|
2024-12-20 16:39:22 +08:00
|
|
|
<insert id="insertRepairInputDetails" parameterType="com.bonus.common.biz.domain.repair.RepairInputDetails" useGeneratedKeys="true" keyProperty="id">
|
2024-09-27 15:44:11 +08:00
|
|
|
insert into repair_input_details
|
|
|
|
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
|
|
|
|
<if test="taskId != null">task_id,</if>
|
|
|
|
|
<if test="auditId != null">audit_id,</if>
|
|
|
|
|
<if test="repairId != null">repair_id,</if>
|
|
|
|
|
<if test="maId != null">ma_id,</if>
|
|
|
|
|
<if test="typeId != null">type_id,</if>
|
|
|
|
|
<if test="repairNum != null">repair_num,</if>
|
|
|
|
|
<if test="inputNum != null">input_num,</if>
|
|
|
|
|
<if test="createBy != null">create_by,</if>
|
2024-11-25 14:31:54 +08:00
|
|
|
create_time,
|
2024-09-27 15:44:11 +08:00
|
|
|
<if test="status != null">status,</if>
|
|
|
|
|
<if test="remark != null">remark,</if>
|
|
|
|
|
<if test="companyId != null">company_id,</if>
|
|
|
|
|
</trim>
|
|
|
|
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
|
|
|
|
<if test="taskId != null">#{taskId},</if>
|
|
|
|
|
<if test="auditId != null">#{auditId},</if>
|
|
|
|
|
<if test="repairId != null">#{repairId},</if>
|
|
|
|
|
<if test="maId != null">#{maId},</if>
|
|
|
|
|
<if test="typeId != null">#{typeId},</if>
|
|
|
|
|
<if test="repairNum != null">#{repairNum},</if>
|
|
|
|
|
<if test="inputNum != null">#{inputNum},</if>
|
|
|
|
|
<if test="createBy != null">#{createBy},</if>
|
2024-11-25 14:31:54 +08:00
|
|
|
NOW(),
|
2024-09-27 15:44:11 +08:00
|
|
|
<if test="status != null">#{status},</if>
|
|
|
|
|
<if test="remark != null">#{remark},</if>
|
|
|
|
|
<if test="companyId != null">#{companyId},</if>
|
|
|
|
|
</trim>
|
|
|
|
|
</insert>
|
|
|
|
|
|
2024-12-13 17:25:52 +08:00
|
|
|
<insert id="insertRad">
|
|
|
|
|
insert into repair_apply_details
|
|
|
|
|
(
|
|
|
|
|
<if test="taskId != null">
|
|
|
|
|
task_id,
|
|
|
|
|
</if>
|
|
|
|
|
<if test="maId != null">
|
|
|
|
|
ma_id,
|
|
|
|
|
</if>
|
|
|
|
|
<if test="typeId != null">
|
|
|
|
|
type_id,
|
|
|
|
|
</if>
|
|
|
|
|
<if test="rejectNum != null">
|
|
|
|
|
repair_num,
|
|
|
|
|
</if>
|
|
|
|
|
status,
|
|
|
|
|
<if test="createBy != null and createBy != ''">
|
|
|
|
|
create_by,
|
|
|
|
|
</if>
|
|
|
|
|
<if test="remark != null and remark != ''">
|
|
|
|
|
remark,
|
|
|
|
|
</if>
|
|
|
|
|
<if test="companyId != null">
|
|
|
|
|
company_id,
|
|
|
|
|
</if>
|
2024-12-19 14:48:12 +08:00
|
|
|
<if test="backId != null">
|
|
|
|
|
back_id,
|
|
|
|
|
</if>
|
2024-12-13 17:25:52 +08:00
|
|
|
create_time
|
|
|
|
|
)
|
|
|
|
|
values (
|
|
|
|
|
<if test="taskId != null">
|
|
|
|
|
#{taskId},
|
|
|
|
|
</if>
|
|
|
|
|
<if test="maId != null">
|
|
|
|
|
#{maId},
|
|
|
|
|
</if>
|
|
|
|
|
<if test="typeId != null">
|
|
|
|
|
#{typeId},
|
|
|
|
|
</if>
|
|
|
|
|
<if test="rejectNum != null">
|
|
|
|
|
#{rejectNum},
|
|
|
|
|
</if>
|
|
|
|
|
0,
|
|
|
|
|
<if test="createBy != null and createBy != ''">
|
|
|
|
|
#{createBy},
|
|
|
|
|
</if>
|
|
|
|
|
<if test="remark != null and remark != ''">
|
|
|
|
|
#{remark},
|
|
|
|
|
</if>
|
|
|
|
|
<if test="companyId != null">
|
|
|
|
|
#{companyId},
|
|
|
|
|
</if>
|
2024-12-19 14:48:12 +08:00
|
|
|
<if test="backId != null">
|
|
|
|
|
#{backId},
|
|
|
|
|
</if>
|
2024-12-13 17:25:52 +08:00
|
|
|
NOW()
|
|
|
|
|
)
|
|
|
|
|
</insert>
|
|
|
|
|
|
2024-12-20 16:39:22 +08:00
|
|
|
<update id="updateRepairInputDetails" parameterType="com.bonus.common.biz.domain.repair.RepairInputDetails">
|
2024-12-13 17:25:52 +08:00
|
|
|
UPDATE repair_input_details
|
|
|
|
|
SET
|
|
|
|
|
<if test="inputNum != null">input_num = IFNULL(input_num, 0) + #{inputNum},</if>
|
|
|
|
|
<if test="rejectNum != null">reject_num = IFNULL(reject_num, 0) + #{rejectNum},</if>
|
|
|
|
|
<if test="rejectReason != null and rejectReason != ''">reject_reason = #{rejectReason},</if>
|
|
|
|
|
update_by = #{updateBy},
|
|
|
|
|
update_time = #{updateTime},
|
|
|
|
|
status = #{status}
|
|
|
|
|
WHERE task_id = #{taskId}
|
|
|
|
|
and type_id = #{typeId}
|
|
|
|
|
<if test="maId != null">
|
|
|
|
|
and ma_id = #{maId}
|
|
|
|
|
</if>
|
|
|
|
|
</update>
|
|
|
|
|
|
|
|
|
|
<update id="updateNum">
|
|
|
|
|
UPDATE ma_type
|
|
|
|
|
SET storage_num = #{inputNum} + IFNULL(storage_num, 0)
|
|
|
|
|
WHERE
|
|
|
|
|
type_id = #{typeId}
|
|
|
|
|
</update>
|
|
|
|
|
|
|
|
|
|
<update id="updateMaStatus">
|
|
|
|
|
UPDATE ma_machine
|
|
|
|
|
SET ma_status = #{status}
|
|
|
|
|
WHERE
|
|
|
|
|
ma_id = #{maId}
|
2024-09-27 15:44:11 +08:00
|
|
|
</update>
|
|
|
|
|
|
|
|
|
|
<delete id="deleteRepairInputDetailsById" parameterType="Long">
|
|
|
|
|
delete from repair_input_details where id = #{id}
|
|
|
|
|
</delete>
|
|
|
|
|
|
2024-11-25 17:03:11 +08:00
|
|
|
<delete id="deleteRepairInputDetailsByTaskId" parameterType="Long">
|
|
|
|
|
delete from repair_input_details where task_id = #{taskId}
|
|
|
|
|
</delete>
|
|
|
|
|
|
2024-09-27 15:44:11 +08:00
|
|
|
<delete id="deleteRepairInputDetailsByIds" parameterType="String">
|
|
|
|
|
delete from repair_input_details where id in
|
|
|
|
|
<foreach item="id" collection="array" open="(" separator="," close=")">
|
|
|
|
|
#{id}
|
|
|
|
|
</foreach>
|
|
|
|
|
</delete>
|
|
|
|
|
</mapper>
|