<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="合同余量注销">
	<query id="FrmOrderNoReport.GetQueryOrderNoMount" desc="查询合同">
<![CDATA[
SELECT T.ORDER_NO,
       T.ORD_PK,
       T.ORD_LN_PK,
       T.PRODUCNAME,
       T.STD_NAME,
       T.STEELNAME,
       T.SPEC_NAME,
       T.MODEL_DESC,
       T.ORDER_QTY,
       T.ORDER_UNIT,
       T.ORD_ENSU_TOTL_LEN,
       T.DELVRY_MIN,
       T.DELVRY_MAX,
       T.ORDER_LN_STATUS,
       SUM(NVL(T.APP_NUM, 0)) APP_NUM,
       SUM(NVL(T.PSS_NUM, 0)) PSS_NUM,
       SUM(NVL(T.PSS_WGT, 0)) PSS_WGT,
       SUM(NVL(T.PAY_NUM, 0)) PAY_NUM,
       SUM(NVL(T.PAY_WGT, 0)) PAY_WGT,
       SUM(NVL(T.PAY_LEN, 0)) PAY_LEN,
       SUM(NVL(T.INSTORAGE_NUM, 0)) INSTORAGE_NUM,
       SUM(NVL(T.INSTORAGE_WGT, 0)) INSTORAGE_WGT,
       SUM(NVL(T.INSTORAGE_LEN, 0)) INSTORAGE_LEN,
       SUM(NVL(T.OUT_NUM, 0)) OUT_NUM,
       SUM(NVL(T.OUT_WGT, 0)) OUT_WGT,
       SUM(NVL(T.OUT_LEN, 0)) OUT_LEN,
       SUM(NVL(T.SENDBILL_NUM, 0)) SENDBILL_NUM,
       SUM(NVL(T.SENDBILL_WGT, 0)) SENDBILL_WGT,
       SUM(NVL(T.SENDBILL_LEN, 0)) SENDBILL_LEN,
       SUM(NVL(T.ACCOUNT_NUM, 0)) ACCOUNT_NUM,
       SUM(NVL(T.ACCOUNT_WGT, 0)) ACCOUNT_WGT,
       SUM(NVL(T.ACCOUNT_LEN, 0)) ACCOUNT_LEN,
       SUM(NVL(T.ELIM_NUM, 0)) ELIM_NUM,
       SUM(NVL(T.ELIM_WGT, 0)) ELIM_WGT,
       SUM(NVL(T.ELIM_LEN, 0)) ELIM_LEN,
       SUM(NVL(T.CHARGE_NUM, 0)) CHARGE_NUM,
       SUM(NVL(T.CHARGE_WGT, 0)) CHARGE_WGT,
       SUM(NVL(T.CHARGE_LEN, 0)) CHARGE_LEN
  FROM (SELECT B.ORDER_NO || '/' || A.ORDER_SEQ ORDER_NO,
               A.ORD_PK,
               A.ORD_LN_PK,
               A.PRODUCNAME,
               A.STD_NAME,
               A.STEELNAME,
               A.SPEC_NAME,
               A.MODEL_DESC,
               NVL(A.ORDER_QTY, 0) ORDER_QTY,
               A.ORDER_UNIT,
               A.ORD_ENSU_TOTL_LEN,
               ('(-' || A.DELVRY_RANGE_MIN || '%' || ',' ||
               A.DELVRY_RANGE_MAX || '%)') DELVRY_RANGE_TPE,
               NVL(A.ORDER_QTY, 0) -
               (NVL(A.DELVRY_RANGE_MIN, 0) / 100) * A.ORDER_QTY DELVRY_MIN,
               NVL(A.ORDER_QTY, 0) +
               (NVL(A.DELVRY_RANGE_MAX, 0) / 100) * A.ORDER_QTY DELVRY_MAX,
               A.ORDER_LN_STATUS,
               (SELECT SUM(NVL(T.ORDER_QTY, 0))
                  FROM PLN_SALEORD T
                 WHERE T.ORD_LN_PK = A.ORD_LN_PK
                   AND T.PORDERSTATUS > '0') APP_NUM,
               (SELECT SUM(NVL(T.PLAN_NUM_D, 0))
                  FROM PLN_SALEORD_PROC T
                 WHERE SUBSTR(T.ORD_LN_DLY_PK, 1, 35) = A.ORD_LN_PK
                   AND (T.PLANSTATUS > '1' AND T.PLANSTATUS <> '9')) PSS_NUM,
               (SELECT SUM(NVL(T.PLAN_WT_D, 0))
                  FROM PLN_SALEORD_PROC T
                 WHERE SUBSTR(T.ORD_LN_DLY_PK, 1, 35) = A.ORD_LN_PK
                   AND (T.PLANSTATUS > '1' AND T.PLANSTATUS <> '9')) PSS_WGT,
               0 PAY_NUM,
               0 PAY_WGT,
               0 PAY_LEN,
               0 INSTORAGE_NUM,
               0 INSTORAGE_WGT,
               0 INSTORAGE_LEN,
               0 OUT_NUM,
               0 OUT_WGT,
               0 OUT_LEN,
               0 SENDBILL_NUM,
               0 SENDBILL_WGT,
               0 SENDBILL_LEN,
               0 ACCOUNT_NUM,
               0 ACCOUNT_WGT,
               0 ACCOUNT_LEN,
               0 ELIM_NUM,
               0 ELIM_WGT,
               0 ELIM_LEN,
               0 CHARGE_NUM,
               0 CHARGE_WGT,
               0 CHARGE_LEN
          FROM SLM_ORDER_LINE A, SLM_ORDER_HEAD B
         WHERE A.ORD_PK = B.ORD_PK
           AND A.VALIDFLAG = '1'
           AND B.VALIDFLAG = '1'
           AND (A.ORDER_LN_STATUS >= '12020402' AND
               INSTR(A.ORDER_LN_STATUS, '12020901') = 0)
          #SALEORG#
           AND A.CREATE_TIME BETWEEN TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS') AND
               TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS')
           AND B.ORDER_NO LIKE '%' || ? || '%'
           AND A.ORDER_LN_STATUS LIKE '%' || ? || '%'
        UNION ALL
        SELECT B.ORDER_NO || '/' || A.ORDER_SEQ ORDER_NO,
               A.ORD_PK,
               A.ORD_LN_PK,
               A.PRODUCNAME,
               A.STD_NAME,
               A.STEELNAME,
               A.SPEC_NAME,
               A.MODEL_DESC,
               NVL(A.ORDER_QTY, 0) ORDER_QTY,
               A.ORDER_UNIT,
               A.ORD_ENSU_TOTL_LEN,
               ('(-' || A.DELVRY_RANGE_MIN || '%' || ',' ||
               A.DELVRY_RANGE_MAX || '%)') DELVRY_RANGE_TPE,
               NVL(A.ORDER_QTY, 0) -
               (NVL(A.DELVRY_RANGE_MIN, 0) / 100) * A.ORDER_QTY DELVRY_MIN,
               NVL(A.ORDER_QTY, 0) +
               (NVL(A.DELVRY_RANGE_MAX, 0) / 100) * A.ORDER_QTY DELVRY_MAX,
               A.ORDER_LN_STATUS,
               0 APP_NUM,
               0 PSS_NUM,
               0 PSS_WGT,
               SUM(JK.ACT_COUNT) PAY_NUM,
               SUM(JK.ACT_WEIGHT) PAY_WGT,
               SUM(JK.ACT_LEN) PAY_LEN,
               0 INSTORAGE_NUM,
               0 INSTORAGE_WGT,
               0 INSTORAGE_LEN,
               0 OUT_NUM,
               0 OUT_WGT,
               0 OUT_LEN,
               0 SENDBILL_NUM,
               0 SENDBILL_WGT,
               0 SENDBILL_LEN,
               0 ACCOUNT_NUM,
               0 ACCOUNT_WGT,
               0 ACCOUNT_LEN,
               0 ELIM_NUM,
               0 ELIM_WGT,
               0 ELIM_LEN,
               0 CHARGE_NUM,
               0 CHARGE_WGT,
               0 CHARGE_LEN
          FROM SLM_ORDER_LINE A, SLM_ORDER_HEAD B, YDM_ZC_INLIST JK
         WHERE A.ORD_PK = B.ORD_PK
           AND A.ORD_LN_PK = JK.ORD_LN_PK
           AND A.VALIDFLAG = '1'
           AND B.VALIDFLAG = '1'
           AND (A.ORDER_LN_STATUS >= '12020402' AND
               INSTR(A.ORDER_LN_STATUS, '12020901') = 0)
          #SALEORG#
           AND JK.INSTOCK_TYPE_CODE IN ('800701', '800706')
           AND JK.PRODUCT_FLAG = '801403'
           AND A.CREATE_TIME BETWEEN TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS') AND
               TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS')
           AND B.ORDER_NO LIKE '%' || ? || '%'
           AND A.ORDER_LN_STATUS LIKE '%' || ? || '%'
         GROUP BY B.ORDER_NO,
                  A.ORDER_SEQ,
                  A.ORD_PK,
                  A.ORD_LN_PK,
                  A.PRODUCNAME,
                  A.STD_NAME,
                  A.STEELNAME,
                  A.SPEC_NAME,
                  A.MODEL_DESC,
                  A.ORDER_QTY,
                  A.ORDER_UNIT,
                  A.ORD_ENSU_TOTL_LEN,
                  A.DELVRY_RANGE_MIN,
                  A.DELVRY_RANGE_MAX,
                  A.ORDER_LN_STATUS
        UNION ALL
        SELECT B.ORDER_NO || '/' || A.ORDER_SEQ ORDER_NO,
               A.ORD_PK,
               A.ORD_LN_PK,
               A.PRODUCNAME,
               A.STD_NAME,
               A.STEELNAME,
               A.SPEC_NAME,
               A.MODEL_DESC,
               NVL(A.ORDER_QTY, 0) ORDER_QTY,
               A.ORDER_UNIT,
               A.ORD_ENSU_TOTL_LEN,
               ('(-' || A.DELVRY_RANGE_MIN || '%' || ',' ||
               A.DELVRY_RANGE_MAX || '%)') DELVRY_RANGE_TPE,
               NVL(A.ORDER_QTY, 0) -
               (NVL(A.DELVRY_RANGE_MIN, 0) / 100) * A.ORDER_QTY DELVRY_MIN,
               NVL(A.ORDER_QTY, 0) +
               (NVL(A.DELVRY_RANGE_MAX, 0) / 100) * A.ORDER_QTY DELVRY_MAX,
               A.ORDER_LN_STATUS,
               0 APP_NUM,
               0 PSS_NUM,
               0 PSS_WGT,
               0 PAY_NUM,
               0 PAY_WGT,
               0 PAY_LEN,
               T1.INSTORAGE_NUM,
               T1.INSTORAGE_WGT,
               T1.INSTORAGE_LEN,
               0 OUT_NUM,
               0 OUT_WGT,
               0 OUT_LEN,
               0 SENDBILL_NUM,
               0 SENDBILL_WGT,
               0 SENDBILL_LEN,
               0 ACCOUNT_NUM,
               0 ACCOUNT_WGT,
               0 ACCOUNT_LEN,
               0 ELIM_NUM,
               0 ELIM_WGT,
               0 ELIM_LEN,
               0 CHARGE_NUM,
               0 CHARGE_WGT,
               0 CHARGE_LEN
          FROM (SELECT T.ORD_PK,
                       T.ORD_LN_PK,
                       SUM(NVL(T.ACT_COUNT, 0)) INSTORAGE_NUM,
                       SUM(NVL(T.ACT_WEIGHT, 0)) INSTORAGE_WGT,
                       SUM(NVL(T.ACT_LEN, 0)) INSTORAGE_LEN
                  FROM MAT_ZC_M T, YDM_ZC_BUTTRESS K
                 WHERE T.MAT_NO = K.MAT_NO
                   AND T.MAT_STATUS = '80150301'
                   AND T.PRODUCT_FLAG = '801403'
                 GROUP BY T.ORD_PK, T.ORD_LN_PK) T1,
               SLM_ORDER_LINE A,
               SLM_ORDER_HEAD B
         WHERE A.ORD_PK = B.ORD_PK
           AND A.ORD_LN_PK = T1.ORD_LN_PK
           AND A.VALIDFLAG = '1'
           AND B.VALIDFLAG = '1'
           AND (A.ORDER_LN_STATUS >= '12020402' AND
               INSTR(A.ORDER_LN_STATUS, '12020901') = 0)
          #SALEORG#
           AND A.CREATE_TIME BETWEEN TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS') AND
               TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS')
           AND B.ORDER_NO LIKE '%' || ? || '%'
           AND A.ORDER_LN_STATUS LIKE '%' || ? || '%'
        UNION ALL
        SELECT B.ORDER_NO || '/' || A.ORDER_SEQ ORDER_NO,
               A.ORD_PK,
               A.ORD_LN_PK,
               A.PRODUCNAME,
               A.STD_NAME,
               A.STEELNAME,
               A.SPEC_NAME,
               A.MODEL_DESC,
               NVL(A.ORDER_QTY, 0) ORDER_QTY,
               A.ORDER_UNIT,
               A.ORD_ENSU_TOTL_LEN,
               ('(-' || A.DELVRY_RANGE_MIN || '%' || ',' ||
               A.DELVRY_RANGE_MAX || '%)') DELVRY_RANGE_TPE,
               NVL(A.ORDER_QTY, 0) -
               (NVL(A.DELVRY_RANGE_MIN, 0) / 100) * A.ORDER_QTY DELVRY_MIN,
               NVL(A.ORDER_QTY, 0) +
               (NVL(A.DELVRY_RANGE_MAX, 0) / 100) * A.ORDER_QTY DELVRY_MAX,
               A.ORDER_LN_STATUS,
               0 APP_NUM,
               0 PSS_NUM,
               0 PSS_WGT,
               0 PAY_NUM,
               0 PAY_WGT,
               0 PAY_LEN,
               0 INSTORAGE_NUM,
               0 INSTORAGE_WGT,
               0 INSTORAGE_LEN,
               SUM(FH.ACT_COUNT) OUT_NUM,
               SUM(CASE
                     WHEN FH.PONDER_NO IS NOT NULL THEN
                      NVL(FH.PONDER_GROSS_WT, 0)
                     ELSE
                      NVL(FH.ACT_WEIGHT, 0)
                   END) OUT_WGT,
               SUM(NVL(FH.SEND_NUM, 0)) OUT_LEN,
               0 SENDBILL_NUM,
               0 SENDBILL_WGT,
               0 SENDBILL_LEN,
               0 ACCOUNT_NUM,
               0 ACCOUNT_WGT,
               0 ACCOUNT_LEN,
               0 ELIM_NUM,
               0 ELIM_WGT,
               0 ELIM_LEN,
               0 CHARGE_NUM,
               0 CHARGE_WGT,
               0 CHARGE_LEN
          FROM SLM_ORDER_LINE A, SLM_ORDER_HEAD B, YDM_ZC_LOADVEHICLE_MAT FH
         WHERE A.ORD_PK = B.ORD_PK
           AND A.ORD_LN_PK = FH.ORD_LN_PK
           AND A.VALIDFLAG = '1'
           AND B.VALIDFLAG = '1'
           AND (A.ORDER_LN_STATUS >= '12020402' AND
               INSTR(A.ORDER_LN_STATUS, '12020901') = 0)
          #SALEORG#
           AND FH.RETURN_FLAG = '0'
           AND FH.VALIDFLAG > '1'
           AND A.CREATE_TIME BETWEEN TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS') AND
               TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS')
           AND B.ORDER_NO LIKE '%' || ? || '%'
           AND A.ORDER_LN_STATUS LIKE '%' || ? || '%'
         GROUP BY B.ORDER_NO,
                  A.ORDER_SEQ,
                  A.ORD_PK,
                  A.ORD_LN_PK,
                  A.PRODUCNAME,
                  A.STD_NAME,
                  A.STEELNAME,
                  A.SPEC_NAME,
                  A.MODEL_DESC,
                  A.ORDER_QTY,
                  A.ORDER_UNIT,
                  A.ORD_ENSU_TOTL_LEN,
                  A.DELVRY_RANGE_MIN,
                  A.DELVRY_RANGE_MAX,
                  A.ORDER_LN_STATUS
        UNION ALL
        SELECT B.ORDER_NO || '/' || A.ORDER_SEQ ORDER_NO,
               A.ORD_PK,
               A.ORD_LN_PK,
               A.PRODUCNAME,
               A.STD_NAME,
               A.STEELNAME,
               A.SPEC_NAME,
               A.MODEL_DESC,
               NVL(A.ORDER_QTY, 0) ORDER_QTY,
               A.ORDER_UNIT,
               A.ORD_ENSU_TOTL_LEN,
               ('(-' || A.DELVRY_RANGE_MIN || '%' || ',' ||
               A.DELVRY_RANGE_MAX || '%)') DELVRY_RANGE_TPE,
               NVL(A.ORDER_QTY, 0) -
               (NVL(A.DELVRY_RANGE_MIN, 0) / 100) * A.ORDER_QTY DELVRY_MIN,
               NVL(A.ORDER_QTY, 0) +
               (NVL(A.DELVRY_RANGE_MAX, 0) / 100) * A.ORDER_QTY DELVRY_MAX,
               A.ORDER_LN_STATUS,
               0 APP_NUM,
               0 PSS_NUM,
               0 PSS_WGT,
               0 PAY_NUM,
               0 PAY_WGT,
               0 PAY_LEN,
               0 INSTORAGE_NUM,
               0 INSTORAGE_WGT,
               0 INSTORAGE_LEN,
               0 OUT_NUM,
               0 OUT_WGT,
               0 OUT_LEN,
               SUM(TD.ACT_COUNT) SENDBILL_NUM,
               SUM(TD.ACT_WEIGHT) SENDBILL_WGT,
               SUM(TD.ACT_LEN) SENDBILL_LEN,
               0 ACCOUNT_NUM,
               0 ACCOUNT_WGT,
               0 ACCOUNT_LEN,
               0 ELIM_NUM,
               0 ELIM_WGT,
               0 ELIM_LEN,
               0 CHARGE_NUM,
               0 CHARGE_WGT,
               0 CHARGE_LEN
          FROM SLM_ORDER_LINE A, SLM_ORDER_HEAD B, YDM_ZC_BILL_C TD
         WHERE A.ORD_PK = B.ORD_PK
           AND A.ORD_LN_PK = TD.ORD_LN_PK
           AND A.VALIDFLAG = '1'
           AND B.VALIDFLAG = '1'
           AND (A.ORDER_LN_STATUS >= '12020402' AND
               INSTR(A.ORDER_LN_STATUS, '12020901') = 0)
          #SALEORG#
           AND TD.RETURN_FLAG = '0'
           AND A.CREATE_TIME BETWEEN TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS') AND
               TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS')
           AND B.ORDER_NO LIKE '%' || ? || '%'
           AND A.ORDER_LN_STATUS LIKE '%' || ? || '%'
         GROUP BY B.ORDER_NO,
                  A.ORDER_SEQ,
                  A.ORD_PK,
                  A.ORD_LN_PK,
                  A.PRODUCNAME,
                  A.STD_NAME,
                  A.STEELNAME,
                  A.SPEC_NAME,
                  A.MODEL_DESC,
                  A.ORDER_QTY,
                  A.ORDER_UNIT,
                  A.ORD_ENSU_TOTL_LEN,
                  A.DELVRY_RANGE_MIN,
                  A.DELVRY_RANGE_MAX,
                  A.ORDER_LN_STATUS
        UNION ALL
        SELECT B.ORDER_NO || '/' || A.ORDER_SEQ ORDER_NO,
               A.ORD_PK,
               A.ORD_LN_PK,
               A.PRODUCNAME,
               A.STD_NAME,
               A.STEELNAME,
               A.SPEC_NAME,
               A.MODEL_DESC,
               NVL(A.ORDER_QTY, 0) ORDER_QTY,
               A.ORDER_UNIT,
               A.ORD_ENSU_TOTL_LEN,
               ('(-' || A.DELVRY_RANGE_MIN || '%' || ',' ||
               A.DELVRY_RANGE_MAX || '%)') DELVRY_RANGE_TPE,
               NVL(A.ORDER_QTY, 0) -
               (NVL(A.DELVRY_RANGE_MIN, 0) / 100) * A.ORDER_QTY DELVRY_MIN,
               NVL(A.ORDER_QTY, 0) +
               (NVL(A.DELVRY_RANGE_MAX, 0) / 100) * A.ORDER_QTY DELVRY_MAX,
               A.ORDER_LN_STATUS,
               0 APP_NUM,
               0 PSS_NUM,
               0 PSS_WGT,
               0 PAY_NUM,
               0 PAY_WGT,
               0 PAY_LEN,
               0 INSTORAGE_NUM,
               0 INSTORAGE_WGT,
               0 INSTORAGE_LEN,
               0 OUT_NUM,
               0 OUT_WGT,
               0 OUT_LEN,
               0 SENDBILL_NUM,
               0 SENDBILL_WGT,
               0 SENDBILL_LEN,
               SUM(NVL(T.QUANTITY, 0)) ACCOUNT_NUM,
               SUM(DECODE(NVL(T.SEND_NUM, 0), 0, T.WEIGHT, T.SEND_NUM)) ACCOUNT_WGT,
               (CASE
                 WHEN (A.ORDER_UNIT = '英尺' OR A.ORDER_UNIT = '米') THEN
                  SUM(NVL(T.SEND_NUM, 0))
                 ELSE
                  0
               END) ACCOUNT_LEN,
               0 ELIM_NUM,
               0 ELIM_WGT,
               0 ELIM_LEN,
               0 CHARGE_NUM,
               0 CHARGE_WGT,
               0 CHARGE_LEN
          FROM SLM_ORDER_LINE A, SLM_ORDER_HEAD B, SLM_BALANCEINFO T
         WHERE A.ORD_PK = B.ORD_PK
           AND A.ORD_LN_PK = T.ORD_LN_PK
           AND A.VALIDFLAG = '1'
           AND B.VALIDFLAG = '1'
           AND (A.ORDER_LN_STATUS >= '12020402' AND
               INSTR(A.ORDER_LN_STATUS, '12020901') = 0)
          #SALEORG#
           AND T.BALANCESTATUS = '3'
           AND T.REALINVOICENO IS NOT NULL
           AND A.CREATE_TIME BETWEEN TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS') AND
               TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS')
           AND B.ORDER_NO LIKE '%' || ? || '%'
           AND A.ORDER_LN_STATUS LIKE '%' || ? || '%'
         GROUP BY B.ORDER_NO,
                  A.ORDER_SEQ,
                  A.ORD_PK,
                  A.ORD_LN_PK,
                  A.PRODUCNAME,
                  A.STD_NAME,
                  A.STEELNAME,
                  A.SPEC_NAME,
                  A.MODEL_DESC,
                  A.ORDER_QTY,
                  A.ORDER_UNIT,
                  A.ORD_ENSU_TOTL_LEN,
                  A.DELVRY_RANGE_MIN,
                  A.DELVRY_RANGE_MAX,
                  A.ORDER_LN_STATUS
        UNION ALL
        SELECT B.ORDER_NO || '/' || A.ORDER_SEQ ORDER_NO,
               A.ORD_PK,
               A.ORD_LN_PK,
               A.PRODUCNAME,
               A.STD_NAME,
               A.STEELNAME,
               A.SPEC_NAME,
               A.MODEL_DESC,
               NVL(A.ORDER_QTY, 0) ORDER_QTY,
               A.ORDER_UNIT,
               A.ORD_ENSU_TOTL_LEN,
               ('(-' || A.DELVRY_RANGE_MIN || '%' || ',' ||
               A.DELVRY_RANGE_MAX || '%)') DELVRY_RANGE_TPE,
               NVL(A.ORDER_QTY, 0) -
               (NVL(A.DELVRY_RANGE_MIN, 0) / 100) * A.ORDER_QTY DELVRY_MIN,
               NVL(A.ORDER_QTY, 0) +
               (NVL(A.DELVRY_RANGE_MAX, 0) / 100) * A.ORDER_QTY DELVRY_MAX,
               A.ORDER_LN_STATUS,
               0 APP_NUM,
               0 PSS_NUM,
               0 PSS_WGT,
               0 PAY_NUM,
               0 PAY_WGT,
               0 PAY_LEN,
               0 INSTORAGE_NUM,
               0 INSTORAGE_WGT,
               0 INSTORAGE_LEN,
               0 OUT_NUM,
               0 OUT_WGT,
               0 OUT_LEN,
               0 SENDBILL_NUM,
               0 SENDBILL_WGT,
               0 SENDBILL_LEN,
               0 ACCOUNT_NUM,
               0 ACCOUNT_WGT,
               0 ACCOUNT_LEN,
               SUM(NVL(T.ACT_COUNT, 0)) ELIM_NUM,
               SUM(NVL(T.ACT_WEIGHT, 0)) ELIM_WGT,
               SUM(NVL(T.ACT_LEN, 0)) ELIM_LEN,
               0 CHARGE_NUM,
               0 CHARGE_WGT,
               0 CHARGE_LEN
          FROM SLM_ORDER_LINE A, SLM_ORDER_HEAD B, MAT_ZC_TRACK T
         WHERE A.ORD_PK = B.ORD_PK
           AND A.ORD_LN_PK = T.ORD_LN_PK
           AND A.VALIDFLAG = '1'
           AND B.VALIDFLAG = '1'
           AND (A.ORDER_LN_STATUS >= '12020402' AND
               INSTR(A.ORDER_LN_STATUS, '12020901') = 0)
          #SALEORG#
           AND T.EVENT_ID = '900101'
           AND A.CREATE_TIME BETWEEN TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS') AND
               TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS')
           AND B.ORDER_NO LIKE '%' || ? || '%'
           AND A.ORDER_LN_STATUS LIKE '%' || ? || '%'
         GROUP BY B.ORDER_NO,
                  A.ORDER_SEQ,
                  A.ORD_PK,
                  A.ORD_LN_PK,
                  A.PRODUCNAME,
                  A.STD_NAME,
                  A.STEELNAME,
                  A.SPEC_NAME,
                  A.MODEL_DESC,
                  A.ORDER_QTY,
                  A.ORDER_UNIT,
                  A.ORD_ENSU_TOTL_LEN,
                  A.DELVRY_RANGE_MIN,
                  A.DELVRY_RANGE_MAX,
                  A.ORDER_LN_STATUS
        UNION ALL
        SELECT B.ORDER_NO || '/' || A.ORDER_SEQ ORDER_NO,
               A.ORD_PK,
               A.ORD_LN_PK,
               A.PRODUCNAME,
               A.STD_NAME,
               A.STEELNAME,
               A.SPEC_NAME,
               A.MODEL_DESC,
               NVL(A.ORDER_QTY, 0) ORDER_QTY,
               A.ORDER_UNIT,
               A.ORD_ENSU_TOTL_LEN,
               ('(-' || A.DELVRY_RANGE_MIN || '%' || ',' ||
               A.DELVRY_RANGE_MAX || '%)') DELVRY_RANGE_TPE,
               NVL(A.ORDER_QTY, 0) -
               (NVL(A.DELVRY_RANGE_MIN, 0) / 100) * A.ORDER_QTY DELVRY_MIN,
               NVL(A.ORDER_QTY, 0) +
               (NVL(A.DELVRY_RANGE_MAX, 0) / 100) * A.ORDER_QTY DELVRY_MAX,
               A.ORDER_LN_STATUS,
               0 APP_NUM,
               0 PSS_NUM,
               0 PSS_WGT,
               0 PAY_NUM,
               0 PAY_WGT,
               0 PAY_LEN,
               0 INSTORAGE_NUM,
               0 INSTORAGE_WGT,
               0 INSTORAGE_LEN,
               0 OUT_NUM,
               0 OUT_WGT,
               0 OUT_LEN,
               0 SENDBILL_NUM,
               0 SENDBILL_WGT,
               0 SENDBILL_LEN,
               0 ACCOUNT_NUM,
               0 ACCOUNT_WGT,
               0 ACCOUNT_LEN,
               0 ELIM_NUM,
               0 ELIM_WGT,
               0 ELIM_LEN,
               SUM(NVL(T.ACT_COUNT, 0)) CHARGE_NUM,
               SUM(NVL(T.ACT_WEIGHT, 0)) CHARGE_WGT,
               SUM(NVL(T.ACT_LEN, 0)) CHARGE_LEN
          FROM SLM_ORDER_LINE A, SLM_ORDER_HEAD B, MAT_ZC_TRACK T
         WHERE A.ORD_PK = B.ORD_PK
           AND A.ORD_LN_PK = T.ORD_LN_PK
           AND A.VALIDFLAG = '1'
           AND B.VALIDFLAG = '1'
           AND (A.ORDER_LN_STATUS >= '12020402' AND
               INSTR(A.ORDER_LN_STATUS, '12020901') = 0)
          #SALEORG#
           AND T.EVENT_ID = '900102'
           AND A.CREATE_TIME BETWEEN TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS') AND
               TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS')
           AND B.ORDER_NO LIKE '%' || ? || '%'
           AND A.ORDER_LN_STATUS LIKE '%' || ? || '%'
         GROUP BY B.ORDER_NO,
                  A.ORDER_SEQ,
                  A.ORD_PK,
                  A.ORD_LN_PK,
                  A.PRODUCNAME,
                  A.STD_NAME,
                  A.STEELNAME,
                  A.SPEC_NAME,
                  A.MODEL_DESC,
                  A.ORDER_QTY,
                  A.ORDER_UNIT,
                  A.ORD_ENSU_TOTL_LEN,
                  A.DELVRY_RANGE_MIN,
                  A.DELVRY_RANGE_MAX,
                  A.ORDER_LN_STATUS) T

 GROUP BY T.ORDER_NO,
          T.ORD_PK,
          T.ORD_LN_PK,
          T.PRODUCNAME,
          T.STD_NAME,
          T.STEELNAME,
          T.SPEC_NAME,
          T.MODEL_DESC,
          T.ORDER_QTY,
          T.ORDER_UNIT,
          T.ORD_ENSU_TOTL_LEN,
          T.DELVRY_MIN,
          T.DELVRY_MAX,
          T.ORDER_LN_STATUS
          ORDER BY T.ORDER_NO ASC

]]>
	</query>
	<query id="FrmOrderNoReport.GetQueryOrderStrats" desc="查询合同行状态">
<![CDATA[
SELECT T.BASECODE, T.BASENAME, t.sortcode
  FROM COM_BASE_INFO T
 WHERE SUBSTR(T.BASECODE, 0, 5) = ?
   AND T.SORTCODE != '1202'
   AND (T.BASECODE >= ? AND INSTR(T.BASECODE, '12021001') = 0)

]]>
	</query>
	<query id="FrmOrderNoReport.GetQueryBillJs" desc="提单是否结算">
<![CDATA[
SELECT DISTINCT T.ORD_LN_PK,
       T.BILL_TICKET_STATUS || T.OUTSTOCK_TICKET_STATUS ||
       T.TRANSMNY_TICKET_STATUS BILL_TICKET_STATUS
  FROM YDM_ZC_BILL_M T
 WHERE T.ORD_LN_PK = ?
   AND T.VALIDFLAG = '1'
]]>
	</query>
	<query id="FrmOrderNoReport.UpdateOrdLnPk" desc="修改合同行状态">
<![CDATA[
UPDATE SLM_ORDER_LINE T
   SET T.ORDER_LN_STATUS = ?,
       UPDATE_NAME       = ?,
       UPDATE_TIME       = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS')
 WHERE T.ORD_LN_PK = ?
 AND T.ORDER_LN_STATUS=?
   AND T.VALIDFLAG = '1'
]]>
	</query>
	<query id="FrmOrderNoReport.QueryOrdPk" desc="查询合同行是否全部发齐或结齐">
<![CDATA[
SELECT COUNT(*) COUNT, T.ORD_PK, T.ORDER_LN_STATUS
  FROM SLM_ORDER_LINE T
 WHERE T.ORD_PK =?
   AND T.VALIDFLAG = '1'
 GROUP BY T.ORD_PK, T.ORDER_LN_STATUS
]]>
	</query>
	<query id="FrmOrderNoReport.QueryOrdLnPk" desc="查询合同行状态">
<![CDATA[
SELECT T.ORD_PK, T.ORDER_LN_STATUS,T.LOGOUT_REVIEW_NO
  FROM SLM_ORDER_LINE T
 WHERE T.ORD_LN_PK =?
   AND T.VALIDFLAG = '1'
]]>
	</query>
	<query id="FrmOrderNoReport.QueryOrdNo" desc="查询合同状态">
<![CDATA[
SELECT COUNT (*)  COUNT FROM(
SELECT  T.ORD_PK, T.ORDER_LN_STATUS
  FROM SLM_ORDER_LINE T
 WHERE T.ORD_PK =?
   AND T.VALIDFLAG = '1'
GROUP BY T.ORD_PK,T.ORDER_LN_STATUS)
]]>
	</query>
	<query id="FrmOrderNoReport.UpdateOrdPk" desc="修改合同头信息">
<![CDATA[
UPDATE SLM_ORDER_HEAD T
   SET T.ORDER_STS      = ?,
       T.ORDER_STS_DESC = ?,
       T.UPDATE_NAME    = ?,
       T.UPDATE_TIME    = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS')
 WHERE T.ORD_PK = ?
   AND T.VALIDFLAG = '1'

]]>
	</query>
	<query id="FrmOrderNoReport.AddOrderLogout" desc="新增合同余量">
<![CDATA[
  INSERT INTO SLM_LOGOUT_ORDER_NUM
  (LOGOUT_NO,
   ORD_PK,
   ORD_LN_PK,
   LOGOUT_NUM,
   LOGOUT_UNIT,
   MEMO,
   CREATE_NAME,
   CREATE_TIME,
   ORDER_NO,
   ORDER_SEQ)
VALUES
  ((SELECT 'ZX-' || ? || '/' || ? ||
       LPAD(SUBSTR(NVL(MAX(T.LOGOUT_NO), '00'), -2, 2) + 1, 3, '0') AS LOGOUT_NO
  FROM SLM_LOGOUT_ORDER_NUM T
 WHERE T.ORDER_NO = ? and T.ORDER_SEQ = ?), ?, ?, ?, ?, ?, ?, TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), ?, ?)
]]>
	</query>
	<query id="FrmOrderNoReport.DeleteOrderLogout" desc="删除余量注销">
<![CDATA[
 DELETE SLM_LOGOUT_ORDER_NUM WHERE LOGOUT_NO = ?
]]>
	</query>
	<query id="FrmOrderNoReport.GetQueryLogoutNo" desc="查询余量">
<![CDATA[
SELECT LOGOUT_NO,
       ORD_PK,
       ORD_LN_PK,
       LOGOUT_NUM,
       LOGOUT_UNIT,
       TO_CHAR(PRINT_DATE, 'YYYY-MM-DD HH24:MI:SS') PRINT_DATE,
       MEMO,
       CREATE_NAME,
       TO_CHAR(CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       UPDATE_NAME,
       TO_CHAR(UPDATE_TIME, 'YYYY-MM-DD HH24:MI:SS') UPDATE_TIME,
       ORDER_NO || '/' || ORDER_SEQ ORDER_NO,
       ORDER_SEQ
  FROM SLM_LOGOUT_ORDER_NUM
WHERE ORD_LN_PK=?
]]>
	</query>
	<query id="FrmOrderNoReport.GetQueryOrderNo" desc="查询合同信息">
<![CDATA[
 SELECT T.ORD_PK,
        T.MANAG_NO,
        T.ORDER_NO,
        T.CUSTM_ORDER_NO,
        T.REVW_RPT_NO,
        T.ORDER_TYP,
        T.ORDER_TYP_DESC,
        T.PROTCL_NO,
        T.CUSTOMER_NO,
        T.CUSTOMER_NM,
        T.MARKET_SYS,
        T.MARKET_SYS_DESC,
        T.ABRVITION,
        T.SUPPLY_UNIT,
        T.PRICE_FL,
        T.CURRENCY,
        T.MNY_ASK_TYP,
        T.STLMT_UNIT_NO,
        T.STLMT_UNIT_NM,
        T.FST_DRAWEE_UNIT,
        T.LEGAL_PSN,
        T.AGENT,
        T.ADDRESS,
        T.ZIP_CODE,
        T.BANK,
        T.ACCOUNT,
        T.TAX_ID,
        T.PHONE,
        T.FAX,
        T.ORDER_WGT,
        T.ORDER_MNY_TAX,
        T.ORDER_MNY_NTAX,
        T.MNY_ASK_DESC,
        T.SIGN_PERSON,
        TO_CHAR(T.SIGN_DATE, 'YYYY-MM-DD HH24:MI:SS') SIGN_DATE,
        T.SIGN_ADDRESS,
        T.ORDER_YEAR,
        TO_CHAR(T.ORDER_BDATE, 'YYYY-MM-DD HH24:MI:SS') ORDER_BDATE,
        TO_CHAR(T.ORDER_EDATE, 'YYYY-MM-DD HH24:MI:SS') ORDER_EDATE,
        T.ORDER_SCAN_NO,
        DECODE(T.CUSTOMER_MODEL_FL, '0', '否', '1', '是') CUSTOMER_MODEL_FL,
        T.ORDER_MODEL_NO,
        T.ORDER_MODEL_DESC,
        T.SALE_ORG,
        T.SALE_ORG_DESC,
        T.SALE_AREA_NO,
        T.SALE_AREA_DESC,
        T.MEMO,
        T.BE_ORDER_STS,
        T.BE_OBJ_STS_OP,
        T.ORDER_STS,
        T.ORDER_STS_DESC,
        T.OBJ_STS_OP,
        T.APPROVAL_MAN,
        TO_CHAR(T.APPROVAL_TIME, 'YYYY-MM-DD HH24:MI:SS') APPROVAL_TIME,
        T.EFFECT_MAN,
        TO_CHAR(T.EFFECT_TIME, 'YYYY-MM-DD HH24:MI:SS') EFFECT_TIME,
        T.CLOSE_MAN,
        TO_CHAR(T.CLOSE_TIME, 'YYYY-MM-DD HH24:MI:SS') CLOSE_TIME,
        T.VALIDFLAG,
        T.CREATE_NAME,
        T.CREATE_DEPT,
        TO_CHAR(T.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
        T.UPDATE_NAME,
        TO_CHAR(T.UPDATE_TIME, 'YYYY-MM-DD HH24:MI:SS') UPDATE_TIME,
        T.DELETE_NAME,
        TO_CHAR(T.DELETE_TIME, 'YYYY-MM-DD HH24:MI:SS') DELETE_TIME,
        T.ORD_PK_OLD,
        T.BE_ORDER_STS_DESC,
        T.PRICE_NO,
        T.ORDER_CHGE_NO,
        DECODE(T.ISLOCK, '0', '未锁定', '锁定') ISLOCK,
        T.PRINT_PRICE,
        T.PRICE_PLAN,
        DECODE(T.CONTAIN_TAX, '0', '否', '1', '是') CONTAIN_TAX,
        DECODE(T.ORDER_ARCHIVE, '0', '否', '1', '是') ORDER_ARCHIVE,
        TO_CHAR(T.PASS_TIME, 'YYYY-MM-DD HH24:MI:SS') PASS_TIME,
        TO_CHAR(T.CONFIRM_TIME, 'YYYY-MM-DD HH24:MI:SS') CONFIRM_TIME,
        T.TRADE_TYPE,
        T.ORDER_CLASSIFY,
        T.BUSINESS_TYPE,
        TO_CHAR(T.PRINT_TIME, 'YYYY-MM-DD HH24:MI:SS') PRINT_TIME,
        T.PRINT_COUNT,
        T.LOCAL_LAW,
        T.ORDER_FILE
   FROM SLM_ORDER_HEAD T
   WHERE 1=1
]]>
	</query>
	<query id="FrmOrderNoReport.GetQueryOrderSeqNo" desc="查询合同行信息">
<![CDATA[SELECT T.ORD_PK,
       T.ORD_LN_PK,
       T1.ORDER_NO ||'/'|| T.ORDER_SEQ ORDER_SEQ,
       T.CUST_ALPHA_NO,
       T.PSC,
       T.PSC_DESC,
       T.MSC,
       T.MSC_DESC,
       T.MSC_STYLE,
       T.USE_CODE,
       T.USE_DESC,
       T.PRD_CLS,
       T.PRODUCCODE,
       T.PRODUCNAME,
       T.STD_CODE,
       T.STD_NAME,
       T.STEELCODE,
       T.STEELNAME,
       T.STD_STYLE,
       T.STD_STYLE_DESC,
       T.ORDER_SPEC_CODE,
       T.ORDER_SPEC_DESC,
       T.SPEC_CODE,
       T.SPEC_NAME,
       T.DIMATER,
       T.HEIGHT,
       T.MODEL_CODE,
       T.MODEL_DESC,
       T.LEN_NO,
       T.LEN_DESC,
       T.LEN_UNIT,
       T.LEN_MIN,
       T.LEN_MAX,
       T.SHRT_LEN_RATO,
       T.SHORTEST,
       T.LONG_LEN_RATO,
       T.LONGEST,
       T.SHRT_STOVE,
       T.AVG_LEN_MIN,
       T.DIFRNC_LEN_MAX,
       T.ENDLEN_SPECSTD,
       T.SIGL_LEN,
       T.ORDER_UNIT,
       T.ORDER_QTY,
       T.ORD_ENSU_TOTL_LEN,
       T.PRDCT_WGT,
       ('(-' || T.DELVRY_RANGE_MIN || '%' || ',' || T.DELVRY_RANGE_MAX || '%)') DELVRY_RANGE_TPE,
       NVL(T.ORDER_QTY, 0) -
       (NVL(T.DELVRY_RANGE_MIN, 0) / 100) * T.ORDER_QTY DELVRY_RANGE_MIN,
       NVL(T.ORDER_QTY, 0) +
       (NVL(T.DELVRY_RANGE_MAX, 0) / 100) * T.ORDER_QTY DELVRY_RANGE_MAX,
       T.FINAL_USER,
       T.FINAL_USER_DESC,
       T.OUTS_BILLET_FL,
       T.OUTS_STL_PIPE_FL,
       T.ASSEL_FL,
       T.PRODUCER_FL,
       T.PRDCR_NO,
       T.PRDCR_DESC,
       T.MPS_FL,
       T.MPS_NO,
       T.MPS_DESC,
       TO_CHAR(T.DELVRY_BDATE, 'YYYY-MM-DD HH24:MI:SS') DELVRY_BDATE,
       TO_CHAR(T.DELVRY_EDATE, 'YYYY-MM-DD HH24:MI:SS') DELVRY_EDATE,
       T.DELVRY_DESC,
       T.TRANS_DESC,
       T.ADD_ASK_NO,
       T.ORDER_ADD_DESC,
       T.ORDER_SPECIAL_FL,
       T.ORDER_SPECIAL_HEAD,
       T.ORDER_SPECIAL_PATH,
       T.ORDER_SPECIAL_DESC,
       T.ZBS,
       T.ORDER_PRICE,
       T.TRANS_PRICE,
       T.TEST_ID,
       T.TEST_PRICE,
       T.OUT_PRICE,
       T.BALNCE_PRICE,
       T.BE_ORDER_LN_STATUS,
       T.BE_OBJ_STS_OP,
       (SELECT T2.BASENAME FROM COM_BASE_INFO T2 WHERE T2.BASECODE=T.ORDER_LN_STATUS AND T2.VALIDFLAG='1') ORDER_LN_STATUS,
       T.OBJ_STS_OP,
       T.MEMO,
       T.VALIDFLAG,
       T.CREATE_NAME,
       TO_CHAR(T.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       T.UPDATE_NAME,
       TO_CHAR(T.UPDATE_TIME, 'YYYY-MM-DD HH24:MI:SS') UPDATE_TIME,
       T.DELETE_NAME,
       TO_CHAR(T.DELETE_TIME, 'YYYY-MM-DD HH24:MI:SS') DELETE_TIME,
       T.ORD_LN_PK_OLD,
       T.ISLOCK,
       T.CUST_ALPHA_NO2,
       T.ORDER_CHGE_NO,
       T.CHGE_ORD_LN_PK,
       T.BALNCE_PRICE_STS,
       T.BALNCE_PRICE_ORG,
       T.BALNCE_PRICE_ORG_STS,
       T.PAK_PRICE,
       T.AW,
       T.MPS_NO_INPUT,
       T.MAN_INSPECTION,
       T.INSPECTION_VALUE,
       T.MPS_NO_FILE,
       T.QUALITY_USER,
       T.QUALITY_USER_DESC,
       T.OUTPUT_STD_NO,
       T.PROJECT_NO,
       T.CRAFT_NO,
       T.CRAFT_NO_V,
       T.ORDER_COUNT,
       T.MPS_ID,
       T.LOGOUT_REVIEW_NO
  FROM SLM_ORDER_LINE T,SLM_ORDER_HEAD T1
 WHERE T.ORD_PK=T1.ORD_PK


]]>
	</query>
	<query id="FrmOrderNoReport.UpdateOrdPkNo" desc="合同关闭时修改合同状态">
<![CDATA[
UPDATE SLM_ORDER_HEAD T
   SET T.ORDER_STS      = ?,
       T.ORDER_STS_DESC = ?,
       T.CLOSE_MAN    = ?,
       T.CLOSE_TIME    = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS')
 WHERE T.ORD_PK = ?
   AND T.VALIDFLAG = '1'
]]></query>
	<query id="FrmOrderNoReport.UpdateOrdLnPkNo" desc="合同关闭时修改合同行状态">
<![CDATA[
DECLARE
BEGIN
  UPDATE SLM_ORDER_LINE T
     SET T.ORDER_LN_STATUS = ?,
         T.UPDATE_NAME     = ?,
         T.UPDATE_TIME     = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS')
   WHERE T.ORD_LN_PK = ?
     AND T.VALIDFLAG = '1';
  UPDATE SLM_ORDER_LINE_DELIVERY T
     SET T.DELIVERY_STATUS = ?,
         T.UPDATE_NAME     = ?,
         T.UPDATE_TIME     = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS')
   WHERE T.ORD_LN_PK = ?;
END;


]]></query>
	<query id="FrmOrderNoReport.QueryLogOutNo" desc="修改注销单打印时间">
<![CDATA[
UPDATE SLM_LOGOUT_ORDER_NUM SET  PRINT_DATE =TO_DATE(?,'YYYY-MM-DD HH24:MI:SS') WHERE LOGOUT_NO=?
]]>
	</query>

	<query id="FrmOrderNoReport.updateLogoutState" desc="修改注销单打印时间">
	<![CDATA[
	UPDATE SLM_LOGOUT_ORDER_NUM SET  PRINT_DATE =TO_DATE(?,'YYYY-MM-DD HH24:MI:SS') WHERE ORDER_NO=?
	]]>
	</query>

	<query id="FrmOrderNoReport.QueryOrderMatNo" desc="是否存在库存">
<![CDATA[
SELECT COUNT(*) COUNT
  FROM MAT_ZC_M T
 WHERE T.ORD_LN_PK = ?
   AND T.PRODUCT_FLAG = '801403'
]]></query>
<query id="FrmOrderNoReport.UpdateOrderZx" desc="修改合同頭有效标志">
<![CDATA[
DECLARE
BEGIN
  UPDATE SLM_ORDER_HEAD T
     SET T.VALIDFLAG   = ?,
         T.DELETE_NAME = ?,
         T.DELETE_TIME = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS')
   WHERE T.ORD_PK = ?;
END;
]]></query>
<query id="FrmOrderNoReport.getDoQueryRev" desc="查询注销单">
<![CDATA[
SELECT T.REVIEW_NO,
       DECODE(T.REVIEW_SRC, 'X', '合同注销') REVIEW_SRC,
       DECODE(T.REVIEW_STATUS,
              'L',
              '封锁',
              'W',
              '待审',
              'S',
              '评审通过',
              'F',
              '评审不通过') REVIEW_STATUS,
       TO_CHAR(T.REVEIW_BDATE, 'YYYY-MM-DD HH24:MI:SS') REVEIW_BDATE,
       TO_CHAR(T.REVEIW_EDATE, 'YYYY-MM-DD HH24:MI:SS') REVEIW_EDATE,
       T.REVEIW_MAN,
       T.REVEIW_CONTENT,
       T.REVEIW_ASKER,
       TO_CHAR(T.REVEIW_ASK_TIME, 'YYYY-MM-DD HH24:MI:SS') REVEIW_ASK_TIME,
       T.MEMO,
       T.CREATE_NAME,
       TO_CHAR(T.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       T.UPDATE_NAME,
       TO_CHAR(T.UPDATE_TIME, 'YYYY-MM-DD HH24:MI:SS') UPDATE_TIME
  FROM SLM_ORDER_LOGOUT_REVIEW T
 WHERE 1 = 1
]]></query>
<query id="FrmOrderNoReport.queryLoagoutRev" desc="生成注销单号">
<![CDATA[
 SELECT ?|| LPAD(SUBSTR(NVL(MAX(T.REVIEW_NO), '000000'), -6, 6) + 1, 6, '0') AS REVIEW_NO
   FROM SLM_ORDER_LOGOUT_REVIEW T
  WHERE TO_CHAR(T.CREATE_TIME, 'YYYY-MM-DD') = ?
    AND T.REVIEW_SRC = ?
]]></query>
<query id="FrmOrderNoReport.queryLoagoutRevStart" desc="注销单状态">
<![CDATA[
SELECT T.REVIEW_NO,
       T.REVIEW_SRC,
       T.ORD_LN_PK,
       T.REVIEW_STATUS,
       TO_CHAR(T.REVEIW_BDATE, 'YYYY-MM-DD HH24:MI:SS') REVEIW_BDATE,
       TO_CHAR(T.REVEIW_EDATE, 'YYYY-MM-DD HH24:MI:SS') REVEIW_EDATE,
       T.REVEIW_MAN,
       T.REVEIW_CONTENT,
       T.REVEIW_ASKER,
       TO_CHAR(T.REVEIW_ASK_TIME, 'YYYY-MM-DD HH24:MI:SS') REVEIW_ASK_TIME,
       T.MEMO,
       T.CREATE_NAME,
       TO_CHAR(T.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       T.UPDATE_NAME,
       TO_CHAR(T.UPDATE_TIME, 'YYYY-MM-DD HH24:MI:SS') UPDATE_TIME
  FROM SLM_ORDER_LOGOUT_REVIEW T
 WHERE T.REVIEW_NO = ?
   AND T.REVIEW_SRC = ?
]]></query>
<query id="FrmOrderNoReport.AddOrderLogoutRev" desc="新增注销单">
<![CDATA[
DECLARE
BEGIN
  INSERT INTO SLM_ORDER_LOGOUT_REVIEW
    (REVIEW_NO,
     REVIEW_SRC,
     ORD_LN_PK,
     REVIEW_STATUS,
     REVEIW_BDATE,
     REVEIW_MAN,
     REVEIW_CONTENT,
     MEMO,
     CREATE_NAME,
     CREATE_TIME)
  VALUES
    (?,
     ?,
     ?,
     ?,
     TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'),
     ?,
     ?,
     ?,
     ?,
     TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'));
  UPDATE SLM_ORDER_LINE T
     SET T.LOGOUT_REVIEW_NO = ?
   WHERE T.ORD_LN_PK = ?
     AND T.ORD_PK = ?
     AND T.VALIDFLAG='1';
END;
]]></query>
<query id="FrmOrderNoReport.deleteRevNo" desc="删除注销单">
<![CDATA[
DELETE SLM_ORDER_LOGOUT_REVIEW
 WHERE REVIEW_NO = ?
]]></query>
<query id="FrmOrderNoReport.UpdateRevNo" desc="修改注销单">
<![CDATA[
UPDATE SLM_ORDER_LOGOUT_REVIEW
   SET REVIEW_STATUS   = ?,
       REVEIW_ASKER    = ?,
       REVEIW_ASK_TIME = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'),
       UPDATE_NAME     = ?,
       UPDATE_TIME     = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS')
 WHERE REVIEW_NO = ?

]]></query>
<query id="FrmOrderNoReport.updateOrdLnPkRevNo" desc="修改合同行注销单">
<![CDATA[
  UPDATE SLM_ORDER_LINE T
     SET T.LOGOUT_REVIEW_NO = ?
   WHERE T.ORD_LN_PK = ?
   AND T.VALIDFLAG='1'
]]></query>
<query id="FrmOrderNoReport.UpdateOrderSeqZx" desc="修改合同行有效标志">
<![CDATA[
DECLARE
BEGIN
  UPDATE SLM_ORDER_LINE T
     SET T.VALIDFLAG   = ?,
         T.DELETE_NAME = ?,
         T.DELETE_TIME = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS')
   WHERE T.ORD_LN_PK = ?;
  UPDATE SLM_ORDER_LINE_DELIVERY T
     SET T.VALIDFLAG   = ?,
         T.DELETE_NAME = ?,
         T.DELETE_TIME = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS')
   WHERE T.ORD_LN_PK = ?;
END;
]]></query>
<query id="FrmOrderNoReport.GetQueryOrderNoReport" desc="查询合同">
<![CDATA[
SELECT B.ORDER_NO || '/' || A.ORDER_SEQ ORDER_NO,
			   B.ORDER_TYP,
			   B.ORDER_TYP_DESC,
               A.ORD_PK,
               A.ORD_LN_PK,
               A.PRODUCNAME,
               A.STD_NAME,
               A.STEELNAME,
               A.SPEC_NAME,
               A.MODEL_DESC,
               NVL(A.ORDER_QTY, 0) ORDER_QTY,
               A.ORDER_UNIT,
               A.ORD_ENSU_TOTL_LEN,
               ('(-' || A.DELVRY_RANGE_MIN || '%' || ',' ||
               A.DELVRY_RANGE_MAX || '%)') DELVRY_RANGE_TPE,
               NVL(A.ORDER_QTY, 0) -
               (NVL(A.DELVRY_RANGE_MIN, 0) / 100) * A.ORDER_QTY DELVRY_MIN,
               NVL(A.ORDER_QTY, 0) +
               (NVL(A.DELVRY_RANGE_MAX, 0) / 100) * A.ORDER_QTY DELVRY_MAX,
               A.ORDER_LN_STATUS,
               (select BASENAME from COM_BASE_INFO where BASECODE = a.ORDER_LN_STATUS) ORDER_LN_STATUS_NAME,
               (SELECT NVL(SUM(T.ORDER_QTY), 0)
                  FROM PLN_SALEORD T
                 WHERE T.ORD_LN_PK = A.ORD_LN_PK
                   AND T.PORDERSTATUS > '0') APP_NUM,
               (SELECT NVL(SUM(T.PLAN_NUM_D), 0)
                  FROM PLN_SALEORD_PROC T
                 WHERE SUBSTR(T.ORD_LN_DLY_PK, 1, 35) = A.ORD_LN_PK
                   AND (T.PLANSTATUS > '1' AND T.PLANSTATUS <> '9')) PSS_NUM,
               (SELECT NVL(SUM(T.PLAN_WT_D), 0)
                  FROM PLN_SALEORD_PROC T
                 WHERE SUBSTR(T.ORD_LN_DLY_PK, 1, 35) = A.ORD_LN_PK
                   AND (T.PLANSTATUS > '1' AND T.PLANSTATUS <> '9')) PSS_WGT,
               (SELECT NVL(SUM(JK.ACT_COUNT),0)             
               FROM YDM_ZC_INLIST JK  WHERE  JK.INSTOCK_TYPE_CODE IN ('800701', '800706')
                   AND JK.PRODUCT_FLAG = '801403' AND JK.ORD_LN_PK = A.ORD_LN_PK ) PAY_NUM,
                (SELECT NVL(SUM(JK.ACT_WEIGHT),0)             
              FROM YDM_ZC_INLIST JK WHERE  JK.INSTOCK_TYPE_CODE IN ('800701', '800706')
                   AND JK.PRODUCT_FLAG = '801403' AND JK.ORD_LN_PK = A.ORD_LN_PK ) PAY_WGT,
                (SELECT NVL(SUM(JK.ACT_LEN),0)            
              FROM YDM_ZC_INLIST JK WHERE  JK.INSTOCK_TYPE_CODE IN ('800701', '800706')
                   AND JK.PRODUCT_FLAG = '801403' AND JK.ORD_LN_PK = A.ORD_LN_PK ) PAY_LEN,
               (SELECT  NVL(SUM(T.ACT_COUNT), 0)
                  FROM MAT_ZC_M T, YDM_ZC_BUTTRESS K
                 WHERE T.MAT_NO = K.MAT_NO
                   AND T.MAT_STATUS = '80150301'
                   AND T.PRODUCT_FLAG = '801403'
                   AND T.ORD_LN_PK = A.ORD_LN_PK ) INSTORAGE_NUM,
               (SELECT  NVL(SUM(T.ACT_WEIGHT), 0)
                  FROM MAT_ZC_M T, YDM_ZC_BUTTRESS K
                 WHERE T.MAT_NO = K.MAT_NO
                   AND T.MAT_STATUS = '80150301'
                   AND T.PRODUCT_FLAG = '801403'
                   AND T.ORD_LN_PK = A.ORD_LN_PK ) INSTORAGE_WGT,
               (SELECT  NVL(SUM(T.ACT_LEN) , 0)
                  FROM MAT_ZC_M T, YDM_ZC_BUTTRESS K
                 WHERE T.MAT_NO = K.MAT_NO
                   AND T.MAT_STATUS = '80150301'
                   AND T.PRODUCT_FLAG = '801403'
                   AND T.ORD_LN_PK = A.ORD_LN_PK ) INSTORAGE_LEN,               
                (SELECT NVL(SUM(FH.ACT_COUNT),0)            
              FROM YDM_ZC_LOADVEHICLE_MAT FH WHERE  FH.RETURN_FLAG = '0'
               AND FH.VALIDFLAG > '1' AND FH.ORD_LN_PK = A.ORD_LN_PK ) OUT_NUM,              
                (SELECT 
                  NVL(SUM(CASE
                       WHEN FH.PONDER_NO IS NOT NULL THEN
                        NVL(FH.PONDER_GROSS_WT, 0)
                       ELSE
                        NVL(FH.ACT_WEIGHT, 0)
                     END),0)               
              FROM YDM_ZC_LOADVEHICLE_MAT FH WHERE  FH.RETURN_FLAG = '0'
               AND FH.VALIDFLAG > '1' AND FH.ORD_LN_PK = A.ORD_LN_PK ) OUT_WGT, 
                (SELECT NVL(SUM(FH.SEND_NUM) ,0)            
              FROM YDM_ZC_LOADVEHICLE_MAT FH WHERE  FH.RETURN_FLAG = '0'
               AND FH.VALIDFLAG > '1' AND FH.ORD_LN_PK = A.ORD_LN_PK ) OUT_LEN,
               (SELECT NVL(SUM(TD.ACT_COUNT),0) FROM YDM_ZC_BILL_C TD WHERE  TD.RETURN_FLAG = '0' AND TD.ORD_LN_PK = A.ORD_LN_PK) SENDBILL_NUM,
               (SELECT NVL(SUM(TD.ACT_WEIGHT),0) FROM YDM_ZC_BILL_C TD WHERE  TD.RETURN_FLAG = '0' AND TD.ORD_LN_PK = A.ORD_LN_PK) SENDBILL_WGT,
               (SELECT NVL(SUM(TD.ACT_LEN),0) FROM YDM_ZC_BILL_C TD WHERE  TD.RETURN_FLAG = '0' AND TD.ORD_LN_PK = A.ORD_LN_PK) SENDBILL_LEN,                              
             --结算量
               (SELECT NVL(SUM(T.QUANTITY),0) FROM SLM_BALANCEINFO T WHERE  T.BALANCESTATUS = '3' AND T.REALINVOICENO IS NOT NULL AND T.ORD_LN_PK = A.ORD_LN_PK) ACCOUNT_NUM,
               (SELECT NVL(SUM(DECODE(NVL(T.SEND_NUM, 0), 0, T.WEIGHT, T.SEND_NUM)),0) FROM SLM_BALANCEINFO T WHERE  T.BALANCESTATUS = '3' AND T.REALINVOICENO IS NOT NULL AND T.ORD_LN_PK = A.ORD_LN_PK) ACCOUNT_WGT,
               (SELECT NVL(SUM(CASE  WHEN (A.ORDER_UNIT = '英尺' OR A.ORDER_UNIT = '米') THEN NVL(T.SEND_NUM, 0)
                                 ELSE  0
                           END),0) FROM SLM_BALANCEINFO T WHERE  T.BALANCESTATUS = '3' AND T.REALINVOICENO IS NOT NULL AND T.ORD_LN_PK = A.ORD_LN_PK) ACCOUNT_LEN,               
              --脱单量
              (SELECT NVL(SUM(T.ACT_COUNT), 0)FROM MAT_ZC_TRACK T WHERE T.EVENT_ID = '900101' AND T.ORD_LN_PK = A.ORD_LN_PK) ELIM_NUM,
              (SELECT NVL(SUM(T.ACT_WEIGHT), 0)FROM MAT_ZC_TRACK T WHERE T.EVENT_ID = '900101' AND T.ORD_LN_PK = A.ORD_LN_PK) ELIM_WGT,
              (SELECT NVL(SUM(T.ACT_LEN), 0)FROM MAT_ZC_TRACK T WHERE T.EVENT_ID = '900101' AND T.ORD_LN_PK = A.ORD_LN_PK) ELIM_LEN,              
              --利库量
              (SELECT NVL(SUM(T.ACT_COUNT), 0)FROM MAT_ZC_TRACK T WHERE T.EVENT_ID = '900102' AND T.ORD_LN_PK = A.ORD_LN_PK) CHARGE_NUM,
              (SELECT NVL(SUM(T.ACT_WEIGHT), 0)FROM MAT_ZC_TRACK T WHERE T.EVENT_ID = '900102' AND T.ORD_LN_PK = A.ORD_LN_PK) CHARGE_WGT,
              (SELECT NVL(SUM(T.ACT_LEN), 0) FROM MAT_ZC_TRACK T WHERE T.EVENT_ID = '900102' AND T.ORD_LN_PK = A.ORD_LN_PK) CHARGE_LEN
             
          FROM SLM_ORDER_LINE A, SLM_ORDER_HEAD B
         WHERE A.ORD_PK = B.ORD_PK
           AND A.VALIDFLAG = '1'
           AND B.VALIDFLAG = '1'
           AND (A.ORDER_LN_STATUS in ('12020402','12020602','12020702','12020802','12020901') OR (A.ORDER_LN_STATUS >= '12020301' AND B.ORDER_TYP = '120102'))
   
]]></query>
</queryMap>