2023-12-17 13:21:21 +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.material.mapper.RepairTestInputMapper">
|
|
|
|
|
<!--新增入库任务详细表-数据-->
|
|
|
|
|
<insert id="addInputApplyDetails">
|
|
|
|
|
INSERT INTO input_apply_details
|
|
|
|
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
|
|
|
|
<if test="taskId != null and taskId != ''">task_id,</if>
|
|
|
|
|
<if test="maId != null and maId!=''">ma_id,</if>
|
|
|
|
|
<if test="typeId != null and typeId !=''">type_id,</if>
|
|
|
|
|
<if test="repairNum != null and repairNum!=''">input_num,</if>
|
|
|
|
|
input_type,
|
|
|
|
|
<if test="updateBy != null and updateBy != ''">create_by,</if>
|
|
|
|
|
<if test="updateTime != null and updateTime != ''">create_time,</if>
|
|
|
|
|
<if test="updateBy != null and updateBy != ''">update_by,</if>
|
|
|
|
|
<if test="updateTime != null and updateTime != ''">update_time,</if>
|
|
|
|
|
<if test="companyId != null">company_id,</if>
|
|
|
|
|
</trim>
|
|
|
|
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
|
|
|
|
<if test="taskId != null and taskId != ''">#{taskId},</if>
|
|
|
|
|
<if test="maId != null and maId!=''">#{maId},</if>
|
|
|
|
|
<if test="typeId != null and typeId !=''">#{typeId},</if>
|
|
|
|
|
<if test="repairNum != null and repairNum!=''">#{repairNum},</if>
|
|
|
|
|
'3',
|
|
|
|
|
<if test="updateBy != null and updateBy != ''">#{updateBy},</if>
|
|
|
|
|
<if test="updateTime != null and updateTime != ''">#{updateTime},</if>
|
|
|
|
|
<if test="updateBy != null and updateBy != ''">#{updateBy},</if>
|
|
|
|
|
<if test="updateTime != null and updateTime != ''">#{updateTime},</if>
|
|
|
|
|
<if test="companyId != null">#{companyId},</if>
|
|
|
|
|
</trim>
|
|
|
|
|
</insert>
|
|
|
|
|
<!--更新修试后入库-数据-->
|
|
|
|
|
<update id="updateRepairInputDetails">
|
|
|
|
|
UPDATE repair_input_details
|
|
|
|
|
<set>
|
|
|
|
|
<if test="repairNum != null and repairNum != ''">input_num = #{repairNum},</if>
|
|
|
|
|
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
|
2023-12-17 16:10:04 +08:00
|
|
|
<if test="updateTime != null and updateTime != ''">update_time = #{updateTime},</if>
|
2023-12-17 13:21:21 +08:00
|
|
|
<if test="checkType != null and checkType != ''">`status` = #{checkType},</if>
|
|
|
|
|
<if test="remark != null and remark != ''">`remark` = #{remark}</if>
|
|
|
|
|
</set>
|
|
|
|
|
WHERE id = #{id}
|
|
|
|
|
</update>
|
|
|
|
|
<!--更新机具类型-库存数量-->
|
|
|
|
|
<update id="updateMaTypeNum">
|
|
|
|
|
UPDATE ma_type SET num = #{num} WHERE type_id = #{typeId}
|
|
|
|
|
</update>
|
|
|
|
|
<!--管理方式为编号的需更新机具设备的机具状态-->
|
|
|
|
|
<update id="updateMaMachineStatus">
|
|
|
|
|
UPDATE ma_machine SET ma_status = #{dicId} WHERE ma_id = #{maId}
|
|
|
|
|
</update>
|
|
|
|
|
<!--更新任务表状态-->
|
|
|
|
|
<update id="updateTmTaskStatus">
|
2023-12-17 16:10:04 +08:00
|
|
|
UPDATE tm_task SET task_status = #{dictId},update_by = #{params.updateBy},update_time = #{params.updateTime} WHERE task_id = #{params.taskId}
|
2023-12-17 13:21:21 +08:00
|
|
|
</update>
|
|
|
|
|
|
|
|
|
|
<!--获取修试后入库列表-->
|
|
|
|
|
<select id="getRepairedList" resultType="com.bonus.sgzb.material.domain.RepairTestInputVo">
|
|
|
|
|
SELECT ANY_VALUE(rid.task_id) AS id,
|
|
|
|
|
ANY_VALUE(tt.`code`) AS repairCode,
|
|
|
|
|
ANY_VALUE(GROUP_CONCAT(a.typeName)) AS maTypeName,
|
|
|
|
|
ANY_VALUE(tt2.create_by) AS wxName,
|
|
|
|
|
ANY_VALUE(tt2.create_time) AS wxTime,
|
|
|
|
|
ANY_VALUE(IFNULL(sd.`name`,'入库进行中')) AS taskStatus
|
|
|
|
|
FROM repair_input_details rid
|
|
|
|
|
LEFT JOIN tm_task tt ON rid.task_id = tt.task_id
|
|
|
|
|
LEFT JOIN sys_dic sd ON tt.task_status = sd.id
|
|
|
|
|
LEFT JOIN tm_task tt2 ON rid.repair_id = tt2.task_id
|
|
|
|
|
LEFT JOIN (
|
|
|
|
|
SELECT mt.type_id,mt3.type_name AS typeName,mt.manage_type
|
|
|
|
|
FROM ma_type mt
|
|
|
|
|
LEFT JOIN ma_type mt2 ON mt2.type_id = mt.parent_id AND mt2.`level` = '3'
|
|
|
|
|
LEFT JOIN ma_type mt3 ON mt2.parent_id = mt3.type_id AND mt3.`level` = '2'
|
|
|
|
|
LEFT JOIN ma_type mt4 ON mt3.parent_id = mt4.type_id AND mt4.`level` = '1'
|
|
|
|
|
WHERE mt.`level` = '4'
|
|
|
|
|
)a ON rid.type_id = a.type_id
|
|
|
|
|
<where>
|
|
|
|
|
<if test="keyWord!=null and keyWord!=''">
|
|
|
|
|
(
|
|
|
|
|
INSTR(tt.`code`,#{keyWord}) > 0 OR
|
|
|
|
|
INSTR(tt2.create_by,#{keyWord}) > 0
|
|
|
|
|
)
|
|
|
|
|
</if>
|
|
|
|
|
</where>
|
|
|
|
|
GROUP BY rid.task_id
|
2023-12-17 16:10:04 +08:00
|
|
|
ORDER BY tt.create_time DESC
|
2023-12-17 13:21:21 +08:00
|
|
|
</select>
|
|
|
|
|
<!--获取修试后入库-详情列表-->
|
|
|
|
|
<select id="getRepairedDetailList" resultType="com.bonus.sgzb.material.domain.RepairTestInputDetailVo">
|
|
|
|
|
SELECT rid.id,
|
|
|
|
|
rid.ma_id AS maId,
|
|
|
|
|
rid.type_id AS typeId,
|
|
|
|
|
a.typeName,
|
|
|
|
|
a.typeName2,
|
|
|
|
|
rid.repair_num AS repairNum,
|
|
|
|
|
a.manage_type AS manageType,
|
|
|
|
|
mm.ma_code AS maCode,
|
|
|
|
|
rid.update_by AS updateBy,
|
|
|
|
|
rid.update_time AS updateTime,
|
|
|
|
|
rid.remark,
|
|
|
|
|
CASE rid.`status` WHEN '0' THEN '进行中' WHEN '1' THEN '已入库' WHEN '2' THEN '驳回' ELSE '进行中' END AS `status`
|
|
|
|
|
FROM repair_input_details rid
|
|
|
|
|
LEFT JOIN ma_machine mm ON rid.ma_id = mm.ma_id
|
|
|
|
|
LEFT JOIN (
|
|
|
|
|
SELECT mt.type_id,mt.type_name AS typeName,mt2.type_name AS typeName2,mt.manage_type
|
|
|
|
|
FROM ma_type mt
|
|
|
|
|
LEFT JOIN ma_type mt2 ON mt2.type_id = mt.parent_id AND mt2.`level` = '3'
|
|
|
|
|
LEFT JOIN ma_type mt3 ON mt2.parent_id = mt3.type_id AND mt3.`level` = '2'
|
|
|
|
|
LEFT JOIN ma_type mt4 ON mt3.parent_id = mt4.type_id AND mt4.`level` = '1'
|
|
|
|
|
WHERE mt.`level` = '4'
|
|
|
|
|
)a ON rid.type_id = a.type_id
|
|
|
|
|
WHERE rid.task_id = #{taskId}
|
|
|
|
|
<if test="keyWord!=null and keyWord!=''">
|
|
|
|
|
AND (
|
|
|
|
|
INSTR(a.typeName,#{keyWord}) > 0 OR
|
|
|
|
|
INSTR(a.typeName2,#{keyWord}) > 0
|
|
|
|
|
)
|
|
|
|
|
</if>
|
2023-12-17 16:10:04 +08:00
|
|
|
<if test="status!=null and status!=''">
|
|
|
|
|
AND rid.status = #{status}
|
|
|
|
|
</if>
|
|
|
|
|
ORDER BY rid.create_time DESC
|
2023-12-17 13:21:21 +08:00
|
|
|
</select>
|
|
|
|
|
<!--查询机具类型-库存数量-->
|
|
|
|
|
<select id="getMaTypeByNum" resultType="java.util.Map">
|
|
|
|
|
SELECT type_name AS typeName,
|
|
|
|
|
num
|
|
|
|
|
FROM ma_type WHERE type_id = #{typeId}
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<!--查询机具状态-在库的id-->
|
|
|
|
|
<select id="getDicByMaStatusId" resultType="java.lang.Integer">
|
|
|
|
|
SELECT sd2.id,sd2.`name`
|
|
|
|
|
FROM sys_dic sd
|
|
|
|
|
LEFT JOIN sys_dic sd2 ON sd.id = sd2.p_id AND sd2.`name` = #{status}
|
|
|
|
|
WHERE sd.`value` = #{maStatus} AND sd.p_id = 0
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<!--查询修试后入库的状态是否全部更新-->
|
|
|
|
|
<select id="getIsAllUpdate" resultType="java.util.Map">
|
|
|
|
|
SELECT COUNT(IF(status = '0' OR status IS NULL OR status = '',1,NULL)) AS noCheckNum,
|
|
|
|
|
COUNT(IF(status = '1',1,NULL)) AS passNum,
|
|
|
|
|
COUNT(IF(status = '2',1,NULL)) AS noPassNum,
|
|
|
|
|
COUNT(*) AS totalNum
|
|
|
|
|
FROM repair_input_details WHERE task_id = #{taskId}
|
|
|
|
|
</select>
|
|
|
|
|
</mapper>
|