<?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.yunfeiyun.agmp.fms.mapper.MppQualitycheckMapper">
    
    <resultMap type="MppQualitycheck" id="MppQualitycheckResult">
        <result property="qualitycheckId"    column="qualitycheckId"    />
        <result property="finishgoodsId"    column="finishgoodsId"    />
        <result property="qualitycheckCreator"    column="qualitycheckCreator"    />
        <result property="qualitycheckCreateddate"    column="qualitycheckCreateddate"    />
        <result property="qualitycheckOrg"    column="qualitycheckOrg"    />
    </resultMap>

    <sql id="selectMppQualitycheckVo">
        select qualitycheckId, finishgoodsId, qualitycheckCreator, qualitycheckCreateddate, qualitycheckOrg, qualitycheckInspectdate, qualityRemark from MppQualitycheck
    </sql>

    <select id="selectMppQualitycheckList" parameterType="MppQualitycheck" resultMap="MppQualitycheckResult">
        <include refid="selectMppQualitycheckVo"/>
        <where>  
            <if test="finishgoodsId != null  and finishgoodsId != ''"> and finishgoodsId = #{finishgoodsId}</if>
            <if test="qualitycheckCreator != null  and qualitycheckCreator != ''"> and qualitycheckCreator = #{qualitycheckCreator}</if>
            <if test="qualitycheckCreateddate != null  and qualitycheckCreateddate != ''"> and qualitycheckCreateddate = #{qualitycheckCreateddate}</if>
            <if test="qualitycheckOrg != null  and qualitycheckOrg != ''"> and qualitycheckOrg = #{qualitycheckOrg}</if>
        </where>
    </select>
    
    <select id="selectMppQualitycheckByQualitycheckId" parameterType="String" resultMap="MppQualitycheckResult">
        <include refid="selectMppQualitycheckVo"/>
        where qualitycheckId = #{qualitycheckId}
    </select>
        
    <insert id="insertMppQualitycheck" parameterType="MppQualitycheck">
        insert into MppQualitycheck
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="qualitycheckId != null">qualitycheckId,</if>
            <if test="finishgoodsId != null">finishgoodsId,</if>
            <if test="qualitycheckCreator != null">qualitycheckCreator,</if>
            <if test="qualitycheckCreateddate != null">qualitycheckCreateddate,</if>
            <if test="qualitycheckOrg != null">qualitycheckOrg,</if>
            <if test="qualitycheckInspectdate != null">qualitycheckInspectdate,</if>
            <if test="qualityRemark != null">qualityRemark,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="qualitycheckId != null">#{qualitycheckId},</if>
            <if test="finishgoodsId != null">#{finishgoodsId},</if>
            <if test="qualitycheckCreator != null">#{qualitycheckCreator},</if>
            <if test="qualitycheckCreateddate != null">#{qualitycheckCreateddate},</if>
            <if test="qualitycheckOrg != null">#{qualitycheckOrg},</if>
            <if test="qualitycheckInspectdate != null">#{qualitycheckInspectdate},</if>
            <if test="qualityRemark != null">#{qualityRemark},</if>
         </trim>
    </insert>

    <insert id="insertMppQualitycheckBatch" parameterType="MppQualitycheck">
        insert into MppQualitycheck
        <trim prefix="(" suffix=")" suffixOverrides=",">
            qualitycheckId,
            finishgoodsId,
            qualitycheckCreator,
            qualitycheckCreateddate,
            qualitycheckOrg,
            qualitycheckInspectdate,
            qualityRemark,
        </trim>
        values
        <foreach item="data" collection="list" separator=",">
            (
            #{data.qualitycheckId},
            #{data.finishgoodsId},
            #{data.qualitycheckCreator},
            #{data.qualitycheckCreateddate},
            #{data.qualitycheckOrg},
            #{data.qualitycheckInspectdate},
            #{data.qualityRemark}
            )
        </foreach>
    </insert>

    <update id="updateMppQualitycheck" parameterType="MppQualitycheck">
        update MppQualitycheck
        <trim prefix="SET" suffixOverrides=",">
            <if test="finishgoodsId != null">finishgoodsId = #{finishgoodsId},</if>
            <if test="qualitycheckCreator != null">qualitycheckCreator = #{qualitycheckCreator},</if>
            <if test="qualitycheckCreateddate != null">qualitycheckCreateddate = #{qualitycheckCreateddate},</if>
            <if test="qualitycheckOrg != null">qualitycheckOrg = #{qualitycheckOrg},</if>
            <if test="qualitycheckInspectdate != null">qualitycheckInspectdate = #{qualitycheckInspectdate},</if>
            <if test="qualityRemark != null">qualityRemark = #{qualityRemark},</if>
        </trim>
        where qualitycheckId = #{qualitycheckId}
    </update>

    <delete id="deleteMppQualitycheckByQualitycheckId" parameterType="String">
        delete from MppQualitycheck where qualitycheckId = #{qualitycheckId}
    </delete>

    <delete id="deleteMppQualitycheckByQualitycheckIds" parameterType="String">
        delete from MppQualitycheck where qualitycheckId in 
        <foreach item="qualitycheckId" collection="array" open="(" separator="," close=")">
            #{qualitycheckId}
        </foreach>
    </delete>
</mapper>