<?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.ruoyi.business.mapper.TCkPickingwavegoodsBackMapper">
    
    <resultMap type="TCkPickingwavegoodsBack" id="TCkPickingwavegoodsBackResult">
        <result property="pickingid"    column="PICKINGID"    />
        <result property="putinId"    column="PUTIN_ID"    />
        <result property="docctnumber"    column="DOCCTNUMBER"    />
        <result property="goodId"    column="GOOD_ID"    />
        <result property="locId"    column="LOC_ID"    />
        <result property="goodsNum"    column="GOODS_NUM"    />
        <result property="specification"    column="SPECIFICATION"    />
        <result property="productionDate"    column="PRODUCTION_DATE"    />
        <result property="wareDate"    column="WARE_DATE"    />
        <result property="providerId"    column="PROVIDER_ID"    />
        <result property="unit"    column="UNIT"    />
        <result property="remark"    column="REMARK"    />
        <result property="outId"    column="OUT_ID"    />
        <result property="scaleUnit"    column="SCALE_UNIT"    />
        <result property="mistockNum"    column="MISTOCK_NUM"    />
        <result property="pickingNum"    column="PICKING_NUM"    />
        <result property="price"    column="PRICE"    />
        <result property="storageAreaId"    column="STORAGE_AREA_ID"    />
        <result property="storageId"    column="STORAGE_ID"    />
        <result property="ctl"    column="CTL"    />
        <result property="goodsNumSj"    column="GOODS_NUM_SJ"    />
        <result property="port"    column="PORT"    />
        <result property="ckType"    column="CK_TYPE"    />
        <result property="sts"    column="STS"    />
        <result property="typests"    column="TYPESTS"    />
        <result property="outstand"    column="OUTSTAND"    />
        <result property="goodsName"    column="GOODS_NAME"    />
        <result property="plcid"    column="PLCID"    />
        <result property="barcode"    column="BARCODE"    />
        <result property="produclotid"    column="PRODUCLOTID"    />
        <result property="toLoc"    column="TO_LOC"    />
        <result property="useid"    column="USEID"    />
        <result property="customermemberid"    column="CUSTOMERMEMBERID"    />
        <result property="datatype"    column="DATATYPE"    />
        <result property="goodsMeasureId"    column="GOODS_MEASURE_ID"    />
        <result property="towhseloc"    column="TOWHSELOC"    />
        <result property="outstatus"    column="OUTSTATUS"    />
        <result property="expiryDate"    column="EXPIRY_DATE"    />
        <result property="createTime"    column="CREATE_TIME"    />
        <result property="userName"    column="USERNAME"    />
    </resultMap>

    <sql id="selectTCkPickingwavegoodsBackVo">
        select PICKINGID, PUTIN_ID, DOCCTNUMBER, GOOD_ID, LOC_ID, GOODS_NUM, SPECIFICATION, PRODUCTION_DATE, WARE_DATE, PROVIDER_ID, UNIT, REMARK, OUT_ID, SCALE_UNIT, MISTOCK_NUM, PICKING_NUM, PRICE, STORAGE_AREA_ID, STORAGE_ID, CTL, GOODS_NUM_SJ, PORT, CK_TYPE, STS, TYPESTS, OUTSTAND, GOODS_NAME, PLCID, BARCODE, PRODUCLOTID, TO_LOC, USEID, CUSTOMERMEMBERID, DATATYPE, GOODS_MEASURE_ID, TOWHSELOC, OUTSTATUS, EXPIRY_DATE, CREATE_TIME, USERNAME from t_ck_pickingwavegoods_back
    </sql>

    <select id="selectTCkPickingwavegoodsBackList" parameterType="TCkPickingwavegoodsBack" resultMap="TCkPickingwavegoodsBackResult">
        <include refid="selectTCkPickingwavegoodsBackVo"/>
        <where>
            <if test="pickingid != null  and pickingid != ''"> and PICKINGID = #{pickingid}</if>
            <if test="putinId != null  and putinId != ''"> and PUTIN_ID = #{putinId}</if>
            <if test="docctnumber != null  and docctnumber != ''"> and DOCCTNUMBER = #{docctnumber}</if>
            <if test="goodId != null  and goodId != ''"> and GOOD_ID = #{goodId}</if>
            <if test="locId != null  and locId != ''"> and LOC_ID = #{locId}</if>
            <if test="goodsNum != null "> and GOODS_NUM = #{goodsNum}</if>
            <if test="specification != null  and specification != ''"> and SPECIFICATION = #{specification}</if>
            <if test="productionDate != null "> and PRODUCTION_DATE = #{productionDate}</if>
            <if test="wareDate != null "> and WARE_DATE = #{wareDate}</if>
            <if test="providerId != null  and providerId != ''"> and PROVIDER_ID = #{providerId}</if>
            <if test="unit != null  and unit != ''"> and UNIT = #{unit}</if>
            <if test="remark != null  and remark != ''"> and REMARK = #{remark}</if>
            <if test="outId != null  and outId != ''"> and OUT_ID = #{outId}</if>
            <if test="scaleUnit != null  and scaleUnit != ''"> and SCALE_UNIT = #{scaleUnit}</if>
            <if test="mistockNum != null "> and MISTOCK_NUM = #{mistockNum}</if>
            <if test="pickingNum != null "> and PICKING_NUM = #{pickingNum}</if>
            <if test="price != null "> and PRICE = #{price}</if>
            <if test="storageAreaId != null  and storageAreaId != ''"> and STORAGE_AREA_ID = #{storageAreaId}</if>
            <if test="storageId != null  and storageId != ''"> and STORAGE_ID = #{storageId}</if>
            <if test="ctl != null  and ctl != ''"> and CTL = #{ctl}</if>
            <if test="goodsNumSj != null "> and GOODS_NUM_SJ = #{goodsNumSj}</if>
            <if test="port != null  and port != ''"> and PORT = #{port}</if>
            <if test="ckType != null  and ckType != ''"> and CK_TYPE = #{ckType}</if>
            <if test="sts != null  and sts != ''"> and STS = #{sts}</if>
            <if test="typests != null  and typests != ''"> and TYPESTS = #{typests}</if>
            <if test="outstand != null  and outstand != ''"> and OUTSTAND = #{outstand}</if>
            <if test="goodsName != null  and goodsName != ''"> and GOODS_NAME like concat('%', #{goodsName}, '%')</if>
            <if test="plcid != null  and plcid != ''"> and PLCID = #{plcid}</if>
            <if test="barcode != null  and barcode != ''"> and BARCODE = #{barcode}</if>
            <if test="produclotid != null  and produclotid != ''"> and PRODUCLOTID = #{produclotid}</if>
            <if test="toLoc != null  and toLoc != ''"> and TO_LOC = #{toLoc}</if>
            <if test="useid != null  and useid != ''"> and USEID = #{useid}</if>
            <if test="customermemberid != null  and customermemberid != ''"> and CUSTOMERMEMBERID = #{customermemberid}</if>
            <if test="datatype != null  and datatype != ''"> and DATATYPE = #{datatype}</if>
            <if test="goodsMeasureId != null  and goodsMeasureId != ''"> and GOODS_MEASURE_ID = #{goodsMeasureId}</if>
            <if test="towhseloc != null  and towhseloc != ''"> and TOWHSELOC = #{towhseloc}</if>
            <if test="outstatus != null  and outstatus != ''">
                and OUTSTATUS in
                <foreach collection="outstatus.split(',')" item="item" separator="," open="(" close=")">
                    #{item}
                </foreach>
            </if>
            <if test="userName != null and userName != ''"> and USERNAME = #{userName}</if>
        </where>
    </select>
    
    <select id="selectTCkPickingwavegoodsBackEmpty" parameterType="TCkPickingwavegoodsBack" resultMap="TCkPickingwavegoodsBackResult">
        <include refid="selectTCkPickingwavegoodsBackVo"/>
        where GOOD_ID == "0000"
        order by CREATE_TIME DESC
    </select>

    <select id="selectTCkPickingwavegoodsBackWithoutEmpty" parameterType="TCkPickingwavegoodsBack" resultMap="TCkPickingwavegoodsBackResult">
        <include refid="selectTCkPickingwavegoodsBackVo"/>
        <where>
            <if test="pickingid != null  and pickingid != ''"> and PICKINGID = #{pickingid}</if>
            <if test="putinId != null  and putinId != ''"> and PUTIN_ID = #{putinId}</if>
            <if test="docctnumber != null  and docctnumber != ''"> and DOCCTNUMBER = #{docctnumber}</if>
            <if test="goodId != null  and goodId != ''"> and GOOD_ID = #{goodId}</if>
            <if test="locId != null  and locId != ''"> and LOC_ID = #{locId}</if>
            <if test="goodsNum != null "> and GOODS_NUM = #{goodsNum}</if>
            <if test="specification != null  and specification != ''"> and SPECIFICATION = #{specification}</if>
            <if test="productionDate != null "> and PRODUCTION_DATE = #{productionDate}</if>
            <if test="wareDate != null "> and WARE_DATE = #{wareDate}</if>
            <if test="providerId != null  and providerId != ''"> and PROVIDER_ID = #{providerId}</if>
            <if test="unit != null  and unit != ''"> and UNIT = #{unit}</if>
            <if test="remark != null  and remark != ''"> and REMARK = #{remark}</if>
            <if test="outId != null  and outId != ''"> and OUT_ID = #{outId}</if>
            <if test="scaleUnit != null  and scaleUnit != ''"> and SCALE_UNIT = #{scaleUnit}</if>
            <if test="mistockNum != null "> and MISTOCK_NUM = #{mistockNum}</if>
            <if test="pickingNum != null "> and PICKING_NUM = #{pickingNum}</if>
            <if test="price != null "> and PRICE = #{price}</if>
            <if test="storageAreaId != null  and storageAreaId != ''"> and STORAGE_AREA_ID = #{storageAreaId}</if>
            <if test="storageId != null  and storageId != ''"> and STORAGE_ID = #{storageId}</if>
            <if test="ctl != null  and ctl != ''"> and CTL = #{ctl}</if>
            <if test="goodsNumSj != null "> and GOODS_NUM_SJ = #{goodsNumSj}</if>
            <if test="port != null  and port != ''"> and PORT = #{port}</if>
            <if test="ckType != null  and ckType != ''"> and CK_TYPE = #{ckType}</if>
            <if test="sts != null  and sts != ''"> and STS = #{sts}</if>
            <if test="typests != null  and typests != ''"> and TYPESTS = #{typests}</if>
            <if test="outstand != null  and outstand != ''"> and OUTSTAND = #{outstand}</if>
            <if test="goodsName != null  and goodsName != ''"> and GOODS_NAME like concat('%', #{goodsName}, '%')</if>
            <if test="plcid != null  and plcid != ''"> and PLCID = #{plcid}</if>
            <if test="barcode != null  and barcode != ''"> and BARCODE = #{barcode}</if>
            <if test="produclotid != null  and produclotid != ''"> and PRODUCLOTID = #{produclotid}</if>
            <if test="toLoc != null  and toLoc != ''"> and TO_LOC = #{toLoc}</if>
            <if test="useid != null  and useid != ''"> and USEID = #{useid}</if>
            <if test="customermemberid != null  and customermemberid != ''"> and CUSTOMERMEMBERID = #{customermemberid}</if>
            <if test="datatype != null  and datatype != ''"> and DATATYPE = #{datatype}</if>
            <if test="goodsMeasureId != null  and goodsMeasureId != ''"> and GOODS_MEASURE_ID = #{goodsMeasureId}</if>
            <if test="towhseloc != null  and towhseloc != ''"> and TOWHSELOC = #{towhseloc}</if>
            <if test="outstatus != null  and outstatus != ''">
                and OUTSTATUS in
                <foreach collection="outstatus.split(',')" item="item" separator="," open="(" close=")">
                    #{item}
                </foreach>
            </if>
            <if test="userName != null and userName != ''"> and USERNAME = #{userName}</if>
            and GOOD_ID != "000000000"
        </where>
        order by CREATE_TIME DESC
    </select>

    <select id="selectTCkPickingwavegoodsBackByPickingid" parameterType="String" resultMap="TCkPickingwavegoodsBackResult">
        <include refid="selectTCkPickingwavegoodsBackVo"/>
        where PICKINGID = #{pickingid}
    </select>

    <select id="selectTCkPickingwavegoodsBakByCreateDate" parameterType="String" resultMap="TCkPickingwavegoodsBackResult">
        <include refid="selectTCkPickingwavegoodsBackVo"/>
        <where>
        <if test="startDate != null  and startDate != ''"> and CREATE_TIME &gt;= #{startDate}</if>
        <if test="endDate != null  and endDate != ''"> and CREATE_TIME &lt;= #{endDate}</if>
        <if test="ckType != null  and ckType != ''"> and CK_TYPE = #{ckType}</if>
        <if test="search != null  and search != ''"> and (GOOD_ID like concat('%', #{search}, '%') or PRODUCLOTID like concat('%', #{search}, '%') or CTL like concat('%', #{search}, '%'))</if>
            and GOOD_ID != "000000000"
        </where>
        order by CREATE_TIME DESC
    </select>
        
    <insert id="insertTCkPickingwavegoodsBack" parameterType="TCkPickingwavegoodsBack">
        insert into t_ck_pickingwavegoods_back
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="pickingid != null and pickingid != ''">PICKINGID,</if>
            <if test="putinId != null">PUTIN_ID,</if>
            <if test="docctnumber != null">DOCCTNUMBER,</if>
            <if test="goodId != null and goodId != ''">GOOD_ID,</if>
            <if test="locId != null">LOC_ID,</if>
            <if test="goodsNum != null">GOODS_NUM,</if>
            <if test="specification != null">SPECIFICATION,</if>
            <if test="productionDate != null">PRODUCTION_DATE,</if>
            <if test="wareDate != null">WARE_DATE,</if>
            <if test="providerId != null">PROVIDER_ID,</if>
            <if test="unit != null">UNIT,</if>
            <if test="remark != null">REMARK,</if>
            <if test="outId != null">OUT_ID,</if>
            <if test="scaleUnit != null">SCALE_UNIT,</if>
            <if test="mistockNum != null">MISTOCK_NUM,</if>
            <if test="pickingNum != null">PICKING_NUM,</if>
            <if test="price != null">PRICE,</if>
            <if test="storageAreaId != null">STORAGE_AREA_ID,</if>
            <if test="storageId != null">STORAGE_ID,</if>
            <if test="ctl != null">CTL,</if>
            <if test="goodsNumSj != null">GOODS_NUM_SJ,</if>
            <if test="port != null">PORT,</if>
            <if test="ckType != null">CK_TYPE,</if>
            <if test="sts != null">STS,</if>
            <if test="typests != null">TYPESTS,</if>
            <if test="outstand != null">OUTSTAND,</if>
            <if test="goodsName != null">GOODS_NAME,</if>
            <if test="plcid != null">PLCID,</if>
            <if test="barcode != null">BARCODE,</if>
            <if test="produclotid != null">PRODUCLOTID,</if>
            <if test="toLoc != null">TO_LOC,</if>
            <if test="useid != null">USEID,</if>
            <if test="customermemberid != null">CUSTOMERMEMBERID,</if>
            <if test="datatype != null">DATATYPE,</if>
            <if test="goodsMeasureId != null">GOODS_MEASURE_ID,</if>
            <if test="towhseloc != null">TOWHSELOC,</if>
            <if test="outstatus != null">OUTSTATUS,</if>
            <if test="userName != null">USERNAME,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="pickingid != null and pickingid != ''">#{pickingid},</if>
            <if test="putinId != null">#{putinId},</if>
            <if test="docctnumber != null">#{docctnumber},</if>
            <if test="goodId != null and goodId != ''">#{goodId},</if>
            <if test="locId != null">#{locId},</if>
            <if test="goodsNum != null">#{goodsNum},</if>
            <if test="specification != null">#{specification},</if>
            <if test="productionDate != null">#{productionDate},</if>
            <if test="wareDate != null">#{wareDate},</if>
            <if test="providerId != null">#{providerId},</if>
            <if test="unit != null">#{unit},</if>
            <if test="remark != null">#{remark},</if>
            <if test="outId != null">#{outId},</if>
            <if test="scaleUnit != null">#{scaleUnit},</if>
            <if test="mistockNum != null">#{mistockNum},</if>
            <if test="pickingNum != null">#{pickingNum},</if>
            <if test="price != null">#{price},</if>
            <if test="storageAreaId != null">#{storageAreaId},</if>
            <if test="storageId != null">#{storageId},</if>
            <if test="ctl != null">#{ctl},</if>
            <if test="goodsNumSj != null">#{goodsNumSj},</if>
            <if test="port != null">#{port},</if>
            <if test="ckType != null">#{ckType},</if>
            <if test="sts != null">#{sts},</if>
            <if test="typests != null">#{typests},</if>
            <if test="outstand != null">#{outstand},</if>
            <if test="goodsName != null">#{goodsName},</if>
            <if test="plcid != null">#{plcid},</if>
            <if test="barcode != null">#{barcode},</if>
            <if test="produclotid != null">#{produclotid},</if>
            <if test="toLoc != null">#{toLoc},</if>
            <if test="useid != null">#{useid},</if>
            <if test="customermemberid != null">#{customermemberid},</if>
            <if test="datatype != null">#{datatype},</if>
            <if test="goodsMeasureId != null">#{goodsMeasureId},</if>
            <if test="towhseloc != null">#{towhseloc},</if>
            <if test="outstatus != null">#{outstatus},</if>
            <if test="userName != null">#{userName},</if>
        </trim>
    </insert>

    <update id="updateTCkPickingwavegoodsBack" parameterType="TCkPickingwavegoodsBack">
        update t_ck_pickingwavegoods_back
        <trim prefix="SET" suffixOverrides=",">
            <if test="putinId != null">PUTIN_ID = #{putinId},</if>
            <if test="docctnumber != null">DOCCTNUMBER = #{docctnumber},</if>
            <if test="goodId != null and goodId != ''">GOOD_ID = #{goodId},</if>
            <if test="locId != null">LOC_ID = #{locId},</if>
            <if test="goodsNum != null">GOODS_NUM = #{goodsNum},</if>
            <if test="specification != null">SPECIFICATION = #{specification},</if>
            <if test="productionDate != null">PRODUCTION_DATE = #{productionDate},</if>
            <if test="wareDate != null">WARE_DATE = #{wareDate},</if>
            <if test="providerId != null">PROVIDER_ID = #{providerId},</if>
            <if test="unit != null">UNIT = #{unit},</if>
            <if test="remark != null">REMARK = #{remark},</if>
            <if test="outId != null">OUT_ID = #{outId},</if>
            <if test="scaleUnit != null">SCALE_UNIT = #{scaleUnit},</if>
            <if test="mistockNum != null">MISTOCK_NUM = #{mistockNum},</if>
            <if test="pickingNum != null">PICKING_NUM = #{pickingNum},</if>
            <if test="price != null">PRICE = #{price},</if>
            <if test="storageAreaId != null">STORAGE_AREA_ID = #{storageAreaId},</if>
            <if test="storageId != null">STORAGE_ID = #{storageId},</if>
            <if test="ctl != null">CTL = #{ctl},</if>
            <if test="goodsNumSj != null">GOODS_NUM_SJ = #{goodsNumSj},</if>
            <if test="port != null">PORT = #{port},</if>
            <if test="ckType != null">CK_TYPE = #{ckType},</if>
            <if test="sts != null">STS = #{sts},</if>
            <if test="typests != null">TYPESTS = #{typests},</if>
            <if test="outstand != null">OUTSTAND = #{outstand},</if>
            <if test="goodsName != null">GOODS_NAME = #{goodsName},</if>
            <if test="plcid != null">PLCID = #{plcid},</if>
            <if test="barcode != null">BARCODE = #{barcode},</if>
            <if test="produclotid != null">PRODUCLOTID = #{produclotid},</if>
            <if test="toLoc != null">TO_LOC = #{toLoc},</if>
            <if test="useid != null">USEID = #{useid},</if>
            <if test="customermemberid != null">CUSTOMERMEMBERID = #{customermemberid},</if>
            <if test="datatype != null">DATATYPE = #{datatype},</if>
            <if test="goodsMeasureId != null">GOODS_MEASURE_ID = #{goodsMeasureId},</if>
            <if test="towhseloc != null">TOWHSELOC = #{towhseloc},</if>
            <if test="outstatus != null">OUTSTATUS = #{outstatus},</if>
            <if test="userName != null">USERNAME = #{userName},</if>
        </trim>
        where PICKINGID = #{pickingid}
    </update>

    <delete id="deleteTCkPickingwavegoodsBackByPickingid" parameterType="String">
        delete from t_ck_pickingwavegoods_back where PICKINGID = #{pickingid}
    </delete>

    <delete id="deleteTCkPickingwavegoodsBackByPickingids" parameterType="String">
        delete from t_ck_pickingwavegoods_back where PICKINGID in 
        <foreach item="pickingid" collection="array" open="(" separator="," close=")">
            #{pickingid}
        </foreach>
    </delete>

</mapper>