<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="查询合同号信息">

	<query id="CoreOrderInfomation.getOrderInfo" desc="查询产品信息">
		<![CDATA[
				SELECT A.SALE_AREA_DESC,
       A.ORDER_NO,
       A.ORDER_NO || '/' || B.ORDER_SEQ ORDER_NO_SEQ,
       B.ORDER_SEQ,
       DECODE(TRIM(B.ORDER_SPECIAL_DESC), NULL, '', '特殊') ORDER_SEPC_TYPE,
       B.PRODUCNAME,
       B.STEELNAME,
       B.SPEC_NAME,
       B.MODEL_DESC,
       B.LEN_DESC,
       B.STD_NAME,
       C.DELVRY_EDATE,
       C.DELVRY_BDATE,
       C.DELVRY_QTY || C.ORDER_UNIT DELVRY_QTY,
       A.CUSTOMER_NM,
       C.RECEIV_NM,
       A.STLMT_UNIT_NM,
       (SELECT E.BASENAME
          FROM COM_BASE_INFO E
         WHERE E.BASECODE = A.ORDER_TYP) ORDER_TYP,
       A.CREATE_TIME,
       A.EFFECT_TIME,
       (SELECT D.BASENAME
          FROM COM_BASE_INFO D
         WHERE D.BASECODE = A.MNY_ASK_TYP) MNY_ASK_TYP,
       A.BANK,
       A.ACCOUNT,
       C.TRANSIT_PLAN,
       A.TAX_ID,
       A.MNY_ASK_DESC,
       A.ORDER_STS_DESC,
       (SELECT D.BASENAME
          FROM COM_BASE_INFO D
         WHERE D.BASECODE = B.ORDER_LN_STATUS) ORDER_LN_STATUS,
       C.DELVRY_ADDR,
       C.RECEIV_ADDR,
       A.CREATE_NAME,
       (SELECT F.DEPARTNAME FROM CORE.CORE_APP_DEPARTMENT F WHERE F.DEPARTID=A.CREATE_DEPT) CREATE_DEPT
  FROM SLM_ORDER_HEAD A, SLM_ORDER_LINE B, SLM_ORDER_LINE_DELIVERY C
 WHERE B.ORD_PK = A.ORD_PK
   AND B.ORD_LN_PK = C.ORD_LN_PK(+)
   AND A.VALIDFLAG = '1'
   AND B.VALIDFLAG = '1'
   AND UPPER(a.order_no) || '&' LIKE UPPER('%' || ? || '%')
   AND UPPER(A.CUSTOMER_NM) || '&' LIKE UPPER('%' || ? || '%')
   AND UPPER(C.RECEIV_NM) || '&' LIKE UPPER('%' || ? || '%')
   AND UPPER(A.STLMT_UNIT_NM) || '&' LIKE UPPER('%' || ? || '%')
   AND A.CREATE_TIME BETWEEN TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS') AND
       TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS')
		]]>
	</query>

	<query id="CoreOrderInfomation.getOrderInfoNext" desc="查询合同行信息">
		<![CDATA[
SELECT A.ORD_PK,
       A.MANAG_NO,
       A.ORDER_NO,
       A.ORDER_NO || '/' || B.ORDER_SEQ ORDER_SEQ_NO,
       A.CUSTM_ORDER_NO,
       A.REVW_RPT_NO,
       A.ORDER_TYP,
       A.ORDER_TYP_DESC,
       A.PROTCL_NO,
       A.CUSTOMER_NO,
       A.CUSTOMER_NM,
       A.MARKET_SYS,
       A.MARKET_SYS_DESC,
       A.ABRVITION,
       (SELECT C.BASENAME
          FROM COM_BASE_INFO C
         WHERE C.BASECODE = A.SUPPLY_UNIT) SUPPLY_UNIT,
       (SELECT C.BASENAME FROM COM_BASE_INFO C WHERE C.BASECODE = A.PRICE_FL) PRICE_FL,
       (SELECT C.BASENAME FROM COM_BASE_INFO C WHERE C.BASECODE = A.CURRENCY) CURRENCY,
       (SELECT C.BASENAME
          FROM COM_BASE_INFO C
         WHERE C.BASECODE = A.MNY_ASK_TYP) MNY_ASK_TYP,
       A.STLMT_UNIT_NO,
       A.STLMT_UNIT_NM,
       (SELECT C.BASENAME
          FROM COM_BASE_INFO C
         WHERE C.BASECODE = A.FST_DRAWEE_UNIT) FST_DRAWEE_UNIT,
       A.ORDER_WGT,
       A.ORDER_MNY_TAX,
       A.ORDER_MNY_NTAX,
       A.MNY_ASK_DESC,
       A.SIGN_PERSON,
       TO_CHAR(A.SIGN_DATE, 'YYYY-MM-DD ') SIGN_DATE,
       A.SIGN_ADDRESS,
       A.ORDER_YEAR,
       A.ORDER_BDATE,
       A.ORDER_EDATE,
       A.ORDER_SCAN_NO,
       DECODE(A.CUSTOMER_MODEL_FL, '1', '是', '否') CUSTOMER_MODEL_FL,
       A.ORDER_MODEL_NO,
       A.ORDER_MODEL_DESC,
       A.SALE_ORG,
       A.SALE_ORG_DESC,
       A.SALE_AREA_NO,
       A.SALE_AREA_DESC,
       A.MEMO,
       A.ORDER_STS,
       (SELECT C.BASENAME
          FROM COM_BASE_INFO C
         WHERE C.BASECODE = A.ORDER_STS) ORDER_STS_DESC,
       A.APPROVAL_MAN,
       TO_CHAR(A.APPROVAL_TIME, 'YYYY-MM-DD HH24:MI:SS') APPROVAL_TIME,
       A.EFFECT_MAN EFFECTMAN,
       TO_CHAR(A.EFFECT_TIME, 'YYYY-MM-DD HH24:MI:SS') EFFECTTIME,
       A.CLOSE_MAN,
       A.CLOSE_TIME,
       (SELECT E.DEPARTNAME
          FROM CORE.CORE_APP_DEPARTMENT E
         WHERE E.DEPARTID = A.CREATE_DEPT) CREATE_DEPT,
       A.ORD_PK_OLD,
       A.BE_ORDER_STS_DESC,
       A.PRICE_NO,
       B.ORD_LN_PK,
       B.ORDER_SEQ,
       B.PSC,
       B.PSC_DESC,
       B.PRODUCNAME ||
       DECODE(B.STD_STYLE_DESC, NULL, '', ',' || B.STD_STYLE_DESC) || ',' ||
       B.STEELNAME || ',' || B.SPEC_NAME ||
       DECODE(B.MODEL_DESC, '/', '', ',' || B.MODEL_DESC) PSC_NAME_DESC,
       B.MSC,
       DECODE(B.MSC_STYLE,
              'A',
              '钢管(坯)',
              'B',
              '套管+接箍',
              'C',
              '附件短节',
              'D',
              '接箍',
              'E',
              '双公短节',
              '数据异常') MSC_STYLE,
       B.USE_CODE,
       B.USE_DESC,
       (SELECT C.BASENAME FROM COM_BASE_INFO C WHERE C.BASECODE = B.PRD_CLS) PRD_CLS,
       B.PRODUCCODE,
       B.PRODUCNAME,
       B.STD_CODE,
       B.STD_NAME,
       B.STEELCODE,
       B.STEELNAME,
       B.STD_STYLE,
       B.STD_STYLE_DESC,
       B.ORDER_SPEC_CODE,
       B.ORDER_SPEC_DESC,
       B.SPEC_CODE,
       B.SPEC_NAME,
       B.DIMATER,
       B.HEIGHT,
       B.MODEL_CODE,
       B.MODEL_DESC,
       B.LEN_NO,
       B.LEN_DESC,
       B.LEN_UNIT,
       B.LEN_MIN,
       B.LEN_MAX,
       B.SHRT_LEN_RATO,
       B.SHORTEST,
       B.LONG_LEN_RATO,
       B.LONGEST,
       B.SHRT_STOVE,
       B.AVG_LEN_MIN,
       B.DIFRNC_LEN_MAX,
       B.ENDLEN_SPECSTD,
       TO_CHAR(B.SIGL_LEN, 'FM9990.000') SIGL_LEN,
       B.ORDER_UNIT,
       TO_CHAR(B.ORDER_QTY, 'FM99999990.000') ORDER_QTY,
       DECODE(ORD_ENSU_TOTL_LEN,
              '0',
              '/',
              TO_CHAR(B.ORD_ENSU_TOTL_LEN, 'FM99999990.0')) ORD_ENSU_TOTL_LEN,
       TO_CHAR(B.PRDCT_WGT, 'FM9999990.000') PRDCT_WGT,
       DECODE(B.DELVRY_RANGE_TPE,
              '%',
              '-' || B.DELVRY_RANGE_MIN || '%' || ',+' || B.DELVRY_RANGE_MAX || '%',
              '(' || B.DELVRY_RANGE_MIN || ',' || B.DELVRY_RANGE_MAX || ')') DELVRY_RANGE_TPE,
       B.DELVRY_RANGE_MIN,
       B.DELVRY_RANGE_MIN,
       B.DELVRY_RANGE_MAX,
       B.FINAL_USER,
       B.FINAL_USER_DESC,
       Q4.ABRVITION FINAL_ABR,
       (SELECT C.BASENAME
          FROM COM_BASE_INFO C
         WHERE C.BASECODE = B.OUTS_BILLET_FL) OUTS_BILLET_FL,
       (SELECT C.BASENAME
          FROM COM_BASE_INFO C
         WHERE C.BASECODE = B.OUTS_STL_PIPE_FL) OUTS_STL_PIPE_FL,
       DECODE(B.ASSEL_FL, '1', 'True', 'False') ASSEL_FL,
       DECODE(B.PRODUCER_FL, '1', 'True', 'False') PRODUCER_FL,
       B.PRDCR_NO,
       Q2.PRDCR_DESC,
       DECODE(B.MPS_FL, '1', 'True', 'False') MPS_FL,
       B.MPS_NO,
       B.MPS_DESC,
       B.DELVRY_BDATE,
       B.DELVRY_EDATE,
       B.DELVRY_DESC,
       B.TRANS_DESC,
       B.ADD_ASK_NO,
       B.ORDER_ADD_DESC,
       B.ORDER_SPECIAL_FL,
       B.ORDER_SPECIAL_HEAD,
       B.ORDER_SPECIAL_PATH,
       B.ORDER_SPECIAL_DESC,
       DECODE(TRIM(B.ORDER_SPECIAL_DESC), NULL, '普通', '特殊') SPECIALTYPE,
       B.ZBS,
       B.ORDER_PRICE,
       B.TRANS_PRICE,
       B.TEST_ID,
       B.TEST_PRICE,
       B.OUT_PRICE,
       B.BALNCE_PRICE,
       (SELECT C.BASENAME
          FROM COM_BASE_INFO C
         WHERE C.BASECODE = B.BE_ORDER_LN_STATUS) BE_ORDER_LN_STATUS,
       B.BE_OBJ_STS_OP,
       (SELECT C.BASENAME
          FROM COM_BASE_INFO C
         WHERE C.BASECODE = B.ORDER_LN_STATUS) ORDER_LN_STATUS,
       B.OBJ_STS_OP,
       B.MEMO,
       B.CREATE_NAME,
       TO_CHAR(B.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       B.UPDATE_NAME,
       TO_CHAR(B.UPDATE_TIME, 'YYYY-MM-DD HH24:MI:SS') UPDATE_TIME,
       B.DELETE_NAME,
       TO_CHAR(B.DELETE_TIME, 'YYYY-MM-DD HH24:MI:SS') DELETE_TIME,
       B.ORD_LN_PK_OLD,
       DECODE(A.CONTAIN_TAX, '1', '含税', '不含税') CONTAIN_TAX,
       B.AW,
       DECODE(B.BALNCE_PRICE_STS, '1', '确认', '未确认') BALNCE_PRICE_STS,
       DECODE(B.BALNCE_PRICE_ORG, NULL, '未维护', '已维护') BALNCE_PRICE_ORG_STS,
       B.PROJECT_NO,
       Q1.REGION_NO,
       GET_ORDER_TECHNICAL_DEC(B.Ord_Ln_Pk) UNIT_DESC,
       A.IPMAC

  FROM SLM_ORDER_HEAD A
  LEFT JOIN (SELECT RE.REGION_NM REGION_NO, Q.CUSTOMER_NO
               FROM SLM_BASE_CUSTOMER Q
               LEFT JOIN SEL_ADMIN_REGION RE
                 ON RE.REGION_NO = Q.REGION_NO
              WHERE Q.VALIDFLAG = '1'
                AND RE.VALIDFLAG = '1'
              GROUP BY Q.CUSTOMER_NO, RE.REGION_NM) Q1
    ON Q1.CUSTOMER_NO = A.CUSTOMER_NO, SLM_ORDER_LINE B
  LEFT JOIN (SELECT Q3.ABRVITION, Q3.CUSTOMER_NO
               FROM SLM_BASE_CUSTOMER Q3
              WHERE Q3.VALIDFLAG = '1'
              GROUP BY Q3.CUSTOMER_NO, Q3.ABRVITION) Q4
    ON B.FINAL_USER = Q4.CUSTOMER_NO
  LEFT JOIN (SELECT LISTAGG(C.BASENAME, ',') WITHIN GROUP(ORDER BY PRDCR_NO) PRDCR_DESC,
                    PRDCR_NO
               FROM SLM_ORDER_LINE_PRDCR F, COM_BASE_INFO C
              WHERE C.BASECODE = F.PRDCR_DESC
              GROUP BY F.PRDCR_NO) Q2
    ON Q2.PRDCR_NO = B.PRDCR_NO
 WHERE A.ORD_PK = B.ORD_PK
   AND A.VALIDFLAG = '1'
   AND B.VALIDFLAG = '1'
   AND UPPER(A.ORDER_NO) || '&' LIKE UPPER('%' || ? || '%')
   AND UPPER(A.CUSTOMER_NM) || '&' LIKE UPPER('%' || ? || '%')
   AND UPPER(A.STLMT_UNIT_NM) || '&' LIKE UPPER('%' || ? || '%')
   AND UPPER(A.CUSTM_ORDER_NO) || '&' LIKE UPPER('%' || ? || '%')
   AND B.CREATE_TIME BETWEEN TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS') AND
       TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS')
		]]>
	</query>


	<query id="CoreOrderInfomation.getOrderDelivyInfo" desc="查询交货行信息">
		<![CDATA[
   SELECT T.ORD_PK,
       T.ORD_LN_PK,
       T.ORD_LN_DLY_PK,
       T.DELIVERY_NO,
       T.DELVRY_BDATE,
       TO_CHAR(T.DELVRY_EDATE, 'YYYY-MM-DD') DELVRY_EDATE,
       TO_CHAR(T.DELVRY_QTY, '99999990.0') DELVRY_QTY,
       T.ORDER_UNIT,
       TO_CHAR(T.WGT_ESTMT, '99999990.0') WGT_ESTMT,
       T.ENSU_TOTL_LEN,
       T.RECEIV_NO,
       T.RECEIV_NM,
       T.DELVRY_ADDR,
       DECODE(T.AGENCY_FL, '1', '有', '无') AGENCY_FL,
       T.RECEIV_ADDR,
       (SELECT BASENAME FROM COM_BASE_INFO WHERE BASECODE = T.TRANSIT_TYP) TRANSIT_TYP,
       T.TRANSIT_PLAN,
       T.TRANSIT_MNY,
       T.BE_DELIVERY_STATUS,
       T.BE_OBJ_STS_OP,
       DECODE(T1.PORDERSTATUS,
              NULL,
              (SELECT A.BASENAME
                 FROM COM_BASE_INFO A
                WHERE A.BASECODE = T.DELIVERY_STATUS),
              (DECODE(T1.PORDERSTATUS,
                      '0',
                      '待接收',
                      '1',
                      '已接收',
                      '2',
                      '已下发',
                      '3',
                      '生产中',
                      '4',
                      '生产完成',
                      '5',
                      '缴库完成',
                      '6',
                      '关闭',
                      '异常'))) DELIVERY_STATUS,
       T1.PORDERSTATUS,
       T.OBJ_STS_OP,
       T.VALIDFLAG,
       T.CREATE_NAME,
       TO_CHAR(T.CREATE_TIME, 'YYYY-MM-DD HH:MI:SS') CREATE_TIME,
       T.UPDATE_NAME,
       T.UPDATE_TIME,
       T.DELETE_NAME,
       T.DELETE_TIME
  FROM SLM_ORDER_LINE_DELIVERY T, PLN_SALEORD T1
 WHERE T.ORD_LN_DLY_PK = T1.ORD_LN_DLY_PK(+) 
   AND T.ORD_LN_PK = ?
   AND T.VALIDFLAG = '1'
		]]>
	</query>

	<query id="CoreOrderInfomation.getOrderTranSit" desc="查询运输方案信息">
		<![CDATA[
       SELECT T.ORD_PK,
       T.ORD_LN_PK,
       T.ORD_LN_DLY_PK,
       T.INDEX_SEQ,
       DECODE(T.AGENCY_FL,'1','有','无') AGENCY_FL,
       (SELECT C.BASENAME
          FROM COM_BASE_INFO C
         WHERE C.BASECODE = T.TRANSIT_TYP) TRANSIT_TYP,
       T.DESTINATION,
       T.STATION_NO,
       (SELECT A.STATION_NM
          FROM SLM_BASE_STATION A
         WHERE A.STATION_NO = T.STATION_NO) STATION_NM,
       T.SPCL_LN_NO,
       (SELECT B.SPCL_LN_NM
          FROM SLM_BASE_SPCL_LN B
         WHERE B.SPCL_LN_NO = T.SPCL_LN_NO) SPCL_LN_NM,
       T.PORT_NO,
       (SELECT D.BASENAME FROM COM_BASE_INFO D WHERE D.BASECODE=T.PORT_NO) PORT_DESC,
       (SELECT D.BASENAME
          FROM COM_BASE_INFO D
         WHERE D.BASECODE = T.CARRIER_UNIT) CARRIER_UNIT,
       T.RECEIVOR,
       T.TRANSIT_LN_MNY,
       T.VALIDFLAG,
       T.CREATE_NAME,
       T.CREATE_TIME,
       T.UPDATE_NAME,
       T.UPDATE_TIME,
       T.DELETE_NAME,
       T.DELETE_TIME,
       T.LV_FACTY_TYP
  FROM SLM_ORDER_DELIVERY_TRANSIT T 
 WHERE T.ORD_LN_DLY_PK = ?
   AND T.VALIDFLAG = '1' 
   ORDER BY T.INDEX_SEQ    
		]]>
	</query>

	<query id="CoreOrderInfomation.getOrderQualityInfo" desc="查询技术评审明细信息">
		<![CDATA[
     SELECT T.DESGIN_KEY,
       T.ORD_LN_PK,
       T.SEQ_INDEX,
       T.LST_ITEM,
       DECODE(T.DESIGN_STS, 'W', '等待', 'S', '通过', 'F', '失败') DESIGN_STS,
       DECODE(T.DESIGN_STS_RS,
              '00',
              '无要求',
              '11',
              '通过',
              '12',
              '通过(警告)',
              '20',
              '待人工确认',
              '21',
              '待系统设计',
              '90',
              '无',
              '91',
              '缺项',
              '92',
              '错项','') DESIGN_STS_RS,
       T.DESIGN_STS_DESC,
       T.PSC,
       T.MSC,
       T.USE_CODE,
       T.FINAL_USER,
       T.GRADECODE,
       T.DESIGN_OBJ_KEY,
       T.UNIT_CODE,
       DECODE(T.UNIT_CODE,
              NULL,
              NULL,
              ((SELECT B.DEPARTNAME
                  FROM CORE.CORE_APP_DEPARTMENT B
                 WHERE B.DEPARTID =
                       (SELECT B.PID
                          FROM CORE.CORE_APP_DEPARTMENT B
                         WHERE B.DEPARTID = T.UNIT_CODE)) || '-' ||
              T.UNIT_DESC)) UNIT_DESC,
       T.VALIDFLAG,
       T.CREATE_NAME,
       T.CREATE_TIME,
       DECODE(T.UPDATE_NAME,
              NULL,
              'SYSTEM',
              NVL((SELECT C.USERNAME
                 FROM CORE.CORE_APP_USER C
                WHERE C.USERID = T.UPDATE_NAME), T.UPDATE_NAME)) UPDATE_NAME,
       DECODE(T.UPDATE_TIME,
              NULL,
              TO_CHAR(T.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS'),
              TO_CHAR(T.UPDATE_TIME, 'YYYY-MM-DD HH24:MI:SS')) UPDATE_TIME,
       T.DELETE_NAME,
       T.DELETE_TIME
  FROM SLM_ORD_DESIGN_STS_TKLG_LST T
 WHERE T.ORD_LN_PK = ?
   AND (T.DESIGN_STS = 'F' OR T.VALIDFLAG = '1')
 ORDER BY   T.CREATE_TIME, T.SEQ_INDEX
		]]>
	</query>

</queryMap>