You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

234 lines
10 KiB
XML

3 months ago
<?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.op.quality.mapper.QcCheckSampleTaskMapper">
<resultMap type="com.op.quality.domain.QcCheckSampleTask" id="QcCheckSampleDefectResult">
<result property="materialName" column="material_name"/>
<result property="incomeBatchNo" column="income_batch_no"/>
<result property="workOrderCodeSap" column="work_order_code_sap"/>
<result property="sampleTime" column="sample_time"/>
<result property="sampleNum" column="sample_Num"/>
<result property="sampleAddress" column="sample_address"/>
<result property="firstCheckUserCode" column="first_check_user_code"/>
<result property="firstCheckUserName" column="first_check_user_name"/>
<result property="firstCheckResult" column="first_check_result"/>
<result property="firstCheckTime" column="first_check_time"/>
<result property="secondCheckUserCode" column="second_check_user_code"/>
<result property="secondCheckUserName" column="second_check_user_name"/>
<result property="secondCheckResult" column="second_check_result"/>
<result property="secondCheckTime" column="second_check_time"/>
<result property="thirdCheckUserCode" column="third_check_user_code"/>
<result property="thirdCheckUserName" column="third_check_user_name"/>
<result property="thirdCheckResult" column="third_check_result"/>
<result property="thirdCheckTime" column="third_check_time"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
<result property="updateBy" column="update_by"/>
<result property="updateTime" column="update_time"/>
</resultMap>
<select id="selectQcCheckSampleTaskList" parameterType="com.op.quality.domain.query.QcCheckSampleTaskQuery"
resultMap="QcCheckSampleDefectResult">
select
id,
material_name,
income_batch_no,
work_order_code_sap,
sample_time,
sample_num,
sample_address,
first_check_user_code,
first_check_user_name,
first_check_result,
first_check_time,
second_check_user_code,
second_check_user_name,
second_check_result,
second_check_time,
third_check_user_code,
third_check_user_name,
third_check_result,
third_check_time
from qc_check_sample_task
<where>
<if test="queryDate != null and queryDate != ''">
and CONVERT(VARCHAR(10), create_time ,23) <![CDATA[ = ]]> #{queryDate}
</if>
<if test="startSampleDate != null and startSampleDate != ''">
and CONVERT(VARCHAR(10), sample_time ,23) <![CDATA[ >= ]]> #{startSampleDate}
</if>
<if test="endSampleDate != null and endSampleDate != ''">
and CONVERT(VARCHAR(10), sample_time ,23) <![CDATA[ <= ]]> #{endSampleDate}
</if>
<if test="materialName != null and materialName != ''">
and material_name like concat('%', #{materialName}, '%')
</if>
<if test="workOrderCodeSap != null and workOrderCodeSap != ''">
and work_order_code_sap <![CDATA[ = ]]> #{workOrderCodeSap}
</if>
</where>
order by sample_time desc,create_time desc
</select>
<select id="selectQcWaitCheckSampleTaskList" parameterType="com.op.quality.domain.query.QcCheckSampleTaskQuery"
resultMap="QcCheckSampleDefectResult">
select
id, material_name, income_batch_no, work_order_code_sap, sample_time,
first_check_user_code, first_check_user_name, first_check_result, first_check_time,
second_check_user_code, second_check_user_name, second_check_result, second_check_time,
third_check_user_code, third_check_user_name, third_check_result, third_check_time
from qc_check_sample_task
<where>
<if test="firstDate != null and firstDate != ''">
and CONVERT(VARCHAR(10), sample_time ,23) <![CDATA[ <= ]]> #{firstDate}
and first_check_result is null
</if>
</where>
UNION
select
id, material_name, income_batch_no, work_order_code_sap, sample_time,
first_check_user_code, first_check_user_name, first_check_result, first_check_time,
second_check_user_code, second_check_user_name, second_check_result, second_check_time,
third_check_user_code, third_check_user_name, third_check_result, third_check_time
from qc_check_sample_task
<where>
<if test="secondDate != null and secondDate != ''">
and CONVERT(VARCHAR(10), sample_time ,23) <![CDATA[ <= ]]> #{secondDate}
and second_check_result is null
</if>
</where>
UNION
select
id, material_name, income_batch_no, work_order_code_sap, sample_time,
first_check_user_code, first_check_user_name, first_check_result, first_check_time,
second_check_user_code, second_check_user_name, second_check_result, second_check_time,
third_check_user_code, third_check_user_name, third_check_result, third_check_time
from qc_check_sample_task
<where>
<if test="thirdDate != null and thirdDate != ''">
and CONVERT(VARCHAR(10), sample_time ,23) <![CDATA[ <= ]]> #{thirdDate}
and third_check_result is null
</if>
</where>
</select>
<update id="updateQcCheckSampleTask" parameterType="com.op.quality.domain.QcCheckSampleTask">
update qc_check_sample_task
<set>
<if test="sampleTime != null">
sample_time = #{sampleTime},
</if>
<if test="sampleNum != null">
sample_Num = #{sampleNum},
</if>
<if test="sampleAddress != null">
sample_Address = #{sampleAddress},
</if>
<if test="firstCheckUserCode != null and firstCheckUserCode != ''">
first_check_user_code = #{firstCheckUserCode},
</if>
<if test="firstCheckUserName != null and firstCheckUserName != ''">
first_check_user_name = #{firstCheckUserName},
</if>
<if test="firstCheckResult != null and firstCheckResult != ''">
first_check_result = #{firstCheckResult},
</if>
<if test="firstCheckTime != null and firstCheckTime != ''">
first_check_time = #{firstCheckTime},
</if>
<if test="secondCheckUserCode != null and secondCheckUserCode != ''">
second_check_user_code = #{secondCheckUserCode},
</if>
<if test="secondCheckUserName != null and secondCheckUserName != ''">
second_check_user_name = #{secondCheckUserName},
</if>
<if test="secondCheckResult != null and secondCheckResult != ''">
second_check_result = #{secondCheckResult},
</if>
<if test="secondCheckTime != null and secondCheckTime != ''">
second_check_time = #{secondCheckTime},
</if>
<if test="thirdCheckUserCode != null and thirdCheckUserCode != ''">
third_check_user_code = #{thirdCheckUserCode},
</if>
<if test="thirdCheckUserName != null and thirdCheckUserName != ''">
third_check_user_name = #{thirdCheckUserName},
</if>
<if test="thirdCheckResult != null and thirdCheckResult != ''">
third_check_result = #{thirdCheckResult},
</if>
<if test="thirdCheckTime != null and thirdCheckTime != ''">
third_check_time = #{thirdCheckTime},
</if>
update_time = getDate()
</set>
where id = #{id}
</update>
<select id="selectScTaskListByDay" resultMap="QcCheckSampleDefectResult">
SELECT
t.material_name AS material_name,
CASE
WHEN
LEN( income_batch_no ) = 24
THEN
SUBSTRING ( t.income_batch_no, 9, 24 )
WHEN
LEN( income_batch_no ) <![CDATA[ <= ]]> 24
THEN
CONVERT ( VARCHAR ( 8 ), create_time, 112 )
WHEN
LEN( income_batch_no ) > 24
THEN income_batch_no
ELSE ''
END AS income_batch_no,
t.create_time AS create_time,
t.workorderCodeSap AS workOrderCodeSap
FROM
(
SELECT
qct.income_batch_no,
qct.material_name,
qct.create_time,
SUBSTRING ( pow.workorder_code_sap, 4, 12 ) AS workorderCodeSap,
ROW_NUMBER ( ) OVER ( PARTITION BY qct.material_name, SUBSTRING ( pow.workorder_code_sap, 4, 12 ) ORDER BY qct.create_time ASC ) AS RowNum
FROM
qc_check_task qct
LEFT JOIN pro_order_workorder pow ON pow.workorder_code = qct.order_no
WHERE
pow.workorder_code_sap IS NOT NULL
AND qct.income_batch_no IS NOT NULL
AND qct.check_type = 'checkTypeSC'
) t
WHERE t.RowNum = 1 AND CONVERT(VARCHAR(10), t.create_time ,23) >= CONVERT(VARCHAR(10), getDate() ,23)
ORDER BY t.create_time DESC
</select>
<insert id="batchInsertQcCheckSampleTask" parameterType="com.op.quality.domain.QcCheckSampleTask">
INSERT INTO qc_check_sample_task (
id,
material_name,
income_batch_no,
work_order_code_sap,
create_time
)
VALUES
<foreach collection="list" item="item" separator=",">
(
#{item.id},
#{item.materialName},
#{item.incomeBatchNo},
#{item.workOrderCodeSap},
#{item.createTime}
)
</foreach>
</insert>
</mapper>