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.
LanJu_Mes/op-modules/op-quality/src/main/resources/mapper/quality/QcCheckTaskDefectMapper.xml

163 lines
8.2 KiB
XML

<?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.QcCheckTaskDefectMapper">
<resultMap type="QcCheckTaskDefect" id="QcCheckTaskDefectResult">
<result property="recordId" column="record_id"/>
<result property="defectCode" column="defect_code"/>
<result property="defectSubclass" column="defect_subclass"/>
<result property="attr1" column="attr1"/>
<result property="attr2" column="attr2"/>
<result property="attr3" column="attr3"/>
<result property="attr4" column="attr4"/>
<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="factoryCode" column="factory_code"/>
<result property="delFlag" column="del_flag"/>
<result property="belongTo" column="belong_to"/>
<result property="okQuality" column="ok_quality"/>
<result property="noOkQuality" column="noOk_quality"/>
</resultMap>
<sql id="selectQcCheckTaskDefectVo">
select record_id, defect_code, defect_subclass, attr1, attr2, attr3, attr4, create_by, create_time, update_by, update_time, factory_code, del_flag, belong_to, ok_quality, noOk_quality from qc_check_task_defect
</sql>
<select id="selectQcCheckTaskDefectList" parameterType="QcCheckTaskDefect" resultMap="QcCheckTaskDefectResult">
<include refid="selectQcCheckTaskDefectVo"/>
<where>
<if test="defectCode != null and defectCode != ''">and defect_code = #{defectCode}</if>
<if test="defectSubclass != null and defectSubclass != ''">and defect_subclass = #{defectSubclass}</if>
<if test="attr1 != null and attr1 != ''">and attr1 = #{attr1}</if>
<if test="attr2 != null and attr2 != ''">and attr2 = #{attr2}</if>
<if test="attr3 != null and attr3 != ''">and attr3 = #{attr3}</if>
<if test="attr4 != null and attr4 != ''">and attr4 = #{attr4}</if>
<if test="factoryCode != null and factoryCode != ''">and factory_code = #{factoryCode}</if>
<if test="belongTo != null and belongTo != ''">and belong_to = #{belongTo}</if>
<if test="okQuality != null ">and ok_quality = #{okQuality}</if>
<if test="noOkQuality != null ">and noOk_quality = #{noOkQuality}</if>
</where>
</select>
<select id="selectQcCheckTaskDefectByRecordId" parameterType="String" resultMap="QcCheckTaskDefectResult">
<include refid="selectQcCheckTaskDefectVo"/>
where record_id = #{recordId}
</select>
<insert id="insertQcCheckTaskDefect" parameterType="QcCheckTaskDefect">
insert into qc_check_task_defect
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="recordId != null">record_id,</if>
<if test="defectCode != null">defect_code,</if>
<if test="defectSubclass != null">defect_subclass,</if>
<if test="attr1 != null">attr1,</if>
<if test="attr2 != null">attr2,</if>
<if test="attr3 != null">attr3,</if>
<if test="attr4 != null">attr4,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="factoryCode != null and factoryCode != ''">factory_code,</if>
<if test="delFlag != null">del_flag,</if>
<if test="belongTo != null">belong_to,</if>
<if test="okQuality != null">ok_quality,</if>
<if test="noOkQuality != null">noOk_quality,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="recordId != null">#{recordId},</if>
<if test="defectCode != null">#{defectCode},</if>
<if test="defectSubclass != null">#{defectSubclass},</if>
<if test="attr1 != null">#{attr1},</if>
<if test="attr2 != null">#{attr2},</if>
<if test="attr3 != null">#{attr3},</if>
<if test="attr4 != null">#{attr4},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="factoryCode != null and factoryCode != ''">#{factoryCode},</if>
<if test="delFlag != null">#{delFlag},</if>
<if test="belongTo != null">#{belongTo},</if>
<if test="okQuality != null">#{okQuality},</if>
<if test="noOkQuality != null">#{noOkQuality},</if>
</trim>
</insert>
<update id="updateQcCheckTaskDefect" parameterType="QcCheckTaskDefect">
update qc_check_task_defect
<trim prefix="SET" suffixOverrides=",">
<if test="defectCode != null">defect_code = #{defectCode},</if>
<if test="defectSubclass != null">defect_subclass = #{defectSubclass},</if>
<if test="attr1 != null">attr1 = #{attr1},</if>
<if test="attr2 != null">attr2 = #{attr2},</if>
<if test="attr3 != null">attr3 = #{attr3},</if>
<if test="attr4 != null">attr4 = #{attr4},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="factoryCode != null and factoryCode != ''">factory_code = #{factoryCode},</if>
<if test="delFlag != null">del_flag = #{delFlag},</if>
<if test="belongTo != null">belong_to = #{belongTo},</if>
<if test="okQuality != null">ok_quality = #{okQuality},</if>
<if test="noOkQuality != null">noOk_quality = #{noOkQuality},</if>
</trim>
where record_id = #{recordId}
</update>
<delete id="deleteQcCheckTaskDefectByRecordId" parameterType="String">
delete from qc_check_task_defect where record_id = #{recordId}
</delete>
<delete id="deleteQcCheckTaskDefectByRecordIds" parameterType="String">
delete from qc_check_task_defect where record_id in
<foreach item="recordId" collection="array" open="(" separator="," close=")">
#{recordId}
</foreach>
</delete>
<delete id="deleteQcCheckTaskDefectByBelongTo" parameterType="String">
delete from qc_check_task_defect where belong_to = #{belongTo}
</delete>
<select id="selectDefectByBelongTo" parameterType="QcCheckTaskDefect" resultMap="QcCheckTaskDefectResult">
<include refid="selectQcCheckTaskDefectVo"/>
where belong_to = #{belongTo}
order by defect_code
</select>
<select id="getDefectMap" resultType="com.op.quality.domain.QcCheckTaskDefect">
SELECT
belong_to,
belong_to_detail belongToDetail,
STUFF(
(SELECT ',' + defect_code
FROM qc_check_task_defect
WHERE belong_to_detail = qctd.belong_to_detail and belong_to = qctd.belong_to
FOR xml path('')
),1,1,''
) defectCodes,
STUFF(
(SELECT ',' + defect_subclass+':' + CAST(noOk_quality AS VARCHAR(15))
FROM qc_check_task_defect
WHERE belong_to_detail = qctd.belong_to_detail and belong_to = qctd.belong_to
FOR xml path('')
),1,1,''
) defectNames,
STUFF(
(SELECT ',' + CAST(noOk_quality AS VARCHAR(15))
FROM qc_check_task_defect
WHERE belong_to_detail = qctd.belong_to_detail and belong_to = qctd.belong_to
FOR xml path('')
),1,1,''
) defectQualitys
FROM qc_check_task_defect qctd where qctd.del_flag = '0' and belong_to= #{belongTo}
GROUP by qctd.belong_to,qctd.belong_to_detail
</select>
</mapper>