<?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.TCkOrderdetailMapper">
    
    <resultMap type="TCkOrderdetail" id="TCkOrderdetailResult">
        <result property="ckId"    column="CK_ID"    />
        <result property="businessid"    column="BUSINESSID"    />
        <result property="goodId"    column="GOOD_ID"    />
        <result property="specification"    column="SPECIFICATION"    />
        <result property="goodsNum"    column="GOODS_NUM"    />
        <result property="remark"    column="REMARK"    />
        <result property="pageNum"    column="PAGE_NUM"    />
        <result property="weith"    column="WEITH"    />
        <result property="price"    column="PRICE"    />
        <result property="scaleUnit"    column="SCALE_UNIT"    />
        <result property="goodsTypeId"    column="GOODS_TYPE_ID"    />
        <result property="totalVolume"    column="TOTAL_VOLUME"    />
        <result property="gvolume"    column="GVOLUME"    />
        <result property="unit"    column="UNIT"    />
        <result property="storageAreaId"    column="STORAGE_AREA_ID"    />
        <result property="locationId"    column="LOCATION_ID"    />
        <result property="pickNum"    column="PICK_NUM"    />
        <result property="trNum"    column="TR_NUM"    />
        <result property="barcode"    column="BARCODE"    />
        <result property="status"    column="STATUS"    />
        <result property="toLoc"    column="TO_LOC"    />
        <result property="storageId"    column="STORAGE_ID"    />
        <result property="buyNum"    column="BUY_NUM"    />
        <result property="orderId"    column="ORDER_ID"    />
        <result property="addtime"    column="ADDTIME"    />
        <result property="endtime"    column="ENDTIME"    />
        <result property="outStand"    column="OUT_STAND"    />
        <result property="ckType"    column="CK_TYPE"    />
        <result property="putinId"    column="PUTIN_ID"    />
        <result property="userName"    column="USERNAME"    />
    </resultMap>

    <sql id="selectTCkOrderdetailVo">
        select CK_ID, BUSINESSID, GOOD_ID, SPECIFICATION, GOODS_NUM, REMARK, PAGE_NUM, WEITH, PRICE, SCALE_UNIT, GOODS_TYPE_ID, TOTAL_VOLUME, GVOLUME, UNIT, STORAGE_AREA_ID, LOCATION_ID, PICK_NUM, TR_NUM, BARCODE, STATUS, TO_LOC, STORAGE_ID, BUY_NUM, ORDER_ID, ADDTIME, ENDTIME, OUT_STAND, PUTIN_ID, CK_TYPE, USERNAME from t_ck_orderdetail
    </sql>

    <select id="selectTCkOrderdetailList" parameterType="TCkOrderdetail" resultMap="TCkOrderdetailResult">
        <include refid="selectTCkOrderdetailVo"/>
        <where>  
            <if test="ckId != null  and ckId != ''"> and CK_ID = #{ckId}</if>
            <if test="businessid != null  and businessid != ''"> and BUSINESSID = #{businessid}</if>
            <if test="goodId != null  and goodId != ''"> and GOOD_ID = #{goodId}</if>
            <if test="specification != null  and specification != ''"> and SPECIFICATION = #{specification}</if>
            <if test="goodsNum != null "> and GOODS_NUM = #{goodsNum}</if>
            <if test="remark != null  and remark != ''"> and REMARK = #{remark}</if>
            <if test="pageNum != null "> and PAGE_NUM = #{pageNum}</if>
            <if test="weith != null "> and WEITH = #{weith}</if>
            <if test="price != null "> and PRICE = #{price}</if>
            <if test="scaleUnit != null  and scaleUnit != ''"> and SCALE_UNIT = #{scaleUnit}</if>
            <if test="goodsTypeId != null  and goodsTypeId != ''"> and GOODS_TYPE_ID = #{goodsTypeId}</if>
            <if test="totalVolume != null "> and TOTAL_VOLUME = #{totalVolume}</if>
            <if test="gvolume != null "> and GVOLUME = #{gvolume}</if>
            <if test="unit != null  and unit != ''"> and UNIT = #{unit}</if>
            <if test="storageAreaId != null  and storageAreaId != ''"> and STORAGE_AREA_ID = #{storageAreaId}</if>
            <if test="locationId != null  and locationId != ''"> and LOCATION_ID = #{locationId}</if>
            <if test="pickNum != null "> and PICK_NUM = #{pickNum}</if>
            <if test="trNum != null "> and TR_NUM = #{trNum}</if>
            <if test="barcode != null  and barcode != ''"> and BARCODE = #{barcode}</if>
            <if test="status != null  and status != ''"> and STATUS = #{status}</if>
            <if test="toLoc != null  and toLoc != ''"> and TO_LOC = #{toLoc}</if>
            <if test="storageId != null  and storageId != ''"> and STORAGE_ID = #{storageId}</if>
            <if test="buyNum != null "> and BUY_NUM = #{buyNum}</if>
            <if test="orderId != null  and orderId != ''"> and ORDER_ID = #{orderId}</if>
            <if test="addtime != null "> and ADDTIME = #{addtime}</if>
            <if test="endtime != null "> and ENDTIME = #{endtime}</if>
            <if test="outStand != null and outStand != ''"> and OUT_STAND = #{outStand}</if>
            <if test="putinId != null and putinId != ''"> and PUTIN_ID = #{putinId}</if>
            <if test="ckType != null and ckType != ''"> and CK_TYPE = #{ckType}</if>
            <if test="userName != null and userName != ''"> and USERNAME = #{userName}</if>
        </where>
    </select>
    
    <select id="selectTCkOrderdetailByCkId" parameterType="String" resultMap="TCkOrderdetailResult">
        <include refid="selectTCkOrderdetailVo"/>
        where CK_ID = #{ckId}
    </select>

    <select id="selectMesTask" parameterType="TCkOrderdetail" resultMap="TCkOrderdetailResult">
        <include refid="selectTCkOrderdetailVo"/>
        <where>
            <if test="goodId != null  and goodId != ''"> and GOOD_ID = #{goodId}</if>
            <if test="pickNum != null "> and PICK_NUM = #{pickNum}</if>
            <if test="status != null  and status != ''"> and STATUS = #{status}</if>
            <if test="orderId != null  and orderId != ''"> and ORDER_ID = #{orderId}</if>
            <if test="userName != null and userName != ''"> and USERNAME = #{userName}</if>
        </where>
        order by GOOD_ID, ORDER_ID
    </select>
        
    <insert id="insertTCkOrderdetail" parameterType="TCkOrderdetail">
        insert into t_ck_orderdetail
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="ckId != null and ckId != ''">CK_ID,</if>
            <if test="businessid != null">BUSINESSID,</if>
            <if test="goodId != null">GOOD_ID,</if>
            <if test="specification != null">SPECIFICATION,</if>
            <if test="goodsNum != null">GOODS_NUM,</if>
            <if test="remark != null">REMARK,</if>
            <if test="pageNum != null">PAGE_NUM,</if>
            <if test="weith != null">WEITH,</if>
            <if test="price != null">PRICE,</if>
            <if test="scaleUnit != null">SCALE_UNIT,</if>
            <if test="goodsTypeId != null">GOODS_TYPE_ID,</if>
            <if test="totalVolume != null">TOTAL_VOLUME,</if>
            <if test="gvolume != null">GVOLUME,</if>
            <if test="unit != null">UNIT,</if>
            <if test="storageAreaId != null">STORAGE_AREA_ID,</if>
            <if test="locationId != null">LOCATION_ID,</if>
            <if test="pickNum != null">PICK_NUM,</if>
            <if test="trNum != null">TR_NUM,</if>
            <if test="barcode != null">BARCODE,</if>
            <if test="status != null">STATUS,</if>
            <if test="toLoc != null">TO_LOC,</if>
            <if test="storageId != null">STORAGE_ID,</if>
            <if test="buyNum != null">BUY_NUM,</if>
            <if test="orderId != null">ORDER_ID,</if>
            <if test="addtime != null">ADDTIME,</if>
            <if test="endtime != null">ENDTIME,</if>
            <if test="outStand != null">OUT_STAND,</if>
            <if test="ckType != null">CK_TYPE,</if>
            <if test="putinId != null">PUTIN_ID,</if>
            <if test="userName != null">USERNAME,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="ckId != null and ckId != ''">#{ckId},</if>
            <if test="businessid != null">#{businessid},</if>
            <if test="goodId != null">#{goodId},</if>
            <if test="specification != null">#{specification},</if>
            <if test="goodsNum != null">#{goodsNum},</if>
            <if test="remark != null">#{remark},</if>
            <if test="pageNum != null">#{pageNum},</if>
            <if test="weith != null">#{weith},</if>
            <if test="price != null">#{price},</if>
            <if test="scaleUnit != null">#{scaleUnit},</if>
            <if test="goodsTypeId != null">#{goodsTypeId},</if>
            <if test="totalVolume != null">#{totalVolume},</if>
            <if test="gvolume != null">#{gvolume},</if>
            <if test="unit != null">#{unit},</if>
            <if test="storageAreaId != null">#{storageAreaId},</if>
            <if test="locationId != null">#{locationId},</if>
            <if test="pickNum != null">#{pickNum},</if>
            <if test="trNum != null">#{trNum},</if>
            <if test="barcode != null">#{barcode},</if>
            <if test="status != null">#{status},</if>
            <if test="toLoc != null">#{toLoc},</if>
            <if test="storageId != null">#{storageId},</if>
            <if test="buyNum != null">#{buyNum},</if>
            <if test="orderId != null">#{orderId},</if>
            <if test="addtime != null">#{addtime},</if>
            <if test="endtime != null">#{endtime},</if>
            <if test="outStand != null">#{outStand},</if>
            <if test="ckType != null">#{ckType},</if>
            <if test="putinId != null">#{putinId},</if>
            <if test="userName != null">#{userName},</if>
         </trim>
    </insert>

    <update id="updateTCkOrderdetail" parameterType="TCkOrderdetail">
        update t_ck_orderdetail
        <trim prefix="SET" suffixOverrides=",">
            <if test="businessid != null">BUSINESSID = #{businessid},</if>
            <if test="goodId != null">GOOD_ID = #{goodId},</if>
            <if test="specification != null">SPECIFICATION = #{specification},</if>
            <if test="goodsNum != null">GOODS_NUM = #{goodsNum},</if>
            <if test="remark != null">REMARK = #{remark},</if>
            <if test="pageNum != null">PAGE_NUM = #{pageNum},</if>
            <if test="weith != null">WEITH = #{weith},</if>
            <if test="price != null">PRICE = #{price},</if>
            <if test="scaleUnit != null">SCALE_UNIT = #{scaleUnit},</if>
            <if test="goodsTypeId != null">GOODS_TYPE_ID = #{goodsTypeId},</if>
            <if test="totalVolume != null">TOTAL_VOLUME = #{totalVolume},</if>
            <if test="gvolume != null">GVOLUME = #{gvolume},</if>
            <if test="unit != null">UNIT = #{unit},</if>
            <if test="storageAreaId != null">STORAGE_AREA_ID = #{storageAreaId},</if>
            <if test="locationId != null">LOCATION_ID = #{locationId},</if>
            <if test="pickNum != null">PICK_NUM = #{pickNum},</if>
            <if test="trNum != null">TR_NUM = #{trNum},</if>
            <if test="barcode != null">BARCODE = #{barcode},</if>
            <if test="status != null">STATUS = #{status},</if>
            <if test="toLoc != null">TO_LOC = #{toLoc},</if>
            <if test="storageId != null">STORAGE_ID = #{storageId},</if>
            <if test="buyNum != null">BUY_NUM = #{buyNum},</if>
            <if test="orderId != null">ORDER_ID = #{orderId},</if>
            <if test="addtime != null">ADDTIME = #{addtime},</if>
            <if test="endtime != null">ENDTIME = #{endtime},</if>
            <if test="outStand != null">OUT_STAND = #{outStand},</if>
            <if test="ckType != null">CK_TYPE = #{ckType},</if>
            <if test="putinId != null">PUTIN_ID = #{putinId},</if>
            <if test="userName != null">USERNAME = #{userName},</if>
        </trim>
        <where>
            <if test="ckId != null  and ckId != ''"> and CK_ID = #{ckId}</if>
            <if test="businessid != null  and businessid != ''"> and BUSINESSID = #{businessid}</if>
            <if test="goodId != null  and goodId != ''"> and GOOD_ID = #{goodId}</if>
            <if test="specification != null  and specification != ''"> and SPECIFICATION = #{specification}</if>
            <if test="goodsNum != null "> and GOODS_NUM = #{goodsNum}</if>
            <if test="remark != null  and remark != ''"> and REMARK = #{remark}</if>
            <if test="pageNum != null "> and PAGE_NUM = #{pageNum}</if>
            <if test="weith != null "> and WEITH = #{weith}</if>
            <if test="price != null "> and PRICE = #{price}</if>
            <if test="scaleUnit != null  and scaleUnit != ''"> and SCALE_UNIT = #{scaleUnit}</if>
            <if test="goodsTypeId != null  and goodsTypeId != ''"> and GOODS_TYPE_ID = #{goodsTypeId}</if>
            <if test="totalVolume != null "> and TOTAL_VOLUME = #{totalVolume}</if>
            <if test="gvolume != null "> and GVOLUME = #{gvolume}</if>
            <if test="unit != null  and unit != ''"> and UNIT = #{unit}</if>
            <if test="storageAreaId != null  and storageAreaId != ''"> and STORAGE_AREA_ID = #{storageAreaId}</if>
            <if test="locationId != null  and locationId != ''"> and LOCATION_ID = #{locationId}</if>
            <if test="pickNum != null "> and PICK_NUM = #{pickNum}</if>
            <if test="trNum != null "> and TR_NUM = #{trNum}</if>
            <if test="barcode != null  and barcode != ''"> and BARCODE = #{barcode}</if>
            <if test="status != null  and status != ''"> and STATUS = #{status}</if>
            <if test="toLoc != null  and toLoc != ''"> and TO_LOC = #{toLoc}</if>
            <if test="storageId != null  and storageId != ''"> and STORAGE_ID = #{storageId}</if>
            <if test="buyNum != null "> and BUY_NUM = #{buyNum}</if>
            <if test="orderId != null  and orderId != ''"> and ORDER_ID = #{orderId}</if>
            <if test="addtime != null "> and ADDTIME = #{addtime}</if>
            <if test="endtime != null "> and ENDTIME = #{endtime}</if>
            <if test="outStand != null and outStand != ''"> and OUT_STAND = #{outStand}</if>
            <if test="putinId != null and putinId != ''"> and PUTIN_ID = #{putinId}</if>
            <if test="ckType != null and ckType != ''"> and CK_TYPE = #{ckType}</if>
            <if test="userName != null and userName != ''"> and USERNAME = #{userName}</if>
        </where>
    </update>

    <delete id="deleteTCkOrderdetailByCkId" parameterType="String">
        delete from t_ck_orderdetail where CK_ID = #{ckId}
    </delete>

    <delete id="deleteTCkOrderdetailByCkIds" parameterType="String">
        delete from t_ck_orderdetail where CK_ID in 
        <foreach item="ckId" collection="array" open="(" separator="," close=")">
            #{ckId}
        </foreach>
    </delete>

</mapper>