<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="出库申核报表">
	<query id="FrmOutFactory.getOutFactory" desc="出库申核信息查询">
            <![CDATA[
              SELECT T1.BILL_NO,
       T1.ORDER_NO || '/' || T1.ORDER_SEQ ORDER_NO,
       T1.RECEIV_NM,
       T2.DELVRY_ADDR DELIVY_PLACE_NAME,
       T1.SPCL_LN_NM,
       DECODE(T1.TRANS_TPE, '110501', '自提','110502', '铁路','') TRANS_TPE,
       T1.STATION_NM,
       T1.PRODUCNAME,
       T1.GRADENAME,
       T1.SPEC_NAME,
       T1.MODEL_DESC,
       T1.STD_NAME,
       --T1.ACT_LEN_MIN || '-' || T1.ACT_LEN_MAX LEN_DESC,
       TO_CHAR(MAX(T1.CREATE_TIME),'YYYY-MM-DD HH24:MI:SS') OUT_TIME,
       T1.MEMO,
       T2.PLAN_NUM PLAN_COUNT,
       T2.PLAN_WT PLAN_WEIGHT,
       SUM(T1.ACT_COUNT) ACT_COUNT,
       SUM(T1.ACT_WEIGHT) ACT_WEIGHT,
       TO_CHAR(MAX(T1.CREATE_TIME), 'YYYY') YEAR,
       TO_CHAR(MAX(T1.CREATE_TIME), 'MM')  MONTH,
       T2.MANAGEMENT_NAME SALE_DESC,
       T4.STORAGE_NAME,
       DECODE(T2.DELVRY_ADDR,
              'TPCO库房车板',
              '公司结',
              '指定地点',
              '公司结',
              'TPCO库房',
              '自结',
              '客户库-腾飞',
              '自结',
              '客户库-宝仓',
              '自结',
              '客户库-安利',
              '自结',
              '客户库-润德',
              '自结',
              '客户库-思创',
              '自结',
              '客户库-滨城',
              '自结',
              '') OUT_HOUSE,
               COUNT(DISTINCT T1.LOADVEHICLE_NO) CAR_NUMBER
  FROM YDM_ZC_LOADVEHICLE_MAT T1,
       (SELECT T3.BILL_NO,
               T3.DELVRY_ADDR,
               T3.MANAGEMENT_NAME,
                T3.MANAGEMENT_NO,
               SUM(T3.PLAN_NUM) PLAN_NUM,
               SUM(T3.PLAN_WT) PLAN_WT,
               O.SUPPLY_UNIT
          FROM YDM_ZC_BILL_M T3,
          SLM_ORDER_HEAD O
          WHERE T3.ORD_PK = O.ORD_PK(+)
         GROUP BY T3.BILL_NO,
                  T3.DELVRY_ADDR,
                  T3.MANAGEMENT_NO,
                  T3.MANAGEMENT_NAME,
                  O.SUPPLY_UNIT) T2,
       YDM_BS_STORAGE T4
 WHERE T1.BILL_NO = T2.BILL_NO
   AND T1.STORAGE_NO = T4.STORAGE_NO(+)
                ]]>
	</query>
</queryMap>