<?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.prolog.upcloud.base.wh.operate.dao.WmsCargoChangeMapper">
    <resultMap id="BaseResultMap" type="com.prolog.upcloud.base.wh.operate.model.WmsCargoChange">
        <id column="HEADER_ID" jdbcType="VARCHAR" property="headerId"/>
        <result column="REF_BILL_NO" jdbcType="VARCHAR" property="refBillNo"/>
        <result column="WAREHOUSE_ID" jdbcType="VARCHAR" property="warehouseId"/>
        <result column="WAREHOUSE_NAME" jdbcType="VARCHAR" property="warehouseName"/>
        <result column="WAREHOUSE_CODE" jdbcType="VARCHAR" property="warehouseCode"/>
        <result column="PO_BILL_ID" jdbcType="VARCHAR" property="poBillId"/>
        <result column="PO_BILL_NO" jdbcType="VARCHAR" property="poBillNo"/>
        <result column="ORDER_BILL_ID" jdbcType="VARCHAR" property="orderBillId"/>
        <result column="ORDER_BILL_NO" jdbcType="VARCHAR" property="orderBillNo"/>
        <result column="SRC_CARGO_OWNER_ID" jdbcType="VARCHAR" property="srcCargoOwnerId"/>
        <result column="SRC_CARGO_OWNER_NAME" jdbcType="VARCHAR" property="srcCargoOwnerName"/>
        <result column="DEST_CARGO_OWNER_ID" jdbcType="VARCHAR" property="destCargoOwnerId"/>
        <result column="DEST_CARGO_OWNER_NAME" jdbcType="VARCHAR" property="destCargoOwnerName"/>
        <result column="STATUS" jdbcType="CHAR" property="status"/>
        <result column="ERR_MSG" jdbcType="VARCHAR" property="errMsg"/>
        <result column="CANCEL_REASON" jdbcType="VARCHAR" property="cancelReason"/>
        <result column="SOURCE_TYPE" jdbcType="VARCHAR" property="sourceType"/>
        <result column="BILL_DATE" jdbcType="TIMESTAMP" property="billDate"/>
        <result column="REMARK" jdbcType="VARCHAR" property="remark"/>
        <result column="ENTERPRISE_ID" jdbcType="VARCHAR" property="enterpriseId"/>
        <result column="CREATOR" jdbcType="VARCHAR" property="creator"/>
        <result column="CREATOR_NAME" jdbcType="VARCHAR" property="creatorName"/>
        <result column="GMT_CREATE" jdbcType="TIMESTAMP" property="gmtCreate"/>
        <result column="MODIFIER" jdbcType="VARCHAR" property="modifier"/>
        <result column="MODIFIER_NAME" jdbcType="VARCHAR" property="modifierName"/>
        <result column="GMT_MODIFYED" jdbcType="TIMESTAMP" property="gmtModified"/>
    </resultMap>
    <sql id="columns">
        HEADER_ID, REF_BILL_NO, WAREHOUSE_ID, WAREHOUSE_NAME, WAREHOUSE_CODE, PO_BILL_ID, PO_BILL_NO, ORDER_BILL_ID, ORDER_BILL_NO, SRC_CARGO_OWNER_ID, SRC_CARGO_OWNER_NAME, DEST_CARGO_OWNER_ID, DEST_CARGO_OWNER_NAME, STATUS, ERR_MSG, CANCEL_REASON, SOURCE_TYPE, BILL_DATE, REMARK, ENTERPRISE_ID, CREATOR, CREATOR_NAME, GMT_CREATE, MODIFIER, MODIFIER_NAME, GMT_MODIFIED
    </sql>
    <select id="getMoveDoneList" resultMap="BaseResultMap">
        select
        <include refid="columns"/>
        from WMS_CARGO_CHANGE C
        where not exists(select 1
        from WMS_CARGO_CHANGE_RESULT R
        WHERE C.HEADER_ID = R.HEADER_ID
        and R.MOVE_FLAG=#{moveFlag}
        and R.DETAIL_ID IN
        <foreach collection="detailIds" item="detailId" open="(" close=")" separator=",">
            #{detailId}
        </foreach>
        )
    </select>
</mapper>
