<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc = "进程表">
<query id = "FrmProcessOrder.getProcessOrder" desc = "进程数据查询">
<![CDATA[
SELECT 
       T.ORD_PK,
       T.ORD_LN_PK,
       T.ORD_LN_DLY_PK,
       T.DELVRY_QTY,
       T.ORDER_UNIT,
       T.ENSU_TOTL_LEN,
       T.APP_NUM,
       T.APP_UNIT,
       T.PSS_NUM,
       T.PSS_WGT,
       T.PAY_NUM,
       T.PAY_LEN,
       T.PAY_WGT,
       T.NEG_PAY_NUM,
       T.NEG_PAY_LEN,
       T.NEG_PAY_WGT,
       T.OUT_NUM,
       T.OUT_WGT,
       T.OUT_LEN,
       T.NEG_OUT_NUM,
       T.NEG_OUT_WGT,
       T.NEG_OUT_LEN,
       T.ELIM_NUM,
       T.ELIM_WGT,
       T.ELIM_LEN,
       T.CHARGE_NUM,
       T.CHARGE_WGT,
       T.CHARGE_LEN,
       T.SOK_WGT,
       T.INV_NUM,
       T.INV_WGT,
       T.INV_LEN,
       T.ONV_NUM,
       T.ONV_WGT,
       T.ONV_LEN,
       T.EVENT_ID,
       T.EVENT_DESC,
       T.FORM_NAME,
       T.CALL_FUNC_CODING,
       TO_CHAR(T.UPDATE_TIME, 'YYYY-MM-DD HH24:MI:SS') UPDATE_TIME,
       T1.ORDER_NO,
       T2.ORDER_SEQ,
       T3.DELIVERY_NO,
       T2.LEN_UNIT,
       (SELECT T6.BASENAME
          FROM COM_BASE_INFO T6
         WHERE T6.BASECODE = T3.DELIVERY_STATUS) DELIVERY_STATUS,
        (SELECT T6.BASENAME
          FROM COM_BASE_INFO T6
         WHERE T6.BASECODE = T2.ORDER_LN_STATUS) ORDER_LN_STATUS,
         T.ACCOUNT_NUM,
         T.ACCOUNT_WGT,
         T.ACCOUNT_LEN,
         T1.SALE_ORG_DESC,
         T1.SALE_AREA_DESC,
         (SELECT T7.BASENAME
          FROM COM_BASE_INFO T7
         WHERE T7.BASECODE = T1.SUPPLY_UNIT) SUPPLY_UNIT,
         T1.CREATE_NAME,
         T3.RECEIV_NM,
         DECODE(T1.CONTAIN_TAX,'0','否','是')CONTAIN_TAX,
         (SELECT T7.BASENAME
          FROM COM_BASE_INFO T7
         WHERE T7.BASECODE = T1.FST_DRAWEE_UNIT) FST_DRAWEE_UNIT,
         (CASE
            WHEN
            T1.FST_DRAWEE_UNIT ='120607'
            THEN
            T2.BALNCE_PRICE
            WHEN
            T1.FST_DRAWEE_UNIT ='120608' AND T1.SUPPLY_UNIT='120501'
            THEN
            T2.BALNCE_PRICE
            WHEN
            T1.FST_DRAWEE_UNIT !='120607' AND T1.SUPPLY_UNIT='120504'
            THEN
            T2.BALNCE_PRICE_ORG
            ELSE
            T2.BALNCE_PRICE
            END) BALNCE_PRICE,T2.BALNCE_PRICE_ORG BALNCE_PRICE_ORG,T2.BALNCE_PRICE BALNCE_PRICE1,
            T2.PRODUCNAME,
            T2.STD_NAME,
            T2.STEELNAME,
            T2.STD_STYLE_DESC,
            T2.SPEC_NAME，
            T2.MODEL_DESC,
            T1.ORDER_STS_DESC PORDERSTATUS,
            t1.ORDER_TYP_DESC,
            t2.DELVRY_RANGE_MIN DELVRY_RANGE_MIN,
            t2.DELVRY_RANGE_TPE,
            t2.DELVRY_RANGE_MAX,
            t3.DELVRY_EDATE,
            (SELECT MAX(JUDGE_TOLRESULT_TIME) FROM QCM_ZG_JUGDE_APPLY WHERE ORD_LN_DLY_PK = T3.ORD_LN_DLY_PK AND TARGET = 'A')  JUDGE_TOLRESULT_TIME,
            (SELECT CREATE_TIME FROM PLN_SALEORD WHERE ORD_LN_DLY_PK = T3.ORD_LN_DLY_PK AND ROWNUM = 1) APP_CREATE_TIME,
            t1.CUSTOMER_NM,
            nvl(T4.ACT_WT,0) BILL_ACT_WT,
            nvl(T4.ACT_NUM,0) BILL_ACT_NUM,
            nvl(T4.ACT_TOTL_LEN,0) BILL_ACT_TOTL_LEN,
            nvl(T5.QUANTITY,0) BALANCE_QUANTITY,
            nvl(T5.WEIGHT,0) BALANCE_WEIGHT,
            nvl(T6.ACT_LEN,0) MAT_ACT_LEN,
            nvl(T6.ACT_WEIGHT,0) MAT_ACT_WEIGHT,
            nvl(T6.ACT_COUNT,0) MAT_ACT_COUNT,
            nvl( T7.ACT_LEN, 0 ) JUDGE_ACT_LEN,
            nvl( T7.ACT_WEIGHT, 0 ) JUDGE_ACT_WEIGHT,
            nvl( T7.ACT_COUNT, 0 ) JUDGE_ACT_COUNT
 FROM PROCESS_ORDER_M T
 LEFT JOIN SLM_ORDER_HEAD T1 ON T.ORD_PK = T1.ORD_PK
 LEFT JOIN SLM_ORDER_LINE T2 ON T.ORD_LN_PK = T2.ORD_LN_PK
 LEFT JOIN SLM_ORDER_LINE_DELIVERY T3 ON T.ORD_LN_DLY_PK = T3.ORD_LN_DLY_PK
 -- LEFT JOIN COM_BASE_INFO T4 ON T.ORD_LN_DLY_PK = T4.BASECODE
 LEFT JOIN (
				SELECT
					B_C.ORD_LN_DLY_PK,
					SUM( B_C.ACT_WEIGHT ) ACT_WT,
					SUM( B_C.ACT_COUNT ) ACT_NUM,
					SUM( B_C.ACT_LEN ) ACT_TOTL_LEN
				FROM
					 YDM_ZC_BILL_M B_M
					left JOIN YDM_ZC_BILL_c B_C ON B_C.BILL_NO = B_M.BILL_NO
					and B_C.ORD_LN_DLY_PK = B_M.ORD_LN_DLY_PK
				WHERE
					B_C.VALIDFLAG = '1'
					AND B_C.RETURN_FLAG = '0'
					AND B_M.BILL_STATUS IN ( '1', '2', '3' )
				GROUP BY
					B_C.ORD_LN_DLY_PK
				) T4 ON T3.ORD_LN_DLY_PK = T4.ORD_LN_DLY_PK
				LEFT JOIN (
				SELECT
					T.ORD_LN_DLY_PK,
					SUM( T.QUANTITY ) QUANTITY,
					SUM( T.WEIGHT ) WEIGHT
				FROM
					SLM_BALANCEINFO T
				WHERE
					BALANCESTATUS IN ( '0', '1', '2' )
				GROUP BY
					T.ORD_LN_DLY_PK
				) T5 ON T3.ORD_LN_DLY_PK = T5.ORD_LN_DLY_PK
				LEFT JOIN ( SELECT ORD_LN_DLY_PK, SUM( ACT_LEN ) ACT_LEN, SUM( ACT_WEIGHT ) ACT_WEIGHT, SUM( ACT_COUNT ) ACT_COUNT FROM MAT_ZC_M GROUP BY ORD_LN_DLY_PK
				) T6 ON T3.ORD_LN_DLY_PK = T6.ORD_LN_DLY_PK
				LEFT JOIN (
				SELECT
					Q.ORD_LN_DLY_PK,
					SUM( Q.ACT_WEIGHT ) ACT_WEIGHT,
					SUM( Q.ACT_COUNT ) ACT_COUNT,
					SUM( Q.ACT_LEN ) ACT_LEN
				FROM
					QCM_ZG_JUGDE_APPLY Q
				WHERE
					Q.TARGET = 'A'
				GROUP BY
					Q.ORD_LN_DLY_PK
				) T7 ON T3.ORD_LN_DLY_PK = T7.ORD_LN_DLY_PK
 WHERE
 T1.VALIDFLAG = '1'
 AND T1.VALIDFLAG = '1'
 AND T3.VALIDFLAG = '1'
 AND T1.ORDER_NO LIKE '%' || ? || '%'
 AND T1.SUPPLY_UNIT LIKE '%' || ? || '%'
 AND T1.STLMT_UNIT_NO LIKE '%' || ? || '%'
]]>
</query>
</queryMap>