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


	<query id="CoreOrderReviewTechnology.UpdateOrderLineMsc" desc="msc">
		<![CDATA[
			UPDATE SLM_ORDER_LINE
				   SET MSC       = NVL(?, MSC),
				       MSC_DESC  = NVL(?, MSC_DESC),
				       MSC_STYLE = NVL(?, MSC_STYLE),
				       USE_CODE  = NVL(?, USE_CODE),
				       USE_DESC  = NVL(?, USE_DESC),
				       CUST_ALPHA_NO='',
				       CUST_ALPHA_NO2 = ?
				 WHERE ORD_LN_PK = ?
		]]>
	</query>

	<query id="CoreOrderReviewTechnology.UpdateOrderHeadSts" desc="修改当前合同头状态为，技术评审失败">
		<![CDATA[
			UPDATE SLM_ORDER_HEAD
			SET 
			ORDER_STS='12020203',
			ORDER_STS_DESC='技术评审失败'
			 WHERE ORD_PK=?
		]]>
	</query>

	<query id="CoreOrderReviewTechnology.GetOrderHeadSts" desc="获取当前合同头状态">
		<![CDATA[
			SELECT ORDER_STS FROM SLM_ORDER_HEAD WHERE ORD_PK=?
		]]>
	</query>

	<query id="CoreOrderReviewTechnology.UpdateOrderHead" desc="合同行均为技术评审通过以上的状态，合同头状态修正为技术评审通过">
		<![CDATA[
			UPDATE SLM_ORDER_HEAD
			SET 
			ORDER_STS='12020202',
			ORDER_STS_DESC='技术评审通过'
			 WHERE ORD_PK=?
		]]>
	</query>

	<query id="CoreOrderReviewTechnology.GetLineDtByOrdPk" desc="依据当前合同行所属合同头Key，查询该合同头下是否还有技术评审通过以下的合同行。">
		<![CDATA[
			 SELECT ORDER_LN_STATUS
			  FROM SLM_ORDER_LINE
			 WHERE ORD_PK = ?
			   AND 
			   ORDER_LN_STATUS in ('12020101','12020102','120202','12020201','12020203')
			   AND
			   VALIDFLAG = '1'
		]]>
	</query>

	<query id="CoreOrderReviewTechnology.UpdateReviewItem" desc="评审项目状态修改">
		<![CDATA[
			 UPDATE 
			 SLM_ORDER_REVIEW_ITEM 
			 SET 
			 REVIEW_STATUS=? 
			 WHERE 
			 REVIEW_NO=? AND REVIEW_ITM='T'
		]]>
	</query>

	<query id="CoreOrderReviewTechnology.updateReviewItemList" desc="评审明细状态修改">
		<![CDATA[
			UPDATE 
			SLM_ORDER_REVIEW_ITEM_LIST 
			SET 
			REVIEW_STATUS=?,
			REVIEW_MAN=?,
			REVIEW_DEPT=?,
			REVIEW_EDATE=SYSDATE
			WHERE 
			REVIEW_NO=?
			AND REVIEW_ITM='T' 
			AND LIST_TYP='L' 
			AND LIST_PK_VAL=?
		]]>
	</query>


	<query id="CoreOrderReviewTechnology.updateOrderLine" desc="合同行状态修改">
		<![CDATA[
			 UPDATE SLM_ORDER_LINE 
			 SET 
			 ORDER_LN_STATUS=? 
			 WHERE 
			 ORD_LN_PK=?
		]]>
	</query>

	<query id="CoreOrderReviewTechnology.isDesignV" desc="获取当前合同行主键下面，设计状态不通过的管理科室。">
		<![CDATA[
			SELECT B.ORD_LN_PK,
             B.UNIT_CODE,
             B.UNIT_DESC,
             B.DESIGN_STS,
             B.DESIGN_STS_RS
        FROM SLM_ORD_DESIGN_STS_TKLG A, SLM_ORD_DESIGN_STS_TKLG_LST B
       WHERE A.DESGIN_KEY = B.DESGIN_KEY
         AND A.ORD_LN_PK = ?
         AND A.VALIDFLAG = '1'
         AND B.DESIGN_STS = 'F'
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.isDesignVCraft" desc="获取当前合同行主键下面，设计状态不通过的管理科室。">
		<![CDATA[
			SELECT B.ORD_LN_PK,
             B.UNIT_CODE,
             B.UNIT_DESC,
             B.DESIGN_STS,
             B.DESIGN_STS_RS
        FROM CRAFT_ORD_DESIGN_STS_TKLG A, Craft_ORD_DESIGN_STS_TKLG_LST B
       WHERE A.DESGIN_KEY = B.DESGIN_KEY
         AND A.ORD_LN_PK = ?
         AND A.VALIDFLAG = '1'
         AND B.DESIGN_STS = 'F'
		]]>
	</query>

	<query id="CoreOrderReviewTechnology.GetSts" desc="">
		<![CDATA[
			SELECT BASECODE,BASENAME FROM COM_BASE_INFO WHERE SORTCODE='1202' ORDER BY BASECODE
		]]>
	</query>


	<query id="CoreOrderReviewTechnology.GetDesignSts" desc="">
		<![CDATA[
			SELECT BASECODE,BASENAME FROM COM_BASE_INFO WHERE SORTCODE='1202' ORDER BY BASECODE
		]]>
	</query>

	<query id="CoreOrderReviewTechnology.doQuery" desc="获取合同行主信息">
		<![CDATA[
SELECT *
  FROM (SELECT *
          FROM (SELECT DECODE(J.REVIEW_STATUS,
                              'W',
                              '待审',
                              'D',
                              '评审中',
                              'S',
                              '评审通过',
                              'F',
                              '评审失败',
                              'L',
                              '封锁') REVIEW_STATUS,
                       K.DESGIN_KEY,
                       DECODE(K.DESIGN_STS,
                              'W',
                              '等待',
                              'S',
                              '通过',
                              'F',
                              '失败') DESIGN_STS,
                       H.ORD_PK,
                       H.ORD_LN_PK,
                       H.ORDER_SEQ,
                       H.FINAL_USER,
                       H.FINAL_USER_DESC,
                       H.PSC,
                       H.PSC_DESC,
                       H.ORDER_SPEC_CODE,
                       H.ORDER_SPEC_DESC,
                       H.MODEL_CODE,
                       H.MODEL_DESC,
                       H.LEN_DESC,
                       H.ORDER_QTY,
                       H.ORDER_UNIT,
                       ROUND(H.PRDCT_WGT, 4) PRDCT_WGT,
                       H.DELVRY_RANGE_TPE,
                       H.DELVRY_RANGE_MIN,
                       H.DELVRY_RANGE_MAX,
                       '-' || H.DELVRY_RANGE_MIN || H.DELVRY_RANGE_TPE || '，' || '+' ||
                       H.DELVRY_RANGE_MAX || H.DELVRY_RANGE_TPE DELVRY_RANGE,
                       (SELECT BASENAME
                          FROM COM_BASE_INFO
                         WHERE BASECODE = OUTS_BILLET_FL) OUTS_BILLET_FL,
                       (SELECT BASENAME
                          FROM COM_BASE_INFO
                         WHERE BASECODE = OUTS_STL_PIPE_FL) OUTS_STL_PIPE_FL,
                       DECODE(H.ASSEL_FL, '1', 'True', 'False') ASSEL_FL,
                       H.ORDER_ADD_DESC,
                       GET_ALL_ADD_ASK_DESC(H.ADD_ASK_NO,
                                            H.STD_CODE,
                                            '新增修改项') ALL_ADD_DESC,
                       H.ORDER_SPECIAL_DESC,
                       H.CUST_ALPHA_NO,
                       J.REVIEW_MAN,
                       J.REVIEW_DEPT,
                       TO_CHAR(J.REVIEW_EDATE, 'yyyy-mm-dd') REVIEW_EDATE,
                       G.ORDER_NO,
                       G.LOCAL_LAW,
                       G.CUSTOMER_NO,
                       G.REVW_RPT_NO,
                       DECODE(H.PRODUCER_FL, '1', 'True', 'False') PRODUCER_FL,
                       H.MSC,
                       H.MSC_DESC,
                       H.SPEC_CODE,
                       H.SPEC_NAME,
                       H.DIMATER,
                       H.HEIGHT,
                       J.REVIEW_NO,
                       H.ADD_ASK_NO,
                       DECODE(H.MPS_FL, '1', 'True', 'False') MPS_FL,
                       H.MPS_NO,
                       H.MPS_DESC,
                       H.STD_CODE,
                       H.STD_NAME,
                       H.USE_DESC,
                       DECODE(H.MAN_INSPECTION,
                              '1',
                              '可手探',
                              '0',
                              '不可手探') MAN_INSPECTION,
                       H.INSPECTION_VALUE,
                       TO_CHAR(H.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
                       H.CREATE_NAME,
					   CASE G.SUPPLY_UNIT
							WHEN '120501' THEN
								DECODE(K.DESIGN_STS, 'S', '002001001001', A.UNIT_CODE)
							ELSE
								DECODE(K.DESIGN_STS, 'S', '002023005003', A.UNIT_CODE)
					   END UNIT_CODE,
					   CASE G.SUPPLY_UNIT
							WHEN '120501' THEN
								DECODE(K.DESIGN_STS, 'S', '计划科', A.UNIT_DESC)
							ELSE
								DECODE(K.DESIGN_STS, 'S', '工艺科', A.UNIT_DESC)
					   END UNIT_DESC,
                       A.ORD_LN_PK A_ORD_LN_PK,
                       ROW_NUMBER() OVER(PARTITION BY A.ORD_LN_PK ORDER BY A.SEQ_INDEX) RN,
                       G.ORDER_NO || '/' || H.ORDER_SEQ MNG_ORDER_NO,
                       (SELECT BASENAME FROM COM_BASE_INFO WHERE BASECODE=G.SUPPLY_UNIT) SUPPLY_UNIT_DESC
                  FROM SLM_ORDER_HEAD             G,
                       SLM_ORDER_REVIEW_ITEM_LIST J,
                       SLM_ORDER_LINE             H
                  LEFT JOIN SLM_ORD_DESIGN_STS_TKLG_LST A
                    ON A.ORD_LN_PK = H.ORD_LN_PK
                   AND A.VALIDFLAG = '1'
                   AND A.DESIGN_STS = 'F'
                  LEFT JOIN SLM_ORD_DESIGN_STS_TKLG K
                    ON H.ORD_LN_PK = K.ORD_LN_PK
                   AND K.VALIDFLAG = '1', SLM_ORDER_REVIEW N
                 WHERE H.ORD_PK = G.ORD_PK
                   AND G.ORD_PK = N.ORD_PK
                   AND N.REVIEW_NO = J.REVIEW_NO
                   AND J.LIST_PK_VAL = H.ORD_LN_PK
                   AND DECODE('#SUPPLY_UNIT#', NULL, '1', G.SUPPLY_UNIT) =
                       DECODE('#SUPPLY_UNIT#', NULL, '1', '#SUPPLY_UNIT#')
                   AND DECODE('#DESIGN_STS#', NULL, '1', K.DESIGN_STS) =
                       DECODE('#DESIGN_STS#', NULL, '1', '#DESIGN_STS#')
                   AND J.REVIEW_ITM = 'T'
                   AND J.LIST_TYP = 'L'
                   AND J.IS_CURT_REVIEW = '1'
                   AND H.VALIDFLAG = '1'
                   AND LOWER(G.ORDER_NO || '/' || H.ORDER_SEQ) || '&' LIKE
                       '%' || LOWER('#ORDER_NO#') || '%'
                   AND DECODE('#BEGIN_TIME#', NULL, SYSDATE, H.CREATE_TIME) BETWEEN
                       DECODE('#BEGIN_TIME#',
                              NULL,
                              SYSDATE,
                              TO_DATE('#BEGIN_TIME#', 'YYYY-MM-DD HH24:MI:SS')) AND
                       DECODE('#BEGIN_TIME#',
                              NULL,
                              SYSDATE,
                              TO_DATE('#END_TIME#', 'YYYY-MM-DD HH24:MI:SS'))
                   AND DECODE('#REVIEW_STATUS#', NULL, '1', J.REVIEW_STATUS) =
                       DECODE('#REVIEW_STATUS#', NULL, '1', '#REVIEW_STATUS#')
                   AND G.Validflag = '1')
         WHERE DECODE(A_ORD_LN_PK, NULL, 1, RN) <= 1
           -- AND (DECODE('#UNIT_CODE#', NULL, '1', UNIT_CODE) =
           --     DECODE('#UNIT_CODE#', NULL, '1', '#UNIT_CODE#') OR
           --     DECODE(UNIT_CODE, NULL, NULL, UNIT_CODE) IS NULL)
        UNION ALL
        SELECT *
          FROM (SELECT DECODE(G.REVIEW_STATUS,
                              '0',
                              '待审',
                              '1',
                              '评审中',
                              '2',
                              '评审通过',
                              '3',
                              '评审失败') REVIEW_STATUS,
                       J.DESGIN_KEY,
                       DECODE(K.DESIGN_STS,
                              'W',
                              '等待',
                              'S',
                              '通过',
                              'F',
                              '失败') DESIGN_STS,
                       null ORD_PK,
                       G.PSC_BL ORD_LN_PK,
                       null ORDER_SEQ,
                       null FINAL_USER,
                       null FINAL_USER_DESC,
                       B.PSC,
                       B.PSC_DESC,
                       null ORDER_SPEC_CODE,
                       null ORDER_SPEC_DESC,
                       G.MODEL_CODE,
                       G.MODEL_DESC,
                       G.MIN_L || '-' || G.MAX_L LEN_DESC,
                       null ORDER_QTY,
                       null ORDER_UNIT,
                       null PRDCT_WGT,
                       null DELVRY_RANGE_TPE,
                       null DELVRY_RANGE_MIN,
                       null DELVRY_RANGE_MAX,
                       null DELVRY_RANGE,
                       null OUTS_BILLET_FL,
                       null OUTS_STL_PIPE_FL,
                       'False' ASSEL_FL,
                       null ORDER_ADD_DESC,
                       GET_ALL_ADD_ASK_DESC(NULL, G.STD_CODE, '新增修改项') ALL_ADD_DESC,
                       null ORDER_SPECIAL_DESC,
                       null CUST_ALPHA_NO,
                       null REVIEW_MAN,
                       null REVIEW_DEPT,
                       null REVIEW_EDATE,
                       G.PSC_BL ORDER_NO,
                       '' LOCAL_LAW,
                       null CUSTOMER_NO,
                       null REVW_RPT_NO,
                       'False' PRODUCER_FL,
                       PM.MSC MSC,
                       PM.MSC_DESC MSC_DESC,
                       null SPEC_CODE,
                       null SPEC_NAME,
                       G.MIN_D DIMATER,
                       G.MIN_H HEIGHT,
                       null REVIEW_NO,
                       null ADD_ASK_NO,
                       'False' MPS_FL,
                       null MPS_NO,
                       null MPS_DESC,
                       G.STD_CODE,
                       G.STD_NAME,
                       G.USE_DESC,
                       NULL MAN_INSPECTION,
                       NULL INSPECTION_VALUE,
                       TO_CHAR(G.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
                       G.CREATE_NAME,
                       DECODE(K.DESIGN_STS,
                              'S',
                              FIRST_VALUE(M.UNIT_CODE)
                              OVER(PARTITION BY M.ORD_LN_PK ORDER BY
                                   M.SEQ_INDEX DESC),
                              A.UNIT_CODE) UNIT_CODE,
                       DECODE(K.DESIGN_STS,
                              'S',
                              FIRST_VALUE(M.UNIT_DESC)
                              OVER(PARTITION BY M.ORD_LN_PK ORDER BY
                                   M.SEQ_INDEX DESC),
                              A.UNIT_DESC) UNIT_DESC,
                       DECODE(K.DESIGN_STS, 'S', M.ORD_LN_PK, A.ORD_LN_PK) A_ORD_LN_PK,
                       DECODE(K.DESIGN_STS,
                              'S',
                              (ROW_NUMBER() OVER(PARTITION BY M.ORD_LN_PK ORDER BY
                                                 M.SEQ_INDEX DESC)),
                              (ROW_NUMBER() OVER(PARTITION BY A.ORD_LN_PK ORDER BY
                                                 A.SEQ_INDEX))) RN,
                       G.PSC_BL MNG_ORDER_NO,
                       NULL SUPPLY_UNIT_DESC
                  FROM COM_MSC_BL G
                  LEFT JOIN SLM_ORD_DESIGN_STS_TKLG_LST M
                    ON M.ORD_LN_PK = G.PSC_BL
                   AND M.VALIDFLAG = '1'
                   AND M.DESIGN_STS = 'S'
                  LEFT JOIN SLM_ORD_DESIGN_STS_TKLG_LST A
                    ON A.ORD_LN_PK = G.PSC_BL
                   AND A.VALIDFLAG = '1'
                   AND A.DESIGN_STS = 'F'
                  LEFT JOIN COM_PSC B
                    ON B.PRODUCCODE = G.PRODUCCODE
                   AND B.STEELCODE = G.STEELCODE
                   AND B.STD_CODE = G.STD_CODE
                   AND DECODE(G.STD_STYLE, NULL, '1', B.STD_STYLE) =
                       DECODE(G.STD_STYLE, NULL, '1', G.STD_STYLE)
                   AND DECODE(G.STD_STYLE, NULL, B.STD_STYLE, NULL) IS NULL
                   AND B.VALIDFLAG = '1'
                  LEFT JOIN COM_PSC_R_MSC PM
                    ON PM.PSC = B.PSC
                   AND PM.USE_CODE = G.USE_CODE
                  LEFT JOIN SLM_ORD_DESIGN_STS_TKLG K
                    ON G.PSC_BL = K.ORD_LN_PK
                   AND K.VALIDFLAG = '1', SLM_ORD_DESIGN_BL J
                 WHERE G.PSC_BL = J.PSC_BL
                   AND G.VALIDFLAG = '1'
                   AND J.VALIDFLAG = '1'
                   AND DECODE('#DESIGN_STS#', NULL, '1', K.DESIGN_STS) =
                       DECODE('#DESIGN_STS#', NULL, '1', '#DESIGN_STS#')
                   AND LOWER(G.PSC_BL) || '&' LIKE
                       '%' || LOWER('#ORDER_NO#') || '%'
                   AND DECODE('#BEGIN_TIME#', NULL, SYSDATE, G.CREATE_TIME) BETWEEN
                       DECODE('#BEGIN_TIME#',
                              NULL,
                              SYSDATE,
                              TO_DATE('#BEGIN_TIME#', 'YYYY-MM-DD HH24:MI:SS')) AND
                       DECODE('#BEGIN_TIME#',
                              NULL,
                              SYSDATE,
                              TO_DATE('#END_TIME#', 'YYYY-MM-DD HH24:MI:SS'))
                   AND DECODE('#REVIEW_STATUS2#', NULL, '1', G.REVIEW_STATUS) =
                       DECODE('#REVIEW_STATUS2#',
                              NULL,
                              '1',
                              '#REVIEW_STATUS2#'))
         WHERE DECODE(A_ORD_LN_PK, NULL, 1, RN) <= 1
           AND (DECODE('#UNIT_CODE#', NULL, '1', UNIT_CODE) =
                DECODE('#UNIT_CODE#', NULL, '1', '#UNIT_CODE#') OR
                DECODE(UNIT_CODE, NULL, NULL, UNIT_CODE) IS NULL))
 ORDER BY ORDER_NO, ORDER_SEQ
		]]>
	</query>

	<query id="CoreOrderReviewTechnology.doQueryBBHT" desc="获取合同行主信息">
		<![CDATA[
SELECT *
  FROM (SELECT *
          FROM (SELECT
                       K.DESGIN_KEY,
                       DECODE(K.DESIGN_STS,
                              'W',
                              '等待',
                              'S',
                              '通过',
                              'F',
                              '失败') DESIGN_STS,
                       H.ORD_PK,
                       H.ORD_LN_PK,
                       H.ORDER_SEQ,
                       H.FINAL_USER,
                       H.FINAL_USER_DESC,
                       H.PSC,
                       H.PSC_DESC,
                       H.ORDER_SPEC_CODE,
                       H.ORDER_SPEC_DESC,
                       H.MODEL_CODE,
                       H.MODEL_DESC,
                       H.LEN_DESC,
                       H.ORDER_QTY,
                       H.ORDER_UNIT,
                       ROUND(H.PRDCT_WGT, 4) PRDCT_WGT,
                       H.DELVRY_RANGE_TPE,
                       H.DELVRY_RANGE_MIN,
                       H.DELVRY_RANGE_MAX,
                       '-' || H.DELVRY_RANGE_MIN || H.DELVRY_RANGE_TPE || '，' || '+' ||
                       H.DELVRY_RANGE_MAX || H.DELVRY_RANGE_TPE DELVRY_RANGE,
                       (SELECT BASENAME
                          FROM COM_BASE_INFO
                         WHERE BASECODE = OUTS_BILLET_FL) OUTS_BILLET_FL,
                       (SELECT BASENAME
                          FROM COM_BASE_INFO
                         WHERE BASECODE = OUTS_STL_PIPE_FL) OUTS_STL_PIPE_FL,
                       DECODE(H.ASSEL_FL, '1', 'True', 'False') ASSEL_FL,
                       H.ORDER_ADD_DESC,
                       GET_ALL_ADD_ASK_DESC(H.ADD_ASK_NO,
                                            H.STD_CODE,
                                            '新增修改项') ALL_ADD_DESC,
                       H.ORDER_SPECIAL_DESC,
                       H.CUST_ALPHA_NO,
                       G.ORDER_NO,
                       G.LOCAL_LAW,
                       G.CUSTOMER_NO,
                       G.REVW_RPT_NO,
                       DECODE(H.PRODUCER_FL, '1', 'True', 'False') PRODUCER_FL,
                       H.MSC,
                       H.MSC_DESC,
                       H.SPEC_CODE,
                       H.SPEC_NAME,
                       H.DIMATER,
                       H.HEIGHT,
                       H.ADD_ASK_NO,
                       DECODE(H.MPS_FL, '1', 'True', 'False') MPS_FL,
                       H.MPS_NO,
                       H.MPS_DESC,
                       H.STD_CODE,
                       H.STD_NAME,
                       H.USE_DESC,
                       DECODE(H.MAN_INSPECTION,
                              '1',
                              '可手探',
                              '0',
                              '不可手探') MAN_INSPECTION,
                       H.INSPECTION_VALUE,
                       TO_CHAR(H.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
                       H.CREATE_NAME,
					   CASE G.SUPPLY_UNIT
							WHEN '120501' THEN
								DECODE(K.DESIGN_STS, 'S', '002001001001', A.UNIT_CODE)
							ELSE
								DECODE(K.DESIGN_STS, 'S', '002023005003', A.UNIT_CODE)
					   END UNIT_CODE,
					   CASE G.SUPPLY_UNIT
							WHEN '120501' THEN
								DECODE(K.DESIGN_STS, 'S', '计划科', A.UNIT_DESC)
							ELSE
								DECODE(K.DESIGN_STS, 'S', '工艺科', A.UNIT_DESC)
					   END UNIT_DESC,
                       A.ORD_LN_PK A_ORD_LN_PK,
                       ROW_NUMBER() OVER(PARTITION BY A.ORD_LN_PK ORDER BY A.SEQ_INDEX) RN,
                       G.ORDER_NO || '/' || H.ORDER_SEQ MNG_ORDER_NO,
                       (SELECT BASENAME FROM COM_BASE_INFO WHERE BASECODE=G.SUPPLY_UNIT) SUPPLY_UNIT_DESC
                  FROM SLM_ORDER_HEAD             G,
                       SLM_ORDER_LINE             H
                  LEFT JOIN SLM_ORD_DESIGN_STS_TKLG_LST A
                    ON A.ORD_LN_PK = H.ORD_LN_PK
                   AND A.VALIDFLAG = '1'
                   AND A.DESIGN_STS = 'F'
                  LEFT JOIN SLM_ORD_DESIGN_STS_TKLG K
                    ON H.ORD_LN_PK = K.ORD_LN_PK
                   AND K.VALIDFLAG = '1'
                 WHERE H.ORD_PK = G.ORD_PK
                   AND DECODE('#SUPPLY_UNIT#', NULL, '1', G.SUPPLY_UNIT) =
                       DECODE('#SUPPLY_UNIT#', NULL, '1', '#SUPPLY_UNIT#')
                   AND DECODE('#DESIGN_STS#', NULL, '1', K.DESIGN_STS) =
                       DECODE('#DESIGN_STS#', NULL, '1', '#DESIGN_STS#')
                   AND H.VALIDFLAG = '1'
                   AND LOWER(G.ORDER_NO || '/' || H.ORDER_SEQ) || '&' LIKE
                       '%' || LOWER('#ORDER_NO#') || '%'
                   AND DECODE('#BEGIN_TIME#', NULL, SYSDATE, H.CREATE_TIME) BETWEEN
                       DECODE('#BEGIN_TIME#',
                              NULL,
                              SYSDATE,
                              TO_DATE('#BEGIN_TIME#', 'YYYY-MM-DD HH24:MI:SS')) AND
                       DECODE('#BEGIN_TIME#',
                              NULL,
                              SYSDATE,
                              TO_DATE('#END_TIME#', 'YYYY-MM-DD HH24:MI:SS'))
                   AND EXISTS ( SELECT 1 FROM SLM_ORDER_HEAD WHERE CUSTM_ORDER_NO = G.ORDER_NO AND VALIDFLAG = '1' AND ORDER_NO LIKE 'TH%' )
                   AND G.Validflag = '1')
         WHERE DECODE(A_ORD_LN_PK, NULL, 1, RN) <= 1
           AND (DECODE('#UNIT_CODE#', NULL, '1', UNIT_CODE) =
                DECODE('#UNIT_CODE#', NULL, '1', '#UNIT_CODE#') OR
                DECODE(UNIT_CODE, NULL, NULL, UNIT_CODE) IS NULL)
                )
 ORDER BY ORDER_NO, ORDER_SEQ
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.doQueryCraft" desc="获取合同行主信息工艺">
		<![CDATA[
SELECT *
  FROM (SELECT T1.DESGIN_KEY,
               T1.REVIEW_STATUS,
               T1.DESIGN_STS,
               T1.PORDERSTATUS,
               T1.ROLL_MONTH,
               T1.ROLL_WELL_MONTH,
               T1.ORDER_LN_STATUS,
               T1.CRAFT_NO,
               T1.CRAFT_NO_V_C,
               T1.CRAFT_NO_V_N,
               T1.CRAFT_CNT,
               T1.CRAFT_SEQ,
               T1.APPOINT_NAME,
               T1.APPOINT_TIME,
               T1.CRAFT_NAME,
               T1.CRAFT_ID,
               T1.ORD_PK,
               T1.ORD_LN_PK,
               T1.ORDER_SEQ,
               T1.FINAL_USER,
               T1.FINAL_USER_DESC,
               T1.PSC,
               T1.PSC_DESC,
               T1.ORDER_SPEC_CODE,
               T1.ORDER_SPEC_DESC,
               T1.MODEL_CODE,
               T1.MODEL_DESC,
               T1.LEN_DESC,
               T1.ORDER_QTY,
               T1.ORDER_UNIT,
               T1.PRDCT_WGT,
               T1.DELVRY_RANGE_TPE,
               T1.DELVRY_RANGE_MIN,
               T1.DELVRY_RANGE_MAX,
               T1.DELVRY_RANGE,
               T1.OUTS_BILLET_FL,
               T1.OUTS_STL_PIPE_FL,
               T1.ASSEL_FL,
               T1.DESCRIPTION_DIFF,
               T1.ORDER_SPECIAL_DESC,
               T1.CUST_ALPHA_NO,
               T1.ORDER_NO,
               T1.SALE_ORG,
               T1.CUSTOMER_NO,
               T1.REVW_RPT_NO,
               T1.PRODUCER_FL,
               T1.MSC,
               T1.MSC_DESC,
               T1.SPEC_CODE,
               T1.SPEC_NAME,
               T1.DIMATER,
               T1.HEIGHT,
               T1.STEELNAME,
               T1.ADD_ASK_NO,
               T1.MPS_FL,
               T1.MPS_NO,
               T1.MPS_DESC,
               T1.STD_CODE,
               T1.STD_NAME,
               T1.USE_DESC,
               T1.MAN_INSPECTION,
               T1.INSPECTION_VALUE,
               T1.CREATE_TIME,
               T1.CREATE_NAME,
               T1.EFFECT_TIME,
               T1.EFFECT_MAN,
               T1.UNIT_CODE,
               T1.UNIT_DESC,
               T1.PLAN_RN,
               T1.PLAN_ORD_LN_PK,
               T1.CRAFT_PATH,
               T1.DESCRIPTION_ALL,
               T1.MSC_RN,
               T1.CHGE_VAL,
               DECODE(T1.CRAFT_NO,
                      NULL,
                      NULL,
                      DECODE((SELECT 1
                               FROM CRAFT_ORD_DESIGN_FILE FIL
                              WHERE FIL.CRAFT_NO = NVL(T1.CRAFT_NO, '-1')
                                AND FIL.CRAFT_NO_V =
                                    NVL(T1.CRAFT_NO_V_C, '-1')),
                             NULL,
                             'L',
                             'G')) CRAFT_TYPE,
               (SELECT DECODE(MIN(TKL_LST.CREATE_NAME), 'SYSTEM', 'SYSTEM', MAX(USERNAME))
                  FROM SLM_ORD_DESIGN_STS_TKLG     TKL,
                       SLM_ORD_DESIGN_STS_TKLG_LST TKL_LST
                       LEFT JOIN CORE_APP_USER USE
                       ON USE.USERID = TKL_LST.CREATE_NAME
                 WHERE TKL.DESGIN_KEY = TKL_LST.DESGIN_KEY
                   AND TKL.VALIDFLAG = '1'
                   AND TKL.ORD_LN_PK = T1.ORD_LN_PK) REVIEW_MAN,
               T1.MEMO,
               T1.OTHER_EDIT_NAME,
               T1.CRAFT_CHANGE_MEMO,
               T1.ORDER_NO || '/' || T1.ORDER_SEQ MNG_ORDER_NO,
               T1.STRANDING_DAY,
               T1.PIC_FD_CHECK,
               T1.WIC_FD_CHECK,
               T1.CIC_FD_CHECK,
               T1.REASON,
               T1.SUPPLY_UNIT_DESC,
               (SELECT
					WBS_NAME
				FROM
					COM_BASE_WBS A INNER JOIN SLM_ORDER_LINE B ON A.WBS_CODE = B.WBS_CODE
					WHERE A.VALIDFLAG = '1' AND B.ORD_LN_PK = T1.ORD_LN_PK) WBS_CODE
          FROM (SELECT K.DESGIN_KEY,
                       DECODE(M.VALIDFLAG,
                              '1',
                              '生效',
                              '2',
                              '制定中',
                              '3',
                              '科室审核中',
                              '4',
                              '审批中',
                              '5',
                              '审核失败',
                              '6',
                              '相关科室审核中',
                              '7',
                              '批准中',
                              '9',
                              '待生成',
                              '8',
                              '变更待生效') REVIEW_STATUS,
                       DECODE(K.DESIGN_STS,
                              'W',
                              '等待',
                              'S',
                              '通过',
                              'F',
                              '失败') DESIGN_STS,
                       DECODE(J.PORDERSTATUS,
                              NULL,
                              '未提报',
                              '0',
                              '待接收',
                              '1',
                              '已接收',
                              '2',
                              '已下发',
                              '3',
                              '生产中',
                              '4',
                              '生产完成',
                              '5',
                              '缴库完成') PORDERSTATUS,
                       J.ROLL_MONTH,
                       J.ROLL_WELL_MONTH,
                       BI.BASENAME ORDER_LN_STATUS,
                       M.CRAFT_NO,
                       H.CRAFT_NO_V CRAFT_NO_V_C,
                       (SELECT MAX(CRAFT_NO_V)
                          FROM CRAFT_ORD_DESIGN
                         WHERE CRAFT_NO = H.CRAFT_NO) CRAFT_NO_V_N,
                       (SELECT COUNT(1)
                          FROM CRAFT_ORD_DESIGN
                         WHERE ORD_LN_PK = M.ORD_LN_PK
                           AND VALIDFLAG <> '0'
                           AND CRAFT_NO IS NOT NULL) CRAFT_CNT,
                       M.CRAFT_SEQ,
                       S.APPOINT_NAME,
                       TO_CHAR(S.APPOINT_TIME, 'YYYY-MM-DD HH24:MI:SS') APPOINT_TIME,
                       S.CRAFT_NAME,
                       S.CRAFT_ID,
                       H.ORD_PK,
                       H.ORD_LN_PK,
                       H.ORDER_SEQ,
                       H.FINAL_USER,
                       H.FINAL_USER_DESC,
                       H.PSC,
                       H.PSC_DESC,
                       H.ORDER_SPEC_CODE,
                       H.ORDER_SPEC_DESC,
                       H.MODEL_CODE,
                       H.MODEL_DESC,
                       H.LEN_DESC,
                       H.ORDER_QTY,
                       H.ORDER_UNIT,
                       ROUND(H.PRDCT_WGT, 4) PRDCT_WGT,
                       H.DELVRY_RANGE_TPE,
                       H.DELVRY_RANGE_MIN,
                       H.DELVRY_RANGE_MAX,
                       '-' || H.DELVRY_RANGE_MIN || H.DELVRY_RANGE_TPE || '，' || '+' ||
                       H.DELVRY_RANGE_MAX || H.DELVRY_RANGE_TPE DELVRY_RANGE,
                       (SELECT BASENAME
                          FROM COM_BASE_INFO
                         WHERE BASECODE = H.OUTS_BILLET_FL) OUTS_BILLET_FL,
                       (SELECT BASENAME
                          FROM COM_BASE_INFO
                         WHERE BASECODE = H.OUTS_STL_PIPE_FL) OUTS_STL_PIPE_FL,
                       DECODE(H.ASSEL_FL, '1', 'True', 'False') ASSEL_FL,
                       H.ORDER_ADD_DESC,
                       H.ORDER_SPECIAL_DESC,
                       H.CUST_ALPHA_NO,
                       G.ORDER_NO,
                       G.SALE_ORG,
                       G.CUSTOMER_NO,
                       G.REVW_RPT_NO,
                       DECODE(H.PRODUCER_FL, '1', 'True', 'False') PRODUCER_FL,
                       H.MSC,
                       H.MSC_DESC,
                       H.SPEC_CODE,
                       H.SPEC_NAME,
                       H.DIMATER,
                       H.HEIGHT,
                       H.STEELNAME,
                       H.ADD_ASK_NO,
                       DECODE(H.MPS_FL, '1', 'True', 'False') MPS_FL,
                       H.MPS_NO_INPUT MPS_NO,
                       H.MPS_DESC,
                       H.STD_CODE,
                       H.STD_NAME,
                       H.USE_DESC,
                       DECODE(H.MAN_INSPECTION,
                              '1',
                              '可手探',
                              '0',
                              '不可手探') MAN_INSPECTION,
                       H.INSPECTION_VALUE,
                       TO_CHAR(H.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
                       H.CREATE_NAME,
                       TO_CHAR(G.EFFECT_TIME, 'YYYY-MM-DD HH24:MI:SS') EFFECT_TIME,
                       G.EFFECT_MAN,
                       NVL((select min(Q.UNIT_CODE)
                          from CRAFT_ORD_DESIGN_STS_TKLG_LST Q
                         WHERE Q.DESIGN_STS = 'F'
                           AND Q.VALIDFLAG = '1'
                           AND Q.DESGIN_KEY = M.DESGIN_KEY), '') UNIT_CODE,
                       nvl((select min(Q.UNIT_DESC)
                          from CRAFT_ORD_DESIGN_STS_TKLG_LST Q
                         WHERE Q.DESIGN_STS = 'F'
                           AND Q.VALIDFLAG = '1'
                           AND Q.DESGIN_KEY = M.DESGIN_KEY), '') UNIT_DESC,
                       (select min(Q.LST_ITEM)
                          from CRAFT_ORD_DESIGN_STS_TKLG_LST Q
                         WHERE Q.DESIGN_STS = 'F'
                           AND Q.VALIDFLAG = '1'
                           AND Q.DESGIN_KEY = M.DESGIN_KEY) LST_ITEM,
                       ROW_NUMBER() OVER(PARTITION BY J.ORD_LN_PK ORDER BY J.DELIVERY_NO) PLAN_RN,
                       J.ORD_LN_PK PLAN_ORD_LN_PK,
                       M.CRAFT_PATH,
                       NULL MSC_RN,
                       CHG.CHGE_VAL,
                       M.MEMO,
                       M.OTHER_EDIT_NAME,
                       M.CRAFT_CHANGE_MEMO,
                       (SELECT MAX(OO.DESCRIPTION_DIFF)
                          FROM CRAFT_ORD_DESIGN_ADD_ASK OO
                         WHERE OO.DESGIN_KEY = M.DESGIN_KEY) DESCRIPTION_DIFF,
                       (SELECT MAX(OO.DESCRIPTION_ALL)
                          FROM CRAFT_ORD_DESIGN_ADD_ASK OO
                         WHERE OO.DESGIN_KEY = M.DESGIN_KEY) DESCRIPTION_ALL,
                       CASE
                       --评审状态不等于生效并且合同状态大于等于开始提报
                         WHEN M.VALIDFLAG <> '1' AND
                              H.ORDER_LN_STATUS >= '12020401' THEN
                          FLOOR(SYSDATE - NVL((SELECT MIN(P.CREATE_TIME)
                                                FROM PLN_SALEORD P
                                               WHERE P.ORD_LN_PK = H.ORD_LN_PK),
                                              SYSDATE)) --滞留天数=当前时间-最小的提报时间
                         ELSE
                          NULL
                       END STRANDING_DAY,
                       DECODE(M.PIC_FD_CHECK, '1', 'True', 'False') PIC_FD_CHECK,
                       DECODE(M.WIC_FD_CHECK, '1', 'True', 'False') WIC_FD_CHECK,
                       DECODE(M.CIC_FD_CHECK, '1', 'True', 'False') CIC_FD_CHECK,
                       M.REASON,
                       (SELECT BASENAME FROM COM_BASE_INFO WHERE BASECODE=G.SUPPLY_UNIT) SUPPLY_UNIT_DESC,null WBS_CODE
                  FROM SLM_ORDER_HEAD G, SLM_ORDER_LINE H
                  LEFT JOIN CHGE_SLM_APPLY_M CHG
                    ON CHG.ORDER_CHGE_NO = NVL(H.ORDER_CHGE_NO, '-1')
                  LEFT JOIN CRAFT_ORD_DESIGN_FILE F
                    ON F.CRAFT_NO = NVL(H.CRAFT_NO, '-1')
                   AND F.CRAFT_NO_V = NVL(H.CRAFT_NO_V, '-1')
                  LEFT JOIN COM_BASE_INFO BI
                    ON BI.BASECODE = NVL(H.ORDER_LN_STATUS, '-1')
                  LEFT JOIN PLN_SALEORD J
                    ON J.ORD_LN_PK = NVL(H.ORD_LN_PK, '-1')
                  LEFT JOIN CRAFT_ORD_DESIGN_APPOINT S
                    ON S.ORD_LN_PK = NVL(H.ORD_LN_PK, '-1'), CRAFT_ORD_DESIGN M
                  LEFT JOIN CRAFT_ORD_DESIGN_STS_TKLG K
                    ON K.DESGIN_KEY = NVL(M.DESGIN_KEY, '-1')
                   AND K.VALIDFLAG = '1'
                 WHERE H.ORD_PK = G.ORD_PK
                   AND G.VALIDFLAG = '1'
                   AND H.ORDER_LN_STATUS >= '12020301'
                   --AND H.ORDER_LN_STATUS <= '12020601'
                   AND G.ORDER_TYP <> '120102'
                   AND M.CRAFT_SEQ =
                       (SELECT MAX(CRAFT_SEQ)
                          FROM CRAFT_ORD_DESIGN
                         WHERE ORD_LN_PK = M.ORD_LN_PK)
                   AND M.VALIDFLAG <> '0'
                   AND DECODE('#DESIGN_STS#', NULL, '1', K.DESIGN_STS) =
                       DECODE('#DESIGN_STS#', NULL, '1', '#DESIGN_STS#')
                   AND DECODE('#REVIEW_STATUS#', NULL, '1', M.VALIDFLAG) =
                       DECODE('#REVIEW_STATUS#', NULL, '1', '#REVIEW_STATUS#')
                   AND M.ORD_LN_PK = H.ORD_LN_PK
                   AND M.VALIDFLAG <> '0'
                   AND H.VALIDFLAG = '1'
                   #SUPPLY_UNIT_FLAG#
                   AND ('#PLAN_STATUS#' IS NULL OR '#PLAN_STATUS#' = '1' OR
                       (J.PORDERSTATUS IN ('1', '2', '3') OR
                       (J.PORDERSTATUS IN ('4', '5') AND
                       TO_DATE(J.ROLL_MONTH, 'YYYY-MM') =
                       TO_DATE(TO_CHAR(SYSDATE, 'YYYY-MM'), 'YYYY-MM'))))
                   AND ('#URGENT#' = '0' OR
                       ((J.PORDERSTATUS = '1' AND M.CRAFT_NO IS NULL) OR
                       (J.PORDERSTATUS = '2' AND M.VALIDFLAG <> '1') OR
                       (J.PORDERSTATUS = '0' AND M.VALIDFLAG <> '1')))
                   AND LOWER(G.ORDER_NO) LIKE
                       '%' || LOWER('#ORDER_NO#') || '%'
                   AND DECODE('#ORDER_SEQ#', NULL, '1', H.ORDER_SEQ) =
                       NVL('#ORDER_SEQ#', '1')
                   AND NOT EXISTS (SELECT 1 FROM SLM_ORDER_HEAD WHERE CUSTM_ORDER_NO = G.ORDER_NO  AND VALIDFLAG = '1' AND ORDER_NO LIKE 'TH%')
                   AND DECODE('#BEGIN_TIME#', NULL, SYSDATE, G.EFFECT_TIME) BETWEEN
                       DECODE('#BEGIN_TIME#',
                              NULL,
                              SYSDATE,
                              TO_DATE('#BEGIN_TIME#', 'YYYY-MM-DD HH24:MI:SS')) AND
                       DECODE('#BEGIN_TIME#',
                              NULL,
                              SYSDATE,
                              TO_DATE('#END_TIME#', 'YYYY-MM-DD HH24:MI:SS'))) T1
         WHERE DECODE(T1.PLAN_ORD_LN_PK, NULL, 1, PLAN_RN) <= 1
           AND (T1.CRAFT_ID = '#USER_ID#' OR
                (T1.LST_ITEM = '试样码' AND EXISTS
                 (SELECT 1
                    FROM CRAFT_SPLINE_UNIT T
                   WHERE T.UNIT_CODE IN ('#UNIT_CODE_S#'))) OR
                T1.UNIT_CODE IN ('#UNIT_CODE_S#') OR 'admin' = 'admin')
        UNION ALL

        SELECT *
          FROM (SELECT '' DESGIN_KEY,
                       '未制定' REVIEW_STATUS,
                       '' DESIGN_STS,
                       DECODE(J.PORDERSTATUS,
                              NULL,
                              '未提报',
                              '0',
                              '待接收',
                              '1',
                              '已接收',
                              '2',
                              '已下发',
                              '3',
                              '生产中',
                              '4',
                              '生产完成',
                              '5',
                              '缴库完成') PORDERSTATUS,
                       J.ROLL_MONTH,
                       J.ROLL_WELL_MONTH,
                       BI.BASENAME ORDER_LN_STATUS,
                       NULL CRAFT_NO,
                       NULL CRAFT_NO_V_C,
                       NULL CRAFT_NO_V_N,
                       0 CRAFT_CNT,
                       TO_NUMBER('') CRAFT_SEQ,
                       S.APPOINT_NAME,
                       TO_CHAR(S.APPOINT_TIME, 'YYYY-MM-DD HH24:MI:SS') APPOINT_TIME,
                       S.CRAFT_NAME,
                       S.CRAFT_ID,
                       H.ORD_PK,
                       H.ORD_LN_PK,
                       H.ORDER_SEQ,
                       H.FINAL_USER,
                       H.FINAL_USER_DESC,
                       H.PSC,
                       H.PSC_DESC,
                       H.ORDER_SPEC_CODE,
                       H.ORDER_SPEC_DESC,
                       H.MODEL_CODE,
                       H.MODEL_DESC,
                       H.LEN_DESC,
                       H.ORDER_QTY,
                       H.ORDER_UNIT,
                       ROUND(H.PRDCT_WGT, 4) PRDCT_WGT,
                       H.DELVRY_RANGE_TPE,
                       H.DELVRY_RANGE_MIN,
                       H.DELVRY_RANGE_MAX,
                       '-' || H.DELVRY_RANGE_MIN || H.DELVRY_RANGE_TPE || '，' || '+' ||
                       H.DELVRY_RANGE_MAX || H.DELVRY_RANGE_TPE DELVRY_RANGE,
                       (SELECT BASENAME
                          FROM COM_BASE_INFO
                         WHERE BASECODE = H.OUTS_BILLET_FL) OUTS_BILLET_FL,
                       (SELECT BASENAME
                          FROM COM_BASE_INFO
                         WHERE BASECODE = H.OUTS_STL_PIPE_FL) OUTS_STL_PIPE_FL,
                       DECODE(H.ASSEL_FL, '1', 'True', 'False') ASSEL_FL,
                       GET_ALL_ADD_ASK_DESC(H.ADD_ASK_NO, '', '新增修改项') DESCRIPTION_DIFF,
                       H.ORDER_SPECIAL_DESC,
                       H.CUST_ALPHA_NO,
                       G.ORDER_NO,
                       G.SALE_ORG,
                       G.CUSTOMER_NO,
                       G.REVW_RPT_NO,
                       DECODE(H.PRODUCER_FL, '1', 'True', 'False') PRODUCER_FL,
                       H.MSC,
                       H.MSC_DESC,
                       H.SPEC_CODE,
                       H.SPEC_NAME,
                       H.DIMATER,
                       H.HEIGHT,
                       H.STEELNAME,
                       H.ADD_ASK_NO,
                       DECODE(H.MPS_FL, '1', 'True', 'False') MPS_FL,
                       H.MPS_NO_INPUT MPS_NO,
                       H.MPS_DESC,
                       H.STD_CODE,
                       H.STD_NAME,
                       H.USE_DESC,
                       DECODE(H.MAN_INSPECTION,
                              '1',
                              '可手探',
                              '0',
                              '不可手探') MAN_INSPECTION,
                       H.INSPECTION_VALUE,
                       TO_CHAR(H.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
                       H.CREATE_NAME,
                       TO_CHAR(G.EFFECT_TIME, 'YYYY-MM-DD HH24:MI:SS') EFFECT_TIME,
                       G.EFFECT_MAN,
                       MSC.UNIT_CODE_PROCESS UNIT_CODE,
                       MSC.UNIT_DESC_PROCESS UNIT_DESC, --002001001001
                       ROW_NUMBER() OVER(PARTITION BY J.ORD_LN_PK ORDER BY J.DELIVERY_NO) PLAN_RN,
                       J.ORD_LN_PK PLAN_ORD_LN_PK,
                       F.CRAFT_PATH,
                       NVL(H.ORDER_ADD_DESC,
                           GET_ALL_ADD_ASK_DESC('', H.STD_CODE, '')) DESCRIPTION_ALL,
                       NULL MSC_RN,
                       CHG.CHGE_VAL,
                       NULL CRAFT_TYPE,
                       (SELECT DECODE(MIN(TKL_LST.CREATE_NAME), 'SYSTEM', 'SYSTEM', MAX(USERNAME))
                      FROM SLM_ORD_DESIGN_STS_TKLG     TKL,
                           SLM_ORD_DESIGN_STS_TKLG_LST TKL_LST
                           LEFT JOIN CORE_APP_USER USE
                           ON USE.USERID = TKL_LST.CREATE_NAME
                     WHERE TKL.DESGIN_KEY = TKL_LST.DESGIN_KEY
                       AND TKL.VALIDFLAG = '1'
                       AND TKL.ORD_LN_PK = H.ORD_LN_PK) REVIEW_MAN,
                       NULL MEMO,
                       NULL OTHER_EDIT_NAME,
                       NULL CRAFT_CHANGE_MEMO,
                       G.ORDER_NO || '/' || H.ORDER_SEQ MNG_ORDER_NO,
                       CASE
                       --合同状态大于等于开始提报
                         WHEN H.ORDER_LN_STATUS >= '12020401' THEN
                          FLOOR(SYSDATE - NVL((SELECT MIN(P.CREATE_TIME)
                                                FROM PLN_SALEORD P
                                               WHERE P.ORD_LN_PK = H.ORD_LN_PK),
                                              SYSDATE)) --滞留天数=当前时间-最小的提报时间
                         ELSE
                          NULL
                       END STRANDING_DAY,
                       'False' PIC_FD_CHECK,
                       'False' WIC_FD_CHECK,
                       'False' CIC_FD_CHECK,
                       NULL RESON,
                       (SELECT BASENAME FROM COM_BASE_INFO WHERE BASECODE=G.SUPPLY_UNIT) SUPPLY_UNIT_DESC,null WBS_CODE
                  FROM SLM_ORDER_HEAD G, COM_MSC MSC
                  LEFT JOIN COM_PSC_R_MSC PRM
                    ON PRM.MSC = NVL(MSC.MSC, '-1')
                  LEFT JOIN COM_PSC PSC
                    ON PSC.PSC = NVL(PRM.PSC, '-1'), SLM_ORDER_LINE H
                  LEFT JOIN CHGE_SLM_APPLY_M CHG
                    ON CHG.ORDER_CHGE_NO = NVL(H.ORDER_CHGE_NO, '-1')
                  LEFT JOIN CRAFT_ORD_DESIGN_FILE F
                    ON F.CRAFT_NO = NVL(H.CRAFT_NO, '-1')
                   AND F.CRAFT_NO_V = NVL(H.CRAFT_NO_V, '-1')
                  LEFT JOIN COM_BASE_INFO BI
                    ON BI.BASECODE = NVL(H.ORDER_LN_STATUS, '-1')
                  LEFT JOIN PLN_SALEORD J
                    ON J.ORD_LN_PK = NVL(H.ORD_LN_PK, '-1')
                  LEFT JOIN CRAFT_ORD_DESIGN_APPOINT S
                    ON S.ORD_LN_PK = NVL(H.ORD_LN_PK, '-1')
                 WHERE H.ORD_PK = G.ORD_PK
                   AND G.VALIDFLAG = '1'
                   AND H.ORDER_LN_STATUS >= '12020301'
                   AND H.ORDER_LN_STATUS <= '12020601'
                   AND G.ORDER_TYP <> '120102'
                   AND H.VALIDFLAG = '1'
                   #SUPPLY_UNIT_FLAG#
                   AND NOT EXISTS (SELECT 1 FROM SLM_ORDER_HEAD WHERE CUSTM_ORDER_NO = G.ORDER_NO AND VALIDFLAG = '1'  AND ORDER_NO LIKE 'TH%')
                   AND ('#PLAN_STATUS#' IS NULL OR '#PLAN_STATUS#' = '1' OR
                       (J.PORDERSTATUS IN ('1', '2', '3') OR
                       (J.PORDERSTATUS IN ('4', '5') AND
                       TO_DATE(J.ROLL_MONTH, 'YYYY-MM') =
                       TO_DATE(TO_CHAR(SYSDATE, 'YYYY-MM'), 'YYYY-MM'))))
                   AND MSC.MSC = H.MSC
                   AND ('#URGENT#' = '0' OR J.ROLL_MONTH >= '2017-05')
                   AND LOWER(G.ORDER_NO) LIKE
                       '%' || LOWER('#ORDER_NO#') || '%'
                   AND DECODE('#ORDER_SEQ#', NULL, '1', H.ORDER_SEQ) =
                       NVL('#ORDER_SEQ#', '1')
                   AND DECODE('#BEGIN_TIME#', NULL, SYSDATE, G.EFFECT_TIME) BETWEEN
                       DECODE('#BEGIN_TIME#',
                              NULL,
                              SYSDATE,
                              TO_DATE('#BEGIN_TIME#', 'YYYY-MM-DD HH24:MI:SS')) AND
                       DECODE('#BEGIN_TIME#',
                              NULL,
                              SYSDATE,
                              TO_DATE('#END_TIME#', 'YYYY-MM-DD HH24:MI:SS'))
                   AND '1' =
                       DECODE('#DESIGN_STS#', NULL, '1', '#DESIGN_STS#')
                   AND NOT EXISTS
                 (SELECT 1
                          FROM CRAFT_ORD_DESIGN M
                         WHERE M.ORD_LN_PK = H.ORD_LN_PK
                           AND M.VALIDFLAG <> '0')
                   AND '6' =
                       DECODE('#REVIEW_STATUS#', NULL, '6', '#REVIEW_STATUS#'))
         WHERE DECODE(PLAN_ORD_LN_PK, NULL, 1, PLAN_RN) <= 1
           AND (CRAFT_ID = '#USER_ID#' OR UNIT_CODE IN ('#UNIT_CODE_S#') OR
                '#USER_ID#' = 'admin')
        UNION ALL

        SELECT DISTINCT *
          FROM (SELECT K.DESGIN_KEY,
                       DECODE(M.VALIDFLAG,
                              '1',
                              '生效',
                              '2',
                              '制定中',
                              '3',
                              '科室审核中',
                              '4',
                              '审批中',
                              '5',
                              '审核失败',
                              '6',
                              '相关科室审核中',
                              '7',
                              '批准中',
                              '9',
                              '待生成',
                              '8',
                              '变更待生效') REVIEW_STATUS,
                       DECODE(K.DESIGN_STS,
                              'W',
                              '等待',
                              'S',
                              '通过',
                              'F',
                              '失败') DESIGN_STS,
                       NULL PORDERSTATUS,
                       NULL ROLL_MONTH,
                       NULL ROLL_WELL_MONTH,
                       DECODE(H.REVIEW_STATUS,
                              '0',
                              '待技术评审',
                              '1',
                              '技术评审中',
                              '2',
                              '技术评审通过',
                              '3',
                              '技术评审通过',
                              '未识别') ORDER_LN_STATUS,
                       M.CRAFT_NO,
                       NULL CRAFT_NO_V_C,
                       M.CRAFT_NO_V CRAFT_NO_V_N,
                       (SELECT COUNT(1)
                          FROM CRAFT_ORD_DESIGN
                         WHERE ORD_LN_PK = M.ORD_LN_PK
                           AND VALIDFLAG <> '0'
                           AND CRAFT_NO IS NOT NULL) CRAFT_CNT,
                       M.CRAFT_SEQ,
                       S.APPOINT_NAME,
                       TO_CHAR(S.APPOINT_TIME, 'YYYY-MM-DD HH24:MI:SS') APPOINT_TIME,
                       S.CRAFT_NAME,
                       S.CRAFT_ID,
                       NULL ORD_PK,
                       H.PSC_BL ORD_LN_PK,
                       NULL ORDER_SEQ,
                       NULL FINAL_USER,
                       NULL FINAL_USER_DESC,
                       PS.PSC,
                       PS.PSC_DESC,
                       NULL ORDER_SPEC_CODE,
                       NULL ORDER_SPEC_DESC,
                       H.MODEL_CODE,
                       H.MODEL_DESC,
                       NULL LEN_DESC,
                       NULL ORDER_QTY,
                       NULL ORDER_UNIT,
                       NULL PRDCT_WGT,
                       NULL DELVRY_RANGE_TPE,
                       NULL DELVRY_RANGE_MIN,
                       NULL DELVRY_RANGE_MAX,
                       NULL DELVRY_RANGE,
                       NULL OUTS_BILLET_FL,
                       NULL OUTS_STL_PIPE_FL,
                       NULL ASSEL_FL,
                       NULL ORDER_ADD_DESC,
                       NULL ORDER_SPECIAL_DESC,
                       NULL CUST_ALPHA_NO,
                       H.PSC_BL ORDER_NO,
                       NULL SALE_ORG,
                       NULL CUSTOMER_NO,
                       NULL REVW_RPT_NO,
                       NULL PRODUCER_FL,
                       MS.MSC,
                       MS.MSC_DESC,
                       NULL SPEC_CODE,
                       H.MIN_D || 'x' || H.MIN_H SPEC_NAME,
                       H.MIN_D DIMATER,
                       H.MIN_H HEIGHT,
                       H.STEELNAME,
                       NULL ADD_ASK_NO,
                       'False' MPS_FL,
                       NULL MPS_NO,
                       NULL MPS_DESC,
                       H.STD_CODE,
                       H.STD_NAME,
                       H.USE_DESC,
                       NULL MAN_INSPECTION,
                       NULL INSPECTION_VALUE,
                       TO_CHAR(H.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
                       H.CREATE_NAME,
                       NULL EFFECT_TIME,
                       NULL EFFECT_MAN,
                       NVL((select min(Q.UNIT_CODE)
                          from CRAFT_ORD_DESIGN_STS_TKLG_LST Q
                         WHERE Q.DESIGN_STS = 'F'
                           AND Q.VALIDFLAG = '1'
                           AND Q.DESGIN_KEY = M.DESGIN_KEY), MS.UNIT_CODE_PROCESS) UNIT_CODE,
                       nvl((select min(Q.UNIT_DESC)
                          from CRAFT_ORD_DESIGN_STS_TKLG_LST Q
                         WHERE Q.DESIGN_STS = 'F'
                           AND Q.VALIDFLAG = '1'
                           AND Q.DESGIN_KEY = M.DESGIN_KEY), MS.UNIT_DESC_PROCESS) UNIT_DESC,
                       NULL PLAN_RN,
                       NULL PLAN_ORD_LN_PK,
                       M.CRAFT_PATH,
                       GET_ALL_ADD_ASK_DESC('', PS.STD_CODE, '') STD_ADD_DESC,
                       ROW_NUMBER() OVER(PARTITION BY PS.PSC ORDER BY MS.MSC) MSC_RN,
                       NULL CHGE_VAL,
                       NULL CRAFT_TYPE,
                       (SELECT DECODE(MIN(TKL_LST.CREATE_NAME), 'SYSTEM', 'SYSTEM', MAX(USERNAME))
                      FROM SLM_ORD_DESIGN_STS_TKLG     TKL,
                           SLM_ORD_DESIGN_STS_TKLG_LST TKL_LST
                           LEFT JOIN CORE_APP_USER USE
                           ON USE.USERID = TKL_LST.CREATE_NAME
                     WHERE TKL.DESGIN_KEY = TKL_LST.DESGIN_KEY
                       AND TKL.VALIDFLAG = '1'
                       AND TKL.ORD_LN_PK = H.PSC_BL) REVIEW_MAN,
                       M.MEMO,
                       M.OTHER_EDIT_NAME,
                       M.CRAFT_CHANGE_MEMO,
                       H.PSC_BL MNG_ORDER_NO,
                       NULL STRANDING_DAY,
                       DECODE(M.PIC_FD_CHECK, '1', 'True', 'False') PIC_FD_CHECK,
                       DECODE(M.WIC_FD_CHECK, '1', 'True', 'False') WIC_FD_CHECK,
                       DECODE(M.CIC_FD_CHECK, '1', 'True', 'False') CIC_FD_CHECK,
                       M.REASON,
                       NULL SUPPLY_UNIT_DESC,null WBS_CODE
                  FROM COM_MSC_BL H
                  LEFT JOIN CRAFT_ORD_DESIGN_APPOINT S
                    ON S.ORD_LN_PK = NVL(H.PSC_BL, '-1')
                  LEFT JOIN COM_PSC PS
                    ON PS.STD_CODE = NVL(H.STD_CODE, '-1')
                   AND PS.PRODUCCODE = NVL(H.PRODUCCODE, '-1')
                   AND PS.STEELCODE = NVL(H.STEELCODE, '-1')
                   AND NVL(PS.STD_STYLE, '/') = NVL(H.STD_STYLE, '/')
                   AND PS.VALIDFLAG = '1'
                  LEFT JOIN COM_PSC_R_MSC PSRMS
                    ON PSRMS.PSC = NVL(PS.PSC, '-1')
                  LEFT JOIN COM_MSC MS
                    ON NVL(PSRMS.MSC, '-1') = MS.MSC
                   AND MS.USE_CODE = NVL(H.USE_CODE, '-1'), CRAFT_ORD_DESIGN M
                  LEFT JOIN CRAFT_ORD_DESIGN_STS_TKLG K
                    ON K.DESGIN_KEY = NVL(M.DESGIN_KEY, '-1')
                   AND K.VALIDFLAG = '1'
                 WHERE M.CRAFT_SEQ =
                       (SELECT MAX(CRAFT_SEQ)
                          FROM CRAFT_ORD_DESIGN
                         WHERE ORD_LN_PK = M.ORD_LN_PK)
                   AND M.VALIDFLAG <> '0'
                   AND DECODE('#DESIGN_STS#', NULL, '1', K.DESIGN_STS) =
                       DECODE('#DESIGN_STS#', NULL, '1', '#DESIGN_STS#')
                   AND DECODE('#REVIEW_STATUS#', NULL, '1', M.VALIDFLAG) =
                       DECODE('#REVIEW_STATUS#', NULL, '1', '#REVIEW_STATUS#')
                   AND M.ORD_LN_PK = H.PSC_BL
                   AND M.VALIDFLAG <> '0'
                   AND H.VALIDFLAG = '1'
                   AND '#IS_POPUP#' = 'True'
                   AND LOWER(H.PSC_BL) || '&' LIKE
                       '%' || LOWER('#ORDER_NO#') || '%'
                   AND DECODE('#BEGIN_TIME#', NULL, SYSDATE, H.CREATE_TIME) BETWEEN
                       DECODE('#BEGIN_TIME#',
                              NULL,
                              SYSDATE,
                              TO_DATE('#BEGIN_TIME#', 'YYYY-MM-DD HH24:MI:SS')) AND
                       DECODE('#BEGIN_TIME#',
                              NULL,
                              SYSDATE,
                              TO_DATE('#END_TIME#', 'YYYY-MM-DD HH24:MI:SS')))
         WHERE DECODE(PSC, NULL, 1, MSC_RN) <= 1
        UNION ALL

        SELECT *
          FROM (SELECT '' DESGIN_KEY,
                       '未制定' REVIEW_STATUS,
                       '' DESIGN_STS,
                       NULL PORDERSTATUS,
                       NULL ROLL_MONTH,
                       NULL ROLL_WELL_MONTH,
                       DECODE(H.REVIEW_STATUS,
                              '0',
                              '待技术评审',
                              '1',
                              '技术评审中',
                              '2',
                              '技术评审通过',
                              '3',
                              '技术评审通过',
                              '未识别') ORDER_LN_STATUS,
                       '' CRAFT_NO,
                       NULL CRAFT_NO_V_C,
                       NULL CRAFT_NO_V_N,
                       0 CRAFT_CNT,
                       TO_NUMBER('') CRAFT_SEQ,
                       S.APPOINT_NAME,
                       TO_CHAR(S.APPOINT_TIME, 'YYYY-MM-DD HH24:MI:SS') APPOINT_TIME,
                       S.CRAFT_NAME,
                       S.CRAFT_ID,
                       NULL ORD_PK,
                       H.PSC_BL ORD_LN_PK,
                       NULL ORDER_SEQ,
                       NULL FINAL_USER,
                       NULL FINAL_USER_DESC,
                       PS.PSC,
                       PS.PSC_DESC,
                       NULL ORDER_SPEC_CODE,
                       NULL ORDER_SPEC_DESC,
                       H.MODEL_CODE,
                       H.MODEL_DESC,
                       NULL LEN_DESC,
                       NULL ORDER_QTY,
                       NULL ORDER_UNIT,
                       NULL PRDCT_WGT,
                       NULL DELVRY_RANGE_TPE,
                       NULL DELVRY_RANGE_MIN,
                       NULL DELVRY_RANGE_MAX,
                       NULL DELVRY_RANGE,
                       NULL OUTS_BILLET_FL,
                       NULL OUTS_STL_PIPE_FL,
                       'False' ASSEL_FL,
                       NULL ORDER_ADD_DESC,
                       NULL ORDER_SPECIAL_DESC,
                       NULL CUST_ALPHA_NO,
                       H.PSC_BL ORDER_NO,
                       NULL SALE_ORG,
                       NULL CUSTOMER_NO,
                       NULL REVW_RPT_NO,
                       NULL PRODUCER_FL,
                       MS.MSC,
                       MS.MSC_DESC,
                       NULL SPEC_CODE,
                       H.MIN_D || 'x' || H.MIN_H SPEC_NAME,
                       H.MIN_D DIMATER,
                       H.MIN_H HEIGHT,
                       H.STEELNAME,
                       NULL ADD_ASK_NO,
                       'False' MPS_FL,
                       NULL MPS_NO,
                       NULL MPS_DESC,
                       H.STD_CODE,
                       H.STD_NAME,
                       H.USE_DESC,
                       NULL MAN_INSPECTION,
                       NULL INSPECTION_VALUE,
                       TO_CHAR(H.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
                       H.CREATE_NAME,
                       NULL EFFECT_TIME,
                       NULL EFFECT_NAME,
                       MS.UNIT_CODE_PROCESS UNIT_CODE,
                       MS.UNIT_DESC_PROCESS UNIT_DESC, --002001001001
                       NULL PLAN_RN,
                       NULL PLAN_ORD_LN_PK,
                       NULL CRAFT_PATH,
                       GET_ALL_ADD_ASK_DESC('', PS.STD_CODE, '') STD_ADD_DESC,
                       ROW_NUMBER() OVER(PARTITION BY PS.PSC ORDER BY MS.MSC) MSC_RN,
                       NULL CHGE_VAL,
                       NULL CRAFT_TYPE,
                       (SELECT DECODE(MIN(TKL_LST.CREATE_NAME), 'SYSTEM', 'SYSTEM', MAX(USERNAME))
                      FROM SLM_ORD_DESIGN_STS_TKLG     TKL,
                           SLM_ORD_DESIGN_STS_TKLG_LST TKL_LST
                           LEFT JOIN CORE_APP_USER USE
                           ON USE.USERID = TKL_LST.CREATE_NAME
                     WHERE TKL.DESGIN_KEY = TKL_LST.DESGIN_KEY
                       AND TKL.VALIDFLAG = '1'
                       AND TKL.ORD_LN_PK = H.PSC_BL) REVIEW_MAN,
                       NULL MEMO,
                       NULL OTHER_EDIT_NAME,
                       NULL CRAFT_CHANGE_MEMO,
                       H.PSC_BL MNG_ORDER_NO,
                       NULL STRANDING_DAY,
                       'False' PIC_FD_CHECK,
                       'False' WIC_FD_CHECK,
                       'False' CIC_FD_CHECK,
                       NULL REASON,
                       NULL SUPPLY_UNIT_DESC,null WBS_CODE
                  FROM COM_MSC_BL H
                  LEFT JOIN CRAFT_ORD_DESIGN_APPOINT S
                    ON S.ORD_LN_PK = NVL(H.PSC_BL, '-1')
                  LEFT JOIN COM_PSC PS
                    ON PS.STD_CODE = NVL(H.STD_CODE, '-1')
                   AND PS.PRODUCCODE = NVL(H.PRODUCCODE, '-1')
                   AND PS.STEELCODE = NVL(H.STEELCODE, '-1')
                   AND NVL(PS.STD_STYLE, '/') = NVL(H.STD_STYLE, '/')
                   AND PS.VALIDFLAG = '1'
                  LEFT JOIN COM_PSC_R_MSC PSRMS
                    ON PSRMS.PSC = NVL(PS.PSC, '-1')
                  LEFT JOIN COM_MSC MS
                    ON NVL(PSRMS.MSC, '-1') = MS.MSC
                   AND MS.USE_CODE = NVL(H.USE_CODE, '-1')
                  LEFT JOIN CRAFT_ORD_DESIGN MV
                    ON MV.ORD_LN_PK = NVL(H.PSC_BL, '-1')
                   AND MV.VALIDFLAG = '1'
                 WHERE H.VALIDFLAG = '1'
                   AND LOWER(H.PSC_BL) || '&' LIKE
                       '%' || LOWER('#ORDER_NO#') || '%'
                   AND DECODE('#BEGIN_TIME#', NULL, SYSDATE, H.CREATE_TIME) BETWEEN
                       DECODE('#BEGIN_TIME#',
                              NULL,
                              SYSDATE,
                              TO_DATE('#BEGIN_TIME#', 'YYYY-MM-DD HH24:MI:SS')) AND
                       DECODE('#BEGIN_TIME#',
                              NULL,
                              SYSDATE,
                              TO_DATE('#END_TIME#', 'YYYY-MM-DD HH24:MI:SS'))
                   AND '1' =
                       DECODE('#DESIGN_STS#', NULL, '1', '#DESIGN_STS#')
                   AND '#IS_POPUP#' = 'True'
                   AND NOT EXISTS
                 (SELECT 1
                          FROM CRAFT_ORD_DESIGN M
                         WHERE M.ORD_LN_PK = H.PSC_BL
                           AND M.VALIDFLAG <> '0')
                   AND '6' =
                       DECODE('#REVIEW_STATUS#', NULL, '6', '#REVIEW_STATUS#'))
         WHERE DECODE(PSC, NULL, 1, MSC_RN) <= 1)
 ORDER BY ORDER_NO, ORDER_SEQ
		]]>
	</query>


	<query id="CoreOrderReviewTechnology.doQueryCraftBBHT" desc="获取合同行主信息工艺">
		<![CDATA[
SELECT *
  FROM (SELECT T1.DESGIN_KEY,
               T1.REVIEW_STATUS,
               T1.DESIGN_STS,
               T1.PORDERSTATUS,
               T1.ROLL_MONTH,
               T1.ROLL_WELL_MONTH,
               T1.ORDER_LN_STATUS,
               T1.CRAFT_NO,
               T1.CRAFT_NO_V_C,
               T1.CRAFT_NO_V_N,
               T1.CRAFT_CNT,
               T1.CRAFT_SEQ,
               T1.APPOINT_NAME,
               T1.APPOINT_TIME,
               T1.CRAFT_NAME,
               T1.CRAFT_ID,
               T1.ORD_PK,
               T1.ORD_LN_PK,
               T1.ORDER_SEQ,
               T1.FINAL_USER,
               T1.FINAL_USER_DESC,
               T1.PSC,
               T1.PSC_DESC,
               T1.ORDER_SPEC_CODE,
               T1.ORDER_SPEC_DESC,
               T1.MODEL_CODE,
               T1.MODEL_DESC,
               T1.LEN_DESC,
               T1.ORDER_QTY,
               T1.ORDER_UNIT,
               T1.PRDCT_WGT,
               T1.DELVRY_RANGE_TPE,
               T1.DELVRY_RANGE_MIN,
               T1.DELVRY_RANGE_MAX,
               T1.DELVRY_RANGE,
               T1.OUTS_BILLET_FL,
               T1.OUTS_STL_PIPE_FL,
               T1.ASSEL_FL,
               T1.DESCRIPTION_DIFF,
               T1.ORDER_SPECIAL_DESC,
               T1.CUST_ALPHA_NO,
               T1.ORDER_NO,
               T1.SALE_ORG,
               T1.CUSTOMER_NO,
               T1.REVW_RPT_NO,
               T1.PRODUCER_FL,
               T1.MSC,
               T1.MSC_DESC,
               T1.SPEC_CODE,
               T1.SPEC_NAME,
               T1.DIMATER,
               T1.HEIGHT,
               T1.STEELNAME,
               T1.ADD_ASK_NO,
               T1.MPS_FL,
               T1.MPS_NO,
               T1.MPS_DESC,
               T1.STD_CODE,
               T1.STD_NAME,
               T1.USE_DESC,
               T1.MAN_INSPECTION,
               T1.INSPECTION_VALUE,
               T1.CREATE_TIME,
               T1.CREATE_NAME,
               T1.EFFECT_TIME,
               T1.EFFECT_MAN,
               T1.UNIT_CODE,
               T1.UNIT_DESC,
               T1.PLAN_RN,
               T1.PLAN_ORD_LN_PK,
               T1.CRAFT_PATH,
               T1.DESCRIPTION_ALL,
               T1.MSC_RN,
               T1.CHGE_VAL,
               DECODE(T1.CRAFT_NO,
                      NULL,
                      NULL,
                      DECODE((SELECT 1
                               FROM CRAFT_ORD_DESIGN_FILE FIL
                              WHERE FIL.CRAFT_NO = NVL(T1.CRAFT_NO, '-1')
                                AND FIL.CRAFT_NO_V =
                                    NVL(T1.CRAFT_NO_V_C, '-1')),
                             NULL,
                             'L',
                             'G')) CRAFT_TYPE,
               (SELECT DECODE(MIN(TKL_LST.CREATE_NAME), 'SYSTEM', 'SYSTEM', MAX(USERNAME))
                  FROM SLM_ORD_DESIGN_STS_TKLG     TKL,
                       SLM_ORD_DESIGN_STS_TKLG_LST TKL_LST
                       LEFT JOIN CORE_APP_USER USE
                       ON USE.USERID = TKL_LST.CREATE_NAME
                 WHERE TKL.DESGIN_KEY = TKL_LST.DESGIN_KEY
                   AND TKL.VALIDFLAG = '1'
                   AND TKL.ORD_LN_PK = T1.ORD_LN_PK) REVIEW_MAN,
               T1.MEMO,
               T1.OTHER_EDIT_NAME,
               T1.CRAFT_CHANGE_MEMO,
               T1.ORDER_NO || '/' || T1.ORDER_SEQ MNG_ORDER_NO,
               T1.STRANDING_DAY,
               T1.PIC_FD_CHECK,
               T1.WIC_FD_CHECK,
               T1.CIC_FD_CHECK,
               T1.REASON,
               T1.SUPPLY_UNIT_DESC
          FROM (SELECT K.DESGIN_KEY,
                       DECODE(M.VALIDFLAG,
                              '1',
                              '生效',
                              '2',
                              '制定中',
                              '3',
                              '科室审核中',
                              '4',
                              '审批中',
                              '5',
                              '审核失败',
                              '6',
                              '相关科室审核中',
                              '7',
                              '批准中',
                              '9',
                              '待生成',
                              '8',
                              '变更待生效') REVIEW_STATUS,
                       DECODE(K.DESIGN_STS,
                              'W',
                              '等待',
                              'S',
                              '通过',
                              'F',
                              '失败') DESIGN_STS,
                       DECODE(J.PORDERSTATUS,
                              NULL,
                              '未提报',
                              '0',
                              '待接收',
                              '1',
                              '已接收',
                              '2',
                              '已下发',
                              '3',
                              '生产中',
                              '4',
                              '生产完成',
                              '5',
                              '缴库完成') PORDERSTATUS,
                       J.ROLL_MONTH,
                       J.ROLL_WELL_MONTH,
                       BI.BASENAME ORDER_LN_STATUS,
                       M.CRAFT_NO,
                       H.CRAFT_NO_V CRAFT_NO_V_C,
                       (SELECT MAX(CRAFT_NO_V)
                          FROM CRAFT_ORD_DESIGN
                         WHERE CRAFT_NO = H.CRAFT_NO) CRAFT_NO_V_N,
                       (SELECT COUNT(1)
                          FROM CRAFT_ORD_DESIGN
                         WHERE ORD_LN_PK = M.ORD_LN_PK
                           AND VALIDFLAG <> '0'
                           AND CRAFT_NO IS NOT NULL) CRAFT_CNT,
                       M.CRAFT_SEQ,
                       S.APPOINT_NAME,
                       TO_CHAR(S.APPOINT_TIME, 'YYYY-MM-DD HH24:MI:SS') APPOINT_TIME,
                       S.CRAFT_NAME,
                       S.CRAFT_ID,
                       H.ORD_PK,
                       H.ORD_LN_PK,
                       H.ORDER_SEQ,
                       H.FINAL_USER,
                       H.FINAL_USER_DESC,
                       H.PSC,
                       H.PSC_DESC,
                       H.ORDER_SPEC_CODE,
                       H.ORDER_SPEC_DESC,
                       H.MODEL_CODE,
                       H.MODEL_DESC,
                       H.LEN_DESC,
                       H.ORDER_QTY,
                       H.ORDER_UNIT,
                       ROUND(H.PRDCT_WGT, 4) PRDCT_WGT,
                       H.DELVRY_RANGE_TPE,
                       H.DELVRY_RANGE_MIN,
                       H.DELVRY_RANGE_MAX,
                       '-' || H.DELVRY_RANGE_MIN || H.DELVRY_RANGE_TPE || '，' || '+' ||
                       H.DELVRY_RANGE_MAX || H.DELVRY_RANGE_TPE DELVRY_RANGE,
                       (SELECT BASENAME
                          FROM COM_BASE_INFO
                         WHERE BASECODE = H.OUTS_BILLET_FL) OUTS_BILLET_FL,
                       (SELECT BASENAME
                          FROM COM_BASE_INFO
                         WHERE BASECODE = H.OUTS_STL_PIPE_FL) OUTS_STL_PIPE_FL,
                       DECODE(H.ASSEL_FL, '1', 'True', 'False') ASSEL_FL,
                       H.ORDER_ADD_DESC,
                       H.ORDER_SPECIAL_DESC,
                       H.CUST_ALPHA_NO,
                       G.ORDER_NO,
                       G.SALE_ORG,
                       G.CUSTOMER_NO,
                       G.REVW_RPT_NO,
                       DECODE(H.PRODUCER_FL, '1', 'True', 'False') PRODUCER_FL,
                       H.MSC,
                       H.MSC_DESC,
                       H.SPEC_CODE,
                       H.SPEC_NAME,
                       H.DIMATER,
                       H.HEIGHT,
                       H.STEELNAME,
                       H.ADD_ASK_NO,
                       DECODE(H.MPS_FL, '1', 'True', 'False') MPS_FL,
                       H.MPS_NO_INPUT MPS_NO,
                       H.MPS_DESC,
                       H.STD_CODE,
                       H.STD_NAME,
                       H.USE_DESC,
                       DECODE(H.MAN_INSPECTION,
                              '1',
                              '可手探',
                              '0',
                              '不可手探') MAN_INSPECTION,
                       H.INSPECTION_VALUE,
                       TO_CHAR(H.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
                       H.CREATE_NAME,
                       TO_CHAR(G.EFFECT_TIME, 'YYYY-MM-DD HH24:MI:SS') EFFECT_TIME,
                       G.EFFECT_MAN,
                       NVL((select min(Q.UNIT_CODE)
                          from CRAFT_ORD_DESIGN_STS_TKLG_LST Q
                         WHERE Q.DESIGN_STS = 'F'
                           AND Q.VALIDFLAG = '1'
                           AND Q.DESGIN_KEY = M.DESGIN_KEY), MSC.UNIT_CODE_PROCESS) UNIT_CODE,
                       nvl((select min(Q.UNIT_DESC)
                          from CRAFT_ORD_DESIGN_STS_TKLG_LST Q
                         WHERE Q.DESIGN_STS = 'F'
                           AND Q.VALIDFLAG = '1'
                           AND Q.DESGIN_KEY = M.DESGIN_KEY), MSC.UNIT_DESC_PROCESS) UNIT_DESC,
                       (select min(Q.LST_ITEM)
                          from CRAFT_ORD_DESIGN_STS_TKLG_LST Q
                         WHERE Q.DESIGN_STS = 'F'
                           AND Q.VALIDFLAG = '1'
                           AND Q.DESGIN_KEY = M.DESGIN_KEY) LST_ITEM,
                       ROW_NUMBER() OVER(PARTITION BY J.ORD_LN_PK ORDER BY J.DELIVERY_NO) PLAN_RN,
                       J.ORD_LN_PK PLAN_ORD_LN_PK,
                       M.CRAFT_PATH,
                       NULL MSC_RN,
                       CHG.CHGE_VAL,
                       M.MEMO,
                       M.OTHER_EDIT_NAME,
                       M.CRAFT_CHANGE_MEMO,
                       (SELECT MAX(OO.DESCRIPTION_DIFF)
                          FROM CRAFT_ORD_DESIGN_ADD_ASK OO
                         WHERE OO.DESGIN_KEY = M.DESGIN_KEY) DESCRIPTION_DIFF,
                       (SELECT MAX(OO.DESCRIPTION_ALL)
                          FROM CRAFT_ORD_DESIGN_ADD_ASK OO
                         WHERE OO.DESGIN_KEY = M.DESGIN_KEY) DESCRIPTION_ALL,
                       CASE
                       --评审状态不等于生效并且合同状态大于等于开始提报
                         WHEN M.VALIDFLAG <> '1' AND
                              H.ORDER_LN_STATUS >= '12020401' THEN
                          FLOOR(SYSDATE - NVL((SELECT MIN(P.CREATE_TIME)
                                                FROM PLN_SALEORD P
                                               WHERE P.ORD_LN_PK = H.ORD_LN_PK),
                                              SYSDATE)) --滞留天数=当前时间-最小的提报时间
                         ELSE
                          NULL
                       END STRANDING_DAY,
                       DECODE(M.PIC_FD_CHECK, '1', 'True', 'False') PIC_FD_CHECK,
                       DECODE(M.WIC_FD_CHECK, '1', 'True', 'False') WIC_FD_CHECK,
                       DECODE(M.CIC_FD_CHECK, '1', 'True', 'False') CIC_FD_CHECK,
                       M.REASON,
                       (SELECT BASENAME FROM COM_BASE_INFO WHERE BASECODE=G.SUPPLY_UNIT) SUPPLY_UNIT_DESC
                  FROM SLM_ORDER_HEAD G, COM_MSC MSC
                  LEFT JOIN COM_PSC_R_MSC PRM
                    ON PRM.MSC = NVL(MSC.MSC, '-1')
                  LEFT JOIN COM_PSC PSC
                    ON PSC.PSC = NVL(PRM.PSC, '-1'), SLM_ORDER_LINE H
                  LEFT JOIN CHGE_SLM_APPLY_M CHG
                    ON CHG.ORDER_CHGE_NO = NVL(H.ORDER_CHGE_NO, '-1')
                  LEFT JOIN CRAFT_ORD_DESIGN_FILE F
                    ON F.CRAFT_NO = NVL(H.CRAFT_NO, '-1')
                   AND F.CRAFT_NO_V = NVL(H.CRAFT_NO_V, '-1')
                  LEFT JOIN COM_BASE_INFO BI
                    ON BI.BASECODE = NVL(H.ORDER_LN_STATUS, '-1')
                  LEFT JOIN PLN_SALEORD J
                    ON J.ORD_LN_PK = NVL(H.ORD_LN_PK, '-1')
                  LEFT JOIN CRAFT_ORD_DESIGN_APPOINT S
                    ON S.ORD_LN_PK = NVL(H.ORD_LN_PK, '-1'), CRAFT_ORD_DESIGN M
                  LEFT JOIN CRAFT_ORD_DESIGN_STS_TKLG K
                    ON K.DESGIN_KEY = NVL(M.DESGIN_KEY, '-1')
                   AND K.VALIDFLAG = '1'
                 WHERE H.ORD_PK = G.ORD_PK
                   AND G.VALIDFLAG = '1'
                   AND H.ORDER_LN_STATUS >= '12020301'
                   --AND H.ORDER_LN_STATUS <= '12020601'
                   AND G.ORDER_TYP <> '120102'
                   AND MSC.MSC = H.MSC
                   AND M.CRAFT_SEQ =
                       (SELECT MAX(CRAFT_SEQ)
                          FROM CRAFT_ORD_DESIGN
                         WHERE ORD_LN_PK = M.ORD_LN_PK)
                   AND M.VALIDFLAG <> '0'
                   AND DECODE('#DESIGN_STS#', NULL, '1', K.DESIGN_STS) =
                       DECODE('#DESIGN_STS#', NULL, '1', '#DESIGN_STS#')
                   AND DECODE('#REVIEW_STATUS#', NULL, '1', M.VALIDFLAG) =
                       DECODE('#REVIEW_STATUS#', NULL, '1', '#REVIEW_STATUS#')
                   AND M.ORD_LN_PK = H.ORD_LN_PK
                   AND M.VALIDFLAG <> '0'
                   AND H.VALIDFLAG = '1'
                   #SUPPLY_UNIT_FLAG#
                   AND ('#PLAN_STATUS#' IS NULL OR '#PLAN_STATUS#' = '1' OR
                       (J.PORDERSTATUS IN ('1', '2', '3') OR
                       (J.PORDERSTATUS IN ('4', '5') AND
                       TO_DATE(J.ROLL_MONTH, 'YYYY-MM') =
                       TO_DATE(TO_CHAR(SYSDATE, 'YYYY-MM'), 'YYYY-MM'))))
                   AND ('#URGENT#' = '0' OR
                       ((J.PORDERSTATUS = '1' AND M.CRAFT_NO IS NULL) OR
                       (J.PORDERSTATUS = '2' AND M.VALIDFLAG <> '1') OR
                       (J.PORDERSTATUS = '0' AND M.VALIDFLAG <> '1')))
                   AND LOWER(G.ORDER_NO) LIKE
                       '%' || LOWER('#ORDER_NO#') || '%'
                   AND DECODE('#ORDER_SEQ#', NULL, '1', H.ORDER_SEQ) =
                       NVL('#ORDER_SEQ#', '1')
                   AND EXISTS (SELECT 1 FROM SLM_ORDER_HEAD WHERE CUSTM_ORDER_NO = G.ORDER_NO AND VALIDFLAG = '1'  AND ORDER_NO LIKE 'TH%')
                   AND DECODE('#BEGIN_TIME#', NULL, SYSDATE, G.EFFECT_TIME) BETWEEN
                       DECODE('#BEGIN_TIME#',
                              NULL,
                              SYSDATE,
                              TO_DATE('#BEGIN_TIME#', 'YYYY-MM-DD HH24:MI:SS')) AND
                       DECODE('#BEGIN_TIME#',
                              NULL,
                              SYSDATE,
                              TO_DATE('#END_TIME#', 'YYYY-MM-DD HH24:MI:SS'))) T1
         WHERE DECODE(T1.PLAN_ORD_LN_PK, NULL, 1, PLAN_RN) <= 1
           AND (T1.CRAFT_ID = '#USER_ID#' OR
                (T1.LST_ITEM = '试样码' AND EXISTS
                 (SELECT 1
                    FROM CRAFT_SPLINE_UNIT T
                   WHERE T.UNIT_CODE IN ('#UNIT_CODE_S#'))) OR
                T1.UNIT_CODE IN ('#UNIT_CODE_S#') OR '#USER_ID#' = 'admin')
        UNION ALL

        SELECT *
          FROM (SELECT '' DESGIN_KEY,
                       '未制定' REVIEW_STATUS,
                       '' DESIGN_STS,
                       DECODE(J.PORDERSTATUS,
                              NULL,
                              '未提报',
                              '0',
                              '待接收',
                              '1',
                              '已接收',
                              '2',
                              '已下发',
                              '3',
                              '生产中',
                              '4',
                              '生产完成',
                              '5',
                              '缴库完成') PORDERSTATUS,
                       J.ROLL_MONTH,
                       J.ROLL_WELL_MONTH,
                       BI.BASENAME ORDER_LN_STATUS,
                       NULL CRAFT_NO,
                       NULL CRAFT_NO_V_C,
                       NULL CRAFT_NO_V_N,
                       0 CRAFT_CNT,
                       TO_NUMBER('') CRAFT_SEQ,
                       S.APPOINT_NAME,
                       TO_CHAR(S.APPOINT_TIME, 'YYYY-MM-DD HH24:MI:SS') APPOINT_TIME,
                       S.CRAFT_NAME,
                       S.CRAFT_ID,
                       H.ORD_PK,
                       H.ORD_LN_PK,
                       H.ORDER_SEQ,
                       H.FINAL_USER,
                       H.FINAL_USER_DESC,
                       H.PSC,
                       H.PSC_DESC,
                       H.ORDER_SPEC_CODE,
                       H.ORDER_SPEC_DESC,
                       H.MODEL_CODE,
                       H.MODEL_DESC,
                       H.LEN_DESC,
                       H.ORDER_QTY,
                       H.ORDER_UNIT,
                       ROUND(H.PRDCT_WGT, 4) PRDCT_WGT,
                       H.DELVRY_RANGE_TPE,
                       H.DELVRY_RANGE_MIN,
                       H.DELVRY_RANGE_MAX,
                       '-' || H.DELVRY_RANGE_MIN || H.DELVRY_RANGE_TPE || '，' || '+' ||
                       H.DELVRY_RANGE_MAX || H.DELVRY_RANGE_TPE DELVRY_RANGE,
                       (SELECT BASENAME
                          FROM COM_BASE_INFO
                         WHERE BASECODE = H.OUTS_BILLET_FL) OUTS_BILLET_FL,
                       (SELECT BASENAME
                          FROM COM_BASE_INFO
                         WHERE BASECODE = H.OUTS_STL_PIPE_FL) OUTS_STL_PIPE_FL,
                       DECODE(H.ASSEL_FL, '1', 'True', 'False') ASSEL_FL,
                       GET_ALL_ADD_ASK_DESC(H.ADD_ASK_NO, '', '新增修改项') DESCRIPTION_DIFF,
                       H.ORDER_SPECIAL_DESC,
                       H.CUST_ALPHA_NO,
                       G.ORDER_NO,
                       G.SALE_ORG,
                       G.CUSTOMER_NO,
                       G.REVW_RPT_NO,
                       DECODE(H.PRODUCER_FL, '1', 'True', 'False') PRODUCER_FL,
                       H.MSC,
                       H.MSC_DESC,
                       H.SPEC_CODE,
                       H.SPEC_NAME,
                       H.DIMATER,
                       H.HEIGHT,
                       H.STEELNAME,
                       H.ADD_ASK_NO,
                       DECODE(H.MPS_FL, '1', 'True', 'False') MPS_FL,
                       H.MPS_NO_INPUT MPS_NO,
                       H.MPS_DESC,
                       H.STD_CODE,
                       H.STD_NAME,
                       H.USE_DESC,
                       DECODE(H.MAN_INSPECTION,
                              '1',
                              '可手探',
                              '0',
                              '不可手探') MAN_INSPECTION,
                       H.INSPECTION_VALUE,
                       TO_CHAR(H.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
                       H.CREATE_NAME,
                       TO_CHAR(G.EFFECT_TIME, 'YYYY-MM-DD HH24:MI:SS') EFFECT_TIME,
                       G.EFFECT_MAN,
                       MSC.UNIT_CODE_PROCESS UNIT_CODE,
                       MSC.UNIT_DESC_PROCESS UNIT_DESC, --002001001001
                       ROW_NUMBER() OVER(PARTITION BY J.ORD_LN_PK ORDER BY J.DELIVERY_NO) PLAN_RN,
                       J.ORD_LN_PK PLAN_ORD_LN_PK,
                       F.CRAFT_PATH,
                       NVL(H.ORDER_ADD_DESC,
                           GET_ALL_ADD_ASK_DESC('', H.STD_CODE, '')) DESCRIPTION_ALL,
                       NULL MSC_RN,
                       CHG.CHGE_VAL,
                       NULL CRAFT_TYPE,
                       (SELECT DECODE(MIN(TKL_LST.CREATE_NAME), 'SYSTEM', 'SYSTEM', MAX(USERNAME))
                      FROM SLM_ORD_DESIGN_STS_TKLG     TKL,
                           SLM_ORD_DESIGN_STS_TKLG_LST TKL_LST
                           LEFT JOIN CORE_APP_USER USE
                           ON USE.USERID = TKL_LST.CREATE_NAME
                     WHERE TKL.DESGIN_KEY = TKL_LST.DESGIN_KEY
                       AND TKL.VALIDFLAG = '1'
                       AND TKL.ORD_LN_PK = H.ORD_LN_PK) REVIEW_MAN,
                       NULL MEMO,
                       NULL OTHER_EDIT_NAME,
                       NULL CRAFT_CHANGE_MEMO,
                       G.ORDER_NO || '/' || H.ORDER_SEQ MNG_ORDER_NO,
                       CASE
                       --合同状态大于等于开始提报
                         WHEN H.ORDER_LN_STATUS >= '12020401' THEN
                          FLOOR(SYSDATE - NVL((SELECT MIN(P.CREATE_TIME)
                                                FROM PLN_SALEORD P
                                               WHERE P.ORD_LN_PK = H.ORD_LN_PK),
                                              SYSDATE)) --滞留天数=当前时间-最小的提报时间
                         ELSE
                          NULL
                       END STRANDING_DAY,
                       'False' PIC_FD_CHECK,
                       'False' WIC_FD_CHECK,
                       'False' CIC_FD_CHECK,
                       NULL RESON,
                       (SELECT BASENAME FROM COM_BASE_INFO WHERE BASECODE=G.SUPPLY_UNIT) SUPPLY_UNIT_DESC
                  FROM SLM_ORDER_HEAD G, COM_MSC MSC
                  LEFT JOIN COM_PSC_R_MSC PRM
                    ON PRM.MSC = NVL(MSC.MSC, '-1')
                  LEFT JOIN COM_PSC PSC
                    ON PSC.PSC = NVL(PRM.PSC, '-1'), SLM_ORDER_LINE H
                  LEFT JOIN CHGE_SLM_APPLY_M CHG
                    ON CHG.ORDER_CHGE_NO = NVL(H.ORDER_CHGE_NO, '-1')
                  LEFT JOIN CRAFT_ORD_DESIGN_FILE F
                    ON F.CRAFT_NO = NVL(H.CRAFT_NO, '-1')
                   AND F.CRAFT_NO_V = NVL(H.CRAFT_NO_V, '-1')
                  LEFT JOIN COM_BASE_INFO BI
                    ON BI.BASECODE = NVL(H.ORDER_LN_STATUS, '-1')
                  LEFT JOIN PLN_SALEORD J
                    ON J.ORD_LN_PK = NVL(H.ORD_LN_PK, '-1')
                  LEFT JOIN CRAFT_ORD_DESIGN_APPOINT S
                    ON S.ORD_LN_PK = NVL(H.ORD_LN_PK, '-1')
                 WHERE H.ORD_PK = G.ORD_PK
                   AND G.VALIDFLAG = '1'
                   AND H.ORDER_LN_STATUS >= '12020301'
                   AND H.ORDER_LN_STATUS <= '12020601'
                   AND G.ORDER_TYP <> '120102'
                   AND H.VALIDFLAG = '1'
                   #SUPPLY_UNIT_FLAG#
                   AND EXISTS (SELECT 1 FROM SLM_ORDER_HEAD WHERE CUSTM_ORDER_NO = G.ORDER_NO AND VALIDFLAG = '1'  AND ORDER_NO LIKE 'TH%')
                   AND ('#PLAN_STATUS#' IS NULL OR '#PLAN_STATUS#' = '1' OR
                       (J.PORDERSTATUS IN ('1', '2', '3') OR
                       (J.PORDERSTATUS IN ('4', '5') AND
                       TO_DATE(J.ROLL_MONTH, 'YYYY-MM') =
                       TO_DATE(TO_CHAR(SYSDATE, 'YYYY-MM'), 'YYYY-MM'))))
                   AND MSC.MSC = H.MSC
                   AND ('#URGENT#' = '0' OR J.ROLL_MONTH >= '2017-05')
                   AND LOWER(G.ORDER_NO) LIKE
                       '%' || LOWER('#ORDER_NO#') || '%'
                   AND DECODE('#ORDER_SEQ#', NULL, '1', H.ORDER_SEQ) =
                       NVL('#ORDER_SEQ#', '1')
                   AND DECODE('#BEGIN_TIME#', NULL, SYSDATE, G.EFFECT_TIME) BETWEEN
                       DECODE('#BEGIN_TIME#',
                              NULL,
                              SYSDATE,
                              TO_DATE('#BEGIN_TIME#', 'YYYY-MM-DD HH24:MI:SS')) AND
                       DECODE('#BEGIN_TIME#',
                              NULL,
                              SYSDATE,
                              TO_DATE('#END_TIME#', 'YYYY-MM-DD HH24:MI:SS'))
                   AND '1' =
                       DECODE('#DESIGN_STS#', NULL, '1', '#DESIGN_STS#')
                   AND NOT EXISTS
                 (SELECT 1
                          FROM CRAFT_ORD_DESIGN M
                         WHERE M.ORD_LN_PK = H.ORD_LN_PK
                           AND M.VALIDFLAG <> '0')
                   AND '6' =
                       DECODE('#REVIEW_STATUS#', NULL, '6', '#REVIEW_STATUS#'))
         WHERE DECODE(PLAN_ORD_LN_PK, NULL, 1, PLAN_RN) <= 1
           AND (CRAFT_ID = '#USER_ID#' OR UNIT_CODE IN ('#UNIT_CODE_S#') OR
                '#USER_ID#' = 'admin'))
 ORDER BY ORDER_NO, ORDER_SEQ
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.GetOrderLineDelivery" desc="获取合同行下交货信息">
		<![CDATA[
SELECT *
  FROM (SELECT A.ORD_PK,
               A.ORD_LN_PK,
               A.ORD_LN_DLY_PK,
               A.DELIVERY_NO,
               B.MSC_PLINE,
               TO_CHAR(A.DELVRY_EDATE, 'yyyy-mm-dd') DELVRY_EDATE,
               A.DELVRY_QTY,
               A.ORDER_UNIT,
               A.WGT_ESTMT,
               A.ENSU_TOTL_LEN,
               TO_CHAR(B.RCMD_DELVRY_EDATE, 'yyyy-mm-dd') RCMD_DELVRY_EDATE,
               ROUND(B.PRD_CYC, 4) PRD_CYC,
               B.CYC_EDIT,
               A.RECEIV_NO,
               A.RECEIV_NM,
               A.DELVRY_ADDR,
               DECODE(A.AGENCY_FL, '1', 'True', 'False') AGENCY_FL,
               A.RECEIV_ADDR,
               A.TRANSIT_PLAN,
               J.REVIEW_STATUS,
               K.DESIGN_STS,
               G.ORDER_NO,
               H.MSC,
               H.MSC_DESC,
               H.SPEC_CODE,
               H.SPEC_NAME,
               H.DIMATER,
               H.HEIGHT,
               H.PSC,
               H.PSC_DESC,
               H.CUST_ALPHA_NO,
               H.MODEL_CODE,
               M.ORD_LN_PK M_ORD_LN_PK,
               DECODE(K.DESIGN_STS, 'S', '002001001001', M.UNIT_CODE) UNIT_CODE,
               ROW_NUMBER() OVER(PARTITION BY M.ORD_LN_PK ORDER BY M.SEQ_INDEX) RN
          FROM SLM_ORDER_LINE_DELIVERY A
          LEFT JOIN slm_ORD_DESIGN_MSC_PL_PC B
            ON A.ORD_LN_DLY_PK = B.ORD_LN_DLY_PK, SLM_ORDER_LINE H
          LEFT JOIN Slm_ORD_DESIGN_STS_TKLG_LST M
            ON M.ORD_LN_PK = H.ORD_LN_PK
           AND M.VALIDFLAG = '1'
           AND M.DESIGN_STS = 'F', SLM_ORDER_HEAD G,
         SLM_ORDER_REVIEW_ITEM_LIST J, Slm_ORD_DESIGN_STS_TKLG K,
         SLM_ORDER_REVIEW N
         WHERE A.ORD_LN_PK = H.ORD_LN_PK
           AND A.ORD_PK = G.ORD_PK
           AND G.ORD_PK = N.ORD_PK
           AND N.REVIEW_NO = J.REVIEW_NO
           AND J.LIST_PK_VAL = H.ORD_LN_PK
           AND A.ORD_LN_PK = K.ORD_LN_PK
           AND K.VALIDFLAG = '1'
           AND DECODE('#DESIGN_STS#', NULL, '1', K.DESIGN_STS) =
               DECODE('#DESIGN_STS#', NULL, '1', '#DESIGN_STS#')
           AND J.REVIEW_ITM = 'T'
           AND J.LIST_TYP = 'L'
           AND J.IS_CURT_REVIEW = '1'
           AND H.VALIDFLAG = '1'
           AND G.ORDER_NO || '&' LIKE '%' || '#ORDER_NO#' || '%'
           AND DECODE('#BEGIN_TIME#', NULL, SYSDATE, H.CREATE_TIME) BETWEEN
               DECODE('#BEGIN_TIME#',
                      NULL,
                      SYSDATE,
                      TO_DATE('#BEGIN_TIME#', 'YYYY-MM-DD HH24:MI:SS')) AND
               DECODE('#BEGIN_TIME#',
                      NULL,
                      SYSDATE,
                      TO_DATE('#END_TIME#', 'YYYY-MM-DD HH24:MI:SS'))
           AND DECODE('#REVIEW_STATUS#', NULL, '1', J.REVIEW_STATUS) =
               DECODE('#REVIEW_STATUS#', NULL, '1', '#REVIEW_STATUS#')
           AND DECODE('#REVIEW_STATUS#', NULL, '1', J.REVIEW_STATUS) =
               DECODE('#REVIEW_STATUS#', NULL, '1', '#REVIEW_STATUS#')
           AND G.VALIDFLAG = '1')
 WHERE DECODE(M_ORD_LN_PK, NULL, 1, RN) <= 1
   AND (DECODE('#UNIT_CODE#', NULL, '1', UNIT_CODE) =
        DECODE('#UNIT_CODE#', NULL, '1', '#UNIT_CODE#') OR
        DECODE(UNIT_CODE, NULL, NULL, UNIT_CODE) IS NULL)
 ORDER BY DELVRY_EDATE DESC
		]]>
	</query>

	<query id="CoreOrderReviewTechnology.GetOrdDesign" desc="获取设计状态与设计状态明细">
		<![CDATA[
				SELECT A.DESGIN_KEY,
			        A.ORD_LN_PK,
			        A.DESIGN_STS DESIGN_STS_MAIN,
			        B.SEQ_INDEX,
			        B.LST_ITEM,
			        B.DESIGN_STS,
			        (CASE B.DESIGN_STS_RS
			          WHEN '00' THEN
			           '无要求'
			          WHEN '11' THEN
			           '通过'
			          WHEN '90' THEN
			           '无'
			          WHEN '91' THEN
			           '缺项'
			          WHEN '92' THEN
			           '错项'
			          ELSE
			           '等待'
			        END) DESIGN_STS_RS,
			        B.DESIGN_STS_DESC,
			        B.UNIT_CODE,
			        B.UNIT_DESC,
			        B.DESIGN_OBJ_KEY
			   FROM SLM_ORD_DESIGN_STS_TKLG A, SLM_ORD_DESIGN_STS_TKLG_LST B
			  WHERE A.DESGIN_KEY = B.DESGIN_KEY
			    AND A.ORD_LN_PK = ?
			    AND A.VALIDFLAG = '1'
			  ORDER BY B.SEQ_INDEX
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.GetCraftDesign" desc="获取设计状态与设计状态明细">
		<![CDATA[
SELECT A.DESGIN_KEY,
       A.ORD_LN_PK,
       A.DESIGN_STS DESIGN_STS_MAIN,
       B.SEQ_INDEX,
       B.LST_ITEM,
       B.DESIGN_STS,
       (CASE B.DESIGN_STS_RS
         WHEN '00' THEN
          '无要求'
         WHEN '11' THEN
          '通过'
         WHEN '90' THEN
          '无'
         WHEN '91' THEN
          '缺项'
         WHEN '92' THEN
          '错项'
         ELSE
          '等待'
       END) DESIGN_STS_RS,
       B.DESIGN_STS_DESC,
       B.UNIT_CODE,
       B.UNIT_DESC,
       B.DESIGN_OBJ_KEY
  FROM Craft_ORD_DESIGN_STS_TKLG     A,
       Craft_ORD_DESIGN_STS_TKLG_LST B,
       CRAFT_ORD_DESIGN              M
 WHERE A.DESGIN_KEY = B.DESGIN_KEY
   AND A.VALIDFLAG = '1'
   AND A.DESGIN_KEY = M.DESGIN_KEY
   AND M.ORD_LN_PK = ?
   AND M.CRAFT_SEQ =
       (SELECT MAX(CRAFT_SEQ) FROM CRAFT_ORD_DESIGN D WHERE D.ORD_LN_PK = ?)
 ORDER BY B.SEQ_INDEX
		]]>
	</query>
	
	
	<query id="CoreOrderReviewTechnology.GetOrdDesignNPass" desc="获取不通过的设计状态与设计状态项">
		<![CDATA[
				SELECT A.DESGIN_KEY,
		              A.ORD_LN_PK,
		              A.DESIGN_STS DESIGN_STS_MAIN,
		              B.SEQ_INDEX,
		              B.LST_ITEM,
		              B.DESIGN_STS,
		              (CASE B.DESIGN_STS_RS
		                WHEN '00' THEN
		                 '无要求'
		                WHEN '11' THEN
		                 '通过'
		                WHEN '90' THEN
		                 '无'
		                WHEN '91' THEN
		                 '缺项'
		                WHEN '92' THEN
		                 '错项'
		                ELSE
		                 '等待'
		              END) DESIGN_STS_RS,
		              B.DESIGN_STS_DESC,
		              B.UNIT_CODE,
		              B.UNIT_DESC,
		              B.PSC,
		              B.MSC,
		              B.USE_CODE,
		              B.FINAL_USER,
		              B.GRADECODE,
		              B.DESIGN_OBJ_KEY
		         FROM SLM_ORD_DESIGN_STS_TKLG A, SLM_ORD_DESIGN_STS_TKLG_LST B
		        WHERE A.DESGIN_KEY = B.DESGIN_KEY
		          AND A.ORD_LN_PK = ?
		          AND A.VALIDFLAG = '1'
		          AND B.DESIGN_STS='F'
		        ORDER BY B.SEQ_INDEX
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.GetCraftDesignNPass" desc="获取不通过的设计状态与设计状态项">
		<![CDATA[
SELECT A.DESGIN_KEY,
       A.ORD_LN_PK,
       A.DESIGN_STS DESIGN_STS_MAIN,
       B.SEQ_INDEX,
       B.LST_ITEM,
       B.DESIGN_STS,
       (CASE B.DESIGN_STS_RS
         WHEN '00' THEN
          '无要求'
         WHEN '11' THEN
          '通过'
         WHEN '90' THEN
          '无'
         WHEN '91' THEN
          '缺项'
         WHEN '92' THEN
          '错项'
         ELSE
          '等待'
       END) DESIGN_STS_RS,
       B.DESIGN_STS_DESC,
       DECODE(B.LST_ITEM,
              '试样码',
              (SELECT T.UNIT_CODE FROM CRAFT_SPLINE_UNIT T),
              B.UNIT_CODE) UNIT_CODE,
       DECODE(B.LST_ITEM,
              '试样码',
              (SELECT C.DEPARTNAME
                 FROM CRAFT_SPLINE_UNIT T, CORE_APP_DEPARTMENT C
                WHERE T.UNIT_CODE = C.DEPARTID),
              B.UNIT_DESC) UNIT_DESC,
       B.PSC,
       B.MSC,
       B.USE_CODE,
       B.FINAL_USER,
       B.GRADECODE,
       B.DESIGN_OBJ_KEY
  FROM CRAFT_ORD_DESIGN_STS_TKLG     A,
       CRAFT_ORD_DESIGN_STS_TKLG_LST B,
       CRAFT_ORD_DESIGN              M
 WHERE A.DESGIN_KEY = B.DESGIN_KEY
   AND A.VALIDFLAG = '1'
   AND B.DESIGN_STS = 'F'
   AND M.DESGIN_KEY = A.DESGIN_KEY
   AND M.ORD_LN_PK = ?
   AND M.CRAFT_SEQ =
       (SELECT MAX(CRAFT_SEQ) FROM CRAFT_ORD_DESIGN D WHERE D.ORD_LN_PK = ?)
 ORDER BY B.SEQ_INDEX
		]]>
	</query>

	<query id="CoreOrderReviewTechnology.GetDesignStd" desc="产品交付要求数据绑定">
		<![CDATA[
SELECT A.DESGIN_KEY，ORD_PK，ORD_LN_PK，PSC,
       PSC_DESC,
       MSC,
       MSC_DESC,
       MSC_STYLE,
       CUST_ALPHA_NO,
       CIC,
       PIC,
       SIC,
       DIC,
       WIC,
       GIC,
       ADD_ASK_NO,
       ORDER_ADD_DESC
  FROM SLM_ORD_DESIGN_MSC A, SLM_ORD_DESIGN_STD B
 WHERE A.DESGIN_KEY = B.DESGIN_KEY
   AND A.DESGIN_KEY = ?
   AND A.VALIDFLAG = 1
UNION ALL
SELECT A.DESGIN_KEY， '' ORD_PK，A.PSC_BL，F.PSC,
       F.PSC_DESC,
       '',
       '',
       '',
       '' CUST_ALPHA_NO,
       CIC,
       PIC,
       SIC,
       DIC,
       WIC,
       GIC,
       '' ADD_ASK_NO,
       '' ORDER_ADD_DESC
  FROM SLM_ORD_DESIGN_BL A
  LEFT JOIN
  COM_PSC F
    ON F.PRODUCCODE = A.PRODUCCODE
   AND NVL(F.STD_STYLE, '/') = NVL(A.STD_STYLE, '/')
   AND F.STEELCODE = A.STEELCODE
   AND F.STD_CODE = A.STD_CODE
   AND F.VALIDFLAG = '1', SLM_ORD_DESIGN_STD B
 WHERE A.DESGIN_KEY = B.DESGIN_KEY
   AND A.DESGIN_KEY = ?
   AND A.VALIDFLAG = 1
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.GetCraftDesignStd" desc="产品交付要求数据绑定">
		<![CDATA[
SELECT A.DESGIN_KEY，ORD_PK，ORD_LN_PK，PSC,
       PSC_DESC,
       MSC,
       MSC_DESC,
       MSC_STYLE,
       CUST_ALPHA_NO,
       CIC,
       PIC,
       SIC,
       DIC,
       WIC,
       GIC,
       ADD_ASK_NO,
       ORDER_ADD_DESC
  FROM Craft_ORD_DESIGN_MSC A, Craft_ORD_DESIGN_STD B
 WHERE A.DESGIN_KEY = B.DESGIN_KEY
   AND A.DESGIN_KEY = ?
   AND A.VALIDFLAG = 1
UNION ALL
SELECT A.DESGIN_KEY,
       '' ORD_PK,
       A.PSC_BL,
       F.PSC,
       F.PSC_DESC,
       '',
       '',
       '',
       '' CUST_ALPHA_NO,
       CIC,
       PIC,
       SIC,
       DIC,
       WIC,
       GIC,
       '' ADD_ASK_NO,
       '' ORDER_ADD_DESC
  FROM SLM_ORD_DESIGN_BL A
  LEFT JOIN COM_PSC F
    ON F.PRODUCCODE = A.PRODUCCODE
   AND NVL(F.STD_STYLE, '/') = NVL(A.STD_STYLE, '/')
   AND F.STEELCODE = A.STEELCODE
   AND F.STD_CODE = A.STD_CODE
   AND F.VALIDFLAG = '1', CRAFT_ORD_DESIGN_STD B
 WHERE A.DESGIN_KEY = B.DESGIN_KEY
   AND A.DESGIN_KEY = ?
   AND A.VALIDFLAG = 1

		]]>
	</query>

	<query id="CoreOrderReviewTechnology.GetDesignMscPl" desc="生产制程,全程途径数据绑定。">
		<![CDATA[
SELECT B.DESGIN_KEY,
       A.ORD_LN_PK,
       MSC_PLINE,
       WHOLE_BACKLOG,
       WHOLE_BACKLOG_DESC,
       SET_FL
  FROM SLM_ORD_DESIGN_MSC A, SLM_ORD_DESIGN_MSC_PL B
 WHERE A.DESGIN_KEY = B.DESGIN_KEY
   AND A.DESGIN_KEY = ?
   AND A.VALIDFLAG = '1'
UNION ALL
SELECT B.DESGIN_KEY,
       A.PSC_BL ORD_LN_PK,
       MSC_PLINE,
       WHOLE_BACKLOG,
       WHOLE_BACKLOG_DESC,
       SET_FL
  FROM SLM_ORD_DESIGN_BL A, SLM_ORD_DESIGN_MSC_PL B
 WHERE A.DESGIN_KEY = B.DESGIN_KEY
   AND A.DESGIN_KEY = ?
   AND A.VALIDFLAG = '1'				
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.GetCraftDesignMscPl" desc="生产制程,全程途径数据绑定。">
		<![CDATA[
SELECT B.DESGIN_KEY,
       A.ORD_LN_PK,
       MSC_PLINE,
       WHOLE_BACKLOG,
       WHOLE_BACKLOG_DESC,
       SET_FL
  FROM Craft_ORD_DESIGN_MSC A, Craft_ORD_DESIGN_MSC_PL B
 WHERE A.DESGIN_KEY = B.DESGIN_KEY
   AND A.DESGIN_KEY = ?
   AND A.VALIDFLAG = '1'				
		]]>
	</query>

	<query id="CoreOrderReviewTechnology.GetDesignMscPlGz" desc="依据全程途径获取对应钢种">
		<![CDATA[
				SELECT 
				DESGIN_KEY,MSC_PLINE,GRADECODE,GRADENAME 
				FROM 
				SLM_ORD_DESIGN_MSC_PL_GZ
				WHERE
				DESGIN_KEY=?
				AND
				MSC_PLINE=?

		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.GetCraftDesignMscPlGz" desc="依据全程途径获取对应钢种">
		<![CDATA[
				SELECT 
				DESGIN_KEY,MSC_PLINE,GRADECODE,GRADENAME 
				FROM 
				Craft_ORD_DESIGN_MSC_PL_GZ
				WHERE
				DESGIN_KEY=?
				AND
				MSC_PLINE=?

		]]>
	</query>

	<query id="CoreOrderReviewTechnology.GetDesignMscPlIn" desc="依据全程途径获取工序投入产出物料以及内控标准">
		<![CDATA[
SELECT A.DESGIN_KEY,
       A.MSC_PLINE,
       A.WHOlE_BACKLOG,
       A.WHOLE_BACKLOG_DESC,
       BACKLOG_SEQ,
       PROCESS_CODE,
       PROCESS_DESC,
       PROCESS_DESC_C,
       CIC,
       PIC,
       SIC,
       DIC,
       WIC,
       GIC
  FROM SLM_ORD_DESIGN_MSC_PL_PRC A
 WHERE A.DESGIN_KEY = ?
   AND A.MSC_PLINE = ?
 ORDER BY BACKLOG_SEQ

		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.GetCraftDesignMscPlIn" desc="依据全程途径获取工序投入产出物料以及内控标准">
		<![CDATA[
SELECT A.DESGIN_KEY,
       A.MSC_PLINE,
       A.WHOlE_BACKLOG,
       A.WHOLE_BACKLOG_DESC,
       BACKLOG_SEQ,
       PROCESS_CODE,
       PROCESS_DESC,
       PROCESS_DESC_C,
       CIC,
       PIC,
       SIC,
       DIC,
       WIC,
       GIC
  FROM Craft_ORD_DESIGN_MSC_PL_PRC A
 WHERE A.DESGIN_KEY = ?
   AND A.MSC_PLINE = ?
 ORDER BY BACKLOG_SEQ

		]]>
	</query>

	<query id="CoreOrderReviewTechnology.GetDesignMscPlGxPrl" desc="依据工序获取适用产线">
		<![CDATA[
				SELECT 
		        DESGIN_KEY,MSC_PLINE,BACKLOG_SEQ,
		        PROCESS_CODE,PLINE_CODE,PLINE_NAME,
		        WARN_DESC
		        FROM
		        SLM_ORD_DESIGN_MSC_PL_GX_PRL
				WHERE 
		        DESGIN_KEY=? 
		        AND
		        MSC_PLINE=?
		        AND
		        BACKLOG_SEQ=?
				AND 
				PROCESS_CODE=?
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.GetCraftDesignMscPlGxPrl" desc="依据工序获取适用产线">
		<![CDATA[
				SELECT 
		        DESGIN_KEY,MSC_PLINE,BACKLOG_SEQ,
		        PROCESS_CODE,PLINE_CODE,PLINE_NAME,
		        WARN_DESC
		        FROM
		        Craft_ORD_DESIGN_MSC_PL_GX_PRL
				WHERE 
		        DESGIN_KEY=? 
		        AND
		        MSC_PLINE=?
		        AND
		        BACKLOG_SEQ=?
				AND 
				PROCESS_CODE=?
		]]>
	</query>

	<query id="CoreOrderReviewTechnology.GetComMscJg" desc="接箍数据绑定">
		<![CDATA[
SELECT B.DESGIN_KEY,
       C.CODE_JG,
       SPEC_JG,
       SPEC_JG_DESC,
       PRODUCCODE_JG,
       PRODUCCODE_JG_DESC,
       STEELCODE_JG,
       STEELCODE_JG_DESC,
       C.MODEL_CODE,
       C.MODEL_DESC,
       D.BASENAME STYLE_JG,
       DIAMETER_JG,
       HEIGHT_JG,
       LENGTH_JG,
       WEIGHT_JG,
       C.MIN_D,
       C.MIN_H,
       DIAMETER_PL,
       HEIGHT_PL,
       LENGTH_MIN,
       LENGTH_MAX,
       C.PRODUCCODE,
       C.PRODUCNAME,
       MIN_H_CP,
       MAX_H_CP,
       MIN_D_JG MIN_D_CP,
       MAX_D_JG MAX_D_CP,
       DIAMETER,
       B.KEY_JG,
       B.ORDER_SPECIAL_DESC ALPHA,
       E.BASENAME DEMAND_DETECTION,
       F.BASENAME DEMAND_BONDERIZING,
       G.BASENAME DEMAND_COPPER,
       H.BASENAME DEMAND_BLAST,
       I.BASENAME TORQUE_UNIT,
       B.TORQUE_MAX,
       B.TORQUE_MIN,
       B.TORQUE_BEST,
       B.POINT_MAX,
       B.POINT_MIN,
       B.M_STD_NO,
       B.W_STD_NO,
       B.M_PRINT_NO,
       B.W_PRINT_NO,
       B.FILE_PATH,
       SUBSTR(B.FILE_PATH, INSTR(B.FILE_PATH, '/', 1, 3) + 1) FILE_NAME,
       B.JG_MEMO,
       B.MEMO
  FROM SLM_ORD_DESIGN_MSC_JG B
  LEFT JOIN COM_BASE_INFO E
    ON E.BASECODE = B.DEMAND_DETECTION
  LEFT JOIN COM_BASE_INFO F
    ON F.BASECODE = B.DEMAND_BONDERIZING
  LEFT JOIN COM_BASE_INFO G
    ON G.BASECODE = B.DEMAND_COPPER
  LEFT JOIN COM_BASE_INFO H
    ON H.BASECODE = B.DEMAND_BLAST
  LEFT JOIN COM_BASE_INFO I
    ON I.BASECODE = B.TORQUE_UNIT, COM_MSC_JG C
  LEFT JOIN COM_BASE_INFO D
    ON D.BASECODE = C.STYLE_JG
 WHERE B.CODE_JG = C.CODE_JG
   AND B.DESGIN_KEY = ?
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.GetCraftComMscJg" desc="接箍数据绑定">
		<![CDATA[
SELECT B.DESGIN_KEY,
       C.CODE_JG,
       SPEC_JG,
       SPEC_JG_DESC,
       PRODUCCODE_JG,
       PRODUCCODE_JG_DESC,
       STEELCODE_JG,
       STEELCODE_JG_DESC,
       C.MODEL_CODE,
       C.MODEL_DESC,
       D.BASENAME STYLE_JG,
       DIAMETER_JG,
       HEIGHT_JG,
       LENGTH_JG,
       WEIGHT_JG,
       C.MIN_D,
       C.MIN_H,
       DIAMETER_PL,
       HEIGHT_PL,
       LENGTH_MIN,
       LENGTH_MAX,
       C.PRODUCCODE,
       C.PRODUCNAME,
       MIN_H_CP,
       MAX_H_CP,
       MIN_D_JG MIN_D_CP,
       MAX_D_JG MAX_D_CP,
       DIAMETER,
       ALPHA,
       B.KEY_JG,
       E.BASENAME DEMAND_DETECTION,
       F.BASENAME DEMAND_BONDERIZING,
       G.BASENAME DEMAND_COPPER,
       H.BASENAME DEMAND_BLAST,
       I.BASENAME TORQUE_UNIT,
       B.TORQUE_MAX,
       B.TORQUE_MIN,
       B.TORQUE_BEST,
       B.POINT_MAX,
       B.POINT_MIN,
       B.M_STD_NO,
       B.W_STD_NO,
       B.M_PRINT_NO,
       B.W_PRINT_NO,
       B.FILE_PATH,
       SUBSTR(B.FILE_PATH, INSTR(B.FILE_PATH, '/', 1, 3) + 1) FILE_NAME,
       B.JG_MEMO,
       B.MEMO
  FROM CRAFT_ORD_DESIGN_MSC_JG B
  LEFT JOIN COM_BASE_INFO E
    ON E.BASECODE = B.DEMAND_DETECTION
  LEFT JOIN COM_BASE_INFO F
    ON F.BASECODE = B.DEMAND_BONDERIZING
  LEFT JOIN COM_BASE_INFO G
    ON G.BASECODE = B.DEMAND_COPPER
  LEFT JOIN COM_BASE_INFO H
    ON H.BASECODE = B.DEMAND_BLAST
  LEFT JOIN COM_BASE_INFO I
    ON I.BASECODE = B.TORQUE_UNIT, COM_MSC_JG C
  LEFT JOIN COM_BASE_INFO D
    ON D.BASECODE = C.STYLE_JG
 WHERE B.CODE_JG = C.CODE_JG
   AND B.DESGIN_KEY = ?
		]]>
	</query>

	<query id="CoreOrderReviewTechnology.GetJgBl" desc="获取接箍备料信息">
		<![CDATA[
				SELECT 
				A.DESGIN_KEY,A.CODE_JG,A.PSC_BL，STEELCODE，STEELNAME，
				PRODUCCODE，PRODUCNAME，MODEL_CODE，MODEL_DESC，
				STD_CODE，STD_NAME， STD_STYLE，STD_STYLE_DESC，
				MIN_D，MIN_H，USE_CODE，USE_DESC，
				MEMO 
				FROM 
				SLM_ORD_DESIGN_MSC_JG_BL A,
				COM_MSC_BL B 
				WHERE 
				A.PSC_BL=B.PSC_BL 
				AND
				A.DESGIN_KEY=? 
				AND
				A.CODE_JG=?
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.GetCraftJgBl" desc="获取接箍备料信息">
		<![CDATA[
SELECT A.DESGIN_KEY,
       A.CODE_JG,
       A.PSC_BL,
       B.STEELCODE,
       B.STEELNAME,
       B.PRODUCCODE,
       B.PRODUCNAME,
       B.MODEL_CODE,
       B.MODEL_DESC,
       B.STD_CODE,
       B.STD_NAME,
       B.STD_STYLE,
       B.STD_STYLE_DESC,
       B.MIN_D,
       B.MIN_H,
       B.USE_CODE,
       B.USE_DESC,
       B.MEMO,
       C.CRAFT_PATH,
       C.CRAFT_NO
  FROM Craft_ORD_DESIGN_MSC_JG_BL A, COM_MSC_BL B, CRAFT_ORD_DESIGN C
 WHERE A.PSC_BL = B.PSC_BL
   AND A.DESGIN_KEY = ?
   AND A.CODE_JG = ?
   AND C.DESGIN_KEY = A.DESGIN_KEY_BL
		]]>
	</query>

	<query id="CoreOrderReviewTechnology.GetMscBl" desc="备料码">
		<![CDATA[
SELECT A.ORD_LN_PK,
       A.DESGIN_KEY,
       B.PSC_BL，C.STEELCODE，C.STEELNAME， C.PRODUCCODE，C.PRODUCNAME，C.MODEL_CODE， C.MODEL_DESC， C.STD_CODE，C.STD_NAME， C.STD_STYLE，C.STD_STYLE_DESC， C.MIN_D，C.MIN_H，C.USE_CODE，C.USE_DESC， C.MEMO
  FROM SLM_ORD_DESIGN_MSC A, SLM_ORD_DESIGN_MSC_BL B, COM_MSC_BL C
 WHERE A.DESGIN_KEY = B.DESGIN_KEY
   AND B.PSC_BL = C.PSC_BL
   AND A.DESGIN_KEY = ?
UNION ALL
SELECT A.PSC_BL                             ORD_LN_PK,
       A.DESGIN_KEY,
       B.PSC_BL，C.STEELCODE，C.STEELNAME， C.PRODUCCODE，C.PRODUCNAME，C.MODEL_CODE， C.MODEL_DESC， C.STD_CODE，C.STD_NAME， C.STD_STYLE，C.STD_STYLE_DESC， C.MIN_D，C.MIN_H，C.USE_CODE，C.USE_DESC， C.MEMO
  FROM SLM_ORD_DESIGN_BL A, SLM_ORD_DESIGN_MSC_BL B, COM_MSC_BL C
 WHERE A.DESGIN_KEY = B.DESGIN_KEY
   AND B.PSC_BL = C.PSC_BL
   AND A.DESGIN_KEY = ?
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.GetCraftMscBl" desc="备料码">
		<![CDATA[
SELECT A.ORD_LN_PK,
       A.DESGIN_KEY,
       B.PSC_BL,
       C.STEELCODE,
       C.STEELNAME,
       C.PRODUCCODE,
       C.PRODUCNAME,
       C.MODEL_CODE,
       C.MODEL_DESC,
       C.STD_CODE,
       C.STD_NAME,
       C.STD_STYLE,
       C.STD_STYLE_DESC,
       C.MIN_D,
       C.MIN_H,
       C.USE_CODE,
       C.USE_DESC,
       C.MEMO,
       D.CRAFT_NO,
       D.CRAFT_PATH
  FROM Craft_ORD_DESIGN_MSC    A,
       Craft_ORD_DESIGN_MSC_BL B,
       COM_MSC_BL              C,
       CRAFT_ORD_DESIGN        D
 WHERE A.DESGIN_KEY = B.DESGIN_KEY
   AND B.PSC_BL = C.PSC_BL
   AND A.DESGIN_KEY = ?
   AND D.DESGIN_KEY = B.DESGIN_KEY_BL
		]]>
	</query>

	<query id="CoreOrderReviewTechnology.UpdateMscPlPc" desc="周期修正值">
		<![CDATA[
				UPDATE 
		        SLM_ORD_DESIGN_MSC_PL_PC 
		        SET
		        CYC_EDIT=?
		        WHERE
		        DESGIN_KEY=?
		        AND
		        ORD_LN_DLY_PK=?
		        AND
		        MSC_PLINE=?
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.UpdateCraftMscPlPc" desc="周期修正值">
		<![CDATA[
				UPDATE 
		        Craft_ORD_DESIGN_MSC_PL_PC 
		        SET
		        CYC_EDIT=?
		        WHERE
		        DESGIN_KEY=?
		        AND
		        ORD_LN_DLY_PK=?
		        AND
		        MSC_PLINE=?
		]]>
	</query>

	<query id="CoreOrderReviewTechnology.GetMscPlPc" desc="交货行数据绑定">
		<![CDATA[
SELECT C.DESGIN_KEY,
       C.MSC_PLINE,
       C.ORD_LN_DLY_PK,
       C.DELVRY_QTY,
       C.ORDER_UNIT,
       TO_CHAR(C.DELVRY_EDATE, 'YYYY-MM-DD') DELVRY_EDATE,
       C.PRD_CYC,
       C.PRD_CYC_BTCH,
       C.CYC_EDIT,
       TO_CHAR(C.RCMD_DELVRY_EDATE, 'YYYY-MM-DD') RCMD_DELVRY_EDATE,
       C.N_MATERIAL_FL
  FROM SLM_ORDER_LINE_DELIVERY  A,
       SLM_ORD_DESIGN_MSC_PL_PC C,
       SLM_ORD_DESIGN_MSC       B
 WHERE A.ORD_LN_DLY_PK = C.ORD_LN_DLY_PK
   AND B.ORD_LN_PK = ?
   AND B.VALIDFLAG = '1'
   AND B.DESGIN_KEY = C.DESGIN_KEY
   AND DECODE(?, NULL, '1', C.MSC_PLINE) = DECODE(?, NULL, '1', ?)
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.GetCraftMscPlPc" desc="交货行数据绑定">
		<![CDATA[
SELECT C.DESGIN_KEY,
       C.MSC_PLINE,
       C.ORD_LN_DLY_PK,
       C.DELVRY_QTY,
       C.ORDER_UNIT,
       TO_CHAR(C.DELVRY_EDATE, 'YYYY-MM-DD') DELVRY_EDATE,
       C.PRD_CYC,
       C.PRD_CYC_BTCH,
       C.CYC_EDIT,
       TO_CHAR(C.RCMD_DELVRY_EDATE, 'YYYY-MM-DD') RCMD_DELVRY_EDATE,
       C.N_MATERIAL_FL
  FROM SLM_ORDER_LINE_DELIVERY    A,
       Craft_ORD_DESIGN_MSC_PL_PC C,
       CRAFT_ORD_DESIGN           B
 WHERE A.ORD_LN_DLY_PK = C.ORD_LN_DLY_PK
   AND B.ORD_LN_PK = ?
   AND C.DESGIN_KEY = B.DESGIN_KEY
   AND B.CRAFT_SEQ = (SELECT MAX(D.CRAFT_SEQ)
                        FROM CRAFT_ORD_DESIGN D
                       WHERE D.VALIDFLAG <> '0'
                         AND D.ORD_LN_PK = B.ORD_LN_PK)
   AND DECODE(?, NULL, '1', C.MSC_PLINE) = DECODE(?, NULL, '1', ?)
		]]>
	</query>

	<query id="CoreOrderReviewTechnology.GetMscPlPcLst" desc="获取交货行对应的工序">
		<![CDATA[
				SELECT
				C.DESGIN_KEY,C.MSC_PLINE,
				C.ORD_LN_DLY_PK, C.BACKLOG_SEQ,C.PROCESS_CODE,C.PROCESS_DESC,
				C.PRD_CYC,TO_CHAR(C.LST_PRD_DATE,'YYYY-MM-DD') LST_PRD_DATE,C.REVIEW_ASK,
				ROUND(PRD_CYC_BTCH, 4) PRD_CYC_BTCH
				FROM 
		        SLM_ORD_DESIGN_MSC_PL_PC_LST C
		        WHERE
				C.DESGIN_KEY=?
		        AND
		        C.MSC_PLINE=?
		        AND
		        C.ORD_LN_DLY_PK=?
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.GetCraftMscPlPcLst" desc="获取交货行对应的工序">
		<![CDATA[
				SELECT
				C.DESGIN_KEY,C.MSC_PLINE,
				C.ORD_LN_DLY_PK, C.BACKLOG_SEQ,C.PROCESS_CODE,C.PROCESS_DESC,
				C.PRD_CYC,TO_CHAR(C.LST_PRD_DATE,'YYYY-MM-DD') LST_PRD_DATE,C.REVIEW_ASK,
				ROUND(PRD_CYC_BTCH, 4) PRD_CYC_BTCH
				FROM 
		        Craft_ORD_DESIGN_MSC_PL_PC_LST C
		        WHERE
				C.DESGIN_KEY=?
		        AND
		        C.MSC_PLINE=?
		        AND
		        C.ORD_LN_DLY_PK=?
		]]>
	</query>

	<query id="CoreOrderReviewTechnology.GetReviewStatus" desc="获取当前选中合同行的技术评审状态。">
		<![CDATA[
				SELECT REVIEW_STATUS
				  FROM SLM_ORDER_REVIEW_ITEM_LIST J
				 WHERE J.REVIEW_ITM = 'T'
				   AND J.LIST_TYP = 'L'
				   AND J.IS_CURT_REVIEW = '1'
				   AND J.LIST_PK_VAL = ?
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.getBomLst" desc="获取Bom">
		<![CDATA[
SELECT T.MATERIAL_NO,
       T.MATERIAL_DESC,
       T.BOM,
       DECODE(T.BOM_TYP,
              'A',
              '产品',
              'B',
              '产品配接',
              'C',
              '产品备料',
              'D',
              '接箍备料',
              '未识别') BOM_TYP,
       T.MSC_PLINE,
       T.WHOLE_BACKLOG,
       T.WHOLE_BACKLOG_DESC,
       T.MSC,
       T.MSC_DESC,
       T.GRADECODE,
       T.GRADENAME,
       T.SPEC_CODE_C,
       T.SPEC_NAME_C,
       T.SPEC_CODE_R,
       T.SPEC_NAME_R,
       T.SPEC_CODE_D,
       T.SPEC_NAME_D,
       T.SPEC_CODE_Z,
       T.SPEC_NAME_Z,
       T.A_IN_MATERIAL_NO,
       T.A_IN_MATERIAL_DESC,
       T.A_OUT_MATERIAL_NO,
       T.A_OUT_MATERIAL_DESC,
       T.B_IN_MATERIAL_NO,
       T.B_IN_MATERIAL_DESC,
       T.B_OUT_MATERIAL_NO,
       T.B_OUT_MATERIAL_DESC,
       T.C_IN_MATERIAL_NO,
       T.C_IN_MATERIAL_DESC,
       T.C_OUT_MATERIAL_NO,
       T.C_OUT_MATERIAL_DESC,
       T.D_IN_MATERIAL_NO,
       T.D_IN_MATERIAL_DESC,
       T.D_OUT_MATERIAL_NO,
       T.D_OUT_MATERIAL_DESC,
       T.E_IN_MATERIAL_NO,
       T.E_IN_MATERIAL_DESC,
       T.E_OUT_MATERIAL_NO,
       T.E_OUT_MATERIAL_DESC,
       T.F_IN_MATERIAL_NO,
       T.F_IN_MATERIAL_DESC,
       T.F_OUT_MATERIAL_NO,
       T.F_OUT_MATERIAL_DESC,
       T.J_IN_MATERIAL_NO,
       T.J_IN_MATERIAL_DESC,
       T.J_OUT_MATERIAL_NO,
       T.J_OUT_MATERIAL_DESC,
       T.I_IN_MATERIAL_NO,
       T.I_IN_MATERIAL_DESC,
       T.I_OUT_MATERIAL_NO,
       T.I_OUT_MATERIAL_DESC
  FROM SLM_ORD_DESIGN_BOM T, SLM_ORD_DESIGN_MSC A, SLM_ORD_LINE_BOM B
 WHERE T.BOM = B.BOM
   AND A.DESGIN_KEY = B.DESGIN_KEY
   AND A.DESGIN_KEY = '#DESGIN_KEY#'
   AND A.VALIDFLAG = '1'
UNION ALL
SELECT T.MATERIAL_NO,
       T.MATERIAL_DESC,
       T.BOM,
       DECODE(T.BOM_TYP,
              'A',
              '产品',
              'B',
              '产品配接',
              'C',
              '产品备料',
              'D',
              '接箍备料',
              '未识别') BOM_TYP,
       T.MSC_PLINE,
       T.WHOLE_BACKLOG,
       T.WHOLE_BACKLOG_DESC,
       T.MSC,
       T.MSC_DESC,
       T.GRADECODE,
       T.GRADENAME,
       T.SPEC_CODE_C,
       T.SPEC_NAME_C,
       T.SPEC_CODE_R,
       T.SPEC_NAME_R,
       T.SPEC_CODE_D,
       T.SPEC_NAME_D,
       T.SPEC_CODE_Z,
       T.SPEC_NAME_Z,
       T.A_IN_MATERIAL_NO,
       T.A_IN_MATERIAL_DESC,
       T.A_OUT_MATERIAL_NO,
       T.A_OUT_MATERIAL_DESC,
       T.B_IN_MATERIAL_NO,
       T.B_IN_MATERIAL_DESC,
       T.B_OUT_MATERIAL_NO,
       T.B_OUT_MATERIAL_DESC,
       T.C_IN_MATERIAL_NO,
       T.C_IN_MATERIAL_DESC,
       T.C_OUT_MATERIAL_NO,
       T.C_OUT_MATERIAL_DESC,
       T.D_IN_MATERIAL_NO,
       T.D_IN_MATERIAL_DESC,
       T.D_OUT_MATERIAL_NO,
       T.D_OUT_MATERIAL_DESC,
       T.E_IN_MATERIAL_NO,
       T.E_IN_MATERIAL_DESC,
       T.E_OUT_MATERIAL_NO,
       T.E_OUT_MATERIAL_DESC,
       T.F_IN_MATERIAL_NO,
       T.F_IN_MATERIAL_DESC,
       T.F_OUT_MATERIAL_NO,
       T.F_OUT_MATERIAL_DESC,
       T.J_IN_MATERIAL_NO,
       T.J_IN_MATERIAL_DESC,
       T.J_OUT_MATERIAL_NO,
       T.J_OUT_MATERIAL_DESC,
       T.I_IN_MATERIAL_NO,
       T.I_IN_MATERIAL_DESC,
       T.I_OUT_MATERIAL_NO,
       T.I_OUT_MATERIAL_DESC
  FROM SLM_ORD_DESIGN_BOM T, SLM_ORD_DESIGN_BL A, SLM_ORD_LINE_BOM B
 WHERE T.BOM = B.BOM
   AND A.DESGIN_KEY = B.DESGIN_KEY
   AND A.DESGIN_KEY = '#DESGIN_KEY#'
   AND A.VALIDFLAG = '1'
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.getCraftBomLst" desc="获取Bom">
		<![CDATA[
SELECT T.MATERIAL_NO,
       T.MATERIAL_DESC,
       T.BOM,
       DECODE(T.BOM_TYP,
              'A',
              '产品',
              'B',
              '产品配接',
              'C',
              '产品备料',
              'D',
              '接箍备料',
              '未识别') BOM_TYP,
       T.MSC_PLINE,
       T.WHOLE_BACKLOG,
       T.WHOLE_BACKLOG_DESC,
       T.MSC,
       T.MSC_DESC,
       T.GRADECODE,
       T.GRADENAME,
       T.SPEC_CODE_C,
       T.SPEC_NAME_C,
       T.SPEC_CODE_R,
       T.SPEC_NAME_R,
       T.SPEC_CODE_D,
       T.SPEC_NAME_D,
       T.SPEC_CODE_Z,
       T.SPEC_NAME_Z,
       T.A_IN_MATERIAL_NO,
       T.A_IN_MATERIAL_DESC,
       T.A_OUT_MATERIAL_NO,
       T.A_OUT_MATERIAL_DESC,
       T.B_IN_MATERIAL_NO,
       T.B_IN_MATERIAL_DESC,
       T.B_OUT_MATERIAL_NO,
       T.B_OUT_MATERIAL_DESC,
       T.C_IN_MATERIAL_NO,
       T.C_IN_MATERIAL_DESC,
       T.C_OUT_MATERIAL_NO,
       T.C_OUT_MATERIAL_DESC,
       T.D_IN_MATERIAL_NO,
       T.D_IN_MATERIAL_DESC,
       T.D_OUT_MATERIAL_NO,
       T.D_OUT_MATERIAL_DESC,
       T.E_IN_MATERIAL_NO,
       T.E_IN_MATERIAL_DESC,
       T.E_OUT_MATERIAL_NO,
       T.E_OUT_MATERIAL_DESC,
       T.F_IN_MATERIAL_NO,
       T.F_IN_MATERIAL_DESC,
       T.F_OUT_MATERIAL_NO,
       T.F_OUT_MATERIAL_DESC,
       T.J_IN_MATERIAL_NO,
       T.J_IN_MATERIAL_DESC,
       T.J_OUT_MATERIAL_NO,
       T.J_OUT_MATERIAL_DESC,
       T.I_IN_MATERIAL_NO,
       T.I_IN_MATERIAL_DESC,
       T.I_OUT_MATERIAL_NO,
       T.I_OUT_MATERIAL_DESC
  FROM SLM_ORD_DESIGN_BOM T, CRAFT_ORD_DESIGN_MSC A, CRAFT_ORD_LINE_BOM B
 WHERE T.BOM = B.BOM
   AND A.DESGIN_KEY = B.DESGIN_KEY
   AND A.DESGIN_KEY = '#DESGIN_KEY#'
   AND A.VALIDFLAG = '1'
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.getBomLstByBomJg" desc="获取Bom">
		<![CDATA[
SELECT T.MATERIAL_NO,
       T.MATERIAL_DESC,
       T.BOM,
       DECODE(T.BOM_TYP,
              'A',
              '产品',
              'B',
              '产品配接',
              'C',
              '产品备料',
              'D',
              '接箍备料',
              '未识别') BOM_TYP,
       T.MSC_PLINE,
       T.WHOLE_BACKLOG,
       T.WHOLE_BACKLOG_DESC,
       T.MSC,
       T.MSC_DESC,
       T.GRADECODE,
       T.GRADENAME,
       T.SPEC_CODE_C,
       T.SPEC_NAME_C,
       T.SPEC_CODE_R,
       T.SPEC_NAME_R,
       T.SPEC_CODE_D,
       T.SPEC_NAME_D,
       T.SPEC_CODE_Z,
       T.SPEC_NAME_Z,
       T.A_IN_MATERIAL_NO,
       T.A_IN_MATERIAL_DESC,
       T.A_OUT_MATERIAL_NO,
       T.A_OUT_MATERIAL_DESC,
       T.B_IN_MATERIAL_NO,
       T.B_IN_MATERIAL_DESC,
       T.B_OUT_MATERIAL_NO,
       T.B_OUT_MATERIAL_DESC,
       T.C_IN_MATERIAL_NO,
       T.C_IN_MATERIAL_DESC,
       T.C_OUT_MATERIAL_NO,
       T.C_OUT_MATERIAL_DESC,
       T.D_IN_MATERIAL_NO,
       T.D_IN_MATERIAL_DESC,
       T.D_OUT_MATERIAL_NO,
       T.D_OUT_MATERIAL_DESC,
       T.E_IN_MATERIAL_NO,
       T.E_IN_MATERIAL_DESC,
       T.E_OUT_MATERIAL_NO,
       T.E_OUT_MATERIAL_DESC,
       T.F_IN_MATERIAL_NO,
       T.F_IN_MATERIAL_DESC,
       T.F_OUT_MATERIAL_NO,
       T.F_OUT_MATERIAL_DESC,
       T.J_IN_MATERIAL_NO,
       T.J_IN_MATERIAL_DESC,
       T.J_OUT_MATERIAL_NO,
       T.J_OUT_MATERIAL_DESC,
       T.I_IN_MATERIAL_NO,
       T.I_IN_MATERIAL_DESC,
       T.I_OUT_MATERIAL_NO,
       T.I_OUT_MATERIAL_DESC,
       A.IN_MATERIAL_NO
  FROM SLM_ORD_DESIGN_BOM T, SLM_ORD_DESIGN_BOM_G A
 WHERE A.BOM = '#BOM#'
   AND A.BOM_JG = '#BOM_JG#'
   AND T.MATERIAL_NO = A.IN_MATERIAL_NO

		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.getBomJgLst" desc="获取BomJg">
		<![CDATA[
SELECT T.MATERIAL_NO,
       T.MATERIAL_DESC,
       T.BOM,
       DECODE(T.BOM_TYP, 'A', '产品', 'B', '产品配接', 'C', '产品备料', 'D', '接箍备料', '未识别') BOM_TYP,
       T.MSC_PLINE,
       T.WHOLE_BACKLOG,
       T.WHOLE_BACKLOG_DESC,
       T.MSC,
       T.MSC_DESC,
       T.GRADECODE,
       T.GRADENAME,
       T.SPEC_CODE_C,
       T.SPEC_NAME_C,
       T.SPEC_CODE_R,
       T.SPEC_NAME_R,
       T.SPEC_CODE_D,
       T.SPEC_NAME_D,
       T.SPEC_CODE_Z,
       T.SPEC_NAME_Z,
       T.A_IN_MATERIAL_NO,
       T.A_IN_MATERIAL_DESC,
       T.A_OUT_MATERIAL_NO,
       T.A_OUT_MATERIAL_DESC,
       T.B_IN_MATERIAL_NO,
       T.B_IN_MATERIAL_DESC,
       T.B_OUT_MATERIAL_NO,
       T.B_OUT_MATERIAL_DESC,
       T.C_IN_MATERIAL_NO,
       T.C_IN_MATERIAL_DESC,
       T.C_OUT_MATERIAL_NO,
       T.C_OUT_MATERIAL_DESC,
       T.D_IN_MATERIAL_NO,
       T.D_IN_MATERIAL_DESC,
       T.D_OUT_MATERIAL_NO,
       T.D_OUT_MATERIAL_DESC,
       T.E_IN_MATERIAL_NO,
       T.E_IN_MATERIAL_DESC,
       T.E_OUT_MATERIAL_NO,
       T.E_OUT_MATERIAL_DESC,
       T.F_IN_MATERIAL_NO,
       T.F_IN_MATERIAL_DESC,
       T.F_OUT_MATERIAL_NO,
       T.F_OUT_MATERIAL_DESC,
       T.J_IN_MATERIAL_NO,
       T.J_IN_MATERIAL_DESC,
       T.J_OUT_MATERIAL_NO,
       T.J_OUT_MATERIAL_DESC,
       T.I_IN_MATERIAL_NO,
       T.I_IN_MATERIAL_DESC,
       T.I_OUT_MATERIAL_NO,
       T.I_OUT_MATERIAL_DESC
  FROM SLM_ORD_DESIGN_BOM T, SLM_ORD_LINE_BOM A, SLM_ORD_LINE_BOM_JG B
 WHERE T.BOM = B.BOM_JG
   AND A.DESGIN_KEY = B.DESGIN_KEY
   AND A.BOM = B.BOM
   AND A.BOM = '#BOM#'
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.getBomBlLst" desc="获取BomBl">
		<![CDATA[
SELECT T.MATERIAL_NO,
       T.MATERIAL_DESC,
       T.BOM,
       DECODE(T.BOM_TYP, 'A', '产品', 'B', '产品配接', 'C', '产品备料', 'D', '接箍备料', '未识别') BOM_TYP,
       T.MSC_PLINE,
       T.WHOLE_BACKLOG,
       T.WHOLE_BACKLOG_DESC,
       T.MSC,
       T.MSC_DESC,
       T.GRADECODE,
       T.GRADENAME,
       T.SPEC_CODE_C,
       T.SPEC_NAME_C,
       T.SPEC_CODE_R,
       T.SPEC_NAME_R,
       T.SPEC_CODE_D,
       T.SPEC_NAME_D,
       T.SPEC_CODE_Z,
       T.SPEC_NAME_Z,
       T.A_IN_MATERIAL_NO,
       T.A_IN_MATERIAL_DESC,
       T.A_OUT_MATERIAL_NO,
       T.A_OUT_MATERIAL_DESC,
       T.B_IN_MATERIAL_NO,
       T.B_IN_MATERIAL_DESC,
       T.B_OUT_MATERIAL_NO,
       T.B_OUT_MATERIAL_DESC,
       T.C_IN_MATERIAL_NO,
       T.C_IN_MATERIAL_DESC,
       T.C_OUT_MATERIAL_NO,
       T.C_OUT_MATERIAL_DESC,
       T.D_IN_MATERIAL_NO,
       T.D_IN_MATERIAL_DESC,
       T.D_OUT_MATERIAL_NO,
       T.D_OUT_MATERIAL_DESC,
       T.E_IN_MATERIAL_NO,
       T.E_IN_MATERIAL_DESC,
       T.E_OUT_MATERIAL_NO,
       T.E_OUT_MATERIAL_DESC,
       T.F_IN_MATERIAL_NO,
       T.F_IN_MATERIAL_DESC,
       T.F_OUT_MATERIAL_NO,
       T.F_OUT_MATERIAL_DESC,
       T.J_IN_MATERIAL_NO,
       T.J_IN_MATERIAL_DESC,
       T.J_OUT_MATERIAL_NO,
       T.J_OUT_MATERIAL_DESC,
       T.I_IN_MATERIAL_NO,
       T.I_IN_MATERIAL_DESC,
       T.I_OUT_MATERIAL_NO,
       T.I_OUT_MATERIAL_DESC
  FROM SLM_ORD_DESIGN_BOM T, SLM_ORD_LINE_BOM A, SLM_ORD_LINE_BOM_BL B
 WHERE T.BOM = B.BOM_BL
   AND A.DESGIN_KEY = B.DESGIN_KEY
   AND A.BOM = B.BOM
   AND A.BOM = '#BOM#'
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.getBomILst" desc="获取BomI(加工)">
		<![CDATA[
		SELECT A.* FROM SLM_ORD_DESIGN_BOM_K A WHERE A.BOM = '#BOM#'
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.getMpsInfo" desc="获取监制信息">
		<![CDATA[
SELECT T.MPS_FL,
       (SELECT COUNT(1)
          FROM SLM_ORD_DESIGN_MSC_PL_STI_TC A
         WHERE A.DESGIN_KEY = B.DESGIN_KEY) COUNT
  FROM SLM_ORDER_LINE T
  LEFT JOIN SLM_ORD_DESIGN_STS_TKLG B
    ON B.ORD_LN_PK = T.ORD_LN_PK
   AND B.VALIDFLAG = '1'
 WHERE T.ORD_LN_PK = '#ORD_LN_PK#'
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.setMscPlPc" desc="修改监制信息">
		<![CDATA[
UPDATE SLM_ORD_DESIGN_MSC_PL_PC T
   SET CYC_EDIT    = '#CYC_EDIT#',
       PRD_CYC_BTCH = '#PRD_CYC_BTCH#',
       UPDATE_NAME = '#UPDATE_NAME#',
       UPDATE_TIME = SYSDATE
 WHERE T.DESGIN_KEY = '#DESGIN_KEY#'
   AND T.ORD_LN_DLY_PK = '#ORD_LN_DLY_PK#'
   AND T.MSC_PLINE = '#MSC_PLINE#'
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.setCraftMscPlPc" desc="修改监制信息">
		<![CDATA[
UPDATE Craft_ORD_DESIGN_MSC_PL_PC T
   SET CYC_EDIT    = '#CYC_EDIT#',
       PRD_CYC_BTCH = '#PRD_CYC_BTCH#',
       UPDATE_NAME = '#UPDATE_NAME#',
       UPDATE_TIME = SYSDATE
 WHERE T.DESGIN_KEY = '#DESGIN_KEY#'
   AND T.ORD_LN_DLY_PK = '#ORD_LN_DLY_PK#'
   AND T.MSC_PLINE = '#MSC_PLINE#'
		]]>
	</query>
	
	
	<query id="CoreOrderReviewTechnology.getOrdLineSatus" 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="CoreOrderReviewTechnology.getOrdLineDesignSatus" desc="查询合同行质量设计明细状态">
		<![CDATA[
                SELECT DISTINCT (NVL(T.DESIGN_STS,'W')) DESIGN_STS
                  FROM SLM_ORD_DESIGN_STS_TKLG_LST T
                 WHERE T.ORD_LN_PK = ?
                   AND T.VALIDFLAG = '1'
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.getCraftLineDesignSatus" desc="查询合同行质量设计明细状态">
		<![CDATA[
                SELECT DISTINCT (T.DESIGN_STS)
                  FROM Craft_ORD_DESIGN_STS_TKLG_LST T
                 WHERE T.ORD_LN_PK = ?
                   AND T.VALIDFLAG = '1'
                   AND T.LST_ITEM != '生产周期'
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.updateItemList" desc="修改评审项目合同行技术评审明细信息">
		<![CDATA[
          UPDATE SLM_ORDER_REVIEW_ITEM_LIST T
             SET T.REVIEW_STATUS = ?,
                 T.REVIEW_F_RS   = ?,
                 T.REVIEW_DEPT   = ?,
                 T.REVIEW_MAN    = ?,
                 T.REVIEW_EDATE  = SYSDATE ,
                 T.RT_REVIEW_ITM = ?
           WHERE T.REVIEW_NO = ?
             AND T.REVIEW_ITM = ?
             AND T.LIST_PK_VAL = ?
             AND T.LIST_TYP = 'L'
           AND T.IS_CURT_REVIEW = '1'
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.updateOldLineStatus" desc="修改合同行状态">
		<![CDATA[
          UPDATE SLM_ORDER_LINE T
             SET T.BE_ORDER_LN_STATUS = T.ORDER_LN_STATUS, T.ORDER_LN_STATUS = ?
           WHERE T.ORD_LN_PK = ?
             AND T.VALIDFLAG = '1'
		]]>
	</query>
	
		<query id="CoreOrderReviewTechnology.updateOldDelivryStatus" desc="修改交货行状态">
		<![CDATA[
          UPDATE SLM_ORDER_LINE_DELIVERY T
             SET T.BE_DELIVERY_STATUS = T.DELIVERY_STATUS, T.DELIVERY_STATUS = ?
           WHERE T.ORD_LN_PK = ?
             AND T.VALIDFLAG = '1'
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.getLinesStatus" desc="查询合同头下所有合同行状态">
		<![CDATA[
          SELECT DISTINCT (T.ORDER_LN_STATUS)
            FROM SLM_ORDER_LINE T
           WHERE T.ORD_PK = ?
             AND T.VALIDFLAG = '1'
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.updateHeadStatus" desc="修改合同头状态">
		<![CDATA[
          UPDATE SLM_ORDER_HEAD T
             SET T.ORDER_STS      = ?,
                 T.ORDER_STS_DESC = ? 
           WHERE T.ORD_PK = ? 
             AND T.VALIDFLAG = '1'
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.updateItemStatus" desc="修改评审项目技术状态">
		<![CDATA[
          UPDATE SLM_ORDER_REVIEW_ITEM T
             SET T.REVEIW_EDATE = SYSDATE, T.REVIEW_STATUS = ?
           WHERE T.REVIEW_NO = ?
             AND T.REVIEW_ITM = 'T'
             AND T.VALIDFLAG = '1'
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.getOrderReview" desc="查询评审单号">
		<![CDATA[
         SELECT T.REVIEW_NO
           FROM SLM_ORDER_REVIEW T
          WHERE T.ORD_PK = ?
            AND T.VALIDFLAG = '1'
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.getMscInfo" desc="查询评审单号">
		<![CDATA[
         SELECT T1.UNIT_DESC_PROCESS,T1.CREATE_NAME FROM COM_MSC T1,SLM_ORDER_LINE T2 WHERE T1.MSC=T2.MSC AND T2.ORD_LN_PK=?
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.getOrdLnState" desc="查询合同行状态">
		<![CDATA[
SELECT T.*, A.DESGIN_KEY, B.ORDER_NO
  FROM SLM_ORDER_HEAD B, SLM_ORDER_LINE T
  LEFT JOIN CRAFT_ORD_DESIGN A
    ON A.ORD_LN_PK = T.ORD_LN_PK
 WHERE T.ORD_LN_PK = '#ORD_LN_PK#'
   AND B.ORD_PK = T.ORD_PK
   AND NVL(A.CRAFT_SEQ, '1') =
       DECODE(A.CRAFT_SEQ,
              NULL,
              '1',
              (SELECT MAX(CRAFT_SEQ)
                 FROM CRAFT_ORD_DESIGN
                WHERE ORD_LN_PK = T.ORD_LN_PK))
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.getOrdLnChgeOrdLnPk" desc="查询合同行状态">
		<![CDATA[
		SELECT T.CHGE_ORD_LN_PK FROM SLM_ORDER_LINE T WHERE T.ORD_LN_PK = ?
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.getComMscBl" desc="查询备料码">
		<![CDATA[
SELECT * FROM COM_MSC_BL T WHERE T.PSC_BL = '#PSC_BL#' AND T.VALIDFLAG = '1'
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.insertCraftOrdDesign" desc="新增工艺评审主表">
		<![CDATA[
INSERT INTO CRAFT_ORD_DESIGN
  (ORD_LN_PK,
   CRAFT_SEQ,
   CRAFT_NO,
   DESGIN_KEY,
   LOCK_FLAG,
   VALIDFLAG,
   CREATE_NAME,
   CREATE_TIME,
   QUALITY_FLAG,
   CRAFT_SOURCE,
   CRAFT_CHANGE_MEMO,
   PIC_FD_CHECK,
   CIC_FD_CHECK,
   WIC_FD_CHECK)
VALUES
  ('#ORD_LN_PK#',
   '#CRAFT_SEQ#',
   '#CRAFT_NO#',
   '#DESGIN_KEY#',
   '1',
   '2',
   '#CREATE_NAME#',
   SYSDATE,
   '0',
   '#CRAFT_SOURCE#',
   '#CRAFT_CHANGE_MEMO#',
   '#PIC_FD_CHECK#',
   '#CIC_FD_CHECK#',
   '#WIC_FD_CHECK#')
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.setAllCraftValidflag" desc="设置所有的标志位为无效">
		<![CDATA[
UPDATE CRAFT_ORD_DESIGN T
   SET T.VALIDFLAG = '0'
 WHERE T.ORD_LN_PK = '#ORD_LN_PK#'
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.getCraftOrdDesignMaxSeq" desc="获取最大的工艺评审序号">
		<![CDATA[
 SELECT MAX(T.CRAFT_SEQ) MAX_VALUE FROM CRAFT_ORD_DESIGN T WHERE T.ORD_LN_PK = '#ORD_LN_PK#'
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.getCraftOrdDesign" desc="获取工艺序号最大的记录">
		<![CDATA[
SELECT *
  FROM CRAFT_ORD_DESIGN T
 WHERE T.ORD_LN_PK = '#ORD_LN_PK#'
   AND T.CRAFT_SEQ = (SELECT MAX(CRAFT_SEQ)
                        FROM CRAFT_ORD_DESIGN
                       WHERE ORD_LN_PK = T.ORD_LN_PK)
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.updateCraftOrdDesign" desc="通过主键修改工艺文件并清空工艺号">
		<![CDATA[
 UPDATE CRAFT_ORD_DESIGN T
   SET T.CRAFT_NO       = NULL,
       T.CRAFT_NO_V     = NULL,
       T.CRAFT_PATH     = NULL,
       T.QUALITY_FLAG   = '0',
       T.DELETE_NAME    = NULL,
       T.DELETE_TIME    = NULL,
       T.AUDIT_NAME     = NULL,
       T.AUDIT_TIME     = NULL,
       T.AUDIT_NAME1    = NULL,
       T.AUDIT_TIME1    = NULL,
       T.APPROVAL_NAME  = NULL,
       T.APPROVAL_TIME  = NULL,
       T.APPROVAL_NAME1 = NULL,
       T.APPROVAL_TIME1 = NULL,
       T.DESGIN_KEY     = '#DESGIN_KEY#',
       T.LOCK_FLAG      = NVL('#LOCK_FLAG#', T.LOCK_FLAG),
       T.VALIDFLAG      = NVL('#VALIDFLAG#', T.VALIDFLAG),
       T.UPDATE_NAME    = '#UPDATE_NAME#',
       T.UPDATE_TIME    = SYSDATE,
       T.CRAFT_SOURCE   = '#CRAFT_SOURCE#'
 WHERE T.ORD_LN_PK = '#ORD_LN_PK#'
   AND T.CRAFT_SEQ = '#CRAFT_SEQ#'
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.updateCraftOrdDesign2" desc="通过主键修改工艺文件不清空工艺号">
		<![CDATA[
 UPDATE CRAFT_ORD_DESIGN T
   SET
        T.QUALITY_FLAG = '0',
        T.DESGIN_KEY = '#DESGIN_KEY#',
        T.LOCK_FLAG = NVL('#LOCK_FLAG#', T.LOCK_FLAG),
        T.VALIDFLAG = NVL('#VALIDFLAG#', T.VALIDFLAG),
        T.UPDATE_NAME = '#UPDATE_NAME#',
        T.UPDATE_TIME = SYSDATE,
        T.CRAFT_SOURCE = '#CRAFT_SOURCE#'
 WHERE
T.ORD_LN_PK = '#ORD_LN_PK#'
AND T.CRAFT_SEQ = '#CRAFT_SEQ#'
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.queryPlnSaleorder" desc="查询销售合同提报表">
		<![CDATA[
SELECT T.* FROM PLN_SALEORD T WHERE T.ORD_LN_PK = '#ORD_LN_PK#'
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.clearCraftOrdDesign" desc="清除工艺评审">
		<![CDATA[
DECLARE
BEGIN
  UPDATE CRAFT_ORD_DESIGN T
     SET T.VALIDFLAG = '0'
   WHERE T.ORD_LN_PK = '#ORD_LN_PK#'; --作废工艺文件

  UPDATE SLM_ORDER_LINE T
     SET T.CRAFT_NO = NULL, T.CRAFT_NO_V = NULL
   WHERE T.ORD_LN_PK = '#ORD_LN_PK#'; --清空合同行表工艺文件号
END;
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.copyOrdToCraft" desc="复制质量设计结果到工艺设计表中">
		<![CDATA[
DECLARE
  P_DESIGN_KEY         CRAFT_ORD_DESIGN_MSC.DESGIN_KEY%TYPE; --质量设计DESIGNKEY
  P_DESIGN_KEY_NEW     CRAFT_ORD_DESIGN_MSC.DESGIN_KEY%TYPE; --工艺评审DESIGNKEY新
  P_DESIGN_KEY_OLD     CRAFT_ORD_DESIGN_MSC.DESGIN_KEY%TYPE; --工艺评审DESIGNKEY旧
  P_DESIGN_KEY_BL      CRAFT_ORD_DESIGN_MSC.DESGIN_KEY%TYPE; --工艺评审DESIGNKEY备料
  P_DESIGN_KEY_JG      CRAFT_ORD_DESIGN_MSC.DESGIN_KEY%TYPE; --工艺评审DESIGNKEY接箍
  P_ORD_DESIGN_MSC_CNT NUMBER(5);
  P_CRAFT_DESIGN_CNT   NUMBER(5);
BEGIN
  P_DESIGN_KEY_NEW := '#DESIGN_KEY_NEW#';
  SELECT COUNT(1)
    INTO P_ORD_DESIGN_MSC_CNT
    FROM SLM_ORD_DESIGN_MSC
   WHERE ORD_LN_PK = '#ORD_LN_PK#'
     AND VALIDFLAG = '1';
  IF P_ORD_DESIGN_MSC_CNT > 0 THEN
    SELECT DESGIN_KEY
      INTO P_DESIGN_KEY
      FROM SLM_ORD_DESIGN_MSC
     WHERE ORD_LN_PK = '#ORD_LN_PK#'
       AND VALIDFLAG = '1';
  END IF;

  SELECT COUNT(1)
    INTO P_CRAFT_DESIGN_CNT
    FROM CRAFT_ORD_DESIGN
   WHERE ORD_LN_PK = '#ORD_LN_PK#'
     AND CRAFT_SEQ = (SELECT MAX(CRAFT_SEQ)
                        FROM CRAFT_ORD_DESIGN
                       WHERE ORD_LN_PK = '#ORD_LN_PK#')
     AND VALIDFLAG <> '1';
  IF P_CRAFT_DESIGN_CNT > 0 THEN
    SELECT DESGIN_KEY
      INTO P_DESIGN_KEY_OLD
      FROM CRAFT_ORD_DESIGN
     WHERE ORD_LN_PK = '#ORD_LN_PK#'
       AND CRAFT_SEQ = (SELECT MAX(CRAFT_SEQ)
                          FROM CRAFT_ORD_DESIGN
                         WHERE ORD_LN_PK = '#ORD_LN_PK#')
       AND VALIDFLAG <> '1';
  END IF;
  DELETE FROM CRAFT_ORD_DESIGN WHERE DESGIN_KEY = P_DESIGN_KEY_OLD;
  DELETE FROM CRAFT_ORD_DESIGN_MSC
   WHERE DESGIN_KEY = P_DESIGN_KEY_OLD
      OR DESGIN_KEY IN (SELECT DESGIN_KEY_BL
                          FROM CRAFT_ORD_DESIGN_MSC_BL
                         WHERE DESGIN_KEY = P_DESIGN_KEY_OLD)
      OR DESGIN_KEY IN (SELECT DESGIN_KEY_BL
                          FROM CRAFT_ORD_DESIGN_MSC_JG_BL
                         WHERE DESGIN_KEY = P_DESIGN_KEY_OLD);
  DELETE FROM CRAFT_ORD_DESIGN_MSC_BILT
   WHERE DESGIN_KEY = P_DESIGN_KEY_OLD
      OR DESGIN_KEY IN (SELECT DESGIN_KEY_BL
                          FROM CRAFT_ORD_DESIGN_MSC_BL
                         WHERE DESGIN_KEY = P_DESIGN_KEY_OLD)
      OR DESGIN_KEY IN (SELECT DESGIN_KEY_BL
                          FROM CRAFT_ORD_DESIGN_MSC_JG_BL
                         WHERE DESGIN_KEY = P_DESIGN_KEY_OLD);
  DELETE FROM CRAFT_ORD_DESIGN_MSC_BILT_C
   WHERE DESGIN_KEY = P_DESIGN_KEY_OLD
      OR DESGIN_KEY IN (SELECT DESGIN_KEY_BL
                          FROM CRAFT_ORD_DESIGN_MSC_BL
                         WHERE DESGIN_KEY = P_DESIGN_KEY_OLD)
      OR DESGIN_KEY IN (SELECT DESGIN_KEY_BL
                          FROM CRAFT_ORD_DESIGN_MSC_JG_BL
                         WHERE DESGIN_KEY = P_DESIGN_KEY_OLD);
  DELETE FROM CRAFT_ORD_DESIGN_MSC_BILT_C_PL
   WHERE DESGIN_KEY = P_DESIGN_KEY_OLD
      OR DESGIN_KEY IN (SELECT DESGIN_KEY_BL
                          FROM CRAFT_ORD_DESIGN_MSC_BL
                         WHERE DESGIN_KEY = P_DESIGN_KEY_OLD)
      OR DESGIN_KEY IN (SELECT DESGIN_KEY_BL
                          FROM CRAFT_ORD_DESIGN_MSC_JG_BL
                         WHERE DESGIN_KEY = P_DESIGN_KEY_OLD);
  DELETE FROM CRAFT_ORD_DESIGN_MSC_BILT_PL
   WHERE DESGIN_KEY = P_DESIGN_KEY_OLD
      OR DESGIN_KEY IN (SELECT DESGIN_KEY_BL
                          FROM CRAFT_ORD_DESIGN_MSC_BL
                         WHERE DESGIN_KEY = P_DESIGN_KEY_OLD)
      OR DESGIN_KEY IN (SELECT DESGIN_KEY_BL
                          FROM CRAFT_ORD_DESIGN_MSC_JG_BL
                         WHERE DESGIN_KEY = P_DESIGN_KEY_OLD);
  DELETE FROM CRAFT_ORD_DESIGN_MSC_GZ_GG
   WHERE DESGIN_KEY = P_DESIGN_KEY_OLD
      OR DESGIN_KEY IN (SELECT DESGIN_KEY_BL
                          FROM CRAFT_ORD_DESIGN_MSC_BL
                         WHERE DESGIN_KEY = P_DESIGN_KEY_OLD)
      OR DESGIN_KEY IN (SELECT DESGIN_KEY_BL
                          FROM CRAFT_ORD_DESIGN_MSC_JG_BL
                         WHERE DESGIN_KEY = P_DESIGN_KEY_OLD);
  DELETE FROM CRAFT_ORD_DESIGN_MSC_GZ_GG_PL
   WHERE DESGIN_KEY = P_DESIGN_KEY_OLD
      OR DESGIN_KEY IN (SELECT DESGIN_KEY_BL
                          FROM CRAFT_ORD_DESIGN_MSC_BL
                         WHERE DESGIN_KEY = P_DESIGN_KEY_OLD)
      OR DESGIN_KEY IN (SELECT DESGIN_KEY_BL
                          FROM CRAFT_ORD_DESIGN_MSC_JG_BL
                         WHERE DESGIN_KEY = P_DESIGN_KEY_OLD);
  DELETE FROM CRAFT_ORD_DESIGN_MSC_JG WHERE DESGIN_KEY = P_DESIGN_KEY_OLD;
  DELETE FROM CRAFT_ORD_DESIGN_MSC_JG_PL
   WHERE DESGIN_KEY = P_DESIGN_KEY_OLD
      OR DESGIN_KEY IN (SELECT DESGIN_KEY_BL
                          FROM CRAFT_ORD_DESIGN_MSC_BL
                         WHERE DESGIN_KEY = P_DESIGN_KEY_OLD)
      OR DESGIN_KEY IN (SELECT DESGIN_KEY_BL
                          FROM CRAFT_ORD_DESIGN_MSC_JG_BL
                         WHERE DESGIN_KEY = P_DESIGN_KEY_OLD);
  DELETE FROM CRAFT_ORD_DESIGN_MSC_JG_PL_STI
   WHERE DESGIN_KEY = P_DESIGN_KEY_OLD
      OR DESGIN_KEY IN (SELECT DESGIN_KEY_BL
                          FROM CRAFT_ORD_DESIGN_MSC_BL
                         WHERE DESGIN_KEY = P_DESIGN_KEY_OLD)
      OR DESGIN_KEY IN (SELECT DESGIN_KEY_BL
                          FROM CRAFT_ORD_DESIGN_MSC_JG_BL
                         WHERE DESGIN_KEY = P_DESIGN_KEY_OLD);
  DELETE FROM CRAFT_ORD_DESIGN_MSC_PL
   WHERE DESGIN_KEY = P_DESIGN_KEY_OLD
      OR DESGIN_KEY IN (SELECT DESGIN_KEY_BL
                          FROM CRAFT_ORD_DESIGN_MSC_BL
                         WHERE DESGIN_KEY = P_DESIGN_KEY_OLD)
      OR DESGIN_KEY IN (SELECT DESGIN_KEY_BL
                          FROM CRAFT_ORD_DESIGN_MSC_JG_BL
                         WHERE DESGIN_KEY = P_DESIGN_KEY_OLD);
  DELETE FROM CRAFT_ORD_DESIGN_MSC_PL_GX_PRL
   WHERE DESGIN_KEY = P_DESIGN_KEY_OLD
      OR DESGIN_KEY IN (SELECT DESGIN_KEY_BL
                          FROM CRAFT_ORD_DESIGN_MSC_BL
                         WHERE DESGIN_KEY = P_DESIGN_KEY_OLD)
      OR DESGIN_KEY IN (SELECT DESGIN_KEY_BL
                          FROM CRAFT_ORD_DESIGN_MSC_JG_BL
                         WHERE DESGIN_KEY = P_DESIGN_KEY_OLD);
  DELETE FROM CRAFT_ORD_DESIGN_MSC_PL_GZ
   WHERE DESGIN_KEY = P_DESIGN_KEY_OLD
      OR DESGIN_KEY IN (SELECT DESGIN_KEY_BL
                          FROM CRAFT_ORD_DESIGN_MSC_BL
                         WHERE DESGIN_KEY = P_DESIGN_KEY_OLD)
      OR DESGIN_KEY IN (SELECT DESGIN_KEY_BL
                          FROM CRAFT_ORD_DESIGN_MSC_JG_BL
                         WHERE DESGIN_KEY = P_DESIGN_KEY_OLD);
  DELETE FROM CRAFT_ORD_DESIGN_MSC_PL_PC
   WHERE DESGIN_KEY = P_DESIGN_KEY_OLD
      OR DESGIN_KEY IN (SELECT DESGIN_KEY_BL
                          FROM CRAFT_ORD_DESIGN_MSC_BL
                         WHERE DESGIN_KEY = P_DESIGN_KEY_OLD)
      OR DESGIN_KEY IN (SELECT DESGIN_KEY_BL
                          FROM CRAFT_ORD_DESIGN_MSC_JG_BL
                         WHERE DESGIN_KEY = P_DESIGN_KEY_OLD);
  DELETE FROM CRAFT_ORD_DESIGN_MSC_PL_PC_LST
   WHERE DESGIN_KEY = P_DESIGN_KEY_OLD
      OR DESGIN_KEY IN (SELECT DESGIN_KEY_BL
                          FROM CRAFT_ORD_DESIGN_MSC_BL
                         WHERE DESGIN_KEY = P_DESIGN_KEY_OLD)
      OR DESGIN_KEY IN (SELECT DESGIN_KEY_BL
                          FROM CRAFT_ORD_DESIGN_MSC_JG_BL
                         WHERE DESGIN_KEY = P_DESIGN_KEY_OLD);
  DELETE FROM CRAFT_ORD_DESIGN_MSC_PL_PRC
   WHERE DESGIN_KEY = P_DESIGN_KEY_OLD
      OR DESGIN_KEY IN (SELECT DESGIN_KEY_BL
                          FROM CRAFT_ORD_DESIGN_MSC_BL
                         WHERE DESGIN_KEY = P_DESIGN_KEY_OLD)
      OR DESGIN_KEY IN (SELECT DESGIN_KEY_BL
                          FROM CRAFT_ORD_DESIGN_MSC_JG_BL
                         WHERE DESGIN_KEY = P_DESIGN_KEY_OLD);
  DELETE FROM CRAFT_ORD_DESIGN_MSC_PL_STI
   WHERE DESGIN_KEY = P_DESIGN_KEY_OLD
      OR DESGIN_KEY IN (SELECT DESGIN_KEY_BL
                          FROM CRAFT_ORD_DESIGN_MSC_BL
                         WHERE DESGIN_KEY = P_DESIGN_KEY_OLD)
      OR DESGIN_KEY IN (SELECT DESGIN_KEY_BL
                          FROM CRAFT_ORD_DESIGN_MSC_JG_BL
                         WHERE DESGIN_KEY = P_DESIGN_KEY_OLD);
  DELETE FROM CRAFT_ORD_DESIGN_MSC_PL_STI_TC
   WHERE DESGIN_KEY = P_DESIGN_KEY_OLD
      OR DESGIN_KEY IN (SELECT DESGIN_KEY_BL
                          FROM CRAFT_ORD_DESIGN_MSC_BL
                         WHERE DESGIN_KEY = P_DESIGN_KEY_OLD)
      OR DESGIN_KEY IN (SELECT DESGIN_KEY_BL
                          FROM CRAFT_ORD_DESIGN_MSC_JG_BL
                         WHERE DESGIN_KEY = P_DESIGN_KEY_OLD);
  DELETE FROM CRAFT_ORD_DESIGN_STD
   WHERE DESGIN_KEY = P_DESIGN_KEY_OLD
      OR DESGIN_KEY IN (SELECT DESGIN_KEY_BL
                          FROM CRAFT_ORD_DESIGN_MSC_BL
                         WHERE DESGIN_KEY = P_DESIGN_KEY_OLD)
      OR DESGIN_KEY IN (SELECT DESGIN_KEY_BL
                          FROM CRAFT_ORD_DESIGN_MSC_JG_BL
                         WHERE DESGIN_KEY = P_DESIGN_KEY_OLD);
  DELETE FROM CRAFT_ORD_DESIGN_STD_CIC
   WHERE DESGIN_KEY = P_DESIGN_KEY_OLD
      OR DESGIN_KEY IN (SELECT DESGIN_KEY_BL
                          FROM CRAFT_ORD_DESIGN_MSC_BL
                         WHERE DESGIN_KEY = P_DESIGN_KEY_OLD)
      OR DESGIN_KEY IN (SELECT DESGIN_KEY_BL
                          FROM CRAFT_ORD_DESIGN_MSC_JG_BL
                         WHERE DESGIN_KEY = P_DESIGN_KEY_OLD);
  DELETE FROM CRAFT_ORD_DESIGN_STD_DIC
   WHERE DESGIN_KEY = P_DESIGN_KEY_OLD
      OR DESGIN_KEY IN (SELECT DESGIN_KEY_BL
                          FROM CRAFT_ORD_DESIGN_MSC_BL
                         WHERE DESGIN_KEY = P_DESIGN_KEY_OLD)
      OR DESGIN_KEY IN (SELECT DESGIN_KEY_BL
                          FROM CRAFT_ORD_DESIGN_MSC_JG_BL
                         WHERE DESGIN_KEY = P_DESIGN_KEY_OLD);
  DELETE FROM CRAFT_ORD_DESIGN_STD_GIC
   WHERE DESGIN_KEY = P_DESIGN_KEY_OLD
      OR DESGIN_KEY IN (SELECT DESGIN_KEY_BL
                          FROM CRAFT_ORD_DESIGN_MSC_BL
                         WHERE DESGIN_KEY = P_DESIGN_KEY_OLD)
      OR DESGIN_KEY IN (SELECT DESGIN_KEY_BL
                          FROM CRAFT_ORD_DESIGN_MSC_JG_BL
                         WHERE DESGIN_KEY = P_DESIGN_KEY_OLD);
  DELETE FROM CRAFT_ORD_DESIGN_STD_PIC
   WHERE DESGIN_KEY = P_DESIGN_KEY_OLD
      OR DESGIN_KEY IN (SELECT DESGIN_KEY_BL
                          FROM CRAFT_ORD_DESIGN_MSC_BL
                         WHERE DESGIN_KEY = P_DESIGN_KEY_OLD)
      OR DESGIN_KEY IN (SELECT DESGIN_KEY_BL
                          FROM CRAFT_ORD_DESIGN_MSC_JG_BL
                         WHERE DESGIN_KEY = P_DESIGN_KEY_OLD);
  DELETE FROM CRAFT_ORD_DESIGN_STD_PIC_SMP
   WHERE DESGIN_KEY = P_DESIGN_KEY_OLD
      OR DESGIN_KEY IN (SELECT DESGIN_KEY_BL
                          FROM CRAFT_ORD_DESIGN_MSC_BL
                         WHERE DESGIN_KEY = P_DESIGN_KEY_OLD)
      OR DESGIN_KEY IN (SELECT DESGIN_KEY_BL
                          FROM CRAFT_ORD_DESIGN_MSC_JG_BL
                         WHERE DESGIN_KEY = P_DESIGN_KEY_OLD);
  DELETE FROM CRAFT_ORD_DESIGN_STD_SIC
   WHERE DESGIN_KEY = P_DESIGN_KEY_OLD
      OR DESGIN_KEY IN (SELECT DESGIN_KEY_BL
                          FROM CRAFT_ORD_DESIGN_MSC_BL
                         WHERE DESGIN_KEY = P_DESIGN_KEY_OLD)
      OR DESGIN_KEY IN (SELECT DESGIN_KEY_BL
                          FROM CRAFT_ORD_DESIGN_MSC_JG_BL
                         WHERE DESGIN_KEY = P_DESIGN_KEY_OLD);
  DELETE FROM CRAFT_ORD_DESIGN_STD_WIC
   WHERE DESGIN_KEY = P_DESIGN_KEY_OLD
      OR DESGIN_KEY IN (SELECT DESGIN_KEY_BL
                          FROM CRAFT_ORD_DESIGN_MSC_BL
                         WHERE DESGIN_KEY = P_DESIGN_KEY_OLD)
      OR DESGIN_KEY IN (SELECT DESGIN_KEY_BL
                          FROM CRAFT_ORD_DESIGN_MSC_JG_BL
                         WHERE DESGIN_KEY = P_DESIGN_KEY_OLD);
  DELETE FROM CRAFT_ORD_DESIGN_STS_PL_PC
   WHERE DESGIN_KEY = P_DESIGN_KEY_OLD
      OR DESGIN_KEY IN (SELECT DESGIN_KEY_BL
                          FROM CRAFT_ORD_DESIGN_MSC_BL
                         WHERE DESGIN_KEY = P_DESIGN_KEY_OLD)
      OR DESGIN_KEY IN (SELECT DESGIN_KEY_BL
                          FROM CRAFT_ORD_DESIGN_MSC_JG_BL
                         WHERE DESGIN_KEY = P_DESIGN_KEY_OLD);
  DELETE FROM CRAFT_ORD_DESIGN_STS_PL_PC_LST
   WHERE DESGIN_KEY = P_DESIGN_KEY_OLD
      OR DESGIN_KEY IN (SELECT DESGIN_KEY_BL
                          FROM CRAFT_ORD_DESIGN_MSC_BL
                         WHERE DESGIN_KEY = P_DESIGN_KEY_OLD)
      OR DESGIN_KEY IN (SELECT DESGIN_KEY_BL
                          FROM CRAFT_ORD_DESIGN_MSC_JG_BL
                         WHERE DESGIN_KEY = P_DESIGN_KEY_OLD);
  DELETE FROM CRAFT_ORD_DESIGN_STS_TKLG
   WHERE DESGIN_KEY = P_DESIGN_KEY_OLD
      OR DESGIN_KEY IN (SELECT DESGIN_KEY_BL
                          FROM CRAFT_ORD_DESIGN_MSC_BL
                         WHERE DESGIN_KEY = P_DESIGN_KEY_OLD)
      OR DESGIN_KEY IN (SELECT DESGIN_KEY_BL
                          FROM CRAFT_ORD_DESIGN_MSC_JG_BL
                         WHERE DESGIN_KEY = P_DESIGN_KEY_OLD);
  DELETE FROM CRAFT_ORD_DESIGN_STS_TKLG_LST
   WHERE DESGIN_KEY = P_DESIGN_KEY_OLD
      OR DESGIN_KEY IN (SELECT DESGIN_KEY_BL
                          FROM CRAFT_ORD_DESIGN_MSC_BL
                         WHERE DESGIN_KEY = P_DESIGN_KEY_OLD)
      OR DESGIN_KEY IN (SELECT DESGIN_KEY_BL
                          FROM CRAFT_ORD_DESIGN_MSC_JG_BL
                         WHERE DESGIN_KEY = P_DESIGN_KEY_OLD);
  DELETE FROM CRAFT_ORD_LINE_BOM
   WHERE DESGIN_KEY = P_DESIGN_KEY_OLD
      OR DESGIN_KEY IN (SELECT DESGIN_KEY_BL
                          FROM CRAFT_ORD_DESIGN_MSC_BL
                         WHERE DESGIN_KEY = P_DESIGN_KEY_OLD)
      OR DESGIN_KEY IN (SELECT DESGIN_KEY_BL
                          FROM CRAFT_ORD_DESIGN_MSC_JG_BL
                         WHERE DESGIN_KEY = P_DESIGN_KEY_OLD);
  DELETE FROM CRAFT_ORD_DESIGN_MSC_JG_BL
   WHERE DESGIN_KEY = P_DESIGN_KEY_OLD;
  DELETE FROM CRAFT_ORD_DESIGN_MSC_BL WHERE DESGIN_KEY = P_DESIGN_KEY_OLD;

  INSERT INTO CRAFT_ORD_DESIGN
    (ORD_LN_PK,
     CRAFT_SEQ,
     CRAFT_NO,
     DESGIN_KEY,
     LOCK_FLAG,
     VALIDFLAG,
     CREATE_NAME,
     CREATE_TIME,
     QUALITY_FLAG)
  VALUES
    ('#ORD_LN_PK#',
     (SELECT NVL(MAX(CRAFT_SEQ), 0) + 1
        FROM CRAFT_ORD_DESIGN
       WHERE ORD_LN_PK = '#ORD_LN_PK#'),
     '',
     P_DESIGN_KEY_NEW,
     '1',
     '2',
     '#CREATE_NAME#',
     SYSDATE,
     '#QUALITY_FLAG#');
  INSERT INTO CRAFT_ORD_DESIGN_MSC
    (DESGIN_KEY,
     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,
     PRD_LEN,
     LOSS_RATE,
     VALIDFLAG,
     CREATE_NAME,
     CREATE_TIME,
     UPDATE_NAME,
     UPDATE_TIME,
     DELETE_NAME,
     DELETE_TIME,
     ORD_LN_PK_OLD)
    (SELECT P_DESIGN_KEY_NEW,
            T.ORD_PK,
            T.ORD_LN_PK,
            T.ORDER_SEQ,
            T.CUST_ALPHA_NO,
            T.PSC,
            T.PSC_DESC,
            T.MSC,
            T.MSC_DESC,
            T.MSC_STYLE,
            T.USE_CODE,
            T.USE_DESC,
            T.PRD_CLS,
            T.PRODUCCODE,
            T.PRODUCNAME,
            T.STD_CODE,
            T.STD_NAME,
            T.STEELCODE,
            T.STEELNAME,
            T.STD_STYLE,
            T.STD_STYLE_DESC,
            T.ORDER_SPEC_CODE,
            T.ORDER_SPEC_DESC,
            T.SPEC_CODE,
            T.SPEC_NAME,
            T.DIMATER,
            T.HEIGHT,
            T.MODEL_CODE,
            T.MODEL_DESC,
            T.LEN_NO,
            T.LEN_DESC,
            T.LEN_UNIT,
            T.LEN_MIN,
            T.LEN_MAX,
            T.SHRT_LEN_RATO,
            T.SHORTEST,
            T.LONG_LEN_RATO,
            T.LONGEST,
            T.SHRT_STOVE,
            T.AVG_LEN_MIN,
            T.DIFRNC_LEN_MAX,
            T.ENDLEN_SPECSTD,
            T.SIGL_LEN,
            T.ORDER_UNIT,
            T.ORDER_QTY,
            T.ORD_ENSU_TOTL_LEN,
            T.PRDCT_WGT,
            T.DELVRY_RANGE_TPE,
            T.DELVRY_RANGE_MIN,
            T.DELVRY_RANGE_MAX,
            T.FINAL_USER,
            T.FINAL_USER_DESC,
            T.OUTS_BILLET_FL,
            T.OUTS_STL_PIPE_FL,
            T.ASSEL_FL,
            T.PRODUCER_FL,
            T.PRDCR_NO,
            T.PRDCR_DESC,
            T.MPS_FL,
            T.MPS_NO,
            T.MPS_DESC,
            T.DELVRY_BDATE,
            T.DELVRY_EDATE,
            T.DELVRY_DESC,
            T.TRANS_DESC,
            T.ADD_ASK_NO,
            T.ORDER_ADD_DESC,
            T.ORDER_SPECIAL_FL,
            T.ORDER_SPECIAL_HEAD,
            T.ORDER_SPECIAL_PATH,
            T.ORDER_SPECIAL_DESC,
            T.ZBS,
            T.ORDER_PRICE,
            T.TRANS_PRICE,
            T.TEST_ID,
            T.TEST_PRICE,
            T.OUT_PRICE,
            T.BALNCE_PRICE,
            T.BE_ORDER_LN_STATUS,
            T.BE_OBJ_STS_OP,
            T.ORDER_LN_STATUS,
            T.OBJ_STS_OP,
            T.MEMO,
            T.PRD_LEN,
            T.LOSS_RATE,
            T.VALIDFLAG,
            T.CREATE_NAME,
            T.CREATE_TIME,
            T.UPDATE_NAME,
            T.UPDATE_TIME,
            T.DELETE_NAME,
            T.DELETE_TIME,
            T.ORD_LN_PK_OLD
       FROM SLM_ORD_DESIGN_MSC T
      WHERE T.DESGIN_KEY = P_DESIGN_KEY);

  INSERT INTO CRAFT_ORD_DESIGN_MSC_BILT
    (DESGIN_KEY, MSC_PLINE, SPEC_CODE, B_SPEC_CODE, B_SPEC_NAME)
    (SELECT P_DESIGN_KEY_NEW,
            T.MSC_PLINE,
            T.SPEC_CODE,
            T.B_SPEC_CODE,
            T.B_SPEC_NAME
       FROM SLM_ORD_DESIGN_MSC_BILT T
      WHERE T.DESGIN_KEY = P_DESIGN_KEY);

  INSERT INTO CRAFT_ORD_DESIGN_MSC_BILT_C
    (DESGIN_KEY,
     MSC_PLINE,
     SPEC_CODE,
     B_SPEC_CODE,
     C_SPEC_CODE,
     C_SPEC_NAME,
     SPEC_CODE_S)
    (SELECT P_DESIGN_KEY_NEW,
            T.MSC_PLINE,
            T.SPEC_CODE,
            T.B_SPEC_CODE,
            T.C_SPEC_CODE,
            T.C_SPEC_NAME,
            T.SPEC_CODE_S
       FROM SLM_ORD_DESIGN_MSC_BILT_C T
      WHERE T.DESGIN_KEY = P_DESIGN_KEY);

  INSERT INTO CRAFT_ORD_DESIGN_MSC_BILT_C_PL
    (DESGIN_KEY, MSC_PLINE, C_SPEC_CODE, PLINE_CODE, PLINE_NAME)
    (SELECT P_DESIGN_KEY_NEW,
            T.MSC_PLINE,
            T.C_SPEC_CODE,
            T.PLINE_CODE,
            T.PLINE_NAME
       FROM SLM_ORD_DESIGN_MSC_BILT_C_PL T
      WHERE T.DESGIN_KEY = P_DESIGN_KEY);

  INSERT INTO CRAFT_ORD_DESIGN_MSC_BILT_PL
    (DESGIN_KEY, MSC_PLINE, B_SPEC_CODE, PLINE_CODE, PLINE_NAME)
    (SELECT P_DESIGN_KEY_NEW,
            T.MSC_PLINE,
            T.B_SPEC_CODE,
            T.PLINE_CODE,
            T.PLINE_NAME
       FROM SLM_ORD_DESIGN_MSC_BILT_PL T
      WHERE T.DESGIN_KEY = P_DESIGN_KEY);

  INSERT INTO CRAFT_ORD_DESIGN_MSC_GZ_GG
    (DESGIN_KEY,
     MSC_PLINE,
     GRADECODE,
     GRADENAME,
     SPEC_CODE,
     SPEC_NAME,
     DIMATER,
     HEIGHT)
    (SELECT P_DESIGN_KEY_NEW,
            T.MSC_PLINE,
            T.GRADECODE,
            T.GRADENAME,
            T.SPEC_CODE,
            T.SPEC_NAME,
            T.DIMATER,
            T.HEIGHT
       FROM SLM_ORD_DESIGN_MSC_GZ_GG T
      WHERE T.DESGIN_KEY = P_DESIGN_KEY);

  INSERT INTO CRAFT_ORD_DESIGN_MSC_GZ_GG_PL
    (DESGIN_KEY,
     MSC_PLINE,
     SPEC_CODE,
     PLINE_CODE,
     PLINE_NAME,
     PRD_LEN,
     LOSS_RATE,
     IS_OUTPUT)
    (SELECT P_DESIGN_KEY_NEW,
            T.MSC_PLINE,
            T.SPEC_CODE,
            T.PLINE_CODE,
            T.PLINE_NAME,
            T.PRD_LEN,
            T.LOSS_RATE,
            T.IS_OUTPUT
       FROM SLM_ORD_DESIGN_MSC_GZ_GG_PL T
      WHERE T.DESGIN_KEY = P_DESIGN_KEY);

  INSERT INTO CRAFT_ORD_DESIGN_MSC_JG
    (DESGIN_KEY,
     CODE_JG,
     DEMAND_DETECTION,
     DEMAND_BONDERIZING,
     DEMAND_COPPER,
     DEMAND_BLAST,
     PRODUCCODE,
     PRODUCNAME,
     STEELCODE,
     STEELNAME,
     MIN_H,
     MAX_H,
     MIN_D,
     MAX_D,
     SET_JG,
     CUST_ALPHA_NO,
     KEY_JG,
     ORDER_SPECIAL_DESC)
    (SELECT P_DESIGN_KEY_NEW,
            T.CODE_JG,
            T.DEMAND_DETECTION,
            T.DEMAND_BONDERIZING,
            T.DEMAND_COPPER,
            T.DEMAND_BLAST,
            T.PRODUCCODE,
            T.PRODUCNAME,
            T.STEELCODE,
            T.STEELNAME,
            T.MIN_H,
            T.MAX_H,
            T.MIN_D,
            T.MAX_D,
            T.SET_JG,
            T.CUST_ALPHA_NO,
            T.KEY_JG,
            T.ORDER_SPECIAL_DESC
       FROM SLM_ORD_DESIGN_MSC_JG T
      WHERE T.DESGIN_KEY = P_DESIGN_KEY);

  INSERT INTO CRAFT_ORD_DESIGN_MSC_JG_PL
    (DESGIN_KEY,
     CODE_JG,
     MSC_PLINE,
     WHOLE_BACKLOG,
     WHOLE_BACKLOG_DESC,
     SET_FL,
     WARN_DESC,
     ORD_LN_PK)
    (SELECT P_DESIGN_KEY_NEW,
            T.CODE_JG,
            T.MSC_PLINE,
            T.WHOLE_BACKLOG,
            T.WHOLE_BACKLOG_DESC,
            T.SET_FL,
            T.WARN_DESC,
            T.ORD_LN_PK
       FROM SLM_ORD_DESIGN_MSC_JG_PL T
      WHERE T.DESGIN_KEY = P_DESIGN_KEY);

  INSERT INTO CRAFT_ORD_DESIGN_MSC_JG_PL_STI
    (DESGIN_KEY,
     CODE_JG,
     MSC_PLINE,
     WHOLE_BACKLOG,
     WHOLE_BACKLOG_DESC,
     BACKLOG_SEQ,
     PROCESS_CODE,
     PROCESS_DESC,
     PROCESS_SEQ,
     PROCESS_CODE_C,
     PROCESS_DESC_C,
     STATION_ID,
     STATION_CODE,
     STATION_DESC,
     STATION_TYPE)
    (SELECT P_DESIGN_KEY_NEW,
            T.CODE_JG,
            T.MSC_PLINE,
            T.WHOLE_BACKLOG,
            T.WHOLE_BACKLOG_DESC,
            T.BACKLOG_SEQ,
            T.PROCESS_CODE,
            T.PROCESS_DESC,
            T.PROCESS_SEQ,
            T.PROCESS_CODE_C,
            T.PROCESS_DESC_C,
            T.STATION_ID,
            T.STATION_CODE,
            T.STATION_DESC,
            T.STATION_TYPE
       FROM SLM_ORD_DESIGN_MSC_JG_PL_STI T
      WHERE T.DESGIN_KEY = P_DESIGN_KEY);

  INSERT INTO CRAFT_ORD_DESIGN_MSC_PL
    (DESGIN_KEY,
     MSC_PLINE,
     WHOLE_BACKLOG,
     WHOLE_BACKLOG_DESC,
     SET_FL,
     WARN_DESC,
     ORD_LN_PK)
    (SELECT P_DESIGN_KEY_NEW,
            T.MSC_PLINE,
            T.WHOLE_BACKLOG,
            T.WHOLE_BACKLOG_DESC,
            T.SET_FL,
            T.WARN_DESC,
            T.ORD_LN_PK
       FROM SLM_ORD_DESIGN_MSC_PL T
      WHERE T.DESGIN_KEY = P_DESIGN_KEY);

  INSERT INTO CRAFT_ORD_DESIGN_MSC_PL_GX_PRL
    (DESGIN_KEY,
     MSC_PLINE,
     BACKLOG_SEQ,
     PROCESS_CODE,
     PLINE_CODE,
     PLINE_NAME,
     WELL_CODE,
     WELL_NAME,
     WARN_FL,
     WARN_DESC,
     VALIDFLAG,
     IDENT_FLAG)
    (SELECT P_DESIGN_KEY_NEW,
            T.MSC_PLINE,
            T.BACKLOG_SEQ,
            T.PROCESS_CODE,
            T.PLINE_CODE,
            T.PLINE_NAME,
            T.WELL_CODE,
            T.WELL_NAME,
            T.WARN_FL,
            T.WARN_DESC,
            T.VALIDFLAG,
            T.IDENT_FLAG
       FROM SLM_ORD_DESIGN_MSC_PL_GX_PRL T
      WHERE T.DESGIN_KEY = P_DESIGN_KEY);

  INSERT INTO CRAFT_ORD_DESIGN_MSC_PL_GZ
    (DESGIN_KEY,
     MSC_PLINE,
     WHOLE_BACKLOG,
     WHOLE_BACKLOG_DESC,
     GRADECODE,
     GRADENAME,
     ASSORTMENT_CODE,
     ASSORTMENT_NAME)
    (SELECT P_DESIGN_KEY_NEW,
            T.MSC_PLINE,
            T.WHOLE_BACKLOG,
            T.WHOLE_BACKLOG_DESC,
            T.GRADECODE,
            T.GRADENAME,
            T.ASSORTMENT_CODE,
            T.ASSORTMENT_NAME
       FROM SLM_ORD_DESIGN_MSC_PL_GZ T
      WHERE T.DESGIN_KEY = P_DESIGN_KEY);

  INSERT INTO CRAFT_ORD_DESIGN_MSC_PL_PC
    (DESGIN_KEY,
     ORD_LN_DLY_PK,
     MSC_PLINE,
     DELVRY_EDATE,
     DELVRY_QTY,
     ORDER_UNIT,
     RECEIV_NO,
     RECEIV_NM,
     RCMD_DELVRY_EDATE,
     PRD_CYC,
     PRD_CYC_BTCH,
     N_MATERIAL_FL,
     CYC_EDIT,
     CREATE_NAME,
     CREATE_TIME,
     UPDATE_NAME,
     UPDATE_TIME)
    (SELECT P_DESIGN_KEY_NEW,
            T.ORD_LN_DLY_PK,
            T.MSC_PLINE,
            T.DELVRY_EDATE,
            T.DELVRY_QTY,
            T.ORDER_UNIT,
            T.RECEIV_NO,
            T.RECEIV_NM,
            T.RCMD_DELVRY_EDATE,
            T.PRD_CYC,
            T.PRD_CYC_BTCH,
            T.N_MATERIAL_FL,
            T.CYC_EDIT,
            T.CREATE_NAME,
            T.CREATE_TIME,
            T.UPDATE_NAME,
            T.UPDATE_TIME
       FROM SLM_ORD_DESIGN_MSC_PL_PC T
      WHERE T.DESGIN_KEY = P_DESIGN_KEY);

  INSERT INTO CRAFT_ORD_DESIGN_MSC_PL_PC_LST
    (DESGIN_KEY,
     ORD_LN_DLY_PK,
     MSC_PLINE,
     BACKLOG_SEQ,
     PROCESS_CODE,
     PROCESS_DESC,
     REVIEW_ASK,
     LST_PRD_DATE,
     PRD_CYC,
     PRD_CYC_BTCH)
    (SELECT P_DESIGN_KEY_NEW,
            T.ORD_LN_DLY_PK,
            T.MSC_PLINE,
            T.BACKLOG_SEQ,
            T.PROCESS_CODE,
            T.PROCESS_DESC,
            T.REVIEW_ASK,
            T.LST_PRD_DATE,
            T.PRD_CYC,
            T.PRD_CYC_BTCH
       FROM SLM_ORD_DESIGN_MSC_PL_PC_LST T
      WHERE T.DESGIN_KEY = P_DESIGN_KEY);

  INSERT INTO CRAFT_ORD_DESIGN_MSC_PL_PRC
    (DESGIN_KEY,
     MSC_PLINE,
     WHOLE_BACKLOG,
     WHOLE_BACKLOG_DESC,
     BACKLOG_SEQ,
     PROCESS_CODE,
     PROCESS_DESC,
     PROCESS_SEQ,
     PROCESS_CODE_C,
     PROCESS_DESC_C,
     MINUTE_PRODUCT,
     MINUTE_PRODUCT_OUT,
     MINUTE_WAITE,
     MINUTE_WAITE_OUT,
     BATCH_WAITE,
     BATCH_WAITE_OUT,
     CIC,
     PIC,
     SIC,
     DIC,
     WIC,
     GIC)
    (SELECT P_DESIGN_KEY_NEW,
            T.MSC_PLINE,
            T.WHOLE_BACKLOG,
            T.WHOLE_BACKLOG_DESC,
            T.BACKLOG_SEQ,
            T.PROCESS_CODE,
            T.PROCESS_DESC,
            T.PROCESS_SEQ,
            T.PROCESS_CODE_C,
            T.PROCESS_DESC_C,
            T.MINUTE_PRODUCT,
            T.MINUTE_PRODUCT_OUT,
            T.MINUTE_WAITE,
            T.MINUTE_WAITE_OUT,
            T.BATCH_WAITE,
            T.BATCH_WAITE_OUT,
            T.CIC,
            T.PIC,
            T.SIC,
            T.DIC,
            T.WIC,
            T.GIC
       FROM SLM_ORD_DESIGN_MSC_PL_PRC T
      WHERE T.DESGIN_KEY = P_DESIGN_KEY);

  INSERT INTO CRAFT_ORD_DESIGN_MSC_PL_STI
    (DESGIN_KEY,
     MSC_PLINE,
     WHOLE_BACKLOG,
     WHOLE_BACKLOG_DESC,
     BACKLOG_SEQ,
     PROCESS_CODE,
     PROCESS_DESC,
     PROCESS_SEQ,
     PROCESS_CODE_C,
     PROCESS_DESC_C,
     STATION_ID,
     STATION_CODE,
     STATION_DESC,
     STATION_TYPE,
     CRAFTITEM_CODE,
     CRAFTITEM_DESC)
    (SELECT P_DESIGN_KEY_NEW,
            T.MSC_PLINE,
            T.WHOLE_BACKLOG,
            T.WHOLE_BACKLOG_DESC,
            T.BACKLOG_SEQ,
            T.PROCESS_CODE,
            T.PROCESS_DESC,
            T.PROCESS_SEQ,
            T.PROCESS_CODE_C,
            T.PROCESS_DESC_C,
            T.STATION_ID,
            T.STATION_CODE,
            T.STATION_DESC,
            T.STATION_TYPE,
            T.CRAFTITEM_CODE,
            T.CRAFTITEM_DESC
       FROM SLM_ORD_DESIGN_MSC_PL_STI T
      WHERE T.DESGIN_KEY = P_DESIGN_KEY);

  INSERT INTO CRAFT_ORD_DESIGN_MSC_PL_STI_TC
    (DESGIN_KEY,
     ORD_PK,
     ORD_LN_PK,
     MSC_PLINE,
     WHOLE_BACKLOG,
     WHOLE_BACKLOG_DESC,
     BACKLOG_SEQ,
     PROCESS_CODE,
     PROCESS_DESC,
     PROCESS_SEQ,
     PROCESS_CODE_C,
     PROCESS_DESC_C,
     STATION_ID,
     STATION_CODE,
     STATION_DESC,
     STATION_TYPE,
     CRAFTITEM_CODE,
     CRAFTITEM_DESC)
    (SELECT P_DESIGN_KEY_NEW,
            T.ORD_PK,
            T.ORD_LN_PK,
            T.MSC_PLINE,
            T.WHOLE_BACKLOG,
            T.WHOLE_BACKLOG_DESC,
            T.BACKLOG_SEQ,
            T.PROCESS_CODE,
            T.PROCESS_DESC,
            T.PROCESS_SEQ,
            T.PROCESS_CODE_C,
            T.PROCESS_DESC_C,
            T.STATION_ID,
            T.STATION_CODE,
            T.STATION_DESC,
            T.STATION_TYPE,
            T.CRAFTITEM_CODE,
            T.CRAFTITEM_DESC
       FROM SLM_ORD_DESIGN_MSC_PL_STI_TC T
      WHERE T.DESGIN_KEY = P_DESIGN_KEY);

  INSERT INTO CRAFT_ORD_DESIGN_STD
    (DESGIN_KEY, CIC, PIC, SIC, DIC, WIC, GIC)
    (SELECT P_DESIGN_KEY_NEW, T.CIC, T.PIC, T.SIC, T.DIC, T.WIC, T.GIC
       FROM SLM_ORD_DESIGN_STD T
      WHERE T.DESGIN_KEY = P_DESIGN_KEY);

  INSERT INTO CRAFT_ORD_DESIGN_STD_CIC
    (DESGIN_KEY,
     CIC,
     USE_CODE,
     USE_DESC,
     SPECL_FL,
     INDEX_SEQ,
     CHEM_CODE,
     CHEM_NAME,
     CHEM_TYPE,
     CHEM_FORMULA,
     ISCHECK,
     ISJUDGE,
     ISQUOTE,
     COMPLEX_TYPE,
     STDMIN_SIGN,
     STDMIN,
     STDMAX_SIGN,
     STDMAX,
     STDTARGET,
     MODEL_CODE,
     MODEL_DESC,
     STDMEMO,
     ELE_CODE,
     ELE_NAME,
     ELE_MIN_SIGN,
     ELE_MIN,
     ELE_MAX_SIGN,
     ELE_MAX,
     SIZE_CODE2,
     SIZE_NAME2,
     SIZE_MIN_SIGN2,
     SIZE_MIN2,
     SIZE_MAX_SIGN2,
     SIZE_MAX2,
     SIZE_CODE,
     SIZE_NAME,
     SIZE_MIN_SIGN,
     SIZE_MIN,
     SIZE_MAX_SIGN,
     SIZE_MAX,
     SPEC_JG,
     SPEC_JG_DESC,
     VALIDFLAG,
     CREATE_NAME,
     CREATE_TIME,
     UPDATE_NAME,
     UPDATE_TIME,
     DELETE_NAME,
     DELETE_TIME,
     REP_CODE,
     REP_NAME,
     REP_MIN_SIGN,
     REP_MIN,
     REP_MAX_SIGN,
     REP_MAX,
     REP_VAL)
    (SELECT P_DESIGN_KEY_NEW,
            T.CIC,
            T.USE_CODE,
            T.USE_DESC,
            T.SPECL_FL,
            T.INDEX_SEQ,
            T.CHEM_CODE,
            T.CHEM_NAME,
            T.CHEM_TYPE,
            T.CHEM_FORMULA,
            T.ISCHECK,
            T.ISJUDGE,
            T.ISQUOTE,
            T.COMPLEX_TYPE,
            T.STDMIN_SIGN,
            T.STDMIN,
            T.STDMAX_SIGN,
            T.STDMAX,
            T.STDTARGET,
            T.MODEL_CODE,
            T.MODEL_DESC,
            T.STDMEMO,
            T.ELE_CODE,
            T.ELE_NAME,
            T.ELE_MIN_SIGN,
            T.ELE_MIN,
            T.ELE_MAX_SIGN,
            T.ELE_MAX,
            T.SIZE_CODE2,
            T.SIZE_NAME2,
            T.SIZE_MIN_SIGN2,
            T.SIZE_MIN2,
            T.SIZE_MAX_SIGN2,
            T.SIZE_MAX2,
            T.SIZE_CODE,
            T.SIZE_NAME,
            T.SIZE_MIN_SIGN,
            T.SIZE_MIN,
            T.SIZE_MAX_SIGN,
            T.SIZE_MAX,
            T.SPEC_JG,
            T.SPEC_JG_DESC,
            T.VALIDFLAG,
            T.CREATE_NAME,
            T.CREATE_TIME,
            T.UPDATE_NAME,
            T.UPDATE_TIME,
            T.DELETE_NAME,
            T.DELETE_TIME,
            T.REP_CODE,
            T.REP_NAME,
            T.REP_MIN_SIGN,
            T.REP_MIN,
            T.REP_MAX_SIGN,
            T.REP_MAX,
            T.REP_VAL
       FROM SLM_ORD_DESIGN_STD_CIC T
      WHERE T.DESGIN_KEY = P_DESIGN_KEY);

  INSERT INTO CRAFT_ORD_DESIGN_STD_DIC
    (DESGIN_KEY,
     DIC,
     USE_CODE,
     USE_DESC,
     SPECL_FL,
     XH,
     PHY_CODE,
     PHY_NAME,
     POSITION_CODE,
     POSITION_DESC,
     STD_DESC,
     LV_CODE,
     LV_DESC,
     GROOVE_POS,
     GROOVE_DIR,
     COVERAGE,
     RATE,
     DESC_RATE,
     DESC_VAL,
     GROUP_SEQ,
     MEMO,
     MIN_D,
     MAX_D,
     MIN_H,
     MAX_H)
    (SELECT P_DESIGN_KEY_NEW,
            T.DIC,
            T.USE_CODE,
            T.USE_DESC,
            T.SPECL_FL,
            T.XH,
            T.PHY_CODE,
            T.PHY_NAME,
            T.POSITION_CODE,
            T.POSITION_DESC,
            T.STD_DESC,
            T.LV_CODE,
            T.LV_DESC,
            T.GROOVE_POS,
            T.GROOVE_DIR,
            T.COVERAGE,
            T.RATE,
            T.DESC_RATE,
            T.DESC_VAL,
            T.GROUP_SEQ,
            T.MEMO,
            T.MIN_D,
            T.MAX_D,
            T.MIN_H,
            T.MAX_H
       FROM SLM_ORD_DESIGN_STD_DIC T
      WHERE T.DESGIN_KEY = P_DESIGN_KEY);

  INSERT INTO CRAFT_ORD_DESIGN_STD_GIC
    (DESGIN_KEY,
     GIC,
     USE_CODE,
     USE_DESC,
     SPECL_FL,
     XH,
     PROCESS_CDOE,
     PROCESS_DESC,
     PROCESS_CDOE_C,
     PROCESS_DESC_C,
     STATION_CODE,
     STATION_DESC,
     VALUE_TEXT,
     VALUE_NUM,
     VALUE_MEMO,
     GROUP_SEQ,
     MEMO)
    (SELECT P_DESIGN_KEY_NEW,
            T.GIC,
            T.USE_CODE,
            T.USE_DESC,
            T.SPECL_FL,
            T.XH,
            T.PROCESS_CDOE,
            T.PROCESS_DESC,
            T.PROCESS_CDOE_C,
            T.PROCESS_DESC_C,
            T.STATION_CODE,
            T.STATION_DESC,
            T.VALUE_TEXT,
            T.VALUE_NUM,
            T.VALUE_MEMO,
            T.GROUP_SEQ,
            T.MEMO
       FROM SLM_ORD_DESIGN_STD_GIC T
      WHERE T.DESGIN_KEY = P_DESIGN_KEY);

  INSERT INTO CRAFT_ORD_DESIGN_STD_PIC
    (DESGIN_KEY,
     PIC,
     USE_CODE,
     USE_DESC,
     SPECL_FL,
     INDEX_SEQ,
     PHY_CODE_MAX,
     PHY_NAME_MAX,
     PHY_CODE_MIN,
     PHY_NAME_MIN,
     PHY_CODE,
     PHY_NAME,
     ITEM_CODE_F,
     ITEM_NAME_F,
     ITEM_CODE_W,
     ITEM_NAME_W,
     ITEM_CODE_S,
     ITEM_NAME_S,
     GROUP_SEQ,
     ISCHECK,
     ISQUOTE,
     RESULT_COUNT,
     ISJUDGE,
     PHY_TYPE,
     PHY_FORMULA,
     STDMIN_SIGN,
     STDMIN,
     STDMAX_SIGN,
     STDMAX,
     JUDGE_BASIS,
     DELIVERYSTATE,
     MODEL_CODE,
     MODEL_DESC,
     STDMEMO,
     SIZE_CODE,
     SIZE_NAME,
     SIZE_MIN_SIGN,
     SIZE_MIN,
     SIZE_MAX_SIGN,
     SIZE_MAX,
     SIZE_CODE2,
     SIZE_NAME2,
     SIZE_MIN_SIGN2,
     SIZE_MIN2,
     SIZE_MAX_SIGN2,
     SIZE_MAX2,
     SPEC_JG,
     SPEC_JG_DESC,
     ADDCONDITION,
     ADDSTDCON_CODE,
     ADDSTD_MIN_SIGN,
     ADDSTD_MIN,
     ADDSTD_MAX_SIGN,
     ADDSTD_MAX,
     ADDPERCENT,
     STDMIN_SIGN2,
     STDMIN2,
     STDMAX_SIGN2,
     STDMAX2,
     STD_CHOOSE)
    (SELECT P_DESIGN_KEY_NEW,
            T.PIC,
            T.USE_CODE,
            T.USE_DESC,
            T.SPECL_FL,
            T.INDEX_SEQ,
            T.PHY_CODE_MAX,
            T.PHY_NAME_MAX,
            T.PHY_CODE_MIN,
            T.PHY_NAME_MIN,
            T.PHY_CODE,
            T.PHY_NAME,
            T.ITEM_CODE_F,
            T.ITEM_NAME_F,
            T.ITEM_CODE_W,
            T.ITEM_NAME_W,
            T.ITEM_CODE_S,
            T.ITEM_NAME_S,
            T.GROUP_SEQ,
            T.ISCHECK,
            T.ISQUOTE,
            T.RESULT_COUNT,
            T.ISJUDGE,
            T.PHY_TYPE,
            T.PHY_FORMULA,
            T.STDMIN_SIGN,
            T.STDMIN,
            T.STDMAX_SIGN,
            T.STDMAX,
            T.JUDGE_BASIS,
            T.DELIVERYSTATE,
            T.MODEL_CODE,
            T.MODEL_DESC,
            T.STDMEMO,
            T.SIZE_CODE,
            T.SIZE_NAME,
            T.SIZE_MIN_SIGN,
            T.SIZE_MIN,
            T.SIZE_MAX_SIGN,
            T.SIZE_MAX,
            T.SIZE_CODE2,
            T.SIZE_NAME2,
            T.SIZE_MIN_SIGN2,
            T.SIZE_MIN2,
            T.SIZE_MAX_SIGN2,
            T.SIZE_MAX2,
            T.SPEC_JG,
            T.SPEC_JG_DESC,
            T.ADDCONDITION,
            T.ADDSTDCON_CODE,
            T.ADDSTD_MIN_SIGN,
            T.ADDSTD_MIN,
            T.ADDSTD_MAX_SIGN,
            T.ADDSTD_MAX,
            T.ADDPERCENT,
            T.STDMIN_SIGN2,
            T.STDMIN2,
            T.STDMAX_SIGN2,
            T.STDMAX2,
            T.STD_CHOOSE
       FROM SLM_ORD_DESIGN_STD_PIC T
      WHERE T.DESGIN_KEY = P_DESIGN_KEY);

  INSERT INTO CRAFT_ORD_DESIGN_STD_PIC_SMP
    (DESGIN_KEY,
     PIC,
     SIC,
     PHY_CODE_MIN,
     PHY_NAME_MIN,
     STD_CODE,
     STD_NAME,
     LENGTH,
     DESC_LENGTH,
     RATE,
     DESC_RATE,
     DESC_COUNT,
     POSITION,
     DESC_POSITION,
     SAMPLE_COUNT,
     MEMO)
    (SELECT P_DESIGN_KEY_NEW,
            T.PIC,
            T.SIC,
            T.PHY_CODE_MIN,
            T.PHY_NAME_MIN,
            T.STD_CODE,
            T.STD_NAME,
            T.LENGTH,
            T.DESC_LENGTH,
            T.RATE,
            T.DESC_RATE,
            T.DESC_COUNT,
            T.POSITION,
            T.DESC_POSITION,
            T.SAMPLE_COUNT,
            T.MEMO
       FROM SLM_ORD_DESIGN_STD_PIC_SMP T
      WHERE T.DESGIN_KEY = P_DESIGN_KEY);

  INSERT INTO CRAFT_ORD_DESIGN_STD_SIC
    (DESGIN_KEY,
     SIC,
     USE_CODE,
     USE_DESC,
     SPECL_FL,
     INDEX_SEQ,
     BIAS_CODE,
     BIAS_NAME,
     LV,
     BIAS_CODE_Z,
     BIAS_NAME_Z,
     ZMIN_SIGN,
     ZMIN,
     ZMAX_SIGN,
     ZMAX,
     BIAS_CODE_C,
     BIAS_NAME_C,
     CMIN_SIGN,
     CMIN,
     CMAX_SIGN,
     CMAX,
     BIAS_CODE_S,
     BIAS_NAME_S,
     SMIN_SIGN,
     SMIN,
     SMAX_SIGN,
     SMAX,
     ISCHECK,
     STD_MIN_VAL,
     STD_MAX_VAL,
     STD_MIN_IN,
     STD_MAX_IN,
     STD_MIN_PERCENT,
     STD_MAX_PERCENT,
     STD_MIN_FORMULA,
     STD_MAX_FORMULA,
     STD_MIN_FORMULA_V,
     STD_MAX_FORMULA_V,
     STDMEMO)
    (SELECT P_DESIGN_KEY_NEW,
            T.SIC,
            T.USE_CODE,
            T.USE_DESC,
            T.SPECL_FL,
            T.INDEX_SEQ,
            T.BIAS_CODE,
            T.BIAS_NAME,
            T.LV,
            T.BIAS_CODE_Z,
            T.BIAS_NAME_Z,
            T.ZMIN_SIGN,
            T.ZMIN,
            T.ZMAX_SIGN,
            T.ZMAX,
            T.BIAS_CODE_C,
            T.BIAS_NAME_C,
            T.CMIN_SIGN,
            T.CMIN,
            T.CMAX_SIGN,
            T.CMAX,
            T.BIAS_CODE_S,
            T.BIAS_NAME_S,
            T.SMIN_SIGN,
            T.SMIN,
            T.SMAX_SIGN,
            T.SMAX,
            T.ISCHECK,
            T.STD_MIN_VAL,
            T.STD_MAX_VAL,
            T.STD_MIN_IN,
            T.STD_MAX_IN,
            T.STD_MIN_PERCENT,
            T.STD_MAX_PERCENT,
            T.STD_MIN_FORMULA,
            T.STD_MAX_FORMULA,
            T.STD_MIN_FORMULA_V,
            T.STD_MAX_FORMULA_V,
            T.STDMEMO
       FROM SLM_ORD_DESIGN_STD_SIC T
      WHERE T.DESGIN_KEY = P_DESIGN_KEY);

  INSERT INTO CRAFT_ORD_DESIGN_STD_WIC
    (DESGIN_KEY,
     WIC,
     USE_CODE,
     USE_DESC,
     SPECL_FL,
     INDEX_SEQ,
     PRESSURE_Y,
     PRESSURE,
     FORMULA,
     SAVE_TIME,
     GET_MAXVALUE,
     GET_MINVALUE,
     RATIO_STD,
     RATIO_REPLACE,
     MAX_PRESS)
    (SELECT P_DESIGN_KEY_NEW,
            T.WIC,
            T.USE_CODE,
            T.USE_DESC,
            T.SPECL_FL,
            T.INDEX_SEQ,
            T.PRESSURE_Y,
            T.PRESSURE,
            T.FORMULA,
            T.SAVE_TIME,
            T.GET_MAXVALUE,
            T.GET_MINVALUE,
            T.RATIO_STD,
            T.RATIO_REPLACE,
            T.MAX_PRESS
       FROM SLM_ORD_DESIGN_STD_WIC T
      WHERE T.DESGIN_KEY = P_DESIGN_KEY);

  INSERT INTO CRAFT_ORD_DESIGN_STS_PL_PC
    (DESGIN_KEY,
     ORD_LN_PK,
     ORD_LN_DLY_PK,
     MSC_PLINE,
     WHOLE_BACKLOG,
     WHOLE_BACKLOG_DESC,
     PRDCYC_MEET,
     VALIDFLAG,
     CREATE_NAME,
     CREATE_TIME,
     UPDATE_NAME,
     UPDATE_TIME,
     DELETE_NAME,
     DELETE_TIME)
    (SELECT P_DESIGN_KEY_NEW,
            T.ORD_LN_PK,
            T.ORD_LN_DLY_PK,
            T.MSC_PLINE,
            T.WHOLE_BACKLOG,
            T.WHOLE_BACKLOG_DESC,
            T.PRDCYC_MEET,
            T.VALIDFLAG,
            T.CREATE_NAME,
            T.CREATE_TIME,
            T.UPDATE_NAME,
            T.UPDATE_TIME,
            T.DELETE_NAME,
            T.DELETE_TIME
       FROM SLM_ORD_DESIGN_STS_PL_PC T
      WHERE T.DESGIN_KEY = P_DESIGN_KEY);

  INSERT INTO CRAFT_ORD_DESIGN_STS_PL_PC_LST
    (DESGIN_KEY,
     ORD_LN_PK,
     ORD_LN_DLY_PK,
     MSC_PLINE,
     WHOLE_BACKLOG,
     WHOLE_BACKLOG_DESC,
     PROCESS_CDOE,
     PROCESS_DESC,
     PRDCYC_MEET,
     VALIDFLAG,
     CREATE_NAME,
     CREATE_TIME,
     UPDATE_NAME,
     UPDATE_TIME,
     DELETE_NAME,
     DELETE_TIME)
    (SELECT P_DESIGN_KEY_NEW,
            T.ORD_LN_PK,
            T.ORD_LN_DLY_PK,
            T.MSC_PLINE,
            T.WHOLE_BACKLOG,
            T.WHOLE_BACKLOG_DESC,
            T.PROCESS_CDOE,
            T.PROCESS_DESC,
            T.PRDCYC_MEET,
            T.VALIDFLAG,
            T.CREATE_NAME,
            T.CREATE_TIME,
            T.UPDATE_NAME,
            T.UPDATE_TIME,
            T.DELETE_NAME,
            T.DELETE_TIME
       FROM SLM_ORD_DESIGN_STS_PL_PC_LST T
      WHERE T.DESGIN_KEY = P_DESIGN_KEY);

  INSERT INTO CRAFT_ORD_DESIGN_STS_TKLG
    (DESGIN_KEY,
     ORD_LN_PK,
     DESIGN_STS,
     PRDCYC_MEET,
     VALIDFLAG,
     CREATE_NAME,
     CREATE_TIME,
     UPDATE_NAME,
     UPDATE_TIME,
     DELETE_NAME,
     DELETE_TIME)
    (SELECT P_DESIGN_KEY_NEW,
            T.ORD_LN_PK,
            T.DESIGN_STS,
            T.PRDCYC_MEET,
            T.VALIDFLAG,
            T.CREATE_NAME,
            T.CREATE_TIME,
            T.UPDATE_NAME,
            T.UPDATE_TIME,
            T.DELETE_NAME,
            T.DELETE_TIME
       FROM SLM_ORD_DESIGN_STS_TKLG T
      WHERE T.DESGIN_KEY = P_DESIGN_KEY);

  INSERT INTO CRAFT_ORD_LINE_BOM
    (DESGIN_KEY, BOM)
    (SELECT T.DESGIN_KEY, T.BOM
       FROM SLM_ORD_LINE_BOM T
      WHERE T.DESGIN_KEY = P_DESIGN_KEY);

  INSERT INTO CRAFT_ORD_DESIGN_STS_TKLG_LST
    (DESGIN_KEY,
     ORD_LN_PK,
     SEQ_INDEX,
     LST_ITEM,
     DESIGN_STS,
     DESIGN_STS_RS,
     DESIGN_STS_DESC,
     PSC,
     MSC,
     USE_CODE,
     FINAL_USER,
     GRADECODE,
     DESIGN_OBJ_KEY,
     UNIT_CODE,
     UNIT_DESC,
     VALIDFLAG,
     CREATE_NAME,
     CREATE_TIME,
     UPDATE_NAME,
     UPDATE_TIME,
     DELETE_NAME,
     DELETE_TIME)
    (SELECT P_DESIGN_KEY_NEW,
            T.ORD_LN_PK,
            T.SEQ_INDEX,
            T.LST_ITEM,
            T.DESIGN_STS,
            T.DESIGN_STS_RS,
            T.DESIGN_STS_DESC,
            T.PSC,
            T.MSC,
            T.USE_CODE,
            T.FINAL_USER,
            T.GRADECODE,
            T.DESIGN_OBJ_KEY,
            T.UNIT_CODE,
            T.UNIT_DESC,
            T.VALIDFLAG,
            T.CREATE_NAME,
            T.CREATE_TIME,
            T.UPDATE_NAME,
            T.UPDATE_TIME,
            T.DELETE_NAME,
            T.DELETE_TIME
       FROM SLM_ORD_DESIGN_STS_TKLG_LST T
      WHERE T.DESGIN_KEY = P_DESIGN_KEY);
  DELETE FROM CRAFT_ORD_DESIGN_STS_TKLG_LST
   WHERE DESGIN_KEY = P_DESIGN_KEY_NEW
     AND SEQ_INDEX IN ('008', '009', '018', '019', '020', '022');

  ----------------
  --复制产品的备料
  ----------------
  FOR V_ROW IN (SELECT *
                  FROM SLM_ORD_DESIGN_MSC_BL
                 WHERE DESGIN_KEY = P_DESIGN_KEY) LOOP
    P_DESIGN_KEY_BL := SYS_GUID();
  
    INSERT INTO CRAFT_ORD_DESIGN_MSC_BL
      (DESGIN_KEY, GROUP_NUM, PSC_BL, DESGIN_KEY_BL)
    VALUES
      (P_DESIGN_KEY_NEW, V_ROW.GROUP_NUM, V_ROW.PSC_BL, P_DESIGN_KEY_BL);
  
    INSERT INTO CRAFT_ORD_DESIGN_MSC
      (DESGIN_KEY,
       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,
       PRD_LEN,
       LOSS_RATE,
       VALIDFLAG,
       CREATE_NAME,
       CREATE_TIME,
       UPDATE_NAME,
       UPDATE_TIME,
       DELETE_NAME,
       DELETE_TIME,
       ORD_LN_PK_OLD)
      (SELECT P_DESIGN_KEY_BL,
              T.ORD_PK,
              T.ORD_LN_PK,
              T.ORDER_SEQ,
              T.CUST_ALPHA_NO,
              T.PSC,
              T.PSC_DESC,
              T.MSC,
              T.MSC_DESC,
              T.MSC_STYLE,
              T.USE_CODE,
              T.USE_DESC,
              T.PRD_CLS,
              T.PRODUCCODE,
              T.PRODUCNAME,
              T.STD_CODE,
              T.STD_NAME,
              T.STEELCODE,
              T.STEELNAME,
              T.STD_STYLE,
              T.STD_STYLE_DESC,
              T.ORDER_SPEC_CODE,
              T.ORDER_SPEC_DESC,
              T.SPEC_CODE,
              T.SPEC_NAME,
              T.DIMATER,
              T.HEIGHT,
              T.MODEL_CODE,
              T.MODEL_DESC,
              T.LEN_NO,
              T.LEN_DESC,
              T.LEN_UNIT,
              T.LEN_MIN,
              T.LEN_MAX,
              T.SHRT_LEN_RATO,
              T.SHORTEST,
              T.LONG_LEN_RATO,
              T.LONGEST,
              T.SHRT_STOVE,
              T.AVG_LEN_MIN,
              T.DIFRNC_LEN_MAX,
              T.ENDLEN_SPECSTD,
              T.SIGL_LEN,
              T.ORDER_UNIT,
              T.ORDER_QTY,
              T.ORD_ENSU_TOTL_LEN,
              T.PRDCT_WGT,
              T.DELVRY_RANGE_TPE,
              T.DELVRY_RANGE_MIN,
              T.DELVRY_RANGE_MAX,
              T.FINAL_USER,
              T.FINAL_USER_DESC,
              T.OUTS_BILLET_FL,
              T.OUTS_STL_PIPE_FL,
              T.ASSEL_FL,
              T.PRODUCER_FL,
              T.PRDCR_NO,
              T.PRDCR_DESC,
              T.MPS_FL,
              T.MPS_NO,
              T.MPS_DESC,
              T.DELVRY_BDATE,
              T.DELVRY_EDATE,
              T.DELVRY_DESC,
              T.TRANS_DESC,
              T.ADD_ASK_NO,
              T.ORDER_ADD_DESC,
              T.ORDER_SPECIAL_FL,
              T.ORDER_SPECIAL_HEAD,
              T.ORDER_SPECIAL_PATH,
              T.ORDER_SPECIAL_DESC,
              T.ZBS,
              T.ORDER_PRICE,
              T.TRANS_PRICE,
              T.TEST_ID,
              T.TEST_PRICE,
              T.OUT_PRICE,
              T.BALNCE_PRICE,
              T.BE_ORDER_LN_STATUS,
              T.BE_OBJ_STS_OP,
              T.ORDER_LN_STATUS,
              T.OBJ_STS_OP,
              T.MEMO,
              T.PRD_LEN,
              T.LOSS_RATE,
              T.VALIDFLAG,
              T.CREATE_NAME,
              T.CREATE_TIME,
              T.UPDATE_NAME,
              T.UPDATE_TIME,
              T.DELETE_NAME,
              T.DELETE_TIME,
              T.ORD_LN_PK_OLD
         FROM SLM_ORD_DESIGN_MSC T
        WHERE T.DESGIN_KEY = V_ROW.DESGIN_KEY_BL);
  
    INSERT INTO CRAFT_ORD_DESIGN_MSC_BILT
      (DESGIN_KEY, MSC_PLINE, SPEC_CODE, B_SPEC_CODE, B_SPEC_NAME)
      (SELECT P_DESIGN_KEY_BL,
              T.MSC_PLINE,
              T.SPEC_CODE,
              T.B_SPEC_CODE,
              T.B_SPEC_NAME
         FROM SLM_ORD_DESIGN_MSC_BILT T
        WHERE T.DESGIN_KEY = V_ROW.DESGIN_KEY_BL);
  
    INSERT INTO CRAFT_ORD_DESIGN_MSC_BILT_C
      (DESGIN_KEY,
       MSC_PLINE,
       SPEC_CODE,
       B_SPEC_CODE,
       C_SPEC_CODE,
       C_SPEC_NAME,
       SPEC_CODE_S)
      (SELECT P_DESIGN_KEY_BL,
              T.MSC_PLINE,
              T.SPEC_CODE,
              T.B_SPEC_CODE,
              T.C_SPEC_CODE,
              T.C_SPEC_NAME,
              T.SPEC_CODE_S
         FROM SLM_ORD_DESIGN_MSC_BILT_C T
        WHERE T.DESGIN_KEY = V_ROW.DESGIN_KEY_BL);
  
    INSERT INTO CRAFT_ORD_DESIGN_MSC_BILT_C_PL
      (DESGIN_KEY, MSC_PLINE, C_SPEC_CODE, PLINE_CODE, PLINE_NAME)
      (SELECT P_DESIGN_KEY_BL,
              T.MSC_PLINE,
              T.C_SPEC_CODE,
              T.PLINE_CODE,
              T.PLINE_NAME
         FROM SLM_ORD_DESIGN_MSC_BILT_C_PL T
        WHERE T.DESGIN_KEY = V_ROW.DESGIN_KEY_BL);
  
    INSERT INTO CRAFT_ORD_DESIGN_MSC_BILT_PL
      (DESGIN_KEY, MSC_PLINE, B_SPEC_CODE, PLINE_CODE, PLINE_NAME)
      (SELECT P_DESIGN_KEY_BL,
              T.MSC_PLINE,
              T.B_SPEC_CODE,
              T.PLINE_CODE,
              T.PLINE_NAME
         FROM SLM_ORD_DESIGN_MSC_BILT_PL T
        WHERE T.DESGIN_KEY = V_ROW.DESGIN_KEY_BL);
  
    INSERT INTO CRAFT_ORD_DESIGN_MSC_GZ_GG
      (DESGIN_KEY,
       MSC_PLINE,
       GRADECODE,
       GRADENAME,
       SPEC_CODE,
       SPEC_NAME,
       DIMATER,
       HEIGHT)
      (SELECT P_DESIGN_KEY_BL,
              T.MSC_PLINE,
              T.GRADECODE,
              T.GRADENAME,
              T.SPEC_CODE,
              T.SPEC_NAME,
              T.DIMATER,
              T.HEIGHT
         FROM SLM_ORD_DESIGN_MSC_GZ_GG T
        WHERE T.DESGIN_KEY = V_ROW.DESGIN_KEY_BL);
  
    INSERT INTO CRAFT_ORD_DESIGN_MSC_GZ_GG_PL
      (DESGIN_KEY,
       MSC_PLINE,
       SPEC_CODE,
       PLINE_CODE,
       PLINE_NAME,
       PRD_LEN,
       LOSS_RATE,
       IS_OUTPUT)
      (SELECT P_DESIGN_KEY_BL,
              T.MSC_PLINE,
              T.SPEC_CODE,
              T.PLINE_CODE,
              T.PLINE_NAME,
              T.PRD_LEN,
              T.LOSS_RATE,
              T.IS_OUTPUT
         FROM SLM_ORD_DESIGN_MSC_GZ_GG_PL T
        WHERE T.DESGIN_KEY = V_ROW.DESGIN_KEY_BL);
  
    INSERT INTO CRAFT_ORD_DESIGN_MSC_JG
      (DESGIN_KEY,
       CODE_JG,
       DEMAND_DETECTION,
       DEMAND_BONDERIZING,
       DEMAND_COPPER,
       DEMAND_BLAST,
       PRODUCCODE,
       PRODUCNAME,
       STEELCODE,
       STEELNAME,
       MIN_H,
       MAX_H,
       MIN_D,
       MAX_D,
       SET_JG,
       CUST_ALPHA_NO,
       KEY_JG,
       ORDER_SPECIAL_DESC)
      (SELECT P_DESIGN_KEY_BL,
              T.CODE_JG,
              T.DEMAND_DETECTION,
              T.DEMAND_BONDERIZING,
              T.DEMAND_COPPER,
              T.DEMAND_BLAST,
              T.PRODUCCODE,
              T.PRODUCNAME,
              T.STEELCODE,
              T.STEELNAME,
              T.MIN_H,
              T.MAX_H,
              T.MIN_D,
              T.MAX_D,
              T.SET_JG,
              T.CUST_ALPHA_NO,
              T.KEY_JG,
              T.ORDER_SPECIAL_DESC
         FROM SLM_ORD_DESIGN_MSC_JG T
        WHERE T.DESGIN_KEY = V_ROW.DESGIN_KEY_BL);
  
    INSERT INTO CRAFT_ORD_DESIGN_MSC_JG_PL
      (DESGIN_KEY,
       CODE_JG,
       MSC_PLINE,
       WHOLE_BACKLOG,
       WHOLE_BACKLOG_DESC,
       SET_FL,
       WARN_DESC,
       ORD_LN_PK)
      (SELECT P_DESIGN_KEY_BL,
              T.CODE_JG,
              T.MSC_PLINE,
              T.WHOLE_BACKLOG,
              T.WHOLE_BACKLOG_DESC,
              T.SET_FL,
              T.WARN_DESC,
              T.ORD_LN_PK
         FROM SLM_ORD_DESIGN_MSC_JG_PL T
        WHERE T.DESGIN_KEY = V_ROW.DESGIN_KEY_BL);
  
    INSERT INTO CRAFT_ORD_DESIGN_MSC_JG_PL_STI
      (DESGIN_KEY,
       CODE_JG,
       MSC_PLINE,
       WHOLE_BACKLOG,
       WHOLE_BACKLOG_DESC,
       BACKLOG_SEQ,
       PROCESS_CODE,
       PROCESS_DESC,
       PROCESS_SEQ,
       PROCESS_CODE_C,
       PROCESS_DESC_C,
       STATION_ID,
       STATION_CODE,
       STATION_DESC,
       STATION_TYPE)
      (SELECT P_DESIGN_KEY_BL,
              T.CODE_JG,
              T.MSC_PLINE,
              T.WHOLE_BACKLOG,
              T.WHOLE_BACKLOG_DESC,
              T.BACKLOG_SEQ,
              T.PROCESS_CODE,
              T.PROCESS_DESC,
              T.PROCESS_SEQ,
              T.PROCESS_CODE_C,
              T.PROCESS_DESC_C,
              T.STATION_ID,
              T.STATION_CODE,
              T.STATION_DESC,
              T.STATION_TYPE
         FROM SLM_ORD_DESIGN_MSC_JG_PL_STI T
        WHERE T.DESGIN_KEY = V_ROW.DESGIN_KEY_BL);
  
    INSERT INTO CRAFT_ORD_DESIGN_MSC_PL
      (DESGIN_KEY,
       MSC_PLINE,
       WHOLE_BACKLOG,
       WHOLE_BACKLOG_DESC,
       SET_FL,
       WARN_DESC,
       ORD_LN_PK)
      (SELECT P_DESIGN_KEY_BL,
              T.MSC_PLINE,
              T.WHOLE_BACKLOG,
              T.WHOLE_BACKLOG_DESC,
              T.SET_FL,
              T.WARN_DESC,
              T.ORD_LN_PK
         FROM SLM_ORD_DESIGN_MSC_PL T
        WHERE T.DESGIN_KEY = V_ROW.DESGIN_KEY_BL);
  
    INSERT INTO CRAFT_ORD_DESIGN_MSC_PL_GX_PRL
      (DESGIN_KEY,
       MSC_PLINE,
       BACKLOG_SEQ,
       PROCESS_CODE,
       PLINE_CODE,
       PLINE_NAME,
       WELL_CODE,
       WELL_NAME,
       WARN_FL,
       WARN_DESC,
       VALIDFLAG,
       IDENT_FLAG)
      (SELECT P_DESIGN_KEY_BL,
              T.MSC_PLINE,
              T.BACKLOG_SEQ,
              T.PROCESS_CODE,
              T.PLINE_CODE,
              T.PLINE_NAME,
              T.WELL_CODE,
              T.WELL_NAME,
              T.WARN_FL,
              T.WARN_DESC,
              T.VALIDFLAG,
              T.IDENT_FLAG
         FROM SLM_ORD_DESIGN_MSC_PL_GX_PRL T
        WHERE T.DESGIN_KEY = V_ROW.DESGIN_KEY_BL);
  
    INSERT INTO CRAFT_ORD_DESIGN_MSC_PL_GZ
      (DESGIN_KEY,
       MSC_PLINE,
       WHOLE_BACKLOG,
       WHOLE_BACKLOG_DESC,
       GRADECODE,
       GRADENAME,
       ASSORTMENT_CODE,
       ASSORTMENT_NAME)
      (SELECT P_DESIGN_KEY_BL,
              T.MSC_PLINE,
              T.WHOLE_BACKLOG,
              T.WHOLE_BACKLOG_DESC,
              T.GRADECODE,
              T.GRADENAME,
              T.ASSORTMENT_CODE,
              T.ASSORTMENT_NAME
         FROM SLM_ORD_DESIGN_MSC_PL_GZ T
        WHERE T.DESGIN_KEY = V_ROW.DESGIN_KEY_BL);
  
    INSERT INTO CRAFT_ORD_DESIGN_MSC_PL_PC
      (DESGIN_KEY,
       ORD_LN_DLY_PK,
       MSC_PLINE,
       DELVRY_EDATE,
       DELVRY_QTY,
       ORDER_UNIT,
       RECEIV_NO,
       RECEIV_NM,
       RCMD_DELVRY_EDATE,
       PRD_CYC,
       PRD_CYC_BTCH,
       N_MATERIAL_FL,
       CYC_EDIT,
       CREATE_NAME,
       CREATE_TIME,
       UPDATE_NAME,
       UPDATE_TIME)
      (SELECT P_DESIGN_KEY_BL,
              T.ORD_LN_DLY_PK,
              T.MSC_PLINE,
              T.DELVRY_EDATE,
              T.DELVRY_QTY,
              T.ORDER_UNIT,
              T.RECEIV_NO,
              T.RECEIV_NM,
              T.RCMD_DELVRY_EDATE,
              T.PRD_CYC,
              T.PRD_CYC_BTCH,
              T.N_MATERIAL_FL,
              T.CYC_EDIT,
              T.CREATE_NAME,
              T.CREATE_TIME,
              T.UPDATE_NAME,
              T.UPDATE_TIME
         FROM SLM_ORD_DESIGN_MSC_PL_PC T
        WHERE T.DESGIN_KEY = V_ROW.DESGIN_KEY_BL);
  
    INSERT INTO CRAFT_ORD_DESIGN_MSC_PL_PC_LST
      (DESGIN_KEY,
       ORD_LN_DLY_PK,
       MSC_PLINE,
       BACKLOG_SEQ,
       PROCESS_CODE,
       PROCESS_DESC,
       REVIEW_ASK,
       LST_PRD_DATE,
       PRD_CYC,
       PRD_CYC_BTCH)
      (SELECT P_DESIGN_KEY_BL,
              T.ORD_LN_DLY_PK,
              T.MSC_PLINE,
              T.BACKLOG_SEQ,
              T.PROCESS_CODE,
              T.PROCESS_DESC,
              T.REVIEW_ASK,
              T.LST_PRD_DATE,
              T.PRD_CYC,
              T.PRD_CYC_BTCH
         FROM SLM_ORD_DESIGN_MSC_PL_PC_LST T
        WHERE T.DESGIN_KEY = V_ROW.DESGIN_KEY_BL);
  
    INSERT INTO CRAFT_ORD_DESIGN_MSC_PL_PRC
      (DESGIN_KEY,
       MSC_PLINE,
       WHOLE_BACKLOG,
       WHOLE_BACKLOG_DESC,
       BACKLOG_SEQ,
       PROCESS_CODE,
       PROCESS_DESC,
       PROCESS_SEQ,
       PROCESS_CODE_C,
       PROCESS_DESC_C,
       MINUTE_PRODUCT,
       MINUTE_PRODUCT_OUT,
       MINUTE_WAITE,
       MINUTE_WAITE_OUT,
       BATCH_WAITE,
       BATCH_WAITE_OUT,
       CIC,
       PIC,
       SIC,
       DIC,
       WIC,
       GIC)
      (SELECT P_DESIGN_KEY_BL,
              T.MSC_PLINE,
              T.WHOLE_BACKLOG,
              T.WHOLE_BACKLOG_DESC,
              T.BACKLOG_SEQ,
              T.PROCESS_CODE,
              T.PROCESS_DESC,
              T.PROCESS_SEQ,
              T.PROCESS_CODE_C,
              T.PROCESS_DESC_C,
              T.MINUTE_PRODUCT,
              T.MINUTE_PRODUCT_OUT,
              T.MINUTE_WAITE,
              T.MINUTE_WAITE_OUT,
              T.BATCH_WAITE,
              T.BATCH_WAITE_OUT,
              T.CIC,
              T.PIC,
              T.SIC,
              T.DIC,
              T.WIC,
              T.GIC
         FROM SLM_ORD_DESIGN_MSC_PL_PRC T
        WHERE T.DESGIN_KEY = V_ROW.DESGIN_KEY_BL);
  
    INSERT INTO CRAFT_ORD_DESIGN_MSC_PL_STI
      (DESGIN_KEY,
       MSC_PLINE,
       WHOLE_BACKLOG,
       WHOLE_BACKLOG_DESC,
       BACKLOG_SEQ,
       PROCESS_CODE,
       PROCESS_DESC,
       PROCESS_SEQ,
       PROCESS_CODE_C,
       PROCESS_DESC_C,
       STATION_ID,
       STATION_CODE,
       STATION_DESC,
       STATION_TYPE,
       CRAFTITEM_CODE,
       CRAFTITEM_DESC)
      (SELECT P_DESIGN_KEY_BL,
              T.MSC_PLINE,
              T.WHOLE_BACKLOG,
              T.WHOLE_BACKLOG_DESC,
              T.BACKLOG_SEQ,
              T.PROCESS_CODE,
              T.PROCESS_DESC,
              T.PROCESS_SEQ,
              T.PROCESS_CODE_C,
              T.PROCESS_DESC_C,
              T.STATION_ID,
              T.STATION_CODE,
              T.STATION_DESC,
              T.STATION_TYPE,
              T.CRAFTITEM_CODE,
              T.CRAFTITEM_DESC
         FROM SLM_ORD_DESIGN_MSC_PL_STI T
        WHERE T.DESGIN_KEY = V_ROW.DESGIN_KEY_BL);
  
    INSERT INTO CRAFT_ORD_DESIGN_MSC_PL_STI_TC
      (DESGIN_KEY,
       ORD_PK,
       ORD_LN_PK,
       MSC_PLINE,
       WHOLE_BACKLOG,
       WHOLE_BACKLOG_DESC,
       BACKLOG_SEQ,
       PROCESS_CODE,
       PROCESS_DESC,
       PROCESS_SEQ,
       PROCESS_CODE_C,
       PROCESS_DESC_C,
       STATION_ID,
       STATION_CODE,
       STATION_DESC,
       STATION_TYPE,
       CRAFTITEM_CODE,
       CRAFTITEM_DESC)
      (SELECT P_DESIGN_KEY_BL,
              T.ORD_PK,
              T.ORD_LN_PK,
              T.MSC_PLINE,
              T.WHOLE_BACKLOG,
              T.WHOLE_BACKLOG_DESC,
              T.BACKLOG_SEQ,
              T.PROCESS_CODE,
              T.PROCESS_DESC,
              T.PROCESS_SEQ,
              T.PROCESS_CODE_C,
              T.PROCESS_DESC_C,
              T.STATION_ID,
              T.STATION_CODE,
              T.STATION_DESC,
              T.STATION_TYPE,
              T.CRAFTITEM_CODE,
              T.CRAFTITEM_DESC
         FROM SLM_ORD_DESIGN_MSC_PL_STI_TC T
        WHERE T.DESGIN_KEY = V_ROW.DESGIN_KEY_BL);
  
    INSERT INTO CRAFT_ORD_DESIGN_STD
      (DESGIN_KEY, CIC, PIC, SIC, DIC, WIC, GIC)
      (SELECT P_DESIGN_KEY_BL, T.CIC, T.PIC, T.SIC, T.DIC, T.WIC, T.GIC
         FROM SLM_ORD_DESIGN_STD T
        WHERE T.DESGIN_KEY = V_ROW.DESGIN_KEY_BL);
  
    INSERT INTO CRAFT_ORD_DESIGN_STD_CIC
      (DESGIN_KEY,
       CIC,
       USE_CODE,
       USE_DESC,
       SPECL_FL,
       INDEX_SEQ,
       CHEM_CODE,
       CHEM_NAME,
       CHEM_TYPE,
       CHEM_FORMULA,
       ISCHECK,
       ISJUDGE,
       ISQUOTE,
       COMPLEX_TYPE,
       STDMIN_SIGN,
       STDMIN,
       STDMAX_SIGN,
       STDMAX,
       STDTARGET,
       MODEL_CODE,
       MODEL_DESC,
       STDMEMO,
       ELE_CODE,
       ELE_NAME,
       ELE_MIN_SIGN,
       ELE_MIN,
       ELE_MAX_SIGN,
       ELE_MAX,
       SIZE_CODE2,
       SIZE_NAME2,
       SIZE_MIN_SIGN2,
       SIZE_MIN2,
       SIZE_MAX_SIGN2,
       SIZE_MAX2,
       SIZE_CODE,
       SIZE_NAME,
       SIZE_MIN_SIGN,
       SIZE_MIN,
       SIZE_MAX_SIGN,
       SIZE_MAX,
       SPEC_JG,
       SPEC_JG_DESC,
       VALIDFLAG,
       CREATE_NAME,
       CREATE_TIME,
       UPDATE_NAME,
       UPDATE_TIME,
       DELETE_NAME,
       DELETE_TIME,
       REP_CODE,
       REP_NAME,
       REP_MIN_SIGN,
       REP_MIN,
       REP_MAX_SIGN,
       REP_MAX,
       REP_VAL)
      (SELECT P_DESIGN_KEY_BL,
              T.CIC,
              T.USE_CODE,
              T.USE_DESC,
              T.SPECL_FL,
              T.INDEX_SEQ,
              T.CHEM_CODE,
              T.CHEM_NAME,
              T.CHEM_TYPE,
              T.CHEM_FORMULA,
              T.ISCHECK,
              T.ISJUDGE,
              T.ISQUOTE,
              T.COMPLEX_TYPE,
              T.STDMIN_SIGN,
              T.STDMIN,
              T.STDMAX_SIGN,
              T.STDMAX,
              T.STDTARGET,
              T.MODEL_CODE,
              T.MODEL_DESC,
              T.STDMEMO,
              T.ELE_CODE,
              T.ELE_NAME,
              T.ELE_MIN_SIGN,
              T.ELE_MIN,
              T.ELE_MAX_SIGN,
              T.ELE_MAX,
              T.SIZE_CODE2,
              T.SIZE_NAME2,
              T.SIZE_MIN_SIGN2,
              T.SIZE_MIN2,
              T.SIZE_MAX_SIGN2,
              T.SIZE_MAX2,
              T.SIZE_CODE,
              T.SIZE_NAME,
              T.SIZE_MIN_SIGN,
              T.SIZE_MIN,
              T.SIZE_MAX_SIGN,
              T.SIZE_MAX,
              T.SPEC_JG,
              T.SPEC_JG_DESC,
              T.VALIDFLAG,
              T.CREATE_NAME,
              T.CREATE_TIME,
              T.UPDATE_NAME,
              T.UPDATE_TIME,
              T.DELETE_NAME,
              T.DELETE_TIME,
              T.REP_CODE,
              T.REP_NAME,
              T.REP_MIN_SIGN,
              T.REP_MIN,
              T.REP_MAX_SIGN,
              T.REP_MAX,
              T.REP_VAL
         FROM SLM_ORD_DESIGN_STD_CIC T
        WHERE T.DESGIN_KEY = V_ROW.DESGIN_KEY_BL);
  
    INSERT INTO CRAFT_ORD_DESIGN_STD_DIC
      (DESGIN_KEY,
       DIC,
       USE_CODE,
       USE_DESC,
       SPECL_FL,
       XH,
       PHY_CODE,
       PHY_NAME,
       POSITION_CODE,
       POSITION_DESC,
       STD_DESC,
       LV_CODE,
       LV_DESC,
       GROOVE_POS,
       GROOVE_DIR,
       COVERAGE,
       RATE,
       DESC_RATE,
       DESC_VAL,
       GROUP_SEQ,
       MEMO,
       MIN_D,
       MAX_D,
       MIN_H,
       MAX_H)
      (SELECT P_DESIGN_KEY_BL,
              T.DIC,
              T.USE_CODE,
              T.USE_DESC,
              T.SPECL_FL,
              T.XH,
              T.PHY_CODE,
              T.PHY_NAME,
              T.POSITION_CODE,
              T.POSITION_DESC,
              T.STD_DESC,
              T.LV_CODE,
              T.LV_DESC,
              T.GROOVE_POS,
              T.GROOVE_DIR,
              T.COVERAGE,
              T.RATE,
              T.DESC_RATE,
              T.DESC_VAL,
              T.GROUP_SEQ,
              T.MEMO,
              T.MIN_D,
              T.MAX_D,
              T.MIN_H,
              T.MAX_H
         FROM SLM_ORD_DESIGN_STD_DIC T
        WHERE T.DESGIN_KEY = V_ROW.DESGIN_KEY_BL);
  
    INSERT INTO CRAFT_ORD_DESIGN_STD_GIC
      (DESGIN_KEY,
       GIC,
       USE_CODE,
       USE_DESC,
       SPECL_FL,
       XH,
       PROCESS_CDOE,
       PROCESS_DESC,
       PROCESS_CDOE_C,
       PROCESS_DESC_C,
       STATION_CODE,
       STATION_DESC,
       VALUE_TEXT,
       VALUE_NUM,
       VALUE_MEMO,
       GROUP_SEQ,
       MEMO)
      (SELECT P_DESIGN_KEY_BL,
              T.GIC,
              T.USE_CODE,
              T.USE_DESC,
              T.SPECL_FL,
              T.XH,
              T.PROCESS_CDOE,
              T.PROCESS_DESC,
              T.PROCESS_CDOE_C,
              T.PROCESS_DESC_C,
              T.STATION_CODE,
              T.STATION_DESC,
              T.VALUE_TEXT,
              T.VALUE_NUM,
              T.VALUE_MEMO,
              T.GROUP_SEQ,
              T.MEMO
         FROM SLM_ORD_DESIGN_STD_GIC T
        WHERE T.DESGIN_KEY = V_ROW.DESGIN_KEY_BL);
  
    INSERT INTO CRAFT_ORD_DESIGN_STD_PIC
      (DESGIN_KEY,
       PIC,
       USE_CODE,
       USE_DESC,
       SPECL_FL,
       INDEX_SEQ,
       PHY_CODE_MAX,
       PHY_NAME_MAX,
       PHY_CODE_MIN,
       PHY_NAME_MIN,
       PHY_CODE,
       PHY_NAME,
       ITEM_CODE_F,
       ITEM_NAME_F,
       ITEM_CODE_W,
       ITEM_NAME_W,
       ITEM_CODE_S,
       ITEM_NAME_S,
       GROUP_SEQ,
       ISCHECK,
       ISQUOTE,
       RESULT_COUNT,
       ISJUDGE,
       PHY_TYPE,
       PHY_FORMULA,
       STDMIN_SIGN,
       STDMIN,
       STDMAX_SIGN,
       STDMAX,
       JUDGE_BASIS,
       DELIVERYSTATE,
       MODEL_CODE,
       MODEL_DESC,
       STDMEMO,
       SIZE_CODE,
       SIZE_NAME,
       SIZE_MIN_SIGN,
       SIZE_MIN,
       SIZE_MAX_SIGN,
       SIZE_MAX,
       SIZE_CODE2,
       SIZE_NAME2,
       SIZE_MIN_SIGN2,
       SIZE_MIN2,
       SIZE_MAX_SIGN2,
       SIZE_MAX2,
       SPEC_JG,
       SPEC_JG_DESC,
       ADDCONDITION,
       ADDSTDCON_CODE,
       ADDSTD_MIN_SIGN,
       ADDSTD_MIN,
       ADDSTD_MAX_SIGN,
       ADDSTD_MAX,
       ADDPERCENT,
       STDMIN_SIGN2,
       STDMIN2,
       STDMAX_SIGN2,
       STDMAX2,
       STD_CHOOSE)
      (SELECT P_DESIGN_KEY_BL,
              T.PIC,
              T.USE_CODE,
              T.USE_DESC,
              T.SPECL_FL,
              T.INDEX_SEQ,
              T.PHY_CODE_MAX,
              T.PHY_NAME_MAX,
              T.PHY_CODE_MIN,
              T.PHY_NAME_MIN,
              T.PHY_CODE,
              T.PHY_NAME,
              T.ITEM_CODE_F,
              T.ITEM_NAME_F,
              T.ITEM_CODE_W,
              T.ITEM_NAME_W,
              T.ITEM_CODE_S,
              T.ITEM_NAME_S,
              T.GROUP_SEQ,
              T.ISCHECK,
              T.ISQUOTE,
              T.RESULT_COUNT,
              T.ISJUDGE,
              T.PHY_TYPE,
              T.PHY_FORMULA,
              T.STDMIN_SIGN,
              T.STDMIN,
              T.STDMAX_SIGN,
              T.STDMAX,
              T.JUDGE_BASIS,
              T.DELIVERYSTATE,
              T.MODEL_CODE,
              T.MODEL_DESC,
              T.STDMEMO,
              T.SIZE_CODE,
              T.SIZE_NAME,
              T.SIZE_MIN_SIGN,
              T.SIZE_MIN,
              T.SIZE_MAX_SIGN,
              T.SIZE_MAX,
              T.SIZE_CODE2,
              T.SIZE_NAME2,
              T.SIZE_MIN_SIGN2,
              T.SIZE_MIN2,
              T.SIZE_MAX_SIGN2,
              T.SIZE_MAX2,
              T.SPEC_JG,
              T.SPEC_JG_DESC,
              T.ADDCONDITION,
              T.ADDSTDCON_CODE,
              T.ADDSTD_MIN_SIGN,
              T.ADDSTD_MIN,
              T.ADDSTD_MAX_SIGN,
              T.ADDSTD_MAX,
              T.ADDPERCENT,
              T.STDMIN_SIGN2,
              T.STDMIN2,
              T.STDMAX_SIGN2,
              T.STDMAX2,
              T.STD_CHOOSE
         FROM SLM_ORD_DESIGN_STD_PIC T
        WHERE T.DESGIN_KEY = V_ROW.DESGIN_KEY_BL);
  
    INSERT INTO CRAFT_ORD_DESIGN_STD_PIC_SMP
      (DESGIN_KEY,
       PIC,
       SIC,
       PHY_CODE_MIN,
       PHY_NAME_MIN,
       STD_CODE,
       STD_NAME,
       LENGTH,
       DESC_LENGTH,
       RATE,
       DESC_RATE,
       DESC_COUNT,
       POSITION,
       DESC_POSITION,
       SAMPLE_COUNT,
       MEMO)
      (SELECT P_DESIGN_KEY_BL,
              T.PIC,
              T.SIC,
              T.PHY_CODE_MIN,
              T.PHY_NAME_MIN,
              T.STD_CODE,
              T.STD_NAME,
              T.LENGTH,
              T.DESC_LENGTH,
              T.RATE,
              T.DESC_RATE,
              T.DESC_COUNT,
              T.POSITION,
              T.DESC_POSITION,
              T.SAMPLE_COUNT,
              T.MEMO
         FROM SLM_ORD_DESIGN_STD_PIC_SMP T
        WHERE T.DESGIN_KEY = V_ROW.DESGIN_KEY_BL);
  
    INSERT INTO CRAFT_ORD_DESIGN_STD_SIC
      (DESGIN_KEY,
       SIC,
       USE_CODE,
       USE_DESC,
       SPECL_FL,
       INDEX_SEQ,
       BIAS_CODE,
       BIAS_NAME,
       LV,
       BIAS_CODE_Z,
       BIAS_NAME_Z,
       ZMIN_SIGN,
       ZMIN,
       ZMAX_SIGN,
       ZMAX,
       BIAS_CODE_C,
       BIAS_NAME_C,
       CMIN_SIGN,
       CMIN,
       CMAX_SIGN,
       CMAX,
       BIAS_CODE_S,
       BIAS_NAME_S,
       SMIN_SIGN,
       SMIN,
       SMAX_SIGN,
       SMAX,
       ISCHECK,
       STD_MIN_VAL,
       STD_MAX_VAL,
       STD_MIN_IN,
       STD_MAX_IN,
       STD_MIN_PERCENT,
       STD_MAX_PERCENT,
       STD_MIN_FORMULA,
       STD_MAX_FORMULA,
       STD_MIN_FORMULA_V,
       STD_MAX_FORMULA_V,
       STDMEMO)
      (SELECT P_DESIGN_KEY_BL,
              T.SIC,
              T.USE_CODE,
              T.USE_DESC,
              T.SPECL_FL,
              T.INDEX_SEQ,
              T.BIAS_CODE,
              T.BIAS_NAME,
              T.LV,
              T.BIAS_CODE_Z,
              T.BIAS_NAME_Z,
              T.ZMIN_SIGN,
              T.ZMIN,
              T.ZMAX_SIGN,
              T.ZMAX,
              T.BIAS_CODE_C,
              T.BIAS_NAME_C,
              T.CMIN_SIGN,
              T.CMIN,
              T.CMAX_SIGN,
              T.CMAX,
              T.BIAS_CODE_S,
              T.BIAS_NAME_S,
              T.SMIN_SIGN,
              T.SMIN,
              T.SMAX_SIGN,
              T.SMAX,
              T.ISCHECK,
              T.STD_MIN_VAL,
              T.STD_MAX_VAL,
              T.STD_MIN_IN,
              T.STD_MAX_IN,
              T.STD_MIN_PERCENT,
              T.STD_MAX_PERCENT,
              T.STD_MIN_FORMULA,
              T.STD_MAX_FORMULA,
              T.STD_MIN_FORMULA_V,
              T.STD_MAX_FORMULA_V,
              T.STDMEMO
         FROM SLM_ORD_DESIGN_STD_SIC T
        WHERE T.DESGIN_KEY = V_ROW.DESGIN_KEY_BL);
  
    INSERT INTO CRAFT_ORD_DESIGN_STD_WIC
      (DESGIN_KEY,
       WIC,
       USE_CODE,
       USE_DESC,
       SPECL_FL,
       INDEX_SEQ,
       PRESSURE_Y,
       PRESSURE,
       FORMULA,
       SAVE_TIME,
       GET_MAXVALUE,
       GET_MINVALUE,
       RATIO_STD,
       RATIO_REPLACE,
       MAX_PRESS)
      (SELECT P_DESIGN_KEY_BL,
              T.WIC,
              T.USE_CODE,
              T.USE_DESC,
              T.SPECL_FL,
              T.INDEX_SEQ,
              T.PRESSURE_Y,
              T.PRESSURE,
              T.FORMULA,
              T.SAVE_TIME,
              T.GET_MAXVALUE,
              T.GET_MINVALUE,
              T.RATIO_STD,
              T.RATIO_REPLACE,
              T.MAX_PRESS
         FROM SLM_ORD_DESIGN_STD_WIC T
        WHERE T.DESGIN_KEY = V_ROW.DESGIN_KEY_BL);
  
    INSERT INTO CRAFT_ORD_DESIGN_STS_PL_PC
      (DESGIN_KEY,
       ORD_LN_PK,
       ORD_LN_DLY_PK,
       MSC_PLINE,
       WHOLE_BACKLOG,
       WHOLE_BACKLOG_DESC,
       PRDCYC_MEET,
       VALIDFLAG,
       CREATE_NAME,
       CREATE_TIME,
       UPDATE_NAME,
       UPDATE_TIME,
       DELETE_NAME,
       DELETE_TIME)
      (SELECT P_DESIGN_KEY_BL,
              T.ORD_LN_PK,
              T.ORD_LN_DLY_PK,
              T.MSC_PLINE,
              T.WHOLE_BACKLOG,
              T.WHOLE_BACKLOG_DESC,
              T.PRDCYC_MEET,
              T.VALIDFLAG,
              T.CREATE_NAME,
              T.CREATE_TIME,
              T.UPDATE_NAME,
              T.UPDATE_TIME,
              T.DELETE_NAME,
              T.DELETE_TIME
         FROM SLM_ORD_DESIGN_STS_PL_PC T
        WHERE T.DESGIN_KEY = V_ROW.DESGIN_KEY_BL);
  
    INSERT INTO CRAFT_ORD_DESIGN_STS_PL_PC_LST
      (DESGIN_KEY,
       ORD_LN_PK,
       ORD_LN_DLY_PK,
       MSC_PLINE,
       WHOLE_BACKLOG,
       WHOLE_BACKLOG_DESC,
       PROCESS_CDOE,
       PROCESS_DESC,
       PRDCYC_MEET,
       VALIDFLAG,
       CREATE_NAME,
       CREATE_TIME,
       UPDATE_NAME,
       UPDATE_TIME,
       DELETE_NAME,
       DELETE_TIME)
      (SELECT P_DESIGN_KEY_BL,
              T.ORD_LN_PK,
              T.ORD_LN_DLY_PK,
              T.MSC_PLINE,
              T.WHOLE_BACKLOG,
              T.WHOLE_BACKLOG_DESC,
              T.PROCESS_CDOE,
              T.PROCESS_DESC,
              T.PRDCYC_MEET,
              T.VALIDFLAG,
              T.CREATE_NAME,
              T.CREATE_TIME,
              T.UPDATE_NAME,
              T.UPDATE_TIME,
              T.DELETE_NAME,
              T.DELETE_TIME
         FROM SLM_ORD_DESIGN_STS_PL_PC_LST T
        WHERE T.DESGIN_KEY = V_ROW.DESGIN_KEY_BL);
  
    INSERT INTO CRAFT_ORD_DESIGN_STS_TKLG
      (DESGIN_KEY,
       ORD_LN_PK,
       DESIGN_STS,
       PRDCYC_MEET,
       VALIDFLAG,
       CREATE_NAME,
       CREATE_TIME,
       UPDATE_NAME,
       UPDATE_TIME,
       DELETE_NAME,
       DELETE_TIME)
      (SELECT P_DESIGN_KEY_BL,
              T.ORD_LN_PK,
              T.DESIGN_STS,
              T.PRDCYC_MEET,
              T.VALIDFLAG,
              T.CREATE_NAME,
              T.CREATE_TIME,
              T.UPDATE_NAME,
              T.UPDATE_TIME,
              T.DELETE_NAME,
              T.DELETE_TIME
         FROM SLM_ORD_DESIGN_STS_TKLG T
        WHERE T.DESGIN_KEY = V_ROW.DESGIN_KEY_BL);
  
    INSERT INTO CRAFT_ORD_LINE_BOM
      (DESGIN_KEY, BOM)
      (SELECT T.DESGIN_KEY, T.BOM
         FROM SLM_ORD_LINE_BOM T
        WHERE T.DESGIN_KEY = V_ROW.DESGIN_KEY_BL);
  
    INSERT INTO CRAFT_ORD_DESIGN_STS_TKLG_LST
      (DESGIN_KEY,
       ORD_LN_PK,
       SEQ_INDEX,
       LST_ITEM,
       DESIGN_STS,
       DESIGN_STS_RS,
       DESIGN_STS_DESC,
       PSC,
       MSC,
       USE_CODE,
       FINAL_USER,
       GRADECODE,
       DESIGN_OBJ_KEY,
       UNIT_CODE,
       UNIT_DESC,
       VALIDFLAG,
       CREATE_NAME,
       CREATE_TIME,
       UPDATE_NAME,
       UPDATE_TIME,
       DELETE_NAME,
       DELETE_TIME)
      (SELECT P_DESIGN_KEY_BL,
              T.ORD_LN_PK,
              T.SEQ_INDEX,
              T.LST_ITEM,
              T.DESIGN_STS,
              T.DESIGN_STS_RS,
              T.DESIGN_STS_DESC,
              T.PSC,
              T.MSC,
              T.USE_CODE,
              T.FINAL_USER,
              T.GRADECODE,
              T.DESIGN_OBJ_KEY,
              T.UNIT_CODE,
              T.UNIT_DESC,
              T.VALIDFLAG,
              T.CREATE_NAME,
              T.CREATE_TIME,
              T.UPDATE_NAME,
              T.UPDATE_TIME,
              T.DELETE_NAME,
              T.DELETE_TIME
         FROM SLM_ORD_DESIGN_STS_TKLG_LST T
        WHERE T.DESGIN_KEY = V_ROW.DESGIN_KEY_BL);
    DELETE FROM CRAFT_ORD_DESIGN_STS_TKLG_LST
     WHERE DESGIN_KEY = V_ROW.DESGIN_KEY_BL
       AND SEQ_INDEX IN ('008', '009', '018', '019', '020', '022');
  END LOOP;

  ------------------
  --接箍备料复制
  ------------------
  FOR V_ROW IN (SELECT *
                  FROM SLM_ORD_DESIGN_MSC_JG_BL
                 WHERE DESGIN_KEY = P_DESIGN_KEY) LOOP
    P_DESIGN_KEY_JG := SYS_GUID();
  
    INSERT INTO CRAFT_ORD_DESIGN_MSC_JG_BL
      (DESGIN_KEY, CODE_JG, PSC_BL, DESGIN_KEY_BL)
    VALUES
      (P_DESIGN_KEY_NEW, V_ROW.CODE_JG, V_ROW.PSC_BL, P_DESIGN_KEY_JG);
  
    INSERT INTO CRAFT_ORD_DESIGN_MSC
      (DESGIN_KEY,
       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,
       PRD_LEN,
       LOSS_RATE,
       VALIDFLAG,
       CREATE_NAME,
       CREATE_TIME,
       UPDATE_NAME,
       UPDATE_TIME,
       DELETE_NAME,
       DELETE_TIME,
       ORD_LN_PK_OLD)
      (SELECT P_DESIGN_KEY_JG,
              T.ORD_PK,
              T.ORD_LN_PK,
              T.ORDER_SEQ,
              T.CUST_ALPHA_NO,
              T.PSC,
              T.PSC_DESC,
              T.MSC,
              T.MSC_DESC,
              T.MSC_STYLE,
              T.USE_CODE,
              T.USE_DESC,
              T.PRD_CLS,
              T.PRODUCCODE,
              T.PRODUCNAME,
              T.STD_CODE,
              T.STD_NAME,
              T.STEELCODE,
              T.STEELNAME,
              T.STD_STYLE,
              T.STD_STYLE_DESC,
              T.ORDER_SPEC_CODE,
              T.ORDER_SPEC_DESC,
              T.SPEC_CODE,
              T.SPEC_NAME,
              T.DIMATER,
              T.HEIGHT,
              T.MODEL_CODE,
              T.MODEL_DESC,
              T.LEN_NO,
              T.LEN_DESC,
              T.LEN_UNIT,
              T.LEN_MIN,
              T.LEN_MAX,
              T.SHRT_LEN_RATO,
              T.SHORTEST,
              T.LONG_LEN_RATO,
              T.LONGEST,
              T.SHRT_STOVE,
              T.AVG_LEN_MIN,
              T.DIFRNC_LEN_MAX,
              T.ENDLEN_SPECSTD,
              T.SIGL_LEN,
              T.ORDER_UNIT,
              T.ORDER_QTY,
              T.ORD_ENSU_TOTL_LEN,
              T.PRDCT_WGT,
              T.DELVRY_RANGE_TPE,
              T.DELVRY_RANGE_MIN,
              T.DELVRY_RANGE_MAX,
              T.FINAL_USER,
              T.FINAL_USER_DESC,
              T.OUTS_BILLET_FL,
              T.OUTS_STL_PIPE_FL,
              T.ASSEL_FL,
              T.PRODUCER_FL,
              T.PRDCR_NO,
              T.PRDCR_DESC,
              T.MPS_FL,
              T.MPS_NO,
              T.MPS_DESC,
              T.DELVRY_BDATE,
              T.DELVRY_EDATE,
              T.DELVRY_DESC,
              T.TRANS_DESC,
              T.ADD_ASK_NO,
              T.ORDER_ADD_DESC,
              T.ORDER_SPECIAL_FL,
              T.ORDER_SPECIAL_HEAD,
              T.ORDER_SPECIAL_PATH,
              T.ORDER_SPECIAL_DESC,
              T.ZBS,
              T.ORDER_PRICE,
              T.TRANS_PRICE,
              T.TEST_ID,
              T.TEST_PRICE,
              T.OUT_PRICE,
              T.BALNCE_PRICE,
              T.BE_ORDER_LN_STATUS,
              T.BE_OBJ_STS_OP,
              T.ORDER_LN_STATUS,
              T.OBJ_STS_OP,
              T.MEMO,
              T.PRD_LEN,
              T.LOSS_RATE,
              T.VALIDFLAG,
              T.CREATE_NAME,
              T.CREATE_TIME,
              T.UPDATE_NAME,
              T.UPDATE_TIME,
              T.DELETE_NAME,
              T.DELETE_TIME,
              T.ORD_LN_PK_OLD
         FROM SLM_ORD_DESIGN_MSC T
        WHERE T.DESGIN_KEY = V_ROW.DESGIN_KEY_BL);
  
    INSERT INTO CRAFT_ORD_DESIGN_MSC_BILT
      (DESGIN_KEY, MSC_PLINE, SPEC_CODE, B_SPEC_CODE, B_SPEC_NAME)
      (SELECT P_DESIGN_KEY_JG,
              T.MSC_PLINE,
              T.SPEC_CODE,
              T.B_SPEC_CODE,
              T.B_SPEC_NAME
         FROM SLM_ORD_DESIGN_MSC_BILT T
        WHERE T.DESGIN_KEY = V_ROW.DESGIN_KEY_BL);
  
    INSERT INTO CRAFT_ORD_DESIGN_MSC_BILT_C
      (DESGIN_KEY,
       MSC_PLINE,
       SPEC_CODE,
       B_SPEC_CODE,
       C_SPEC_CODE,
       C_SPEC_NAME,
       SPEC_CODE_S)
      (SELECT P_DESIGN_KEY_JG,
              T.MSC_PLINE,
              T.SPEC_CODE,
              T.B_SPEC_CODE,
              T.C_SPEC_CODE,
              T.C_SPEC_NAME,
              T.SPEC_CODE_S
         FROM SLM_ORD_DESIGN_MSC_BILT_C T
        WHERE T.DESGIN_KEY = V_ROW.DESGIN_KEY_BL);
  
    INSERT INTO CRAFT_ORD_DESIGN_MSC_BILT_C_PL
      (DESGIN_KEY, MSC_PLINE, C_SPEC_CODE, PLINE_CODE, PLINE_NAME)
      (SELECT P_DESIGN_KEY_JG,
              T.MSC_PLINE,
              T.C_SPEC_CODE,
              T.PLINE_CODE,
              T.PLINE_NAME
         FROM SLM_ORD_DESIGN_MSC_BILT_C_PL T
        WHERE T.DESGIN_KEY = V_ROW.DESGIN_KEY_BL);
  
    INSERT INTO CRAFT_ORD_DESIGN_MSC_BILT_PL
      (DESGIN_KEY, MSC_PLINE, B_SPEC_CODE, PLINE_CODE, PLINE_NAME)
      (SELECT P_DESIGN_KEY_JG,
              T.MSC_PLINE,
              T.B_SPEC_CODE,
              T.PLINE_CODE,
              T.PLINE_NAME
         FROM SLM_ORD_DESIGN_MSC_BILT_PL T
        WHERE T.DESGIN_KEY = V_ROW.DESGIN_KEY_BL);
  
    INSERT INTO CRAFT_ORD_DESIGN_MSC_GZ_GG
      (DESGIN_KEY,
       MSC_PLINE,
       GRADECODE,
       GRADENAME,
       SPEC_CODE,
       SPEC_NAME,
       DIMATER,
       HEIGHT)
      (SELECT P_DESIGN_KEY_JG,
              T.MSC_PLINE,
              T.GRADECODE,
              T.GRADENAME,
              T.SPEC_CODE,
              T.SPEC_NAME,
              T.DIMATER,
              T.HEIGHT
         FROM SLM_ORD_DESIGN_MSC_GZ_GG T
        WHERE T.DESGIN_KEY = V_ROW.DESGIN_KEY_BL);
  
    INSERT INTO CRAFT_ORD_DESIGN_MSC_GZ_GG_PL
      (DESGIN_KEY,
       MSC_PLINE,
       SPEC_CODE,
       PLINE_CODE,
       PLINE_NAME,
       PRD_LEN,
       LOSS_RATE,
       IS_OUTPUT)
      (SELECT P_DESIGN_KEY_JG,
              T.MSC_PLINE,
              T.SPEC_CODE,
              T.PLINE_CODE,
              T.PLINE_NAME,
              T.PRD_LEN,
              T.LOSS_RATE,
              T.IS_OUTPUT
         FROM SLM_ORD_DESIGN_MSC_GZ_GG_PL T
        WHERE T.DESGIN_KEY = V_ROW.DESGIN_KEY_BL);
  
    INSERT INTO CRAFT_ORD_DESIGN_MSC_JG
      (DESGIN_KEY,
       CODE_JG,
       DEMAND_DETECTION,
       DEMAND_BONDERIZING,
       DEMAND_COPPER,
       DEMAND_BLAST,
       PRODUCCODE,
       PRODUCNAME,
       STEELCODE,
       STEELNAME,
       MIN_H,
       MAX_H,
       MIN_D,
       MAX_D,
       SET_JG,
       CUST_ALPHA_NO,
       KEY_JG,
       ORDER_SPECIAL_DESC)
      (SELECT P_DESIGN_KEY_JG,
              T.CODE_JG,
              T.DEMAND_DETECTION,
              T.DEMAND_BONDERIZING,
              T.DEMAND_COPPER,
              T.DEMAND_BLAST,
              T.PRODUCCODE,
              T.PRODUCNAME,
              T.STEELCODE,
              T.STEELNAME,
              T.MIN_H,
              T.MAX_H,
              T.MIN_D,
              T.MAX_D,
              T.SET_JG,
              T.CUST_ALPHA_NO,
              T.KEY_JG,
              T.ORDER_SPECIAL_DESC
         FROM SLM_ORD_DESIGN_MSC_JG T
        WHERE T.DESGIN_KEY = V_ROW.DESGIN_KEY_BL);
  
    INSERT INTO CRAFT_ORD_DESIGN_MSC_JG_PL
      (DESGIN_KEY,
       CODE_JG,
       MSC_PLINE,
       WHOLE_BACKLOG,
       WHOLE_BACKLOG_DESC,
       SET_FL,
       WARN_DESC,
       ORD_LN_PK)
      (SELECT P_DESIGN_KEY_JG,
              T.CODE_JG,
              T.MSC_PLINE,
              T.WHOLE_BACKLOG,
              T.WHOLE_BACKLOG_DESC,
              T.SET_FL,
              T.WARN_DESC,
              T.ORD_LN_PK
         FROM SLM_ORD_DESIGN_MSC_JG_PL T
        WHERE T.DESGIN_KEY = V_ROW.DESGIN_KEY_BL);
  
    INSERT INTO CRAFT_ORD_DESIGN_MSC_JG_PL_STI
      (DESGIN_KEY,
       CODE_JG,
       MSC_PLINE,
       WHOLE_BACKLOG,
       WHOLE_BACKLOG_DESC,
       BACKLOG_SEQ,
       PROCESS_CODE,
       PROCESS_DESC,
       PROCESS_SEQ,
       PROCESS_CODE_C,
       PROCESS_DESC_C,
       STATION_ID,
       STATION_CODE,
       STATION_DESC,
       STATION_TYPE)
      (SELECT P_DESIGN_KEY_JG,
              T.CODE_JG,
              T.MSC_PLINE,
              T.WHOLE_BACKLOG,
              T.WHOLE_BACKLOG_DESC,
              T.BACKLOG_SEQ,
              T.PROCESS_CODE,
              T.PROCESS_DESC,
              T.PROCESS_SEQ,
              T.PROCESS_CODE_C,
              T.PROCESS_DESC_C,
              T.STATION_ID,
              T.STATION_CODE,
              T.STATION_DESC,
              T.STATION_TYPE
         FROM SLM_ORD_DESIGN_MSC_JG_PL_STI T
        WHERE T.DESGIN_KEY = V_ROW.DESGIN_KEY_BL);
  
    INSERT INTO CRAFT_ORD_DESIGN_MSC_PL
      (DESGIN_KEY,
       MSC_PLINE,
       WHOLE_BACKLOG,
       WHOLE_BACKLOG_DESC,
       SET_FL,
       WARN_DESC,
       ORD_LN_PK)
      (SELECT P_DESIGN_KEY_JG,
              T.MSC_PLINE,
              T.WHOLE_BACKLOG,
              T.WHOLE_BACKLOG_DESC,
              T.SET_FL,
              T.WARN_DESC,
              T.ORD_LN_PK
         FROM SLM_ORD_DESIGN_MSC_PL T
        WHERE T.DESGIN_KEY = V_ROW.DESGIN_KEY_BL);
  
    INSERT INTO CRAFT_ORD_DESIGN_MSC_PL_GX_PRL
      (DESGIN_KEY,
       MSC_PLINE,
       BACKLOG_SEQ,
       PROCESS_CODE,
       PLINE_CODE,
       PLINE_NAME,
       WELL_CODE,
       WELL_NAME,
       WARN_FL,
       WARN_DESC,
       VALIDFLAG,
       IDENT_FLAG)
      (SELECT P_DESIGN_KEY_JG,
              T.MSC_PLINE,
              T.BACKLOG_SEQ,
              T.PROCESS_CODE,
              T.PLINE_CODE,
              T.PLINE_NAME,
              T.WELL_CODE,
              T.WELL_NAME,
              T.WARN_FL,
              T.WARN_DESC,
              T.VALIDFLAG,
              T.IDENT_FLAG
         FROM SLM_ORD_DESIGN_MSC_PL_GX_PRL T
        WHERE T.DESGIN_KEY = V_ROW.DESGIN_KEY_BL);
  
    INSERT INTO CRAFT_ORD_DESIGN_MSC_PL_GZ
      (DESGIN_KEY,
       MSC_PLINE,
       WHOLE_BACKLOG,
       WHOLE_BACKLOG_DESC,
       GRADECODE,
       GRADENAME,
       ASSORTMENT_CODE,
       ASSORTMENT_NAME)
      (SELECT P_DESIGN_KEY_JG,
              T.MSC_PLINE,
              T.WHOLE_BACKLOG,
              T.WHOLE_BACKLOG_DESC,
              T.GRADECODE,
              T.GRADENAME,
              T.ASSORTMENT_CODE,
              T.ASSORTMENT_NAME
         FROM SLM_ORD_DESIGN_MSC_PL_GZ T
        WHERE T.DESGIN_KEY = V_ROW.DESGIN_KEY_BL);
  
    INSERT INTO CRAFT_ORD_DESIGN_MSC_PL_PC
      (DESGIN_KEY,
       ORD_LN_DLY_PK,
       MSC_PLINE,
       DELVRY_EDATE,
       DELVRY_QTY,
       ORDER_UNIT,
       RECEIV_NO,
       RECEIV_NM,
       RCMD_DELVRY_EDATE,
       PRD_CYC,
       PRD_CYC_BTCH,
       N_MATERIAL_FL,
       CYC_EDIT,
       CREATE_NAME,
       CREATE_TIME,
       UPDATE_NAME,
       UPDATE_TIME)
      (SELECT P_DESIGN_KEY_JG,
              T.ORD_LN_DLY_PK,
              T.MSC_PLINE,
              T.DELVRY_EDATE,
              T.DELVRY_QTY,
              T.ORDER_UNIT,
              T.RECEIV_NO,
              T.RECEIV_NM,
              T.RCMD_DELVRY_EDATE,
              T.PRD_CYC,
              T.PRD_CYC_BTCH,
              T.N_MATERIAL_FL,
              T.CYC_EDIT,
              T.CREATE_NAME,
              T.CREATE_TIME,
              T.UPDATE_NAME,
              T.UPDATE_TIME
         FROM SLM_ORD_DESIGN_MSC_PL_PC T
        WHERE T.DESGIN_KEY = V_ROW.DESGIN_KEY_BL);
  
    INSERT INTO CRAFT_ORD_DESIGN_MSC_PL_PC_LST
      (DESGIN_KEY,
       ORD_LN_DLY_PK,
       MSC_PLINE,
       BACKLOG_SEQ,
       PROCESS_CODE,
       PROCESS_DESC,
       REVIEW_ASK,
       LST_PRD_DATE,
       PRD_CYC,
       PRD_CYC_BTCH)
      (SELECT P_DESIGN_KEY_JG,
              T.ORD_LN_DLY_PK,
              T.MSC_PLINE,
              T.BACKLOG_SEQ,
              T.PROCESS_CODE,
              T.PROCESS_DESC,
              T.REVIEW_ASK,
              T.LST_PRD_DATE,
              T.PRD_CYC,
              T.PRD_CYC_BTCH
         FROM SLM_ORD_DESIGN_MSC_PL_PC_LST T
        WHERE T.DESGIN_KEY = V_ROW.DESGIN_KEY_BL);
  
    INSERT INTO CRAFT_ORD_DESIGN_MSC_PL_PRC
      (DESGIN_KEY,
       MSC_PLINE,
       WHOLE_BACKLOG,
       WHOLE_BACKLOG_DESC,
       BACKLOG_SEQ,
       PROCESS_CODE,
       PROCESS_DESC,
       PROCESS_SEQ,
       PROCESS_CODE_C,
       PROCESS_DESC_C,
       MINUTE_PRODUCT,
       MINUTE_PRODUCT_OUT,
       MINUTE_WAITE,
       MINUTE_WAITE_OUT,
       BATCH_WAITE,
       BATCH_WAITE_OUT,
       CIC,
       PIC,
       SIC,
       DIC,
       WIC,
       GIC)
      (SELECT P_DESIGN_KEY_JG,
              T.MSC_PLINE,
              T.WHOLE_BACKLOG,
              T.WHOLE_BACKLOG_DESC,
              T.BACKLOG_SEQ,
              T.PROCESS_CODE,
              T.PROCESS_DESC,
              T.PROCESS_SEQ,
              T.PROCESS_CODE_C,
              T.PROCESS_DESC_C,
              T.MINUTE_PRODUCT,
              T.MINUTE_PRODUCT_OUT,
              T.MINUTE_WAITE,
              T.MINUTE_WAITE_OUT,
              T.BATCH_WAITE,
              T.BATCH_WAITE_OUT,
              T.CIC,
              T.PIC,
              T.SIC,
              T.DIC,
              T.WIC,
              T.GIC
         FROM SLM_ORD_DESIGN_MSC_PL_PRC T
        WHERE T.DESGIN_KEY = V_ROW.DESGIN_KEY_BL);
  
    INSERT INTO CRAFT_ORD_DESIGN_MSC_PL_STI
      (DESGIN_KEY,
       MSC_PLINE,
       WHOLE_BACKLOG,
       WHOLE_BACKLOG_DESC,
       BACKLOG_SEQ,
       PROCESS_CODE,
       PROCESS_DESC,
       PROCESS_SEQ,
       PROCESS_CODE_C,
       PROCESS_DESC_C,
       STATION_ID,
       STATION_CODE,
       STATION_DESC,
       STATION_TYPE,
       CRAFTITEM_CODE,
       CRAFTITEM_DESC)
      (SELECT P_DESIGN_KEY_JG,
              T.MSC_PLINE,
              T.WHOLE_BACKLOG,
              T.WHOLE_BACKLOG_DESC,
              T.BACKLOG_SEQ,
              T.PROCESS_CODE,
              T.PROCESS_DESC,
              T.PROCESS_SEQ,
              T.PROCESS_CODE_C,
              T.PROCESS_DESC_C,
              T.STATION_ID,
              T.STATION_CODE,
              T.STATION_DESC,
              T.STATION_TYPE,
              T.CRAFTITEM_CODE,
              T.CRAFTITEM_DESC
         FROM SLM_ORD_DESIGN_MSC_PL_STI T
        WHERE T.DESGIN_KEY = V_ROW.DESGIN_KEY_BL);
  
    INSERT INTO CRAFT_ORD_DESIGN_MSC_PL_STI_TC
      (DESGIN_KEY,
       ORD_PK,
       ORD_LN_PK,
       MSC_PLINE,
       WHOLE_BACKLOG,
       WHOLE_BACKLOG_DESC,
       BACKLOG_SEQ,
       PROCESS_CODE,
       PROCESS_DESC,
       PROCESS_SEQ,
       PROCESS_CODE_C,
       PROCESS_DESC_C,
       STATION_ID,
       STATION_CODE,
       STATION_DESC,
       STATION_TYPE,
       CRAFTITEM_CODE,
       CRAFTITEM_DESC)
      (SELECT P_DESIGN_KEY_JG,
              T.ORD_PK,
              T.ORD_LN_PK,
              T.MSC_PLINE,
              T.WHOLE_BACKLOG,
              T.WHOLE_BACKLOG_DESC,
              T.BACKLOG_SEQ,
              T.PROCESS_CODE,
              T.PROCESS_DESC,
              T.PROCESS_SEQ,
              T.PROCESS_CODE_C,
              T.PROCESS_DESC_C,
              T.STATION_ID,
              T.STATION_CODE,
              T.STATION_DESC,
              T.STATION_TYPE,
              T.CRAFTITEM_CODE,
              T.CRAFTITEM_DESC
         FROM SLM_ORD_DESIGN_MSC_PL_STI_TC T
        WHERE T.DESGIN_KEY = V_ROW.DESGIN_KEY_BL);
  
    INSERT INTO CRAFT_ORD_DESIGN_STD
      (DESGIN_KEY, CIC, PIC, SIC, DIC, WIC, GIC)
      (SELECT P_DESIGN_KEY_JG, T.CIC, T.PIC, T.SIC, T.DIC, T.WIC, T.GIC
         FROM SLM_ORD_DESIGN_STD T
        WHERE T.DESGIN_KEY = V_ROW.DESGIN_KEY_BL);
  
    INSERT INTO CRAFT_ORD_DESIGN_STD_CIC
      (DESGIN_KEY,
       CIC,
       USE_CODE,
       USE_DESC,
       SPECL_FL,
       INDEX_SEQ,
       CHEM_CODE,
       CHEM_NAME,
       CHEM_TYPE,
       CHEM_FORMULA,
       ISCHECK,
       ISJUDGE,
       ISQUOTE,
       COMPLEX_TYPE,
       STDMIN_SIGN,
       STDMIN,
       STDMAX_SIGN,
       STDMAX,
       STDTARGET,
       MODEL_CODE,
       MODEL_DESC,
       STDMEMO,
       ELE_CODE,
       ELE_NAME,
       ELE_MIN_SIGN,
       ELE_MIN,
       ELE_MAX_SIGN,
       ELE_MAX,
       SIZE_CODE2,
       SIZE_NAME2,
       SIZE_MIN_SIGN2,
       SIZE_MIN2,
       SIZE_MAX_SIGN2,
       SIZE_MAX2,
       SIZE_CODE,
       SIZE_NAME,
       SIZE_MIN_SIGN,
       SIZE_MIN,
       SIZE_MAX_SIGN,
       SIZE_MAX,
       SPEC_JG,
       SPEC_JG_DESC,
       VALIDFLAG,
       CREATE_NAME,
       CREATE_TIME,
       UPDATE_NAME,
       UPDATE_TIME,
       DELETE_NAME,
       DELETE_TIME,
       REP_CODE,
       REP_NAME,
       REP_MIN_SIGN,
       REP_MIN,
       REP_MAX_SIGN,
       REP_MAX,
       REP_VAL)
      (SELECT P_DESIGN_KEY_JG,
              T.CIC,
              T.USE_CODE,
              T.USE_DESC,
              T.SPECL_FL,
              T.INDEX_SEQ,
              T.CHEM_CODE,
              T.CHEM_NAME,
              T.CHEM_TYPE,
              T.CHEM_FORMULA,
              T.ISCHECK,
              T.ISJUDGE,
              T.ISQUOTE,
              T.COMPLEX_TYPE,
              T.STDMIN_SIGN,
              T.STDMIN,
              T.STDMAX_SIGN,
              T.STDMAX,
              T.STDTARGET,
              T.MODEL_CODE,
              T.MODEL_DESC,
              T.STDMEMO,
              T.ELE_CODE,
              T.ELE_NAME,
              T.ELE_MIN_SIGN,
              T.ELE_MIN,
              T.ELE_MAX_SIGN,
              T.ELE_MAX,
              T.SIZE_CODE2,
              T.SIZE_NAME2,
              T.SIZE_MIN_SIGN2,
              T.SIZE_MIN2,
              T.SIZE_MAX_SIGN2,
              T.SIZE_MAX2,
              T.SIZE_CODE,
              T.SIZE_NAME,
              T.SIZE_MIN_SIGN,
              T.SIZE_MIN,
              T.SIZE_MAX_SIGN,
              T.SIZE_MAX,
              T.SPEC_JG,
              T.SPEC_JG_DESC,
              T.VALIDFLAG,
              T.CREATE_NAME,
              T.CREATE_TIME,
              T.UPDATE_NAME,
              T.UPDATE_TIME,
              T.DELETE_NAME,
              T.DELETE_TIME,
              T.REP_CODE,
              T.REP_NAME,
              T.REP_MIN_SIGN,
              T.REP_MIN,
              T.REP_MAX_SIGN,
              T.REP_MAX,
              T.REP_VAL
         FROM SLM_ORD_DESIGN_STD_CIC T
        WHERE T.DESGIN_KEY = V_ROW.DESGIN_KEY_BL);
  
    INSERT INTO CRAFT_ORD_DESIGN_STD_DIC
      (DESGIN_KEY,
       DIC,
       USE_CODE,
       USE_DESC,
       SPECL_FL,
       XH,
       PHY_CODE,
       PHY_NAME,
       POSITION_CODE,
       POSITION_DESC,
       STD_DESC,
       LV_CODE,
       LV_DESC,
       GROOVE_POS,
       GROOVE_DIR,
       COVERAGE,
       RATE,
       DESC_RATE,
       DESC_VAL,
       GROUP_SEQ,
       MEMO,
       MIN_D,
       MAX_D,
       MIN_H,
       MAX_H)
      (SELECT P_DESIGN_KEY_JG,
              T.DIC,
              T.USE_CODE,
              T.USE_DESC,
              T.SPECL_FL,
              T.XH,
              T.PHY_CODE,
              T.PHY_NAME,
              T.POSITION_CODE,
              T.POSITION_DESC,
              T.STD_DESC,
              T.LV_CODE,
              T.LV_DESC,
              T.GROOVE_POS,
              T.GROOVE_DIR,
              T.COVERAGE,
              T.RATE,
              T.DESC_RATE,
              T.DESC_VAL,
              T.GROUP_SEQ,
              T.MEMO,
              T.MIN_D,
              T.MAX_D,
              T.MIN_H,
              T.MAX_H
         FROM SLM_ORD_DESIGN_STD_DIC T
        WHERE T.DESGIN_KEY = V_ROW.DESGIN_KEY_BL);
  
    INSERT INTO CRAFT_ORD_DESIGN_STD_GIC
      (DESGIN_KEY,
       GIC,
       USE_CODE,
       USE_DESC,
       SPECL_FL,
       XH,
       PROCESS_CDOE,
       PROCESS_DESC,
       PROCESS_CDOE_C,
       PROCESS_DESC_C,
       STATION_CODE,
       STATION_DESC,
       VALUE_TEXT,
       VALUE_NUM,
       VALUE_MEMO,
       GROUP_SEQ,
       MEMO)
      (SELECT P_DESIGN_KEY_JG,
              T.GIC,
              T.USE_CODE,
              T.USE_DESC,
              T.SPECL_FL,
              T.XH,
              T.PROCESS_CDOE,
              T.PROCESS_DESC,
              T.PROCESS_CDOE_C,
              T.PROCESS_DESC_C,
              T.STATION_CODE,
              T.STATION_DESC,
              T.VALUE_TEXT,
              T.VALUE_NUM,
              T.VALUE_MEMO,
              T.GROUP_SEQ,
              T.MEMO
         FROM SLM_ORD_DESIGN_STD_GIC T
        WHERE T.DESGIN_KEY = V_ROW.DESGIN_KEY_BL);
  
    INSERT INTO CRAFT_ORD_DESIGN_STD_PIC
      (DESGIN_KEY,
       PIC,
       USE_CODE,
       USE_DESC,
       SPECL_FL,
       INDEX_SEQ,
       PHY_CODE_MAX,
       PHY_NAME_MAX,
       PHY_CODE_MIN,
       PHY_NAME_MIN,
       PHY_CODE,
       PHY_NAME,
       ITEM_CODE_F,
       ITEM_NAME_F,
       ITEM_CODE_W,
       ITEM_NAME_W,
       ITEM_CODE_S,
       ITEM_NAME_S,
       GROUP_SEQ,
       ISCHECK,
       ISQUOTE,
       RESULT_COUNT,
       ISJUDGE,
       PHY_TYPE,
       PHY_FORMULA,
       STDMIN_SIGN,
       STDMIN,
       STDMAX_SIGN,
       STDMAX,
       JUDGE_BASIS,
       DELIVERYSTATE,
       MODEL_CODE,
       MODEL_DESC,
       STDMEMO,
       SIZE_CODE,
       SIZE_NAME,
       SIZE_MIN_SIGN,
       SIZE_MIN,
       SIZE_MAX_SIGN,
       SIZE_MAX,
       SIZE_CODE2,
       SIZE_NAME2,
       SIZE_MIN_SIGN2,
       SIZE_MIN2,
       SIZE_MAX_SIGN2,
       SIZE_MAX2,
       SPEC_JG,
       SPEC_JG_DESC,
       ADDCONDITION,
       ADDSTDCON_CODE,
       ADDSTD_MIN_SIGN,
       ADDSTD_MIN,
       ADDSTD_MAX_SIGN,
       ADDSTD_MAX,
       ADDPERCENT,
       STDMIN_SIGN2,
       STDMIN2,
       STDMAX_SIGN2,
       STDMAX2,
       STD_CHOOSE)
      (SELECT P_DESIGN_KEY_JG,
              T.PIC,
              T.USE_CODE,
              T.USE_DESC,
              T.SPECL_FL,
              T.INDEX_SEQ,
              T.PHY_CODE_MAX,
              T.PHY_NAME_MAX,
              T.PHY_CODE_MIN,
              T.PHY_NAME_MIN,
              T.PHY_CODE,
              T.PHY_NAME,
              T.ITEM_CODE_F,
              T.ITEM_NAME_F,
              T.ITEM_CODE_W,
              T.ITEM_NAME_W,
              T.ITEM_CODE_S,
              T.ITEM_NAME_S,
              T.GROUP_SEQ,
              T.ISCHECK,
              T.ISQUOTE,
              T.RESULT_COUNT,
              T.ISJUDGE,
              T.PHY_TYPE,
              T.PHY_FORMULA,
              T.STDMIN_SIGN,
              T.STDMIN,
              T.STDMAX_SIGN,
              T.STDMAX,
              T.JUDGE_BASIS,
              T.DELIVERYSTATE,
              T.MODEL_CODE,
              T.MODEL_DESC,
              T.STDMEMO,
              T.SIZE_CODE,
              T.SIZE_NAME,
              T.SIZE_MIN_SIGN,
              T.SIZE_MIN,
              T.SIZE_MAX_SIGN,
              T.SIZE_MAX,
              T.SIZE_CODE2,
              T.SIZE_NAME2,
              T.SIZE_MIN_SIGN2,
              T.SIZE_MIN2,
              T.SIZE_MAX_SIGN2,
              T.SIZE_MAX2,
              T.SPEC_JG,
              T.SPEC_JG_DESC,
              T.ADDCONDITION,
              T.ADDSTDCON_CODE,
              T.ADDSTD_MIN_SIGN,
              T.ADDSTD_MIN,
              T.ADDSTD_MAX_SIGN,
              T.ADDSTD_MAX,
              T.ADDPERCENT,
              T.STDMIN_SIGN2,
              T.STDMIN2,
              T.STDMAX_SIGN2,
              T.STDMAX2,
              T.STD_CHOOSE
         FROM SLM_ORD_DESIGN_STD_PIC T
        WHERE T.DESGIN_KEY = V_ROW.DESGIN_KEY_BL);
  
    INSERT INTO CRAFT_ORD_DESIGN_STD_PIC_SMP
      (DESGIN_KEY,
       PIC,
       SIC,
       PHY_CODE_MIN,
       PHY_NAME_MIN,
       STD_CODE,
       STD_NAME,
       LENGTH,
       DESC_LENGTH,
       RATE,
       DESC_RATE,
       DESC_COUNT,
       POSITION,
       DESC_POSITION,
       SAMPLE_COUNT,
       MEMO)
      (SELECT P_DESIGN_KEY_JG,
              T.PIC,
              T.SIC,
              T.PHY_CODE_MIN,
              T.PHY_NAME_MIN,
              T.STD_CODE,
              T.STD_NAME,
              T.LENGTH,
              T.DESC_LENGTH,
              T.RATE,
              T.DESC_RATE,
              T.DESC_COUNT,
              T.POSITION,
              T.DESC_POSITION,
              T.SAMPLE_COUNT,
              T.MEMO
         FROM SLM_ORD_DESIGN_STD_PIC_SMP T
        WHERE T.DESGIN_KEY = V_ROW.DESGIN_KEY_BL);
  
    INSERT INTO CRAFT_ORD_DESIGN_STD_SIC
      (DESGIN_KEY,
       SIC,
       USE_CODE,
       USE_DESC,
       SPECL_FL,
       INDEX_SEQ,
       BIAS_CODE,
       BIAS_NAME,
       LV,
       BIAS_CODE_Z,
       BIAS_NAME_Z,
       ZMIN_SIGN,
       ZMIN,
       ZMAX_SIGN,
       ZMAX,
       BIAS_CODE_C,
       BIAS_NAME_C,
       CMIN_SIGN,
       CMIN,
       CMAX_SIGN,
       CMAX,
       BIAS_CODE_S,
       BIAS_NAME_S,
       SMIN_SIGN,
       SMIN,
       SMAX_SIGN,
       SMAX,
       ISCHECK,
       STD_MIN_VAL,
       STD_MAX_VAL,
       STD_MIN_IN,
       STD_MAX_IN,
       STD_MIN_PERCENT,
       STD_MAX_PERCENT,
       STD_MIN_FORMULA,
       STD_MAX_FORMULA,
       STD_MIN_FORMULA_V,
       STD_MAX_FORMULA_V,
       STDMEMO)
      (SELECT P_DESIGN_KEY_JG,
              T.SIC,
              T.USE_CODE,
              T.USE_DESC,
              T.SPECL_FL,
              T.INDEX_SEQ,
              T.BIAS_CODE,
              T.BIAS_NAME,
              T.LV,
              T.BIAS_CODE_Z,
              T.BIAS_NAME_Z,
              T.ZMIN_SIGN,
              T.ZMIN,
              T.ZMAX_SIGN,
              T.ZMAX,
              T.BIAS_CODE_C,
              T.BIAS_NAME_C,
              T.CMIN_SIGN,
              T.CMIN,
              T.CMAX_SIGN,
              T.CMAX,
              T.BIAS_CODE_S,
              T.BIAS_NAME_S,
              T.SMIN_SIGN,
              T.SMIN,
              T.SMAX_SIGN,
              T.SMAX,
              T.ISCHECK,
              T.STD_MIN_VAL,
              T.STD_MAX_VAL,
              T.STD_MIN_IN,
              T.STD_MAX_IN,
              T.STD_MIN_PERCENT,
              T.STD_MAX_PERCENT,
              T.STD_MIN_FORMULA,
              T.STD_MAX_FORMULA,
              T.STD_MIN_FORMULA_V,
              T.STD_MAX_FORMULA_V,
              T.STDMEMO
         FROM SLM_ORD_DESIGN_STD_SIC T
        WHERE T.DESGIN_KEY = V_ROW.DESGIN_KEY_BL);
  
    INSERT INTO CRAFT_ORD_DESIGN_STD_WIC
      (DESGIN_KEY,
       WIC,
       USE_CODE,
       USE_DESC,
       SPECL_FL,
       INDEX_SEQ,
       PRESSURE_Y,
       PRESSURE,
       FORMULA,
       SAVE_TIME,
       GET_MAXVALUE,
       GET_MINVALUE,
       RATIO_STD,
       RATIO_REPLACE,
       MAX_PRESS)
      (SELECT P_DESIGN_KEY_JG,
              T.WIC,
              T.USE_CODE,
              T.USE_DESC,
              T.SPECL_FL,
              T.INDEX_SEQ,
              T.PRESSURE_Y,
              T.PRESSURE,
              T.FORMULA,
              T.SAVE_TIME,
              T.GET_MAXVALUE,
              T.GET_MINVALUE,
              T.RATIO_STD,
              T.RATIO_REPLACE,
              T.MAX_PRESS
         FROM SLM_ORD_DESIGN_STD_WIC T
        WHERE T.DESGIN_KEY = V_ROW.DESGIN_KEY_BL);
  
    INSERT INTO CRAFT_ORD_DESIGN_STS_PL_PC
      (DESGIN_KEY,
       ORD_LN_PK,
       ORD_LN_DLY_PK,
       MSC_PLINE,
       WHOLE_BACKLOG,
       WHOLE_BACKLOG_DESC,
       PRDCYC_MEET,
       VALIDFLAG,
       CREATE_NAME,
       CREATE_TIME,
       UPDATE_NAME,
       UPDATE_TIME,
       DELETE_NAME,
       DELETE_TIME)
      (SELECT P_DESIGN_KEY_JG,
              T.ORD_LN_PK,
              T.ORD_LN_DLY_PK,
              T.MSC_PLINE,
              T.WHOLE_BACKLOG,
              T.WHOLE_BACKLOG_DESC,
              T.PRDCYC_MEET,
              T.VALIDFLAG,
              T.CREATE_NAME,
              T.CREATE_TIME,
              T.UPDATE_NAME,
              T.UPDATE_TIME,
              T.DELETE_NAME,
              T.DELETE_TIME
         FROM SLM_ORD_DESIGN_STS_PL_PC T
        WHERE T.DESGIN_KEY = V_ROW.DESGIN_KEY_BL);
  
    INSERT INTO CRAFT_ORD_DESIGN_STS_PL_PC_LST
      (DESGIN_KEY,
       ORD_LN_PK,
       ORD_LN_DLY_PK,
       MSC_PLINE,
       WHOLE_BACKLOG,
       WHOLE_BACKLOG_DESC,
       PROCESS_CDOE,
       PROCESS_DESC,
       PRDCYC_MEET,
       VALIDFLAG,
       CREATE_NAME,
       CREATE_TIME,
       UPDATE_NAME,
       UPDATE_TIME,
       DELETE_NAME,
       DELETE_TIME)
      (SELECT P_DESIGN_KEY_JG,
              T.ORD_LN_PK,
              T.ORD_LN_DLY_PK,
              T.MSC_PLINE,
              T.WHOLE_BACKLOG,
              T.WHOLE_BACKLOG_DESC,
              T.PROCESS_CDOE,
              T.PROCESS_DESC,
              T.PRDCYC_MEET,
              T.VALIDFLAG,
              T.CREATE_NAME,
              T.CREATE_TIME,
              T.UPDATE_NAME,
              T.UPDATE_TIME,
              T.DELETE_NAME,
              T.DELETE_TIME
         FROM SLM_ORD_DESIGN_STS_PL_PC_LST T
        WHERE T.DESGIN_KEY = V_ROW.DESGIN_KEY_BL);
  
    INSERT INTO CRAFT_ORD_DESIGN_STS_TKLG
      (DESGIN_KEY,
       ORD_LN_PK,
       DESIGN_STS,
       PRDCYC_MEET,
       VALIDFLAG,
       CREATE_NAME,
       CREATE_TIME,
       UPDATE_NAME,
       UPDATE_TIME,
       DELETE_NAME,
       DELETE_TIME)
      (SELECT P_DESIGN_KEY_JG,
              T.ORD_LN_PK,
              T.DESIGN_STS,
              T.PRDCYC_MEET,
              T.VALIDFLAG,
              T.CREATE_NAME,
              T.CREATE_TIME,
              T.UPDATE_NAME,
              T.UPDATE_TIME,
              T.DELETE_NAME,
              T.DELETE_TIME
         FROM SLM_ORD_DESIGN_STS_TKLG T
        WHERE T.DESGIN_KEY = V_ROW.DESGIN_KEY_BL);
  
    INSERT INTO CRAFT_ORD_LINE_BOM
      (DESGIN_KEY, BOM)
      (SELECT T.DESGIN_KEY, T.BOM
         FROM SLM_ORD_LINE_BOM T
        WHERE T.DESGIN_KEY = V_ROW.DESGIN_KEY_BL);
  
    INSERT INTO CRAFT_ORD_DESIGN_STS_TKLG_LST
      (DESGIN_KEY,
       ORD_LN_PK,
       SEQ_INDEX,
       LST_ITEM,
       DESIGN_STS,
       DESIGN_STS_RS,
       DESIGN_STS_DESC,
       PSC,
       MSC,
       USE_CODE,
       FINAL_USER,
       GRADECODE,
       DESIGN_OBJ_KEY,
       UNIT_CODE,
       UNIT_DESC,
       VALIDFLAG,
       CREATE_NAME,
       CREATE_TIME,
       UPDATE_NAME,
       UPDATE_TIME,
       DELETE_NAME,
       DELETE_TIME)
      (SELECT P_DESIGN_KEY_JG,
              T.ORD_LN_PK,
              T.SEQ_INDEX,
              T.LST_ITEM,
              T.DESIGN_STS,
              T.DESIGN_STS_RS,
              T.DESIGN_STS_DESC,
              T.PSC,
              T.MSC,
              T.USE_CODE,
              T.FINAL_USER,
              T.GRADECODE,
              T.DESIGN_OBJ_KEY,
              T.UNIT_CODE,
              T.UNIT_DESC,
              T.VALIDFLAG,
              T.CREATE_NAME,
              T.CREATE_TIME,
              T.UPDATE_NAME,
              T.UPDATE_TIME,
              T.DELETE_NAME,
              T.DELETE_TIME
         FROM SLM_ORD_DESIGN_STS_TKLG_LST T
        WHERE T.DESGIN_KEY = V_ROW.DESGIN_KEY_BL);
    DELETE FROM CRAFT_ORD_DESIGN_STS_TKLG_LST
     WHERE DESGIN_KEY = V_ROW.DESGIN_KEY_BL
       AND SEQ_INDEX IN ('008', '009', '018', '019', '020', '022');
  END LOOP;
END;
		]]>
	</query>
	
	
	<query id="CoreOrderReviewTechnology.copyOrdToCraft2" desc="复制质量设计结果到工艺设计表中(正在使用的， 上面那个暂时不使用)">
		<![CDATA[
DECLARE
  P_DESIGN_KEY         CRAFT_ORD_DESIGN_MSC.DESGIN_KEY%TYPE; --质量设计DESIGNKEY
  P_DESIGN_KEY_NEW     CRAFT_ORD_DESIGN_MSC.DESGIN_KEY%TYPE; --工艺评审DESIGNKEY新
  P_DESIGN_KEY_OLD     CRAFT_ORD_DESIGN_MSC.DESGIN_KEY%TYPE; --工艺评审DESIGNKEY旧
  P_DESIGN_KEY_BL      CRAFT_ORD_DESIGN_MSC.DESGIN_KEY%TYPE; --工艺评审DESIGNKEY备料
  P_DESIGN_KEY_JG      CRAFT_ORD_DESIGN_MSC.DESGIN_KEY%TYPE; --工艺评审DESIGNKEY接箍
  P_ORD_DESIGN_MSC_CNT NUMBER(5);
  P_CRAFT_DESIGN_CNT   NUMBER(5);
  P_JG_BL_CNT          NUMBER(5);
  P_BL_CNT             NUMBER(5);
  P_DESIGN_KEY_CNT     NUMBER(5);
  P_ADD_ASK_ALL        VARCHAR2(4000);
  P_ADD_ASK_DIFF       VARCHAR2(4000);

BEGIN
  P_DESIGN_KEY_NEW := '#DESIGN_KEY_NEW#';
  SELECT COUNT(1)
    INTO P_ORD_DESIGN_MSC_CNT
    FROM SLM_ORD_DESIGN_MSC
   WHERE ORD_LN_PK = '#ORD_LN_PK#'
     AND VALIDFLAG = '1';
  IF P_ORD_DESIGN_MSC_CNT > 0 THEN
    SELECT DESGIN_KEY
      INTO P_DESIGN_KEY
      FROM SLM_ORD_DESIGN_MSC
     WHERE ORD_LN_PK = '#ORD_LN_PK#'
       AND VALIDFLAG = '1';
  END IF;

  SELECT COUNT(1)
    INTO P_CRAFT_DESIGN_CNT
    FROM CRAFT_ORD_DESIGN
   WHERE ORD_LN_PK = '#ORD_LN_PK#'
     AND CRAFT_SEQ = (SELECT MAX(CRAFT_SEQ)
                        FROM CRAFT_ORD_DESIGN
                       WHERE ORD_LN_PK = '#ORD_LN_PK#')
     AND VALIDFLAG <> '1';
  IF P_CRAFT_DESIGN_CNT > 0 THEN
    SELECT DESGIN_KEY
      INTO P_DESIGN_KEY_OLD
      FROM CRAFT_ORD_DESIGN
     WHERE ORD_LN_PK = '#ORD_LN_PK#'
       AND CRAFT_SEQ = (SELECT MAX(CRAFT_SEQ)
                          FROM CRAFT_ORD_DESIGN
                         WHERE ORD_LN_PK = '#ORD_LN_PK#')
       AND VALIDFLAG <> '1';
  END IF;

  --如果有多条合同行使用相同的DESIGN_KEY，则不能删除工艺制定的数据。
  SELECT COUNT(1)
    INTO P_DESIGN_KEY_CNT
    FROM CRAFT_ORD_DESIGN
   WHERE DESGIN_KEY = P_DESIGN_KEY_OLD;

  IF '#OPERATE_TYPE#' = '0' THEN
    DELETE FROM CRAFT_ORD_DESIGN
     WHERE ORD_LN_PK = '#ORD_LN_PK#'
       AND CRAFT_SEQ = (SELECT MAX(CRAFT_SEQ)
                          FROM CRAFT_ORD_DESIGN
                         WHERE ORD_LN_PK = '#ORD_LN_PK#')
       AND VALIDFLAG <> '1';
  END IF;

  IF P_DESIGN_KEY_CNT <= 1 THEN
  
    DELETE FROM CRAFT_ORD_DESIGN_ADD_ASK
     WHERE DESGIN_KEY = P_DESIGN_KEY_OLD
        OR DESGIN_KEY IN
           (SELECT DESGIN_KEY_BL
              FROM CRAFT_ORD_DESIGN_MSC_BL
             WHERE DESGIN_KEY = P_DESIGN_KEY_OLD)
        OR DESGIN_KEY IN
           (SELECT DESGIN_KEY_BL
              FROM CRAFT_ORD_DESIGN_MSC_JG_BL
             WHERE DESGIN_KEY = P_DESIGN_KEY_OLD);
    DELETE FROM CRAFT_ORD_DESIGN_MSC
     WHERE DESGIN_KEY = P_DESIGN_KEY_OLD
        OR DESGIN_KEY IN
           (SELECT DESGIN_KEY_BL
              FROM CRAFT_ORD_DESIGN_MSC_BL
             WHERE DESGIN_KEY = P_DESIGN_KEY_OLD)
        OR DESGIN_KEY IN
           (SELECT DESGIN_KEY_BL
              FROM CRAFT_ORD_DESIGN_MSC_JG_BL
             WHERE DESGIN_KEY = P_DESIGN_KEY_OLD);
    DELETE FROM CRAFT_ORD_DESIGN_MSC_BILT
     WHERE DESGIN_KEY = P_DESIGN_KEY_OLD
        OR DESGIN_KEY IN
           (SELECT DESGIN_KEY_BL
              FROM CRAFT_ORD_DESIGN_MSC_BL
             WHERE DESGIN_KEY = P_DESIGN_KEY_OLD)
        OR DESGIN_KEY IN
           (SELECT DESGIN_KEY_BL
              FROM CRAFT_ORD_DESIGN_MSC_JG_BL
             WHERE DESGIN_KEY = P_DESIGN_KEY_OLD);
    DELETE FROM CRAFT_ORD_DESIGN_MSC_BILT_C
     WHERE DESGIN_KEY = P_DESIGN_KEY_OLD
        OR DESGIN_KEY IN
           (SELECT DESGIN_KEY_BL
              FROM CRAFT_ORD_DESIGN_MSC_BL
             WHERE DESGIN_KEY = P_DESIGN_KEY_OLD)
        OR DESGIN_KEY IN
           (SELECT DESGIN_KEY_BL
              FROM CRAFT_ORD_DESIGN_MSC_JG_BL
             WHERE DESGIN_KEY = P_DESIGN_KEY_OLD);
    DELETE FROM CRAFT_ORD_DESIGN_MSC_BILT_C_PL
     WHERE DESGIN_KEY = P_DESIGN_KEY_OLD
        OR DESGIN_KEY IN
           (SELECT DESGIN_KEY_BL
              FROM CRAFT_ORD_DESIGN_MSC_BL
             WHERE DESGIN_KEY = P_DESIGN_KEY_OLD)
        OR DESGIN_KEY IN
           (SELECT DESGIN_KEY_BL
              FROM CRAFT_ORD_DESIGN_MSC_JG_BL
             WHERE DESGIN_KEY = P_DESIGN_KEY_OLD);
    DELETE FROM CRAFT_ORD_DESIGN_MSC_BILT_PL
     WHERE DESGIN_KEY = P_DESIGN_KEY_OLD
        OR DESGIN_KEY IN
           (SELECT DESGIN_KEY_BL
              FROM CRAFT_ORD_DESIGN_MSC_BL
             WHERE DESGIN_KEY = P_DESIGN_KEY_OLD)
        OR DESGIN_KEY IN
           (SELECT DESGIN_KEY_BL
              FROM CRAFT_ORD_DESIGN_MSC_JG_BL
             WHERE DESGIN_KEY = P_DESIGN_KEY_OLD);
    DELETE FROM CRAFT_ORD_DESIGN_MSC_GZ_GG
     WHERE DESGIN_KEY = P_DESIGN_KEY_OLD
        OR DESGIN_KEY IN
           (SELECT DESGIN_KEY_BL
              FROM CRAFT_ORD_DESIGN_MSC_BL
             WHERE DESGIN_KEY = P_DESIGN_KEY_OLD)
        OR DESGIN_KEY IN
           (SELECT DESGIN_KEY_BL
              FROM CRAFT_ORD_DESIGN_MSC_JG_BL
             WHERE DESGIN_KEY = P_DESIGN_KEY_OLD);
    DELETE FROM CRAFT_ORD_DESIGN_MSC_GZ_GG_PL
     WHERE DESGIN_KEY = P_DESIGN_KEY_OLD
        OR DESGIN_KEY IN
           (SELECT DESGIN_KEY_BL
              FROM CRAFT_ORD_DESIGN_MSC_BL
             WHERE DESGIN_KEY = P_DESIGN_KEY_OLD)
        OR DESGIN_KEY IN
           (SELECT DESGIN_KEY_BL
              FROM CRAFT_ORD_DESIGN_MSC_JG_BL
             WHERE DESGIN_KEY = P_DESIGN_KEY_OLD);
    DELETE FROM CRAFT_ORD_DESIGN_MSC_JG
     WHERE DESGIN_KEY = P_DESIGN_KEY_OLD;
    DELETE FROM CRAFT_ORD_DESIGN_MSC_JG_PL
     WHERE DESGIN_KEY = P_DESIGN_KEY_OLD
        OR DESGIN_KEY IN
           (SELECT DESGIN_KEY_BL
              FROM CRAFT_ORD_DESIGN_MSC_BL
             WHERE DESGIN_KEY = P_DESIGN_KEY_OLD)
        OR DESGIN_KEY IN
           (SELECT DESGIN_KEY_BL
              FROM CRAFT_ORD_DESIGN_MSC_JG_BL
             WHERE DESGIN_KEY = P_DESIGN_KEY_OLD);
    DELETE FROM CRAFT_ORD_DESIGN_MSC_JG_PL_STI
     WHERE DESGIN_KEY = P_DESIGN_KEY_OLD
        OR DESGIN_KEY IN
           (SELECT DESGIN_KEY_BL
              FROM CRAFT_ORD_DESIGN_MSC_BL
             WHERE DESGIN_KEY = P_DESIGN_KEY_OLD)
        OR DESGIN_KEY IN
           (SELECT DESGIN_KEY_BL
              FROM CRAFT_ORD_DESIGN_MSC_JG_BL
             WHERE DESGIN_KEY = P_DESIGN_KEY_OLD);
    DELETE FROM CRAFT_ORD_DESIGN_MSC_PL
     WHERE DESGIN_KEY = P_DESIGN_KEY_OLD
        OR DESGIN_KEY IN
           (SELECT DESGIN_KEY_BL
              FROM CRAFT_ORD_DESIGN_MSC_BL
             WHERE DESGIN_KEY = P_DESIGN_KEY_OLD)
        OR DESGIN_KEY IN
           (SELECT DESGIN_KEY_BL
              FROM CRAFT_ORD_DESIGN_MSC_JG_BL
             WHERE DESGIN_KEY = P_DESIGN_KEY_OLD);
    DELETE FROM CRAFT_ORD_DESIGN_MSC_PL_GX_PRL
     WHERE DESGIN_KEY = P_DESIGN_KEY_OLD
        OR DESGIN_KEY IN
           (SELECT DESGIN_KEY_BL
              FROM CRAFT_ORD_DESIGN_MSC_BL
             WHERE DESGIN_KEY = P_DESIGN_KEY_OLD)
        OR DESGIN_KEY IN
           (SELECT DESGIN_KEY_BL
              FROM CRAFT_ORD_DESIGN_MSC_JG_BL
             WHERE DESGIN_KEY = P_DESIGN_KEY_OLD);
    DELETE FROM CRAFT_ORD_DESIGN_MSC_PL_GZ
     WHERE DESGIN_KEY = P_DESIGN_KEY_OLD
        OR DESGIN_KEY IN
           (SELECT DESGIN_KEY_BL
              FROM CRAFT_ORD_DESIGN_MSC_BL
             WHERE DESGIN_KEY = P_DESIGN_KEY_OLD)
        OR DESGIN_KEY IN
           (SELECT DESGIN_KEY_BL
              FROM CRAFT_ORD_DESIGN_MSC_JG_BL
             WHERE DESGIN_KEY = P_DESIGN_KEY_OLD);
    DELETE FROM CRAFT_ORD_DESIGN_MSC_PL_PC
     WHERE DESGIN_KEY = P_DESIGN_KEY_OLD
        OR DESGIN_KEY IN
           (SELECT DESGIN_KEY_BL
              FROM CRAFT_ORD_DESIGN_MSC_BL
             WHERE DESGIN_KEY = P_DESIGN_KEY_OLD)
        OR DESGIN_KEY IN
           (SELECT DESGIN_KEY_BL
              FROM CRAFT_ORD_DESIGN_MSC_JG_BL
             WHERE DESGIN_KEY = P_DESIGN_KEY_OLD);
    DELETE FROM CRAFT_ORD_DESIGN_MSC_PL_PC_LST
     WHERE DESGIN_KEY = P_DESIGN_KEY_OLD
        OR DESGIN_KEY IN
           (SELECT DESGIN_KEY_BL
              FROM CRAFT_ORD_DESIGN_MSC_BL
             WHERE DESGIN_KEY = P_DESIGN_KEY_OLD)
        OR DESGIN_KEY IN
           (SELECT DESGIN_KEY_BL
              FROM CRAFT_ORD_DESIGN_MSC_JG_BL
             WHERE DESGIN_KEY = P_DESIGN_KEY_OLD);
    DELETE FROM CRAFT_ORD_DESIGN_MSC_PL_PRC
     WHERE DESGIN_KEY = P_DESIGN_KEY_OLD
        OR DESGIN_KEY IN
           (SELECT DESGIN_KEY_BL
              FROM CRAFT_ORD_DESIGN_MSC_BL
             WHERE DESGIN_KEY = P_DESIGN_KEY_OLD)
        OR DESGIN_KEY IN
           (SELECT DESGIN_KEY_BL
              FROM CRAFT_ORD_DESIGN_MSC_JG_BL
             WHERE DESGIN_KEY = P_DESIGN_KEY_OLD);
    DELETE FROM CRAFT_ORD_DESIGN_MSC_PL_STI
     WHERE DESGIN_KEY = P_DESIGN_KEY_OLD
        OR DESGIN_KEY IN
           (SELECT DESGIN_KEY_BL
              FROM CRAFT_ORD_DESIGN_MSC_BL
             WHERE DESGIN_KEY = P_DESIGN_KEY_OLD)
        OR DESGIN_KEY IN
           (SELECT DESGIN_KEY_BL
              FROM CRAFT_ORD_DESIGN_MSC_JG_BL
             WHERE DESGIN_KEY = P_DESIGN_KEY_OLD);
    DELETE FROM CRAFT_ORD_DESIGN_MSC_PL_STI_TC
     WHERE DESGIN_KEY = P_DESIGN_KEY_OLD
        OR DESGIN_KEY IN
           (SELECT DESGIN_KEY_BL
              FROM CRAFT_ORD_DESIGN_MSC_BL
             WHERE DESGIN_KEY = P_DESIGN_KEY_OLD)
        OR DESGIN_KEY IN
           (SELECT DESGIN_KEY_BL
              FROM CRAFT_ORD_DESIGN_MSC_JG_BL
             WHERE DESGIN_KEY = P_DESIGN_KEY_OLD);
    DELETE FROM CRAFT_ORD_DESIGN_STD
     WHERE DESGIN_KEY = P_DESIGN_KEY_OLD
        OR DESGIN_KEY IN
           (SELECT DESGIN_KEY_BL
              FROM CRAFT_ORD_DESIGN_MSC_BL
             WHERE DESGIN_KEY = P_DESIGN_KEY_OLD)
        OR DESGIN_KEY IN
           (SELECT DESGIN_KEY_BL
              FROM CRAFT_ORD_DESIGN_MSC_JG_BL
             WHERE DESGIN_KEY = P_DESIGN_KEY_OLD);
    DELETE FROM CRAFT_ORD_DESIGN_STD_CIC
     WHERE DESGIN_KEY = P_DESIGN_KEY_OLD
        OR DESGIN_KEY IN
           (SELECT DESGIN_KEY_BL
              FROM CRAFT_ORD_DESIGN_MSC_BL
             WHERE DESGIN_KEY = P_DESIGN_KEY_OLD)
        OR DESGIN_KEY IN
           (SELECT DESGIN_KEY_BL
              FROM CRAFT_ORD_DESIGN_MSC_JG_BL
             WHERE DESGIN_KEY = P_DESIGN_KEY_OLD);
    DELETE FROM CRAFT_ORD_DESIGN_STD_DIC
     WHERE DESGIN_KEY = P_DESIGN_KEY_OLD
        OR DESGIN_KEY IN
           (SELECT DESGIN_KEY_BL
              FROM CRAFT_ORD_DESIGN_MSC_BL
             WHERE DESGIN_KEY = P_DESIGN_KEY_OLD)
        OR DESGIN_KEY IN
           (SELECT DESGIN_KEY_BL
              FROM CRAFT_ORD_DESIGN_MSC_JG_BL
             WHERE DESGIN_KEY = P_DESIGN_KEY_OLD);
    DELETE FROM CRAFT_ORD_DESIGN_STD_GIC
     WHERE DESGIN_KEY = P_DESIGN_KEY_OLD
        OR DESGIN_KEY IN
           (SELECT DESGIN_KEY_BL
              FROM CRAFT_ORD_DESIGN_MSC_BL
             WHERE DESGIN_KEY = P_DESIGN_KEY_OLD)
        OR DESGIN_KEY IN
           (SELECT DESGIN_KEY_BL
              FROM CRAFT_ORD_DESIGN_MSC_JG_BL
             WHERE DESGIN_KEY = P_DESIGN_KEY_OLD);
    DELETE FROM CRAFT_ORD_DESIGN_STD_PIC
     WHERE DESGIN_KEY = P_DESIGN_KEY_OLD
        OR DESGIN_KEY IN
           (SELECT DESGIN_KEY_BL
              FROM CRAFT_ORD_DESIGN_MSC_BL
             WHERE DESGIN_KEY = P_DESIGN_KEY_OLD)
        OR DESGIN_KEY IN
           (SELECT DESGIN_KEY_BL
              FROM CRAFT_ORD_DESIGN_MSC_JG_BL
             WHERE DESGIN_KEY = P_DESIGN_KEY_OLD);
    DELETE FROM CRAFT_ORD_DESIGN_STD_PIC_SMP
     WHERE DESGIN_KEY = P_DESIGN_KEY_OLD
        OR DESGIN_KEY IN
           (SELECT DESGIN_KEY_BL
              FROM CRAFT_ORD_DESIGN_MSC_BL
             WHERE DESGIN_KEY = P_DESIGN_KEY_OLD)
        OR DESGIN_KEY IN
           (SELECT DESGIN_KEY_BL
              FROM CRAFT_ORD_DESIGN_MSC_JG_BL
             WHERE DESGIN_KEY = P_DESIGN_KEY_OLD);
    DELETE FROM CRAFT_ORD_DESIGN_STD_SIC
     WHERE DESGIN_KEY = P_DESIGN_KEY_OLD
        OR DESGIN_KEY IN
           (SELECT DESGIN_KEY_BL
              FROM CRAFT_ORD_DESIGN_MSC_BL
             WHERE DESGIN_KEY = P_DESIGN_KEY_OLD)
        OR DESGIN_KEY IN
           (SELECT DESGIN_KEY_BL
              FROM CRAFT_ORD_DESIGN_MSC_JG_BL
             WHERE DESGIN_KEY = P_DESIGN_KEY_OLD);
    DELETE FROM CRAFT_ORD_DESIGN_STD_WIC
     WHERE DESGIN_KEY = P_DESIGN_KEY_OLD
        OR DESGIN_KEY IN
           (SELECT DESGIN_KEY_BL
              FROM CRAFT_ORD_DESIGN_MSC_BL
             WHERE DESGIN_KEY = P_DESIGN_KEY_OLD)
        OR DESGIN_KEY IN
           (SELECT DESGIN_KEY_BL
              FROM CRAFT_ORD_DESIGN_MSC_JG_BL
             WHERE DESGIN_KEY = P_DESIGN_KEY_OLD);
    DELETE FROM SLM_ORD_DESIGN_STD_BIAS_C
     WHERE DESGIN_KEY = P_DESIGN_KEY_OLD
        OR DESGIN_KEY IN
           (SELECT DESGIN_KEY_BL
              FROM CRAFT_ORD_DESIGN_MSC_BL
             WHERE DESGIN_KEY = P_DESIGN_KEY_OLD)
        OR DESGIN_KEY IN
           (SELECT DESGIN_KEY_BL
              FROM CRAFT_ORD_DESIGN_MSC_JG_BL
             WHERE DESGIN_KEY = P_DESIGN_KEY_OLD);
    DELETE FROM CRAFT_ORD_DESIGN_STS_PL_PC
     WHERE DESGIN_KEY = P_DESIGN_KEY_OLD
        OR DESGIN_KEY IN
           (SELECT DESGIN_KEY_BL
              FROM CRAFT_ORD_DESIGN_MSC_BL
             WHERE DESGIN_KEY = P_DESIGN_KEY_OLD)
        OR DESGIN_KEY IN
           (SELECT DESGIN_KEY_BL
              FROM CRAFT_ORD_DESIGN_MSC_JG_BL
             WHERE DESGIN_KEY = P_DESIGN_KEY_OLD);
    DELETE FROM CRAFT_ORD_DESIGN_STS_PL_PC_LST
     WHERE DESGIN_KEY = P_DESIGN_KEY_OLD
        OR DESGIN_KEY IN
           (SELECT DESGIN_KEY_BL
              FROM CRAFT_ORD_DESIGN_MSC_BL
             WHERE DESGIN_KEY = P_DESIGN_KEY_OLD)
        OR DESGIN_KEY IN
           (SELECT DESGIN_KEY_BL
              FROM CRAFT_ORD_DESIGN_MSC_JG_BL
             WHERE DESGIN_KEY = P_DESIGN_KEY_OLD);
    DELETE FROM CRAFT_ORD_DESIGN_STS_TKLG
     WHERE DESGIN_KEY = P_DESIGN_KEY_OLD
        OR DESGIN_KEY IN
           (SELECT DESGIN_KEY_BL
              FROM CRAFT_ORD_DESIGN_MSC_BL
             WHERE DESGIN_KEY = P_DESIGN_KEY_OLD)
        OR DESGIN_KEY IN
           (SELECT DESGIN_KEY_BL
              FROM CRAFT_ORD_DESIGN_MSC_JG_BL
             WHERE DESGIN_KEY = P_DESIGN_KEY_OLD);
    DELETE FROM CRAFT_ORD_DESIGN_STS_TKLG_LST
     WHERE DESGIN_KEY = P_DESIGN_KEY_OLD
        OR DESGIN_KEY IN
           (SELECT DESGIN_KEY_BL
              FROM CRAFT_ORD_DESIGN_MSC_BL
             WHERE DESGIN_KEY = P_DESIGN_KEY_OLD)
        OR DESGIN_KEY IN
           (SELECT DESGIN_KEY_BL
              FROM CRAFT_ORD_DESIGN_MSC_JG_BL
             WHERE DESGIN_KEY = P_DESIGN_KEY_OLD);
    DELETE FROM CRAFT_ORD_LINE_BOM
     WHERE DESGIN_KEY = P_DESIGN_KEY_OLD
        OR DESGIN_KEY IN
           (SELECT DESGIN_KEY_BL
              FROM CRAFT_ORD_DESIGN_MSC_BL
             WHERE DESGIN_KEY = P_DESIGN_KEY_OLD)
        OR DESGIN_KEY IN
           (SELECT DESGIN_KEY_BL
              FROM CRAFT_ORD_DESIGN_MSC_JG_BL
             WHERE DESGIN_KEY = P_DESIGN_KEY_OLD);
  
    DELETE FROM CRAFT_ORD_DESIGN_MSC_JG_BL
     WHERE DESGIN_KEY = P_DESIGN_KEY_OLD;
    DELETE FROM CRAFT_ORD_DESIGN_MSC_BL
     WHERE DESGIN_KEY = P_DESIGN_KEY_OLD;
  END IF;

  IF '#OPERATE_TYPE#' = '0' THEN
    INSERT INTO CRAFT_ORD_DESIGN
      (ORD_LN_PK,
       CRAFT_SEQ,
       CRAFT_NO,
       DESGIN_KEY,
       LOCK_FLAG,
       VALIDFLAG,
       CREATE_NAME,
       CREATE_TIME,
       QUALITY_FLAG)
    VALUES
      ('#ORD_LN_PK#',
       (SELECT NVL(MAX(CRAFT_SEQ), 0) + 1
          FROM CRAFT_ORD_DESIGN
         WHERE ORD_LN_PK = '#ORD_LN_PK#'),
       '',
       P_DESIGN_KEY_NEW,
       '1',
       '2',
       '#CREATE_NAME#',
       SYSDATE,
       '#QUALITY_FLAG#');
  ELSE
    UPDATE CRAFT_ORD_DESIGN
       SET DESGIN_KEY  = P_DESIGN_KEY_NEW,
           UPDATE_NAME = '#UPDATE_NAME#',
           UPDATE_TIME = SYSDATE
     WHERE ORD_LN_PK = '#ORD_LN_PK#'
       AND CRAFT_SEQ = (SELECT MAX(CRAFT_SEQ)
                          FROM CRAFT_ORD_DESIGN
                         WHERE ORD_LN_PK = '#ORD_LN_PK#');
  END IF;

  ---------------------附加要求

  ------------------附加要求差异项
  FOR V_ROW IN (SELECT *
                  FROM (SELECT ORD_ADD.ASK_ITME,
                               ORD_ADD.ASK_ITME_DESC,
                               ORD_ADD.ASK_SUB_ITME,
                               ORD_ADD.ASK_SUB_ITME_DESC,
                               ORD_ADD.ASK_SUB_ITME_VAL,
                               ORD_ADD.ASK_SUB_ITME_VAL_DESC
                          FROM SLM_ORDER_ADD_ASK ORD_ADD, SLM_ORDER_LINE T
                         WHERE T.ADD_ASK_NO = ORD_ADD.ADD_ASK_NO
                           AND T.ORD_LN_PK = '#ORD_LN_PK#'
                           AND ORD_ADD.ADD_ASK_TYPE IN ('1', '2')) A
                 ORDER BY A.ASK_ITME_DESC,
                          A.ASK_SUB_ITME_DESC,
                          A.ASK_SUB_ITME_VAL_DESC) LOOP
    IF P_ADD_ASK_DIFF IS NULL THEN
      P_ADD_ASK_DIFF := V_ROW.ASK_SUB_ITME_DESC ||
                        V_ROW.ASK_SUB_ITME_VAL_DESC;
    ELSE
      P_ADD_ASK_DIFF := P_ADD_ASK_DIFF || CHR(13) || CHR(10) ||
                        V_ROW.ASK_SUB_ITME_DESC ||
                        V_ROW.ASK_SUB_ITME_VAL_DESC;
    END IF;
  END LOOP;

  FOR V_ROW IN (SELECT *
                  FROM (SELECT ORD_ADD.ASK_ITME,
                               ORD_ADD.ASK_ITME_DESC,
                               ORD_ADD.ASK_SUB_ITME,
                               ORD_ADD.ASK_SUB_ITME_DESC,
                               ORD_ADD.ASK_SUB_ITME_VAL,
                               ORD_ADD.ASK_SUB_ITME_VAL_DESC
                          FROM SLM_ORDER_ADD_ASK ORD_ADD, SLM_ORDER_LINE T
                         WHERE T.ADD_ASK_NO = ORD_ADD.ADD_ASK_NO
                           AND T.ORD_LN_PK = '#ORD_LN_PK#'
                           AND ORD_ADD.VALIDFLAG = '1'
                           AND T.VALIDFLAG = '1'
                        UNION ALL
                        SELECT BAS_ADD.ASK_ITME,
                               BAS_ADD.ASK_ITME_DESC,
                               BAS_ADD.ASK_SUB_ITME,
                               BAS_ADD.ASK_SUB_ITME_DESC,
                               BAS_ADD.ASK_SUB_ITME_VAL,
                               BAS_ADD.ASK_SUB_ITME_VAL_DESC
                          FROM COM_BASE_ADDITIONAL BAS_ADD, SLM_ORDER_LINE T
                         WHERE T.STD_CODE = BAS_ADD.STD_CODE
                           AND T.ORD_LN_PK = '#ORD_LN_PK#'
                           AND T.VALIDFLAG = '1'
                           AND BAS_ADD.VALIDFLAG = '1'
                           AND NOT EXISTS
                         (SELECT 1
                                  FROM SLM_ORDER_ADD_ASK ORD_ADD,
                                       SLM_ORDER_LINE    T
                                 WHERE T.ADD_ASK_NO = ORD_ADD.ADD_ASK_NO
                                   AND T.ORD_LN_PK = '#ORD_LN_PK#'
                                   AND ORD_ADD.ASK_SUB_ITME =
                                       BAS_ADD.ASK_SUB_ITME
                                   AND ORD_ADD.VALIDFLAG = '1'
                                   AND T.VALIDFLAG = '1')) A
                 ORDER BY A.ASK_ITME_DESC,
                          A.ASK_SUB_ITME_DESC,
                          A.ASK_SUB_ITME_VAL_DESC) LOOP
    IF P_ADD_ASK_ALL IS NULL THEN
      P_ADD_ASK_ALL := V_ROW.ASK_SUB_ITME_DESC ||
                       V_ROW.ASK_SUB_ITME_VAL_DESC;
    ELSE
      P_ADD_ASK_ALL := P_ADD_ASK_ALL || CHR(13) || CHR(10) ||
                       V_ROW.ASK_SUB_ITME_DESC ||
                       V_ROW.ASK_SUB_ITME_VAL_DESC;
    END IF;
    INSERT INTO CRAFT_ORD_DESIGN_ADD_ASK
      (DESGIN_KEY,
       ASK_ITME,
       ASK_ITME_DESC,
       ASK_SUB_ITME,
       ASK_SUB_ITME_DESC,
       ASK_SUB_ITME_VAL,
       ASK_SUB_ITME_VAL_DESC,
       DESCRIPTION_ALL,
       DESCRIPTION_DIFF)
    VALUES
      (P_DESIGN_KEY_NEW,
       V_ROW.ASK_ITME,
       V_ROW.ASK_ITME_DESC,
       V_ROW.ASK_SUB_ITME,
       V_ROW.ASK_SUB_ITME_DESC,
       V_ROW.ASK_SUB_ITME_VAL,
       V_ROW.ASK_SUB_ITME_VAL_DESC,
       P_ADD_ASK_ALL,
       P_ADD_ASK_DIFF);
  END LOOP;

  INSERT INTO CRAFT_ORD_DESIGN_MSC
    (DESGIN_KEY,
     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,
     PRD_LEN,
     LOSS_RATE,
     VALIDFLAG,
     CREATE_NAME,
     CREATE_TIME,
     UPDATE_NAME,
     UPDATE_TIME,
     DELETE_NAME,
     DELETE_TIME,
     ORD_LN_PK_OLD)
    (SELECT P_DESIGN_KEY_NEW,
            T.ORD_PK,
            T.ORD_LN_PK,
            T.ORDER_SEQ,
            T.CUST_ALPHA_NO,
            T.PSC,
            T.PSC_DESC,
            T.MSC,
            T.MSC_DESC,
            T.MSC_STYLE,
            T.USE_CODE,
            T.USE_DESC,
            T.PRD_CLS,
            T.PRODUCCODE,
            T.PRODUCNAME,
            T.STD_CODE,
            T.STD_NAME,
            T.STEELCODE,
            T.STEELNAME,
            T.STD_STYLE,
            T.STD_STYLE_DESC,
            T.ORDER_SPEC_CODE,
            T.ORDER_SPEC_DESC,
            T.SPEC_CODE,
            T.SPEC_NAME,
            T.DIMATER,
            T.HEIGHT,
            T.MODEL_CODE,
            T.MODEL_DESC,
            T.LEN_NO,
            T.LEN_DESC,
            T.LEN_UNIT,
            T.LEN_MIN,
            T.LEN_MAX,
            T.SHRT_LEN_RATO,
            T.SHORTEST,
            T.LONG_LEN_RATO,
            T.LONGEST,
            T.SHRT_STOVE,
            T.AVG_LEN_MIN,
            T.DIFRNC_LEN_MAX,
            T.ENDLEN_SPECSTD,
            T.SIGL_LEN,
            T.ORDER_UNIT,
            T.ORDER_QTY,
            T.ORD_ENSU_TOTL_LEN,
            T.PRDCT_WGT,
            T.DELVRY_RANGE_TPE,
            T.DELVRY_RANGE_MIN,
            T.DELVRY_RANGE_MAX,
            T.FINAL_USER,
            T.FINAL_USER_DESC,
            T.OUTS_BILLET_FL,
            T.OUTS_STL_PIPE_FL,
            T.ASSEL_FL,
            T.PRODUCER_FL,
            T.PRDCR_NO,
            T.PRDCR_DESC,
            T.MPS_FL,
            T.MPS_NO,
            T.MPS_DESC,
            T.DELVRY_BDATE,
            T.DELVRY_EDATE,
            T.DELVRY_DESC,
            T.TRANS_DESC,
            T.ADD_ASK_NO,
            T.ORDER_ADD_DESC,
            T.ORDER_SPECIAL_FL,
            T.ORDER_SPECIAL_HEAD,
            T.ORDER_SPECIAL_PATH,
            T.ORDER_SPECIAL_DESC,
            T.ZBS,
            T.ORDER_PRICE,
            T.TRANS_PRICE,
            T.TEST_ID,
            T.TEST_PRICE,
            T.OUT_PRICE,
            T.BALNCE_PRICE,
            T.BE_ORDER_LN_STATUS,
            T.BE_OBJ_STS_OP,
            T.ORDER_LN_STATUS,
            T.OBJ_STS_OP,
            T.MEMO,
            T.PRD_LEN,
            T.LOSS_RATE,
            T.VALIDFLAG,
            T.CREATE_NAME,
            T.CREATE_TIME,
            T.UPDATE_NAME,
            T.UPDATE_TIME,
            T.DELETE_NAME,
            T.DELETE_TIME,
            T.ORD_LN_PK_OLD
       FROM SLM_ORD_DESIGN_MSC T
      WHERE T.DESGIN_KEY = P_DESIGN_KEY);

  INSERT INTO CRAFT_ORD_DESIGN_MSC_BILT
    (DESGIN_KEY, MSC_PLINE, SPEC_CODE, B_SPEC_CODE, B_SPEC_NAME)
    (SELECT P_DESIGN_KEY_NEW,
            T.MSC_PLINE,
            T.SPEC_CODE,
            T.B_SPEC_CODE,
            T.B_SPEC_NAME
       FROM SLM_ORD_DESIGN_MSC_BILT T
      WHERE T.DESGIN_KEY = P_DESIGN_KEY);

  INSERT INTO CRAFT_ORD_DESIGN_MSC_BILT_C
    (DESGIN_KEY,
     MSC_PLINE,
     SPEC_CODE,
     B_SPEC_CODE,
     C_SPEC_CODE,
     C_SPEC_NAME,
     SPEC_CODE_S)
    (SELECT P_DESIGN_KEY_NEW,
            T.MSC_PLINE,
            T.SPEC_CODE,
            T.B_SPEC_CODE,
            T.C_SPEC_CODE,
            T.C_SPEC_NAME,
            T.SPEC_CODE_S
       FROM SLM_ORD_DESIGN_MSC_BILT_C T
      WHERE T.DESGIN_KEY = P_DESIGN_KEY);

  INSERT INTO CRAFT_ORD_DESIGN_MSC_BILT_C_PL
    (DESGIN_KEY, MSC_PLINE, C_SPEC_CODE, PLINE_CODE, PLINE_NAME)
    (SELECT P_DESIGN_KEY_NEW,
            T.MSC_PLINE,
            T.C_SPEC_CODE,
            T.PLINE_CODE,
            T.PLINE_NAME
       FROM SLM_ORD_DESIGN_MSC_BILT_C_PL T
      WHERE T.DESGIN_KEY = P_DESIGN_KEY);

  INSERT INTO CRAFT_ORD_DESIGN_MSC_BILT_PL
    (DESGIN_KEY, MSC_PLINE, B_SPEC_CODE, PLINE_CODE, PLINE_NAME)
    (SELECT P_DESIGN_KEY_NEW,
            T.MSC_PLINE,
            T.B_SPEC_CODE,
            T.PLINE_CODE,
            T.PLINE_NAME
       FROM SLM_ORD_DESIGN_MSC_BILT_PL T
      WHERE T.DESGIN_KEY = P_DESIGN_KEY);

  INSERT INTO CRAFT_ORD_DESIGN_MSC_GZ_GG
    (DESGIN_KEY,
     MSC_PLINE,
     GRADECODE,
     GRADENAME,
     SPEC_CODE,
     SPEC_NAME,
     DIMATER,
     HEIGHT)
    (SELECT P_DESIGN_KEY_NEW,
            T.MSC_PLINE,
            T.GRADECODE,
            T.GRADENAME,
            T.SPEC_CODE,
            T.SPEC_NAME,
            T.DIMATER,
            T.HEIGHT
       FROM SLM_ORD_DESIGN_MSC_GZ_GG T
      WHERE T.DESGIN_KEY = P_DESIGN_KEY);

  INSERT INTO CRAFT_ORD_DESIGN_MSC_GZ_GG_PL
    (DESGIN_KEY,
     MSC_PLINE,
     SPEC_CODE,
     PLINE_CODE,
     PLINE_NAME,
     PRD_LEN,
     LOSS_RATE,
     IS_OUTPUT)
    (SELECT P_DESIGN_KEY_NEW,
            T.MSC_PLINE,
            T.SPEC_CODE,
            T.PLINE_CODE,
            T.PLINE_NAME,
            T.PRD_LEN,
            T.LOSS_RATE,
            T.IS_OUTPUT
       FROM SLM_ORD_DESIGN_MSC_GZ_GG_PL T
      WHERE T.DESGIN_KEY = P_DESIGN_KEY);

  INSERT INTO CRAFT_ORD_DESIGN_MSC_JG
    (DESGIN_KEY,
     CODE_JG,
     DEMAND_DETECTION,
     DEMAND_BONDERIZING,
     DEMAND_COPPER,
     DEMAND_BLAST,
     PRODUCCODE,
     PRODUCNAME,
     STEELCODE,
     STEELNAME,
     MIN_H,
     MAX_H,
     MIN_D,
     MAX_D,
     SET_JG,
     CUST_ALPHA_NO,
     KEY_JG,
     ORDER_SPECIAL_DESC)
    (SELECT P_DESIGN_KEY_NEW,
            T.CODE_JG,
            T.DEMAND_DETECTION,
            T.DEMAND_BONDERIZING,
            T.DEMAND_COPPER,
            T.DEMAND_BLAST,
            T.PRODUCCODE,
            T.PRODUCNAME,
            T.STEELCODE,
            T.STEELNAME,
            T.MIN_H,
            T.MAX_H,
            T.MIN_D,
            T.MAX_D,
            T.SET_JG,
            T.CUST_ALPHA_NO,
            T.KEY_JG,
            T.ORDER_SPECIAL_DESC
       FROM SLM_ORD_DESIGN_MSC_JG T
      WHERE T.DESGIN_KEY = P_DESIGN_KEY);

  INSERT INTO CRAFT_ORD_DESIGN_MSC_JG_PL
    (DESGIN_KEY,
     CODE_JG,
     MSC_PLINE,
     WHOLE_BACKLOG,
     WHOLE_BACKLOG_DESC,
     SET_FL,
     WARN_DESC,
     ORD_LN_PK)
    (SELECT P_DESIGN_KEY_NEW,
            T.CODE_JG,
            T.MSC_PLINE,
            T.WHOLE_BACKLOG,
            T.WHOLE_BACKLOG_DESC,
            T.SET_FL,
            T.WARN_DESC,
            T.ORD_LN_PK
       FROM SLM_ORD_DESIGN_MSC_JG_PL T
      WHERE T.DESGIN_KEY = P_DESIGN_KEY);

  INSERT INTO CRAFT_ORD_DESIGN_MSC_JG_PL_STI
    (DESGIN_KEY,
     CODE_JG,
     MSC_PLINE,
     WHOLE_BACKLOG,
     WHOLE_BACKLOG_DESC,
     BACKLOG_SEQ,
     PROCESS_CODE,
     PROCESS_DESC,
     PROCESS_SEQ,
     PROCESS_CODE_C,
     PROCESS_DESC_C,
     STATION_ID,
     STATION_CODE,
     STATION_DESC,
     STATION_TYPE)
    (SELECT P_DESIGN_KEY_NEW,
            T.CODE_JG,
            T.MSC_PLINE,
            T.WHOLE_BACKLOG,
            T.WHOLE_BACKLOG_DESC,
            T.BACKLOG_SEQ,
            T.PROCESS_CODE,
            T.PROCESS_DESC,
            T.PROCESS_SEQ,
            T.PROCESS_CODE_C,
            T.PROCESS_DESC_C,
            T.STATION_ID,
            T.STATION_CODE,
            T.STATION_DESC,
            T.STATION_TYPE
       FROM SLM_ORD_DESIGN_MSC_JG_PL_STI T
      WHERE T.DESGIN_KEY = P_DESIGN_KEY);

  INSERT INTO CRAFT_ORD_DESIGN_MSC_PL
    (DESGIN_KEY,
     MSC_PLINE,
     WHOLE_BACKLOG,
     WHOLE_BACKLOG_DESC,
     SET_FL,
     WARN_DESC,
     ORD_LN_PK)
    (SELECT P_DESIGN_KEY_NEW,
            T.MSC_PLINE,
            T.WHOLE_BACKLOG,
            T.WHOLE_BACKLOG_DESC,
            T.SET_FL,
            T.WARN_DESC,
            T.ORD_LN_PK
       FROM SLM_ORD_DESIGN_MSC_PL T
      WHERE T.DESGIN_KEY = P_DESIGN_KEY);

  INSERT INTO CRAFT_ORD_DESIGN_MSC_PL_GX_PRL
    (DESGIN_KEY,
     MSC_PLINE,
     BACKLOG_SEQ,
     PROCESS_CODE,
     PLINE_CODE,
     PLINE_NAME,
     WELL_CODE,
     WELL_NAME,
     WARN_FL,
     WARN_DESC,
     VALIDFLAG,
     IDENT_FLAG)
    (SELECT P_DESIGN_KEY_NEW,
            T.MSC_PLINE,
            T.BACKLOG_SEQ,
            T.PROCESS_CODE,
            T.PLINE_CODE,
            T.PLINE_NAME,
            T.WELL_CODE,
            T.WELL_NAME,
            T.WARN_FL,
            T.WARN_DESC,
            T.VALIDFLAG,
            T.IDENT_FLAG
       FROM SLM_ORD_DESIGN_MSC_PL_GX_PRL T
      WHERE T.DESGIN_KEY = P_DESIGN_KEY);

  INSERT INTO CRAFT_ORD_DESIGN_MSC_PL_GZ
    (DESGIN_KEY,
     MSC_PLINE,
     WHOLE_BACKLOG,
     WHOLE_BACKLOG_DESC,
     GRADECODE,
     GRADENAME,
     ASSORTMENT_CODE,
     ASSORTMENT_NAME)
    (SELECT P_DESIGN_KEY_NEW,
            T.MSC_PLINE,
            T.WHOLE_BACKLOG,
            T.WHOLE_BACKLOG_DESC,
            T.GRADECODE,
            T.GRADENAME,
            T.ASSORTMENT_CODE,
            T.ASSORTMENT_NAME
       FROM SLM_ORD_DESIGN_MSC_PL_GZ T
      WHERE T.DESGIN_KEY = P_DESIGN_KEY);

  INSERT INTO CRAFT_ORD_DESIGN_MSC_PL_PC
    (DESGIN_KEY,
     ORD_LN_DLY_PK,
     MSC_PLINE,
     DELVRY_EDATE,
     DELVRY_QTY,
     ORDER_UNIT,
     RECEIV_NO,
     RECEIV_NM,
     RCMD_DELVRY_EDATE,
     PRD_CYC,
     PRD_CYC_BTCH,
     N_MATERIAL_FL,
     CYC_EDIT,
     CREATE_NAME,
     CREATE_TIME,
     UPDATE_NAME,
     UPDATE_TIME)
    (SELECT P_DESIGN_KEY_NEW,
            T.ORD_LN_DLY_PK,
            T.MSC_PLINE,
            T.DELVRY_EDATE,
            T.DELVRY_QTY,
            T.ORDER_UNIT,
            T.RECEIV_NO,
            T.RECEIV_NM,
            T.RCMD_DELVRY_EDATE,
            T.PRD_CYC,
            T.PRD_CYC_BTCH,
            T.N_MATERIAL_FL,
            T.CYC_EDIT,
            T.CREATE_NAME,
            T.CREATE_TIME,
            T.UPDATE_NAME,
            T.UPDATE_TIME
       FROM SLM_ORD_DESIGN_MSC_PL_PC T
      WHERE T.DESGIN_KEY = P_DESIGN_KEY);

  INSERT INTO CRAFT_ORD_DESIGN_MSC_PL_PC_LST
    (DESGIN_KEY,
     ORD_LN_DLY_PK,
     MSC_PLINE,
     BACKLOG_SEQ,
     PROCESS_CODE,
     PROCESS_DESC,
     REVIEW_ASK,
     LST_PRD_DATE,
     PRD_CYC,
     PRD_CYC_BTCH)
    (SELECT P_DESIGN_KEY_NEW,
            T.ORD_LN_DLY_PK,
            T.MSC_PLINE,
            T.BACKLOG_SEQ,
            T.PROCESS_CODE,
            T.PROCESS_DESC,
            T.REVIEW_ASK,
            T.LST_PRD_DATE,
            T.PRD_CYC,
            T.PRD_CYC_BTCH
       FROM SLM_ORD_DESIGN_MSC_PL_PC_LST T
      WHERE T.DESGIN_KEY = P_DESIGN_KEY);

  INSERT INTO CRAFT_ORD_DESIGN_MSC_PL_PRC
    (DESGIN_KEY,
     MSC_PLINE,
     WHOLE_BACKLOG,
     WHOLE_BACKLOG_DESC,
     BACKLOG_SEQ,
     PROCESS_CODE,
     PROCESS_DESC,
     PROCESS_SEQ,
     PROCESS_CODE_C,
     PROCESS_DESC_C,
     MINUTE_PRODUCT,
     MINUTE_PRODUCT_OUT,
     MINUTE_WAITE,
     MINUTE_WAITE_OUT,
     BATCH_WAITE,
     BATCH_WAITE_OUT,
     CIC,
     PIC,
     SIC,
     DIC,
     WIC,
     GIC)
    (SELECT P_DESIGN_KEY_NEW,
            T.MSC_PLINE,
            T.WHOLE_BACKLOG,
            T.WHOLE_BACKLOG_DESC,
            T.BACKLOG_SEQ,
            T.PROCESS_CODE,
            T.PROCESS_DESC,
            T.PROCESS_SEQ,
            T.PROCESS_CODE_C,
            T.PROCESS_DESC_C,
            T.MINUTE_PRODUCT,
            T.MINUTE_PRODUCT_OUT,
            T.MINUTE_WAITE,
            T.MINUTE_WAITE_OUT,
            T.BATCH_WAITE,
            T.BATCH_WAITE_OUT,
            T.CIC,
            T.PIC,
            T.SIC,
            T.DIC,
            T.WIC,
            T.GIC
       FROM SLM_ORD_DESIGN_MSC_PL_PRC T
      WHERE T.DESGIN_KEY = P_DESIGN_KEY);

  INSERT INTO CRAFT_ORD_DESIGN_MSC_PL_STI
    (DESGIN_KEY,
     MSC_PLINE,
     WHOLE_BACKLOG,
     WHOLE_BACKLOG_DESC,
     BACKLOG_SEQ,
     PROCESS_CODE,
     PROCESS_DESC,
     PROCESS_SEQ,
     PROCESS_CODE_C,
     PROCESS_DESC_C,
     STATION_ID,
     STATION_CODE,
     STATION_DESC,
     STATION_TYPE,
     CRAFTITEM_CODE,
     CRAFTITEM_DESC)
    (SELECT P_DESIGN_KEY_NEW,
            T.MSC_PLINE,
            T.WHOLE_BACKLOG,
            T.WHOLE_BACKLOG_DESC,
            T.BACKLOG_SEQ,
            T.PROCESS_CODE,
            T.PROCESS_DESC,
            T.PROCESS_SEQ,
            T.PROCESS_CODE_C,
            T.PROCESS_DESC_C,
            T.STATION_ID,
            T.STATION_CODE,
            T.STATION_DESC,
            T.STATION_TYPE,
            T.CRAFTITEM_CODE,
            T.CRAFTITEM_DESC
       FROM SLM_ORD_DESIGN_MSC_PL_STI T
      WHERE T.DESGIN_KEY = P_DESIGN_KEY);

  INSERT INTO CRAFT_ORD_DESIGN_MSC_PL_STI_TC
    (DESGIN_KEY,
     ORD_PK,
     ORD_LN_PK,
     MSC_PLINE,
     WHOLE_BACKLOG,
     WHOLE_BACKLOG_DESC,
     BACKLOG_SEQ,
     PROCESS_CODE,
     PROCESS_DESC,
     PROCESS_SEQ,
     PROCESS_CODE_C,
     PROCESS_DESC_C,
     STATION_ID,
     STATION_CODE,
     STATION_DESC,
     STATION_TYPE,
     CRAFTITEM_CODE,
     CRAFTITEM_DESC)
    (SELECT P_DESIGN_KEY_NEW,
            T.ORD_PK,
            T.ORD_LN_PK,
            T.MSC_PLINE,
            T.WHOLE_BACKLOG,
            T.WHOLE_BACKLOG_DESC,
            T.BACKLOG_SEQ,
            T.PROCESS_CODE,
            T.PROCESS_DESC,
            T.PROCESS_SEQ,
            T.PROCESS_CODE_C,
            T.PROCESS_DESC_C,
            T.STATION_ID,
            T.STATION_CODE,
            T.STATION_DESC,
            T.STATION_TYPE,
            T.CRAFTITEM_CODE,
            T.CRAFTITEM_DESC
       FROM SLM_ORD_DESIGN_MSC_PL_STI_TC T
      WHERE T.DESGIN_KEY = P_DESIGN_KEY);

  INSERT INTO CRAFT_ORD_DESIGN_STD
    (DESGIN_KEY, CIC, PIC, SIC, DIC, WIC, GIC)
    (SELECT P_DESIGN_KEY_NEW, T.CIC, T.PIC, T.SIC, T.DIC, T.WIC, T.GIC
       FROM SLM_ORD_DESIGN_STD T
      WHERE T.DESGIN_KEY = P_DESIGN_KEY);

  INSERT INTO CRAFT_ORD_DESIGN_STD_CIC
    (DESGIN_KEY,
     CIC,
     USE_CODE,
     USE_DESC,
     SPECL_FL,
     INDEX_SEQ,
     CHEM_CODE,
     CHEM_NAME,
     CHEM_TYPE,
     CHEM_FORMULA,
     ISCHECK,
     ISJUDGE,
     ISQUOTE,
     COMPLEX_TYPE,
     STDMIN_SIGN,
     STDMIN,
     STDMAX_SIGN,
     STDMAX,
     STDTARGET,
     MODEL_CODE,
     MODEL_DESC,
     STDMEMO,
     ELE_CODE,
     ELE_NAME,
     ELE_MIN_SIGN,
     ELE_MIN,
     ELE_MAX_SIGN,
     ELE_MAX,
     SIZE_CODE2,
     SIZE_NAME2,
     SIZE_MIN_SIGN2,
     SIZE_MIN2,
     SIZE_MAX_SIGN2,
     SIZE_MAX2,
     SIZE_CODE,
     SIZE_NAME,
     SIZE_MIN_SIGN,
     SIZE_MIN,
     SIZE_MAX_SIGN,
     SIZE_MAX,
     SPEC_JG,
     SPEC_JG_DESC,
     VALIDFLAG,
     CREATE_NAME,
     CREATE_TIME,
     UPDATE_NAME,
     UPDATE_TIME,
     DELETE_NAME,
     DELETE_TIME,
     REP_CODE,
     REP_NAME,
     REP_MIN_SIGN,
     REP_MIN,
     REP_MAX_SIGN,
     REP_MAX,
     REP_VAL)
    (SELECT P_DESIGN_KEY_NEW,
            T.CIC,
            T.USE_CODE,
            T.USE_DESC,
            T.SPECL_FL,
            T.INDEX_SEQ,
            T.CHEM_CODE,
            T.CHEM_NAME,
            T.CHEM_TYPE,
            T.CHEM_FORMULA,
            T.ISCHECK,
            T.ISJUDGE,
            T.ISQUOTE,
            T.COMPLEX_TYPE,
            T.STDMIN_SIGN,
            T.STDMIN,
            T.STDMAX_SIGN,
            T.STDMAX,
            T.STDTARGET,
            T.MODEL_CODE,
            T.MODEL_DESC,
            T.STDMEMO,
            T.ELE_CODE,
            T.ELE_NAME,
            T.ELE_MIN_SIGN,
            T.ELE_MIN,
            T.ELE_MAX_SIGN,
            T.ELE_MAX,
            T.SIZE_CODE2,
            T.SIZE_NAME2,
            T.SIZE_MIN_SIGN2,
            T.SIZE_MIN2,
            T.SIZE_MAX_SIGN2,
            T.SIZE_MAX2,
            T.SIZE_CODE,
            T.SIZE_NAME,
            T.SIZE_MIN_SIGN,
            T.SIZE_MIN,
            T.SIZE_MAX_SIGN,
            T.SIZE_MAX,
            T.SPEC_JG,
            T.SPEC_JG_DESC,
            T.VALIDFLAG,
            T.CREATE_NAME,
            T.CREATE_TIME,
            T.UPDATE_NAME,
            T.UPDATE_TIME,
            T.DELETE_NAME,
            T.DELETE_TIME,
            T.REP_CODE,
            T.REP_NAME,
            T.REP_MIN_SIGN,
            T.REP_MIN,
            T.REP_MAX_SIGN,
            T.REP_MAX,
            T.REP_VAL
       FROM SLM_ORD_DESIGN_STD_CIC T
      WHERE T.DESGIN_KEY = P_DESIGN_KEY);

  INSERT INTO CRAFT_ORD_DESIGN_STD_DIC
    (DESGIN_KEY,
     DIC,
     USE_CODE,
     USE_DESC,
     SPECL_FL,
     XH,
     PHY_CODE,
     PHY_NAME,
     POSITION_CODE,
     POSITION_DESC,
     STD_DESC,
     LV_CODE,
     LV_DESC,
     GROOVE_POS,
     GROOVE_DIR,
     COVERAGE,
     RATE,
     DESC_RATE,
     DESC_VAL,
     GROUP_SEQ,
     MEMO,
     MIN_D,
     MAX_D,
     MIN_H,
     MAX_H)
    (SELECT P_DESIGN_KEY_NEW,
            T.DIC,
            T.USE_CODE,
            T.USE_DESC,
            T.SPECL_FL,
            T.XH,
            T.PHY_CODE,
            T.PHY_NAME,
            T.POSITION_CODE,
            T.POSITION_DESC,
            T.STD_DESC,
            T.LV_CODE,
            T.LV_DESC,
            T.GROOVE_POS,
            T.GROOVE_DIR,
            T.COVERAGE,
            T.RATE,
            T.DESC_RATE,
            T.DESC_VAL,
            T.GROUP_SEQ,
            T.MEMO,
            T.MIN_D,
            T.MAX_D,
            T.MIN_H,
            T.MAX_H
       FROM SLM_ORD_DESIGN_STD_DIC T
      WHERE T.DESGIN_KEY = P_DESIGN_KEY);

  INSERT INTO CRAFT_ORD_DESIGN_STD_GIC
    (DESGIN_KEY,
     GIC,
     USE_CODE,
     USE_DESC,
     SPECL_FL,
     XH,
     PROCESS_CDOE,
     PROCESS_DESC,
     PROCESS_CDOE_C,
     PROCESS_DESC_C,
     STATION_CODE,
     STATION_DESC,
     VALUE_TEXT,
     VALUE_NUM,
     VALUE_MEMO,
     GROUP_SEQ,
     MEMO)
    (SELECT P_DESIGN_KEY_NEW,
            T.GIC,
            T.USE_CODE,
            T.USE_DESC,
            T.SPECL_FL,
            T.XH,
            T.PROCESS_CDOE,
            T.PROCESS_DESC,
            T.PROCESS_CDOE_C,
            T.PROCESS_DESC_C,
            T.STATION_CODE,
            T.STATION_DESC,
            T.VALUE_TEXT,
            T.VALUE_NUM,
            T.VALUE_MEMO,
            T.GROUP_SEQ,
            T.MEMO
       FROM SLM_ORD_DESIGN_STD_GIC T
      WHERE T.DESGIN_KEY = P_DESIGN_KEY);

  INSERT INTO CRAFT_ORD_DESIGN_STD_PIC
    (DESGIN_KEY,
     PIC,
     USE_CODE,
     USE_DESC,
     SPECL_FL,
     INDEX_SEQ,
     PHY_CODE_MAX,
     PHY_NAME_MAX,
     PHY_CODE_MIN,
     PHY_NAME_MIN,
     PHY_CODE,
     PHY_NAME,
     ITEM_CODE_F,
     ITEM_NAME_F,
     ITEM_CODE_W,
     ITEM_NAME_W,
     ITEM_CODE_S,
     ITEM_NAME_S,
     GROUP_SEQ,
     ISCHECK,
     ISQUOTE,
     RESULT_COUNT,
     ISJUDGE,
     PHY_TYPE,
     PHY_FORMULA,
     STDMIN_SIGN,
     STDMIN,
     STDMAX_SIGN,
     STDMAX,
     JUDGE_BASIS,
     DELIVERYSTATE,
     MODEL_CODE,
     MODEL_DESC,
     STDMEMO,
     SIZE_CODE,
     SIZE_NAME,
     SIZE_MIN_SIGN,
     SIZE_MIN,
     SIZE_MAX_SIGN,
     SIZE_MAX,
     SIZE_CODE2,
     SIZE_NAME2,
     SIZE_MIN_SIGN2,
     SIZE_MIN2,
     SIZE_MAX_SIGN2,
     SIZE_MAX2,
     SPEC_JG,
     SPEC_JG_DESC,
     ADDCONDITION,
     ADDSTDCON_CODE,
     ADDSTD_MIN_SIGN,
     ADDSTD_MIN,
     ADDSTD_MAX_SIGN,
     ADDSTD_MAX,
     ADDPERCENT,
     STDMIN_SIGN2,
     STDMIN2,
     STDMAX_SIGN2,
     STDMAX2,
     STD_CHOOSE)
    (SELECT P_DESIGN_KEY_NEW,
            T.PIC,
            T.USE_CODE,
            T.USE_DESC,
            T.SPECL_FL,
            T.INDEX_SEQ,
            T.PHY_CODE_MAX,
            T.PHY_NAME_MAX,
            T.PHY_CODE_MIN,
            T.PHY_NAME_MIN,
            T.PHY_CODE,
            T.PHY_NAME,
            T.ITEM_CODE_F,
            T.ITEM_NAME_F,
            T.ITEM_CODE_W,
            T.ITEM_NAME_W,
            T.ITEM_CODE_S,
            T.ITEM_NAME_S,
            T.GROUP_SEQ,
            T.ISCHECK,
            T.ISQUOTE,
            T.RESULT_COUNT,
            T.ISJUDGE,
            T.PHY_TYPE,
            T.PHY_FORMULA,
            T.STDMIN_SIGN,
            T.STDMIN,
            T.STDMAX_SIGN,
            T.STDMAX,
            T.JUDGE_BASIS,
            T.DELIVERYSTATE,
            T.MODEL_CODE,
            T.MODEL_DESC,
            T.STDMEMO,
            T.SIZE_CODE,
            T.SIZE_NAME,
            T.SIZE_MIN_SIGN,
            T.SIZE_MIN,
            T.SIZE_MAX_SIGN,
            T.SIZE_MAX,
            T.SIZE_CODE2,
            T.SIZE_NAME2,
            T.SIZE_MIN_SIGN2,
            T.SIZE_MIN2,
            T.SIZE_MAX_SIGN2,
            T.SIZE_MAX2,
            T.SPEC_JG,
            T.SPEC_JG_DESC,
            T.ADDCONDITION,
            T.ADDSTDCON_CODE,
            T.ADDSTD_MIN_SIGN,
            T.ADDSTD_MIN,
            T.ADDSTD_MAX_SIGN,
            T.ADDSTD_MAX,
            T.ADDPERCENT,
            T.STDMIN_SIGN2,
            T.STDMIN2,
            T.STDMAX_SIGN2,
            T.STDMAX2,
            T.STD_CHOOSE
       FROM SLM_ORD_DESIGN_STD_PIC T
      WHERE T.DESGIN_KEY = P_DESIGN_KEY);

  INSERT INTO CRAFT_ORD_DESIGN_STD_PIC_SMP
    (DESGIN_KEY,
     PIC,
     SIC,
     PHY_CODE_MIN,
     PHY_NAME_MIN,
     STD_CODE,
     STD_NAME,
     LENGTH,
     DESC_LENGTH,
     RATE,
     DESC_RATE,
     DESC_COUNT,
     POSITION,
     DESC_POSITION,
     SAMPLE_COUNT,
     MEMO,
     SAMPLE_STYLE,
     BATCH_CNT,
     WIDTH,
     BATCH_UNIT,
     EIC,
     PHY_DIR,
     SIZE_DESC,
     SAMPLE_KEY,
     SAMPLE_KEY_DESC,
     ITEM_CODE_F,
     ITEM_CODE_C,
     ITEM_CODE_W,
     STD_CODE_TEST,
     STD_NAME_TEST)
    (SELECT P_DESIGN_KEY_NEW,
            T.PIC,
            T.SIC,
            T.PHY_CODE_MIN,
            T.PHY_NAME_MIN,
            T.STD_CODE,
            T.STD_NAME,
            T.LENGTH,
            T.DESC_LENGTH,
            T.RATE,
            T.DESC_RATE,
            T.DESC_COUNT,
            T.POSITION,
            T.DESC_POSITION,
            T.SAMPLE_COUNT,
            T.MEMO,
            T.SAMPLE_STYLE,
            T.BATCH_CNT,
            T.WIDTH,
            T.BATCH_UNIT,
            T.EIC,
            T.PHY_DIR,
            T.SIZE_DESC,
            T.SAMPLE_KEY,
            T.SAMPLE_KEY_DESC,
            T.ITEM_CODE_F,
            T.ITEM_CODE_C,
            T.ITEM_CODE_W,
            T.STD_CODE_TEST,
            T.STD_NAME_TEST
       FROM SLM_ORD_DESIGN_STD_PIC_SMP T
      WHERE T.DESGIN_KEY = P_DESIGN_KEY);

  INSERT INTO CRAFT_ORD_DESIGN_STD_SIC
    (DESGIN_KEY,
     SIC,
     USE_CODE,
     USE_DESC,
     SPECL_FL,
     INDEX_SEQ,
     BIAS_CODE,
     BIAS_NAME,
     LV,
     BIAS_CODE_Z,
     BIAS_NAME_Z,
     ZMIN_SIGN,
     ZMIN,
     ZMAX_SIGN,
     ZMAX,
     BIAS_CODE_C,
     BIAS_NAME_C,
     CMIN_SIGN,
     CMIN,
     CMAX_SIGN,
     CMAX,
     BIAS_CODE_S,
     BIAS_NAME_S,
     SMIN_SIGN,
     SMIN,
     SMAX_SIGN,
     SMAX,
     ISCHECK,
     STD_MIN_VAL,
     STD_MAX_VAL,
     STD_MIN_IN,
     STD_MAX_IN,
     STD_MIN_PERCENT,
     STD_MAX_PERCENT,
     STD_MIN_FORMULA,
     STD_MAX_FORMULA,
     STD_MIN_FORMULA_V,
     STD_MAX_FORMULA_V,
     STDMEMO)
    (SELECT P_DESIGN_KEY_NEW,
            T.SIC,
            T.USE_CODE,
            T.USE_DESC,
            T.SPECL_FL,
            T.INDEX_SEQ,
            T.BIAS_CODE,
            T.BIAS_NAME,
            T.LV,
            T.BIAS_CODE_Z,
            T.BIAS_NAME_Z,
            T.ZMIN_SIGN,
            T.ZMIN,
            T.ZMAX_SIGN,
            T.ZMAX,
            T.BIAS_CODE_C,
            T.BIAS_NAME_C,
            T.CMIN_SIGN,
            T.CMIN,
            T.CMAX_SIGN,
            T.CMAX,
            T.BIAS_CODE_S,
            T.BIAS_NAME_S,
            T.SMIN_SIGN,
            T.SMIN,
            T.SMAX_SIGN,
            T.SMAX,
            T.ISCHECK,
            T.STD_MIN_VAL,
            T.STD_MAX_VAL,
            T.STD_MIN_IN,
            T.STD_MAX_IN,
            T.STD_MIN_PERCENT,
            T.STD_MAX_PERCENT,
            T.STD_MIN_FORMULA,
            T.STD_MAX_FORMULA,
            T.STD_MIN_FORMULA_V,
            T.STD_MAX_FORMULA_V,
            T.STDMEMO
       FROM SLM_ORD_DESIGN_STD_SIC T
      WHERE T.DESGIN_KEY = P_DESIGN_KEY);

  INSERT INTO CRAFT_ORD_DESIGN_STD_WIC
    (DESGIN_KEY,
     WIC,
     USE_CODE,
     USE_DESC,
     SPECL_FL,
     INDEX_SEQ,
     PRESSURE_Y,
     PRESSURE,
     FORMULA,
     SAVE_TIME,
     GET_MAXVALUE,
     GET_MINVALUE,
     RATIO_STD,
     RATIO_REPLACE,
     MAX_PRESS)
    (SELECT P_DESIGN_KEY_NEW,
            T.WIC,
            T.USE_CODE,
            T.USE_DESC,
            T.SPECL_FL,
            T.INDEX_SEQ,
            T.PRESSURE_Y,
            T.PRESSURE,
            T.FORMULA,
            T.SAVE_TIME,
            T.GET_MAXVALUE,
            T.GET_MINVALUE,
            T.RATIO_STD,
            T.RATIO_REPLACE,
            T.MAX_PRESS
       FROM SLM_ORD_DESIGN_STD_WIC T
      WHERE T.DESGIN_KEY = P_DESIGN_KEY);

  INSERT INTO CRAFT_ORD_DESIGN_STD_BIAS_C
    (CIC,
     INDEX_SEQ,
     CHEM_CODE,
     CHEM_NAME,
     WHOLE_BACKLOG,
     CHEM_FORMULA,
     MIN_SIGN,
     MIN_VAL,
     MAX_SIGN,
     MAX_VAL,
     STD_MIN_SIGN,
     STD_MIN_VAL,
     STD_MAX_SIGN,
     STD_MAX_VAL,
     CREATE_NAME,
     CREATE_TIME,
     UPDATE_NAME,
     UPDATE_TIME,
     DELETE_NAME,
     DELETE_TIME,
     VALIDFLAG,
     DESGIN_KEY,
     SPECL_FL)
    (SELECT T.CIC,
            T.INDEX_SEQ,
            T.CHEM_CODE,
            T.CHEM_NAME,
            T.WHOLE_BACKLOG,
            T.CHEM_FORMULA,
            T.MIN_SIGN,
            T.MIN_VAL,
            T.MAX_SIGN,
            T.MAX_VAL,
            T.STD_MIN_SIGN,
            T.STD_MIN_VAL,
            T.STD_MAX_SIGN,
            T.STD_MAX_VAL,
            T.CREATE_NAME,
            T.CREATE_TIME,
            T.UPDATE_NAME,
            T.UPDATE_TIME,
            T.DELETE_NAME,
            T.DELETE_TIME,
            T.VALIDFLAG,
            P_DESIGN_KEY_NEW,
            T.SPECL_FL
       FROM SLM_ORD_DESIGN_STD_BIAS_C T
       WHERE T.DESGIN_KEY = P_DESIGN_KEY);

  INSERT INTO CRAFT_ORD_DESIGN_STS_PL_PC
    (DESGIN_KEY,
     ORD_LN_PK,
     ORD_LN_DLY_PK,
     MSC_PLINE,
     WHOLE_BACKLOG,
     WHOLE_BACKLOG_DESC,
     PRDCYC_MEET,
     VALIDFLAG,
     CREATE_NAME,
     CREATE_TIME,
     UPDATE_NAME,
     UPDATE_TIME,
     DELETE_NAME,
     DELETE_TIME)
    (SELECT P_DESIGN_KEY_NEW,
            T.ORD_LN_PK,
            T.ORD_LN_DLY_PK,
            T.MSC_PLINE,
            T.WHOLE_BACKLOG,
            T.WHOLE_BACKLOG_DESC,
            T.PRDCYC_MEET,
            T.VALIDFLAG,
            T.CREATE_NAME,
            T.CREATE_TIME,
            T.UPDATE_NAME,
            T.UPDATE_TIME,
            T.DELETE_NAME,
            T.DELETE_TIME
       FROM SLM_ORD_DESIGN_STS_PL_PC T
      WHERE T.DESGIN_KEY = P_DESIGN_KEY);

  INSERT INTO CRAFT_ORD_DESIGN_STS_PL_PC_LST
    (DESGIN_KEY,
     ORD_LN_PK,
     ORD_LN_DLY_PK,
     MSC_PLINE,
     WHOLE_BACKLOG,
     WHOLE_BACKLOG_DESC,
     PROCESS_CDOE,
     PROCESS_DESC,
     PRDCYC_MEET,
     VALIDFLAG,
     CREATE_NAME,
     CREATE_TIME,
     UPDATE_NAME,
     UPDATE_TIME,
     DELETE_NAME,
     DELETE_TIME)
    (SELECT P_DESIGN_KEY_NEW,
            T.ORD_LN_PK,
            T.ORD_LN_DLY_PK,
            T.MSC_PLINE,
            T.WHOLE_BACKLOG,
            T.WHOLE_BACKLOG_DESC,
            T.PROCESS_CDOE,
            T.PROCESS_DESC,
            T.PRDCYC_MEET,
            T.VALIDFLAG,
            T.CREATE_NAME,
            T.CREATE_TIME,
            T.UPDATE_NAME,
            T.UPDATE_TIME,
            T.DELETE_NAME,
            T.DELETE_TIME
       FROM SLM_ORD_DESIGN_STS_PL_PC_LST T
      WHERE T.DESGIN_KEY = P_DESIGN_KEY);

  INSERT INTO CRAFT_ORD_DESIGN_STS_TKLG
    (DESGIN_KEY,
     ORD_LN_PK,
     DESIGN_STS,
     PRDCYC_MEET,
     VALIDFLAG,
     CREATE_NAME,
     CREATE_TIME,
     UPDATE_NAME,
     UPDATE_TIME,
     DELETE_NAME,
     DELETE_TIME)
    (SELECT P_DESIGN_KEY_NEW,
            T.ORD_LN_PK,
            T.DESIGN_STS,
            T.PRDCYC_MEET,
            T.VALIDFLAG,
            T.CREATE_NAME,
            T.CREATE_TIME,
            T.UPDATE_NAME,
            T.UPDATE_TIME,
            T.DELETE_NAME,
            T.DELETE_TIME
       FROM SLM_ORD_DESIGN_STS_TKLG T
      WHERE T.DESGIN_KEY = P_DESIGN_KEY);

  INSERT INTO CRAFT_ORD_DESIGN_STS_TKLG_LST
    (DESGIN_KEY,
     ORD_LN_PK,
     SEQ_INDEX,
     LST_ITEM,
     DESIGN_STS,
     DESIGN_STS_RS,
     DESIGN_STS_DESC,
     PSC,
     MSC,
     USE_CODE,
     FINAL_USER,
     GRADECODE,
     DESIGN_OBJ_KEY,
     UNIT_CODE,
     UNIT_DESC,
     VALIDFLAG,
     CREATE_NAME,
     CREATE_TIME,
     UPDATE_NAME,
     UPDATE_TIME,
     DELETE_NAME,
     DELETE_TIME)
    (SELECT P_DESIGN_KEY_NEW,
            T.ORD_LN_PK,
            T.SEQ_INDEX,
            T.LST_ITEM,
            T.DESIGN_STS,
            T.DESIGN_STS_RS,
            T.DESIGN_STS_DESC,
            T.PSC,
            T.MSC,
            T.USE_CODE,
            T.FINAL_USER,
            T.GRADECODE,
            T.DESIGN_OBJ_KEY,
            T.UNIT_CODE,
            T.UNIT_DESC,
            T.VALIDFLAG,
            T.CREATE_NAME,
            T.CREATE_TIME,
            T.UPDATE_NAME,
            T.UPDATE_TIME,
            T.DELETE_NAME,
            T.DELETE_TIME
       FROM SLM_ORD_DESIGN_STS_TKLG_LST T
      WHERE T.DESGIN_KEY = P_DESIGN_KEY);
  DELETE FROM CRAFT_ORD_DESIGN_STS_TKLG_LST
   WHERE DESGIN_KEY = P_DESIGN_KEY_NEW
     AND LST_ITEM IN ('产品技术要求',
                      'MSC(n)',
                      '投入/产出物料',
                      '合同附加要求',
                      'MPS',
                      '生产周期');

  INSERT INTO CRAFT_ORD_DESIGN_MSC_JG_BL
    (DESGIN_KEY, CODE_JG, PSC_BL, DESGIN_KEY_BL)
    (SELECT P_DESIGN_KEY_NEW, CODE_JG, PSC_BL, ''
       FROM SLM_ORD_DESIGN_MSC_JG_BL
      WHERE DESGIN_KEY = P_DESIGN_KEY);

  INSERT INTO CRAFT_ORD_DESIGN_MSC_BL
    (DESGIN_KEY, GROUP_NUM, PSC_BL, DESGIN_KEY_BL)
    (SELECT P_DESIGN_KEY_NEW, GROUP_NUM, PSC_BL, ''
       FROM SLM_ORD_DESIGN_MSC_BL
      WHERE DESGIN_KEY = P_DESIGN_KEY);

  INSERT INTO CRAFT_ORD_LINE_BOM
    (DESGIN_KEY, BOM)
    (SELECT P_DESIGN_KEY_NEW, T.BOM
       FROM SLM_ORD_LINE_BOM T
      WHERE T.DESGIN_KEY = P_DESIGN_KEY);

  FOR V_ROW IN (SELECT *
                  FROM CRAFT_ORD_DESIGN_MSC_JG_BL
                 WHERE DESGIN_KEY = P_DESIGN_KEY_NEW) LOOP
    SELECT COUNT(1)
      INTO P_JG_BL_CNT
      FROM CRAFT_ORD_DESIGN T
     WHERE T.ORD_LN_PK = V_ROW.PSC_BL
       AND T.VALIDFLAG = '1';
    IF P_JG_BL_CNT = 0 THEN
      UPDATE CRAFT_ORD_DESIGN_STS_TKLG_LST
         SET DESIGN_OBJ_KEY  = MSC || ',' || '0',
             DESIGN_STS      = 'F',
             DESIGN_STS_RS   = '92',
             DESIGN_STS_DESC = '备料码' || V_ROW.PSC_BL ||
                               '未通过工艺设计，请对该备料码进行工艺设计！'
       WHERE DESGIN_KEY = P_DESIGN_KEY_NEW
         AND LST_ITEM = '接箍';
      UPDATE CRAFT_ORD_DESIGN_STS_TKLG
         SET DESIGN_STS = 'F'
       WHERE DESGIN_KEY = P_DESIGN_KEY_NEW;
      EXIT;
    ELSE
      UPDATE CRAFT_ORD_DESIGN_MSC_JG_BL
         SET DESGIN_KEY_BL =
             (SELECT FIRST_VALUE(DESGIN_KEY) OVER(ORDER BY CRAFT_SEQ DESC)
                FROM CRAFT_ORD_DESIGN
               WHERE ORD_LN_PK = V_ROW.PSC_BL
                 AND VALIDFLAG = '1'
                 AND ROWNUM = 1)
       WHERE DESGIN_KEY = V_ROW.DESGIN_KEY
         AND CODE_JG = V_ROW.CODE_JG
         AND PSC_BL = V_ROW.PSC_BL;
    END IF;
  END LOOP;

  FOR V_ROW IN (SELECT *
                  FROM CRAFT_ORD_DESIGN_MSC_BL
                 WHERE DESGIN_KEY = P_DESIGN_KEY_NEW) LOOP
    SELECT COUNT(1)
      INTO P_BL_CNT
      FROM CRAFT_ORD_DESIGN T
     WHERE T.ORD_LN_PK = V_ROW.PSC_BL
       AND T.VALIDFLAG = '1';
    IF P_BL_CNT = 0 THEN
      UPDATE CRAFT_ORD_DESIGN_STS_TKLG_LST
         SET DESIGN_OBJ_KEY  = MSC || ',' || '0',
             DESIGN_STS      = 'F',
             DESIGN_STS_RS   = '92',
             DESIGN_STS_DESC = '备料码' || V_ROW.PSC_BL ||
                               '未通过工艺设计，请对该备料码进行工艺设计！'
       WHERE DESGIN_KEY = P_DESIGN_KEY_NEW
         AND LST_ITEM = '备料';
      UPDATE CRAFT_ORD_DESIGN_STS_TKLG
         SET DESIGN_STS = 'F'
       WHERE DESGIN_KEY = P_DESIGN_KEY_NEW;
      EXIT;
    ELSE
      UPDATE CRAFT_ORD_DESIGN_MSC_BL
         SET DESGIN_KEY_BL =
             (SELECT FIRST_VALUE(DESGIN_KEY) OVER(ORDER BY CRAFT_SEQ DESC)
                FROM CRAFT_ORD_DESIGN
               WHERE ORD_LN_PK = V_ROW.PSC_BL
                 AND VALIDFLAG = '1'
                 AND ROWNUM = 1)
       WHERE DESGIN_KEY = V_ROW.DESGIN_KEY
         AND GROUP_NUM = V_ROW.GROUP_NUM
         AND PSC_BL = V_ROW.PSC_BL;
    END IF;
  END LOOP;
END;
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.getCraftDesignSts" desc="查询工艺质量设计状态">
		<![CDATA[
SELECT A.DESIGN_STS, M.VALIDFLAG, M.CRAFT_SEQ, M.DESGIN_KEY, M.CRAFT_PATH
  FROM CRAFT_ORD_DESIGN_MSC      T,
       Craft_ORD_DESIGN_STS_TKLG A,
       CRAFT_ORD_DESIGN          M
 WHERE A.VALIDFLAG = '1'
   AND T.VALIDFLAG = '1'
   AND M.DESGIN_KEY = T.DESGIN_KEY
   AND M.DESGIN_KEY = A.DESGIN_KEY
   AND M.ORD_LN_PK = '#ORD_LN_PK#'
   AND M.CRAFT_SEQ = (SELECT MAX(CRAFT_SEQ)
                        FROM CRAFT_ORD_DESIGN
                       WHERE ORD_LN_PK = M.ORD_LN_PK)
   AND M.VALIDFLAG <> '0'
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.getCraftDesignSts2" desc="查询工艺质量设计状态">
		<![CDATA[
SELECT A.DESIGN_STS VALUE, M.VALIDFLAG VALUE2, M.DESGIN_KEY VALUE3
  FROM CRAFT_ORD_DESIGN_MSC      T,
       Craft_ORD_DESIGN_STS_TKLG A,
       CRAFT_ORD_DESIGN          M
 WHERE A.VALIDFLAG = '1'
   AND T.VALIDFLAG = '1'
   AND M.DESGIN_KEY = T.DESGIN_KEY
   AND M.DESGIN_KEY = A.DESGIN_KEY
   AND M.ORD_LN_PK = '#ORD_LN_PK#'
   AND M.CRAFT_SEQ = (SELECT MAX(CRAFT_SEQ)
                        FROM CRAFT_ORD_DESIGN
                       WHERE ORD_LN_PK = M.ORD_LN_PK)
   AND M.VALIDFLAG <> '0'
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.getDepartment" desc="获取管理部门科室">
		<![CDATA[
SELECT T.DEPARTID CODE,
       T.DEPARTNAME NAME,
       DECODE(T.DEPARTID, '002001001', '', '002001007', '','002023005', '','002023003','', T.PID) P_CODE
  FROM CORE_APP_DEPARTMENT T
  LEFT JOIN CORE_APP_DEPARTMENT A
    ON A.DEPARTID = T.PID
 WHERE T.DEPARTID IN ('002001001', '002001007','002023003','002023003001','002023003002','002023005','002023005003')
    OR T.PID IN ('002001001', '002001007')
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.getUser" desc="通过科室带出成员">
		<![CDATA[
SELECT T.USERID, T.USERNAME
      FROM CORE_APP_USER T
     WHERE T.DEPTID = '#DEPTID#'
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.insertCraftDesignAppoint" desc="新增工艺指派">
		<![CDATA[
INSERT INTO CRAFT_ORD_DESIGN_APPOINT
  (ORD_LN_PK, APPOINT_NAME, APPOINT_TIME, CRAFT_NAME, CRAFT_ID)
VALUES
  ('#ORD_LN_PK#', '#APPOINT_NAME#', DECODE('#APPOINT_NAME#', NULL, NULL, SYSDATE), '#CRAFT_NAME#', '#CRAFT_ID#')
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.updateCraftDesignAppoint" desc="修改工艺指派">
		<![CDATA[
UPDATE CRAFT_ORD_DESIGN_APPOINT T
   SET T.APPOINT_NAME = '#APPOINT_NAME#',
       T.APPOINT_TIME = SYSDATE,
       T.CRAFT_NAME   = '#CRAFT_NAME#',
       T.CRAFT_ID     = '#CRAFT_ID#'
 WHERE T.ORD_LN_PK = '#ORD_LN_PK#'
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.getCraftDesignAppointCnt" desc="查询工艺指派数目">
		<![CDATA[
 SELECT COUNT(1) COUNT
   FROM CRAFT_ORD_DESIGN_APPOINT T
  WHERE T.ORD_LN_PK = '#ORD_LN_PK#'
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.getCraftDesignAppointByPk" desc="通过主键查询工艺指派数目">
		<![CDATA[
SELECT * FROM CRAFT_ORD_DESIGN_APPOINT T WHERE T.ORD_LN_PK = '#ORD_LN_PK#'
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.getGuid" desc="获取GUID">
		<![CDATA[
SELECT SYS_GUID() VALUE FROM DUAL
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.updateOrderLineInspV" desc="修改合同行切长">
		<![CDATA[
UPDATE SLM_ORDER_LINE T
   SET T.INSPECTION_VALUE = '#INSPECTION_VALUE#'
 WHERE T.ORD_LN_PK = '#ORD_LN_PK#'
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.getDesignPlCraftNo" desc="获取制程工艺设计表中的工艺文件号">
		<![CDATA[
SELECT DISTINCT PROCESS_NO, MSC_PLINE, MSC
  FROM (SELECT T.PROCESS_NO, T.MSC_PLINE, A.MSC
          FROM CRAFT_ORD_DESIGN_MSC_PL T, CRAFT_ORD_DESIGN_MSC A
         WHERE T.DESGIN_KEY = '#DESGIN_KEY#'
           AND T.VALIDFLAG = '1'
           AND T.SET_FL = '1'
           AND A.DESGIN_KEY = T.DESGIN_KEY
        UNION ALL
        SELECT T.PROCESS_NO, T.MSC_PLINE, A.MSC
          FROM CRAFT_ORD_DESIGN_MSC_PL T, CRAFT_ORD_DESIGN_MSC A
         WHERE T.DESGIN_KEY = '#DESGIN_KEY#'
           AND T.VALIDFLAG = '1'
           AND A.DESGIN_KEY = T.DESGIN_KEY
           AND NOT EXISTS (SELECT 1
                  FROM CRAFT_ORD_DESIGN_MSC_PL
                 WHERE DESGIN_KEY = '#DESGIN_KEY#'
                   AND VALIDFLAG = '1'
                   AND SET_FL = '1'))
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.updateCraftNo" desc="修改工艺文件号,并置为生效状态">
		<![CDATA[
UPDATE CRAFT_ORD_DESIGN
   SET CRAFT_NO  = '#CRAFT_NO#',
       CRAFT_PATH = '#CRAFT_PATH#',
       VALIDFLAG = DECODE((SELECT DESIGN_STS
                            FROM CRAFT_ORD_DESIGN_STS_TKLG
                           WHERE DESGIN_KEY = '#DESGIN_KEY#'),
                          'S',
                          '1',
                          VALIDFLAG),
       LOCK_FLAG = DECODE((SELECT DESIGN_STS
                            FROM CRAFT_ORD_DESIGN_STS_TKLG
                           WHERE DESGIN_KEY = '#DESGIN_KEY#'),
                          'S',
                          '0',
                          '1')
 WHERE DESGIN_KEY = '#DESGIN_KEY#'
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.getOrdSeqByOrdPk" desc="查询合同行号通过合同主键">
		<![CDATA[
SELECT A.ORDER_NO, T.ORD_LN_PK, T.ORDER_SEQ
  FROM SLM_ORDER_LINE T, SLM_ORDER_HEAD A
 WHERE T.ORD_PK = '#ORD_PK#'
   AND A.ORD_PK = T.ORD_PK
   AND T.VALIDFLAG = '1'
   AND A.VALIDFLAG = '1'
   AND T.ORDER_LN_STATUS >= '12020301'
   AND T.ORDER_LN_STATUS < '12020502'
   AND A.ORDER_TYP <> '120102'
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.getCraftOrdDesignFile" desc="查询工艺文件">
		<![CDATA[
SELECT T.CRAFT_NO,
       SUBSTR(T.CRAFT_PATH, INSTR(T.CRAFT_PATH, '/', -1, 1) + 1) CRAFT_PATH,
       T.CRAFT_PATH CRAFT_PATH_OLD,
       T.CRAFT_NO_V,
       T.CREATE_NAME,
       TO_CHAR(T.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       T.MEMO,
       T.CRAFT_KEY,
       'G' CRAFT_TYPE,
       DECODE(T.VALIDFLAG, '0', '无效', '有效') VALIDFLAG,
       NULL ORD_LN_PK,
       NULL CRAFT_SEQ,
       NULL EFFECT_TIME
  FROM CRAFT_ORD_DESIGN_FILE T
 WHERE '#CUSTOM_INFO#' <> 'AppointTmpCraftFile'
   AND DECODE('#CRAFT_NO#', NULL, '1', T.CRAFT_NO) LIKE
       DECODE('#CRAFT_NO#', NULL, '1', '%#CRAFT_NO#%')
   AND DECODE('#MEMO#', NULL, '1', T.MEMO) LIKE
       DECODE('#MEMO#', NULL, '1', '%#MEMO#%')
   AND VALIDFLAG = '1'
UNION ALL
SELECT CRAFT_NO,
       CRAFT_PATH,
       CRAFT_PATH_OLD,
       CRAFT_NO_V,
       CREATE_NAME,
       CREATE_TIME,
       MEMO,
       CRAFT_KEY,
       CRAFT_TYPE,
       VALIDFLAG,
       ORD_LN_PK,
       CRAFT_SEQ,
       TO_CHAR(DECODE(APPROVAL_TIME1,NULL,APPROVAL_TIME,APPROVAL_TIME1),'YYYY-MM-DD HH24:MI:SS')EFFECT_TIME
  FROM (SELECT ROW_NUMBER() OVER(PARTITION BY T.CRAFT_NO, T.CRAFT_NO_V ORDER BY T.ORD_LN_PK) ROWN,
               T.CRAFT_NO,
               SUBSTR((FIRST_VALUE(T.CRAFT_PATH)
                       OVER(PARTITION BY T.CRAFT_NO,
                            T.CRAFT_NO_V ORDER BY T.ORD_LN_PK)),
                      INSTR((FIRST_VALUE(T.CRAFT_PATH)
                             OVER(PARTITION BY T.CRAFT_NO,
                                  T.CRAFT_NO_V ORDER BY T.ORD_LN_PK)),
                            '/',
                            -1,
                            1) + 1) CRAFT_PATH,
               (FIRST_VALUE(T.CRAFT_PATH)
                OVER(PARTITION BY T.CRAFT_NO,
                     T.CRAFT_NO_V ORDER BY T.ORD_LN_PK)) CRAFT_PATH_OLD,
               T.CRAFT_NO_V,
               NVL((FIRST_VALUE(T.DELETE_NAME)
                    OVER(PARTITION BY T.CRAFT_NO,
                         T.CRAFT_NO_V ORDER BY T.ORD_LN_PK)),
                   (FIRST_VALUE(T.CREATE_NAME)
                    OVER(PARTITION BY T.CRAFT_NO,
                         T.CRAFT_NO_V ORDER BY T.ORD_LN_PK))) CREATE_NAME,
               TO_CHAR(NVL((FIRST_VALUE(T.DELETE_TIME)
                            OVER(PARTITION BY T.CRAFT_NO,
                                 T.CRAFT_NO_V ORDER BY T.ORD_LN_PK)),
                           (FIRST_VALUE(T.CREATE_TIME)
                            OVER(PARTITION BY T.CRAFT_NO,
                                 T.CRAFT_NO_V ORDER BY T.ORD_LN_PK))),
                       'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
               FIRST_VALUE(T.APPROVAL_TIME) OVER(PARTITION BY T.CRAFT_NO, T.CRAFT_NO_V ORDER BY T.ORD_LN_PK) APPROVAL_TIME,
               FIRST_VALUE(T.APPROVAL_TIME1) OVER(PARTITION BY T.CRAFT_NO, T.CRAFT_NO_V ORDER BY T.APPROVAL_TIME1) APPROVAL_TIME1,                
               FIRST_VALUE(T.MEMO) OVER(PARTITION BY T.CRAFT_NO, T.CRAFT_NO_V ORDER BY T.ORD_LN_PK) MEMO,
               t.DESGIN_KEY CRAFT_KEY,
               'L' CRAFT_TYPE,
               DECODE((FIRST_VALUE(T.VALIDFLAG)
                       OVER(PARTITION BY T.CRAFT_NO,
                            T.CRAFT_NO_V ORDER BY T.ORD_LN_PK)),
                      '0',
                      '无效',
                      '有效') VALIDFLAG,
               FIRST_VALUE(T.ORD_LN_PK) OVER(PARTITION BY T.CRAFT_NO, T.CRAFT_NO_V ORDER BY T.ORD_LN_PK) ORD_LN_PK,
               FIRST_VALUE(T.CRAFT_SEQ) OVER(PARTITION BY T.CRAFT_NO, T.CRAFT_NO_V ORDER BY T.ORD_LN_PK) CRAFT_SEQ
          FROM CRAFT_ORD_DESIGN T
         WHERE NOT EXISTS
         (SELECT 1
                  FROM CRAFT_ORD_DESIGN_FILE
                 WHERE CRAFT_NO = T.CRAFT_NO
                   AND CRAFT_NO_V = T.CRAFT_NO_V)
           AND T.CRAFT_PATH IS NOT NULL
           AND T.CRAFT_NO IS NOT NULL
           AND '#CUSTOM_INFO#' IN ('CraftQuery', 'ChoiceCraftNo', 'AppointTmpCraftFile')
           AND DECODE('#CRAFT_NO#', NULL, '1', T.CRAFT_NO) LIKE
               DECODE('#CRAFT_NO#', NULL, '1', '%#CRAFT_NO#%')
           AND DECODE('#MEMO#', NULL, '1', T.MEMO) LIKE
               DECODE('#MEMO#', NULL, '1', '%#MEMO#%')
           AND DECODE('#VALIDFLAG#', '999', '1', T.VALIDFLAG) =
               DECODE('#VALIDFLAG#', '999', '1', '1'))
 WHERE ROWN <= 1
 ORDER BY CRAFT_NO, CRAFT_NO_V DESC
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.saveCraftNoBatch" desc="批量保存工艺文件号和文件路径">
		<![CDATA[
DECLARE
  P_COUNT     VARCHAR(5);
  P_ORD_LN_PK CRAFT_ORD_DESIGN.ORD_LN_PK%TYPE;
  P_CRAFT_SEQ CRAFT_ORD_DESIGN.CRAFT_SEQ%TYPE;
BEGIN
  FOR V_ROW IN (SELECT T.*
				  FROM CRAFT_ORD_DESIGN T, CRAFT_ORD_DESIGN_STS_TKLG A
				 WHERE T.ORD_LN_PK IN (#ORD_LN_PK_S#)
				   AND T.CRAFT_SEQ = (SELECT MAX(CRAFT_SEQ)
				                        FROM CRAFT_ORD_DESIGN
				                       WHERE ORD_LN_PK = T.ORD_LN_PK)
				   AND T.VALIDFLAG = '2'
				   AND T.LOCK_FLAG = '1'
				   AND A.DESGIN_KEY = T.DESGIN_KEY
				   AND A.DESIGN_STS = 'S') LOOP
                         
    UPDATE CRAFT_ORD_DESIGN T
       SET T.CRAFT_NO     = '#CRAFT_NO#',
           T.CRAFT_PATH   = '#CRAFT_PATH#',
           T.VALIDFLAG    = DECODE(CRAFT_SEQ, '1', '1', '8'),
           T.CRAFT_NO_V   = '#CRAFT_NO_V#',
           T.CRAFT_SOURCE = '人工上传',
           T.MEMO = '#MEMO#',
           T.DELETE_TIME = SYSDATE,
           T.DELETE_NAME = '#DELETE_NAME#'
     WHERE T.ORD_LN_PK = V_ROW.ORD_LN_PK
       AND T.CRAFT_SEQ = V_ROW.CRAFT_SEQ;
  
    UPDATE CRAFT_ORD_DESIGN T
       SET T.VALIDFLAG = '0'
     WHERE T.ORD_LN_PK = V_ROW.ORD_LN_PK
       AND T.CRAFT_SEQ < V_ROW.CRAFT_SEQ;
    UPDATE SLM_ORDER_LINE T
       SET T.CRAFT_NO = '#CRAFT_NO#', T.CRAFT_NO_V = '#CRAFT_NO_V#'
     WHERE T.ORD_LN_PK = V_ROW.ORD_LN_PK;
  END LOOP;
END;
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.getCrafFileByCraftNo" desc="通过工艺文件号查询工艺文件数">
		<![CDATA[
SELECT COUNT(1) FROM CRAFT_ORD_DESIGN_FILE WHERE CRAFT_NO = '#CRAFT_NO#'
AND CRAFT_NO_V = '#CRAFT_NO_V#'
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.setCraftFile" desc="修改工艺文件备注和工艺文件号">
		<![CDATA[
UPDATE CRAFT_ORD_DESIGN_FILE T
   SET T.MEMO = '#MEMO#',
   T.CRAFT_NO = '#CRAFT_NO#'
 WHERE T.CRAFT_KEY = '#CRAFT_KEY#'
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.deleteCraftFile" desc="删除工艺文件备注和工艺文件号">
		<![CDATA[
DECLARE
  P_CRAFT_KEY CRAFT_ORD_DESIGN_FILE.CRAFT_NO%TYPE;
BEGIN
  SELECT CRAFT_KEY
    INTO P_CRAFT_KEY
    FROM CRAFT_ORD_DESIGN_FILE T
   WHERE T.CRAFT_KEY = '#CRAFT_KEY#';
  DELETE FROM CRAFT_ORD_DESIGN_FILE T WHERE T.CRAFT_KEY = '#CRAFT_KEY#';
  DELETE FROM CRAFT_FILE_APPLY T WHERE T.CRAFT_KEY = P_CRAFT_KEY;
END;
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.getComMscByOrdLnPk" desc="获取冶金规范">
		<![CDATA[
SELECT A.*
  FROM COM_MSC A, SLM_ORDER_LINE B
 WHERE B.ORD_LN_PK = '#ORD_LN_PK#'
   AND A.MSC = B.MSC
UNION ALL
SELECT A.*
  FROM COM_MSC A, COM_MSC_BL B, COM_PSC C, COM_PSC_R_MSC D
 WHERE B.PSC_BL = '#ORD_LN_PK#'
   AND C.PRODUCCODE = B.PRODUCCODE
   AND C.STEELCODE = B.STEELCODE
   AND C.STD_CODE = B.STD_CODE
   AND NVL(C.STD_STYLE, '004') = NVL(B.STD_STYLE, '004')
   AND D.PSC = C.PSC
   AND A.MSC = D.MSC
   AND A.USE_CODE = B.USE_CODE
   AND C.VALIDFLAG='1'
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.getOrdStdAddAskDesc" desc="获取标准和客户附加要求的合并项">
		<![CDATA[
SELECT REPLACE(WM_CONCAT(ASK_SUB_ITME_DESC || ':' || ASK_SUB_ITME_VAL_DESC),
               ',',
               CHR(13) || CHR(10)) ADD_ASK_DESC
  FROM (SELECT ORD_ADD.ASK_SUB_ITME_DESC,
               ORD_ADD.ASK_SUB_ITME_VAL_DESC,
               ORD_ADD.ADD_ASK_NO,
               NULL STD_CODE,
               ORD_ADD.ASK_ITME_DESC
          FROM SLM_ORDER_ADD_ASK ORD_ADD
         WHERE ORD_ADD.ADD_ASK_NO = '#ADD_ASK_NO#'
        UNION ALL
        SELECT BAS_ADD.ASK_SUB_ITME_DESC,
               BAS_ADD.ASK_SUB_ITME_VAL_DESC,
               NULL ADD_ASK_NO,
               BAS_ADD.STD_CODE,
               BAS_ADD.ASK_ITME_DESC
          FROM COM_BASE_ADDITIONAL BAS_ADD
         WHERE BAS_ADD.STD_CODE = '#STD_CODE#'
           AND NOT EXISTS
         (SELECT 1
                  FROM SLM_ORDER_ADD_ASK ORD_ADD
                 WHERE ORD_ADD.ADD_ASK_NO = '#ADD_ASK_NO#'
                   AND ORD_ADD.ASK_ITME = BAS_ADD.ASK_ITME
                   AND ORD_ADD.ASK_SUB_ITME = BAS_ADD.ASK_SUB_ITME)
         ORDER BY ASK_ITME_DESC, ASK_SUB_ITME_DESC)
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.invalidCraftFile" desc="作废工艺文件">
		<![CDATA[
UPDATE CRAFT_ORD_DESIGN_FILE T
   SET T.VALIDFLAG = '#VALIDFLAG#'
 WHERE T.CRAFT_KEY = '#CRAFT_KEY#'
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.deleteCraftOrdDesignFile" desc="删除工艺文件">
		<![CDATA[
DELETE FROM CRAFT_ORD_DESIGN T
 WHERE T.CRAFT_NO = '#CRAFT_NO#' AND T.CRAFT_NO_V = '#CRAFT_NO_V#'
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.getCraftFileByPk" desc="查询主键工艺文件">
		<![CDATA[
SELECT *
  FROM CRAFT_ORD_DESIGN_FILE T
 WHERE T.CRAFT_KEY = '#CRAFT_KEY#'
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.getFailLstItem" desc="查询失败的节点名称">
		<![CDATA[
SELECT A.LST_ITEM
  FROM CRAFT_ORD_DESIGN T, CRAFT_ORD_DESIGN_STS_TKLG_LST A
 WHERE T.ORD_LN_PK = {0}
   AND T.CRAFT_SEQ = (SELECT MAX(CRAFT_SEQ)
                        FROM CRAFT_ORD_DESIGN A
                       WHERE A.ORD_LN_PK = {0})
   AND A.DESIGN_STS = 'F'
   AND A.DESGIN_KEY = T.DESGIN_KEY
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.getPlnSaleOrdByPk" desc="通过合同行主键查询计划表">
		<![CDATA[
SELECT T.PORDERSTATUS, T.JGORD_IS_OK, T.DJBL_REQ_IS_OK
  FROM PLN_SALEORD T
 WHERE T.ORD_LN_PK = {0}
   AND T.DELIVERY_NO = (SELECT MIN(A.DELIVERY_NO)
                          FROM PLN_SALEORD A
                         WHERE A.ORD_LN_PK = T.ORD_LN_PK)
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.lockZg" desc="锁定轧管">
		<![CDATA[
UPDATE PLN_ORDER_ZG_S T
   SET T.IF_CRAFT_LOCKED = '1',
       T.CRAFT_FILE_NO   = NULL,
       T.CRAFT_FILE_MAN  = NULL,
       T.CRAFT_SEQ       = NULL
 WHERE T.ORD_LN_DLY_PK IN
       (SELECT A.ORD_LN_DLY_PK FROM PLN_SALEORD A WHERE A.ORD_LN_PK = {0})
   AND ((T.EXE_STATUS = '0' AND NOT EXISTS
        (SELECT 1
            FROM PLN_ZY_ZG_M B
           WHERE B.PRO_PLAN_ID = T.PRO_PLAN_ID
             AND B.GX_PLAN_NO = T.GX_PLAN_NO
             AND B.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK)) OR
       (T.EXE_STATUS = '1' AND NOT EXISTS
        (SELECT 1
            FROM PLN_ZY_ZG_M B
           WHERE B.PRO_PLAN_ID = T.PRO_PLAN_ID
             AND B.GX_PLAN_NO = T.GX_PLAN_NO
             AND B.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK
             AND B.PLANSTATUS IN ('1', '2'))))
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.lockDbk" desc="锁定镦拔扩">
		<![CDATA[
UPDATE PLN_ORDER_DBK_S T
   SET T.IF_CRAFT_LOCKED = '1',
       T.CRAFT_FILE_NO   = NULL,
       T.CRAFT_FILE_MAN  = NULL,
       T.CRAFT_SEQ       = NULL
 WHERE T.ORD_LN_DLY_PK IN
       (SELECT A.ORD_LN_DLY_PK FROM PLN_SALEORD A WHERE A.ORD_LN_PK = {0})
   AND ((T.EXE_STATUS = '0' AND NOT EXISTS
        (SELECT 1
            FROM PLN_ZY_ZG_M B
           WHERE B.PRO_PLAN_ID = T.PRO_PLAN_ID
             AND B.GX_PLAN_NO = T.GX_PLAN_NO
             AND B.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK)) OR
       (T.EXE_STATUS = '1' AND NOT EXISTS
        (SELECT 1
            FROM PLN_ZY_ZG_M B
           WHERE B.PRO_PLAN_ID = T.PRO_PLAN_ID
             AND B.GX_PLAN_NO = T.GX_PLAN_NO
             AND B.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK
             AND B.PLANSTATUS IN ('1', '2'))))
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.lockRcl" desc="锁定热处理">
		<![CDATA[
UPDATE PLN_ORDER_RCL_S T
   SET T.IF_CRAFT_LOCKED = '1',
       T.CRAFT_FILE_NO   = NULL,
       T.CRAFT_FILE_MAN  = NULL,
       T.CRAFT_SEQ       = NULL
 WHERE T.ORD_LN_DLY_PK IN
       (SELECT A.ORD_LN_DLY_PK FROM PLN_SALEORD A WHERE A.ORD_LN_PK = {0})
   AND ((T.EXE_STATUS = '0' AND NOT EXISTS
        (SELECT 1
            FROM PLN_ZY_ZG_M B
           WHERE B.PRO_PLAN_ID = T.PRO_PLAN_ID
             AND B.GX_PLAN_NO = T.GX_PLAN_NO
             AND B.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK)) OR
       (T.EXE_STATUS = '1' AND NOT EXISTS
        (SELECT 1
            FROM PLN_ZY_ZG_M B
           WHERE B.PRO_PLAN_ID = T.PRO_PLAN_ID
             AND B.GX_PLAN_NO = T.GX_PLAN_NO
             AND B.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK
             AND B.PLANSTATUS IN ('1', '2'))))
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.lockJgx" desc="锁定加工">
		<![CDATA[
UPDATE PLN_ORDER_JGX_S T
   SET T.IF_CRAFT_LOCKED = '1',
       T.CRAFT_FILE_NO   = NULL,
       T.CRAFT_FILE_MAN  = NULL,
       T.CRAFT_SEQ       = NULL
 WHERE T.ORD_LN_DLY_PK IN
       (SELECT A.ORD_LN_DLY_PK FROM PLN_SALEORD A WHERE A.ORD_LN_PK = {0})
   AND ((T.EXE_STATUS = '0' AND NOT EXISTS
        (SELECT 1
            FROM PLN_ZY_ZG_M B
           WHERE B.PRO_PLAN_ID = T.PRO_PLAN_ID
             AND B.GX_PLAN_NO = T.GX_PLAN_NO
             AND B.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK)) OR
       (T.EXE_STATUS = '1' AND NOT EXISTS
        (SELECT 1
            FROM PLN_ZY_ZG_M B
           WHERE B.PRO_PLAN_ID = T.PRO_PLAN_ID
             AND B.GX_PLAN_NO = T.GX_PLAN_NO
             AND B.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK
             AND B.PLANSTATUS IN ('1', '2'))))
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.clearCraftLockZg" desc="清除轧管锁定记录表">
		<![CDATA[
DECLARE
BEGIN
  FOR V IN (SELECT B.PRO_PLAN_ID, B.GX_PLAN_NO
              FROM PLN_SALEORD A, PLN_ORDER_ZG_S B
             WHERE A.ORD_LN_PK = {0}
               AND A.ORD_LN_DLY_PK = B.ORD_LN_DLY_PK) LOOP
    DELETE FROM CRAFT_PLN_PROCESS_LOCK T
     WHERE T.PRO_PLAN_ID = V.PRO_PLAN_ID
       AND T.GX_PLAN_NO = V.GX_PLAN_NO;
  END LOOP;
END;
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.clearCraftLockDbk" desc="清除镦拔扩锁定记录表">
		<![CDATA[
DECLARE
BEGIN
  FOR V IN (SELECT B.PRO_PLAN_ID, B.GX_PLAN_NO
              FROM PLN_SALEORD A, PLN_ORDER_DBK_S B
             WHERE A.ORD_LN_PK = {0}
               AND A.ORD_LN_DLY_PK = B.ORD_LN_DLY_PK) LOOP
    DELETE FROM CRAFT_PLN_PROCESS_LOCK T
     WHERE T.PRO_PLAN_ID = V.PRO_PLAN_ID
       AND T.GX_PLAN_NO = V.GX_PLAN_NO;
  END LOOP;
END;
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.clearCraftLockRcl" desc="清除热处理锁定记录表">
		<![CDATA[
DECLARE
BEGIN
  FOR V IN (SELECT B.PRO_PLAN_ID, B.GX_PLAN_NO
              FROM PLN_SALEORD A, PLN_ORDER_Rcl_S B
             WHERE A.ORD_LN_PK = {0}
               AND A.ORD_LN_DLY_PK = B.ORD_LN_DLY_PK) LOOP
    DELETE FROM CRAFT_PLN_PROCESS_LOCK T
     WHERE T.PRO_PLAN_ID = V.PRO_PLAN_ID
       AND T.GX_PLAN_NO = V.GX_PLAN_NO;
  END LOOP;
END;
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.clearCraftLockJgx" desc="清除加工锁定记录表">
		<![CDATA[
DECLARE
BEGIN
  FOR V IN (SELECT B.PRO_PLAN_ID, B.GX_PLAN_NO
              FROM PLN_SALEORD A, PLN_ORDER_JGX_S B
             WHERE A.ORD_LN_PK = {0}
               AND A.ORD_LN_DLY_PK = B.ORD_LN_DLY_PK) LOOP
    DELETE FROM CRAFT_PLN_PROCESS_LOCK T
     WHERE T.PRO_PLAN_ID = V.PRO_PLAN_ID
       AND T.GX_PLAN_NO = V.GX_PLAN_NO;
  END LOOP;
END;
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.saveCraftLockZg" desc="保存轧管锁定记录表">
		<![CDATA[
INSERT INTO CRAFT_PLN_PROCESS_LOCK
  (PRO_PLAN_ID, GX_PLAN_NO, CRAFT_FILE_NO, CRAFT_FILE_MAN, CRAFT_SEQ)
  (SELECT T.PRO_PLAN_ID,
          T.GX_PLAN_NO,
          CRAFT_FILE_NO,
          CRAFT_FILE_MAN,
          CRAFT_SEQ
     FROM PLN_ORDER_ZG_S T
    WHERE T.ORD_LN_DLY_PK IN
          (SELECT A.ORD_LN_DLY_PK FROM PLN_SALEORD A WHERE A.ORD_LN_PK = {0})
      AND ((T.EXE_STATUS = '0' AND NOT EXISTS
           (SELECT 1
               FROM PLN_ZY_ZG_M B
              WHERE B.PRO_PLAN_ID = T.PRO_PLAN_ID
                AND B.GX_PLAN_NO = T.GX_PLAN_NO
                AND B.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK)) OR
          (T.EXE_STATUS = '1' AND NOT EXISTS
           (SELECT 1
               FROM PLN_ZY_ZG_M B
              WHERE B.PRO_PLAN_ID = T.PRO_PLAN_ID
                AND B.GX_PLAN_NO = T.GX_PLAN_NO
                AND B.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK
                AND B.PLANSTATUS IN ('1', '2')))))
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.saveCraftLockDbk" desc="保存镦拔扩锁定记录表">
		<![CDATA[
INSERT INTO CRAFT_PLN_PROCESS_LOCK
  (PRO_PLAN_ID, GX_PLAN_NO, CRAFT_FILE_NO, CRAFT_FILE_MAN, CRAFT_SEQ)
  (SELECT T.PRO_PLAN_ID,
          T.GX_PLAN_NO,
          CRAFT_FILE_NO,
          CRAFT_FILE_MAN,
          CRAFT_SEQ
     FROM PLN_ORDER_DBK_S T
    WHERE T.ORD_LN_DLY_PK IN
          (SELECT A.ORD_LN_DLY_PK FROM PLN_SALEORD A WHERE A.ORD_LN_PK = {0})
      AND ((T.EXE_STATUS = '0' AND NOT EXISTS
           (SELECT 1
               FROM PLN_ZY_DBK_M B
              WHERE B.PRO_PLAN_ID = T.PRO_PLAN_ID
                AND B.GX_PLAN_NO = T.GX_PLAN_NO
                AND B.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK)) OR
          (T.EXE_STATUS = '1' AND NOT EXISTS
           (SELECT 1
               FROM PLN_ZY_DBK_M B
              WHERE B.PRO_PLAN_ID = T.PRO_PLAN_ID
                AND B.GX_PLAN_NO = T.GX_PLAN_NO
                AND B.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK
                AND B.PLANSTATUS IN ('1', '2')))))
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.saveCraftLockRcl" desc="保存热处理锁定记录表">
		<![CDATA[
INSERT INTO CRAFT_PLN_PROCESS_LOCK
  (PRO_PLAN_ID, GX_PLAN_NO, CRAFT_FILE_NO, CRAFT_FILE_MAN, CRAFT_SEQ)
  (SELECT T.PRO_PLAN_ID,
          T.GX_PLAN_NO,
          CRAFT_FILE_NO,
          CRAFT_FILE_MAN,
          CRAFT_SEQ
     FROM PLN_ORDER_RCL_S T
    WHERE T.ORD_LN_DLY_PK IN
          (SELECT A.ORD_LN_DLY_PK FROM PLN_SALEORD A WHERE A.ORD_LN_PK = {0})
      AND ((T.EXE_STATUS = '0' AND NOT EXISTS
           (SELECT 1
               FROM PLN_ZY_RCL_M B
              WHERE B.PRO_PLAN_ID = T.PRO_PLAN_ID
                AND B.GX_PLAN_NO = T.GX_PLAN_NO
                AND B.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK)) OR
          (T.EXE_STATUS = '1' AND NOT EXISTS
           (SELECT 1
               FROM PLN_ZY_RCL_M B
              WHERE B.PRO_PLAN_ID = T.PRO_PLAN_ID
                AND B.GX_PLAN_NO = T.GX_PLAN_NO
                AND B.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK
                AND B.PLANSTATUS IN ('1', '2')))))
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.saveCraftLockJgx" desc="保存加工线锁定记录表">
		<![CDATA[
INSERT INTO CRAFT_PLN_PROCESS_LOCK
  (PRO_PLAN_ID, GX_PLAN_NO, CRAFT_FILE_NO, CRAFT_FILE_MAN, CRAFT_SEQ)
  (SELECT T.PRO_PLAN_ID,
          T.GX_PLAN_NO,
          CRAFT_FILE_NO,
          CRAFT_FILE_MAN,
          CRAFT_SEQ
     FROM PLN_ORDER_JGX_S T
    WHERE T.ORD_LN_DLY_PK IN
          (SELECT A.ORD_LN_DLY_PK FROM PLN_SALEORD A WHERE A.ORD_LN_PK = {0})
      AND ((T.EXE_STATUS = '0' AND NOT EXISTS
           (SELECT 1
               FROM PLN_ZY_JGX_M B
              WHERE B.PRO_PLAN_ID = T.PRO_PLAN_ID
                AND B.GX_PLAN_NO = T.GX_PLAN_NO
                AND B.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK)) OR
          (T.EXE_STATUS = '1' AND NOT EXISTS
           (SELECT 1
               FROM PLN_ZY_JGX_M B
              WHERE B.PRO_PLAN_ID = T.PRO_PLAN_ID
                AND B.GX_PLAN_NO = T.GX_PLAN_NO
                AND B.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK
                AND B.PLANSTATUS IN ('1', '2')))))
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.rollBackPlnZg" desc="回滚计划轧管">
		<![CDATA[
DECLARE
BEGIN
  FOR V IN (SELECT C.PRO_PLAN_ID,
                   C.GX_PLAN_NO,
                   C.CRAFT_FILE_NO,
                   C.CRAFT_FILE_MAN,
                   C.CRAFT_SEQ
              FROM PLN_SALEORD            A,
                   PLN_ORDER_ZG_S        B,
                   CRAFT_PLN_PROCESS_LOCK C
             WHERE A.ORD_LN_PK = {0}
               AND A.ORD_LN_DLY_PK = B.ORD_LN_DLY_PK
               AND C.PRO_PLAN_ID = B.PRO_PLAN_ID
               AND C.GX_PLAN_NO = B.GX_PLAN_NO
               AND B.IF_CRAFT_LOCKED = '1') LOOP
    UPDATE PLN_ORDER_ZG_S T
       SET T.CRAFT_FILE_NO  = V.CRAFT_FILE_NO,
           T.CRAFT_FILE_MAN = V.CRAFT_FILE_MAN,
           T.CRAFT_SEQ      = V.CRAFT_SEQ,
           T.IF_CRAFT_LOCKED = '0'
     WHERE T.PRO_PLAN_ID = V.PRO_PLAN_ID
       AND T.GX_PLAN_NO = V.GX_PLAN_NO;
  END LOOP;
END;
		]]>
	</query>
	<query id="CoreOrderReviewTechnology.rollBackPlnDbk" desc="回滚计划镦拔扩">
		<![CDATA[
DECLARE
BEGIN
  FOR V IN (SELECT C.PRO_PLAN_ID,
                   C.GX_PLAN_NO,
                   C.CRAFT_FILE_NO,
                   C.CRAFT_FILE_MAN,
                   C.CRAFT_SEQ
              FROM PLN_SALEORD            A,
                   PLN_ORDER_DBK_S        B,
                   CRAFT_PLN_PROCESS_LOCK C
             WHERE A.ORD_LN_PK = {0}
               AND A.ORD_LN_DLY_PK = B.ORD_LN_DLY_PK
               AND C.PRO_PLAN_ID = B.PRO_PLAN_ID
               AND C.GX_PLAN_NO = B.GX_PLAN_NO
               AND B.IF_CRAFT_LOCKED = '1') LOOP
    UPDATE PLN_ORDER_DBK_S T
       SET T.CRAFT_FILE_NO  = V.CRAFT_FILE_NO,
           T.CRAFT_FILE_MAN = V.CRAFT_FILE_MAN,
           T.CRAFT_SEQ      = V.CRAFT_SEQ,
           T.IF_CRAFT_LOCKED = '0'
     WHERE T.PRO_PLAN_ID = V.PRO_PLAN_ID
       AND T.GX_PLAN_NO = V.GX_PLAN_NO;
  END LOOP;
END;
		]]>
	</query>
	<query id="CoreOrderReviewTechnology.rollBackPlnRcl" desc="回滚计划热处理">
		<![CDATA[
DECLARE
BEGIN
  FOR V IN (SELECT C.PRO_PLAN_ID,
                   C.GX_PLAN_NO,
                   C.CRAFT_FILE_NO,
                   C.CRAFT_FILE_MAN,
                   C.CRAFT_SEQ
              FROM PLN_SALEORD            A,
                   PLN_ORDER_RCL_S        B,
                   CRAFT_PLN_PROCESS_LOCK C
             WHERE A.ORD_LN_PK = {0}
               AND A.ORD_LN_DLY_PK = B.ORD_LN_DLY_PK
               AND C.PRO_PLAN_ID = B.PRO_PLAN_ID
               AND C.GX_PLAN_NO = B.GX_PLAN_NO
               AND B.IF_CRAFT_LOCKED = '1') LOOP
    UPDATE PLN_ORDER_RCL_S T
       SET T.CRAFT_FILE_NO  = V.CRAFT_FILE_NO,
           T.CRAFT_FILE_MAN = V.CRAFT_FILE_MAN,
           T.CRAFT_SEQ      = V.CRAFT_SEQ,
           T.IF_CRAFT_LOCKED = '0'
     WHERE T.PRO_PLAN_ID = V.PRO_PLAN_ID
       AND T.GX_PLAN_NO = V.GX_PLAN_NO;
  END LOOP;
END;
		]]>
	</query>
	<query id="CoreOrderReviewTechnology.rollBackPlnJgx" desc="回滚计划加工线">
		<![CDATA[
DECLARE
BEGIN
  FOR V IN (SELECT C.PRO_PLAN_ID,
                   C.GX_PLAN_NO,
                   C.CRAFT_FILE_NO,
                   C.CRAFT_FILE_MAN,
                   C.CRAFT_SEQ
              FROM PLN_SALEORD            A,
                   PLN_ORDER_JGX_S        B,
                   CRAFT_PLN_PROCESS_LOCK C
             WHERE A.ORD_LN_PK = {0}
               AND A.ORD_LN_DLY_PK = B.ORD_LN_DLY_PK
               AND C.PRO_PLAN_ID = B.PRO_PLAN_ID
               AND C.GX_PLAN_NO = B.GX_PLAN_NO
               AND B.IF_CRAFT_LOCKED = '1') LOOP
    UPDATE PLN_ORDER_JGX_S T
       SET T.CRAFT_FILE_NO  = V.CRAFT_FILE_NO,
           T.CRAFT_FILE_MAN = V.CRAFT_FILE_MAN,
           T.CRAFT_SEQ      = V.CRAFT_SEQ,
           T.IF_CRAFT_LOCKED = '0'
     WHERE T.PRO_PLAN_ID = V.PRO_PLAN_ID
       AND T.GX_PLAN_NO = V.GX_PLAN_NO;
  END LOOP;
END;
		]]>
	</query>
	<query id="CoreOrderReviewTechnology.rollBackCraftOrdDesign" desc="回滚工艺评审主表">
		<![CDATA[
DECLARE
BEGIN
  DELETE FROM CRAFT_ORD_DESIGN T
   WHERE T.ORD_LN_PK = {0}
     AND T.CRAFT_SEQ = {1};
  UPDATE CRAFT_ORD_DESIGN T
     SET T.VALIDFLAG = '1'
   WHERE T.ORD_LN_PK = {0}
     AND T.CRAFT_SEQ = (SELECT MAX(A.CRAFT_SEQ)
                          FROM CRAFT_ORD_DESIGN A
                         WHERE A.ORD_LN_PK = T.ORD_LN_PK);
END;
		]]>
	</query>
	<query id="CoreOrderReviewTechnology.updatePlnZg" desc="修改计划轧管">
		<![CDATA[
DECLARE
BEGIN
  FOR V IN (SELECT B.PRO_PLAN_ID,
                   B.GX_PLAN_NO,
                   C.CRAFT_NO,
                   C.DELETE_NAME,
                   C.CRAFT_SEQ
              FROM PLN_SALEORD A, PLN_ORDER_ZG_S B, CRAFT_ORD_DESIGN C
             WHERE A.ORD_LN_PK = {0}
               AND A.ORD_LN_DLY_PK = B.ORD_LN_DLY_PK
               AND B.IF_CRAFT_LOCKED = '1'
               AND C.ORD_LN_PK = A.ORD_LN_PK
               AND C.VALIDFLAG = '1') LOOP
    UPDATE PLN_ORDER_ZG_S T
       SET T.CRAFT_FILE_NO  = V.CRAFT_NO,
           T.CRAFT_FILE_MAN = V.DELETE_NAME,
           T.CRAFT_SEQ      = V.CRAFT_SEQ
     WHERE T.PRO_PLAN_ID = V.PRO_PLAN_ID
       AND T.GX_PLAN_NO = V.GX_PLAN_NO;
  END LOOP;
END;
		]]>
	</query>
	<query id="CoreOrderReviewTechnology.updatePlnDbk" desc="修改计划镦拔扩">
		<![CDATA[
DECLARE
BEGIN
  FOR V IN (SELECT B.PRO_PLAN_ID,
                   B.GX_PLAN_NO,
                   C.CRAFT_NO,
                   C.DELETE_NAME,
                   C.CRAFT_SEQ
              FROM PLN_SALEORD A, PLN_ORDER_DBK_S B, CRAFT_ORD_DESIGN C
             WHERE A.ORD_LN_PK = {0}
               AND A.ORD_LN_DLY_PK = B.ORD_LN_DLY_PK
               AND B.IF_CRAFT_LOCKED = '1'
               AND C.ORD_LN_PK = A.ORD_LN_PK
               AND C.VALIDFLAG = '1') LOOP
    UPDATE PLN_ORDER_DBK_S T
       SET T.CRAFT_FILE_NO  = V.CRAFT_NO,
           T.CRAFT_FILE_MAN = V.DELETE_NAME,
           T.CRAFT_SEQ      = V.CRAFT_SEQ
     WHERE T.PRO_PLAN_ID = V.PRO_PLAN_ID
       AND T.GX_PLAN_NO = V.GX_PLAN_NO;
  END LOOP;
END;
		]]>
	</query>
	<query id="CoreOrderReviewTechnology.updatePlnRcl" desc="修改计划热处理">
		<![CDATA[
DECLARE
BEGIN
  FOR V IN (SELECT B.PRO_PLAN_ID,
                   B.GX_PLAN_NO,
                   C.CRAFT_NO,
                   C.DELETE_NAME,
                   C.CRAFT_SEQ
              FROM PLN_SALEORD A, PLN_ORDER_RCL_S B, CRAFT_ORD_DESIGN C
             WHERE A.ORD_LN_PK = {0}
               AND A.ORD_LN_DLY_PK = B.ORD_LN_DLY_PK
               AND B.IF_CRAFT_LOCKED = '1'
               AND C.ORD_LN_PK = A.ORD_LN_PK
               AND C.VALIDFLAG = '1') LOOP
    UPDATE PLN_ORDER_RCL_S T
       SET T.CRAFT_FILE_NO  = V.CRAFT_NO,
           T.CRAFT_FILE_MAN = V.DELETE_NAME,
           T.CRAFT_SEQ      = V.CRAFT_SEQ
     WHERE T.PRO_PLAN_ID = V.PRO_PLAN_ID
       AND T.GX_PLAN_NO = V.GX_PLAN_NO;
  END LOOP;
END;
		]]>
	</query>
	<query id="CoreOrderReviewTechnology.updatePlnJgx" desc="修改计划加工">
		<![CDATA[
DECLARE
BEGIN
  FOR V IN (SELECT B.PRO_PLAN_ID,
                   B.GX_PLAN_NO,
                   C.CRAFT_NO,
                   C.DELETE_NAME,
                   C.CRAFT_SEQ
              FROM PLN_SALEORD A, PLN_ORDER_JGX_S B, CRAFT_ORD_DESIGN C
             WHERE A.ORD_LN_PK = {0}
               AND A.ORD_LN_DLY_PK = B.ORD_LN_DLY_PK
               AND B.IF_CRAFT_LOCKED = '1'
               AND C.ORD_LN_PK = A.ORD_LN_PK
               AND C.VALIDFLAG = '1') LOOP
    UPDATE PLN_ORDER_JGX_S T
       SET T.CRAFT_FILE_NO  = V.CRAFT_NO,
           T.CRAFT_FILE_MAN = V.DELETE_NAME,
           T.CRAFT_SEQ      = V.CRAFT_SEQ
     WHERE T.PRO_PLAN_ID = V.PRO_PLAN_ID
       AND T.GX_PLAN_NO = V.GX_PLAN_NO;
  END LOOP;
END;
		]]>
	</query>
	<query id="CoreOrderReviewTechnology.unLockPlnZg" desc="解锁计划轧管">
		<![CDATA[
UPDATE PLN_ORDER_ZG_S T
   SET T.IF_CRAFT_LOCKED = '0'
 WHERE T.PRO_PLAN_ID = {0}
   AND T.GX_PLAN_NO = {1}
		]]>
	</query>
	<query id="CoreOrderReviewTechnology.unLockPlnDbk" desc="解锁计划镦拔扩">
		<![CDATA[
UPDATE PLN_ORDER_DBK_S T
   SET T.IF_CRAFT_LOCKED = '0'
 WHERE T.PRO_PLAN_ID = {0}
   AND T.GX_PLAN_NO = {1}
		]]>
	</query>
	<query id="CoreOrderReviewTechnology.unLockPlnRcl" desc="解锁计划热处理">
		<![CDATA[
UPDATE PLN_ORDER_RCL_S T
   SET T.IF_CRAFT_LOCKED = '0'
 WHERE T.PRO_PLAN_ID = {0}
   AND T.GX_PLAN_NO = {1}
		]]>
	</query>
	<query id="CoreOrderReviewTechnology.unLockPlnJgx" desc="解锁计划加工">
		<![CDATA[
UPDATE PLN_ORDER_JGX_S T
   SET T.IF_CRAFT_LOCKED = '0'
 WHERE T.PRO_PLAN_ID = {0}
   AND T.GX_PLAN_NO = {1}
		]]>
	</query>
	<query id="CoreOrderReviewTechnology.queryPlnProcess" desc="查询计划各个工序">
		<![CDATA[
--轧制
SELECT DECODE(V.IF_CRAFT_LOCKED, '0', '否', '1', '是') IF_CRAFT_LOCKED,
       '轧制' PROCESS_DESC,
       DECODE(V.EXE_STATUS,
              '0',
              '计划',
              '1',
              '生产中',
              '2',
              '完成',
              '3',
              '关闭A') EXE_STATUS,
       V.CRAFT_FILE_NO,
       V.CRAFT_FILE_MAN,
       V.CRAFT_SEQ,
       C.CRAFT_PATH,
       C.MEMO,
       C.CRAFT_FILE_LV2_D CRAFT_FILE_LV2,
       (SELECT LISTAGG(A.CRAFT_NO_LV2 || '【' || C.CREATE_NAME || '】', ';') within group(order by A.CRAFT_NO_LV2)
          FROM CRAFT_FILE_LV2 A
         WHERE INSTR(C.CRAFT_FILE_LV2_D, A.PK) > 0) CRAFT_FILE_LV2_DESC,
       (SELECT REPLACE(WM_CONCAT(D.FEED_HEAT_NO || '(' ||
                                 DECODE(D.PLANSTATUS,
                                        '00',
                                        '计划',
                                        '01',
                                        '下发',
                                        '02',
                                        '生产中',
                                        '03',
                                        '生产完成',
                                        '04',
                                        '关闭A') || ')'),
                       ',',
                       '；')
          FROM PLN_ZY_ZG_M D
         WHERE D.ORD_LN_DLY_PK = V.ORD_LN_DLY_PK
           AND D.PRO_PLAN_ID = V.PRO_PLAN_ID
           AND D.GX_PLAN_NO = V.GX_PLAN_NO) HEATON_PLN_SET,
       V.PRO_PLAN_ID,
       V.GX_PLAN_NO,
       V.ORD_LN_DLY_PK,
       V.GPREQ_ID
  FROM PLN_ORDER_ZG_S V
  LEFT JOIN CRAFT_ORD_DESIGN C
    ON C.ORD_LN_PK = {0}
   AND C.CRAFT_SEQ = V.CRAFT_SEQ
 WHERE V.PRO_PLAN_ID IN
       (SELECT T.PRO_PLAN_ID
          FROM PLN_ORDER_ZG T
         WHERE SUBSTR(T.ORD_LN_DLY_PK, 1, 35) = {0})

UNION ALL
--镦拨扩          
SELECT DECODE(V.IF_CRAFT_LOCKED, '0', '否', '1', '是') IF_CRAFT_LOCKED,
       '镦拔扩' PROCESS_DESC,
       DECODE(V.EXE_STATUS,
              '0',
              '计划',
              '1',
              '生产中',
              '2',
              '完成',
              '3',
              '关闭A') EXE_STATUS,
       V.CRAFT_FILE_NO,
       V.CRAFT_FILE_MAN,
       V.CRAFT_SEQ,
       C.CRAFT_PATH,
       C.MEMO,
       C.CRAFT_FILE_LV2_E CRAFT_FILE_LV2,
       (SELECT LISTAGG(A.CRAFT_NO_LV2 || '【' || C.CREATE_NAME || '】', ';') within group(order by A.CRAFT_NO_LV2)
          FROM CRAFT_FILE_LV2 A
         WHERE INSTR(C.CRAFT_FILE_LV2_E, A.PK) > 0) CRAFT_FILE_LV2_DESC,
       (SELECT REPLACE(WM_CONCAT(D.JUDGE_STOVE_NO || '(' ||
                                 DECODE(D.PLANSTATUS,
                                        '00',
                                        '计划',
                                        '01',
                                        '下发',
                                        '02',
                                        '生产中',
                                        '03',
                                        '生产完成',
                                        '04',
                                        '关闭A') || ')'),
                       ',',
                       '；')
          FROM PLN_ZY_DBK_M D
         WHERE D.ORD_LN_DLY_PK = V.ORD_LN_DLY_PK
           AND D.PRO_PLAN_ID = V.PRO_PLAN_ID
           AND D.GX_PLAN_NO = V.GX_PLAN_NO) HEATON_PLN_SET,
       V.PRO_PLAN_ID,
       V.GX_PLAN_NO,
       V.ORD_LN_DLY_PK,
       NULL
  FROM PLN_ORDER_DBK_S V
  LEFT JOIN CRAFT_ORD_DESIGN C
    ON C.ORD_LN_PK = {0}
   AND C.CRAFT_SEQ = V.CRAFT_SEQ
 WHERE V.PRO_PLAN_ID IN
       (SELECT T.PRO_PLAN_ID
          FROM PLN_ORDER_DBK T
         WHERE SUBSTR(T.ORD_LN_DLY_PK, 1, 35) = {0})
UNION ALL
--热处理          
SELECT DECODE(V.IF_CRAFT_LOCKED, '0', '否', '1', '是') IF_CRAFT_LOCKED,
       '热处理' PROCESS_DESC,
       DECODE(V.EXE_STATUS,
              '0',
              '计划',
              '1',
              '生产中',
              '2',
              '完成',
              '3',
              '关闭A') EXE_STATUS,
       V.CRAFT_FILE_NO,
       V.CRAFT_FILE_MAN,
       V.CRAFT_SEQ,
       C.CRAFT_PATH,
       C.MEMO,
       C.CRAFT_FILE_LV2_F CRAFT_FILE_LV2,
       (SELECT LISTAGG(A.CRAFT_NO_LV2 || '【' || C.CREATE_NAME || '】', ';') within group(order by A.CRAFT_NO_LV2)
          FROM CRAFT_FILE_LV2 A
         WHERE INSTR(C.CRAFT_FILE_LV2_F, A.PK) > 0) CRAFT_FILE_LV2_DESC,
       (SELECT REPLACE(WM_CONCAT(D.JUDGE_STOVE_NO || '(' ||
                                 DECODE(D.PLANSTATUS,
                                        '00',
                                        '计划',
                                        '01',
                                        '下发',
                                        '02',
                                        '生产中',
                                        '03',
                                        '生产完成',
                                        '04',
                                        '关闭A') || ')'),
                       ',',
                       '；')
          FROM PLN_ZY_RCL_M D
         WHERE D.ORD_LN_DLY_PK = V.ORD_LN_DLY_PK
           AND D.PRO_PLAN_ID = V.PRO_PLAN_ID
           AND D.GX_PLAN_NO = V.GX_PLAN_NO) HEATON_PLN_SET,
       V.PRO_PLAN_ID,
       V.GX_PLAN_NO,
       V.ORD_LN_DLY_PK,
       NULL
  FROM PLN_ORDER_RCL_S V
  LEFT JOIN CRAFT_ORD_DESIGN C
    ON C.ORD_LN_PK = {0}
   AND C.CRAFT_SEQ = V.CRAFT_SEQ
 WHERE V.PRO_PLAN_ID IN
       (SELECT T.PRO_PLAN_ID
          FROM PLN_ORDER_RCL T
         WHERE SUBSTR(T.ORD_LN_DLY_PK, 1, 35) = {0})
UNION ALL
--加工          
SELECT DECODE(V.IF_CRAFT_LOCKED, '0', '否', '1', '是') IF_CRAFT_LOCKED,
       '加工' PROCESS_DESC,
       DECODE(V.EXE_STATUS,
              '0',
              '计划',
              '1',
              '生产中',
              '2',
              '完成',
              '3',
              '关闭A') EXE_STATUS,
       V.CRAFT_FILE_NO,
       V.CRAFT_FILE_MAN,
       V.CRAFT_SEQ,
       C.CRAFT_PATH,
       C.MEMO,
       C.CRAFT_FILE_LV2_G CRAFT_FILE_LV2,
       (SELECT LISTAGG(A.CRAFT_NO_LV2 || '【' || C.CREATE_NAME || '】', ';') within group(order by A.CRAFT_NO_LV2)
          FROM CRAFT_FILE_LV2 A
         WHERE INSTR(C.CRAFT_FILE_LV2_G, A.PK) > 0) CRAFT_FILE_LV2_DESC,
       (SELECT REPLACE(WM_CONCAT(D.JUDGE_STOVE_NO || '(' ||
                                 DECODE(D.PLANSTATUS,
                                        '00',
                                        '计划',
                                        '01',
                                        '下发',
                                        '02',
                                        '生产中',
                                        '03',
                                        '生产完成',
                                        '04',
                                        '关闭A') || ')'),
                       ',',
                       '；')
          FROM PLN_ZY_JGX_M D
         WHERE D.ORD_LN_DLY_PK = V.ORD_LN_DLY_PK
           AND D.PRO_PLAN_ID = V.PRO_PLAN_ID
           AND D.GX_PLAN_NO = V.GX_PLAN_NO) HEATON_PLN_SET,
       V.PRO_PLAN_ID,
       V.GX_PLAN_NO,
       V.ORD_LN_DLY_PK,
       NULL
  FROM PLN_ORDER_JGX_S V
  LEFT JOIN CRAFT_ORD_DESIGN C
    ON C.ORD_LN_PK = {0}
   AND C.CRAFT_SEQ = V.CRAFT_SEQ
 WHERE V.PRO_PLAN_ID IN
       (SELECT T.PRO_PLAN_ID
          FROM PLN_ORDER_JGX T
         WHERE SUBSTR(T.ORD_LN_DLY_PK, 1, 35) = {0})
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.queryPlnProcessBl" desc="查询计划各个工序Bl">
		<![CDATA[
SELECT DECODE(T.IF_CRAFT_LOCKED, '0', '否', '1', '是') IF_CRAFT_LOCKED,
       '轧制' PROCESS_DESC,
       DECODE(T.EXE_STATUS,
              '0',
              '计划',
              '1',
              '生产中',
              '2',
              '完成',
              '3',
              '关闭A') EXE_STATUS,
       T.CRAFT_FILE_NO,
       T.CRAFT_FILE_MAN,
       T.CRAFT_SEQ,
       C.CRAFT_PATH,
       C.MEMO,
       C.CRAFT_FILE_LV2_D,
       (SELECT REPLACE(WM_CONCAT(D.JUDGE_STOVE_NO || '(' ||
                                 DECODE(D.PLANSTATUS,
                                        '00',
                                        '计划',
                                        '10',
                                        '下发',
                                        '20',
                                        '生产中',
                                        '30',
                                        '生产完成',
                                        '40',
                                        '关闭A') || ')'),
                       ',',
                       '；')
          FROM PLN_ZY_ZG_M D
         WHERE D.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK
           AND D.PRO_PLAN_ID = T.PRO_PLAN_ID
           AND D.GX_PLAN_NO = T.GX_PLAN_NO) HEATON_PLN_SET,
       T.PRO_PLAN_ID,
       T.GX_PLAN_NO,
       T.ORD_LN_DLY_PK,
       T.GPREQ_ID
  FROM PLN_ORDER_ZG_S T
  LEFT JOIN CRAFT_ORD_DESIGN C
    ON C.ORD_LN_PK = {0}
   AND C.CRAFT_SEQ = T.CRAFT_SEQ
 WHERE T.ORD_LN_DLY_PK IN (SELECT T.ORD_LN_DLY_PK
                             FROM PLN_SALEORD T
                            WHERE T.PORDERSTATUS < 4
                              AND T.ORD_LN_PK = {0})

UNION ALL
--镦拨扩
SELECT DECODE(T.IF_CRAFT_LOCKED, '0', '否', '1', '是') IF_CRAFT_LOCKED,
       '镦拔扩' PROCESS_DESC,
       DECODE(T.EXE_STATUS,
              '0',
              '计划',
              '1',
              '生产中',
              '2',
              '完成',
              '3',
              '关闭A') EXE_STATUS,
       T.CRAFT_FILE_NO,
       T.CRAFT_FILE_MAN,
       T.CRAFT_SEQ,
       C.CRAFT_PATH,
       C.MEMO,
       C.CRAFT_FILE_LV2_D,
       (SELECT REPLACE(WM_CONCAT(D.JUDGE_STOVE_NO || '(' ||
                                 DECODE(D.PLANSTATUS,
                                        '00',
                                        '计划',
                                        '10',
                                        '下发',
                                        '20',
                                        '生产中',
                                        '30',
                                        '生产完成',
                                        '40',
                                        '关闭A') || ')'),
                       ',',
                       '；')
          FROM PLN_ZY_DBK_M D
         WHERE D.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK
           AND D.PRO_PLAN_ID = T.PRO_PLAN_ID
           AND D.GX_PLAN_NO = T.GX_PLAN_NO) HEATON_PLN_SET,
       T.PRO_PLAN_ID,
       T.GX_PLAN_NO,
       T.ORD_LN_DLY_PK,
       NULL
  FROM PLN_ORDER_DBK_S T
  LEFT JOIN CRAFT_ORD_DESIGN C
    ON C.ORD_LN_PK = {0}
   AND C.CRAFT_SEQ = T.CRAFT_SEQ
 WHERE T.ORD_LN_DLY_PK IN (SELECT T.ORD_LN_DLY_PK
                             FROM PLN_SALEORD T
                            WHERE T.PORDERSTATUS < 4
                              AND T.ORD_LN_PK = {0})
UNION ALL
--热处理
SELECT DECODE(T.IF_CRAFT_LOCKED, '0', '否', '1', '是') IF_CRAFT_LOCKED,
       '热处理' PROCESS_DESC,
       DECODE(T.EXE_STATUS,
              '0',
              '计划',
              '1',
              '生产中',
              '2',
              '完成',
              '3',
              '关闭A') EXE_STATUS,
       T.CRAFT_FILE_NO,
       T.CRAFT_FILE_MAN,
       T.CRAFT_SEQ,
       C.CRAFT_PATH,
       C.MEMO,
       C.CRAFT_FILE_LV2_D,
       (SELECT REPLACE(WM_CONCAT(D.JUDGE_STOVE_NO || '(' ||
                                 DECODE(D.PLANSTATUS,
                                        '00',
                                        '计划',
                                        '10',
                                        '下发',
                                        '20',
                                        '生产中',
                                        '30',
                                        '生产完成',
                                        '40',
                                        '关闭A') || ')'),
                       ',',
                       '；')
          FROM PLN_ZY_RCL_M D
         WHERE D.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK
           AND D.PRO_PLAN_ID = T.PRO_PLAN_ID
           AND D.GX_PLAN_NO = T.GX_PLAN_NO) HEATON_PLN_SET,
       T.PRO_PLAN_ID,
       T.GX_PLAN_NO,
       T.ORD_LN_DLY_PK,
       NULL
  FROM PLN_ORDER_RCL_S T
  LEFT JOIN CRAFT_ORD_DESIGN C
    ON C.ORD_LN_PK = {0}
   AND C.CRAFT_SEQ = T.CRAFT_SEQ
 WHERE T.ORD_LN_DLY_PK IN (SELECT T.ORD_LN_DLY_PK
                             FROM PLN_SALEORD T
                            WHERE T.PORDERSTATUS < 4
                              AND T.ORD_LN_PK = {0})
UNION ALL
--管加工
SELECT DECODE(T.IF_CRAFT_LOCKED, '0', '否', '1', '是') IF_CRAFT_LOCKED,
       '加工' PROCESS_DESC,
       DECODE(T.EXE_STATUS,
              '0',
              '计划',
              '1',
              '生产中',
              '2',
              '完成',
              '3',
              '关闭A') EXE_STATUS,
       T.CRAFT_FILE_NO,
       T.CRAFT_FILE_MAN,
       T.CRAFT_SEQ,
       C.CRAFT_PATH,
       C.MEMO,
       C.CRAFT_FILE_LV2_D,
       (SELECT REPLACE(WM_CONCAT(D.JUDGE_STOVE_NO || '(' ||
                                 DECODE(D.PLANSTATUS,
                                        '00',
                                        '计划',
                                        '10',
                                        '下发',
                                        '20',
                                        '生产中',
                                        '30',
                                        '生产完成',
                                        '40',
                                        '关闭A') || ')'),
                       ',',
                       '；')
          FROM PLN_ZY_JGX_M D
         WHERE D.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK
           AND D.PRO_PLAN_ID = T.PRO_PLAN_ID
           AND D.GX_PLAN_NO = T.GX_PLAN_NO) HEATON_PLN_SET,
       T.PRO_PLAN_ID,
       T.GX_PLAN_NO,
       T.ORD_LN_DLY_PK,
       NULL
  FROM PLN_ORDER_JGX_S T
  LEFT JOIN CRAFT_ORD_DESIGN C
    ON C.ORD_LN_PK = {0}
   AND C.CRAFT_SEQ = T.CRAFT_SEQ
 WHERE T.ORD_LN_DLY_PK IN (SELECT T.ORD_LN_DLY_PK
                             FROM PLN_SALEORD T
                            WHERE T.PORDERSTATUS < 4
                              AND T.ORD_LN_PK = {0})
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.queryPlnOrdProcessS" desc="查询计划各工序排产">
		<![CDATA[
--轧制
SELECT V.ORD_LN_DLY_PK,
       V.BOM,
       V.PLINE_CODE,
       B.PLINE_NAME,
       V.PRO_PLAN_ID,
       V.GX_PLAN_NO,
       'D' PROCESS_CODE,
       V.CIC,
       V.PIC,
       V.SIC,
       V.DIC,
       V.WIC,
       V.GIC,
       V.CIC_GROUP_GP,
       V.PIC_GROUP_GP,
       V.SIC_GROUP_GP,
       V.DIC_GROUP_GP,
       V.WIC_GROUP_GP,
       V.GIC_GROUP_GP
  FROM PLN_ORDER_ZG_S V
  LEFT JOIN COM_BASE_PLINE B
    ON B.PLINE_CODE = V.PLINE_CODE
 WHERE V.PRO_PLAN_ID IN
       (SELECT T.PRO_PLAN_ID
          FROM PLN_ORDER_ZG T
         WHERE SUBSTR(T.ORD_LN_DLY_PK, 1, 35) = {0})
   AND V.EXE_STATUS IN ('0')
   AND V.CRAFT_SEQ <> (SELECT MAX(A.CRAFT_SEQ)
                         FROM CRAFT_ORD_DESIGN A
                        WHERE A.ORD_LN_PK = {0})
UNION ALL
--镦拨扩          
SELECT V.ORD_LN_DLY_PK,
       V.BOM,
       V.PLINE_CODE,
       B.PLINE_NAME,
       V.PRO_PLAN_ID,
       V.GX_PLAN_NO,
       'E' PROCESS_CODE,
       V.CIC,
       V.PIC,
       V.SIC,
       V.DIC,
       V.WIC,
       V.GIC,
       NULL,
       NULL,
       NULL,
       NULL,
       NULL,
       NULL
  FROM PLN_ORDER_DBK_S V
  LEFT JOIN COM_BASE_PLINE B
    ON B.PLINE_CODE = V.PLINE_CODE
 WHERE V.PRO_PLAN_ID IN
       (SELECT T.PRO_PLAN_ID
          FROM PLN_ORDER_DBK T
         WHERE SUBSTR(T.ORD_LN_DLY_PK, 1, 35) = {0})
   AND V.EXE_STATUS IN ('0')
   AND V.CRAFT_SEQ <> (SELECT MAX(A.CRAFT_SEQ)
                         FROM CRAFT_ORD_DESIGN A
                        WHERE A.ORD_LN_PK = {0})
UNION ALL
--热处理          
SELECT V.ORD_LN_DLY_PK,
       V.BOM,
       V.PLINE_CODE,
       B.PLINE_NAME,
       V.PRO_PLAN_ID,
       V.GX_PLAN_NO,
       'F' PROCESS_CODE,
       V.CIC,
       V.PIC,
       V.SIC,
       V.DIC,
       V.WIC,
       V.GIC,
       NULL,
       NULL,
       NULL,
       NULL,
       NULL,
       NULL
  FROM PLN_ORDER_RCL_S V
  LEFT JOIN COM_BASE_PLINE B
    ON B.PLINE_CODE = V.PLINE_CODE
 WHERE V.PRO_PLAN_ID IN
       (SELECT T.PRO_PLAN_ID
          FROM PLN_ORDER_RCL T
         WHERE SUBSTR(T.ORD_LN_DLY_PK, 1, 35) = {0})
   AND V.EXE_STATUS IN ('0')
   AND V.CRAFT_SEQ <> (SELECT MAX(A.CRAFT_SEQ)
                         FROM CRAFT_ORD_DESIGN A
                        WHERE A.ORD_LN_PK = {0})
UNION ALL
--加工          
SELECT V.ORD_LN_DLY_PK,
       V.BOM,
       V.PLINE_CODE,
       B.PLINE_NAME,
       V.PRO_PLAN_ID,
       V.GX_PLAN_NO,
       'G' PROCESS_CODE,
       V.CIC,
       V.PIC,
       V.SIC,
       V.DIC,
       V.WIC,
       V.GIC,
       NULL,
       NULL,
       NULL,
       NULL,
       NULL,
       NULL
  FROM PLN_ORDER_JGX_S V
  LEFT JOIN COM_BASE_PLINE B
    ON B.PLINE_CODE = V.PLINE_CODE
 WHERE V.PRO_PLAN_ID IN
       (SELECT T.PRO_PLAN_ID
          FROM PLN_ORDER_JGX T
         WHERE SUBSTR(T.ORD_LN_DLY_PK, 1, 35) = {0})
   AND V.EXE_STATUS IN ('0')
   AND V.CRAFT_SEQ <> (SELECT MAX(A.CRAFT_SEQ)
                         FROM CRAFT_ORD_DESIGN A
                        WHERE A.ORD_LN_PK = {0})
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.queryPlnOrdProcessSBl" desc="查询计划各工序排产（备料）">
		<![CDATA[
SELECT T.ORD_LN_DLY_PK,
       T.BOM,
       T.PLINE_CODE,
       B.PLINE_NAME,
       T.PRO_PLAN_ID,
       T.GX_PLAN_NO,
       'D' PROCESS_CODE,
       T.CIC,
       T.PIC,
       T.SIC,
       T.DIC,
       T.WIC,
       T.GIC,
       T.CIC_GROUP_GP,
       T.PIC_GROUP_GP,
       T.SIC_GROUP_GP,
       T.DIC_GROUP_GP,
       T.WIC_GROUP_GP,
       T.GIC_GROUP_GP
  FROM PLN_ORDER_ZG_S T
  LEFT JOIN COM_BASE_PLINE B
    ON B.PLINE_CODE = T.PLINE_CODE
 WHERE T.ORD_LN_DLY_PK IN (SELECT T.ORD_LN_DLY_PK
                             FROM PLN_SALEORD T
                            WHERE T.PORDERSTATUS < 4
                              AND T.ORD_LN_PK = {0})
   AND T.EXE_STATUS IN ('0')
   AND T.CRAFT_SEQ <> (SELECT MAX(A.CRAFT_SEQ)
                         FROM CRAFT_ORD_DESIGN A
                        WHERE A.ORD_LN_PK = {0})
UNION ALL
--镦拨扩
SELECT T.ORD_LN_DLY_PK,
       T.BOM,
       T.PLINE_CODE,
       B.PLINE_NAME,
       T.PRO_PLAN_ID,
       T.GX_PLAN_NO,
       'E' PROCESS_CODE,
       T.CIC,
       T.PIC,
       T.SIC,
       T.DIC,
       T.WIC,
       T.GIC,
       NULL,
       NULL,
       NULL,
       NULL,
       NULL,
       NULL
  FROM PLN_ORDER_DBK_S T
  LEFT JOIN COM_BASE_PLINE B
    ON B.PLINE_CODE = T.PLINE_CODE
 WHERE T.ORD_LN_DLY_PK IN (SELECT T.ORD_LN_DLY_PK
                             FROM PLN_SALEORD T
                            WHERE T.PORDERSTATUS < 4
                              AND T.ORD_LN_PK = {0})
   AND T.EXE_STATUS IN ('0')
   AND T.CRAFT_SEQ <> (SELECT MAX(A.CRAFT_SEQ)
                         FROM CRAFT_ORD_DESIGN A
                        WHERE A.ORD_LN_PK = {0})
UNION ALL
--热处理
SELECT T.ORD_LN_DLY_PK,
       T.BOM,
       T.PLINE_CODE,
       B.PLINE_NAME,
       T.PRO_PLAN_ID,
       T.GX_PLAN_NO,
       'F' PROCESS_CODE,
       T.CIC,
       T.PIC,
       T.SIC,
       T.DIC,
       T.WIC,
       T.GIC,
       NULL,
       NULL,
       NULL,
       NULL,
       NULL,
       NULL
  FROM PLN_ORDER_RCL_S T
  LEFT JOIN COM_BASE_PLINE B
    ON B.PLINE_CODE = T.PLINE_CODE
 WHERE T.ORD_LN_DLY_PK IN (SELECT T.ORD_LN_DLY_PK
                             FROM PLN_SALEORD T
                            WHERE T.PORDERSTATUS < 4
                              AND T.ORD_LN_PK = {0})
   AND T.EXE_STATUS IN ('0')
   AND T.CRAFT_SEQ <> (SELECT MAX(A.CRAFT_SEQ)
                         FROM CRAFT_ORD_DESIGN A
                        WHERE A.ORD_LN_PK = {0})
UNION ALL
--管加工
SELECT T.ORD_LN_DLY_PK,
       T.BOM,
       T.PLINE_CODE,
       B.PLINE_NAME,
       T.PRO_PLAN_ID,
       T.GX_PLAN_NO,
       'G' PROCESS_CODE,
       T.CIC,
       T.PIC,
       T.SIC,
       T.DIC,
       T.WIC,
       T.GIC,
       NULL,
       NULL,
       NULL,
       NULL,
       NULL,
       NULL
  FROM PLN_ORDER_JGX_S T
  LEFT JOIN COM_BASE_PLINE B
    ON B.PLINE_CODE = T.PLINE_CODE
 WHERE T.ORD_LN_DLY_PK IN (SELECT T.ORD_LN_DLY_PK
                             FROM PLN_SALEORD T
                            WHERE T.PORDERSTATUS < 4
                              AND T.ORD_LN_PK = {0})
   AND T.EXE_STATUS IN ('0')
   AND T.CRAFT_SEQ <> (SELECT MAX(A.CRAFT_SEQ)
                         FROM CRAFT_ORD_DESIGN A
                        WHERE A.ORD_LN_PK = {0})
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.queryPlnSaleOrdProc" desc="查询排产分解表">
		<![CDATA[
SELECT DISTINCT T.ORD_LN_DLY_PK, T.MSC, T.INDEX_SEQ, T.PROCESS_SEQ
  FROM PLN_SALEORD_PROC T
 WHERE T.ORD_LN_DLY_PK = {0}
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.queryNewCraftMsc" desc="查询新工艺MSC">
		<![CDATA[
SELECT B.MSC VALUE
  FROM CRAFT_ORD_DESIGN A, CRAFT_ORD_DESIGN_MSC B
 WHERE A.DESGIN_KEY = B.DESGIN_KEY
   AND A.ORD_LN_PK = {0}
   AND A.CRAFT_SEQ = (SELECT MAX(C.CRAFT_SEQ)
                        FROM CRAFT_ORD_DESIGN C
                       WHERE C.ORD_LN_PK = A.ORD_LN_PK)
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.queryNewCraftBacklog" desc="查询新工艺制程">
		<![CDATA[
SELECT B.MSC_PLINE VALUE, B.WHOLE_BACKLOG VALUE2
  FROM CRAFT_ORD_DESIGN A, Craft_Ord_Design_Msc_Pl B
 WHERE A.DESGIN_KEY = B.DESGIN_KEY
   AND A.ORD_LN_PK = {0}
   AND A.CRAFT_SEQ = (SELECT MAX(C.CRAFT_SEQ)
                        FROM CRAFT_ORD_DESIGN C
                       WHERE C.ORD_LN_PK = A.ORD_LN_PK)
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.queryPlnOrdJg" desc="查询计划接箍">
		<![CDATA[
select t.Code_Jg, t.Pro_Plan_Id from PLN_ORDER_JG t where t.ord_ln_dly_pk = {0}
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.queryNewCraftJg" desc="查询新工艺接箍">
		<![CDATA[
SELECT B.CODE_JG VALUE
  FROM craft_ord_design a, CRAFT_ORD_DESIGN_MSC_JG b
 where a.ord_ln_pk = {0}
 AND A.CRAFT_SEQ = (SELECT MAX(C.CRAFT_SEQ)
                        FROM CRAFT_ORD_DESIGN C
                       WHERE C.ORD_LN_PK = A.ORD_LN_PK)
   and a.desgin_key = b.desgin_key
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.queryPlnOrdJgBL" desc="查询计划接箍备料">
		<![CDATA[
select distinct t.Code_Jg_Bl from PLN_JG_AND_BL t where t.pro_plan_id = {0}
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.queryNewCraftJgBl" desc="查询新工艺接箍备料">
		<![CDATA[
SELECT B.PSC_BL VALUE
  FROM CRAFT_ORD_DESIGN A, CRAFT_ORD_DESIGN_MSC_JG_BL B
 WHERE A.ORD_LN_PK = {0}
   AND A.CRAFT_SEQ = (SELECT MAX(C.CRAFT_SEQ)
                        FROM CRAFT_ORD_DESIGN C
                       WHERE C.ORD_LN_PK = A.ORD_LN_PK)
   AND A.DESGIN_KEY = B.DESGIN_KEY
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.queryPlnBl" desc="查询计划备料">
		<![CDATA[
select distinct t.code_dj_bl
  from PLN_PORDER_BL_REQ t
 where t.bltype = '短节备料'
   and t.Ord_Ln_Dly_Pk = {0}
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.queryNewCraftBl" desc="查询新工艺备料">
		<![CDATA[
SELECT B.PSC_BL VALUE
  FROM CRAFT_ORD_DESIGN A, CRAFT_ORD_DESIGN_MSC_BL B
 WHERE A.ORD_LN_PK = {0}
   AND A.CRAFT_SEQ = (SELECT MAX(C.CRAFT_SEQ)
                        FROM CRAFT_ORD_DESIGN C
                       WHERE C.ORD_LN_PK = A.ORD_LN_PK)
   AND A.DESGIN_KEY = B.DESGIN_KEY
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.queryNewCraftBom" desc="查询新工艺Bom">
		<![CDATA[
SELECT B.BOM VALUE
  FROM CRAFT_ORD_DESIGN A, CRAFT_ORD_LINE_BOM B
 WHERE A.ORD_LN_PK = {0}
   AND A.CRAFT_SEQ = (SELECT MAX(C.CRAFT_SEQ)
                        FROM CRAFT_ORD_DESIGN C
                       WHERE C.ORD_LN_PK = A.ORD_LN_PK)
   AND A.DESGIN_KEY = B.DESGIN_KEY
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.queryNewCraftPline" desc="查询新工艺产线">
		<![CDATA[
SELECT B.Pline_Code VALUE
  FROM CRAFT_ORD_DESIGN A, CRAFT_ORD_DESIGN_MSC_PL_GX_PRL B
 WHERE A.ORD_LN_PK = {0}
   AND A.CRAFT_SEQ = (SELECT MAX(C.CRAFT_SEQ)
                        FROM CRAFT_ORD_DESIGN C
                       WHERE C.ORD_LN_PK = A.ORD_LN_PK)
   AND A.DESGIN_KEY = B.DESGIN_KEY
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.queryLgNkIndex" desc="获取内控索引号">
		<![CDATA[
SELECT NULL CIC,
       WM_CONCAT(PIC) PIC,
       WM_CONCAT(SIC) SIC,
       WM_CONCAT(DIC) DIC,
       WM_CONCAT(WIC) WIC,
       WM_CONCAT(GIC) GIC,
       MAX(MSC_PLINE) MSC_PLINE
  FROM (SELECT T.CIC, T.PIC, T.SIC, T.DIC, T.WIC, T.GIC, T.MSC_PLINE
          FROM CRAFT_ORD_DESIGN_MSC_PL_PRC T
         WHERE T.DESGIN_KEY = {0}
           AND T.MSC_PLINE = (SELECT A.INDEX_SEQ
                                FROM PLN_ORDER_ZG_S A
                               WHERE A.PRO_PLAN_ID = {1}
                                 AND A.GX_PLAN_NO = {2})
           AND T.PROCESS_CODE IN ('A', 'B', 'C'))
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.queryLgNkCic" desc="获取内控索引号">
		<![CDATA[
SELECT WM_CONCAT(D.CIC) CIC
  FROM CRAFT_ORD_DESIGN_STD_CIC   D,
       COM_MSC_STD_CIC            F,
       CRAFT_ORD_DESIGN_MSC_PL_GZ E
 WHERE D.DESGIN_KEY = {0}
   AND D.MSC_PLINE = (SELECT A.INDEX_SEQ
                        FROM PLN_ORDER_ZG_S A
                       WHERE A.PRO_PLAN_ID = {1}
                         AND A.GX_PLAN_NO = {2})
   AND D.PROCESS_CODE IN ('A', 'B', 'C')
   AND F.CIC = D.CIC
   AND E.DESGIN_KEY = D.DESGIN_KEY
   AND E.MSC_PLINE = D.MSC_PLINE
   AND E.PRIORITY < 100
   AND F.GRADECODE = E.GRADECODE
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.queryZgNkIndex" desc="获取内控索引号">
		<![CDATA[
 SELECT T.CIC, T.PIC, T.SIC, T.DIC, T.WIC, T.GIC, T.MSC_PLINE
     FROM CRAFT_ORD_DESIGN_MSC_PL_PRC T
    WHERE T.DESGIN_KEY = {0}
      AND T.MSC_PLINE = (SELECT A.INDEX_SEQ
                        FROM PLN_ORDER_ZG_S A
                       WHERE A.PRO_PLAN_ID = {1}
                         AND A.GX_PLAN_NO = {2})
      AND T.PROCESS_CODE = 'D'
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.queryZgNkLkGrade" desc="获取轧管内控利库钢种和CIC">
		<![CDATA[
SELECT WM_CONCAT(DISTINCT CIC) VALUE, WM_CONCAT(DISTINCT GRADECODE) VALUE2, WM_CONCAT(DISTINCT GRADENAME) VALUE3
  FROM (SELECT DISTINCT A.CIC, C.GRADECODE, C.GRADENAME
          FROM CRAFT_ORD_DESIGN_STD_CIC   A,
               COM_MSC_STD_CIC            B,
               CRAFT_ORD_DESIGN_MSC_PL_GZ C
         WHERE A.DESGIN_KEY = {0}
           AND A.MSC_PLINE = (SELECT A.INDEX_SEQ
                        FROM PLN_ORDER_ZG_S A
                       WHERE A.PRO_PLAN_ID = {1}
                         AND A.GX_PLAN_NO = {2})
           AND A.PROCESS_CODE = 'A'
           AND A.DESGIN_KEY = C.DESGIN_KEY
           AND C.MSC_PLINE = A.MSC_PLINE
           AND C.PRIORITY >= 100
           AND B.CIC = A.CIC
           AND B.GRADECODE = C.GRADECODE)
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.queryZgNkLkCic" desc="获取轧管内控利库钢种和CIC">
		<![CDATA[
SELECT WM_CONCAT(DISTINCT CIC) VALUE, WM_CONCAT(DISTINCT GRADECODE) VALUE2, WM_CONCAT(DISTINCT GRADENAME) VALUE3
  FROM (SELECT DISTINCT A.CIC, C.GRADECODE, C.GRADENAME
          FROM CRAFT_ORD_DESIGN_STD_CIC   A,
               COM_MSC_STD_CIC            B,
               CRAFT_ORD_DESIGN_MSC_PL_GZ C
         WHERE A.DESGIN_KEY = {0}
           AND A.MSC_PLINE = (SELECT A.INDEX_SEQ
                        FROM PLN_ORDER_ZG_S A
                       WHERE A.PRO_PLAN_ID = {1}
                         AND A.GX_PLAN_NO = {2})
           AND A.PROCESS_CODE = 'D'
           AND A.DESGIN_KEY = C.DESGIN_KEY
           AND C.MSC_PLINE = A.MSC_PLINE
           AND C.PRIORITY >= 100
           AND B.CIC = A.CIC
           AND B.GRADECODE = C.GRADECODE)
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.queryDbkNkIndex" desc="获取内控索引号">
		<![CDATA[
 SELECT T.CIC, T.PIC, T.SIC, T.DIC, T.WIC, T.GIC, T.MSC_PLINE
     FROM CRAFT_ORD_DESIGN_MSC_PL_PRC T
    WHERE T.DESGIN_KEY = {0}
      AND T.MSC_PLINE = (SELECT A.INDEX_SEQ
                        FROM PLN_ORDER_DBK_S A
                       WHERE A.PRO_PLAN_ID = {1}
                         AND A.GX_PLAN_NO = {2})
      AND T.PROCESS_CODE = 'E'
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.queryRclNkIndex" desc="获取内控索引号">
		<![CDATA[
 SELECT T.CIC, T.PIC, T.SIC, T.DIC, T.WIC, T.GIC, T.MSC_PLINE
     FROM CRAFT_ORD_DESIGN_MSC_PL_PRC T
    WHERE T.DESGIN_KEY = {0}
      AND T.MSC_PLINE = (SELECT A.INDEX_SEQ
                        FROM PLN_ORDER_RCL_S A
                       WHERE A.PRO_PLAN_ID = {1}
                         AND A.GX_PLAN_NO = {2})
      AND T.PROCESS_CODE = 'F'
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.queryJgxNkIndex" desc="获取内控索引号">
		<![CDATA[
 SELECT T.CIC, T.PIC, T.SIC, T.DIC, T.WIC, T.GIC, T.MSC_PLINE
     FROM CRAFT_ORD_DESIGN_MSC_PL_PRC T
    WHERE T.DESGIN_KEY = {0}
      AND T.MSC_PLINE = (SELECT A.INDEX_SEQ
                        FROM PLN_ORDER_JGX_S A
                       WHERE A.PRO_PLAN_ID = {1}
                         AND A.GX_PLAN_NO = {2})
      AND T.PROCESS_CODE = 'G'
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.updatePlnOrdZg" desc="更新轧管">
		<![CDATA[
update PLN_ORDER_ZG t
   set t.CRAFT_FILE_NO  = {0},
       t.craft_file_man = {1},
       t.craft_seq      = {2},
       t.CRAFT_NO_V     = {3}
 where t.pro_plan_id = {4}
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.updatePlnOrdZgS" desc="更新轧管">
		<![CDATA[
UPDATE PLN_ORDER_ZG_S T
   SET T.CRAFT_FILE_NO   = {0},
       T.CRAFT_FILE_MAN  = {1},
       T.CRAFT_SEQ       = {2},
       T.IF_CRAFT_LOCKED = '1',
       T.CIC             = {5},
       T.PIC             = {6},
       T.SIC             = {7},
       T.DIC             = {8},
       T.WIC             = {9},
       T.GIC             = {10},
       T.CIC_GROUP_LK    = {11},
       T.GRADECODE_LK    = {12},
       T.GRADENAME_LK    = {13}
 WHERE T.PRO_PLAN_ID = {3}
   AND T.GX_PLAN_NO = {4}
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.updatePlnOrdZgS2" desc="更新轧管">
		<![CDATA[
UPDATE PLN_ORDER_ZG_S T
   SET T.CRAFT_FILE_NO   = {0},
       T.CRAFT_FILE_MAN  = {1},
       T.CRAFT_SEQ       = {2},
       T.IF_CRAFT_LOCKED = '1',
       T.CIC_GROUP_GP    = {5},
       T.PIC_GROUP_GP    = {6},
       T.SIC_GROUP_GP    = {7},
       T.DIC_GROUP_GP    = {8},
       T.WIC_GROUP_GP    = {9},
       T.GIC_GROUP_GP    = {10}
 WHERE T.PRO_PLAN_ID = {3}
   AND T.GX_PLAN_NO = {4}
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.getZgSLgCic" desc="获取炼钢索引码">
		<![CDATA[
SELECT T.CIC_GROUP_GP
  FROM PLN_ORDER_ZG_S T
 WHERE T.PRO_PLAN_ID = {0}
   AND T.GX_PLAN_NO = {1}
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.getZgSByPk" desc="获取炼钢索引码">
		<![CDATA[
SELECT T.*
  FROM PLN_ORDER_ZG_S T
 WHERE T.PRO_PLAN_ID = {0}
   AND T.GX_PLAN_NO = {1}
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.updatePlnOrdDbk" desc="更新镦拔扩">
		<![CDATA[
update PLN_ORDER_DBK t
   set t.CRAFT_FILE_NO  = {0},
       t.craft_file_man = {1},
       t.craft_seq      = {2}
 where t.pro_plan_id = {3}
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.updatePlnOrdDbkS" desc="更新镦拔扩">
		<![CDATA[
 UPDATE PLN_ORDER_DBK_S T
    SET T.CRAFT_FILE_NO   = {0},
        T.CRAFT_FILE_MAN  = {1},
        T.CRAFT_SEQ       = {2},
        T.IF_CRAFT_LOCKED = '1',
        T.CIC             = {5},
        T.PIC             = {6},
        T.SIC             = {7},
        T.DIC             = {8},
        T.WIC             = {9},
        T.GIC             = {10}
  WHERE T.PRO_PLAN_ID = {3}
    AND T.GX_PLAN_NO = {4}
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.updatePlnOrdRcl" desc="更新热处理">
		<![CDATA[
update PLN_ORDER_RCL t
   set t.CRAFT_FILE_NO  = {0},
       t.craft_file_man = {1},
       t.craft_seq      = {2}
 where t.pro_plan_id = {3}
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.updatePlnOrdRclS" desc="更新热处理">
		<![CDATA[
UPDATE PLN_ORDER_RCL_S T
   SET T.CRAFT_FILE_NO   = {0},
       T.CRAFT_FILE_MAN  = {1},
       T.CRAFT_SEQ       = {2},
       T.IF_CRAFT_LOCKED = '1',
       T.CIC             = {5},
       T.PIC             = {6},
       T.SIC             = {7},
       T.DIC             = {8},
       T.WIC             = {9},
       T.GIC             = {10}
 WHERE T.PRO_PLAN_ID = {3}
   AND T.GX_PLAN_NO = {4}
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.updatePlnOrdJgx" desc="更新加工">
		<![CDATA[
update PLN_ORDER_JGX t
   set t.CRAFT_FILE_NO  = {0},
       t.craft_file_man = {1},
       t.craft_seq      = {2}
 where t.pro_plan_id = {3}
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.updatePlnOrdJgxS" desc="更新加工">
		<![CDATA[
UPDATE PLN_ORDER_JGX_S T
   SET T.CRAFT_FILE_NO   = {0},
       T.CRAFT_FILE_MAN  = {1},
       T.CRAFT_SEQ       = {2},
       T.IF_CRAFT_LOCKED = '1',
       T.CIC             = {5},
       T.PIC             = {6},
       T.SIC             = {7},
       T.DIC             = {8},
       T.WIC             = {9},
       T.GIC             = {10}
 WHERE T.PRO_PLAN_ID = {3}
   AND T.GX_PLAN_NO = {4}
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.queryNewCraft" desc="查询新工艺文件主表">
		<![CDATA[
SELECT t.craft_no, t.delete_name, t.craft_seq, t.craft_no_v, T.DESGIN_KEY
  FROM CRAFT_ORD_DESIGN T
 WHERE T.ORD_LN_PK = {0}
   AND T.CRAFT_SEQ = (SELECT MAX(A.CRAFT_SEQ)
                        FROM CRAFT_ORD_DESIGN A
                       WHERE A.ORD_LN_PK = T.ORD_LN_PK)
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.updatePlnOrdProc" desc="修改计划排产表">
		<![CDATA[
UPDATE PLN_SALEORD_PROC T
   SET T.CRAFT_FILE_NO = {0}, T.CRAFT_FILE_MAN = {1}, T.CRAFT_SEQ = {2}
 WHERE T.ORD_LN_DLY_PK = {3}
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.QueryPreCraftLv2" desc="查询上一次工艺文件">
		<![CDATA[
SELECT T.ORD_LN_PK,
       T.CRAFT_SEQ,
       T.CRAFT_FILE_LV2_D_DESC,
       T.CRAFT_FILE_LV2_E_DESC,
       T.CRAFT_FILE_LV2_F_DESC,
       T.CRAFT_FILE_LV2_G_DESC,
       T.CRAFT_FILE_LV2_H_DESC,
       T.CRAFT_FILE_LV2_D,
       T.CRAFT_FILE_LV2_E,
       T.CRAFT_FILE_LV2_F,
       T.CRAFT_FILE_LV2_G,
       T.CRAFT_FILE_LV2_H
  FROM CRAFT_ORD_DESIGN T
 WHERE T.ORD_LN_PK = {0}
   AND T.CRAFT_SEQ = (SELECT MAX(A.CRAFT_SEQ) - 1
                        FROM CRAFT_ORD_DESIGN A
                       WHERE A.ORD_LN_PK = T.ORD_LN_PK)
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.updateCraftLv2" desc="修改二级工艺文件">
		<![CDATA[
DECLARE
BEGIN
  FOR V IN (SELECT *
              FROM CRAFT_ORD_DESIGN T
             WHERE T.ORD_LN_PK = {0}
               AND T.CRAFT_SEQ = {1}) LOOP
    UPDATE CRAFT_ORD_DESIGN T
       SET T.CRAFT_FILE_LV2_D      = DECODE({2}, 'False', NULL, V.CRAFT_FILE_LV2_D),
           T.CRAFT_FILE_LV2_E      = DECODE({3}, 'False', NULL, V.CRAFT_FILE_LV2_E),
           T.CRAFT_FILE_LV2_F      = DECODE({4}, 'False', NULL,  V.CRAFT_FILE_LV2_F),
           T.CRAFT_FILE_LV2_G      = DECODE({5}, 'False', NULL,  V.CRAFT_FILE_LV2_G),
           T.CRAFT_FILE_LV2_H      = DECODE({6}, 'False', NULL,  V.CRAFT_FILE_LV2_H),
           T.CRAFT_FILE_LV2_D_DESC = DECODE({2}, 'False', NULL,  V.CRAFT_FILE_LV2_D_DESC),
           T.CRAFT_FILE_LV2_E_DESC = DECODE({3}, 'False', NULL,  V.CRAFT_FILE_LV2_E_DESC),
           T.CRAFT_FILE_LV2_F_DESC = DECODE({4}, 'False', NULL,  V.CRAFT_FILE_LV2_F_DESC),
           T.CRAFT_FILE_LV2_G_DESC = DECODE({5}, 'False', NULL,  V.CRAFT_FILE_LV2_G_DESC),
           T.CRAFT_FILE_LV2_H_DESC = DECODE({6}, 'False', NULL,  V.CRAFT_FILE_LV2_H_DESC)
     WHERE T.ORD_LN_PK = V.ORD_LN_PK
       AND T.CRAFT_SEQ = (SELECT MAX(B.CRAFT_SEQ)
                            FROM CRAFT_ORD_DESIGN B
                           WHERE B.ORD_LN_PK = T.ORD_LN_PK);
  END LOOP;
END;
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.UpdateCraftChangeMemo" desc="修改二级工艺文件备注">
		<![CDATA[
UPDATE CRAFT_ORD_DESIGN T
   SET T.CRAFT_CHANGE_MEMO = {2}
 WHERE T.ORD_LN_PK = {0}
   AND T.CRAFT_SEQ = {1}
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.UpdateCraftValidflag" desc="修改最大的工艺文件状态">
		<![CDATA[
UPDATE CRAFT_ORD_DESIGN T
   SET T.VALIDFLAG = {1}
 WHERE T.ORD_LN_PK = {0}
   AND T.CRAFT_SEQ = (SELECT MAX(CRAFT_SEQ)
                        FROM CRAFT_ORD_DESIGN A
                       WHERE A.ORD_LN_PK = T.ORD_LN_PK)
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.QueryTechnologyByUnit" desc="通过科室查询技术评审">
		<![CDATA[
SELECT *
  FROM (SELECT *
          FROM (SELECT DECODE(J.REVIEW_STATUS,
                              'W',
                              '待审',
                              'D',
                              '评审中',
                              'S',
                              '评审通过',
                              'F',
                              '评审失败',
                              'L',
                              '封锁') REVIEW_STATUS,
                       K.DESGIN_KEY,
                       DECODE(K.DESIGN_STS,
                              'W',
                              '等待',
                              'S',
                              '通过',
                              'F',
                              '失败') DESIGN_STS,
                       H.ORD_PK,
                       H.ORD_LN_PK,
                       H.ORDER_SEQ,
                       H.FINAL_USER,
                       H.FINAL_USER_DESC,
                       H.PSC,
                       H.PSC_DESC,
                       H.ORDER_SPEC_CODE,
                       H.ORDER_SPEC_DESC,
                       H.MODEL_CODE,
                       H.MODEL_DESC,
                       H.LEN_DESC,
                       H.ORDER_QTY,
                       H.ORDER_UNIT,
                       ROUND(H.PRDCT_WGT, 4) PRDCT_WGT,
                       H.DELVRY_RANGE_TPE,
                       H.DELVRY_RANGE_MIN,
                       H.DELVRY_RANGE_MAX,
                       '-' || H.DELVRY_RANGE_MIN || H.DELVRY_RANGE_TPE || '，' || '+' ||
                       H.DELVRY_RANGE_MAX || H.DELVRY_RANGE_TPE DELVRY_RANGE,
                       (SELECT BASENAME
                          FROM COM_BASE_INFO
                         WHERE BASECODE = OUTS_BILLET_FL) OUTS_BILLET_FL,
                       (SELECT BASENAME
                          FROM COM_BASE_INFO
                         WHERE BASECODE = OUTS_STL_PIPE_FL) OUTS_STL_PIPE_FL,
                       DECODE(H.ASSEL_FL, '1', 'True', 'False') ASSEL_FL,
                       H.ORDER_ADD_DESC,
                       H.ORDER_SPECIAL_DESC,
                       H.CUST_ALPHA_NO,
                       J.REVIEW_MAN,
                       J.REVIEW_DEPT,
                       TO_CHAR(J.REVIEW_EDATE, 'yyyy-mm-dd') REVIEW_EDATE,
                       G.ORDER_NO,
                       G.LOCAL_LAW,
                       G.CUSTOMER_NO,
                       G.REVW_RPT_NO,
                       DECODE(H.PRODUCER_FL, '1', 'True', 'False') PRODUCER_FL,
                       H.MSC,
                       H.MSC_DESC,
                       H.SPEC_CODE,
                       H.SPEC_NAME,
                       H.DIMATER,
                       H.HEIGHT,
                       J.REVIEW_NO,
                       H.ADD_ASK_NO,
                       DECODE(H.MPS_FL, '1', 'True', 'False') MPS_FL,
                       H.MPS_NO,
                       H.MPS_DESC,
                       H.STD_CODE,
                       H.STD_NAME,
                       DECODE(H.MAN_INSPECTION,
                              '1',
                              '可手探',
                              '0',
                              '不可手探') MAN_INSPECTION,
                       H.INSPECTION_VALUE,
                       TO_CHAR(H.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
                       H.CREATE_NAME,
                       DECODE(K.DESIGN_STS, 'S', '002001001001', A.UNIT_CODE) UNIT_CODE,
                       DECODE(K.DESIGN_STS, 'S', '计划科', A.UNIT_DESC) UNIT_DESC, --002001001001
                       A.ORD_LN_PK A_ORD_LN_PK,
                       ROW_NUMBER() OVER(PARTITION BY A.ORD_LN_PK ORDER BY A.SEQ_INDEX) RN,
                       G.ORDER_NO || '/' || H.ORDER_SEQ MNG_ORDER_NO
                  FROM SLM_ORDER_HEAD             G,
                       SLM_ORDER_REVIEW_ITEM_LIST J,
                       SLM_ORDER_LINE             H
                  LEFT JOIN SLM_ORD_DESIGN_STS_TKLG_LST A
                    ON A.ORD_LN_PK = H.ORD_LN_PK
                   AND A.VALIDFLAG = '1'
                   AND A.DESIGN_STS = 'F'
                  LEFT JOIN SLM_ORD_DESIGN_STS_TKLG K
                    ON H.ORD_LN_PK = K.ORD_LN_PK
                   AND K.VALIDFLAG = '1', SLM_ORDER_REVIEW N
                 WHERE H.ORD_PK = G.ORD_PK
                   AND G.ORD_PK = N.ORD_PK
                   AND N.REVIEW_NO = J.REVIEW_NO
                   AND J.LIST_PK_VAL = H.ORD_LN_PK
                   AND J.REVIEW_ITM = 'T'
                   AND J.LIST_TYP = 'L'
                   AND J.IS_CURT_REVIEW = '1'
                   AND H.VALIDFLAG = '1'
                   AND EXISTS
                 (SELECT 1
                          FROM SLM_ORD_DESIGN_STS_TKLG_LST T,
                               CORE_APP_DEPARTMENT         B,
                               CORE_APP_USER               C
                         WHERE T.ORD_LN_PK = H.ORD_LN_PK
                           AND (T.DESIGN_STS = 'F' OR T.VALIDFLAG = '1')
                           AND B.DEPARTID = T.UNIT_CODE
                           AND DECODE({0}, NULL, '1', B.PID) = NVL({0}, '1')
                           AND DECODE({1}, NULL, '1', T.UNIT_CODE) =
                               NVL({1}, '1')
                           AND C.USERID = T.UPDATE_NAME
                           AND DECODE({2}, NULL, '1', c.username) LIKE
                               NVL('%' || {2} || '%', '1'))
                   AND G.Validflag = '1')
         WHERE DECODE(A_ORD_LN_PK, NULL, 1, RN) <= 1
        UNION ALL
        SELECT *
          FROM (SELECT DECODE(G.REVIEW_STATUS,
                              '0',
                              '待审',
                              '1',
                              '评审中',
                              '2',
                              '评审通过',
                              '3',
                              '评审失败') REVIEW_STATUS,
                       J.DESGIN_KEY,
                       DECODE(K.DESIGN_STS,
                              'W',
                              '等待',
                              'S',
                              '通过',
                              'F',
                              '失败') DESIGN_STS,
                       null ORD_PK,
                       G.PSC_BL ORD_LN_PK,
                       null ORDER_SEQ,
                       null FINAL_USER,
                       null FINAL_USER_DESC,
                       B.PSC,
                       B.PSC_DESC,
                       null ORDER_SPEC_CODE,
                       null ORDER_SPEC_DESC,
                       G.MODEL_CODE,
                       G.MODEL_DESC,
                       G.MIN_L || '-' || G.MAX_L LEN_DESC,
                       null ORDER_QTY,
                       null ORDER_UNIT,
                       null PRDCT_WGT,
                       null DELVRY_RANGE_TPE,
                       null DELVRY_RANGE_MIN,
                       null DELVRY_RANGE_MAX,
                       null DELVRY_RANGE,
                       null OUTS_BILLET_FL,
                       null OUTS_STL_PIPE_FL,
                       'False' ASSEL_FL,
                       null ORDER_ADD_DESC,
                       null ORDER_SPECIAL_DESC,
                       null CUST_ALPHA_NO,
                       null REVIEW_MAN,
                       null REVIEW_DEPT,
                       null REVIEW_EDATE,
                       G.PSC_BL ORDER_NO,
                       '' LOCAL_LAW,
                       null CUSTOMER_NO,
                       null REVW_RPT_NO,
                       'False' PRODUCER_FL,
                       PM.MSC MSC,
                       PM.MSC_DESC MSC_DESC,
                       null SPEC_CODE,
                       null SPEC_NAME,
                       G.MIN_D DIMATER,
                       G.MIN_H HEIGHT,
                       null REVIEW_NO,
                       null ADD_ASK_NO,
                       'False' MPS_FL,
                       null MPS_NO,
                       null MPS_DESC,
                       G.STD_CODE,
                       G.STD_NAME,
                       NULL MAN_INSPECTION,
                       NULL INSPECTION_VALUE,
                       TO_CHAR(G.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
                       G.CREATE_NAME,
                       DECODE(K.DESIGN_STS,
                              'S',
                              FIRST_VALUE(M.UNIT_CODE)
                              OVER(PARTITION BY M.ORD_LN_PK ORDER BY
                                   M.SEQ_INDEX DESC),
                              A.UNIT_CODE) UNIT_CODE,
                       DECODE(K.DESIGN_STS,
                              'S',
                              FIRST_VALUE(M.UNIT_DESC)
                              OVER(PARTITION BY M.ORD_LN_PK ORDER BY
                                   M.SEQ_INDEX DESC),
                              A.UNIT_DESC) UNIT_DESC,
                       DECODE(K.DESIGN_STS, 'S', M.ORD_LN_PK, A.ORD_LN_PK) A_ORD_LN_PK,
                       DECODE(K.DESIGN_STS,
                              'S',
                              (ROW_NUMBER() OVER(PARTITION BY M.ORD_LN_PK ORDER BY
                                                 M.SEQ_INDEX DESC)),
                              (ROW_NUMBER() OVER(PARTITION BY A.ORD_LN_PK ORDER BY
                                                 A.SEQ_INDEX))) RN,
                       G.PSC_BL MNG_ORDER_NO
                  FROM COM_MSC_BL G
                  LEFT JOIN SLM_ORD_DESIGN_STS_TKLG_LST M
                    ON M.ORD_LN_PK = G.PSC_BL
                   AND M.VALIDFLAG = '1'
                   AND M.DESIGN_STS = 'S'
                  LEFT JOIN SLM_ORD_DESIGN_STS_TKLG_LST A
                    ON A.ORD_LN_PK = G.PSC_BL
                   AND A.VALIDFLAG = '1'
                   AND A.DESIGN_STS = 'F'
                  LEFT JOIN COM_PSC B
                    ON B.PRODUCCODE = G.PRODUCCODE
                   AND B.STEELCODE = G.STEELCODE
                   AND B.STD_CODE = G.STD_CODE
                   AND DECODE(G.STD_STYLE, NULL, '1', B.STD_STYLE) =
                       DECODE(G.STD_STYLE, NULL, '1', G.STD_STYLE)
                   AND DECODE(G.STD_STYLE, NULL, B.STD_STYLE, NULL) IS NULL
                   AND B.VALIDFLAG = '1'
                  LEFT JOIN COM_PSC_R_MSC PM
                    ON PM.PSC = B.PSC
                   AND PM.USE_CODE = G.USE_CODE
                  LEFT JOIN SLM_ORD_DESIGN_STS_TKLG K
                    ON G.PSC_BL = K.ORD_LN_PK
                   AND K.VALIDFLAG = '1', SLM_ORD_DESIGN_BL J
                 WHERE G.PSC_BL = J.PSC_BL
                   AND G.VALIDFLAG = '1'
                   AND J.VALIDFLAG = '1'
                   AND EXISTS
                 (SELECT 1
                          FROM SLM_ORD_DESIGN_STS_TKLG_LST T,
                               CORE_APP_DEPARTMENT         B,
                               CORE_APP_USER               C
                         WHERE T.ORD_LN_PK = G.PSC_BL
                           AND (T.DESIGN_STS = 'F' OR T.VALIDFLAG = '1')
                           AND B.DEPARTID = T.UNIT_CODE
                           AND DECODE({0}, NULL, '1', B.PID) = NVL({0}, '1')
                           AND DECODE({1}, NULL, '1', T.UNIT_CODE) =
                               NVL({1}, '1')
                           AND C.USERID = T.UPDATE_NAME
                           AND DECODE({2}, NULL, '1', C.USERNAME) LIKE
                               NVL({2}, '1')))
         WHERE DECODE(A_ORD_LN_PK, NULL, 1, RN) <= 1)
 ORDER BY ORDER_NO, ORDER_SEQ
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.GetOrderLineCntByBl" desc="通过备料查询接收状态的合同数">
		<![CDATA[
SELECT COUNT(1)
  FROM CRAFT_ORD_DESIGN A, PLN_SALEORD D
 WHERE A.VALIDFLAG = '1'
   AND D.ORD_LN_PK = A.ORD_LN_PK
   AND D.DELIVERY_NO = (SELECT MIN(E.DELIVERY_NO)
                          FROM PLN_SALEORD E
                         WHERE E.ORD_LN_PK = D.ORD_LN_PK)
   AND D.PORDERSTATUS = '1'
   AND (EXISTS (SELECT 1
                  FROM CRAFT_ORD_DESIGN_MSC_JG_BL B
                 WHERE B.DESGIN_KEY = A.DESGIN_KEY
                   AND B.PSC_BL = {0}) OR EXISTS
        (SELECT 1
           FROM CRAFT_ORD_DESIGN_MSC_BL C
          WHERE C.DESGIN_KEY = A.DESGIN_KEY
            AND C.PSC_BL = {0}))
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.GetSlmDesignWater" desc="获取质量设计水压标准">
		<![CDATA[
SELECT DESGIN_KEY,
       WIC,
       USE_CODE,
       USE_DESC,
       DECODE(SPECL_FL, '0', '交付标准', '1', '特殊要求', '2', '内控') SPECL_FL,
       INDEX_SEQ,
       PRESSURE_Y,
       PRESSURE,
       FORMULA,
       SAVE_TIME,
       DECODE(GET_MAXVALUE, '0', 'False', '1', 'True') GET_MAXVALUE,
       DECODE(GET_MINVALUE, '0', 'False', '1', 'True') GET_MINVALUE,
       RATIO_STD,
       RATIO_REPLACE,
       MAX_PRESS,
       A.BASENAME ROUND_RULE
  FROM SLM_ORD_DESIGN_STD_WIC T
  LEFT JOIN COM_BASE_INFO A
    ON A.BASECODE = T.ROUND_RULE
 WHERE T.DESGIN_KEY = {0}
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.GetCraftDesignWater" desc="获取工艺评审水压标准">
		<![CDATA[
SELECT DESGIN_KEY,
       WIC,
       USE_CODE,
       USE_DESC,
       DECODE(SPECL_FL, '0', '交付标准', '1', '特殊要求', '2', '内控') SPECL_FL,
       INDEX_SEQ,
       PRESSURE_Y,
       PRESSURE,
       FORMULA,
       SAVE_TIME,
       DECODE(GET_MAXVALUE, '0', 'False', '1', 'True') GET_MAXVALUE,
       DECODE(GET_MINVALUE, '0', 'False', '1', 'True') GET_MINVALUE,
       RATIO_STD,
       RATIO_REPLACE,
       MAX_PRESS,
       A.BASENAME ROUND_RULE,
       MSC_PLINE,
       B.PROCESS_DESC PROCESS_CODE,
       WIC_MEMO
  FROM CRAFT_ORD_DESIGN_STD_WIC T
  LEFT JOIN COM_BASE_INFO A
    ON A.BASECODE = T.ROUND_RULE
  LEFT JOIN COM_BASE_PROCESS B
    ON B.PROCESS_CODE = T.PROCESS_CODE
 WHERE T.DESGIN_KEY = {0}
		]]>
	</query>

	<query id="CoreOrderReviewTechnology.GetCraftDesignProcess" desc="获取工艺评审水压标准">
		<![CDATA[
			SELECT
				t.DESGIN_KEY,
				t.GIC,
				t.USE_CODE,
				t.USE_DESC,
				t.XH,
				t.PROCESS_CDOE,
				t.PROCESS_DESC,
				t.PROCESS_CDOE_C,
				t.PROCESS_DESC_C,
				t.STATION_CODE,
				t.STATION_DESC,
				VALUE_TEXT,
				VALUE_NUM,
				VALUE_MEMO,
				t.GROUP_SEQ,
				t.MEMO,
				t.MSC_PLINE,
				CRAFT_SOURCE,
				GIC_MEMO,
				DECODE( SPECL_FL, '0', '交付标准', '1', '特殊要求', '2', '内控' ) SPECL_FL,
				B.PROCESS_DESC PROCESS_CODE
		  FROM CRAFT_ORD_DESIGN_STD_GIC T
		  LEFT JOIN COM_BASE_PROCESS B
			ON B.PROCESS_CODE = T.PROCESS_CODE
		 WHERE T.DESGIN_KEY = {0}
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.GetPlnSaleProc" desc="获取排产制程分解表">
		<![CDATA[
SELECT T.ORD_LN_DLY_PK VALUE, T.PLN_DIVIDE_ID VALUE2, T.PLANSTATUS VALUE3
  FROM PLN_SALEORD_PROC T, PLN_SALEORD A
 WHERE A.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK
   AND A.ORD_LN_PK = {0}
   AND T.PLANSTATUS IN ('1', '2', '3', '4')
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.UpdatePlnProcGrade" desc="更新排产制程分解表">
		<![CDATA[
UPDATE PLN_SALEORD_PROC T
   SET T.GRADECODE_ALL = {0}
 WHERE T.ORD_LN_DLY_PK = {1}
   AND T.PLN_DIVIDE_ID = {2}
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.queryNewCraftAllGrade" desc="获取新工艺所有钢种">
		<![CDATA[
SELECT DISTINCT B.GRADENAME VALUE
  FROM CRAFT_ORD_DESIGN A, CRAFT_ORD_DESIGN_MSC_PL_GZ B
 WHERE A.DESGIN_KEY = B.DESGIN_KEY
   AND B.PRIORITY < 100
   AND A.ORD_LN_PK = {0}
   AND A.CRAFT_SEQ = (SELECT MAX(C.CRAFT_SEQ)
                        FROM CRAFT_ORD_DESIGN C
                       WHERE C.ORD_LN_PK = A.ORD_LN_PK)
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.queryComMscByOrdLnPk" desc="获取新工艺所有钢种">
		<![CDATA[
SELECT B.*
  FROM SLM_ORDER_LINE A, COM_MSC B
 WHERE A.ORD_LN_PK = {0}
   AND A.MSC = B.MSC
UNION ALL
SELECT B.*
  FROM COM_MSC_BL A, COM_MSC B
 WHERE A.PSC_BL = {0}
   AND A.PRODUCCODE = B.PRODUCCODE
   AND A.STD_CODE = B.STD_CODE
   AND A.STEELCODE = B.STEELCODE
   AND NVL(A.STD_STYLE, '/') = NVL(B.STD_STYLE, '/')
   AND A.USE_CODE = B.USE_CODE
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.setPicFdCheck" desc="获取新工艺所有钢种">
		<![CDATA[
UPDATE CRAFT_ORD_DESIGN T
   SET T.PIC_FD_CHECK = {2}
 WHERE T.ORD_LN_PK = {0}
   AND T.CRAFT_SEQ = {1}
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.setWicFdCheck" desc="获取新工艺所有钢种">
		<![CDATA[
UPDATE CRAFT_ORD_DESIGN T
   SET T.WIC_FD_CHECK = {2}
 WHERE T.ORD_LN_PK = {0}
   AND T.CRAFT_SEQ = {1}
		]]>
	</query>
	
	<query id="CoreOrderReviewTechnology.setCicFdCheck" desc="获取新工艺所有钢种">
		<![CDATA[
UPDATE CRAFT_ORD_DESIGN T
   SET T.CIC_FD_CHECK = {2}
 WHERE T.ORD_LN_PK = {0}
   AND T.CRAFT_SEQ = {1}
		]]>
	</query>
</queryMap>