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

    <select id="selectSKcCrkDcddStorepurchaseorderList" parameterType="pd" resultType="pd">
        select * from s_kc_crk_dcdd_storepurchaseorder where 1=1
        <if test="storeShortName !=null and storeShortName !='' ">
            and storeShortName = #{storeShortName}
        </if>
        <if test="purchaseOrderNumber !=null and purchaseOrderNumber !='' ">
            and purchaseOrderNumber = #{purchaseOrderNumber}
        </if>
        <if test="purchaseRequestNumber !=null and purchaseRequestNumber !='' ">
            and purchaseRequestNumber = #{purchaseRequestNumber}
        </if>
        <if test="productSupplier !=null and productSupplier !='' ">
            and productSupplier = #{productSupplier}
        </if>
        <if test="documentStatus !=null and documentStatus !='' ">
            and documentStatus = #{documentStatus}
        </if>
        <if test="totalCostAmount !=null and totalCostAmount !='' ">
            and totalCostAmount = #{totalCostAmount}
        </if>
        <if test="headquartersConfirmationTime !=null and headquartersConfirmationTime !='' ">
            and headquartersConfirmationTime = #{headquartersConfirmationTime}
        </if>
    </select>


    <update id="updateSKcCrkDcddStorepurchaseorder" parameterType="pd" >
        update s_kc_crk_dcdd_storepurchaseorder
        <trim prefix=" SET " suffix="" prefixOverrides="," suffixOverrides=",">
        <if test="storeShortName !=null and storeShortName !='' ">
            storeShortName = #{storeShortName},
        </if>
        <if test="purchaseOrderNumber !=null and purchaseOrderNumber !='' ">
            purchaseOrderNumber = #{purchaseOrderNumber},
        </if>
        <if test="purchaseRequestNumber !=null and purchaseRequestNumber !='' ">
            purchaseRequestNumber = #{purchaseRequestNumber},
        </if>
        <if test="productSupplier !=null and productSupplier !='' ">
            productSupplier = #{productSupplier},
        </if>
        <if test="documentStatus !=null and documentStatus !='' ">
            documentStatus = #{documentStatus},
        </if>
        <if test="totalCostAmount !=null and totalCostAmount !='' ">
            totalCostAmount = #{totalCostAmount},
        </if>
        <if test="headquartersConfirmationTime !=null and headquartersConfirmationTime !='' ">
            headquartersConfirmationTime = #{headquartersConfirmationTime},
        </if>
        </trim>
        <if test="up != null and up!=''">
            <if test="id != null and id!=''">
                where id=#{id}
            </if>
        </if>
    </update>

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

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

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

        <if test="storeShortName !=null and storeShortName !='' ">
            storeShortName,
        </if>
        <if test="purchaseOrderNumber !=null and purchaseOrderNumber !='' ">
            purchaseOrderNumber,
        </if>
        <if test="purchaseRequestNumber !=null and purchaseRequestNumber !='' ">
            purchaseRequestNumber,
        </if>
        <if test="productSupplier !=null and productSupplier !='' ">
            productSupplier,
        </if>
        <if test="documentStatus !=null and documentStatus !='' ">
            documentStatus,
        </if>
        <if test="totalCostAmount !=null and totalCostAmount !='' ">
            totalCostAmount,
        </if>
        <if test="headquartersConfirmationTime !=null and headquartersConfirmationTime !='' ">
            headquartersConfirmationTime,
        </if>
        </trim>
        <trim prefix=" VALUES (" suffix=")" prefixOverrides="," suffixOverrides=",">
        <if test="storeShortName !=null and storeShortName !='' ">
             #{storeShortName},
        </if>
        <if test="purchaseOrderNumber !=null and purchaseOrderNumber !='' ">
             #{purchaseOrderNumber},
        </if>
        <if test="purchaseRequestNumber !=null and purchaseRequestNumber !='' ">
             #{purchaseRequestNumber},
        </if>
        <if test="productSupplier !=null and productSupplier !='' ">
             #{productSupplier},
        </if>
        <if test="documentStatus !=null and documentStatus !='' ">
             #{documentStatus},
        </if>
        <if test="totalCostAmount !=null and totalCostAmount !='' ">
             #{totalCostAmount},
        </if>
        <if test="headquartersConfirmationTime !=null and headquartersConfirmationTime !='' ">
             #{headquartersConfirmationTime},
        </if>
        </trim>

    </insert>

</mapper>
