<?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="SKcKnAdjustmentdocumentMapper" >
    <!-- 通用查询映射结果 -->

    <select id="selectSKcKnAdjustmentdocumentList" parameterType="pd" resultType="pd">
        select * from s_kc_kn_adjustmentdocument where 1=1
        <if test="serialNumber !=null and serialNumber !='' ">
            and serialNumber = #{serialNumber}
        </if>
        <if test="documentNumber !=null and documentNumber !='' ">
            and documentNumber = #{documentNumber}
        </if>
        <if test="storeName !=null and storeName !='' ">
            and storeName = #{storeName}
        </if>
        <if test="totalItems !=null and totalItems !='' ">
            and totalItems = #{totalItems}
        </if>
        <if test="damageTotal !=null and damageTotal !='' ">
            and damageTotal = #{damageTotal}
        </if>
        <if test="surplusTotal !=null and surplusTotal !='' ">
            and surplusTotal = #{surplusTotal}
        </if>
        <if test="source !=null and source !='' ">
            and source = #{source}
        </if>
        <if test="applicant !=null and applicant !='' ">
            and applicant = #{applicant}
        </if>
        <if test="applicationTime !=null and applicationTime !='' ">
            and applicationTime = #{applicationTime}
        </if>
        <if test="status !=null and status !='' ">
            and status = #{status}
        </if>
    </select>


    <update id="updateSKcKnAdjustmentdocument" parameterType="pd" >
        update s_kc_kn_adjustmentdocument
        <trim prefix=" SET " suffix="" prefixOverrides="," suffixOverrides=",">
        <if test="serialNumber !=null and serialNumber !='' ">
            serialNumber = #{serialNumber},
        </if>
        <if test="documentNumber !=null and documentNumber !='' ">
            documentNumber = #{documentNumber},
        </if>
        <if test="storeName !=null and storeName !='' ">
            storeName = #{storeName},
        </if>
        <if test="totalItems !=null and totalItems !='' ">
            totalItems = #{totalItems},
        </if>
        <if test="damageTotal !=null and damageTotal !='' ">
            damageTotal = #{damageTotal},
        </if>
        <if test="surplusTotal !=null and surplusTotal !='' ">
            surplusTotal = #{surplusTotal},
        </if>
        <if test="source !=null and source !='' ">
            source = #{source},
        </if>
        <if test="applicant !=null and applicant !='' ">
            applicant = #{applicant},
        </if>
        <if test="applicationTime !=null and applicationTime !='' ">
            applicationTime = #{applicationTime},
        </if>
        <if test="status !=null and status !='' ">
            status = #{status},
        </if>
        </trim>
        <if test="up != null and up!=''">
            <if test="id != null and id!=''">
                where id=#{id}
            </if>
        </if>
    </update>

    <delete id="SKcKnAdjustmentdocumentRemove" parameterType="pd">
        <if test="ids != null">
            delete from s_kc_kn_adjustmentdocument where
            <if test="ids != null">
                id in(${ids})
            </if>
        </if>
    </delete>

    <insert id="addSKcKnAdjustmentdocument" parameterType="pd" >

        insert into s_kc_kn_adjustmentdocument
        <trim prefix="(" suffix=")" prefixOverrides="," suffixOverrides=",">

        <if test="serialNumber !=null and serialNumber !='' ">
            serialNumber,
        </if>
        <if test="documentNumber !=null and documentNumber !='' ">
            documentNumber,
        </if>
        <if test="storeName !=null and storeName !='' ">
            storeName,
        </if>
        <if test="totalItems !=null and totalItems !='' ">
            totalItems,
        </if>
        <if test="damageTotal !=null and damageTotal !='' ">
            damageTotal,
        </if>
        <if test="surplusTotal !=null and surplusTotal !='' ">
            surplusTotal,
        </if>
        <if test="source !=null and source !='' ">
            source,
        </if>
        <if test="applicant !=null and applicant !='' ">
            applicant,
        </if>
        <if test="applicationTime !=null and applicationTime !='' ">
            applicationTime,
        </if>
        <if test="status !=null and status !='' ">
            status,
        </if>
        </trim>
        <trim prefix=" VALUES (" suffix=")" prefixOverrides="," suffixOverrides=",">
        <if test="serialNumber !=null and serialNumber !='' ">
             #{serialNumber},
        </if>
        <if test="documentNumber !=null and documentNumber !='' ">
             #{documentNumber},
        </if>
        <if test="storeName !=null and storeName !='' ">
             #{storeName},
        </if>
        <if test="totalItems !=null and totalItems !='' ">
             #{totalItems},
        </if>
        <if test="damageTotal !=null and damageTotal !='' ">
             #{damageTotal},
        </if>
        <if test="surplusTotal !=null and surplusTotal !='' ">
             #{surplusTotal},
        </if>
        <if test="source !=null and source !='' ">
             #{source},
        </if>
        <if test="applicant !=null and applicant !='' ">
             #{applicant},
        </if>
        <if test="applicationTime !=null and applicationTime !='' ">
             #{applicationTime},
        </if>
        <if test="status !=null and status !='' ">
             #{status},
        </if>
        </trim>

    </insert>

</mapper>
