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

    <select id="selectSKcBbSalesanddispensingList" parameterType="pd" resultType="pd">
        select * from s_kc_bb_salesanddispensing where 1=1
        <if test="saleDate !=null and saleDate !='' ">
            and saleDate = #{saleDate}
        </if>
        <if test="productName !=null and productName !='' ">
            and productName = #{productName}
        </if>
        <if test="genericName !=null and genericName !='' ">
            and genericName = #{genericName}
        </if>
        <if test="productCode !=null and productCode !='' ">
            and productCode = #{productCode}
        </if>
        <if test="saleDocumentNumber !=null and saleDocumentNumber !='' ">
            and saleDocumentNumber = #{saleDocumentNumber}
        </if>
        <if test="firstDispenseDate !=null and firstDispenseDate !='' ">
            and firstDispenseDate = #{firstDispenseDate}
        </if>
        <if test="specification !=null and specification !='' ">
            and specification = #{specification}
        </if>
        <if test="batchNumber !=null and batchNumber !='' ">
            and batchNumber = #{batchNumber}
        </if>
        <if test="manufacturer !=null and manufacturer !='' ">
            and manufacturer = #{manufacturer}
        </if>
        <if test="expirationDate !=null and expirationDate !='' ">
            and expirationDate = #{expirationDate}
        </if>
        <if test="saleQuantity !=null and saleQuantity !='' ">
            and saleQuantity = #{saleQuantity}
        </if>
        <if test="dispenseUnit !=null and dispenseUnit !='' ">
            and dispenseUnit = #{dispenseUnit}
        </if>
        <if test="dispenser !=null and dispenser !='' ">
            and dispenser = #{dispenser}
        </if>
        <if test="verifier !=null and verifier !='' ">
            and verifier = #{verifier}
        </if>
    </select>


    <update id="updateSKcBbSalesanddispensing" parameterType="pd" >
        update s_kc_bb_salesanddispensing
        <trim prefix=" SET " suffix="" prefixOverrides="," suffixOverrides=",">
        <if test="saleDate !=null and saleDate !='' ">
            saleDate = #{saleDate},
        </if>
        <if test="productName !=null and productName !='' ">
            productName = #{productName},
        </if>
        <if test="genericName !=null and genericName !='' ">
            genericName = #{genericName},
        </if>
        <if test="productCode !=null and productCode !='' ">
            productCode = #{productCode},
        </if>
        <if test="saleDocumentNumber !=null and saleDocumentNumber !='' ">
            saleDocumentNumber = #{saleDocumentNumber},
        </if>
        <if test="firstDispenseDate !=null and firstDispenseDate !='' ">
            firstDispenseDate = #{firstDispenseDate},
        </if>
        <if test="specification !=null and specification !='' ">
            specification = #{specification},
        </if>
        <if test="batchNumber !=null and batchNumber !='' ">
            batchNumber = #{batchNumber},
        </if>
        <if test="manufacturer !=null and manufacturer !='' ">
            manufacturer = #{manufacturer},
        </if>
        <if test="expirationDate !=null and expirationDate !='' ">
            expirationDate = #{expirationDate},
        </if>
        <if test="saleQuantity !=null and saleQuantity !='' ">
            saleQuantity = #{saleQuantity},
        </if>
        <if test="dispenseUnit !=null and dispenseUnit !='' ">
            dispenseUnit = #{dispenseUnit},
        </if>
        <if test="dispenser !=null and dispenser !='' ">
            dispenser = #{dispenser},
        </if>
        <if test="verifier !=null and verifier !='' ">
            verifier = #{verifier},
        </if>
        </trim>
        <if test="up != null and up!=''">
            <if test="id != null and id!=''">
                where id=#{id}
            </if>
        </if>
    </update>

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

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

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

        <if test="saleDate !=null and saleDate !='' ">
            saleDate,
        </if>
        <if test="productName !=null and productName !='' ">
            productName,
        </if>
        <if test="genericName !=null and genericName !='' ">
            genericName,
        </if>
        <if test="productCode !=null and productCode !='' ">
            productCode,
        </if>
        <if test="saleDocumentNumber !=null and saleDocumentNumber !='' ">
            saleDocumentNumber,
        </if>
        <if test="firstDispenseDate !=null and firstDispenseDate !='' ">
            firstDispenseDate,
        </if>
        <if test="specification !=null and specification !='' ">
            specification,
        </if>
        <if test="batchNumber !=null and batchNumber !='' ">
            batchNumber,
        </if>
        <if test="manufacturer !=null and manufacturer !='' ">
            manufacturer,
        </if>
        <if test="expirationDate !=null and expirationDate !='' ">
            expirationDate,
        </if>
        <if test="saleQuantity !=null and saleQuantity !='' ">
            saleQuantity,
        </if>
        <if test="dispenseUnit !=null and dispenseUnit !='' ">
            dispenseUnit,
        </if>
        <if test="dispenser !=null and dispenser !='' ">
            dispenser,
        </if>
        <if test="verifier !=null and verifier !='' ">
            verifier,
        </if>
        </trim>
        <trim prefix=" VALUES (" suffix=")" prefixOverrides="," suffixOverrides=",">
        <if test="saleDate !=null and saleDate !='' ">
             #{saleDate},
        </if>
        <if test="productName !=null and productName !='' ">
             #{productName},
        </if>
        <if test="genericName !=null and genericName !='' ">
             #{genericName},
        </if>
        <if test="productCode !=null and productCode !='' ">
             #{productCode},
        </if>
        <if test="saleDocumentNumber !=null and saleDocumentNumber !='' ">
             #{saleDocumentNumber},
        </if>
        <if test="firstDispenseDate !=null and firstDispenseDate !='' ">
             #{firstDispenseDate},
        </if>
        <if test="specification !=null and specification !='' ">
             #{specification},
        </if>
        <if test="batchNumber !=null and batchNumber !='' ">
             #{batchNumber},
        </if>
        <if test="manufacturer !=null and manufacturer !='' ">
             #{manufacturer},
        </if>
        <if test="expirationDate !=null and expirationDate !='' ">
             #{expirationDate},
        </if>
        <if test="saleQuantity !=null and saleQuantity !='' ">
             #{saleQuantity},
        </if>
        <if test="dispenseUnit !=null and dispenseUnit !='' ">
             #{dispenseUnit},
        </if>
        <if test="dispenser !=null and dispenser !='' ">
             #{dispenser},
        </if>
        <if test="verifier !=null and verifier !='' ">
             #{verifier},
        </if>
        </trim>

    </insert>

</mapper>
