<?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.dgtly.system.mapper.MetaHanaDeliverOrderMapper">

        <resultMap type="MetaHanaDeliverOrder" id="MetaHanaDeliverOrderResult">
            <result property="deliverNumber"    column="DELIVER_NUMBER"    />
            <result property="deliverItem"    column="DELIVER_ITEM"    />
            <result property="docNumber"    column="DOC_NUMBER"    />
            <result property="docItem"    column="DOC_ITEM"    />
            <result property="salesOrg"    column="SALES_ORG"    />
            <result property="salesOrgName"    column="SALES_ORG_NAME"    />
            <result property="distributionChannel"    column="DISTRIBUTION_CHANNEL"    />
            <result property="customerCode"    column="CUSTOMER_CODE"    />
            <result property="customerName"    column="CUSTOMER_NAME"    />
            <result property="division"    column="DIVISION"    />
            <result property="salesGroup"    column="SALES_GROUP"    />
            <result property="plant"    column="PLANT"    />
            <result property="plantName"    column="PLANT_NAME"    />
            <result property="docType"    column="DOC_TYPE"    />
            <result property="deliverType"    column="DELIVER_TYPE"    />
            <result property="materialCode"    column="MATERIAL_CODE"    />
            <result property="materialName"    column="MATERIAL_NAME"    />
            <result property="sizeDim"    column="SIZE_DIM"    />
            <result property="shipmentNumber"    column="SHIPMENT_NUMBER"    />
            <result property="shipmentCreateDate"    column="SHIPMENT_CREATE_DATE"    />
            <result property="shipToAddress"    column="SHIP_TO_ADDRESS"    />
            <result property="createDateDoc"    column="CREATE_DATE_DOC"    />
            <result property="createDateDocItem"    column="CREATE_DATE_DOC_ITEM"    />
            <result property="createDateDeliver"    column="CREATE_DATE_DELIVER"    />
            <result property="actualDeliverDate"    column="ACTUAL_DELIVER_DATE"    />
            <result property="planDeliverDate"    column="PLAN_DELIVER_DATE"    />
            <result property="requestDeliverDate"    column="REQUEST_DELIVER_DATE"    />
            <result property="requestDeliverDateItem"    column="REQUEST_DELIVER_DATE_ITEM"    />
            <result property="reviewStatus"    column="REVIEW_STATUS"    />
            <result property="orderQty"    column="ORDER_QTY"    />
            <result property="orderWt"    column="ORDER_WT"    />
            <result property="deliverQty"    column="DELIVER_QTY"    />
            <result property="deliverWt"    column="DELIVER_WT"    />
            <result property="netValue"    column="NET_VALUE"    />
            <result property="postingDate"    column="POSTING_DATE"    />
            <result property="expressInfo"    column="EXPRESS_INFO"    />
            <result property="code"    column="code"    />
        </resultMap>

        <select id="selectCount" resultType="int">
            SELECT
                count(0)
            FROM
                meta_hana_deliver_order
        </select>

    <select id="selectMetaDeliverOrderListByNo" resultType="com.dgtly.system.domain.MetaHanaDeliverOrder"  >
        SELECT
            concat(m.DELIVER_NUMBER,m.DELIVER_ITEM) as code,
            m.DELIVER_NUMBER as  deliverNumber,
            m.DELIVER_ITEM as  deliverItem,
            m.DOC_NUMBER as docNumber,
            m.DOC_ITEM as docItem,
            m.CREATE_DATE_DOC as createDateDoc,
            m.CUSTOMER_CODE as customerCode,
            m.CUSTOMER_NAME as customerName,
            m.PLANT,
            m.PLANT_NAME  as plantName,
            m.MATERIAL_CODE as materialCode,
            m.MATERIAL_NAME as materialName,
            m.SIZE_DIM as sizeDim,
            m.SHIPMENT_NUMBER as shipmentNumber,
            m.SHIP_TO_ADDRESS as shipToAddress ,
            m.REVIEW_STATUS as reviewStatus,
            m.DELIVER_WT as deliverWt,
            m.DELIVER_QTY as deliverQty,
            m.NET_VALUE as netValue,
            m.POSTING_DATE as postingDate
        FROM
            meta_hana_deliver_order m   ORDER BY POSTING_DATE asc limit ${pageNo},${pageSize}

    </select>
    <select id="selectMetaDeliverOrderListByYes" resultType="com.dgtly.system.domain.MetaHanaDeliverOrder"  >
        SELECT
            concat(m.DELIVER_NUMBER,m.DELIVER_ITEM) as code,
            m.DELIVER_NUMBER as  deliverNumber,
            m.DELIVER_ITEM as  deliverItem,
            m.DOC_NUMBER as docNumber,
            m.DOC_ITEM as docItem,
            m.CREATE_DATE_DOC as createDateDoc,
            m.CUSTOMER_CODE as customerCode,
            m.CUSTOMER_NAME as customerName,
            m.PLANT,
            m.PLANT_NAME  as plantName,
            m.MATERIAL_CODE as materialCode,
            m.MATERIAL_NAME as materialName,
            m.SIZE_DIM as sizeDim,
            m.SHIPMENT_NUMBER as shipmentNumber,
            m.SHIP_TO_ADDRESS as shipToAddress ,
            m.REVIEW_STATUS as reviewStatus,
            m.DELIVER_WT as deliverWt,
            m.DELIVER_QTY as deliverQty,
            m.NET_VALUE as netValue,
            m.POSTING_DATE as postingDate
        FROM
            meta_hana_deliver_order m  where  m.REVIEW_STATUS='已复核' ORDER BY POSTING_DATE asc limit ${pageNo},${pageSize}

    </select>

    <select id="selectPlant" resultType="java.lang.String">
        select distinct  plant_code from tms_plant
    </select>

    <select id="selectDocNumberByVSBED12" resultType="java.lang.String">
        SELECT distinct DOC_NUMBER FROM `meta_hana_sales_order` where 1=1  and ( VSBED='12' or VSBED='14')
    </select>
</mapper>
