<?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.OmsCnsConversionMapper">
    <resultMap id="BaseResultMap" type="com.prolog.upcloud.base.wh.operate.model.OmsCnsConversion">
        <id column="BILLID" jdbcType="VARCHAR" property="billid"/>
        <result column="BILLNO" jdbcType="VARCHAR" property="billno"/>
        <result column="BRANCHID" jdbcType="VARCHAR" property="branchid"/>
        <result column="BRANCHCODE" jdbcType="VARCHAR" property="branchcode"/>
        <result column="BRANCHNAME" jdbcType="VARCHAR" property="branchname"/>
        <result column="SOURCECONSIGNORID" jdbcType="VARCHAR" property="sourceconsignorid"/>
        <result column="SOURCECONSIGNORNAME" jdbcType="VARCHAR" property="sourceconsignorname"/>
        <result column="ORDER_BILL_ID" jdbcType="VARCHAR" property="orderBillId"/>
        <result column="ORDER_BILL_NO" jdbcType="VARCHAR" property="orderBillNo"/>
        <result column="SOURCEITEMID" jdbcType="VARCHAR" property="sourceitemid"/>
        <result column="SOURCEITEMNAME" jdbcType="VARCHAR" property="sourceitemname"/>
        <result column="TARGETCONSIGNORID" jdbcType="VARCHAR" property="targetconsignorid"/>
        <result column="TARGETCONSIGNORNAME" jdbcType="VARCHAR" property="targetconsignorname"/>
        <result column="PO_BILL_ID" jdbcType="VARCHAR" property="poBillId"/>
        <result column="PO_BILL_NO" jdbcType="VARCHAR" property="poBillNo"/>
        <result column="TARGETITEMID" jdbcType="VARCHAR" property="targetitemid"/>
        <result column="TARGETITEMNAME" jdbcType="VARCHAR" property="targetitemname"/>
        <result column="LOTNO" jdbcType="VARCHAR" property="lotno"/>
        <result column="QTY" jdbcType="DECIMAL" property="qty"/>
        <result column="BILL_DATE" jdbcType="TIMESTAMP" property="billDate"/>
        <result column="REMARK" jdbcType="VARCHAR" property="remark"/>
        <result column="CLOSED_REASON" jdbcType="VARCHAR" property="closedReason"/>
        <result column="STATUS" jdbcType="VARCHAR" property="status"/>
        <result column="ATTR_STR1" jdbcType="VARCHAR" property="attrStr1"/>
        <result column="ATTR_STR2" jdbcType="VARCHAR" property="attrStr2"/>
        <result column="ATTR_STR3" jdbcType="VARCHAR" property="attrStr3"/>
        <result column="ATTR_STR4" jdbcType="VARCHAR" property="attrStr4"/>
        <result column="ATTR_STR5" jdbcType="VARCHAR" property="attrStr5"/>
        <result column="ATTR_STR6" jdbcType="VARCHAR" property="attrStr6"/>
        <result column="ATTR_STR7" jdbcType="VARCHAR" property="attrStr7"/>
        <result column="ATTR_STR8" jdbcType="VARCHAR" property="attrStr8"/>
        <result column="ATTR_STR9" jdbcType="VARCHAR" property="attrStr9"/>
        <result column="ATTR_STR10" jdbcType="VARCHAR" property="attrStr10"/>
        <result column="ATTR_NUM1" jdbcType="DECIMAL" property="attrNum1"/>
        <result column="ATTR_NUM2" jdbcType="DECIMAL" property="attrNum2"/>
        <result column="ATTR_NUM3" jdbcType="DECIMAL" property="attrNum3"/>
        <result column="ATTR_NUM4" jdbcType="DECIMAL" property="attrNum4"/>
        <result column="ATTR_NUM5" jdbcType="DECIMAL" property="attrNum5"/>
        <result column="ATTR_DTE1" jdbcType="TIMESTAMP" property="attrDte1"/>
        <result column="ATTR_DTE2" jdbcType="TIMESTAMP" property="attrDte2"/>
        <result column="ATTR_DTE3" jdbcType="TIMESTAMP" property="attrDte3"/>
        <result column="ATTR_DTE4" jdbcType="TIMESTAMP" property="attrDte4"/>
        <result column="ATTR_DTE5" jdbcType="TIMESTAMP" property="attrDte5"/>
        <result column="CREATEBY" jdbcType="VARCHAR" property="createby"/>
        <result column="CREATEDATE" jdbcType="TIMESTAMP" property="createdate"/>
        <result column="LASTMODIFYBY" jdbcType="VARCHAR" property="lastmodifyby"/>
        <result column="LASTMODIFYDATE" jdbcType="TIMESTAMP" property="lastmodifydate"/>
        <result column="P_ENTERPRISEID" jdbcType="VARCHAR" property="pEnterpriseid"/>
        <result column="P_ENTERPRISENAME" jdbcType="VARCHAR" property="pEnterprisename"/>
    </resultMap>
    <sql id="Base_Column_List">
        BILLID, BILLNO, BRANCHID, BRANCHCODE, BRANCHNAME, SOURCECONSIGNORID, SOURCECONSIGNORNAME,
    ORDER_BILL_ID, ORDER_BILL_NO, SOURCEITEMID, SOURCEITEMNAME, TARGETCONSIGNORID, TARGETCONSIGNORNAME,
    PO_BILL_ID, PO_BILL_NO, TARGETITEMID, TARGETITEMNAME, LOTNO, QTY, BILL_DATE, REMARK,
    CLOSED_REASON, "STATUS", ATTR_STR1, ATTR_STR2, ATTR_STR3, ATTR_STR4, ATTR_STR5, ATTR_STR6,
    ATTR_STR7, ATTR_STR8, ATTR_STR9, ATTR_STR10, ATTR_NUM1, ATTR_NUM2, ATTR_NUM3, ATTR_NUM4,
    ATTR_NUM5, ATTR_DTE1, ATTR_DTE2, ATTR_DTE3, ATTR_DTE4, ATTR_DTE5, CREATEBY, CREATEDATE,
    LASTMODIFYBY, LASTMODIFYDATE, P_ENTERPRISEID, P_ENTERPRISENAME
    </sql>
    <select id="getSourceHeaderList" resultType="com.prolog.upcloud.base.wh.operate.vo.OmsCnsConversionListVO">
        SELECT DISTINCT billno,
                        branchid,
                        branchcode,
                        branchname,
                        sourceconsignorid,
                        sourceconsignorname,
                        targetconsignorid,
                        targetconsignorname,
                        ORDER_BILL_ID,
                        ORDER_BILL_NO,
                        PO_BILL_ID,
                        PO_BILL_NO,
                        BILL_DATE
        FROM UPCLOUD_BIZ_WH_OPERATE.OMS_CNS_CONVERSION C
        WHERE
        BRANCHID = #{warehouseId}
        AND NOT EXISTS(SELECT 1 FROM WMS_CARGO_CHANGE WHERE WMS_CARGO_CHANGE.REF_BILL_NO = C.BILLNO)
    </select>
</mapper>
