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

    <select id="selectSKcBbInventoryvariationList" parameterType="pd" resultType="pd">
        select * from s_kc_bb_inventoryvariation where 1=1
        <if test="sequenceNumber !=null and sequenceNumber !='' ">
            and sequenceNumber = #{sequenceNumber}
        </if>
        <if test="period !=null and period !='' ">
            and period = #{period}
        </if>
        <if test="productCode !=null and productCode !='' ">
            and productCode = #{productCode}
        </if>
        <if test="productName !=null and productName !='' ">
            and productName = #{productName}
        </if>
        <if test="specification !=null and specification !='' ">
            and specification = #{specification}
        </if>
        <if test="unit !=null and unit !='' ">
            and unit = #{unit}
        </if>
        <if test="manufacturer !=null and manufacturer !='' ">
            and manufacturer = #{manufacturer}
        </if>
        <if test="dosageForm !=null and dosageForm !='' ">
            and dosageForm = #{dosageForm}
        </if>
        <if test="batchNumber !=null and batchNumber !='' ">
            and batchNumber = #{batchNumber}
        </if>
        <if test="batch !=null and batch !='' ">
            and batch = #{batch}
        </if>
        <if test="initialStockQuantity !=null and initialStockQuantity !='' ">
            and initialStockQuantity = #{initialStockQuantity}
        </if>
        <if test="initialStockCost !=null and initialStockCost !='' ">
            and initialStockCost = #{initialStockCost}
        </if>
        <if test="warehouseDeliveryQuantity !=null and warehouseDeliveryQuantity !='' ">
            and warehouseDeliveryQuantity = #{warehouseDeliveryQuantity}
        </if>
        <if test="warehouseDeliveryCost !=null and warehouseDeliveryCost !='' ">
            and warehouseDeliveryCost = #{warehouseDeliveryCost}
        </if>
        <if test="transferInQuantity !=null and transferInQuantity !='' ">
            and transferInQuantity = #{transferInQuantity}
        </if>
        <if test="transferInCost !=null and transferInCost !='' ">
            and transferInCost = #{transferInCost}
        </if>
        <if test="storeReceiptQuantity !=null and storeReceiptQuantity !='' ">
            and storeReceiptQuantity = #{storeReceiptQuantity}
        </if>
        <if test="storeReceiptCost !=null and storeReceiptCost !='' ">
            and storeReceiptCost = #{storeReceiptCost}
        </if>
        <if test="storeReturnQuantity !=null and storeReturnQuantity !='' ">
            and storeReturnQuantity = #{storeReturnQuantity}
        </if>
        <if test="storeReturnAmount !=null and storeReturnAmount !='' ">
            and storeReturnAmount = #{storeReturnAmount}
        </if>
        <if test="transferOutQuantity !=null and transferOutQuantity !='' ">
            and transferOutQuantity = #{transferOutQuantity}
        </if>
        <if test="transferOutCost !=null and transferOutCost !='' ">
            and transferOutCost = #{transferOutCost}
        </if>
        <if test="storeReturnWarehouseQuantity !=null and storeReturnWarehouseQuantity !='' ">
            and storeReturnWarehouseQuantity = #{storeReturnWarehouseQuantity}
        </if>
        <if test="storeReturnWarehouseCost !=null and storeReturnWarehouseCost !='' ">
            and storeReturnWarehouseCost = #{storeReturnWarehouseCost}
        </if>
        <if test="offlineSalesQuantity !=null and offlineSalesQuantity !='' ">
            and offlineSalesQuantity = #{offlineSalesQuantity}
        </if>
        <if test="offlineSalesCost !=null and offlineSalesCost !='' ">
            and offlineSalesCost = #{offlineSalesCost}
        </if>
        <if test="offlineSalesReturnQuantity !=null and offlineSalesReturnQuantity !='' ">
            and offlineSalesReturnQuantity = #{offlineSalesReturnQuantity}
        </if>
        <if test="offlineSalesReturnAmount !=null and offlineSalesReturnAmount !='' ">
            and offlineSalesReturnAmount = #{offlineSalesReturnAmount}
        </if>
        <if test="onlineSalesQuantity !=null and onlineSalesQuantity !='' ">
            and onlineSalesQuantity = #{onlineSalesQuantity}
        </if>
        <if test="onlineSalesCost !=null and onlineSalesCost !='' ">
            and onlineSalesCost = #{onlineSalesCost}
        </if>
        <if test="onlineSalesReturnQuantity !=null and onlineSalesReturnQuantity !='' ">
            and onlineSalesReturnQuantity = #{onlineSalesReturnQuantity}
        </if>
        <if test="onlineSalesReturnAmount !=null and onlineSalesReturnAmount !='' ">
            and onlineSalesReturnAmount = #{onlineSalesReturnAmount}
        </if>
        <if test="lossQuantity !=null and lossQuantity !='' ">
            and lossQuantity = #{lossQuantity}
        </if>
        <if test="lossCost !=null and lossCost !='' ">
            and lossCost = #{lossCost}
        </if>
        <if test="gainQuantity !=null and gainQuantity !='' ">
            and gainQuantity = #{gainQuantity}
        </if>
        <if test="gainCost !=null and gainCost !='' ">
            and gainCost = #{gainCost}
        </if>
        <if test="finalStockQuantity !=null and finalStockQuantity !='' ">
            and finalStockQuantity = #{finalStockQuantity}
        </if>
        <if test="finalStockCost !=null and finalStockCost !='' ">
            and finalStockCost = #{finalStockCost}
        </if>
        <if test="initialImportQuantity !=null and initialImportQuantity !='' ">
            and initialImportQuantity = #{initialImportQuantity}
        </if>
        <if test="initialImportCost !=null and initialImportCost !='' ">
            and initialImportCost = #{initialImportCost}
        </if>
    </select>


    <update id="updateSKcBbInventoryvariation" parameterType="pd" >
        update s_kc_bb_inventoryvariation
        <trim prefix=" SET " suffix="" prefixOverrides="," suffixOverrides=",">
        <if test="sequenceNumber !=null and sequenceNumber !='' ">
            sequenceNumber = #{sequenceNumber},
        </if>
        <if test="period !=null and period !='' ">
            period = #{period},
        </if>
        <if test="productCode !=null and productCode !='' ">
            productCode = #{productCode},
        </if>
        <if test="productName !=null and productName !='' ">
            productName = #{productName},
        </if>
        <if test="specification !=null and specification !='' ">
            specification = #{specification},
        </if>
        <if test="unit !=null and unit !='' ">
            unit = #{unit},
        </if>
        <if test="manufacturer !=null and manufacturer !='' ">
            manufacturer = #{manufacturer},
        </if>
        <if test="dosageForm !=null and dosageForm !='' ">
            dosageForm = #{dosageForm},
        </if>
        <if test="batchNumber !=null and batchNumber !='' ">
            batchNumber = #{batchNumber},
        </if>
        <if test="batch !=null and batch !='' ">
            batch = #{batch},
        </if>
        <if test="initialStockQuantity !=null and initialStockQuantity !='' ">
            initialStockQuantity = #{initialStockQuantity},
        </if>
        <if test="initialStockCost !=null and initialStockCost !='' ">
            initialStockCost = #{initialStockCost},
        </if>
        <if test="warehouseDeliveryQuantity !=null and warehouseDeliveryQuantity !='' ">
            warehouseDeliveryQuantity = #{warehouseDeliveryQuantity},
        </if>
        <if test="warehouseDeliveryCost !=null and warehouseDeliveryCost !='' ">
            warehouseDeliveryCost = #{warehouseDeliveryCost},
        </if>
        <if test="transferInQuantity !=null and transferInQuantity !='' ">
            transferInQuantity = #{transferInQuantity},
        </if>
        <if test="transferInCost !=null and transferInCost !='' ">
            transferInCost = #{transferInCost},
        </if>
        <if test="storeReceiptQuantity !=null and storeReceiptQuantity !='' ">
            storeReceiptQuantity = #{storeReceiptQuantity},
        </if>
        <if test="storeReceiptCost !=null and storeReceiptCost !='' ">
            storeReceiptCost = #{storeReceiptCost},
        </if>
        <if test="storeReturnQuantity !=null and storeReturnQuantity !='' ">
            storeReturnQuantity = #{storeReturnQuantity},
        </if>
        <if test="storeReturnAmount !=null and storeReturnAmount !='' ">
            storeReturnAmount = #{storeReturnAmount},
        </if>
        <if test="transferOutQuantity !=null and transferOutQuantity !='' ">
            transferOutQuantity = #{transferOutQuantity},
        </if>
        <if test="transferOutCost !=null and transferOutCost !='' ">
            transferOutCost = #{transferOutCost},
        </if>
        <if test="storeReturnWarehouseQuantity !=null and storeReturnWarehouseQuantity !='' ">
            storeReturnWarehouseQuantity = #{storeReturnWarehouseQuantity},
        </if>
        <if test="storeReturnWarehouseCost !=null and storeReturnWarehouseCost !='' ">
            storeReturnWarehouseCost = #{storeReturnWarehouseCost},
        </if>
        <if test="offlineSalesQuantity !=null and offlineSalesQuantity !='' ">
            offlineSalesQuantity = #{offlineSalesQuantity},
        </if>
        <if test="offlineSalesCost !=null and offlineSalesCost !='' ">
            offlineSalesCost = #{offlineSalesCost},
        </if>
        <if test="offlineSalesReturnQuantity !=null and offlineSalesReturnQuantity !='' ">
            offlineSalesReturnQuantity = #{offlineSalesReturnQuantity},
        </if>
        <if test="offlineSalesReturnAmount !=null and offlineSalesReturnAmount !='' ">
            offlineSalesReturnAmount = #{offlineSalesReturnAmount},
        </if>
        <if test="onlineSalesQuantity !=null and onlineSalesQuantity !='' ">
            onlineSalesQuantity = #{onlineSalesQuantity},
        </if>
        <if test="onlineSalesCost !=null and onlineSalesCost !='' ">
            onlineSalesCost = #{onlineSalesCost},
        </if>
        <if test="onlineSalesReturnQuantity !=null and onlineSalesReturnQuantity !='' ">
            onlineSalesReturnQuantity = #{onlineSalesReturnQuantity},
        </if>
        <if test="onlineSalesReturnAmount !=null and onlineSalesReturnAmount !='' ">
            onlineSalesReturnAmount = #{onlineSalesReturnAmount},
        </if>
        <if test="lossQuantity !=null and lossQuantity !='' ">
            lossQuantity = #{lossQuantity},
        </if>
        <if test="lossCost !=null and lossCost !='' ">
            lossCost = #{lossCost},
        </if>
        <if test="gainQuantity !=null and gainQuantity !='' ">
            gainQuantity = #{gainQuantity},
        </if>
        <if test="gainCost !=null and gainCost !='' ">
            gainCost = #{gainCost},
        </if>
        <if test="finalStockQuantity !=null and finalStockQuantity !='' ">
            finalStockQuantity = #{finalStockQuantity},
        </if>
        <if test="finalStockCost !=null and finalStockCost !='' ">
            finalStockCost = #{finalStockCost},
        </if>
        <if test="initialImportQuantity !=null and initialImportQuantity !='' ">
            initialImportQuantity = #{initialImportQuantity},
        </if>
        <if test="initialImportCost !=null and initialImportCost !='' ">
            initialImportCost = #{initialImportCost},
        </if>
        </trim>
        <if test="up != null and up!=''">
            <if test="id != null and id!=''">
                where id=#{id}
            </if>
        </if>
    </update>

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

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

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

        <if test="sequenceNumber !=null and sequenceNumber !='' ">
            sequenceNumber,
        </if>
        <if test="period !=null and period !='' ">
            period,
        </if>
        <if test="productCode !=null and productCode !='' ">
            productCode,
        </if>
        <if test="productName !=null and productName !='' ">
            productName,
        </if>
        <if test="specification !=null and specification !='' ">
            specification,
        </if>
        <if test="unit !=null and unit !='' ">
            unit,
        </if>
        <if test="manufacturer !=null and manufacturer !='' ">
            manufacturer,
        </if>
        <if test="dosageForm !=null and dosageForm !='' ">
            dosageForm,
        </if>
        <if test="batchNumber !=null and batchNumber !='' ">
            batchNumber,
        </if>
        <if test="batch !=null and batch !='' ">
            batch,
        </if>
        <if test="initialStockQuantity !=null and initialStockQuantity !='' ">
            initialStockQuantity,
        </if>
        <if test="initialStockCost !=null and initialStockCost !='' ">
            initialStockCost,
        </if>
        <if test="warehouseDeliveryQuantity !=null and warehouseDeliveryQuantity !='' ">
            warehouseDeliveryQuantity,
        </if>
        <if test="warehouseDeliveryCost !=null and warehouseDeliveryCost !='' ">
            warehouseDeliveryCost,
        </if>
        <if test="transferInQuantity !=null and transferInQuantity !='' ">
            transferInQuantity,
        </if>
        <if test="transferInCost !=null and transferInCost !='' ">
            transferInCost,
        </if>
        <if test="storeReceiptQuantity !=null and storeReceiptQuantity !='' ">
            storeReceiptQuantity,
        </if>
        <if test="storeReceiptCost !=null and storeReceiptCost !='' ">
            storeReceiptCost,
        </if>
        <if test="storeReturnQuantity !=null and storeReturnQuantity !='' ">
            storeReturnQuantity,
        </if>
        <if test="storeReturnAmount !=null and storeReturnAmount !='' ">
            storeReturnAmount,
        </if>
        <if test="transferOutQuantity !=null and transferOutQuantity !='' ">
            transferOutQuantity,
        </if>
        <if test="transferOutCost !=null and transferOutCost !='' ">
            transferOutCost,
        </if>
        <if test="storeReturnWarehouseQuantity !=null and storeReturnWarehouseQuantity !='' ">
            storeReturnWarehouseQuantity,
        </if>
        <if test="storeReturnWarehouseCost !=null and storeReturnWarehouseCost !='' ">
            storeReturnWarehouseCost,
        </if>
        <if test="offlineSalesQuantity !=null and offlineSalesQuantity !='' ">
            offlineSalesQuantity,
        </if>
        <if test="offlineSalesCost !=null and offlineSalesCost !='' ">
            offlineSalesCost,
        </if>
        <if test="offlineSalesReturnQuantity !=null and offlineSalesReturnQuantity !='' ">
            offlineSalesReturnQuantity,
        </if>
        <if test="offlineSalesReturnAmount !=null and offlineSalesReturnAmount !='' ">
            offlineSalesReturnAmount,
        </if>
        <if test="onlineSalesQuantity !=null and onlineSalesQuantity !='' ">
            onlineSalesQuantity,
        </if>
        <if test="onlineSalesCost !=null and onlineSalesCost !='' ">
            onlineSalesCost,
        </if>
        <if test="onlineSalesReturnQuantity !=null and onlineSalesReturnQuantity !='' ">
            onlineSalesReturnQuantity,
        </if>
        <if test="onlineSalesReturnAmount !=null and onlineSalesReturnAmount !='' ">
            onlineSalesReturnAmount,
        </if>
        <if test="lossQuantity !=null and lossQuantity !='' ">
            lossQuantity,
        </if>
        <if test="lossCost !=null and lossCost !='' ">
            lossCost,
        </if>
        <if test="gainQuantity !=null and gainQuantity !='' ">
            gainQuantity,
        </if>
        <if test="gainCost !=null and gainCost !='' ">
            gainCost,
        </if>
        <if test="finalStockQuantity !=null and finalStockQuantity !='' ">
            finalStockQuantity,
        </if>
        <if test="finalStockCost !=null and finalStockCost !='' ">
            finalStockCost,
        </if>
        <if test="initialImportQuantity !=null and initialImportQuantity !='' ">
            initialImportQuantity,
        </if>
        <if test="initialImportCost !=null and initialImportCost !='' ">
            initialImportCost,
        </if>
        </trim>
        <trim prefix=" VALUES (" suffix=")" prefixOverrides="," suffixOverrides=",">
        <if test="sequenceNumber !=null and sequenceNumber !='' ">
             #{sequenceNumber},
        </if>
        <if test="period !=null and period !='' ">
             #{period},
        </if>
        <if test="productCode !=null and productCode !='' ">
             #{productCode},
        </if>
        <if test="productName !=null and productName !='' ">
             #{productName},
        </if>
        <if test="specification !=null and specification !='' ">
             #{specification},
        </if>
        <if test="unit !=null and unit !='' ">
             #{unit},
        </if>
        <if test="manufacturer !=null and manufacturer !='' ">
             #{manufacturer},
        </if>
        <if test="dosageForm !=null and dosageForm !='' ">
             #{dosageForm},
        </if>
        <if test="batchNumber !=null and batchNumber !='' ">
             #{batchNumber},
        </if>
        <if test="batch !=null and batch !='' ">
             #{batch},
        </if>
        <if test="initialStockQuantity !=null and initialStockQuantity !='' ">
             #{initialStockQuantity},
        </if>
        <if test="initialStockCost !=null and initialStockCost !='' ">
             #{initialStockCost},
        </if>
        <if test="warehouseDeliveryQuantity !=null and warehouseDeliveryQuantity !='' ">
             #{warehouseDeliveryQuantity},
        </if>
        <if test="warehouseDeliveryCost !=null and warehouseDeliveryCost !='' ">
             #{warehouseDeliveryCost},
        </if>
        <if test="transferInQuantity !=null and transferInQuantity !='' ">
             #{transferInQuantity},
        </if>
        <if test="transferInCost !=null and transferInCost !='' ">
             #{transferInCost},
        </if>
        <if test="storeReceiptQuantity !=null and storeReceiptQuantity !='' ">
             #{storeReceiptQuantity},
        </if>
        <if test="storeReceiptCost !=null and storeReceiptCost !='' ">
             #{storeReceiptCost},
        </if>
        <if test="storeReturnQuantity !=null and storeReturnQuantity !='' ">
             #{storeReturnQuantity},
        </if>
        <if test="storeReturnAmount !=null and storeReturnAmount !='' ">
             #{storeReturnAmount},
        </if>
        <if test="transferOutQuantity !=null and transferOutQuantity !='' ">
             #{transferOutQuantity},
        </if>
        <if test="transferOutCost !=null and transferOutCost !='' ">
             #{transferOutCost},
        </if>
        <if test="storeReturnWarehouseQuantity !=null and storeReturnWarehouseQuantity !='' ">
             #{storeReturnWarehouseQuantity},
        </if>
        <if test="storeReturnWarehouseCost !=null and storeReturnWarehouseCost !='' ">
             #{storeReturnWarehouseCost},
        </if>
        <if test="offlineSalesQuantity !=null and offlineSalesQuantity !='' ">
             #{offlineSalesQuantity},
        </if>
        <if test="offlineSalesCost !=null and offlineSalesCost !='' ">
             #{offlineSalesCost},
        </if>
        <if test="offlineSalesReturnQuantity !=null and offlineSalesReturnQuantity !='' ">
             #{offlineSalesReturnQuantity},
        </if>
        <if test="offlineSalesReturnAmount !=null and offlineSalesReturnAmount !='' ">
             #{offlineSalesReturnAmount},
        </if>
        <if test="onlineSalesQuantity !=null and onlineSalesQuantity !='' ">
             #{onlineSalesQuantity},
        </if>
        <if test="onlineSalesCost !=null and onlineSalesCost !='' ">
             #{onlineSalesCost},
        </if>
        <if test="onlineSalesReturnQuantity !=null and onlineSalesReturnQuantity !='' ">
             #{onlineSalesReturnQuantity},
        </if>
        <if test="onlineSalesReturnAmount !=null and onlineSalesReturnAmount !='' ">
             #{onlineSalesReturnAmount},
        </if>
        <if test="lossQuantity !=null and lossQuantity !='' ">
             #{lossQuantity},
        </if>
        <if test="lossCost !=null and lossCost !='' ">
             #{lossCost},
        </if>
        <if test="gainQuantity !=null and gainQuantity !='' ">
             #{gainQuantity},
        </if>
        <if test="gainCost !=null and gainCost !='' ">
             #{gainCost},
        </if>
        <if test="finalStockQuantity !=null and finalStockQuantity !='' ">
             #{finalStockQuantity},
        </if>
        <if test="finalStockCost !=null and finalStockCost !='' ">
             #{finalStockCost},
        </if>
        <if test="initialImportQuantity !=null and initialImportQuantity !='' ">
             #{initialImportQuantity},
        </if>
        <if test="initialImportCost !=null and initialImportCost !='' ">
             #{initialImportCost},
        </if>
        </trim>

    </insert>

</mapper>
