<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="权限功能表查询">

	<query id="CoreOrderChangeManage.QueryOrderHead" desc="合同类型 ">
		<![CDATA[
		
			SELECT ORD_PK,
       MANAG_NO,
       ORDER_NO,
       CUSTM_ORDER_NO,
       REVW_RPT_NO,
       ORDER_TYP,
       (SELECT BASENAME FROM COM_BASE_INFO WHERE BASECODE = ORDER_TYP AND VALIDFLAG = '1') ORDER_TYP_DESC,
       PROTCL_NO,
       CUSTOMER_NO,
       CUSTOMER_NM,
       MARKET_SYS,
       (SELECT BASENAME FROM COM_BASE_INFO WHERE BASECODE = MARKET_SYS AND VALIDFLAG = '1') MARKET_SYS_DESC,
       ABRVITION,
       (SELECT BASENAME FROM COM_BASE_INFO WHERE BASECODE = SUPPLY_UNIT AND VALIDFLAG = '1') SUPPLY_UNIT,
       (SELECT BASENAME FROM COM_BASE_INFO WHERE BASECODE = PRICE_FL AND VALIDFLAG = '1') PRICE_FL,
       (SELECT BASENAME FROM COM_BASE_INFO WHERE BASECODE = CURRENCY AND VALIDFLAG = '1') CURRENCY,
       (SELECT BASENAME FROM COM_BASE_INFO WHERE BASECODE = MNY_ASK_TYP AND VALIDFLAG = '1') MNY_ASK_TYP,
       STLMT_UNIT_NO,
       STLMT_UNIT_NM,
       (SELECT BASENAME FROM COM_BASE_INFO WHERE BASECODE = FST_DRAWEE_UNIT AND VALIDFLAG = '1') FST_DRAWEE_UNIT ,
       LEGAL_PSN,
       AGENT,
       ADDRESS,
       ZIP_CODE,
       BANK,
       ACCOUNT,
       TAX_ID,
       PHONE,
       FAX,
       ORDER_WGT,
       ORDER_MNY_TAX,
       ORDER_MNY_NTAX,
       MNY_ASK_DESC,
       SIGN_PERSON,
       TO_CHAR(SIGN_DATE,'YYYY-MM-DD') SIGN_DATE,
       SIGN_ADDRESS,
       ORDER_YEAR,
       ORDER_BDATE,
       ORDER_EDATE,
       ORDER_SCAN_NO,
       CUSTOMER_MODEL_FL,
       ORDER_MODEL_NO,
       ORDER_MODEL_DESC,
       SALE_ORG,
       SALE_ORG_DESC,
       SALE_AREA_NO,
       SALE_AREA_DESC,
       MEMO,
       BE_ORDER_STS,
       BE_OBJ_STS_OP,
       ORDER_STS,
       (SELECT BASENAME FROM COM_BASE_INFO WHERE BASECODE = ORDER_STS AND VALIDFLAG = '1') ORDER_STS_DESC,
       OBJ_STS_OP,
       APPROVAL_MAN,
       TO_CHAR(APPROVAL_TIME,'YYYY-MM-DD HH24:MI:SS') APPROVAL_TIME,
       EFFECT_MAN,
       TO_CHAR(EFFECT_TIME,'YYYY-MM-DD HH24:MI:SS') EFFECT_TIME,
       CLOSE_MAN,
       TO_CHAR(CLOSE_TIME,'YYYY-MM-DD HH24:MI:SS') CLOSE_TIME,
       DECODE(VALIDFLAG,'1','有效','无效') VALIDFLAG,
       CREATE_NAME,
       CREATE_DEPT,
       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,
       DELETE_NAME,
       TO_CHAR(DELETE_TIME,'YYYY-MM-DD HH24:MI:SS') DELETE_TIME,
       ORD_PK_OLD,
       BE_ORDER_STS_DESC,
       PRICE_NO
  FROM SLM_ORDER_HEAD T
  WHERE (T.SALE_ORG = ? or 1=1)
   AND T.ORDER_NO LIKE '%' || ? || '%'
   AND T.VALIDFLAG = '1'
   AND (T.ORDER_STS >= '12020301' AND  T.ORDER_STS <='12020602')		
   --AND T.ORDER_STS IN ('12020301','12020401')
   AND T.ORDER_TYP <> '120102'
		
		]]>
	</query>

	<query id="CoreOrderChangeManage.QueryOrderLine" desc="合同类型 ">
		<![CDATA[
			 SELECT ORD_PK, ORD_LN_PK, ORDER_SEQ, CUST_ALPHA_NO, MSC_STYLE,
			     NVL (ORDER_QTY * ORDER_PRICE, '0') SUMPRICE, PSC, PSC_DESC, PRD_CLS,
			     PRODUCCODE, PRODUCNAME, STD_CODE, STD_NAME, STEELCODE, STEELNAME,
			     ORDER_SPEC_CODE, ORDER_SPEC_DESC, SPEC_CODE, SPEC_NAME, DIMATER,
			     HEIGHT, MODEL_CODE, MODEL_DESC, LEN_NO, LEN_DESC, LEN_UNIT, LEN_MIN,
			     LEN_MAX, SHRT_LEN_RATO, SHORTEST, LONG_LEN_RATO, LONGEST, SHRT_STOVE,
			     AVG_LEN_MIN, DIFRNC_LEN_MAX, SIGL_LEN, ORDER_UNIT, ORDER_QTY,
			     ORD_ENSU_TOTL_LEN, PRDCT_WGT, DELVRY_RANGE_TPE, DELVRY_RANGE_MIN,
			     DELVRY_RANGE_MAX, FINAL_USER, FINAL_USER_DESC,STD_STYLE,STD_STYLE_DESC,
			     (SELECT BASENAME
			        FROM COM_BASE_INFO
			       WHERE BASECODE = LE.OUTS_BILLET_FL) OUTS_BILLET_FL,
			     OUTS_BILLET_FL OUTS_BILLET_FL_ID,
			     (SELECT BASENAME
			        FROM COM_BASE_INFO
			       WHERE BASECODE = LE.OUTS_STL_PIPE_FL) OUTS_STL_PIPE_FL,
			     OUTS_STL_PIPE_FL OUTS_STL_PIPE_FL_ID, ASSEL_FL,USE_CODE,USE_DESC,
			     TO_CHAR (DELVRY_BDATE, 'YYYY-MM-DD') DELVRY_BDATE,
			     TO_CHAR (DELVRY_EDATE, 'YYYY-MM-DD') DELVRY_EDATE, DELVRY_DESC,
			     TRANS_DESC, ADD_ASK_NO, ORDER_SPECIAL_DESC, ORDER_ADD_DESC,
			     ORDER_PRICE, TRANS_PRICE, TEST_ID, TEST_PRICE, OUT_PRICE, BALNCE_PRICE,
			     ORDER_LN_STATUS,
			     (SELECT BASENAME
			        FROM COM_BASE_INFO
			       WHERE BASECODE = LE.ORDER_LN_STATUS) ORDER_LN_STATUS_DESC, MEMO,
			     DECODE(VALIDFLAG,'1','有效','无效') VALIDFLAG, 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,
			     TO_CHAR(DELETE_TIME,'YYYY-MM-DD HH24:MI:SS') DELETE_TIME,
			     DELETE_NAME, MSC, MSC_DESC, PRODUCER_FL,
			     (SELECT ORDER_NO
			        FROM SLM_ORDER_HEAD
			       WHERE ORD_PK = LE.ORD_PK) ORDER_NO,
			     (SELECT BASENAME
			        FROM COM_BASE_INFO
			       WHERE BASECODE = LE.OUTS_BILLET_FL) OUTS_BILLET_DESC,
			     (SELECT BASENAME
			        FROM COM_BASE_INFO
			       WHERE BASECODE = LE.OUTS_STL_PIPE_FL) OUTS_STL_PIPE_DESC,
			        '(-'
			     || TO_CHAR (DELVRY_RANGE_MIN)
			     || DECODE (DELVRY_RANGE_TPE, '%', '%', ORDER_UNIT)
			     || ','
			     || TO_CHAR (DELVRY_RANGE_MAX)
			     || DECODE (DELVRY_RANGE_TPE, '%', '%', ORDER_UNIT)
			     || ')' DELIVERY_TPE,
			     MPS_FL,ISLOCK IS_LOCK
			FROM SLM_ORDER_LINE LE WHERE ORD_PK = ? 
			AND VALIDFLAG ='1'
			 ORDER BY CREATE_TIME DESC
		
		]]>
	</query>

	<query id="CoreOrderChangeManage.QueryOrderDlyLine" desc="合同类型 ">
		<![CDATA[
		SELECT ORD_PK,
       ORD_LN_PK,
       ORD_LN_DLY_PK,
       DELIVERY_NO,
       TO_CHAR(DELVRY_EDATE,'YYYY-MM-DD') DELVRY_EDATE,
       DELVRY_QTY,
       ORDER_UNIT,
       WGT_ESTMT,
       ENSU_TOTL_LEN,
       RECEIV_NO,
       RECEIV_NM,
       DELVRY_ADDR,
       AGENCY_FL,
       RECEIV_ADDR,
       (SELECT BASENAME FROM COM_BASE_INFO WHERE BASECODE = TRANSIT_TYP AND VALIDFLAG = '1') TRANSIT_TYP,
       TRANSIT_PLAN,
       TRANSIT_MNY,
       (SELECT BASENAME FROM COM_BASE_INFO WHERE BASECODE = DELIVERY_STATUS AND VALIDFLAG = '1') DELIVERY_STATUS,
       DECODE(VALIDFLAG, '1', '有效', '无效') VALIDFLAG,
       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,
       ISLOCK IS_LOCK,
       DECODE(IS_ADD,'1','是','否') IS_ADD

  FROM SLM_ORDER_LINE_DELIVERY T
 WHERE T.ORD_PK = ?
   AND T.ORD_LN_PK = ?
   AND T.VALIDFLAG = '1'
		

			]]>
	</query>

	<query id="CoreOrderChangeManage.QueryOrderDlyLineTransit" desc="合同类型 ">
		<![CDATA[
	               SELECT ORD_PK,
       ORD_LN_PK,
       ORD_LN_DLY_PK,
       INDEX_SEQ,
       DECODE(AGENCY_FL, '0', '无代办', '1', 'TPCO代办', '2', '客户代办') AGENCY_FL,
       (SELECT BASENAME
          FROM COM_BASE_INFO
         WHERE BASECODE = TRANSIT_TYP
           AND VALIDFLAG = '1') TRANSIT_TYP,
       DESTINATION,
       STATION_NO,
       (SELECT STATION_NM
  FROM SLM_BASE_STATION A
 WHERE A.STATION_NO = T.STATION_NO ) STATION_NM, SPCL_LN_NO,
 (SELECT SPCL_LN_NM
          FROM SLM_BASE_SPCL_LN B
         WHERE B.SPCL_LN_NO = T.SPCL_LN_NO) SPCL_LN_NM, PORT_NO,
 (SELECT BASENAME
          FROM COM_BASE_INFO
         WHERE BASECODE = PORT_NO
           AND VALIDFLAG = '1') PORT_DESC,
 (SELECT BASENAME
          FROM COM_BASE_INFO
         WHERE BASECODE = CARRIER_UNIT
           AND VALIDFLAG = '1') CARRIER_UNIT, RECEIVOR,
 TRANSIT_LN_MNY, DECODE(VALIDFLAG, '1', '有效', '无效') VALIDFLAG,
 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

 FROM SLM_ORDER_DELIVERY_TRANSIT T
 WHERE ORD_PK = ?
   AND ORD_LN_PK = ?
   AND ORD_LN_DLY_PK = ?
	               
		         

		]]>
	</query>

	<query id="CoreOrderChangeManage.GetCHGEOrderDelivery" desc="查询交货行变更表 ">
		<![CDATA[
	 		SELECT 1 FROM 	CHGE_SLM_ORDER_DELIVERY T
	 		WHERE T.ORD_PK = ? AND T.ORD_LN_PK = ?
	 	]]>
	</query>

	<query id="CoreOrderChangeManage.GetCHGEOrderDeliveryTransit"
		desc="查询发运表变更">
		<![CDATA[
	 		SELECT 1 FROM 	CHGE_SLM_ORDER_TRANSIT T
	 		WHERE T.ORD_PK = ? AND T.ORD_LN_PK = ?
	 	]]>
	</query>

	<query id="CoreOrderChangeManage.InsertCHGEOrderDelivery" desc="插入变更交货表 ">
		<![CDATA[
	 			INSERT INTO CHGE_SLM_ORDER_DELIVERY
  (ORD_PK,
   ORD_LN_PK,
   ORD_LN_DLY_PK,
   DELIVERY_NO,
   DELVRY_BDATE,
   DELVRY_EDATE,
   DELVRY_QTY,
   ORDER_UNIT,
   WGT_ESTMT,
   ENSU_TOTL_LEN,
   RECEIV_NO,
   RECEIV_NM,
   DELVRY_ADDR,
   AGENCY_FL,
   RECEIV_ADDR,
   TRANSIT_TYP,
   TRANSIT_PLAN,
   TRANSIT_MNY,
   BE_DELIVERY_STATUS,
   BE_OBJ_STS_OP,
   DELIVERY_STATUS,
   OBJ_STS_OP,
   VALIDFLAG,
   CREATE_NAME,
   CREATE_TIME,
   UPDATE_NAME,
   UPDATE_TIME,
   DELETE_NAME,
   DELETE_TIME,
   EXTRA_FLAG,
   IS_ADD)

  SELECT ORD_PK,
         ORD_LN_PK,
         ORD_LN_DLY_PK,
         DELIVERY_NO,
         DELVRY_BDATE,
         DELVRY_EDATE,
         DELVRY_QTY,
         ORDER_UNIT,
         WGT_ESTMT,
         ENSU_TOTL_LEN,
         RECEIV_NO,
         RECEIV_NM,
         DELVRY_ADDR,
         AGENCY_FL,
         RECEIV_ADDR,
         TRANSIT_TYP,
         TRANSIT_PLAN,
         TRANSIT_MNY,
         BE_DELIVERY_STATUS,
         BE_OBJ_STS_OP,
         DELIVERY_STATUS,
         OBJ_STS_OP,
         VALIDFLAG,
         CREATE_NAME,
         CREATE_TIME,
         UPDATE_NAME,
         UPDATE_TIME,
         DELETE_NAME,
         DELETE_TIME,
         EXTRA_FLAG,
         IS_ADD
  
    FROM SLM_ORDER_LINE_DELIVERY T
   WHERE T.ORD_PK = ?
     AND T.ORD_LN_PK = ?
     AND (T.DELIVERY_STATUS ='12020301' OR T.DELIVERY_STATUS ='12020302')
	 AND T.VALIDFLAG = '1'		
	 				
	 	]]>
	</query>

	<query id="CoreOrderChangeManage.InsertCHGEOrderDeliveryTransit"
		desc="插入发运变更表 ">
		<![CDATA[
	 				
	 				INSERT INTO CHGE_SLM_ORDER_TRANSIT
  (ORD_PK,
   ORD_LN_PK,
   ORD_LN_DLY_PK,
   INDEX_SEQ,
   AGENCY_FL,
   TRANSIT_TYP,
   DESTINATION,
   STATION_NO,
   STATION_NM,
   SPCL_LN_NO,
   SPCL_LN_NM,
   PORT_NO,
   PORT_DESC,
   CARRIER_UNIT,
   RECEIVOR,
   TRANSIT_LN_MNY,
   VALIDFLAG,
   CREATE_NAME,
   CREATE_TIME,
   UPDATE_NAME,
   UPDATE_TIME,
   DELETE_NAME,
   DELETE_TIME,
   LV_FACTY_TYP)
   
  SELECT ORD_PK,
         ORD_LN_PK,
         ORD_LN_DLY_PK,
         INDEX_SEQ,
         AGENCY_FL,
         TRANSIT_TYP,
         DESTINATION,
         STATION_NO,
         STATION_NM,
         SPCL_LN_NO,
         SPCL_LN_NM,
         PORT_NO,
         PORT_DESC,
         CARRIER_UNIT,
         RECEIVOR,
         TRANSIT_LN_MNY,
         VALIDFLAG,
         CREATE_NAME,
         CREATE_TIME,
         UPDATE_NAME,
         UPDATE_TIME,
         DELETE_NAME,
         DELETE_TIME,
         LV_FACTY_TYP
    FROM SLM_ORDER_DELIVERY_TRANSIT T
   WHERE T.ORD_PK = ?
     AND T.ORD_LN_PK = ?
     AND T.VALIDFLAG = '1'
	 				
	 	]]>
	</query>

	<query id="CoreOrderChangeManage.QueryCHGEOrderDelivery" desc="查询发运表变更">
		<![CDATA[
	SELECT T.ORD_PK,
       T.ORD_LN_PK,
       T.ORD_LN_DLY_PK,
       T.DELIVERY_NO,
       TO_CHAR(T.DELVRY_EDATE, 'YYYY-MM-DD') DELVRY_EDATE,
	   K.PRDCYC_MEET,
       K.RCMD_DELVRY_EDATE,
       T.DELVRY_QTY,
       T.ORDER_UNIT,
       T.WGT_ESTMT,
       T.ENSU_TOTL_LEN,
       T.RECEIV_NO,
       T.RECEIV_NM,
       T.DELVRY_ADDR,
       DECODE(T.AGENCY_FL, '1', 'TRUE', 'FALSE') AGENCY_FL,
       T.RECEIV_ADDR,
       T.TRANSIT_PLAN,
       T.TRANSIT_MNY,
       T.VALIDFLAG,
       T.CREATE_NAME,
       TO_CHAR(T.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       T.TRANSIT_TYP,
       DECODE(T.EXTRA_FLAG,'1','是','否') EXTRA_FLAG,
       DECODE(T.IS_ADD,'1','是','否') IS_ADD,
       T.IS_ADD IS_ADD_CODE,
       (SELECT BASENAME
          FROM COM_BASE_INFO
         WHERE BASECODE = T.TRANSIT_TYP
           AND VALIDFLAG = '1') TRANSIT_TYP_NM        
		FROM (SELECT T3.DESGIN_KEY,
		       T1.ORD_LN_DLY_PK,
		       T1.ORD_LN_PK,
		       DECODE(T1.PRDCYC_MEET, 'S', '满足', 'F', '不满足') PRDCYC_MEET,
		       TO_CHAR(T2.RCMD_DELVRY_EDATE, 'YYYY-MM-DD') RCMD_DELVRY_EDATE
		  FROM SLM_ORD_DESIGN_STS_PL_PC T1,
		       SLM_ORD_DESIGN_MSC_PL_PC T2,
		       SLM_ORD_DESIGN_MSC       T3
		 WHERE T3.DESGIN_KEY = T2.DESGIN_KEY(+)
		   AND T3.DESGIN_KEY = T1.DESGIN_KEY(+)
		   AND T2.ORD_LN_DLY_PK = T1.ORD_LN_DLY_PK
		   AND T3.VALIDFLAG = '1')K,
		   CHGE_SLM_ORDER_DELIVERY  T   
		   WHERE T.ORD_LN_DLY_PK = K.ORD_LN_DLY_PK(+)
		   AND  T.VALIDFLAG = '1'
		   AND T.ORD_PK = ?
		   AND T.ORD_LN_PK = ?
		    ORDER BY DELVRY_EDATE DESC 
	 	]]>
	</query>

	<query id="CoreOrderChangeManage.getDeliveryTransit" desc="查询合同行交货运输方案">
		<![CDATA[
       SELECT ORD_PK,
       ORD_LN_PK,
       ORD_LN_DLY_PK,
       INDEX_SEQ,
       AGENCY_FL,
       DECODE(AGENCY_FL, '1', 'True', '2', 'True', 'False') AGENCY_FL2,
       TRANSIT_TYP,
       DESTINATION,
       STATION_NO,
       STATION_NM,
       SPCL_LN_NO,
       SPCL_LN_NM,
       PORT_NO,
       PORT_DESC,
       CARRIER_UNIT,
       RECEIVOR,
       TRANSIT_LN_MNY,
       VALIDFLAG,
       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,
       DELETE_NAME,
       TO_CHAR(DELETE_TIME, 'YYYY-MM-DD HH24:MI:SS') DELETE_TIME
   FROM CHGE_SLM_ORDER_TRANSIT T
   WHERE T.ORD_PK = '#ORD_PK#'
   AND T.ORD_LN_PK = '#ORD_LN_PK#'
   AND T.ORD_LN_DLY_PK = '#ORD_LN_DLY_PK#'
   AND (T.AGENCY_FL = '#AGENCY_FL#' OR DECODE('#AGENCY_FL#', '2', T.AGENCY_FL, '1') = DECODE('#AGENCY_FL#', '2', '0', '2'))
   AND T.VALIDFLAG = '1'
		]]>
	</query>


	<query id="CoreOrderChangeManage.doUpdateOrderDlyLine" desc="查询发运表变更">
		 
		<![CDATA[
			UPDATE 
			CHGE_SLM_ORDER_DELIVERY 
			SET 
			ORD_LN_DLY_PK = DECODE(?,'',ORD_LN_DLY_PK,?||LPAD(TO_NUMBER(SUBSTR(?,36,3))+1,3,'0')),
            DELVRY_EDATE=TO_DATE(?,'YYYY-MM-DD'),
            DELVRY_QTY=?,
            ORDER_UNIT=?,
            WGT_ESTMT=ROUND(?,3),
            ENSU_TOTL_LEN=?,
            RECEIV_NO=?,
            RECEIV_NM=?,
            DELVRY_ADDR=?,
            AGENCY_FL=?,
            RECEIV_ADDR=?,
            TRANSIT_PLAN=?,
            TRANSIT_MNY=?,
            UPDATE_NAME=?,
            UPDATE_TIME=SYSDATE,
            TRANSIT_TYP = ? ,
            EXTRA_FLAG = ?
			WHERE
			ORD_PK=? AND ORD_LN_PK=? AND ORD_LN_DLY_PK=?
	 
	 	]]>
	</query>

	<query id="CoreOrderChangeManage.clearTransit" desc="查询发运表变更">
		<![CDATA[
	 		 DELETE FROM CHGE_SLM_ORDER_TRANSIT WHERE ORD_LN_DLY_PK=? 
	 	]]>
	</query>

	<query id="CoreOrderChangeManage.deleteDelivery" desc="查询发运表变更">
		<![CDATA[
	 		 DELETE FROM  CHGE_SLM_ORDER_DELIVERY WHERE ORD_LN_DLY_PK=? 
	 	]]>
	</query>
	
	<query id="CoreOrderChangeManage.deleteDeliveryMsc" desc="查询发运表变更">
		<![CDATA[
	 		 DELETE FROM  SLM_ORD_DESIGN_MSC_PL_PC WHERE ORD_LN_DLY_PK=? 
	 	]]>
	</query>
	
	<query id="CoreOrderChangeManage.deleteDeliverySts" desc="查询发运表变更">
		<![CDATA[
	 		 DELETE FROM  SLM_ORD_DESIGN_STS_PL_PC WHERE ORD_LN_DLY_PK=? 
	 	]]>
	</query>
	

	<query id="CoreOrderChangeManage.clearTransitOrdLnPk" desc="查询发运表变更">
		<![CDATA[
	 		 DELETE FROM CHGE_SLM_ORDER_TRANSIT WHERE ORD_LN_PK=? 
	 	]]>
	</query>

	<query id="CoreOrderChangeManage.deleteDeliveryOrdLnPk" desc="查询发运表变更">
		<![CDATA[
	 		 DELETE FROM  CHGE_SLM_ORDER_DELIVERY WHERE ORD_LN_PK=? 
	 	]]>
	</query>

	<query id="CoreOrderChangeManage.doAdd" desc="交货信息新增">
		<![CDATA[
			INSERT INTO CHGE_SLM_ORDER_DELIVERY(
					            ORD_PK,ORD_LN_PK,ORD_LN_DLY_PK,DELIVERY_NO,
					            DELVRY_EDATE,DELVRY_QTY,ORDER_UNIT,
					            WGT_ESTMT,ENSU_TOTL_LEN,RECEIV_NO,RECEIV_NM,
					            DELVRY_ADDR,AGENCY_FL,RECEIV_ADDR,TRANSIT_PLAN,
					            TRANSIT_MNY,VALIDFLAG,CREATE_NAME,CREATE_TIME,
					            TRANSIT_TYP,DELIVERY_STATUS,EXTRA_FLAG,IS_ADD
								) 
					            VALUES
					            (?,?,(DECODE(?, '', ? || '001',
								              ? ||LPAD(TO_NUMBER(SUBSTR(?,36,3)) + 1, 3, '0')
								             )
								    ),
								(CASE
                                  WHEN (SELECT TO_NUMBER(NVL(MAX(DELIVERY_NO), '0')) + 1
                                           FROM SLM_ORDER_LINE_DELIVERY
                                          WHERE ORD_LN_PK = ?) >=
                                         (SELECT TO_NUMBER(NVL(MAX(DELIVERY_NO), '0')) + 1
                                            FROM CHGE_SLM_ORDER_DELIVERY
                                    WHERE ORD_LN_PK = ?) THEN
                                   (SELECT LPAD(TO_NUMBER(NVL(MAX(DELIVERY_NO), '0')) + 1, '3', '0')
                                     FROM SLM_ORDER_LINE_DELIVERY
                                     WHERE ORD_LN_PK = ?)
                                   ELSE
                                   (SELECT LPAD(TO_NUMBER(NVL(MAX(DELIVERY_NO), '0')) + 1, '3', '0')
                                    FROM CHGE_SLM_ORDER_DELIVERY
                                WHERE ORD_LN_PK = ?)
                                END),
					            TO_DATE(?,'YYYY-MM-DD'),?,?,
					            ROUND(?,3),?,?,?,
					            ?,?,?,?,
					            ?,1,?,SYSDATE,
					            ?,'12020101',?,?)

		]]>
	</query>

	<query id="CoreOrderChangeManage.GetMaxDeliveryNo" desc="获取最大交货编号">
		<![CDATA[
		SELECT MAX(DELIVERY_NO) 
			FROM 
			SLM_ORDER_LINE_DELIVERY 
			WHERE 
			ORD_LN_PK=? AND VALIDFLAG = '1'		
			
		]]>
	</query>

	<query id="CoreOrderChangeManage.getDeliveryTransitCnt" desc="获取运输线路信息数目">
		<![CDATA[
 SELECT COUNT(1) COUNT
  FROM CHGE_SLM_ORDER_TRANSIT T
 WHERE T.ORD_PK = '#ORD_PK#'
   AND T.ORD_LN_PK = '#ORD_LN_PK#'
   AND T.ORD_LN_DLY_PK = '#ORD_LN_DLY_PK#'
   AND T.INDEX_SEQ = '#INDEX_SEQ#'
		]]>
	</query>

	<query id="CoreOrderChangeManage.insertDeliveryTransit" desc="新增运输线路信息">
		<![CDATA[
INSERT INTO CHGE_SLM_ORDER_TRANSIT
  (ORD_PK,
   ORD_LN_PK,
   ORD_LN_DLY_PK,
   INDEX_SEQ,
   AGENCY_FL,
   TRANSIT_TYP,
   DESTINATION,
   STATION_NO,
   STATION_NM,
   SPCL_LN_NO,
   SPCL_LN_NM,
   PORT_NO,
   PORT_DESC,
   CARRIER_UNIT,
   RECEIVOR,
   TRANSIT_LN_MNY,
   CREATE_NAME,
   CREATE_TIME)
VALUES
  ('#ORD_PK#',
   '#ORD_LN_PK#',
   '#ORD_LN_DLY_PK#',
   '#INDEX_SEQ#',
   '#AGENCY_FL#',
   '#TRANSIT_TYP#',
   '#DESTINATION#',
   '#STATION_NO#',
   '#STATION_NM#',
   '#SPCL_LN_NO#',
   '#SPCL_LN_NM#',
   '#PORT_NO#',
   '#PORT_DESC#',
   '#CARRIER_UNIT#',
   '#RECEIVOR#',
   '#TRANSIT_LN_MNY#',
   '#CREATE_NAME#',
   SYSDATE)
		]]>
	</query>

	<query id="CoreOrderChangeManage.getDeliveryTransitMxIndx" desc="获取运输线路信息最大序号+1">
		<![CDATA[
		SELECT NVL(MAX(to_number(T.INDEX_SEQ)), 0) + 1  MAX_VALUE
		  FROM CHGE_SLM_ORDER_TRANSIT T
		 WHERE T.ORD_PK = '#ORD_PK#'
		   AND T.ORD_LN_PK = '#ORD_LN_PK#'
		   AND T.ORD_LN_DLY_PK = '#ORD_LN_DLY_PK#'
		]]>
	</query>

	<query id="CoreOrderChangeManage.updateDeliveryTransit" desc="修改运输线路信息">
		<![CDATA[
UPDATE CHGE_SLM_ORDER_TRANSIT T
   SET ORD_PK         = '#ORD_PK#',
       ORD_LN_PK      = '#ORD_LN_PK#',
       ORD_LN_DLY_PK  = '#ORD_LN_DLY_PK#',
       INDEX_SEQ      = '#INDEX_SEQ#',
       AGENCY_FL      = '#AGENCY_FL#',
       TRANSIT_TYP    = '#TRANSIT_TYP#',
       DESTINATION    = '#DESTINATION#',
       STATION_NO     = '#STATION_NO#',
       STATION_NM     = '#STATION_NM#',
       SPCL_LN_NO     = '#SPCL_LN_NO#',
       SPCL_LN_NM     = '#SPCL_LN_NM#',
       PORT_NO        = '#PORT_NO#',
       PORT_DESC      = '#PORT_DESC#',
       CARRIER_UNIT   = '#CARRIER_UNIT#',
       RECEIVOR       = '#RECEIVOR#',
       TRANSIT_LN_MNY = '#TRANSIT_LN_MNY#',
       UPDATE_NAME    = '#UPDATE_NAME#',
       UPDATE_TIME    = SYSDATE
 WHERE T.ORD_PK = '#ORD_PK#'
   AND T.ORD_LN_PK = '#ORD_LN_PK#'
   AND T.ORD_LN_DLY_PK = '#ORD_LN_DLY_PK#'
   AND T.INDEX_SEQ = '#INDEX_SEQ#'
		]]>
	</query>

	<query id="CoreOrderChangeManage.deleteDeliveryTransit" desc="删除运输线路信息">
		<![CDATA[
     UPDATE CHGE_SLM_ORDER_TRANSIT T
     SET T.DELETE_NAME = '#DELETE_NAME#',
       T.DELETE_TIME = SYSDATE,
       T.VALIDFLAG   = '0'
     WHERE T.ORD_PK = '#ORD_PK#'
     AND T.ORD_LN_PK = '#ORD_LN_PK#'
     AND T.ORD_LN_DLY_PK = '#ORD_LN_DLY_PK#'
     AND T.INDEX_SEQ = '#INDEX_SEQ#'
		]]>
	</query>

	<query id="CoreOrderChangeManage.generateSlmApply" desc="删除运输线路信息">
		<![CDATA[
     			 INSERT INTO CHGE_SLM_APPLY_M(
        ORDER_NO,
        ORDER_SEQ,
        DELIVERY_NO,
        ORDER_CHGE_NO,
        ORD_PK,
        ORD_LN_PK,
        ORD_LN_DLY_PK,
        DEPARTMENT_CODE,
        DEPARTMENT_DESC,
        UNIT_CODE,
        UNIT_DESC,
        CHGE_TYPE,
        CHGER,
        CHGE_DATE,
        CHGE_VAL,
        CHGE_RSN,
        ACP_DEPARTMENT_CODE,
        ACP_DEPARTMENT_DESC,
        ACP_UNIT_CODE,
        ACP_UNIT_DESC,
        ACCEPTOR,
        CHGE_PATCH,
        MEMO,
        CREATE_NAME,
        CREATE_TIME,
        ORD_LN_PK_AFTER
        )
 VALUES( 
        '#ORDER_NO#',
        '#ORDER_SEQ#',
        '#DELIVERY_NO#',
         (SELECT 'G' || '#TIME#' ||
        LPAD(TO_NUMBER(NVL(MAX(SUBSTR(ORDER_CHGE_NO, 10, 5)), '0')) + 1,
            5,
            '0')
        FROM CHGE_SLM_APPLY_M
        WHERE SUBSTR(ORDER_CHGE_NO, 2, 8) = '#TIME#'
        ),
        '#ORD_PK#',
        '#ORD_LN_PK#',
        '#ORD_LN_DLY_PK#',
        '#DEPARTMENT_CODE#',
        '#DEPARTMENT_DESC#',
        '#UNIT_CODE#',
        '#UNIT_DESC#',
        '#CHGE_TYPE#',
        '#CHGER#',
         SYSDATE,
        '#CHGE_VAL#',
        '#CHGE_RSN#',
        '#ACP_DEPARTMENT_CODE#',
        '#ACP_DEPARTMENT_DESC#',
        '#ACP_UNIT_CODE#',
        '#ACP_UNIT_DESC#',
        '#ACCEPTOR#',
        '#CHGE_PATCH#',
        '#MEMO#',
        '#CREATE_NAME#',
        SYSDATE,
        '#ORD_LN_PK_AFTER#')
		]]>
	</query>

	<query id="CoreOrderChangeManage.getOrderApply" desc="删除运输线路信息">
		<![CDATA[
    			SELECT ORDER_CHGE_NO,
       T.ORD_PK,
       ORD_LN_PK,
       ORD_LN_DLY_PK,
       DEPARTMENT_CODE,
       DEPARTMENT_DESC,
       UNIT_CODE,
       UNIT_DESC,
       CHGE_TYPE,
       CHGER,
       CHGE_DATE,
       CHGE_VAL,
       CHGE_RSN,
       ACP_DEPARTMENT_CODE,
       ACP_DEPARTMENT_DESC,
       ACP_UNIT_CODE,
       ACP_UNIT_DESC,
       ACCEPTOR,
       DEAL_EDATE,
       DECODE(CHGE_STATUS,'L','封锁','W','待审','S','通过','F','失败') CHGE_STATUS,
       CHGE_PATCH,
       MEMO,
       VALIDFLAG,
       CREATE_NAME,
       CREATE_TIME,
       UPDATE_NAME,
       UPDATE_TIME,
       DELETE_NAME,
       DELETE_TIME,
       ORDER_NO,
       ORDER_SEQ,
       DELIVERY_NO,
       APPROVAL_NO
       FROM CHGE_SLM_APPLY_M T
       left JOIN (SELECT ORD_PK,SUPPLY_UNIT from SLM_ORDER_HEAD) H ON T.ORD_PK = H.ORD_PK
       WHERE T.VALIDFLAG = '1'
 	   AND '&'||T.ORDER_NO LIKE '&'||'%'||?||'%'
 	   AND '&'||T.ORDER_CHGE_NO LIKE '&'||'%'||?||'%'
 	   AND (T.APPROVAL_NO LIKE '%'||?||'%' OR T.APPROVAL_NO IS NULL)
    			
		]]>
	</query>

	<query id="CoreOrderChangeManage.getMaxOrdLnDlyPk" desc="删除运输线路信息">
		<![CDATA[
     		SELECT MAX(ORD_LN_DLY_PK) FROM SLM_ORDER_LINE_DELIVERY T
     		WHERE T.ORD_LN_PK = ? AND T.VALIDFLAG = '1'
     	
		]]>
	</query>

	<query id="CoreOrderChangeManage.getMaxOrdLnDlyPkCh" desc="删除运输线路信息">
		<![CDATA[
     		SELECT MAX(ORD_LN_DLY_PK) FROM CHGE_SLM_ORDER_DELIVERY T
     		WHERE T.ORD_LN_PK = ? AND T.VALIDFLAG = '1'
     	
		]]>
	</query>

	<query id="CoreOrderChangeManage.getLineDelivery" desc="生产周期  查询交货行信息">
         <![CDATA[
         SELECT ORD_PK,
       ORD_LN_PK,
       ORD_LN_DLY_PK,
       DELIVERY_NO,
       TO_CHAR(DELVRY_BDATE, 'YYYY-MM-DD') DELVRY_BDATE,
       TO_CHAR(DELVRY_EDATE, 'YYYY-MM-DD') DELVRY_EDATE,
       DELVRY_QTY,
       ORDER_UNIT,
       WGT_ESTMT,
       ENSU_TOTL_LEN,
       RECEIV_NO,
       RECEIV_NM,
       DELVRY_ADDR,
       AGENCY_FL,
       RECEIV_ADDR,
       TRANSIT_PLAN,
       TRANSIT_MNY,
       DELIVERY_STATUS
  FROM CHGE_SLM_ORDER_DELIVERY T
 WHERE T.ORD_LN_PK = ?
   AND T.VALIDFLAG = '1'
         ]]>
	</query>

	<query id="CoreOrderChangeManage.getDeliveryQty" desc="查询发运表变更AND T.DELIVERY_STATUS = '12020301'">
		<![CDATA[
	 		SELECT NVL(SUM(DELVRY_QTY),0) FROM SLM_ORDER_LINE_DELIVERY T
	 		WHERE T.ORD_LN_PK = ? AND T.VALIDFLAG = '1' 
	 		AND (T.DELIVERY_STATUS ='12020301' OR T.DELIVERY_STATUS ='12020302')
	 	]]>
	</query>

	<query id="CoreOrderChangeManage.getDeliveryPrdcycleMeet" desc="查询发运表变更">
		<![CDATA[
	 		 
     SELECT T1.PRDCYC_MEET

  FROM CHGE_SLM_ORDER_DELIVERY  T,
       SLM_ORD_DESIGN_STS_PL_PC T1,
       SLM_ORD_DESIGN_MSC       T2
 WHERE T.ORD_LN_PK = ?
   AND T.ORD_LN_DLY_PK = T1.ORD_LN_DLY_PK
   AND T.ORD_LN_PK = T2.ORD_LN_PK
   AND T2.VALIDFLAG = '1'
   AND T2.DESGIN_KEY = T1.DESGIN_KEY
    

	 
	 	]]>
	</query>

	<query id="CoreOrderChangeManage.getChgeLinePrdcycleMeet" desc="查询发运表变更">
		<![CDATA[
	 		 
     SELECT T1.PRDCYC_MEET

     FROM SLM_ORDER_LINE_DELIVERY  T,
       SLM_ORD_DESIGN_STS_PL_PC T1,
       SLM_ORD_DESIGN_MSC       T2
     WHERE T.ORD_LN_DLY_PK = T1.ORD_LN_DLY_PK(+)
     AND T.ORD_LN_PK = T2.ORD_LN_PK
     AND T2.VALIDFLAG = '1'
     AND T2.DESGIN_KEY = T1.DESGIN_KEY
     AND T.ORD_LN_PK = ?
	 
	 	]]>
	</query>

	<query id="CoreOrderChangeManage.getExistsApplyNo" desc="查询发运表变更">
		<![CDATA[
	 		 
    	SELECT CHGE_STATUS FROM CHGE_SLM_APPLY_M T
    	WHERE T.ORD_LN_PK LIKE  ? ||'%' AND T.VALIDFLAG = '1'
    	--AND INSTR(T.CHGE_TYPE,'交货行')>0
	 		 
	 	]]>
	</query>

	<query id="CoreOrderChangeManage.deleteApplyNo" desc="查询发运表变更">
		<![CDATA[
	 		 
    	DELETE FROM CHGE_SLM_APPLY_M T
    	WHERE T.ORD_LN_PK = ? AND T.VALIDFLAG = '1'
    	AND INSTR(T.CHGE_TYPE,'交货行')>0
	 		 
	 	]]>
	</query>

	<query id="CoreOrderChangeManage.deleteApplyWithStatus" desc="查询发运表变更">
		<![CDATA[
	 		 
    	DELETE FROM CHGE_SLM_APPLY_M T
    	WHERE T.ORD_LN_PK = ? AND T.VALIDFLAG = '1'
    	AND INSTR(T.CHGE_TYPE,'交货行')>0
    	AND T.CHGE_STATUS = ?
	 		 
	 	]]>
	</query>


	<query id="CoreOrderChangeManage.deleteOrderApplyNo" desc="查询发运表变更">
		<![CDATA[
	 		 
    	UPDATE  CHGE_SLM_APPLY_M T
    	SET VALIDFLAG = '0',
    	    DELETE_NAME = ?,
    	    DELETE_TIME = SYSDATE
    	WHERE  T.ORDER_CHGE_NO = ?
    	 AND T.VALIDFLAG = '1'
	 		 
	 	]]>
	</query>

	<query id="CoreOrderChangeManage.commitApplyNo" desc="查询发运表变更">
		<![CDATA[
	 		 
    	UPDATE CHGE_SLM_APPLY_M T
    	SET CHGE_STATUS = 'W'
    	WHERE  T.ORDER_CHGE_NO = ? 
    	AND T.VALIDFLAG = '1'
	 		 
	 	]]>
	</query>

	<query id="CoreOrderChangeManage.selectApplyNoStatus" desc="查询发运表变更">
		<![CDATA[
	 		 
    	SELECT CHGE_STATUS FROM  CHGE_SLM_APPLY_M T
    	 
    	WHERE  T.ORDER_CHGE_NO = ? 
    	AND T.VALIDFLAG = '1'
	 		 
	 	]]>
	</query>

	<query id="CoreOrderChangeManage.selectOrderLineLockStatus" desc="查询发运表变更">
		<![CDATA[
	 	SELECT ORD_PK,
       ORD_LN_PK,
       ORDER_SEQ,
       CUST_ALPHA_NO,
       PSC,
       PSC_DESC,
       MSC,
       MSC_DESC,
       MSC_STYLE,
       USE_CODE,
       USE_DESC,
       PRD_CLS,
       PRODUCCODE,
       PRODUCNAME,
       STD_CODE,
       STD_NAME,
       STEELCODE,
       STEELNAME,
       STD_STYLE,
       STD_STYLE_DESC,
       ORDER_SPEC_CODE,
       ORDER_SPEC_DESC,
       SPEC_CODE,
       SPEC_NAME,
       DIMATER,
       HEIGHT,
       MODEL_CODE,
       MODEL_DESC,
       LEN_NO,
       LEN_DESC,
       LEN_UNIT,
       LEN_MIN,
       LEN_MAX,
       SHRT_LEN_RATO,
       SHORTEST,
       LONG_LEN_RATO,
       LONGEST,
       SHRT_STOVE,
       AVG_LEN_MIN,
       DIFRNC_LEN_MAX,
       ENDLEN_SPECSTD,
       SIGL_LEN,
       ORDER_UNIT,
       ORDER_QTY,
       ORD_ENSU_TOTL_LEN,
       PRDCT_WGT,
       DELVRY_RANGE_TPE,
       DELVRY_RANGE_MIN,
       DELVRY_RANGE_MAX,
       FINAL_USER,
       FINAL_USER_DESC,
       OUTS_BILLET_FL,
       OUTS_STL_PIPE_FL,
       ASSEL_FL,
       PRODUCER_FL,
       PRDCR_NO,
       PRDCR_DESC,
       MPS_FL,
       MPS_NO,
       MPS_DESC,
       DELVRY_BDATE,
       DELVRY_EDATE,
       DELVRY_DESC,
       TRANS_DESC,
       ADD_ASK_NO,
       ORDER_ADD_DESC,
       ORDER_SPECIAL_FL,
       ORDER_SPECIAL_HEAD,
       ORDER_SPECIAL_PATH,
       ORDER_SPECIAL_DESC,
       ZBS,
       ORDER_PRICE,
       TRANS_PRICE,
       TEST_ID,
       TEST_PRICE,
       OUT_PRICE,
       BALNCE_PRICE,
       BE_ORDER_LN_STATUS,
       BE_OBJ_STS_OP,
       ORDER_LN_STATUS,
       OBJ_STS_OP,
       MEMO,
       VALIDFLAG,
       CREATE_NAME,
       CREATE_TIME,
       UPDATE_NAME,
       UPDATE_TIME,
       DELETE_NAME,
       DELETE_TIME,
       ORD_LN_PK_OLD,
       ISLOCK  IS_LOCK

  FROM SLM_ORDER_LINE T
 WHERE T.ORD_LN_PK = ?
   AND T.VALIDFLAG = '1'

	 		 
	 	]]>
	</query>

	<query id="CoreOrderChangeManage.lockOrderLineStatus" desc="查询发运表变更">
		<![CDATA[
	 		 
    	UPDATE  SLM_ORDER_LINE T
    	SET  ISLOCK = ?
    	WHERE  T.ORD_LN_PK = ? 
    	 
	 	]]>
	</query>

	<query id="CoreOrderChangeManage.moveDataToHis" desc="查询发运表变更">
		<![CDATA[
	 		 INSERT INTO CHGE_SLM_ORDER_DELIVERY_H
  (ORD_PK,
   ORD_LN_PK,
   ORD_LN_DLY_PK,
   DELIVERY_NO,
   DELVRY_BDATE,
   DELVRY_EDATE,
   DELVRY_QTY,
   ORDER_UNIT,
   WGT_ESTMT,
   ENSU_TOTL_LEN,
   RECEIV_NO,
   RECEIV_NM,
   DELVRY_ADDR,
   AGENCY_FL,
   RECEIV_ADDR,
   TRANSIT_TYP,
   TRANSIT_PLAN,
   TRANSIT_MNY,
   BE_DELIVERY_STATUS,
   BE_OBJ_STS_OP,
   DELIVERY_STATUS,
   OBJ_STS_OP,
   VALIDFLAG,
   CREATE_NAME,
   CREATE_TIME,
   UPDATE_NAME,
   UPDATE_TIME,
   DELETE_NAME,
   DELETE_TIME,
   EXTRA_FLAG,
   IS_ADD)
 
     SELECT ORD_PK,
       ORD_LN_PK,
       ORD_LN_DLY_PK,
       DELIVERY_NO,
       DELVRY_BDATE,
       DELVRY_EDATE,
       DELVRY_QTY,
       ORDER_UNIT,
       WGT_ESTMT,
       ENSU_TOTL_LEN,
       RECEIV_NO,
       RECEIV_NM,
       DELVRY_ADDR,
       AGENCY_FL,
       RECEIV_ADDR,
       TRANSIT_TYP,
       TRANSIT_PLAN,
       TRANSIT_MNY,
       BE_DELIVERY_STATUS,
       BE_OBJ_STS_OP,
       DELIVERY_STATUS,
       OBJ_STS_OP,
       VALIDFLAG,
       CREATE_NAME,
       CREATE_TIME,
       UPDATE_NAME,
       UPDATE_TIME,
       DELETE_NAME,
       DELETE_TIME,
       EXTRA_FLAG,
       IS_ADD

  FROM SLM_ORDER_LINE_DELIVERY T
  WHERE T.ORD_PK= ?
  AND T.ORD_LN_PK = ? 
  AND T.VALIDFLAG = '1'
  AND T.DELIVERY_STATUS ='12020301'
  	 
	 	]]>
	</query>

	<query id="CoreOrderChangeManage.chDataMoveToOriginal" desc="变更数据移到原表">
		<![CDATA[
	 		INSERT INTO SLM_ORDER_LINE_DELIVERY
  (ORD_PK,
   ORD_LN_PK,
   ORD_LN_DLY_PK,
   DELIVERY_NO,
   DELVRY_BDATE,
   DELVRY_EDATE,
   DELVRY_QTY,
   ORDER_UNIT,
   WGT_ESTMT,
   ENSU_TOTL_LEN,
   RECEIV_NO,
   RECEIV_NM,
   DELVRY_ADDR,
   AGENCY_FL,
   RECEIV_ADDR,
   TRANSIT_TYP,
   TRANSIT_PLAN,
   TRANSIT_MNY,
   BE_DELIVERY_STATUS,
   BE_OBJ_STS_OP,
   DELIVERY_STATUS,
   OBJ_STS_OP,
   VALIDFLAG,
   CREATE_NAME,
   CREATE_TIME,
   UPDATE_NAME,
   UPDATE_TIME,
   DELETE_NAME,
   DELETE_TIME,
   EXTRA_FLAG,
   IS_ADD)

  SELECT ORD_PK,
         ORD_LN_PK,
         ORD_LN_DLY_PK,
         DELIVERY_NO,
         DELVRY_BDATE,
         DELVRY_EDATE,
         DELVRY_QTY,
         ORDER_UNIT,
         WGT_ESTMT,
         ENSU_TOTL_LEN,
         RECEIV_NO,
         RECEIV_NM,
         DELVRY_ADDR,
         AGENCY_FL,
         RECEIV_ADDR,
         TRANSIT_TYP,
         TRANSIT_PLAN,
         TRANSIT_MNY,
         BE_DELIVERY_STATUS,
         BE_OBJ_STS_OP,
         DELIVERY_STATUS,
         OBJ_STS_OP,
         VALIDFLAG,
         CREATE_NAME,
         CREATE_TIME,
         UPDATE_NAME,
         UPDATE_TIME,
         DELETE_NAME,
         DELETE_TIME,
         EXTRA_FLAG,
         IS_ADD
    FROM CHGE_SLM_ORDER_DELIVERY T
   WHERE T.ORD_PK = ?
     AND T.ORD_LN_PK = ?
     AND T.VALIDFLAG = '1'
	 		
	 	]]>
	</query>

	<query id="CoreOrderChangeManage.deleteOriginalDataWithCh" desc="删除原表中变更了的数据">
		<![CDATA[
	 	DELETE SLM_ORDER_LINE_DELIVERY T
        WHERE T.ORD_PK = ?
        AND T.ORD_LN_PK = ?
        AND T.DELIVERY_STATUS = '12020301'
	 		  	 
	 	]]>
	</query>

	<query id="CoreOrderChangeManage.deleteChangeData" desc="删除变更数据">
		<![CDATA[
	 DELETE CHGE_SLM_ORDER_DELIVERY T
     WHERE T.ORD_PK = ?
     AND T.ORD_LN_PK = ?

	 		  	 
	 	]]>
	</query>

	<query id="CoreOrderChangeManage.UpdateChangedDataDlyStatus"
		desc="修改修改后的交货行的状态">
		<![CDATA[
	 UPDATE SLM_ORDER_LINE_DELIVERY T
     SET T.DELIVERY_STATUS = '12020301'
     WHERE T.ORD_PK = ?
     AND T.ORD_LN_PK = ?
     AND T.VALIDFLAG = '1'
     AND T.DELIVERY_STATUS < '12020301'
	  	 
	 	]]>
	</query>

	<query id="CoreOrderChangeManage.queryChangedDlyData" desc="查询交货量重量估算保总长">
		<![CDATA[
	 SELECT
	 '交货量:'|| SUM(T.DELVRY_QTY)||';交货日期:'|| max(TO_CHAR(DELVRY_EDATE,'YYYY-MM-DD')) || ';收货单位:' || max(RECEIV_NM) || ';交货地点:' || max(DELVRY_ADDR),
	  SUM(T.DELVRY_QTY) DELVRY_QTY,
	  SUM(T.WGT_ESTMT) WGT_ESTMT,
	  SUM(T.ENSU_TOTL_LEN) ENSU_TOTL_LEN
	 FROM  SLM_ORDER_LINE_DELIVERY T
     WHERE T.ORD_PK = ?
     AND T.ORD_LN_PK = ?
     AND T.VALIDFLAG = '1'
     AND T.IS_ADD !='1'
 
	 	]]>
	</query>

	<query id="CoreOrderChangeManage.updateChangedOrderLineData"
		desc="修改修改后的交货行的状态">
		<![CDATA[
	  UPDATE SLM_ORDER_LINE  T
	  SET T.ORDER_QTY = ?,
	      T.ORD_ENSU_TOTL_LEN = ?,
	      T.PRDCT_WGT   = ?
	  WHERE T.ORD_PK = ?
	  AND T.ORD_LN_PK = ?
	  AND T.VALIDFLAG = '1'
     
 
	 	]]>
	</query>

	<query id="CoreOrderChangeManage.UpdateChangeApplyStatus" desc="修改修改后变更单的状态">
		<![CDATA[
	 UPDATE CHGE_SLM_APPLY_M
   SET ACP_DEPARTMENT_CODE = ?,
       ACP_DEPARTMENT_DESC = ?,
       ACP_UNIT_CODE       = ?,
       ACP_UNIT_DESC       = ?,
       ACCEPTOR            = ?,
       DEAL_EDATE          = SYSDATE,
       CHGE_STATUS         = ?,
       UPDATE_NAME         = ?,
       UPDATE_TIME         = SYSDATE

  WHERE ORDER_CHGE_NO = ?
   AND VALIDFLAG = '1'

	 
	 	]]>
	</query>

	<query id="CoreOrderChangeManage.moveTransitDataToHis" desc="发运信息转到历史表">
		<![CDATA[
	 				INSERT INTO CHGE_SLM_ORDER_TRANSIT_H
  (ORD_PK,
   ORD_LN_PK,
   ORD_LN_DLY_PK,
   INDEX_SEQ,
   AGENCY_FL,
   TRANSIT_TYP,
   DESTINATION,
   STATION_NO,
   STATION_NM,
   SPCL_LN_NO,
   SPCL_LN_NM,
   PORT_NO,
   PORT_DESC,
   CARRIER_UNIT,
   RECEIVOR,
   TRANSIT_LN_MNY,
   VALIDFLAG,
   CREATE_NAME,
   CREATE_TIME,
   UPDATE_NAME,
   UPDATE_TIME,
   DELETE_NAME,
   DELETE_TIME,
   LV_FACTY_TYP)
   
  SELECT ORD_PK,
         ORD_LN_PK,
         ORD_LN_DLY_PK,
         INDEX_SEQ,
         AGENCY_FL,
         TRANSIT_TYP,
         DESTINATION,
         STATION_NO,
         STATION_NM,
         SPCL_LN_NO,
         SPCL_LN_NM,
         PORT_NO,
         PORT_DESC,
         CARRIER_UNIT,
         RECEIVOR,
         TRANSIT_LN_MNY,
         VALIDFLAG,
         CREATE_NAME,
         CREATE_TIME,
         UPDATE_NAME,
         UPDATE_TIME,
         DELETE_NAME,
         DELETE_TIME,
         LV_FACTY_TYP
    FROM SLM_ORDER_DELIVERY_TRANSIT T
   WHERE T.ORD_PK = ?
     AND T.ORD_LN_PK = ?
     AND T.VALIDFLAG = '1'
	 				
	  	 
	 	]]>
	</query>

	<query id="CoreOrderChangeManage.chTransitDataToOriginal" desc="发运信息转到历史表">
		<![CDATA[
	 		INSERT INTO SLM_ORDER_DELIVERY_TRANSIT
  (ORD_PK,
   ORD_LN_PK,
   ORD_LN_DLY_PK,
   INDEX_SEQ,
   AGENCY_FL,
   TRANSIT_TYP,
   DESTINATION,
   STATION_NO,
   STATION_NM,
   SPCL_LN_NO,
   SPCL_LN_NM,
   PORT_NO,
   PORT_DESC,
   CARRIER_UNIT,
   RECEIVOR,
   TRANSIT_LN_MNY,
   VALIDFLAG,
   CREATE_NAME,
   CREATE_TIME,
   UPDATE_NAME,
   UPDATE_TIME,
   DELETE_NAME,
   DELETE_TIME,
   LV_FACTY_TYP)

  SELECT ORD_PK,
         ORD_LN_PK,
         ORD_LN_DLY_PK,
         INDEX_SEQ,
         AGENCY_FL,
         TRANSIT_TYP,
         DESTINATION,
         STATION_NO,
         STATION_NM,
         SPCL_LN_NO,
         SPCL_LN_NM,
         PORT_NO,
         PORT_DESC,
         CARRIER_UNIT,
         RECEIVOR,
         TRANSIT_LN_MNY,
         VALIDFLAG,
         CREATE_NAME,
         CREATE_TIME,
         UPDATE_NAME,
         UPDATE_TIME,
         DELETE_NAME,
         DELETE_TIME,
         LV_FACTY_TYP
    FROM CHGE_SLM_ORDER_TRANSIT T
   WHERE T.ORD_PK = ?
     AND T.ORD_LN_PK = ?
     AND T.VALIDFLAG = '1'
	 		
	  	 
	 	]]>
	</query>

	<query id="CoreOrderChangeManage.deleteChTransitData" desc="发运信息转到历史表">
		<![CDATA[
	 	DELETE CHGE_SLM_ORDER_TRANSIT
   WHERE ORD_PK = ?
   AND ORD_LN_PK = ?
	 	
	  	 
	 	]]>
	</query>

	<query id="CoreOrderChangeManage.deleteOriginalTransitData" desc="发运信息转到历史表">
		<![CDATA[
	 	DELETE SLM_ORDER_DELIVERY_TRANSIT
   WHERE ORD_PK = ?
   AND ORD_LN_PK = ?
	 	
	  	 
	 	]]>
	</query>

	<query id="CoreOrderChangeManage.GetSlmApplyEntity" desc="获取变更单实体对象">
		<![CDATA[
	    
	 	SELECT ORDER_CHGE_NO,
       ORD_PK,
       ORD_LN_PK,
       ORD_LN_DLY_PK,
       DEPARTMENT_CODE,
       DEPARTMENT_DESC,
       UNIT_CODE,
       UNIT_DESC,
       CHGE_TYPE,
       CHGER,
       CHGE_DATE,
       CHGE_VAL,
       CHGE_RSN,
       ACP_DEPARTMENT_CODE,
       ACP_DEPARTMENT_DESC,
       ACP_UNIT_CODE,
       ACP_UNIT_DESC,
       ACCEPTOR,
       DEAL_EDATE,
       CHGE_STATUS,
       CHGE_PATCH,
       MEMO,
       VALIDFLAG,
       CREATE_NAME,
       CREATE_TIME,
       UPDATE_NAME,
       UPDATE_TIME,
       DELETE_NAME,
       DELETE_TIME,
       ORDER_NO,
       ORDER_SEQ,
       DELIVERY_NO,
       APPROVAL_NO
  FROM CHGE_SLM_APPLY_M T
 WHERE T.ORD_LN_PK = ?
   AND T.VALIDFLAG = '1'
   AND T.CHGE_STATUS IN ('L', 'W')
  
	  	 
	 	]]>
	</query>

	<!--合同变更区域的SQL语句 -->

	<query id="CoreOrderChangeManage.chgeOrderHeadQuery" desc="发运信息转到历史表">
		<![CDATA[
	 		SELECT MANAG_NO,
       ORDER_NO,
       CUSTM_ORDER_NO,
       ORDER_TYP,
       ORDER_TYP_DESC,
       PROTCL_NO,
       CUSTOMER_NO,
       CUSTOMER_NM,
       (SELECT BASENAME FROM COM_BASE_INFO WHERE BASECODE = SUPPLY_UNIT) SUPPLY_UNIT_NM,
       (SELECT BASENAME FROM COM_BASE_INFO WHERE BASECODE = PRICE_FL) PRICE_FL_NM,
       (SELECT BASENAME FROM COM_BASE_INFO WHERE BASECODE = CURRENCY) CURRENCY_NM,
       STLMT_UNIT_NO,
       STLMT_UNIT_NM,
       (SELECT BASENAME FROM COM_BASE_INFO WHERE BASECODE = FST_DRAWEE_UNIT) FST_DRAWEE_UNIT_NM,
       LEGAL_PSN,
       AGENT,
       ADDRESS,
       ZIP_CODE,
       BANK,
       ACCOUNT,
       TAX_ID,
       PHONE,
       FAX,
       ORDER_WGT,
       ORDER_MNY_TAX,
       ORDER_MNY_NTAX,
       MNY_ASK_DESC,
       SIGN_PERSON,
       TO_CHAR(SIGN_DATE, 'YYYY-MM-DD') SIGN_DATE,
       ORDER_BDATE,
       ORDER_EDATE,
       ORDER_SCAN_NO,
       CUSTOMER_MODEL_FL,
       ORDER_MODEL_NO,
       SALE_ORG,
       SALE_ORG_DESC,
       SALE_AREA_NO,
       SALE_AREA_DESC,
       MEMO,
       ORDER_STS,
       (SELECT BASENAME
          FROM COM_BASE_INFO
         WHERE BASECODE = ORDER_STS
           AND VALIDFLAG = '1') ORDER_STS_DESC,
       APPROVAL_MAN,
       APPROVAL_TIME,
       DECODE(VALIDFLAG,'1','TRUE','FALSE') VALIDFLAG,
       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,
       DELETE_NAME,
       TO_CHAR(DELETE_TIME, 'YYYY-MM-DD HH24:MI:SS') DELETE_TIME,
       ORDER_YEAR,
       EFFECT_TIME,
       EFFECT_MAN,
       CLOSE_TIME,
       CLOSE_MAN,
       (SELECT BASENAME FROM COM_BASE_INFO WHERE BASECODE = MNY_ASK_TYP) MNY_ASK_TYP_NM,
       SIGN_ADDRESS,
       SUPPLY_UNIT,
       PRICE_FL,
       CURRENCY,
       FST_DRAWEE_UNIT,
       MNY_ASK_TYP,
       NVL(ORDER_MODEL_DESC, ' ') ORDER_MODEL_DESC,
       ORD_PK,
       CREATE_DEPT,
       MARKET_SYS,
       MARKET_SYS_DESC,
       ABRVITION,
       REVW_RPT_NO,
       DECODE(CONTAIN_TAX,'1','是','否') CONTAIN_TAX_DESC,
       DECODE(ORDER_ARCHIVE,'1','是','否') ORDER_ARCHIVE,
       (SELECT BASENAME FROM COM_BASE_INFO WHERE BASECODE= TRADE_TYPE) TRADE_TYPE ,
       (SELECT BASENAME FROM COM_BASE_INFO WHERE BASECODE= ORDER_CLASSIFY) ORDER_CLASSIFY ,
       BUSINESS_TYPE
   FROM SLM_ORDER_HEAD
   WHERE ORDER_NO || '&' LIKE '%' || ? || '%'
   AND CREATE_TIME >= TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS')
   AND CREATE_TIME <= TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS')
   AND VALIDFLAG IN (1, ?)
   AND (SALE_ORG = ? or 1=1 )
   AND (CREATE_DEPT = ? or 1=1 )
   AND ORDER_TYP  <> '120102'
   AND ORDER_TYP  <> '120105'

	 	]]>
	</query>

	<query id="CoreOrderChangeManage.GetOperateOrderLine" desc="发运信息转到历史表">
		<![CDATA[
	 	 SELECT ORD_PK,
       ORD_LN_PK,
       ORDER_SEQ,
       CUST_ALPHA_NO,
       PSC,
       PSC_DESC,
       MSC,
       MSC_DESC,
       MSC_STYLE,
       USE_CODE,
       USE_DESC,
       PRD_CLS,
       PRODUCCODE,
       PRODUCNAME,
       STD_CODE,
       STD_NAME,
       STEELCODE,
       STEELNAME,
       STD_STYLE,
       STD_STYLE_DESC,
       ORDER_SPEC_CODE,
       ORDER_SPEC_DESC,
       SPEC_CODE,
       SPEC_NAME,
       DIMATER,
       HEIGHT,
       MODEL_CODE,
       MODEL_DESC,
       LEN_NO,
       LEN_DESC,
       LEN_UNIT,
       LEN_MIN,
       LEN_MAX,
       SHRT_LEN_RATO,
       SHORTEST,
       LONG_LEN_RATO,
       LONGEST,
       SHRT_STOVE,
       AVG_LEN_MIN,
       DIFRNC_LEN_MAX,
       ENDLEN_SPECSTD,
       SIGL_LEN,
       ORDER_UNIT,
       ORDER_QTY,
       ORD_ENSU_TOTL_LEN,
       PRDCT_WGT,
       DELVRY_RANGE_TPE,
       DELVRY_RANGE_MIN,
       DELVRY_RANGE_MAX,
       FINAL_USER,
       FINAL_USER_DESC,
       OUTS_BILLET_FL,
       OUTS_STL_PIPE_FL,
       ASSEL_FL,
       PRODUCER_FL,
       PRDCR_NO,
       PRDCR_DESC,
       MPS_FL,
       MPS_NO,
       MPS_DESC,
       DELVRY_BDATE,
       DELVRY_EDATE,
       DELVRY_DESC,
       TRANS_DESC,
       ADD_ASK_NO,
       ORDER_ADD_DESC,
       ORDER_SPECIAL_FL,
       ORDER_SPECIAL_HEAD,
       ORDER_SPECIAL_PATH,
       ORDER_SPECIAL_DESC,
       ZBS,
       ORDER_PRICE,
       TRANS_PRICE,
       TEST_ID,
       TEST_PRICE,
       OUT_PRICE,
       BALNCE_PRICE,
       BE_ORDER_LN_STATUS,
       BE_OBJ_STS_OP,
       ORDER_LN_STATUS,
       OBJ_STS_OP,
       MEMO,
       VALIDFLAG,
       CREATE_NAME,
       CREATE_TIME,
       UPDATE_NAME,
       UPDATE_TIME,
       DELETE_NAME,
       DELETE_TIME,
       ORD_LN_PK_OLD,
       ISLOCK IS_LOCK,
       CUST_ALPHA_NO2,
       ORDER_CHGE_NO,
       CHGE_ORD_LN_PK
  FROM SLM_ORDER_LINE T
 WHERE T.ORD_LN_PK = ?
   AND T.VALIDFLAG = '1'
	 	 
	  	 
	 	]]>
	</query>

	<query id="CoreOrderChangeManage.gernaerateChgeCode" desc="生成变更单号">
	<![CDATA[
	
	  SELECT 'G' || ? ||
        LPAD(TO_NUMBER(NVL(MAX(SUBSTR(ORDER_CHGE_NO, 10, 5)), '0')) + 1,
            5,
            '0')
        FROM CHGE_SLM_APPLY_M
        WHERE SUBSTR(ORDER_CHGE_NO, 2, 8) = ?
	
	]]>

	</query>

	<query id="CoreOrderChangeManage.InsertChgeSlmApplyM" desc="插入变更单信息">
	<![CDATA[
			  INSERT INTO CHGE_SLM_APPLY_M(
        ORD_LN_PK_AFTER,
        ORDER_NO,
        ORDER_SEQ,
        DELIVERY_NO,
        ORDER_CHGE_NO,
        ORD_PK,
        ORD_LN_PK,
        ORD_LN_DLY_PK,
        DEPARTMENT_CODE,
        DEPARTMENT_DESC,
        UNIT_CODE,
        UNIT_DESC,
        CHGE_TYPE,
        CHGER,
        CHGE_DATE,
        CHGE_VAL,
        CHGE_RSN,
        ACP_DEPARTMENT_CODE,
        ACP_DEPARTMENT_DESC,
        ACP_UNIT_CODE,
        ACP_UNIT_DESC,
        ACCEPTOR,
        CHGE_PATCH,
        CREATE_NAME,
        CREATE_TIME,
        MEMO
       )
 VALUES( 
        '#ORD_LN_PK_AFTER#',
        '#ORDER_NO#',
        '#ORDER_SEQ#',
        '#DELIVERY_NO#',
        '#ORDER_CHGE_NO#',
        '#ORD_PK#',
        '#ORD_LN_PK#',
        '#ORD_LN_DLY_PK#',
        '#DEPARTMENT_CODE#',
        '#DEPARTMENT_DESC#',
        '#UNIT_CODE#',
        '#UNIT_DESC#',
        '#CHGE_TYPE#',
        '#CHGER#',
         SYSDATE,
        '#CHGE_VAL#',
        '#CHGE_RSN#',
        '#ACP_DEPARTMENT_CODE#',
        '#ACP_DEPARTMENT_DESC#',
        '#ACP_UNIT_CODE#',
        '#ACP_UNIT_DESC#',
        '#ACCEPTOR#',
        '#CHGE_PATCH#',
        '#CREATE_NAME#',
         SYSDATE,
         '#MEMO#'
     )
	   
	
	]]>
	</query>

	<query id="CoreOrderChangeManage.UpdateChgeOrderLineWithDelete"
		desc="更改变更的合同行--删除">
	<![CDATA[
	  UPDATE SLM_ORDER_LINE
    SET VALIDFLAG = '0', ISLOCK = ?, ORDER_CHGE_NO = ?, CHGE_ORD_LN_PK = ?
    WHERE ORD_LN_PK = ? AND VALIDFLAG = '1'
	  
	]]>
	</query>

	<query id="CoreOrderChangeManage.getApplyInfo" desc="获取变更单的信息">
	<![CDATA[
	   SELECT ORDER_CHGE_NO,
       ORD_PK,
       ORD_LN_PK,
       ORD_LN_DLY_PK,
       DEPARTMENT_CODE,
       DEPARTMENT_DESC,
       UNIT_CODE,
       UNIT_DESC,
       CHGE_TYPE,
       CHGER,
       CHGE_DATE,
       CHGE_VAL,
       CHGE_RSN,
       ACP_DEPARTMENT_CODE,
       ACP_DEPARTMENT_DESC,
       ACP_UNIT_CODE,
       ACP_UNIT_DESC,
       ACCEPTOR,
       DEAL_EDATE,
       CHGE_STATUS,
       CHGE_PATCH,
       MEMO,
       VALIDFLAG,
       CREATE_NAME,
       CREATE_TIME,
       UPDATE_NAME,
       UPDATE_TIME,
       DELETE_NAME,
       DELETE_TIME,
       ORDER_NO,
       ORDER_SEQ,
       DELIVERY_NO,
       ORD_LN_PK_AFTER
  FROM CHGE_SLM_APPLY_M T
 WHERE T.ORDER_CHGE_NO = '#ORDER_CHGE_NO#'
   AND T.VALIDFLAG = '1'
	   
	  
	]]>
	</query>

	<query id="CoreOrderChangeManage.chgeCancelDeleteOrderLine" desc="取消变更单内容">
	<![CDATA[
	  UPDATE SLM_ORDER_LINE
    SET VALIDFLAG = '1', ISLOCK = ?, CHGE_ORD_LN_PK = ?
    WHERE ORD_LN_PK = ?  
	  
	]]>
	</query>

	<query id="CoreOrderChangeManage.chgeDeleteOrderDlyLine" desc="取消变更单内容">
	<![CDATA[
	  UPDATE  SLM_ORDER_LINE_DELIVERY  T
	  SET T.VALIDFLAG = '0' ,
	      T.DELETE_NAME = ?,
	      T.DELETE_TIME = SYSDATE
	  WHERE T.ORD_LN_PK = ?
	  
	  
	]]>
	</query>

	<query id="CoreOrderChangeManage.chgeDeleteOrderDlyTransitLine"
		desc="取消变更单内容">
	<![CDATA[
	  UPDATE  SLM_ORDER_DELIVERY_TRANSIT  T
	  SET T.VALIDFLAG = '0' ,
	      T.DELETE_NAME = ?,
	      T.DELETE_TIME = SYSDATE
	  WHERE T.ORD_LN_PK = ?
	  
	]]>
	</query>

	<query id="CoreOrderChangeManage.doAddLine" desc="合同行新增">
		<![CDATA[
				 INSERT INTO SLM_ORDER_LINE(
        ORDER_CHGE_NO,
        CHGE_ORD_LN_PK,
        ORD_PK,
        ORD_LN_PK,
        ORDER_SEQ,
        CUST_ALPHA_NO,
        PSC,
        PSC_DESC,
        MSC,
        MSC_DESC,
        MSC_STYLE,
        USE_CODE,
        USE_DESC,
        PRD_CLS,
        PRODUCCODE,
        PRODUCNAME,
        STD_CODE,
        STD_NAME,
        STEELCODE,
        STEELNAME,
        STD_STYLE,
        STD_STYLE_DESC,
        ORDER_SPEC_CODE,
        ORDER_SPEC_DESC,
        SPEC_CODE,
        SPEC_NAME,
        DIMATER,
        HEIGHT,
        MODEL_CODE,
        MODEL_DESC,
        LEN_NO,
        LEN_DESC,
        LEN_UNIT,
        LEN_MIN,
        LEN_MAX,
        SHRT_LEN_RATO,
        SHORTEST,
        LONG_LEN_RATO,
        LONGEST,
        SHRT_STOVE,
        AVG_LEN_MIN,
        DIFRNC_LEN_MAX,
        ENDLEN_SPECSTD,
        SIGL_LEN,
        ORDER_UNIT,
        ORDER_QTY,
        ORD_ENSU_TOTL_LEN,
        PRDCT_WGT,
        DELVRY_RANGE_TPE,
        DELVRY_RANGE_MIN,
        DELVRY_RANGE_MAX,
        FINAL_USER,
        FINAL_USER_DESC,
        OUTS_BILLET_FL,
        OUTS_STL_PIPE_FL,
        ASSEL_FL,
        PRODUCER_FL,
        PRDCR_NO,
        PRDCR_DESC,
        MPS_FL,
        MPS_NO,
        MPS_DESC,
        DELVRY_BDATE,
        DELVRY_EDATE,
        DELVRY_DESC,
        TRANS_DESC,
        ADD_ASK_NO,
        ORDER_ADD_DESC,
        ORDER_SPECIAL_FL,
        ORDER_SPECIAL_HEAD,
        ORDER_SPECIAL_PATH,
        ORDER_SPECIAL_DESC,
        ZBS,
        ORDER_PRICE,
        TRANS_PRICE,
        TEST_ID,
        TEST_PRICE,
        OUT_PRICE,
        BALNCE_PRICE,
        BE_ORDER_LN_STATUS,
        BE_OBJ_STS_OP,
        ORDER_LN_STATUS,
        MEMO,
        CREATE_NAME,
        CREATE_TIME,
        ISLOCK,
        AW,
        MAN_INSPECTION,
        QUALITY_USER ,
        QUALITY_USER_DESC,
        OUTPUT_STD_NO,
        PROJECT_NO
        
        )
 VALUES( 
        '#ORDER_CHGE_NO#',
        '#CHGE_ORD_LN_PK#',
        '#ORD_PK#',
        '#ORD_LN_PK#',
        '#ORDER_SEQ#',
        '#CUST_ALPHA_NO#',
        '#PSC#',
        '#PSC_DESC#',
        '#MSC#',
        '#MSC_DESC#',
        '#MSC_STYLE#',
        '#USE_CODE#',
        '#USE_DESC#',
        '#PRD_CLS#',
        '#PRODUCCODE#',
        '#PRODUCNAME#',
        '#STD_CODE#',
        '#STD_NAME#',
        '#STEELCODE#',
        '#STEELNAME#',
        '#STD_STYLE#',
        '#STD_STYLE_DESC#',
        '#ORDER_SPEC_CODE#',
        '#ORDER_SPEC_DESC#',
        '#SPEC_CODE#',
        '#SPEC_NAME#',
        '#DIMATER#',
        '#HEIGHT#',
        '#MODEL_CODE#',
        '#MODEL_DESC#',
        '#LEN_NO#',
        '#LEN_DESC#',
        '#LEN_UNIT#',
        '#LEN_MIN#',
        '#LEN_MAX#',
        '#SHRT_LEN_RATO#',
        '#SHORTEST#',
        '#LONG_LEN_RATO#',
        '#LONGEST#',
        '#SHRT_STOVE#',
        '#AVG_LEN_MIN#',
        '#DIFRNC_LEN_MAX#',
        '#ENDLEN_SPECSTD#',
        '#SIGL_LEN#',
        '#ORDER_UNIT#',
        '#ORDER_QTY#',
        '#ORD_ENSU_TOTL_LEN#',
        '#PRDCT_WGT#',
        '#DELVRY_RANGE_TPE#',
        '#DELVRY_RANGE_MIN#',
        '#DELVRY_RANGE_MAX#',
        '#FINAL_USER#',
        '#FINAL_USER_DESC#',
        '#OUTS_BILLET_FL#',
        '#OUTS_STL_PIPE_FL#',
        '#ASSEL_FL#',
        '#PRODUCER_FL#',
        '#PRDCR_NO#',
        '#PRDCR_DESC#',
        '#MPS_FL#',
        '#MPS_NO#',
        '#MPS_DESC#',
        '#DELVRY_BDATE#',
        '#DELVRY_EDATE#',
        '#DELVRY_DESC#',
        '#TRANS_DESC#',
        '#ADD_ASK_NO#',
        '#ORDER_ADD_DESC#',
        '#ORDER_SPECIAL_FL#',
        '#ORDER_SPECIAL_HEAD#',
        '#ORDER_SPECIAL_PATH#',
        '#ORDER_SPECIAL_DESC#',
        '#ZBS#',
        '#ORDER_PRICE#',
        '#TRANS_PRICE#',
        '#TEST_ID#',
        '#TEST_PRICE#',
        '#OUT_PRICE#',
        '#BALNCE_PRICE#',
        '#BE_ORDER_LN_STATUS#',
        '#BE_OBJ_STS_OP#',
        '#ORDER_LN_STATUS#',
        '#MEMO#',
        '#CREATE_NAME#',
         SYSDATE,
        '#ISLOCK#',
        '#AW#',
        '#MAN_INSPECTION#',
        '#QUALITY_USER#' ,
        '#QUALITY_USER_DESC#',
        '#OUTPUT_STD_NO#',
        '#PROJECT_NO#')
		]]>
	</query>

	<query id="CoreOrderChangeManage.doAddLineUpdate" desc="修改导致的新增">
		<![CDATA[
				 INSERT INTO SLM_ORDER_LINE(
        ORDER_CHGE_NO,
        CHGE_ORD_LN_PK,
        ORD_PK,
        ORD_LN_PK,
        ORDER_SEQ,
        CUST_ALPHA_NO,
        PSC,
        PSC_DESC,
        MSC,
        MSC_DESC,
        MSC_STYLE,
        USE_CODE,
        USE_DESC,
        PRD_CLS,
        PRODUCCODE,
        PRODUCNAME,
        STD_CODE,
        STD_NAME,
        STEELCODE,
        STEELNAME,
        STD_STYLE,
        STD_STYLE_DESC,
        ORDER_SPEC_CODE,
        ORDER_SPEC_DESC,
        SPEC_CODE,
        SPEC_NAME,
        DIMATER,
        HEIGHT,
        MODEL_CODE,
        MODEL_DESC,
        LEN_NO,
        LEN_DESC,
        LEN_UNIT,
        LEN_MIN,
        LEN_MAX,
        SHRT_LEN_RATO,
        SHORTEST,
        LONG_LEN_RATO,
        LONGEST,
        SHRT_STOVE,
        AVG_LEN_MIN,
        DIFRNC_LEN_MAX,
        ENDLEN_SPECSTD,
        SIGL_LEN,
        ORDER_UNIT,
        ORDER_QTY,
        ORD_ENSU_TOTL_LEN,
        PRDCT_WGT,
        DELVRY_RANGE_TPE,
        DELVRY_RANGE_MIN,
        DELVRY_RANGE_MAX,
        FINAL_USER,
        FINAL_USER_DESC,
        OUTS_BILLET_FL,
        OUTS_STL_PIPE_FL,
        ASSEL_FL,
        PRODUCER_FL,
        PRDCR_NO,
        PRDCR_DESC,
        MPS_FL,
        MPS_NO,
        MPS_DESC,
        DELVRY_BDATE,
        DELVRY_EDATE,
        DELVRY_DESC,
        TRANS_DESC,
        ADD_ASK_NO,
        ORDER_ADD_DESC,
        ORDER_SPECIAL_FL,
        ORDER_SPECIAL_HEAD,
        ORDER_SPECIAL_PATH,
        ORDER_SPECIAL_DESC,
        ZBS,
        ORDER_PRICE,
        TRANS_PRICE,
        TEST_ID,
        TEST_PRICE,
        OUT_PRICE,
        BALNCE_PRICE,
        BE_ORDER_LN_STATUS,
        BE_OBJ_STS_OP,
        ORDER_LN_STATUS,
        MEMO,
        CREATE_NAME,
        CREATE_TIME,
        ISLOCK,
        UPDATE_NAME,
        UPDATE_TIME,
        AW,
        MAN_INSPECTION,
        QUALITY_USER ,
        QUALITY_USER_DESC,
        OUTPUT_STD_NO,
        PROJECT_NO,
        OUTBOUND_CALCULATE,ORDER_TEAM,MODE_OF_TRANSPORT
        )
 VALUES( 
        '#ORDER_CHGE_NO#',
        '#CHGE_ORD_LN_PK#',
        '#ORD_PK#',
        '#ORD_LN_PK#',
        '#ORDER_SEQ#',
        '#CUST_ALPHA_NO#',
        '#PSC#',
        '#PSC_DESC#',
        '#MSC#',
        '#MSC_DESC#',
        '#MSC_STYLE#',
        '#USE_CODE#',
        '#USE_DESC#',
        '#PRD_CLS#',
        '#PRODUCCODE#',
        '#PRODUCNAME#',
        '#STD_CODE#',
        '#STD_NAME#',
        '#STEELCODE#',
        '#STEELNAME#',
        '#STD_STYLE#',
        '#STD_STYLE_DESC#',
        '#ORDER_SPEC_CODE#',
        '#ORDER_SPEC_DESC#',
        '#SPEC_CODE#',
        '#SPEC_NAME#',
        '#DIMATER#',
        '#HEIGHT#',
        '#MODEL_CODE#',
        '#MODEL_DESC#',
        '#LEN_NO#',
        '#LEN_DESC#',
        '#LEN_UNIT#',
        '#LEN_MIN#',
        '#LEN_MAX#',
        '#SHRT_LEN_RATO#',
        '#SHORTEST#',
        '#LONG_LEN_RATO#',
        '#LONGEST#',
        '#SHRT_STOVE#',
        '#AVG_LEN_MIN#',
        '#DIFRNC_LEN_MAX#',
        '#ENDLEN_SPECSTD#',
        '#SIGL_LEN#',
        '#ORDER_UNIT#',
        '#ORDER_QTY#',
        '#ORD_ENSU_TOTL_LEN#',
        '#PRDCT_WGT#',
        '#DELVRY_RANGE_TPE#',
        '#DELVRY_RANGE_MIN#',
        '#DELVRY_RANGE_MAX#',
        '#FINAL_USER#',
        '#FINAL_USER_DESC#',
        '#OUTS_BILLET_FL#',
        '#OUTS_STL_PIPE_FL#',
        '#ASSEL_FL#',
        '#PRODUCER_FL#',
        '#PRDCR_NO#',
        '#PRDCR_DESC#',
        '#MPS_FL#',
        '#MPS_NO#',
        '#MPS_DESC#',
        TO_DATE('#DELVRY_BDATE#','YYYY-MM-DD'),
        TO_DATE('#DELVRY_EDATE#','YYYY-MM-DD'),
        '#DELVRY_DESC#',
        '#TRANS_DESC#',
        '#ADD_ASK_NO#',
        '#ORDER_ADD_DESC#',
        '#ORDER_SPECIAL_FL#',
        '#ORDER_SPECIAL_HEAD#',
        '#ORDER_SPECIAL_PATH#',
        '#ORDER_SPECIAL_DESC#',
        '#ZBS#',
        '#ORDER_PRICE#',
        '#TRANS_PRICE#',
        '#TEST_ID#',
        '#TEST_PRICE#',
        '#OUT_PRICE#',
        '#BALNCE_PRICE#',
        '#BE_ORDER_LN_STATUS#',
        '#BE_OBJ_STS_OP#',
        '#ORDER_LN_STATUS#',
        '#MEMO#',
        '#CREATE_NAME#',
         TO_DATE('#CREATE_TIME#','YYYY-MM-DD HH24:MI:SS'),
        '#ISLOCK#',
        '#UPDATE_NAME#',
         SYSDATE,
        '#AW#',
        '#MAN_INSPECTION#',
        '#QUALITY_USER#' ,
        '#QUALITY_USER_DESC#',
        '#OUTPUT_STD_NO#',
        '#PROJECT_NO#',
        '#OUTBOUND_CALCULATE#',
        '#ORDER_TEAM#',
        '#MODE_OF_TRANSPORT#')
		]]>
	</query>

	<query id="CoreOrderChangeManage.generateOrderSeq" desc="生成合同行号 ">
	<![CDATA[
	SELECT DECODE (MAX (ORDER_SEQ), '', '001',
				LPAD (MAX(ORDER_SEQ)+1, 3, '0')
								  )
				  FROM SLM_ORDER_LINE
		 WHERE ORD_PK = '#ORD_PK#' 
	
	]]>
	</query>

	<query id="CoreOrderChangeManage.getLockedOrderLine" desc="是否存在锁定的合同行">
	<![CDATA[
	    SELECT ORD_LN_PK FROM SLM_ORDER_LINE  T
	    WHERE T.ORD_PK = ? AND T.VALIDFLAG = '1'
	    AND T.ISLOCK = '1'
	  
	]]>
	</query>

	<query id="CoreOrderChangeManage.chgeCancelAddOrderLine" desc="取消合同行变更-新增合同行">
	<![CDATA[
	    UPDATE SLM_ORDER_LINE T 
	    SET ISLOCK = '0' ,
	    	VALIDFLAG = '0',
	    	CHGE_ORD_LN_PK = ''	
	  WHERE ORD_LN_PK = ?
	  
	]]>
	</query>

	<query id="CoreOrderChangeManage.chgeDeleteOrderReviewList" desc="取消合同行变更合同行对应的评审明细记录">
	<![CDATA[
	    UPDATE SLM_ORDER_REVIEW_ITEM_LIST 
	    SET IS_CURT_REVIEW = '0'
	    WHERE LIST_PK_VAL = ? AND  IS_CURT_REVIEW = '1'
	  
	]]>
	</query>

	<query id="CoreOrderChangeManage.selectOrderLine" desc="取消合同行变更合同行对应的评审明细记录">
	<![CDATA[
	    SELECT  T.ORDER_LN_STATUS,T.ISLOCK
	    FROM SLM_ORDER_LINE T
	    WHERE T.ORD_LN_PK = ?
	    AND T.VALIDFLAG = '1'

	]]>
	</query>

	<query id="CoreOrderChangeManage.updateOrderLineStatusAndUnLock"
		desc="合同行生效并解锁">
	<![CDATA[
	   UPDATE SLM_ORDER_LINE T
	   SET T.ORDER_LN_STATUS = '12020301',
	      T.ISLOCK = '0',
	      T.CHGE_ORD_LN_PK =''
	   WHERE T.ORD_LN_PK = ?
	   AND T.VALIDFLAG = '1'

	]]>
	</query>

	<query id="CoreOrderChangeManage.getChgeSlmOrderLine" desc="合同行生效并解锁">
	<![CDATA[
	     SELECT 
       ORDER_CHGE_NO,
       CHGE_ORD_LN_PK,
       ORD_PK,
       ORD_LN_PK,
       ORDER_SEQ,
       CUST_ALPHA_NO,
       PSC,
       PSC_DESC,
       MSC,
       MSC_DESC,
       MSC_STYLE,
       USE_CODE,
       USE_DESC,
       PRD_CLS,
       PRODUCCODE,
       PRODUCNAME,
       STD_CODE,
       STD_NAME,
       STEELCODE,
       STEELNAME,
       STD_STYLE,
       STD_STYLE_DESC,
       ORDER_SPEC_CODE,
       ORDER_SPEC_DESC,
       SPEC_CODE,
       SPEC_NAME,
       DIMATER,
       HEIGHT,
       MODEL_CODE,
       MODEL_DESC,
       LEN_NO,
       LEN_DESC,
       LEN_UNIT,
       LEN_MIN,
       LEN_MAX,
       SHRT_LEN_RATO,
       SHORTEST,
       LONG_LEN_RATO,
       LONGEST,
       SHRT_STOVE,
       AVG_LEN_MIN,
       DIFRNC_LEN_MAX,
       ENDLEN_SPECSTD,
       SIGL_LEN,
       ORDER_UNIT,
       ORDER_QTY,
       ORD_ENSU_TOTL_LEN,
       PRDCT_WGT,
       DELVRY_RANGE_TPE,
       DELVRY_RANGE_MIN,
       DELVRY_RANGE_MAX,
       FINAL_USER,
       FINAL_USER_DESC,
       OUTS_BILLET_FL,
       OUTS_STL_PIPE_FL,
       ASSEL_FL,
       PRODUCER_FL,
       PRDCR_NO,
       PRDCR_DESC,
       MPS_FL,
       MPS_NO,
       MPS_DESC,
       TO_CHAR(DELVRY_BDATE, 'YYYY-MM-DD') DELVRY_BDATE,
       TO_CHAR(DELVRY_EDATE, 'YYYY-MM-DD') DELVRY_EDATE,
       DELVRY_DESC,
       TRANS_DESC,
       ADD_ASK_NO,
       ORDER_ADD_DESC,
       ORDER_SPECIAL_FL,
       ORDER_SPECIAL_HEAD,
       ORDER_SPECIAL_PATH,
       ORDER_SPECIAL_DESC,
       ZBS,
       ORDER_PRICE,
       TRANS_PRICE,
       TEST_ID,
       TEST_PRICE,
       OUT_PRICE,
       BALNCE_PRICE,
       BE_ORDER_LN_STATUS,
       BE_OBJ_STS_OP,
       ORDER_LN_STATUS,
       OBJ_STS_OP,
       MEMO,
       VALIDFLAG,
       CREATE_NAME,
       TO_CHAR(NVL(CREATE_TIME,SYSDATE),'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       UPDATE_NAME,
       TO_CHAR(UPDATE_TIME, 'YYYY-MM-DD HH24:MI:SS') UPDATE_TIME,
       DELETE_NAME,
       TO_CHAR(DELETE_TIME, 'YYYY-MM-DD HH24:MI:SS') DELETE_TIME,
       ORD_LN_PK_OLD,
       ISLOCK ,
       CUST_ALPHA_NO2,
       AW,
       MAN_INSPECTION,
       QUALITY_USER,
       QUALITY_USER_DESC,
       OUTPUT_STD_NO,
       PROJECT_NO,
       OUTBOUND_CALCULATE,
       ORDER_TEAM,MODE_OF_TRANSPORT
   FROM SLM_ORDER_LINE
   WHERE ORD_LN_PK = '#ORD_LN_PK#'   
	]]>
	</query>

	<query id="CoreOrderChangeManage.updateChgeOrderLineInfo" desc="合同行生效并解锁">
	<![CDATA[
	   UPDATE SLM_ORDER_LINE
      SET ORDER_CHGE_NO   = '#ORDER_CHGE_NO#',
       CHGE_ORD_LN_PK     = '#CHGE_ORD_LN_PK#',
       ORD_PK             = '#ORD_PK#',
       ORD_LN_PK          = '#ORD_LN_PK#',
       ORDER_SEQ          = '#ORDER_SEQ#',
       CUST_ALPHA_NO      = '#CUST_ALPHA_NO#',
       PSC                = '#PSC#',
       PSC_DESC           = '#PSC_DESC#',
       MSC                = '#MSC#',
       MSC_DESC           = '#MSC_DESC#',
       MSC_STYLE          = '#MSC_STYLE#',
       USE_CODE           = '#USE_CODE#',
       USE_DESC           = '#USE_DESC#',
       PRD_CLS            = '#PRD_CLS#',
       PRODUCCODE         = '#PRODUCCODE#',
       PRODUCNAME         = '#PRODUCNAME#',
       STD_CODE           = '#STD_CODE#',
       STD_NAME           = '#STD_NAME#',
       STEELCODE          = '#STEELCODE#',
       STEELNAME          = '#STEELNAME#',
       STD_STYLE          = '#STD_STYLE#',
       STD_STYLE_DESC     = '#STD_STYLE_DESC#',
       ORDER_SPEC_CODE    = '#ORDER_SPEC_CODE#',
       ORDER_SPEC_DESC    = '#ORDER_SPEC_DESC#',
       SPEC_CODE          = '#SPEC_CODE#',
       SPEC_NAME          = '#SPEC_NAME#',
       DIMATER            = '#DIMATER#',
       HEIGHT             = '#HEIGHT#',
       MODEL_CODE         = '#MODEL_CODE#',
       MODEL_DESC         = '#MODEL_DESC#',
       LEN_NO             = '#LEN_NO#',
       LEN_DESC           = '#LEN_DESC#',
       LEN_UNIT           = '#LEN_UNIT#',
       LEN_MIN            = '#LEN_MIN#',
       LEN_MAX            = '#LEN_MAX#',
       SHRT_LEN_RATO      = '#SHRT_LEN_RATO#',
       SHORTEST           = '#SHORTEST#',
       LONG_LEN_RATO      = '#LONG_LEN_RATO#',
       LONGEST            = '#LONGEST#',
       SHRT_STOVE         = '#SHRT_STOVE#',
       AVG_LEN_MIN        = '#AVG_LEN_MIN#',
       DIFRNC_LEN_MAX     = '#DIFRNC_LEN_MAX#',
       ENDLEN_SPECSTD     = '#ENDLEN_SPECSTD#',
       SIGL_LEN           = '#SIGL_LEN#',
       ORDER_UNIT         = '#ORDER_UNIT#',
       ORDER_QTY          = '#ORDER_QTY#',
       ORD_ENSU_TOTL_LEN  = '#ORD_ENSU_TOTL_LEN#',
       PRDCT_WGT          = '#PRDCT_WGT#',
       DELVRY_RANGE_TPE   = '#DELVRY_RANGE_TPE#',
       DELVRY_RANGE_MIN   = '#DELVRY_RANGE_MIN#',
       DELVRY_RANGE_MAX   = '#DELVRY_RANGE_MAX#',
       FINAL_USER         = '#FINAL_USER#',
       FINAL_USER_DESC    = '#FINAL_USER_DESC#',
       OUTS_BILLET_FL     = '#OUTS_BILLET_FL#',
       OUTS_STL_PIPE_FL   = '#OUTS_STL_PIPE_FL#',
       ASSEL_FL           = '#ASSEL_FL#',
       PRODUCER_FL        = '#PRODUCER_FL#',
       PRDCR_NO           = '#PRDCR_NO#',
       PRDCR_DESC         = '#PRDCR_DESC#',
       MPS_FL             = '#MPS_FL#',
       MPS_NO             = '#MPS_NO#',
       MPS_DESC           = '#MPS_DESC#',
       DELVRY_BDATE       = TO_DATE('#DELVRY_BDATE#','YYYY-MM-DD'),
       DELVRY_EDATE       = TO_DATE('#DELVRY_EDATE#','YYYY-MM-DD'),
       DELVRY_DESC        = '#DELVRY_DESC#',
       TRANS_DESC         = '#TRANS_DESC#',
       ADD_ASK_NO         = '#ADD_ASK_NO#',
       ORDER_ADD_DESC     = '#ORDER_ADD_DESC#',
       ORDER_SPECIAL_FL   = '#ORDER_SPECIAL_FL#',
       ORDER_SPECIAL_HEAD = '#ORDER_SPECIAL_HEAD#',
       ORDER_SPECIAL_PATH = '#ORDER_SPECIAL_PATH#',
       ORDER_SPECIAL_DESC = '#ORDER_SPECIAL_DESC#',
       ZBS                = '#ZBS#',
       ORDER_PRICE        = '#ORDER_PRICE#',
       TRANS_PRICE        = '#TRANS_PRICE#',
       TEST_ID            = '#TEST_ID#',
       TEST_PRICE         = '#TEST_PRICE#',
       OUT_PRICE          = '#OUT_PRICE#',
       BALNCE_PRICE       = '#BALNCE_PRICE#',
       BE_ORDER_LN_STATUS = '#BE_ORDER_LN_STATUS#',
       BE_OBJ_STS_OP      = '#BE_OBJ_STS_OP#',
       ORDER_LN_STATUS    = '#ORDER_LN_STATUS#',
       OBJ_STS_OP         = '#OBJ_STS_OP#',
       MEMO               = '#MEMO#',
       CREATE_NAME        = '#CREATE_NAME#',
       CREATE_TIME        = TO_DATE('#CREATE_TIME#','YYYY-MM-DD HH24:MI:SS'),
       UPDATE_NAME        = '#UPDATE_NAME#',
       UPDATE_TIME        =  SYSDATE ,
       AW                 = '#AW#'

       WHERE ORD_LN_PK    = '#ORD_LN_PK#'
       AND VALIDFLAG = '1'
	   
	]]>
	</query>

	<query id="CoreOrderChangeManage.chgeUpdateOrderLineStatus" desc="修改-变更新增合同行状态">
	<![CDATA[
	    UPDATE SLM_ORDER_LINE T 
	    SET ISLOCK = ?,
	    	VALIDFLAG = ?,
	    	CHGE_ORD_LN_PK = ?,
	    	ORDER_CHGE_NO = ?
	  WHERE ORD_LN_PK = ?
	  
	]]>
	</query>

	<query id="CoreOrderChangeManage.chgeSelectOrderDlyLine" desc="取消变更单内容">
	<![CDATA[
	   SELECT 
       PICKUP_FLAG,
       ORD_PK,
       ORD_LN_PK,
       ORD_LN_DLY_PK,
       DELIVERY_NO,
       TO_CHAR(DELVRY_BDATE, 'YYYY-MM-DD') DELVRY_BDATE,
       TO_CHAR(DELVRY_EDATE, 'YYYY-MM-DD') DELVRY_EDATE,
       DELVRY_QTY,
       ORDER_UNIT,
       WGT_ESTMT,
       ENSU_TOTL_LEN,
       RECEIV_NO,
       RECEIV_NM,
       DELVRY_ADDR,
       AGENCY_FL,
       RECEIV_ADDR,
       TRANSIT_TYP,
       TRANSIT_PLAN,
       TRANSIT_MNY,
       BE_DELIVERY_STATUS,
       BE_OBJ_STS_OP,
       DELIVERY_STATUS,
       OBJ_STS_OP,
       VALIDFLAG,
       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,
       DELETE_NAME,
       TO_CHAR(DELETE_TIME, 'YYYY-MM-DD HH24:MI:SS') DELETE_TIME,
       ISLOCK
       FROM SLM_ORDER_LINE_DELIVERY T
       WHERE  T.ORD_LN_PK = '#ORD_LN_PK#' AND T.VALIDFLAG = '1'
	   
	]]>
	</query>

	<query id="CoreOrderChangeManage.chgeInsertOrderDlyLine" desc="取消变更单内容">
	<![CDATA[
		 INSERT INTO SLM_ORDER_LINE_DELIVERY(
        PICKUP_FLAG,
        ORD_PK,
        ORD_LN_PK,
        ORD_LN_DLY_PK,
        DELIVERY_NO,
        DELVRY_BDATE,
        DELVRY_EDATE,
        DELVRY_QTY,
        ORDER_UNIT,
        WGT_ESTMT,
        ENSU_TOTL_LEN,
        RECEIV_NO,
        RECEIV_NM,
        DELVRY_ADDR,
        AGENCY_FL,
        RECEIV_ADDR,
        TRANSIT_TYP,
        TRANSIT_PLAN,
        TRANSIT_MNY,
        BE_DELIVERY_STATUS,
        BE_OBJ_STS_OP,
        DELIVERY_STATUS,
        OBJ_STS_OP,
        VALIDFLAG,
        CREATE_NAME,
        CREATE_TIME,
        UPDATE_NAME,
        UPDATE_TIME,
        DELETE_NAME,
        DELETE_TIME,
        ISLOCK)
 VALUES( 
        '#PICKUP_FLAG#',
        '#ORD_PK#',
        '#ORD_LN_PK#',
        '#ORD_LN_DLY_PK#',
        '#DELIVERY_NO#',
        TO_DATE('#DELVRY_BDATE#','YYYY-MM-DD'),
        TO_DATE('#DELVRY_EDATE#','YYYY-MM-DD'),
        '#DELVRY_QTY#',
        '#ORDER_UNIT#',
        '#WGT_ESTMT#',
        '#ENSU_TOTL_LEN#',
        '#RECEIV_NO#',
        '#RECEIV_NM#',
        '#DELVRY_ADDR#',
        '#AGENCY_FL#',
        '#RECEIV_ADDR#',
        '#TRANSIT_TYP#',
        '#TRANSIT_PLAN#',
        '#TRANSIT_MNY#',
        '#BE_DELIVERY_STATUS#',
        '#BE_OBJ_STS_OP#',
        '#DELIVERY_STATUS#',
        '#OBJ_STS_OP#',
        '#VALIDFLAG#',
        '#CREATE_NAME#',
        TO_DATE('#CREATE_TIME#','YYYY-MM-DD HH24:MI:SS'),
        '#UPDATE_NAME#',
        TO_DATE('#UPDATE_TIME#','YYYY-MM-DD HH24:MI:SS'),
        '#DELETE_NAME#',
        TO_DATE('#DELETE_TIME#','YYYY-MM-DD HH24:MI:SS'),
        '#ISLOCK#')
	
      ]]>
	</query>

	<query id="CoreOrderChangeManage.chgeSelectOrderDlyLineTransit"
		desc="修改-变更新增合同行状态">
	<![CDATA[
	    SELECT 
       ORD_PK,
       ORD_LN_PK,
       ORD_LN_DLY_PK,
       INDEX_SEQ,
       AGENCY_FL,
       TRANSIT_TYP,
       DESTINATION,
       STATION_NO,
       STATION_NM,
       SPCL_LN_NO,
       SPCL_LN_NM,
       PORT_NO,
       PORT_DESC,
       CARRIER_UNIT,
       RECEIVOR,
       TRANSIT_LN_MNY,
       VALIDFLAG,
       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,
       DELETE_NAME,
       TO_CHAR(DELETE_TIME, 'YYYY-MM-DD HH24:MI:SS') DELETE_TIME,
       LV_FACTY_TYP
   FROM SLM_ORDER_DELIVERY_TRANSIT T
   WHERE T.ORD_LN_PK = '#ORD_LN_PK#' AND T.VALIDFLAG = '1'
	  
	]]>
	</query>

	<query id="CoreOrderChangeManage.chgeInsertOrderDlyLineTransit"
		desc="修改-变更新增合同行状态">
	<![CDATA[
	    INSERT INTO SLM_ORDER_DELIVERY_TRANSIT(
        ORD_PK,
        ORD_LN_PK,
        ORD_LN_DLY_PK,
        INDEX_SEQ,
        AGENCY_FL,
        TRANSIT_TYP,
        DESTINATION,
        STATION_NO,
        STATION_NM,
        SPCL_LN_NO,
        SPCL_LN_NM,
        PORT_NO,
        PORT_DESC,
        CARRIER_UNIT,
        RECEIVOR,
        TRANSIT_LN_MNY,
        VALIDFLAG,
        CREATE_NAME,
        CREATE_TIME,
        UPDATE_NAME,
        UPDATE_TIME,
        DELETE_NAME,
        DELETE_TIME,
        LV_FACTY_TYP)
 VALUES( 
        '#ORD_PK#',
        '#ORD_LN_PK#',
        '#ORD_LN_DLY_PK#',
        '#INDEX_SEQ#',
        '#AGENCY_FL#',
        '#TRANSIT_TYP#',
        '#DESTINATION#',
        '#STATION_NO#',
        '#STATION_NM#',
        '#SPCL_LN_NO#',
        '#SPCL_LN_NM#',
        '#PORT_NO#',
        '#PORT_DESC#',
        '#CARRIER_UNIT#',
        '#RECEIVOR#',
        '#TRANSIT_LN_MNY#',
        '#VALIDFLAG#',
        '#CREATE_NAME#',
        TO_DATE('#CREATE_TIME#','YYYY-MM-DD HH24:MI:SS'),
        '#UPDATE_NAME#',
        TO_DATE('#UPDATE_TIME#','YYYY-MM-DD HH24:MI:SS'),
        '#DELETE_NAME#',
        TO_DATE('#DELETE_TIME#','YYYY-MM-DD HH24:MI:SS'),
        '#LV_FACTY_TYP#')
	  
	]]>
	</query>

	<query id="CoreOrderChangeManage.IsExistsChgeOrdLnPk" desc="修改-变更新增合同行状态">
	<![CDATA[
	   
	SELECT CHGE_ORD_LN_PK FROM SLM_ORDER_LINE T
	WHERE T.ORD_LN_PK = ? AND T.VALIDFLAG  = '1'
	  
	]]>
	</query>

	<query id="CoreOrderChangeManage.chgeOrderLineExistsDesignKey"
		desc="是否存在变更行的designkey">
	<![CDATA[
	   SELECT T.DESGIN_KEY
     FROM SLM_ORD_DESIGN_MSC T
    WHERE T.ORD_LN_PK = ?
    AND T.VALIDFLAG = '1'

	]]>
	</query>

	<query id="CoreOrderChangeManage.chgeInsertOrderLineHistory"
		desc="是否存在变更行的designkey">
	<![CDATA[
	   
   			 INSERT INTO CHGE_SLM_ORDER_LINE_H(
        ISLOCK,
        CUST_ALPHA_NO2,
        ORDER_CHGE_NO,
        CHGE_ORD_LN_PK,
        ORD_LN_PK_OLD,
        ORD_PK,
        ORD_LN_PK,
        ORDER_SEQ,
        CUST_ALPHA_NO,
        PSC,
        PSC_DESC,
        MSC,
        MSC_DESC,
        MSC_STYLE,
        USE_CODE,
        USE_DESC,
        PRD_CLS,
        PRODUCCODE,
        PRODUCNAME,
        STD_CODE,
        STD_NAME,
        STEELCODE,
        STEELNAME,
        STD_STYLE,
        STD_STYLE_DESC,
        ORDER_SPEC_CODE,
        ORDER_SPEC_DESC,
        SPEC_CODE,
        SPEC_NAME,
        DIMATER,
        HEIGHT,
        MODEL_CODE,
        MODEL_DESC,
        LEN_NO,
        LEN_DESC,
        LEN_UNIT,
        LEN_MIN,
        LEN_MAX,
        SHRT_LEN_RATO,
        SHORTEST,
        LONG_LEN_RATO,
        LONGEST,
        SHRT_STOVE,
        AVG_LEN_MIN,
        DIFRNC_LEN_MAX,
        ENDLEN_SPECSTD,
        SIGL_LEN,
        ORDER_UNIT,
        ORDER_QTY,
        ORD_ENSU_TOTL_LEN,
        PRDCT_WGT,
        DELVRY_RANGE_TPE,
        DELVRY_RANGE_MIN,
        DELVRY_RANGE_MAX,
        FINAL_USER,
        FINAL_USER_DESC,
        OUTS_BILLET_FL,
        OUTS_STL_PIPE_FL,
        ASSEL_FL,
        PRODUCER_FL,
        PRDCR_NO,
        PRDCR_DESC,
        MPS_FL,
        MPS_NO,
        MPS_DESC,
        DELVRY_BDATE,
        DELVRY_EDATE,
        DELVRY_DESC,
        TRANS_DESC,
        ADD_ASK_NO,
        ORDER_ADD_DESC,
        ORDER_SPECIAL_FL,
        ORDER_SPECIAL_HEAD,
        ORDER_SPECIAL_PATH,
        ORDER_SPECIAL_DESC,
        ZBS,
        ORDER_PRICE,
        TRANS_PRICE,
        TEST_ID,
        TEST_PRICE,
        OUT_PRICE,
        BALNCE_PRICE,
        BE_ORDER_LN_STATUS,
        BE_OBJ_STS_OP,
        ORDER_LN_STATUS,
        OBJ_STS_OP,
        MEMO,
        VALIDFLAG,
        CREATE_NAME,
        CREATE_TIME,
        UPDATE_NAME,
        UPDATE_TIME,
        AW,
        MAN_INSPECTION,
        QUALITY_USER,
        QUALITY_USER_DESC,
        OUTPUT_STD_NO,
        PROJECT_NO)
 VALUES( 
        '#ISLOCK#',
        '#CUST_ALPHA_NO2#',
        '#ORDER_CHGE_NO#',
        '#CHGE_ORD_LN_PK#',
        '#ORD_LN_PK_OLD#',
        '#ORD_PK#',
        '#ORD_LN_PK#',
        '#ORDER_SEQ#',
        '#CUST_ALPHA_NO#',
        '#PSC#',
        '#PSC_DESC#',
        '#MSC#',
        '#MSC_DESC#',
        '#MSC_STYLE#',
        '#USE_CODE#',
        '#USE_DESC#',
        '#PRD_CLS#',
        '#PRODUCCODE#',
        '#PRODUCNAME#',
        '#STD_CODE#',
        '#STD_NAME#',
        '#STEELCODE#',
        '#STEELNAME#',
        '#STD_STYLE#',
        '#STD_STYLE_DESC#',
        '#ORDER_SPEC_CODE#',
        '#ORDER_SPEC_DESC#',
        '#SPEC_CODE#',
        '#SPEC_NAME#',
        '#DIMATER#',
        '#HEIGHT#',
        '#MODEL_CODE#',
        '#MODEL_DESC#',
        '#LEN_NO#',
        '#LEN_DESC#',
        '#LEN_UNIT#',
        '#LEN_MIN#',
        '#LEN_MAX#',
        '#SHRT_LEN_RATO#',
        '#SHORTEST#',
        '#LONG_LEN_RATO#',
        '#LONGEST#',
        '#SHRT_STOVE#',
        '#AVG_LEN_MIN#',
        '#DIFRNC_LEN_MAX#',
        '#ENDLEN_SPECSTD#',
        '#SIGL_LEN#',
        '#ORDER_UNIT#',
        '#ORDER_QTY#',
        '#ORD_ENSU_TOTL_LEN#',
        '#PRDCT_WGT#',
        '#DELVRY_RANGE_TPE#',
        '#DELVRY_RANGE_MIN#',
        '#DELVRY_RANGE_MAX#',
        '#FINAL_USER#',
        '#FINAL_USER_DESC#',
        '#OUTS_BILLET_FL#',
        '#OUTS_STL_PIPE_FL#',
        '#ASSEL_FL#',
        '#PRODUCER_FL#',
        '#PRDCR_NO#',
        '#PRDCR_DESC#',
        '#MPS_FL#',
        '#MPS_NO#',
        '#MPS_DESC#',
        TO_DATE('#DELVRY_BDATE#','YYYY-MM-DD'),
        TO_DATE('#DELVRY_EDATE#','YYYY-MM-DD'),
        '#DELVRY_DESC#',
        '#TRANS_DESC#',
        '#ADD_ASK_NO#',
        '#ORDER_ADD_DESC#',
        '#ORDER_SPECIAL_FL#',
        '#ORDER_SPECIAL_HEAD#',
        '#ORDER_SPECIAL_PATH#',
        '#ORDER_SPECIAL_DESC#',
        '#ZBS#',
        '#ORDER_PRICE#',
        '#TRANS_PRICE#',
        '#TEST_ID#',
        '#TEST_PRICE#',
        '#OUT_PRICE#',
        '#BALNCE_PRICE#',
        '#BE_ORDER_LN_STATUS#',
        '#BE_OBJ_STS_OP#',
        '#ORDER_LN_STATUS#',
        '#OBJ_STS_OP#',
        '#MEMO#',
        '#VALIDFLAG#',
        '#CREATE_NAME#',
        TO_DATE('#CREATE_TIME#','YYYY-MM-DD HH24:MI:SS'),
        '#UPDATE_NAME#',
        TO_DATE('#UPDATE_TIME#','YYYY-MM-DD HH24:MI:SS'),
        '#AW#',
        '#MAN_INSPECTION#',
        '#QUALITY_USER#',
        '#QUALITY_USER_DESC#',
        '#OUTPUT_STD_NO#',
        '#PROJECT_NO#')

	]]>
	</query>

	<query id="CoreOrderChangeManage.chgeReturnOrderLineInfo" desc="回写合同行信息">
	<![CDATA[
			UPDATE SLM_ORDER_LINE
   SET ORDER_CHGE_NO      = '#ORDER_CHGE_NO#',
       CHGE_ORD_LN_PK     = '#CHGE_ORD_LN_PK#',
       ORD_PK             = '#ORD_PK#',
       ORD_LN_PK          = '#ORD_LN_PK#',
       ORDER_SEQ          = '#ORDER_SEQ#',
       CUST_ALPHA_NO      = '#CUST_ALPHA_NO#',
       PSC                = '#PSC#',
       PSC_DESC           = '#PSC_DESC#',
       MSC                = '#MSC#',
       MSC_DESC           = '#MSC_DESC#',
       MSC_STYLE          = '#MSC_STYLE#',
       USE_CODE           = '#USE_CODE#',
       USE_DESC           = '#USE_DESC#',
       PRD_CLS            = '#PRD_CLS#',
       PRODUCCODE         = '#PRODUCCODE#',
       PRODUCNAME         = '#PRODUCNAME#',
       STD_CODE           = '#STD_CODE#',
       STD_NAME           = '#STD_NAME#',
       STEELCODE          = '#STEELCODE#',
       STEELNAME          = '#STEELNAME#',
       STD_STYLE          = '#STD_STYLE#',
       STD_STYLE_DESC     = '#STD_STYLE_DESC#',
       ORDER_SPEC_CODE    = '#ORDER_SPEC_CODE#',
       ORDER_SPEC_DESC    = '#ORDER_SPEC_DESC#',
       SPEC_CODE          = '#SPEC_CODE#',
       SPEC_NAME          = '#SPEC_NAME#',
       DIMATER            = '#DIMATER#',
       HEIGHT             = '#HEIGHT#',
       MODEL_CODE         = '#MODEL_CODE#',
       MODEL_DESC         = '#MODEL_DESC#',
       LEN_NO             = '#LEN_NO#',
       LEN_DESC           = '#LEN_DESC#',
       LEN_UNIT           = '#LEN_UNIT#',
       LEN_MIN            = '#LEN_MIN#',
       LEN_MAX            = '#LEN_MAX#',
       SHRT_LEN_RATO      = '#SHRT_LEN_RATO#',
       SHORTEST           = '#SHORTEST#',
       LONG_LEN_RATO      = '#LONG_LEN_RATO#',
       LONGEST            = '#LONGEST#',
       SHRT_STOVE         = '#SHRT_STOVE#',
       AVG_LEN_MIN        = '#AVG_LEN_MIN#',
       DIFRNC_LEN_MAX     = '#DIFRNC_LEN_MAX#',
       ENDLEN_SPECSTD     = '#ENDLEN_SPECSTD#',
       SIGL_LEN           = '#SIGL_LEN#',
       ORDER_UNIT         = '#ORDER_UNIT#',
       ORDER_QTY          = '#ORDER_QTY#',
       ORD_ENSU_TOTL_LEN  = '#ORD_ENSU_TOTL_LEN#',
       PRDCT_WGT          = '#PRDCT_WGT#',
       DELVRY_RANGE_TPE   = '#DELVRY_RANGE_TPE#',
       DELVRY_RANGE_MIN   = '#DELVRY_RANGE_MIN#',
       DELVRY_RANGE_MAX   = '#DELVRY_RANGE_MAX#',
       FINAL_USER         = '#FINAL_USER#',
       FINAL_USER_DESC    = '#FINAL_USER_DESC#',
       OUTS_BILLET_FL     = '#OUTS_BILLET_FL#',
       OUTS_STL_PIPE_FL   = '#OUTS_STL_PIPE_FL#',
       ASSEL_FL           = '#ASSEL_FL#',
       PRODUCER_FL        = '#PRODUCER_FL#',
       PRDCR_NO           = '#PRDCR_NO#',
       PRDCR_DESC         = '#PRDCR_DESC#',
       MPS_FL             = '#MPS_FL#',
       MPS_NO             = '#MPS_NO#',
       MPS_DESC           = '#MPS_DESC#',
       DELVRY_BDATE       = '#DELVRY_BDATE#',
       DELVRY_EDATE       = '#DELVRY_BDATE#',
       DELVRY_DESC        = '#DELVRY_DESC#',
       TRANS_DESC         = '#TRANS_DESC#',
       ADD_ASK_NO         = '#ADD_ASK_NO#',
       ORDER_ADD_DESC     = '#ORDER_ADD_DESC#',
       ORDER_SPECIAL_FL   = '#ORDER_SPECIAL_FL#',
       ORDER_SPECIAL_HEAD = '#ORDER_SPECIAL_HEAD#',
       ORDER_SPECIAL_PATH = '#ORDER_SPECIAL_PATH#',
       ORDER_SPECIAL_DESC = '#ORDER_SPECIAL_DESC#',
       ZBS                = '#ZBS#',
       ORDER_PRICE        = '#ORDER_PRICE#',
       TRANS_PRICE        = '#TRANS_PRICE#',
       TEST_ID            = '#TEST_ID#',
       TEST_PRICE         = '#TEST_PRICE#',
       OUT_PRICE          = '#OUT_PRICE#',
       BALNCE_PRICE       = '#BALNCE_PRICE#',
       BE_ORDER_LN_STATUS = '#BE_ORDER_LN_STATUS#',
       BE_OBJ_STS_OP      = '#BE_OBJ_STS_OP#',
       ORDER_LN_STATUS    = '#ORDER_LN_STATUS#',
       OBJ_STS_OP         = '#OBJ_STS_OP#',
       MEMO               = '#MEMO#',
       VALIDFLAG          = '#VALIDFLAG#',
       CREATE_NAME        = '#CREATE_NAME#',
       CREATE_TIME        = TO_DATE('#CREATE_TIME#', 'YYYY-MM-DD HH24:MI:SS'),
       UPDATE_NAME        = '#UPDATE_NAME#',
       UPDATE_TIME        = TO_DATE('#UPDATE_TIME#', 'YYYY-MM-DD HH24:MI:SS'),
       DELETE_NAME        = '#DELETE_NAME#',
       DELETE_TIME        = TO_DATE('#DELETE_TIME#', 'YYYY-MM-DD HH24:MI:SS'),
       ORD_LN_PK_OLD      = '#ORD_LN_PK_OLD#',
       ISLOCK             = '#ISLOCK#',
       CUST_ALPHA_NO2     = '#CUST_ALPHA_NO2#',
       AW                 = '#AW#',
       MAN_INSPECTION     = '#MAN_INSPECTION#',
       QUALITY_USER       = '#QUALITY_USER#',
       QUALITY_USER_DESC  = '#QUALITY_USER_DESC#',
       OUTPUT_STD_NO      = '#OUTPUT_STD_NO#',
       PROJECT_NO         = '#PROJECT_NO#',
       OUTBOUND_CALCULATE = '#OUTBOUND_CALCULATE#',
       ORDER_TEAM         = '#ORDER_TEAM#',
       MODE_OF_TRANSPORT  = '#MODE_OF_TRANSPORT#'
       WHERE ORD_LN_PK    = '#ORD_LN_PK#'  
			

	]]>
	</query>

	<query id="CoreOrderChangeManage.getOldLnPkOrderLine" desc="获取和同行信息">
	<![CDATA[
			SELECT ORD_PK,
       ORD_LN_PK,
       ORDER_SEQ,
       CUST_ALPHA_NO,
       PSC,
       PSC_DESC,
       MSC,
       MSC_DESC,
       MSC_STYLE,
       USE_CODE,
       USE_DESC,
       PRD_CLS,
       PRODUCCODE,
       PRODUCNAME,
       STD_CODE,
       STD_NAME,
       STEELCODE,
       STEELNAME,
       STD_STYLE,
       STD_STYLE_DESC,
       ORDER_SPEC_CODE,
       ORDER_SPEC_DESC,
       SPEC_CODE,
       SPEC_NAME,
       DIMATER,
       HEIGHT,
       MODEL_CODE,
       MODEL_DESC,
       LEN_NO,
       LEN_DESC,
       LEN_UNIT,
       LEN_MIN,
       LEN_MAX,
       SHRT_LEN_RATO,
       SHORTEST,
       LONG_LEN_RATO,
       LONGEST,
       SHRT_STOVE,
       AVG_LEN_MIN,
       DIFRNC_LEN_MAX,
       ENDLEN_SPECSTD,
       SIGL_LEN,
       ORDER_UNIT,
       ORDER_QTY,
       ORD_ENSU_TOTL_LEN,
       PRDCT_WGT,
       DELVRY_RANGE_TPE,
       DELVRY_RANGE_MIN,
       DELVRY_RANGE_MAX,
       FINAL_USER,
       FINAL_USER_DESC,
       OUTS_BILLET_FL,
       (SELECT BASENAME FROM COM_BASE_INFO WHERE BASECODE = OUTS_BILLET_FL AND VALIDFLAG = '1') OUTS_BILLET_FL_DESC,
       OUTS_STL_PIPE_FL,
       (SELECT BASENAME FROM COM_BASE_INFO WHERE BASECODE = OUTS_STL_PIPE_FL AND VALIDFLAG = '1') OUTS_STL_PIPE_FL_DESC,
       ASSEL_FL,
       PRODUCER_FL,
       PRDCR_NO,
       PRDCR_DESC,
       MPS_FL,
       MPS_NO,
       MPS_DESC,
       DELVRY_BDATE,
       DELVRY_EDATE,
       DELVRY_DESC,
       TRANS_DESC,
       ADD_ASK_NO,
       ORDER_ADD_DESC,
       ORDER_SPECIAL_FL,
       ORDER_SPECIAL_HEAD,
       ORDER_SPECIAL_PATH,
       ORDER_SPECIAL_DESC,
       ZBS,
       ORDER_PRICE,
       TRANS_PRICE,
       TEST_ID,
       TEST_PRICE,
       OUT_PRICE,
       BALNCE_PRICE,
       BE_ORDER_LN_STATUS,
       BE_OBJ_STS_OP,
       ORDER_LN_STATUS,
       OBJ_STS_OP,
       MEMO,
       VALIDFLAG,
       CREATE_NAME,
       CREATE_TIME,
       UPDATE_NAME,
       UPDATE_TIME,
       DELETE_NAME,
       DELETE_TIME,
       ORD_LN_PK_OLD,
       ISLOCK,
       CUST_ALPHA_NO2,
       ORDER_CHGE_NO,
       CHGE_ORD_LN_PK,
       MAN_INSPECTION,
       QUALITY_USER,
       QUALITY_USER_DESC,
       OUTPUT_STD_NO,
       (SELECT BASENAME FROM COM_BASE_INFO A WHERE A.BASECODE = OUTPUT_STD_NO AND A.VALIDFLAG = '1') OUTPUT_STD_NO_DESC,
       PROJECT_NO,OUTBOUND_CALCULATE,ORDER_TEAM,MODE_OF_TRANSPORT
  FROM SLM_ORDER_LINE T
 WHERE T.ORD_LN_PK = ?
			
	]]>
	</query>

	<query id="CoreOrderChangeManage.orderChangeHeadDetail" desc="发运信息转到历史表">
		<![CDATA[
	 		SELECT MANAG_NO,
       ORDER_NO,
       CUSTM_ORDER_NO,
       ORDER_TYP,
       ORDER_TYP_DESC,
       PROTCL_NO,
       CUSTOMER_NO,
       CUSTOMER_NM,
       (SELECT BASENAME FROM COM_BASE_INFO WHERE BASECODE = SUPPLY_UNIT) SUPPLY_UNIT_NM,
       (SELECT BASENAME FROM COM_BASE_INFO WHERE BASECODE = PRICE_FL) PRICE_FL_NM,
       (SELECT BASENAME FROM COM_BASE_INFO WHERE BASECODE = CURRENCY) CURRENCY_NM,
       STLMT_UNIT_NO,
       STLMT_UNIT_NM,
       (SELECT BASENAME FROM COM_BASE_INFO WHERE BASECODE = FST_DRAWEE_UNIT) FST_DRAWEE_UNIT_NM,
       LEGAL_PSN,
       AGENT,
       ADDRESS,
       ZIP_CODE,
       BANK,
       ACCOUNT,
       TAX_ID,
       PHONE,
       FAX,
       ORDER_WGT,
       ORDER_MNY_TAX,
       ORDER_MNY_NTAX,
       MNY_ASK_DESC,
       SIGN_PERSON,
       TO_CHAR(SIGN_DATE, 'YYYY-MM-DD') SIGN_DATE,
       ORDER_BDATE,
       ORDER_EDATE,
       ORDER_SCAN_NO,
       CUSTOMER_MODEL_FL,
       ORDER_MODEL_NO,
       SALE_ORG,
       SALE_ORG_DESC,
       SALE_AREA_NO,
       SALE_AREA_DESC,
       MEMO,
       ORDER_STS,
       (SELECT BASENAME
          FROM COM_BASE_INFO
         WHERE BASECODE = ORDER_STS
           AND VALIDFLAG = '1') ORDER_STS_DESC,
       APPROVAL_MAN,
       APPROVAL_TIME,
       DECODE(VALIDFLAG,'1','TRUE','FALSE') VALIDFLAG,
       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,
       DELETE_NAME,
       TO_CHAR(DELETE_TIME, 'YYYY-MM-DD HH24:MI:SS') DELETE_TIME,
       ORDER_YEAR,
       EFFECT_TIME,
       EFFECT_MAN,
       CLOSE_TIME,
       CLOSE_MAN,
       (SELECT BASENAME FROM COM_BASE_INFO WHERE BASECODE = MNY_ASK_TYP) MNY_ASK_TYP_NM,
       SIGN_ADDRESS,
       SUPPLY_UNIT,
       PRICE_FL,
       CURRENCY,
       FST_DRAWEE_UNIT,
       MNY_ASK_TYP,
       NVL(ORDER_MODEL_DESC, ' ') ORDER_MODEL_DESC,
       ORD_PK,
       CREATE_DEPT,
       MARKET_SYS,
       MARKET_SYS_DESC,
       ABRVITION,
       REVW_RPT_NO,
       ISLOCK,
       ORDER_CHGE_NO,
       PRICE_NO,
       PRINT_PRICE,
       PRICE_PLAN,
       CONTAIN_TAX,
       DECODE(CONTAIN_TAX,'1','是','0','否') CONTAIN_TAX_DESC,
       (SELECT BASENAME FROM COM_BASE_INFO WHERE BASECODE = TRADE_TYPE AND VALIDFLAG = '1') TRADE_TYPE,
       (SELECT BASENAME FROM COM_BASE_INFO WHERE BASECODE = ORDER_CLASSIFY AND VALIDFLAG = '1') ORDER_CLASSIFY,
       BUSINESS_TYPE,
       LOCAL_LAW
        
   FROM SLM_ORDER_HEAD
   WHERE ORDER_NO || '&' LIKE '%' || ? || '%'
   AND CREATE_TIME >= TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS')
   AND CREATE_TIME <= TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS')
   AND VALIDFLAG IN (1, ?)
   AND SALE_ORG = ?
   AND CREATE_DEPT = ?
   AND ORDER_STS  >= '12020301'
   AND ((VALIDFLAG = '0' AND ISLOCK = '1') OR VALIDFLAG = '1')

	 	]]>
	</query>

	<query id="CoreOrderChangeManage.getHeadStatus" desc="获取合同头状态">
	<![CDATA[
	   SELECT ORDER_STS  FROM  SLM_ORDER_HEAD 
	   WHERE ORD_PK = ? AND VALIDFLAG = '1'
	
	]]>
	</query>

	<query id="CoreOrderChangeManage.getApplyStatus" desc="获取合同头状态">
	<![CDATA[
	   SELECT CHGE_STATUS  FROM  CHGE_SLM_APPLY_M 
	   WHERE ORDER_CHGE_NO = ? AND VALIDFLAG = '1'
	
	]]>
	</query>

	<query id="CoreOrderChangeManage.getOrderHeadWithOrdPk" desc="获取合同头状态">
	<![CDATA[
	    SELECT ORD_PK,
       MANAG_NO,
       ORDER_NO,
       CUSTM_ORDER_NO,
       REVW_RPT_NO,
       ORDER_TYP,
       ORDER_TYP_DESC,
       PROTCL_NO,
       CUSTOMER_NO,
       CUSTOMER_NM,
       MARKET_SYS,
       MARKET_SYS_DESC,
       ABRVITION,
       SUPPLY_UNIT, 
       (SELECT BASENAME FROM COM_BASE_INFO WHERE BASECODE = SUPPLY_UNIT AND VALIDFLAG = '1') SUPPLY_UNIT_DESC,
       PRICE_FL,
       (SELECT BASENAME FROM COM_BASE_INFO WHERE BASECODE = PRICE_FL AND VALIDFLAG = '1') PRICE_FL_DESC,
       CURRENCY,
       (SELECT BASENAME FROM COM_BASE_INFO WHERE BASECODE = CURRENCY AND VALIDFLAG = '1') CURRENCY_DESC,
       MNY_ASK_TYP,
       (SELECT BASENAME FROM COM_BASE_INFO WHERE BASECODE = MNY_ASK_TYP AND VALIDFLAG = '1') MNY_ASK_TYP_DESC,
       STLMT_UNIT_NO,
       STLMT_UNIT_NM,
       FST_DRAWEE_UNIT,
       (SELECT BASENAME FROM COM_BASE_INFO WHERE BASECODE = FST_DRAWEE_UNIT AND VALIDFLAG = '1') FST_DRAWEE_UNIT_DESC,
       LEGAL_PSN,
       AGENT,
       ADDRESS,
       ZIP_CODE,
       BANK,
       ACCOUNT,
       TAX_ID,
       PHONE,
       FAX,
       ORDER_WGT,
       ORDER_MNY_TAX,
       ORDER_MNY_NTAX,
       MNY_ASK_DESC,
       SIGN_PERSON,
       TO_CHAR(SIGN_DATE,'YYYY-MM-DD') SIGN_DATE,
       SIGN_ADDRESS,
       ORDER_YEAR,
       ORDER_BDATE,
       ORDER_EDATE,
       ORDER_SCAN_NO,
       CUSTOMER_MODEL_FL,
       ORDER_MODEL_NO,
       ORDER_MODEL_DESC,
       SALE_ORG,
       SALE_ORG_DESC,
       SALE_AREA_NO,
       SALE_AREA_DESC,
       MEMO,
       BE_ORDER_STS,
       BE_OBJ_STS_OP,
       ORDER_STS,
       ORDER_STS_DESC,
       OBJ_STS_OP,
       APPROVAL_MAN,
       APPROVAL_TIME,
       EFFECT_MAN,
       EFFECT_TIME,
       CLOSE_MAN,
       CLOSE_TIME,
       VALIDFLAG,
       CREATE_NAME,
       CREATE_DEPT,
       CREATE_TIME,
       UPDATE_NAME,
       UPDATE_TIME,
       DELETE_NAME,
       DELETE_TIME,
       ORD_PK_OLD,
       BE_ORDER_STS_DESC,
       PRICE_NO,
       ISLOCK,
       PRINT_PRICE,
       PRICE_PLAN,
       CONTAIN_TAX,
       ORDER_CHGE_NO,
       TRADE_TYPE,
       (SELECT BASENAME FROM COM_BASE_INFO WHERE BASECODE = TRADE_TYPE AND VALIDFLAG = '1') TRADE_TYPE_DESC,
       ORDER_CLASSIFY,
       (SELECT BASENAME FROM COM_BASE_INFO WHERE BASECODE = ORDER_CLASSIFY AND VALIDFLAG = '1') ORDER_CLASSIFY_DESC,
       BUSINESS_TYPE,
       LOCAL_LAW
       
  FROM SLM_ORDER_HEAD T
 WHERE T.ORD_PK = ?
   AND T.VALIDFLAG = '1'
	    
	]]>
	</query>

	<query id="CoreOrderChangeManage.InsertChgeOrderHead" desc="插入变更合同头表">
	<![CDATA[
	  INSERT INTO CHGE_SLM_ORDER_HEAD
  (ORD_PK,
   ORDER_NO,
   CUSTM_ORDER_NO,
   REVW_RPT_NO,
   ORDER_TYP,
   ORDER_TYP_DESC,
   PROTCL_NO,
   CUSTOMER_NO,
   CUSTOMER_NM,
   MARKET_SYS,
   MARKET_SYS_DESC,
   ABRVITION,
   SUPPLY_UNIT,
   PRICE_FL,
   CURRENCY,
   MNY_ASK_TYP,
   STLMT_UNIT_NO,
   STLMT_UNIT_NM,
   FST_DRAWEE_UNIT,
   LEGAL_PSN,
   AGENT,
   ADDRESS,
   ZIP_CODE,
   BANK,
   ACCOUNT,
   TAX_ID,
   PHONE,
   FAX,
   ORDER_WGT,
   ORDER_MNY_TAX,
   ORDER_MNY_NTAX,
   MNY_ASK_DESC,
   SIGN_PERSON,
   SIGN_DATE,
   SIGN_ADDRESS,
   ORDER_YEAR,
   ORDER_BDATE,
   ORDER_EDATE,
   ORDER_SCAN_NO,
   CUSTOMER_MODEL_FL,
   ORDER_MODEL_NO,
   ORDER_MODEL_DESC,
   SALE_ORG,
   SALE_ORG_DESC,
   SALE_AREA_NO,
   SALE_AREA_DESC,
   MEMO,
   EFFECT_MAN,
   EFFECT_TIME,
   CLOSE_MAN,
   CLOSE_TIME,
   CREATE_NAME,
   CREATE_DEPT,
   CREATE_TIME,
   UPDATE_NAME,
   UPDATE_TIME,
   ORD_PK_OLD,
   BE_ORDER_STS_DESC,
   PRICE_NO,
   ORDER_CHGE_NO,
   PRINT_PRICE,
   PRICE_PLAN,
   CONTAIN_TAX,
   TRADE_TYPE,
   ORDER_CLASSIFY,
   BUSINESS_TYPE,
   LOCAL_LAW
   )
VALUES
  ('#ORD_PK#',
   '#ORDER_NO#',
   '#CUSTM_ORDER_NO#',
   '#REVW_RPT_NO#',
   '#ORDER_TYP#',
   '#ORDER_TYP_DESC#',
   '#PROTCL_NO#',
   '#CUSTOMER_NO#',
   '#CUSTOMER_NM#',
   '#MARKET_SYS#',
   '#MARKET_SYS_DESC#',
   '#ABRVITION#',
   '#SUPPLY_UNIT#',
   '#PRICE_FL#',
   '#CURRENCY#',
   '#MNY_ASK_TYP#',
   '#STLMT_UNIT_NO#',
   '#STLMT_UNIT_NM#',
   '#FST_DRAWEE_UNIT#',
   '#LEGAL_PSN#',
   '#AGENT#',
   '#ADDRESS#',
   '#ZIP_CODE#',
   '#BANK#',
   '#ACCOUNT#',
   '#TAX_ID#',
   '#PHONE#',
   '#FAX#',
   '#ORDER_WGT#',
   '#ORDER_MNY_TAX#',
   '#ORDER_MNY_NTAX#',
   '#MNY_ASK_DESC#',
   '#SIGN_PERSON#',
   TO_DATE('#SIGN_DATE#','YYYY-MM-DD'),
   '#SIGN_ADDRESS#',
   '#ORDER_YEAR#',
   TO_DATE('#ORDER_BDATE#','YYYY-MM-DD'),
   TO_DATE('#ORDER_EDATE#','YYYY-MM-DD'),
   '#ORDER_SCAN_NO#',
   '#CUSTOMER_MODEL_FL#',
   '#ORDER_MODEL_NO#',
   '#ORDER_MODEL_DESC#',
   '#SALE_ORG#',
   '#SALE_ORG_DESC#',
   '#SALE_AREA_NO#',
   '#SALE_AREA_DESC#',
   '#MEMO#',
   '#EFFECT_MAN#',
   TO_DATE('#EFFECT_TIME#','YYYY-MM-DD HH24:MI:SS'),
   '#CLOSE_MAN#',
   TO_DATE('#CLOSE_TIME#','YYYY-MM-DD HH24:MI:SS'),
   '#CREATE_NAME#',
   '#CREATE_DEPT#',
   TO_DATE('#CREATE_TIME#','YYYY-MM-DD HH24:MI:SS'),
   '#UPDATE_NAME#',
    SYSDATE,
   '#ORD_PK_OLD#',
   '#BE_ORDER_STS_DESC#',
   '#PRICE_NO#',
   '#ORDER_CHGE_NO#',
   '#PRINT_PRICE#',
   '#PRICE_PLAN#',
   '#CONTAIN_TAX#',
   '#TRADE_TYPE#',
   '#ORDER_CLASSIFY#',
   '#BUSINESS_TYPE#',
   '#LOCAL_LAW#'
   )
	  
	]]>
	</query>

	<query id="CoreOrderChangeManage.updateChgeSlmApplyMInfo" desc="修改修改后的交货行的状态">
		<![CDATA[
	   UPDATE CHGE_SLM_APPLY_M
   SET ORD_LN_PK_AFTER     = '#ORD_LN_PK_AFTER#',
       ORDER_NO            = '#ORDER_NO#',
       ORDER_SEQ           = '#ORDER_SEQ#',
       DELIVERY_NO         = '#DELIVERY_NO#',
       ORDER_CHGE_NO       = '#ORDER_CHGE_NO#',
       ORD_PK              = '#ORD_PK#',
       ORD_LN_PK           = '#ORD_LN_PK#',
       ORD_LN_DLY_PK       = '#ORD_LN_DLY_PK#',
       DEPARTMENT_CODE     = '#DEPARTMENT_CODE#',
       DEPARTMENT_DESC     = '#DEPARTMENT_DESC#',
       UNIT_CODE           = '#UNIT_CODE#',
       UNIT_DESC           = '#UNIT_DESC#',
       CHGE_TYPE           = '#CHGE_TYPE#',
       CHGER               = '#CHGER#',
       CHGE_DATE           = SYSDATE,
       CHGE_VAL            = '#CHGE_VAL#',
       CHGE_RSN            = '#CHGE_RSN#',
       ACP_DEPARTMENT_CODE = '#ACP_DEPARTMENT_CODE#',
       ACP_DEPARTMENT_DESC = '#ACP_DEPARTMENT_DESC#',
       ACP_UNIT_CODE       = '#ACP_UNIT_CODE#',
       ACP_UNIT_DESC       = '#ACP_UNIT_DESC#',
       ACCEPTOR            = '#ACCEPTOR#',
       CHGE_STATUS         = '#CHGE_STATUS#',
       CHGE_PATCH          = '#CHGE_PATCH#',
       MEMO                = '#MEMO#',
       UPDATE_NAME         = '#UPDATE_NAME#',
       UPDATE_TIME         = SYSDATE

       WHERE ORDER_CHGE_NO = '#ORDER_CHGE_NO#'
	   
	 	]]>
	</query>


	<query id="CoreOrderChangeManage.SelectChgeOrderHead" desc="修改修改后的交货行的状态">
		<![CDATA[
		 SELECT 1 FROM  CHGE_SLM_ORDER_HEAD  T
		 WHERE T.ORD_PK = ? AND  T.VALIDFLAG = '1'
		
		]]>
	</query>

	<query id="CoreOrderChangeManage.UpdateChgeOrderHead" desc="修改修改后的交货行的状态">
		<![CDATA[
		 UPDATE CHGE_SLM_ORDER_HEAD
   SET ORD_PK            = '#ORD_PK#',
       MANAG_NO          = '#MANAG_NO#',
       ORDER_NO          = '#ORDER_NO#',
       CUSTM_ORDER_NO    = '#CUSTM_ORDER_NO#',
       REVW_RPT_NO       = '#REVW_RPT_NO#',
       ORDER_TYP         = '#ORDER_TYP#',
       ORDER_TYP_DESC    = '#ORDER_TYP_DESC#',
       PROTCL_NO         = '#PROTCL_NO#',
       CUSTOMER_NO       = '#CUSTOMER_NO#',
       CUSTOMER_NM       = '#CUSTOMER_NM#',
       MARKET_SYS        = '#MARKET_SYS#',
       MARKET_SYS_DESC   = '#MARKET_SYS_DESC#',
       ABRVITION         = '#ABRVITION#',
       SUPPLY_UNIT       = '#SUPPLY_UNIT#',
       PRICE_FL          = '#PRICE_FL#',
       CURRENCY          = '#CURRENCY#',
       MNY_ASK_TYP       = '#MNY_ASK_TYP#',
       STLMT_UNIT_NO     = '#STLMT_UNIT_NO#',
       STLMT_UNIT_NM     = '#STLMT_UNIT_NM#',
       FST_DRAWEE_UNIT   = '#FST_DRAWEE_UNIT#',
       LEGAL_PSN         = '#LEGAL_PSN#',
       AGENT             = '#AGENT#',
       ADDRESS           = '#ADDRESS#',
       ZIP_CODE          = '#ZIP_CODE#',
       BANK              = '#BANK#',
       ACCOUNT           = '#ACCOUNT#',
       TAX_ID            = '#TAX_ID#',
       PHONE             = '#PHONE#',
       FAX               = '#FAX#',
       ORDER_WGT         = '#ORDER_WGT#',
       ORDER_MNY_TAX     = '#ORDER_MNY_TAX#',
       ORDER_MNY_NTAX    = '#ORDER_MNY_NTAX#',
       MNY_ASK_DESC      = '#MNY_ASK_DESC#',
       SIGN_PERSON       = '#SIGN_PERSON#',
       SIGN_DATE         = TO_DATE('#SIGN_DATE#','YYYY-MM-DD'),
       SIGN_ADDRESS      = '#SIGN_ADDRESS#',
       ORDER_YEAR        = '#ORDER_YEAR#',
       ORDER_BDATE       = TO_DATE('#ORDER_BDATE#','YYYY-MM-DD'),
       ORDER_EDATE       = TO_DATE('#ORDER_EDATE#','YYYY-MM-DD'),
       ORDER_SCAN_NO     = '#ORDER_SCAN_NO#',
       CUSTOMER_MODEL_FL = '#CUSTOMER_MODEL_FL#',
       ORDER_MODEL_NO    = '#ORDER_MODEL_NO#',
       ORDER_MODEL_DESC  = '#ORDER_MODEL_DESC#',
       SALE_ORG          = '#SALE_ORG#',
       SALE_ORG_DESC     = '#SALE_ORG_DESC#',
       SALE_AREA_NO      = '#SALE_AREA_NO#',
       SALE_AREA_DESC    = '#SALE_AREA_DESC#',
       MEMO              = '#MEMO#',
       BE_ORDER_STS      = '#BE_ORDER_STS#',
       BE_OBJ_STS_OP     = '#BE_OBJ_STS_OP#',
       ORDER_STS         = '#ORDER_STS#',
       ORDER_STS_DESC    = '#ORDER_STS_DESC#',
       OBJ_STS_OP        = '#OBJ_STS_OP#',
       APPROVAL_MAN      = '#APPROVAL_MAN#',
       APPROVAL_TIME     = '#APPROVAL_TIME#',
       EFFECT_MAN        = '#EFFECT_MAN#',
       EFFECT_TIME       = TO_DATE('#EFFECT_TIME#','YYYY-MM-DD HH24:MI:SS'),
       CLOSE_MAN         = '#CLOSE_MAN#',
       CLOSE_TIME        = TO_DATE('#CLOSE_TIME#','YYYY-MM-DD HH24:MI:SS'),
       UPDATE_NAME       = '#UPDATE_NAME#',
       UPDATE_TIME       =  SYSDATE,
       ORD_PK_OLD        = '#ORD_PK_OLD#',
       BE_ORDER_STS_DESC = '#BE_ORDER_STS_DESC#',
       PRICE_NO          = '#PRICE_NO#',
       PRINT_PRICE       = '#PRINT_PRICE#',  
       PRICE_PLAN        = '#PRICE_PLAN#',
       CONTAIN_TAX       = '#CONTAIN_TAX#',
       TRADE_TYPE        = '#TRADE_TYPE#',
       ORDER_CLASSIFY    = '#ORDER_CLASSIFY#',
       BUSINESS_TYPE     = '#BUSINESS_TYPE#',
       LOCAL_LAW         = '#LOCAL_LAW#'
       
       WHERE ORD_PK = '#ORD_PK#'
		 
		
		]]>
	</query>

	<query id="CoreOrderChangeManage.UpdateOrderHeadStatus" desc="锁定原来的合同头">
		UPDATE SLM_ORDER_HEAD
		SET ISLOCK = ?

		WHERE ORD_PK = ?


	</query>

	<query id="CoreOrderChangeManage.UpdateOrderHeadChgeNo" desc="锁定原来的合同头">

		UPDATE SLM_ORDER_HEAD
		SET
		ORDER_CHGE_NO = ?
		WHERE ORD_PK = ?

	</query>

	<query id="CoreOrderChangeManage.DeleteChgeOrderHead" desc="锁定原来的合同头">
		DELETE FROM CHGE_SLM_ORDER_HEAD
		WHERE ORD_PK = ?

	</query>

	<query id="CoreOrderChangeManage.SelectOrderHeadInfo" desc="获取合同头状态">
	<![CDATA[
	   SELECT ORDER_CHGE_NO,
       ORD_PK,
       MANAG_NO,
       ORDER_NO,
       CUSTM_ORDER_NO,
       REVW_RPT_NO,
       ORDER_TYP,
       ORDER_TYP_DESC,
       PROTCL_NO,
       CUSTOMER_NO,
       CUSTOMER_NM,
       MARKET_SYS,
       MARKET_SYS_DESC,
       ABRVITION,
       SUPPLY_UNIT,
       PRICE_FL,
       CURRENCY,
       MNY_ASK_TYP,
       STLMT_UNIT_NO,
       STLMT_UNIT_NM,
       FST_DRAWEE_UNIT,
       LEGAL_PSN,
       AGENT,
       ADDRESS,
       ZIP_CODE,
       BANK,
       ACCOUNT,
       TAX_ID,
       PHONE,
       FAX,
       ORDER_WGT,
       ORDER_MNY_TAX,
       ORDER_MNY_NTAX,
       MNY_ASK_DESC,
       SIGN_PERSON,
       TO_CHAR(SIGN_DATE, 'YYYY-MM-DD') SIGN_DATE,
       SIGN_ADDRESS,
       ORDER_YEAR,
       TO_CHAR(ORDER_BDATE, 'YYYY-MM-DD') ORDER_BDATE,
       TO_CHAR(ORDER_EDATE, 'YYYY-MM-DD') ORDER_EDATE,
       ORDER_SCAN_NO,
       CUSTOMER_MODEL_FL,
       ORDER_MODEL_NO,
       ORDER_MODEL_DESC,
       SALE_ORG,
       SALE_ORG_DESC,
       SALE_AREA_NO,
       SALE_AREA_DESC,
       MEMO,
       BE_ORDER_STS,
       BE_OBJ_STS_OP,
       ORDER_STS,
       ORDER_STS_DESC,
       OBJ_STS_OP,
       APPROVAL_MAN,
       TO_CHAR(APPROVAL_TIME, 'YYYY-MM-DD HH24:MI:SS') APPROVAL_TIME,
       EFFECT_MAN,
       TO_CHAR(EFFECT_TIME, 'YYYY-MM-DD HH24:MI:SS') EFFECT_TIME,
       CLOSE_MAN,
       TO_CHAR(CLOSE_TIME, 'YYYY-MM-DD HH24:MI:SS') CLOSE_TIME,
       VALIDFLAG,
       CREATE_NAME,
       CREATE_DEPT,
       TO_CHAR(CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       ISLOCK,
       BE_ORDER_STS_DESC,
       UPDATE_NAME,
       TO_CHAR(UPDATE_TIME, 'YYYY-MM-DD HH24:MI:SS') UPDATE_TIME,
       DELETE_NAME,
       TO_CHAR(DELETE_TIME, 'YYYY-MM-DD HH24:MI:SS') DELETE_TIME,
       ORD_PK_OLD,
       PRICE_NO,
       PRINT_PRICE,
       PRICE_PLAN,
	   CONTAIN_TAX,
	   TRADE_TYPE,
       ORDER_CLASSIFY,
       BUSINESS_TYPE
	   
       FROM SLM_ORDER_HEAD
       WHERE ORD_PK = ?
	   
	
	]]>
	</query>

	<query id="CoreOrderChangeManage.InsertOrderHeadHis" desc="写入合同头历史表">
	<![CDATA[
	INSERT INTO CHGE_SLM_ORDER_HEAD_H
  (ORDER_CHGE_NO,
   ORD_PK,
   MANAG_NO,
   ORDER_NO,
   CUSTM_ORDER_NO,
   REVW_RPT_NO,
   ORDER_TYP,
   ORDER_TYP_DESC,
   PROTCL_NO,
   CUSTOMER_NO,
   CUSTOMER_NM,
   MARKET_SYS,
   MARKET_SYS_DESC,
   ABRVITION,
   SUPPLY_UNIT,
   PRICE_FL,
   CURRENCY,
   MNY_ASK_TYP,
   STLMT_UNIT_NO,
   STLMT_UNIT_NM,
   FST_DRAWEE_UNIT,
   ISLOCK,
   LEGAL_PSN,
   AGENT,
   ADDRESS,
   ZIP_CODE,
   BANK,
   ACCOUNT,
   TAX_ID,
   PHONE,
   FAX,
   ORDER_WGT,
   ORDER_MNY_TAX,
   ORDER_MNY_NTAX,
   MNY_ASK_DESC,
   SIGN_PERSON,
   SIGN_DATE,
   SIGN_ADDRESS,
   ORDER_YEAR,
   ORDER_BDATE,
   ORDER_EDATE,
   ORDER_SCAN_NO,
   CUSTOMER_MODEL_FL,
   ORDER_MODEL_NO,
   ORDER_MODEL_DESC,
   SALE_ORG,
   SALE_ORG_DESC,
   SALE_AREA_NO,
   SALE_AREA_DESC,
   MEMO,
   BE_ORDER_STS,
   BE_OBJ_STS_OP,
   ORDER_STS,
   ORDER_STS_DESC,
   OBJ_STS_OP,
   APPROVAL_MAN,
   APPROVAL_TIME,
   EFFECT_MAN,
   EFFECT_TIME,
   CLOSE_MAN,
   CLOSE_TIME,
   VALIDFLAG,
   CREATE_NAME,
   CREATE_DEPT,
   CREATE_TIME,
   UPDATE_NAME,
   UPDATE_TIME,
   ORD_PK_OLD,
   BE_ORDER_STS_DESC,
   PRICE_NO,
   PRINT_PRICE,
   PRICE_PLAN,
   CONTAIN_TAX,
   TRADE_TYPE,
   ORDER_CLASSIFY,
   BUSINESS_TYPE,
   LOCAL_LAW
   
   )
VALUES
  ('#ORDER_CHGE_NO#',
   '#ORD_PK#',
   '#MANAG_NO#',
   '#ORDER_NO#',
   '#CUSTM_ORDER_NO#',
   '#REVW_RPT_NO#',
   '#ORDER_TYP#',
   '#ORDER_TYP_DESC#',
   '#PROTCL_NO#',
   '#CUSTOMER_NO#',
   '#CUSTOMER_NM#',
   '#MARKET_SYS#',
   '#MARKET_SYS_DESC#',
   '#ABRVITION#',
   '#SUPPLY_UNIT#',
   '#PRICE_FL#',
   '#CURRENCY#',
   '#MNY_ASK_TYP#',
   '#STLMT_UNIT_NO#',
   '#STLMT_UNIT_NM#',
   '#FST_DRAWEE_UNIT#',
   '#ISLOCK#',
   '#LEGAL_PSN#',
   '#AGENT#',
   '#ADDRESS#',
   '#ZIP_CODE#',
   '#BANK#',
   '#ACCOUNT#',
   '#TAX_ID#',
   '#PHONE#',
   '#FAX#',
   '#ORDER_WGT#',
   '#ORDER_MNY_TAX#',
   '#ORDER_MNY_NTAX#',
   '#MNY_ASK_DESC#',
   '#SIGN_PERSON#',
   TO_DATE('#SIGN_DATE#','YYYY-MM-DD'),
   '#SIGN_ADDRESS#',
   '#ORDER_YEAR#',
   TO_DATE('#ORDER_BDATE#','YYYY-MM-DD'),
   TO_DATE('#ORDER_EDATE#','YYYY-MM-DD'),
   '#ORDER_SCAN_NO#',
   '#CUSTOMER_MODEL_FL#',
   '#ORDER_MODEL_NO#',
   '#ORDER_MODEL_DESC#',
   '#SALE_ORG#',
   '#SALE_ORG_DESC#',
   '#SALE_AREA_NO#',
   '#SALE_AREA_DESC#',
   '#MEMO#',
   '#BE_ORDER_STS#',
   '#BE_OBJ_STS_OP#',
   '#ORDER_STS#',
   '#ORDER_STS_DESC#',
   '#OBJ_STS_OP#',
   '#APPROVAL_MAN#',
   TO_DATE('#APPROVAL_TIME#','YYYY-MM-DD HH24:MI:SS'),
   '#EFFECT_MAN#',
   TO_DATE('#EFFECT_TIME#','YYYY-MM-DD HH24:MI:SS'),
   '#CLOSE_MAN#',
   TO_DATE('#CLOSE_TIME#','YYYY-MM-DD HH24:MI:SS'),
   '#VALIDFLAG#',
   '#CREATE_NAME#',
   '#CREATE_DEPT#',
   TO_DATE('#CREATE_TIME#','YYYY-MM-DD HH24:MI:SS'),
   '#UPDATE_NAME#',
   TO_DATE('#UPDATE_TIME#','YYYY-MM-DD HH24:MI:SS'),
   '#ORD_PK_OLD#',
   '#BE_ORDER_STS_DESC#',
   '#PRICE_NO#',
   '#PRINT_PRICE#',
   '#PRICE_PLAN#',
   '#CONTAIN_TAX#',
   '#TRADE_TYPE#',
   '#ORDER_CLASSIFY#',
   '#BUSINESS_TYPE#',
   '#LOCAL_LAW#'
   )
	
	]]>
	</query>

	<query id="CoreOrderChangeManage.SelectChgeOrderHeadInfo" desc="写入合同头历史表">
	<![CDATA[
 	SELECT ORD_PK,
       MANAG_NO,
       ORDER_NO,
       CUSTM_ORDER_NO,
       REVW_RPT_NO,
       ORDER_TYP,
       ORDER_TYP_DESC,
       PROTCL_NO,
       CUSTOMER_NO,
       CUSTOMER_NM,
       MARKET_SYS,
       MARKET_SYS_DESC,
       ABRVITION,
       SUPPLY_UNIT,
       PRICE_FL,
       CURRENCY,
       MNY_ASK_TYP,
       STLMT_UNIT_NO,
       STLMT_UNIT_NM,
       FST_DRAWEE_UNIT,
       LEGAL_PSN,
       AGENT,
       ADDRESS,
       ZIP_CODE,
       BANK,
       ACCOUNT,
       TAX_ID,
       PHONE,
       FAX,
       ORDER_WGT,
       ORDER_MNY_TAX,
       ORDER_MNY_NTAX,
       MNY_ASK_DESC,
       SIGN_PERSON,
       TO_CHAR(SIGN_DATE, 'YYYY-MM-DD') SIGN_DATE,
       SIGN_ADDRESS,
       ORDER_YEAR,
       TO_CHAR(ORDER_BDATE, 'YYYY-MM-DD') ORDER_BDATE,
       TO_CHAR(ORDER_EDATE, 'YYYY-MM-DD') ORDER_EDATE,
       ORDER_SCAN_NO,
       CUSTOMER_MODEL_FL,
       ORDER_MODEL_NO,
       ORDER_MODEL_DESC,
       SALE_ORG,
       SALE_ORG_DESC,
       SALE_AREA_NO,
       SALE_AREA_DESC,
       MEMO,
       BE_ORDER_STS,
       BE_OBJ_STS_OP,
       ORDER_STS,
       ORDER_STS_DESC,
       OBJ_STS_OP,
       APPROVAL_MAN,
       TO_CHAR(APPROVAL_TIME, 'YYYY-MM-DD HH24:MI:SS') APPROVAL_TIME,
       EFFECT_MAN,
       TO_CHAR(EFFECT_TIME, 'YYYY-MM-DD HH24:MI:SS') EFFECT_TIME,
       CLOSE_MAN,
       TO_CHAR(CLOSE_TIME, 'YYYY-MM-DD HH24:MI:SS') CLOSE_TIME,
       VALIDFLAG,
       CREATE_NAME,
       CREATE_DEPT,
       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,
       DELETE_NAME,
       TO_CHAR(DELETE_TIME, 'YYYY-MM-DD HH24:MI:SS') DELETE_TIME,
       ORD_PK_OLD,
       BE_ORDER_STS_DESC,
       PRICE_NO,
       ORDER_CHGE_NO,
       PRINT_PRICE ,
       PRICE_PLAN,
	   CONTAIN_TAX,
	   TRADE_TYPE,
	   ORDER_CLASSIFY,
       BUSINESS_TYPE,
       LOCAL_LAW
	     
   FROM CHGE_SLM_ORDER_HEAD
   WHERE ORD_PK = ?
 	
	]]>
	</query>

	<query id="CoreOrderChangeManage.UpdateOrderHeadUseChgeOrderHead"
		desc="将变更数据写入原合同头">
	<![CDATA[
	UPDATE SLM_ORDER_HEAD
    SET ORDER_CHGE_NO    = '#ORDER_CHGE_NO#',
       ORD_PK            = '#ORD_PK#',
       ORDER_NO          = '#ORDER_NO#',
       CUSTM_ORDER_NO    = '#CUSTM_ORDER_NO#',
       ORDER_TYP         = '#ORDER_TYP#',
       ORDER_TYP_DESC    = '#ORDER_TYP_DESC#',
       PROTCL_NO         = '#PROTCL_NO#',
       CUSTOMER_NO       = '#CUSTOMER_NO#',
       CUSTOMER_NM       = '#CUSTOMER_NM#',
       MARKET_SYS        = '#MARKET_SYS#',
       MARKET_SYS_DESC   = '#MARKET_SYS_DESC#',
       ABRVITION         = '#ABRVITION#',
       SUPPLY_UNIT       = '#SUPPLY_UNIT#',
       PRICE_FL          = '#PRICE_FL#',
       CURRENCY          = '#CURRENCY#',
       MNY_ASK_TYP       = '#MNY_ASK_TYP#',
       STLMT_UNIT_NO     = '#STLMT_UNIT_NO#',
       STLMT_UNIT_NM     = '#STLMT_UNIT_NM#',
       FST_DRAWEE_UNIT   = '#FST_DRAWEE_UNIT#',
       LEGAL_PSN         = '#LEGAL_PSN#',
       AGENT             = '#AGENT#',
       ADDRESS           = '#ADDRESS#',
       ZIP_CODE          = '#ZIP_CODE#',
       BANK              = '#BANK#',
       ACCOUNT           = '#ACCOUNT#',
       TAX_ID            = '#TAX_ID#',
       PHONE             = '#PHONE#',
       FAX               = '#FAX#',
       ORDER_WGT         = '#ORDER_WGT#',
       ORDER_MNY_TAX     = '#ORDER_MNY_TAX#',
       ORDER_MNY_NTAX    = '#ORDER_MNY_NTAX#',
       MNY_ASK_DESC      = '#MNY_ASK_DESC#',
       SIGN_PERSON       = '#SIGN_PERSON#',
       SIGN_DATE         = TO_DATE('#SIGN_DATE#','YYYY-MM-DD'),
       SIGN_ADDRESS      = '#SIGN_ADDRESS#',
       ORDER_YEAR        = '#ORDER_YEAR#',
       ORDER_BDATE       = TO_DATE('#ORDER_BDATE#','YYYY-MM-DD'),
       ORDER_EDATE       = TO_DATE('#ORDER_EDATE#','YYYY-MM-DD'),
       ORDER_SCAN_NO     = '#ORDER_SCAN_NO#',
       CUSTOMER_MODEL_FL = '#CUSTOMER_MODEL_FL#',
       ORDER_MODEL_NO    = '#ORDER_MODEL_NO#',
       ORDER_MODEL_DESC  = '#ORDER_MODEL_DESC#',
       SALE_ORG          = '#SALE_ORG#',
       SALE_ORG_DESC     = '#SALE_ORG_DESC#',
       SALE_AREA_NO      = '#SALE_AREA_NO#',
       SALE_AREA_DESC    = '#SALE_AREA_DESC#',
       MEMO              = '#MEMO#',
       UPDATE_NAME       = '#UPDATE_NAME#',
       UPDATE_TIME       = SYSDATE,
       PRINT_PRICE       = '#PRINT_PRICE#',
       PRICE_PLAN        = '#PRICE_PLAN#',
       CONTAIN_TAX       = '#CONTAIN_TAX#',
       TRADE_TYPE        = '#TRADE_TYPE#',
       ORDER_CLASSIFY    = '#ORDER_CLASSIFY#',
       BUSINESS_TYPE     = '#BUSINESS_TYPE#',
       LOCAL_LAW         = '#LOCAL_LAW#'
       WHERE ORD_PK = '#ORD_PK#'
	
	]]>
	</query>
	<query id="CoreOrderChangeManage.getOrderHeadInfoAgo" desc="合同头修改前的信息">
	<![CDATA[
	SELECT ORDER_CHGE_NO,
       ORD_PK,
       MANAG_NO,
       ORDER_NO,
       CUSTM_ORDER_NO,
       REVW_RPT_NO,
       ORDER_TYP,
       (SELECT BASENAME FROM COM_BASE_INFO WHERE BASECODE = ORDER_TYP) ORDER_TYP_DESC,
       PROTCL_NO,
       CUSTOMER_NO,
       CUSTOMER_NM,
       MARKET_SYS,
       MARKET_SYS_DESC,
       ABRVITION,
       (SELECT BASENAME FROM COM_BASE_INFO WHERE BASECODE = SUPPLY_UNIT )  SUPPLY_UNIT,
       (SELECT BASENAME FROM COM_BASE_INFO WHERE BASECODE = PRICE_FL) PRICE_FL,
       (SELECT BASENAME FROM COM_BASE_INFO WHERE BASECODE = CURRENCY) CURRENCY,
       (SELECT BASENAME FROM COM_BASE_INFO WHERE BASECODE = MNY_ASK_TYP) MNY_ASK_TYP,
       STLMT_UNIT_NO,
       STLMT_UNIT_NM,
       (SELECT BASENAME FROM COM_BASE_INFO WHERE BASECODE = FST_DRAWEE_UNIT) FST_DRAWEE_UNIT,
       LEGAL_PSN,
       AGENT,
       ADDRESS,
       ZIP_CODE,
       BANK,
       ACCOUNT,
       TAX_ID,
       PHONE,
       FAX,
       ORDER_WGT,
       ORDER_MNY_TAX,
       ORDER_MNY_NTAX,
       MNY_ASK_DESC,
       SIGN_PERSON,
       TO_CHAR(SIGN_DATE, 'YYYY-MM-DD') SIGN_DATE,
       SIGN_ADDRESS,
       ORDER_YEAR,
       TO_CHAR(ORDER_BDATE, 'YYYY-MM-DD') ORDER_BDATE,
       TO_CHAR(ORDER_EDATE, 'YYYY-MM-DD') ORDER_EDATE,
       ORDER_SCAN_NO,
       CUSTOMER_MODEL_FL,
       ORDER_MODEL_NO,
       ORDER_MODEL_DESC,
       SALE_ORG,
       SALE_ORG_DESC,
       SALE_AREA_NO,
       SALE_AREA_DESC,
       MEMO,
       BE_ORDER_STS,
       BE_OBJ_STS_OP,
       ORDER_STS,
       (SELECT BASENAME FROM  COM_BASE_INfO WHERE BASECODE = ORDER_STS) ORDER_STS_DESC,
       OBJ_STS_OP,
       APPROVAL_MAN,
       TO_CHAR(APPROVAL_TIME, 'YYYY-MM-DD HH24:MI:SS') APPROVAL_TIME,
       EFFECT_MAN,
       TO_CHAR(EFFECT_TIME, 'YYYY-MM-DD HH24:MI:SS') EFFECT_TIME,
       CLOSE_MAN,
       TO_CHAR(CLOSE_TIME, 'YYYY-MM-DD HH24:MI:SS') CLOSE_TIME,
       DECODE(VALIDFLAG,'1','有效','无效') VALIDFLAG,
       CREATE_NAME,
       CREATE_DEPT,
       TO_CHAR(CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       ISLOCK,
       BE_ORDER_STS_DESC,
       UPDATE_NAME,
       TO_CHAR(UPDATE_TIME, 'YYYY-MM-DD HH24:MI:SS') UPDATE_TIME,
       DELETE_NAME,
       TO_CHAR(DELETE_TIME, 'YYYY-MM-DD HH24:MI:SS') DELETE_TIME,
       ORD_PK_OLD,
       PRICE_NO
       FROM SLM_ORDER_HEAD
       WHERE ORD_PK = ?
	
	]]>
	</query>

	<query id="CoreOrderChangeManage.getOrderHeadInfoAfter" desc="合同头修改后的信息">
	<![CDATA[
	
	SELECT ORDER_CHGE_NO,
       ORD_PK,
       MANAG_NO,
       ORDER_NO,
       CUSTM_ORDER_NO,
       REVW_RPT_NO,
       ORDER_TYP,
       (SELECT BASENAME FROM COM_BASE_INFO WHERE BASECODE = ORDER_TYP ) ORDER_TYP_DESC,
       PROTCL_NO,
       CUSTOMER_NO,
       CUSTOMER_NM,
       MARKET_SYS,
       MARKET_SYS_DESC,
       ABRVITION,
        (SELECT BASENAME FROM COM_BASE_INFO WHERE BASECODE = SUPPLY_UNIT )  SUPPLY_UNIT,
       (SELECT BASENAME FROM COM_BASE_INFO WHERE BASECODE = PRICE_FL ) PRICE_FL,
       (SELECT BASENAME FROM COM_BASE_INFO WHERE BASECODE = CURRENCY ) CURRENCY,
       (SELECT BASENAME FROM COM_BASE_INFO WHERE BASECODE = MNY_ASK_TYP ) MNY_ASK_TYP,
       STLMT_UNIT_NO,
       STLMT_UNIT_NM,
       (SELECT BASENAME FROM COM_BASE_INFO WHERE BASECODE = FST_DRAWEE_UNIT ) FST_DRAWEE_UNIT,
       LEGAL_PSN,
       AGENT,
       ADDRESS,
       ZIP_CODE,
       BANK,
       ACCOUNT,
       TAX_ID,
       PHONE,
       FAX,
       ORDER_WGT,
       ORDER_MNY_TAX,
       ORDER_MNY_NTAX,
       MNY_ASK_DESC,
       SIGN_PERSON,
       TO_CHAR(SIGN_DATE, 'YYYY-MM-DD') SIGN_DATE,
       SIGN_ADDRESS,
       ORDER_YEAR,
       TO_CHAR(ORDER_BDATE, 'YYYY-MM-DD') ORDER_BDATE,
       TO_CHAR(ORDER_EDATE, 'YYYY-MM-DD') ORDER_EDATE,
       ORDER_SCAN_NO,
       CUSTOMER_MODEL_FL,
       ORDER_MODEL_NO,
       ORDER_MODEL_DESC,
       SALE_ORG,
       SALE_ORG_DESC,
       SALE_AREA_NO,
       SALE_AREA_DESC,
       MEMO,
       BE_ORDER_STS,
       BE_OBJ_STS_OP,
       ORDER_STS,
       (SELECT BASENAME FROM COM_BASE_INFO WHERE BASECODE = ORDER_STS )  ORDER_STS_DESC,
       OBJ_STS_OP,
       APPROVAL_MAN,
       TO_CHAR(APPROVAL_TIME, 'YYYY-MM-DD HH24:MI:SS') APPROVAL_TIME,
       EFFECT_MAN,
       TO_CHAR(EFFECT_TIME, 'YYYY-MM-DD HH24:MI:SS') EFFECT_TIME,
       CLOSE_MAN,
       TO_CHAR(CLOSE_TIME, 'YYYY-MM-DD HH24:MI:SS') CLOSE_TIME,
        DECODE(VALIDFLAG,'1','有效','无效') VALIDFLAG,
       CREATE_NAME,
       CREATE_DEPT,
       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,
       DELETE_NAME,
       TO_CHAR(DELETE_TIME, 'YYYY-MM-DD HH24:MI:SS') DELETE_TIME,
       ORD_PK_OLD,
       BE_ORDER_STS_DESC,
       PRICE_NO
       FROM CHGE_SLM_ORDER_HEAD
       WHERE ORD_PK = ?
	
	]]>
	</query>


	<query id="CoreOrderChangeManage.generateApprovalNo" desc="生成审批单号">
		<![CDATA[
		
		SELECT ? || LPAD(TO_NUMBER(NVL(SUBSTR(MAX(APPROVAL_NO), 11, 4), '0')) + 1,
                         '4',
                         '0')
          FROM CHGE_SLM_APPLY_M
         WHERE SUBSTR(APPROVAL_NO, 1, 10) = ?

		]]>
	</query>

	<query id="CoreOrderChangeManage.updateApprovalNo" desc="生成审批单号">
		<![CDATA[
		
	 UPDATE CHGE_SLM_APPLY_M
     SET APPROVAL_NO =  ?
      WHERE ORDER_CHGE_NO = ?
      AND APPROVAL_NO IS NULL
		]]>
	</query>

	<query id="CoreOrderChangeManage.selectOrderHeadApply" desc="生成审批单号">
		<![CDATA[
		
	 	SELECT 1 FROM CHGE_SLM_APPLY_M T
	 	WHERE T.ORD_PK = ? AND T.ORD_LN_PK IS NULL
	 	AND INSTR(T.CHGE_TYPE,'合同头')>0
       
		]]>
	</query>

	<query id="CoreOrderChangeManage.updateOrderHeadDelete" desc="生成审批单号">
		<![CDATA[
		
	 	 UPDATE SLM_ORDER_HEAD T
	 	 SET T.ISLOCK = '1',
	 	 	 T.VALIDFLAG = '0',
	 	 	 T.ORDER_CHGE_NO = ?
	 	 WHERE T.ORD_PK = ?
	 	 	     
		]]>
	</query>

	<query id="CoreOrderChangeManage.updateOrderHeadResume" desc="生成审批单号">
		<![CDATA[
		
	 	 UPDATE SLM_ORDER_HEAD T
	 	 SET T.ISLOCK = '0',
	 	 	 T.VALIDFLAG = '1',
	 	 	 T.ORDER_CHGE_NO = ?
	 	 WHERE T.ORD_PK = ?
	 	 	     
		]]>
	</query>
	
	<query id="CoreOrderChangeManage.ClearOrderPrice" desc="生成审批单号">
		<![CDATA[
		
	 	 DELETE FROM SLM_ORDER_PRICE T WHERE T.PRICE_NO = ?
	 	 	     
		]]>
	</query>
	
	<query id="CoreOrderChangeManage.ClearOrderPriceList" desc="生成审批单号">
		<![CDATA[
		
	 	   DELETE FROM SLM_ORDER_PRICE_LIST T WHERE T.PRICE_NO = ?
		]]>
	</query>
	
	<query id="CoreOrderChangeManage.ClearOrderPriceNo" desc="生成审批单号">
		<![CDATA[
		
	 	   UPDATE   SLM_ORDER_HEAD T 
	 	   SET T.PRICE_NO = ''
	 	   WHERE  T.ORD_PK =  ?
		]]>
	</query>
	
	<query id="CoreOrderChangeManage.QueryOrderPriceNo" desc="生成审批单号">
		<![CDATA[
		
	 	   SELECT PRICE_NO FROM  SLM_ORDER_HEAD T 
	 	   WHERE  T.ORD_PK =  ? AND T.VALIDFLAG = '1'
		]]>
	</query>
	
	<query id="CoreOrderChangeManage.ClearOrderLinePriceStatus" desc="生成审批单号">
		<![CDATA[
		
	 	  UPDATE  SLM_ORDER_LINE T 
	 	  SET T.BALNCE_PRICE_STS = '0',
	 	      T.BALNCE_PRICE_ORG_STS = '0'
	 	  WHERE  T.ORD_PK =  ? 
	 	  AND T.VALIDFLAG = '1'
		]]>
	</query>
	
	<query id="CoreOrderChangeManage.queryCraftDesignStatus" desc="生成审批单号">
		<![CDATA[
		
	 	  SELECT 1 FROM CRAFT_ORD_DESIGN T
	 	  WHERE T.ORD_LN_PK = ?
	 	  AND T.LOCK_FLAG= '1'
	 	  AND T.VALIDFLAG = '1'
		]]>
	</query>
	
	<query id="CoreOrderChangeManage.queryPlnSaleOrdStatus" desc="生成审批单号">
		<![CDATA[
		
	 	   SELECT DISTINCT T.IF_SALE_FREEZE FROM PLN_SALEORD T WHERE T.ORD_LN_PK =  ?
		]]>
	</query>
	
	<query id="CoreOrderChangeManage.getOrdLineHistory" desc="生成审批单号">
		<![CDATA[
		
	 	   SELECT  T.ORDER_ADD_DESC ,T.ADD_ASK_NO,T.ORDER_SEQ
	 	   FROM    CHGE_SLM_ORDER_LINE T
	 	   WHERE   T.ORD_LN_PK  = ?
		]]>
	</query>
	
	<query id="CoreOrderChangeManage.InsertChgeOrdLine" desc="生成审批单号">
		<![CDATA[
		
	INSERT INTO CHGE_SLM_ORDER_LINE
  (ORD_PK,
   ORD_LN_PK,
   ORDER_SEQ,
   PSC,
   PSC_DESC,
   ADD_ASK_NO,
   ORDER_ADD_DESC,
   PRODUCCODE,
   PRODUCNAME,
   STD_CODE,
   STD_NAME,
   STEELCODE,
   STEELNAME,
   ORDER_SPEC_CODE,
   ORDER_SPEC_DESC,
   SPEC_CODE,
   SPEC_NAME,
   DIMATER,
   HEIGHT,
   FINAL_USER,
   FINAL_USER_DESC)
  (SELECT ORD_PK,
          ORD_LN_PK,
          ORDER_SEQ,
          PSC,
          PSC_DESC,
          ADD_ASK_NO,
          ORDER_ADD_DESC,
          PRODUCCODE,
          PRODUCNAME,
          STD_CODE,
          STD_NAME,
          STEELCODE,
          STEELNAME,
          ORDER_SPEC_CODE,
          ORDER_SPEC_DESC,
          SPEC_CODE,
          SPEC_NAME,
          DIMATER,
          HEIGHT,
          FINAL_USER,
          FINAL_USER_DESC
      FROM SLM_ORDER_LINE A
      WHERE A.ORD_LN_PK = ?)

  
		]]>
	</query>
	
	<query id="CoreOrderChangeManage.UpdateOrdLineAsk" desc="生成审批单号">
		<![CDATA[
		
		UPDATE SLM_ORDER_LINE T
    SET T.ADD_ASK_NO = '#ADD_ASK_NO#', 
        T.ORDER_ADD_DESC = '#ORDER_ADD_DESC#',
        T.ORDER_CHGE_NO = '#ORDER_CHGE_NO#',
        T.ISLOCK  = '1'
    WHERE T.ORD_LN_PK = '#ORD_LN_PK#'
		
		]]>
	</query>
	
	<query id="CoreOrderChangeManage.UpdateChgeSlmApplyM" desc="插入变更单信息">
	<![CDATA[
	
         UPDATE  CHGE_SLM_APPLY_M T
   SET CHGE_VAL    = '#CHGE_VAL#',
       UPDATE_NAME = '#UPDATE_NAME#',
       UPDATE_TIME =  SYSDATE
  WHERE T.ORDER_CHGE_NO = '#ORDER_CHGE_NO#'
        AND T.ORD_LN_PK <> T.ORD_LN_PK_AFTER
         
	]]>
	</query>
	
	<query id="CoreOrderChangeManage.RestoreOrdLineAsk" desc="还原合同信息">
		<![CDATA[
		
		UPDATE SLM_ORDER_LINE T
    SET T.ADD_ASK_NO = ?, 
        T.ORDER_ADD_DESC = ?,
        T.ORDER_CHGE_NO = '',
        T.ISLOCK  = '0'
    WHERE T.ORD_LN_PK = ?
		
		]]>
	</query>
	
	<query id="CoreOrderChangeManage.DeleteTempBackUp" desc="还原合同信息">
		<![CDATA[
		
	    DELETE FROM CHGE_SLM_ORDER_LINE T
	    WHERE T.ORD_LN_PK = ?
		
		]]>
	</query>
	
	<query id="CoreOrderChangeManage.UnlockOrdLine" desc="还原合同信息">
		<![CDATA[
		
	    UPDATE SLM_ORDER_LINE T
	    SET T.ISLOCK = '0'
	    WHERE T.ORD_LN_PK = ?
		
		]]>
	</query>
	
	<query id="CoreOrderChangeManage.UnFreezePlnSaleOrd" desc="解锁冻结变更标志">
		<![CDATA[
		
	   UPDATE PLN_SALEORD T
       SET  T.IF_SALE_FREEZE = '0'
       WHERE T.ORD_LN_PK = ?

		]]>
	</query>
	
	<query id="CoreOrderChangeManage.UpdatePlnSaleOrd" desc="更新计划附加要求">
		<![CDATA[
		
	   UPDATE PLN_SALEORD T
   SET T.ADD_ASK_NO    =
       (SELECT A.ADD_ASK_NO FROM SLM_ORDER_LINE A WHERE A.ORD_LN_PK = ?),
       T.ORDER_ADD_DESC =
       (SELECT A.ORDER_ADD_DESC FROM SLM_ORDER_LINE A WHERE A.ORD_LN_PK = ?),
       T.IF_SALE_FREEZE = '0'
   WHERE T.ORD_LN_PK = ?

		]]>
	</query>
	
	<query id="CoreOrderChangeManage.UpdateProcessOrderM" desc="更新进程表数据">
		<![CDATA[
		
	 	DECLARE
 BEGIN

  DELETE FROM PROCESS_ORDER_M T
   WHERE T.ORD_LN_PK = '#ORDER_LN_PK#'
     AND T.ORD_LN_DLY_PK NOT IN
         (SELECT A.ORD_LN_DLY_PK
            FROM SLM_ORDER_LINE_DELIVERY A
           WHERE A.ORD_LN_PK = '#ORDER_LN_PK#'
             AND A.VALIDFLAG = '1');
             
  INSERT INTO PROCESS_ORDER_M
    (ORD_PK,
     ORD_LN_PK,
     ORD_LN_DLY_PK,
     DELVRY_QTY,
     ORDER_UNIT,
     ENSU_TOTL_LEN)
    SELECT ORD_PK,
           ORD_LN_PK,
           ORD_LN_DLY_PK,
           DELVRY_QTY,
           ORDER_UNIT,
           ENSU_TOTL_LEN
      FROM SLM_ORDER_LINE_DELIVERY T
     WHERE T.ORD_LN_PK = '#ORDER_LN_PK#'
       AND T.ORD_LN_DLY_PK NOT IN
           (SELECT A.ORD_LN_DLY_PK
              FROM PROCESS_ORDER_M A
             WHERE A.ORD_LN_PK = '#ORDER_LN_PK#')
       AND T.VALIDFLAG = '1';
       
  END;
	 	
		]]>
	</query>
	
	
	<query id="CoreOrderChangeManage.getOrderMat" desc="更新计划附加要求">
		<![CDATA[
		
	    SELECT DISTINCT T.MAT_STATUS
   FROM MAT_ZC_M T
  WHERE T.ORD_LN_PK = ?
    AND T.ORD_LN_DLY_PK IN
        (SELECT A.ORD_LN_DLY_PK
           FROM SLM_ORDER_LINE_DELIVERY A
          WHERE A.ORD_LN_PK = ?
            AND A.VALIDFLAG = '1'
            AND A.DELIVERY_STATUS = '12020301')

		]]>
	</query>
	
	<query id="CoreOrderChangeManage.getOrderPlan" desc="更新计划附加要求">
		<![CDATA[
		
	SELECT 1
  FROM YDM_ZC_SENDPLAN_M T, YDM_ZC_SENDPLAN_C T1
 WHERE T.SEND_PLAN_NO = T1.SEND_PLAN_NO
   AND T1.ORD_LN_PK = ?
   AND T1.ORD_LN_DLY_PK IN
       (SELECT A.ORD_LN_DLY_PK 
         FROM SLM_ORDER_LINE_DELIVERY A
         WHERE A.ORD_LN_PK = ?
           AND A.VALIDFLAG = '1'
           AND A.DELIVERY_STATUS = '12020301')
  AND T.SEND_PLAN_STATUS <> '3'

		]]>
	</query>
	
	<query id = "CoreOrderChangeManage.queryBalStatus" desc = "合同是否参与结算">
	
	<![CDATA[
	
	SELECT 1
  FROM SLM_BALANCEINFO T
  WHERE T.BALANCESTATUS = '3'
   AND T.ORD_PK = ?
   GROUP BY ORD_PK
	
	]]>
	</query>
	
	<query id = "CoreOrderChangeManage.DeleteProcessDltLine" desc = "合同是否参与结算">
	
	<![CDATA[
	
	  DELETE FROM  process_order_m T
	  WHERE T.ORD_LN_PK = ?
 
	
	]]>
	</query>
	
	<query id = "CoreOrderChangeManage.AddProcessAddLine" desc = "合同是否参与结算">
	
	<![CDATA[
	
		 INSERT INTO PROCESS_ORDER_M
   (ORD_PK, ORD_LN_PK, ORD_LN_DLY_PK, DELVRY_QTY, ORDER_UNIT, ENSU_TOTL_LEN)
   SELECT ORD_PK,
         ORD_LN_PK,
         ORD_LN_DLY_PK,
         DELVRY_QTY,
         ORDER_UNIT,
         ENSU_TOTL_LEN
    FROM SLM_ORDER_LINE_DELIVERY T
    WHERE T.ORD_LN_PK = ?
     AND T.VALIDFLAG = '1'
	  
 
	]]>
	</query>
	

</queryMap>