<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="工艺变更确认">
	<query id="CoreConfirmCraft.querySaleOrder" desc="查询">
		<![CDATA[
			SELECT M.DESGIN_KEY,
       (SELECT COUNT(*)
          FROM CRAFT_ORD_DESIGN_MSC_PL T
         WHERE T.DESGIN_KEY = M.DESGIN_KEY
           AND T.VALIDFLAG = '1') WHOLE_BACKLOG_COUNT,
       T.ORD_PK,
       T.ORD_LN_PK,
       T.ORDER_NO,
       T.ORDER_SEQ,
       T.DELIVERY_NO,
       (T.ORDER_NO || '/' || T.ORDER_SEQ) ORDER_NO_SEQ,
       (SELECT A.PRODUC_DESC
          FROM COM_BASE_PRODUCT A
         WHERE A.PRODUCCODE = T.PRODUCCODE
           AND A.VALIDFLAG = '1') PRD_CLS,
       T.PRODUCCODE,
       T.PRODUCNAME,
       T.STD_CODE,
       T.STD_NAME,
       T.STEELCODE,
       T.STEELNAME,
       T.SPEC_CODE,
       T.SPEC_NAME,
       T.OUTDIAMETER,
       T.WALLTHICK,
       T.LEN_UNIT,
       T.LENGTHMAX,
       T.LENGTHMIN,
       T.LENGTHDISC,
       T.MODEL_CODE,
       T.MODEL_DESC,
       T.ORDERWEIGHT,
       T.SUPPLY_UNIT_CODE,
       T.SUPPLY_UNIT,
       T.DELVRY_ADDR,
       DECODE(T.ORDER_UNIT, '支', '支', '吨') ORDERWEIGHTUNIT,
       DECODE(T.TOTLENGTH, 0, '', T.TOTLENGTH) TOTLENGTH,
       T.TOTLENGTH_UNIT,
       T.DELVRY_RANGE_TPE,
       T.DELVRY_RANGE_MIN,
       T.DELVRY_RANGE_MAX,
       '(-' || TO_CHAR(ABS(T.DELVRY_RANGE_MIN)) ||
       DECODE(T.DELVRY_RANGE_TPE, '%', '%', '') || ',' ||
       TO_CHAR(T.DELVRY_RANGE_MAX) ||
       DECODE(T.DELVRY_RANGE_TPE, '%', '%', '') || ')' DELVRY_RANGE,
       T.BUYER_ID,
       (SELECT A.ABRVITION
          FROM SLM_BASE_CUSTOMER A
         WHERE A.CUSTOMER_NO = T.BUYER_ID) BUYER_NAME,
       T.ORDER_SPECIAL_DESC,
       T.ADD_ASK_NO,
       M2.ORDER_ADD_DESC,
       (SELECT A.BASENAME
          FROM COM_BASE_INFO A
         WHERE A.BASECODE = T.ORDERFROM) ORDERFROM,
       T.FINAL_USER,
       NVL((SELECT A.ABRVITION
             FROM SLM_BASE_CUSTOMER A
            WHERE A.CUSTOMER_NO = DECODE(T.FINAL_USER,
                                         NULL,
                                         T.BUYER_ID,
                                         '/',
                                         T.BUYER_ID,
                                         T.FINAL_USER)),
           DECODE(T.FINAL_USER_DESC,
                  NULL,
                  T.BUYER_NAME,
                  '/',
                  T.BUYER_NAME,
                  T.FINAL_USER_DESC)) FINAL_USER_DESC,
       TO_CHAR(T.DELVRY_EDATE, 'YYYY-MM-DD') DELVRY_EDATE,
       T.ORDERCONTACT,
       (SELECT A.BASENAME
          FROM COM_BASE_INFO A
         WHERE A.BASECODE = T.MONITORDEMAND) MONITORDEMAND,
       E.PRDCRPRO,
       T.SPECSTANDARD,
       T.PSC,
       T.MSC,
       T.CODE_JG,
       T.CODE_DJ_BL,
       T.PLANWEIGHT,
       T.PAYDOWNWEIGHT,
       DECODE(E.ORDER_SOURCE, '补量需求', R.REQ_NAME, T.CREATE_NAME) CREATE_NAME,
       TO_CHAR(DECODE(E.ORDER_SOURCE, '补量需求', R.REQ_TIME, T.CREATE_TIME),
               'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       DECODE(E.ORDER_SOURCE, '补量需求', R.PLAN_DEAL_NAME, T.UPDATE_NAME) UPDATE_NAME,
       TO_CHAR(DECODE(E.ORDER_SOURCE,
                      '补量需求',
                      R.PLAN_DEAL_TIME,
                      T.UPDATE_TIME),
               'YYYY-MM-DD HH24:MI:SS') UPDATE_TIME,
       T.ENDGXNAME,
       T.MERGETYPE,
       DECODE(T.JZ_FILE_IF_ALL, '1', '是', '0', '否') JZ_FILE_IF_ALL,
       T.PRDCR_NO,
       E.ROLL_MONTH,
       T.MATERIAL_NO,
       T.MATERIAL_DESC,
       T.BL_GROUP_NUM,
       T.SHRT_LEN_RATO,
       T.SHORTEST,
       T.LONG_LEN_RATO,
       T.LONGEST,
       T.SHRT_STOVE,
       T.AVG_LEN_MIN,
       T.DIFRNC_LEN_MAX,
       T.SIGL_LEN,
       T.ENDLEN_SPECSTD,
       T.STATION_NO,
       T.STATION_NM,
       T.PRODUCE_SORT,
       T.USE_CODE,
       T.USE_DESC,
       DECODE(T.TOTLENGTH_M, 0, '', T.TOTLENGTH_M) TOTLENGTH_M,
       T.ORDERNUM,
       (SELECT A.BASENAME
          FROM COM_BASE_INFO A
         WHERE A.BASECODE = T.OUTS_BILLET_FL) OUTS_BILLET_FL,
       T.PIPE_PROPERTY,
       T.LEN_TOEND_MIN,
       T.LEN_TOEND_MAX,
       T.LENGTH_JG,
       T.WEIGH_TYPE,
       T.TRANSIT_TYP,
       DECODE(E.ORDER_SOURCE, '补量需求', R.ACCEPT_NO, T.ACCEPT_NO) ACCEPT_NO,
       (SELECT A.BASENAME
          FROM COM_BASE_INFO A
         WHERE A.BASECODE = T.OUTS_STL_PIPE_FL) OUTS_STL_PIPE_FL,
       H.SALE_AREA_DESC,
       DECODE(T.JGORD_IS_OK, '0', '否', '1', '是', '2', '/') JGORD_IS_OK,
       DECODE(T.JGL_REQ_IS_OK, '0', '否', '1', '是', '2', '/') JGL_REQ_IS_OK,
       DECODE(T.DJBL_REQ_IS_OK, '0', '否', '1', '是', '2', '/') DJBL_REQ_IS_OK,
       DECODE(T.IF_SALE_FREEZE, '1', '是', '0', '否') IF_SALE_FREEZE,
       T.ASK_TYPE_STATUS,
       T.STD_STYLE_DESC,
       NVL(T.ROLL_WELL_MONTH, T.ROLL_MONTH) ROLL_WELL_MONTH,
       T.PAYDOWN_NUM,
       T.HEIGHT_ORD_MIN,
       T.HEIGHT_ORD_MAX,
       M2.AW,
       (SELECT A.BASENAME FROM COM_BASE_INFO A WHERE A.BASECODE = E.PRIORITY) PRIORITY,
       E.PRIORITY_MEMO,
       E.ORDER_SOURCE,
       E.ORD_LN_DLY_PK,
       E.PLN_DIVIDE_ID,
       E.R_NUM_ID,
       E.CRAFT_SEQ,
       E.CRAFT_FILE_NO,
       E.CRAFT_NO_V,
       (SELECT T1.CRAFT_NAME
          FROM CRAFT_ORD_DESIGN_APPOINT T1
         WHERE T1.ORD_LN_PK = T.ORD_LN_PK) CRAFT_FILE_MAN,
       (SELECT MAX(T1.CRAFT_NO)
          FROM CRAFT_ORD_DESIGN T1
         WHERE T1.ORD_LN_PK = T.ORD_LN_PK
           AND T1.VALIDFLAG = '1') CRAFT_NO_NEW,
       (SELECT MAX(T1.CRAFT_NO_V)
          FROM CRAFT_ORD_DESIGN T1
         WHERE T1.ORD_LN_PK = T.ORD_LN_PK
           AND T1.VALIDFLAG = '1') CRAFT_NO_V_NEW,
       DECODE(E.CRAFT_SEQ,
              NVL((SELECT MAX(T1.CRAFT_SEQ)
                    FROM CRAFT_ORD_DESIGN T1
                   WHERE T1.ORD_LN_PK = T.ORD_LN_PK
                     AND T1.VALIDFLAG = '1'),
                  E.CRAFT_SEQ),
              '无更新',
              DECODE(E.PLANSTATUS, '4', '无更新', '5', '无更新', '待替换')) CRAFT_RENEW_ST,
       E.INDEX_SEQ,
       E.PROCESS_SEQ,
       (SELECT P.WHOLE_BACKLOG_DESC
          FROM CRAFT_ORD_DESIGN_MSC_PL P
         WHERE P.DESGIN_KEY = M.DESGIN_KEY
           AND P.MSC_PLINE = E.INDEX_SEQ) WHOLE_BACKLOG_DESC,
       E.BOM,
       (SELECT B.BASENAME
          FROM COM_BASE_INFO B
         WHERE B.BASECODE = E.GROUP_JGX) GROUP_JGX,
       (SELECT B.BASENAME
          FROM COM_BASE_INFO B
         WHERE B.BASECODE = E.GROUP_RCL) GROUP_RCL,
       DECODE(E.PLANSTATUS,
              '1',
              '已接收',
              '2',
              '已下发',
              '3',
              '生产中',
              '4',
              '生产完成',
              '5',
              '缴库完成') PLANSTATUS,
       E.GRADECODE_ALL,
       (SELECT A.GRADENAME
          FROM COM_BASE_GRADE A
         WHERE A.GRADECODE = E.GRADECODE) GRADECODE,
       E.GROUP_ROLL_ALL,
       (SELECT A.PLINE_NAME
          FROM COM_BASE_PLINE A
         WHERE A.PLINE_CODE = E.GROUP_ROLL) GROUP_ROLL,
       E.BJ_TYPE,
       E.E_IN_MATERIAL_NO,
       E.E_IN_MATERIAL_DESC,
       E.DIMATER_YLG,
       E.HEIGHT_YLG,
       E.STUFF_PROPERTY,
       E.WEIGHT_PER_M,
       E.PLAN_TOT_LEN_D,
       E.ORDER_QTY_D,
       E.ORDER_UNIT,
       E.PLAN_WT_D,
       E.PLAN_NUM_D,
       E.FINISH_WT,
       E.PLAN_WT_BEGIN,
       E.PLAN_NUM_BEGIN,
       E.HEIGHT_NK_MIN,
       E.HEIGHT_NK_MAX,
       E.AIM_LEN_END,
       E.AIM_LEN_ROLL,
       E.TOT_LEN_ONE_P,
       E.CUT_NUM_P,
       E.AIM_WALLTHICK,
       E.ROLL_LENGTH,
       E.PLAN_P_MAIN,
       E.ISSUED_MAN,
       E.IF_EXPORT,
       TO_CHAR(E.ISSUED_TIME, 'YYYY-MM-DD HH24:MI:SS') ISSUED_TIME,
       DECODE(E.F_IS_OK, '0', '否', '1', '是', '2', '/') F_IS_OK,
       DECODE(E.IF_ALLOW_ISSUE, '0', '否', '1', '是') IF_ALLOW_ISSUE,
       DECODE(E.G_IS_OK, '0', '否', '1', '是', '2', '/') G_IS_OK,
       DECODE(E.GRADECODE_IS_OK, '0', '否', '1', '是') GRADECODE_IS_OK,
       DECODE(E.D_IS_OK, '0', '否', '1', '是', '2', '/') D_IS_OK,
       DECODE(E.PLAN_IS_OK, '0', '否', '1', '是') PLAN_IS_OK,
       DECODE(E.E_IS_OK, '0', '否', '1', '是', '2', '/') E_IS_OK,
       MC.UNIT_DESC_PROCESS UNIT_DESC,
       F.DEPARTNAME,
       E.LEN_ROLL_MAX,
       E.LEN_ROLL_MIN,
       Z1.Z_ORDERWEIGHT,
       Z1.Z_ORDERNUM,
       M2.DESIGN_STS,
       ((SELECT TO_CHAR(WM_CONCAT(ORDER_NO || '/' || ORDER_SEQ || '/' ||
                                  DELIVERY_NO))
           FROM PLN_ORDER_JG
          WHERE PRO_PLAN_ID IN
                (SELECT PRO_PLAN_ID
                   FROM PLN_JG_AND_BL
                  WHERE REQ_BL_ID = E.ORD_LN_DLY_PK)) ||
       (SELECT (ORDER_NO || '/' || ORDER_SEQ || '/' || DELIVERY_NO)
           FROM PLN_PORDER_BL_REQ
          WHERE REQ_BL_ID = E.ORD_LN_DLY_PK
            AND BLTYPE = '短节备料')) MEMO,
       E.AIM_OUTDIAMETER,
       E.FEED_RATE,
       E.COEFFICIENT,
       E.COEFFICIENT_MIN,
       E.PLAN_P_MAIN_MIN,
       E.AIM_WT_END,
       E.WEIGHT_KZ_M,
       E.DELETE_NAME,
       E.CHECK_MOTH,
       TO_CHAR(E.DELETE_TIME,'YYYY-MM-DD HH:MM:SS')DELETE_TIME,
       NVL((SELECT T1.CHECK_J_VAL
             FROM COM_MSC_JG T1
            WHERE T1.CODE_JG = T.CODE_JG
              AND T1.VALIDFLAG = '1'),
           0) / 1000 CHECK_J_VAL,
       NVL((SELECT T1.WEIGHT_JG
             FROM COM_MSC_JG T1
            WHERE T1.CODE_JG = T.CODE_JG
              AND T1.VALIDFLAG = '1'),
           0) / 1000 WEIGHT_JG,
       E.PROC_DESC_C_RCL RCL_INFO,
       DECODE(BL.CODE_DJ_BL, '', BL.CODE_JG_BL, BL.CODE_DJ_BL) CODE_BL
  FROM PLN_SALEORD_PROC E
  LEFT JOIN (SELECT Z.ORD_LN_DLY_PK,
                    Z.PLN_DIVIDE_ID,
                    SUM(Z.ORDERWEIGHT) Z_ORDERWEIGHT,
                    SUM(Z.ORDERNUM) Z_ORDERNUM
               FROM PLN_ORDER_ZG Z
              GROUP BY Z.ORD_LN_DLY_PK, Z.PLN_DIVIDE_ID) Z1
    ON Z1.ORD_LN_DLY_PK = E.ORD_LN_DLY_PK
   AND Z1.PLN_DIVIDE_ID = E.PLN_DIVIDE_ID
  LEFT JOIN PLN_SALEORD T
    ON T.ORD_LN_DLY_PK = E.ORD_LN_DLY_PK
  LEFT JOIN SLM_ORDER_HEAD H
    ON H.ORD_PK = T.ORD_PK
   AND H.VALIDFLAG = '1'
  LEFT JOIN (SELECT DECODE(K.DESIGN_STS,
                           'W',
                           '等待',
                           'S',
                           '通过',
                           'F',
                           '失败') DESIGN_STS,
                    H.ORD_LN_PK,
                    H.AW,
                    H.ORDER_ADD_DESC
               FROM SLM_ORDER_LINE H, CRAFT_ORD_DESIGN M
               LEFT JOIN CRAFT_ORD_DESIGN_STS_TKLG K
                 ON K.DESGIN_KEY = M.DESGIN_KEY
                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 H.VALIDFLAG <> '0'
                AND M.ORD_LN_PK = H.ORD_LN_PK
                AND M.VALIDFLAG <> '0') M2
    ON M2.ORD_LN_PK = T.ORD_LN_PK
  LEFT JOIN COM_MSC MC
  LEFT JOIN CORE_APP_DEPARTMENT DP
    ON DP.DEPARTID = MC.UNIT_CODE_PROCESS
  LEFT JOIN CORE_APP_DEPARTMENT F
    ON F.DEPARTID = DP.PID ON T.MSC = MC.MSC
  LEFT JOIN CRAFT_ORD_DESIGN M
    ON M.ORD_LN_PK = T.ORD_LN_PK
   AND M.CRAFT_SEQ = E.CRAFT_SEQ
  LEFT JOIN PLN_SALEORDER_R_NUM R
    ON R.R_NUM_ID = E.R_NUM_ID 
    LEFT JOIN PLN_PORDER_BL_REQ BL
    ON E.ORD_LN_DLY_PK = BL.REQ_BL_ID
 WHERE T.ORD_LN_DLY_PK = E.ORD_LN_DLY_PK
			   AND NVL(E.ROLL_MONTH, '1') LIKE
			       '%' || NVL(?, NVL(E.ROLL_MONTH, '1')) || '%'
			   AND (DECODE(E.ORDER_SOURCE,
			               '补量需求',
			               R.ACCEPT_NO,
			               NVL(T.ACCEPT_NO, '1')) LIKE
			       '%' || NVL(NLS_UPPER(?),
			                   DECODE(E.ORDER_SOURCE,
			                          '补量需求',
			                          R.ACCEPT_NO,
			                          NVL(T.ACCEPT_NO, '1'))) || '%')
			   AND (T.ORDER_NO || '/' || T.ORDER_SEQ) LIKE '%' || NLS_UPPER(?) || '%'
			   AND E.PLANSTATUS LIKE '%' || ? || '%'
			   AND DECODE(?, '1', T.JGORD_IS_OK, 1) != DECODE(?, '1', '2', 2)
			   AND DECODE(?, '1', T.DJBL_REQ_IS_OK, 1) != DECODE(?, '1', '2', 2)
			   AND DECODE(?, '1', T.MERGETYPE, 1) = DECODE(?, '1', '3', 1)
			   AND E.ORDER_SOURCE LIKE '%' || ? || '%'
		]]>
	</query>

	<query id="CoreConfirmCraft.querySaleOrder1" desc="查询">
		<![CDATA[
			SELECT M.DESGIN_KEY,
       (SELECT COUNT(*)
          FROM CRAFT_ORD_DESIGN_MSC_PL T
         WHERE T.DESGIN_KEY = M.DESGIN_KEY
           AND T.VALIDFLAG = '1') WHOLE_BACKLOG_COUNT,
       T.ORD_PK,
       T.ORD_LN_PK,
       T.ORDER_NO,
       T.ORDER_SEQ,
       T.DELIVERY_NO,
       (T.ORDER_NO || '/' || T.ORDER_SEQ) ORDER_NO_SEQ,
       (SELECT A.PRODUC_DESC
          FROM COM_BASE_PRODUCT A
         WHERE A.PRODUCCODE = T.PRODUCCODE
           AND A.VALIDFLAG = '1') PRD_CLS,
       T.PRODUCCODE,
       T.PRODUCNAME,
       T.STD_CODE,
       T.STD_NAME,
       T.STEELCODE,
       T.STEELNAME,
       T.SPEC_CODE,
       T.SPEC_NAME,
       T.OUTDIAMETER,
       T.WALLTHICK,
       T.LEN_UNIT,
       T.LENGTHMAX,
       T.LENGTHMIN,
       T.LENGTHDISC,
       T.MODEL_CODE,
       T.MODEL_DESC,
       T.ORDERWEIGHT,
       T.SUPPLY_UNIT_CODE,
       T.SUPPLY_UNIT,
       T.DELVRY_ADDR,
       DECODE(T.ORDER_UNIT, '支', '支', '吨') ORDERWEIGHTUNIT,
       DECODE(T.TOTLENGTH, 0, '', T.TOTLENGTH) TOTLENGTH,
       T.TOTLENGTH_UNIT,
       T.DELVRY_RANGE_TPE,
       T.DELVRY_RANGE_MIN,
       T.DELVRY_RANGE_MAX,
       '(-' || TO_CHAR(ABS(T.DELVRY_RANGE_MIN)) ||
       DECODE(T.DELVRY_RANGE_TPE, '%', '%', '') || ',' ||
       TO_CHAR(T.DELVRY_RANGE_MAX) ||
       DECODE(T.DELVRY_RANGE_TPE, '%', '%', '') || ')' DELVRY_RANGE,
       T.BUYER_ID,
       (SELECT A.ABRVITION
          FROM SLM_BASE_CUSTOMER A
         WHERE A.CUSTOMER_NO = T.BUYER_ID) BUYER_NAME,
       T.ORDER_SPECIAL_DESC,
       T.ADD_ASK_NO,
       M2.ORDER_ADD_DESC,
       (SELECT A.BASENAME
          FROM COM_BASE_INFO A
         WHERE A.BASECODE = T.ORDERFROM) ORDERFROM,
       T.FINAL_USER,
       NVL((SELECT A.ABRVITION
             FROM SLM_BASE_CUSTOMER A
            WHERE A.CUSTOMER_NO = DECODE(T.FINAL_USER,
                                         NULL,
                                         T.BUYER_ID,
                                         '/',
                                         T.BUYER_ID,
                                         T.FINAL_USER)),
           DECODE(T.FINAL_USER_DESC,
                  NULL,
                  T.BUYER_NAME,
                  '/',
                  T.BUYER_NAME,
                  T.FINAL_USER_DESC)) FINAL_USER_DESC,
       TO_CHAR(T.DELVRY_EDATE, 'YYYY-MM-DD') DELVRY_EDATE,
       T.ORDERCONTACT,
       (SELECT A.BASENAME
          FROM COM_BASE_INFO A
         WHERE A.BASECODE = T.MONITORDEMAND) MONITORDEMAND,
       E.PRDCRPRO,
       T.SPECSTANDARD,
       T.PSC,
       T.MSC,
       T.CODE_JG,
       T.CODE_DJ_BL,
       T.PLANWEIGHT,
       T.PAYDOWNWEIGHT,
       DECODE(E.ORDER_SOURCE, '补量需求', R.REQ_NAME, T.CREATE_NAME) CREATE_NAME,
       TO_CHAR(DECODE(E.ORDER_SOURCE, '补量需求', R.REQ_TIME, T.CREATE_TIME),
               'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       DECODE(E.ORDER_SOURCE, '补量需求', R.PLAN_DEAL_NAME, T.UPDATE_NAME) UPDATE_NAME,
       TO_CHAR(DECODE(E.ORDER_SOURCE,
                      '补量需求',
                      R.PLAN_DEAL_TIME,
                      T.UPDATE_TIME),
               'YYYY-MM-DD HH24:MI:SS') UPDATE_TIME,
       T.ENDGXNAME,
       T.MERGETYPE,
       DECODE(T.JZ_FILE_IF_ALL, '1', '是', '0', '否') JZ_FILE_IF_ALL,
       T.PRDCR_NO,
       E.ROLL_MONTH,
       T.MATERIAL_NO,
       T.MATERIAL_DESC,
       T.BL_GROUP_NUM,
       T.SHRT_LEN_RATO,
       T.SHORTEST,
       T.LONG_LEN_RATO,
       T.LONGEST,
       T.SHRT_STOVE,
       T.AVG_LEN_MIN,
       T.DIFRNC_LEN_MAX,
       T.SIGL_LEN,
       T.ENDLEN_SPECSTD,
       T.STATION_NO,
       T.STATION_NM,
       T.PRODUCE_SORT,
       T.USE_CODE,
       T.USE_DESC,
       DECODE(T.TOTLENGTH_M, 0, '', T.TOTLENGTH_M) TOTLENGTH_M,
       T.ORDERNUM,
       (SELECT A.BASENAME
          FROM COM_BASE_INFO A
         WHERE A.BASECODE = T.OUTS_BILLET_FL) OUTS_BILLET_FL,
       T.PIPE_PROPERTY,
       T.LEN_TOEND_MIN,
       T.LEN_TOEND_MAX,
       T.LENGTH_JG,
       T.WEIGH_TYPE,
       T.TRANSIT_TYP,
       DECODE(E.ORDER_SOURCE, '补量需求', R.ACCEPT_NO, T.ACCEPT_NO) ACCEPT_NO,
       (SELECT A.BASENAME
          FROM COM_BASE_INFO A
         WHERE A.BASECODE = T.OUTS_STL_PIPE_FL) OUTS_STL_PIPE_FL,
       H.SALE_AREA_DESC,
       DECODE(T.JGORD_IS_OK, '0', '否', '1', '是', '2', '/') JGORD_IS_OK,
       DECODE(T.JGL_REQ_IS_OK, '0', '否', '1', '是', '2', '/') JGL_REQ_IS_OK,
       DECODE(T.DJBL_REQ_IS_OK, '0', '否', '1', '是', '2', '/') DJBL_REQ_IS_OK,
       DECODE(T.IF_SALE_FREEZE, '1', '是', '0', '否') IF_SALE_FREEZE,
       T.ASK_TYPE_STATUS,
       T.STD_STYLE_DESC,
       NVL(T.ROLL_WELL_MONTH, T.ROLL_MONTH) ROLL_WELL_MONTH,
       T.PAYDOWN_NUM,
       T.HEIGHT_ORD_MIN,
       T.HEIGHT_ORD_MAX,
       M2.AW,
       (SELECT A.BASENAME FROM COM_BASE_INFO A WHERE A.BASECODE = E.PRIORITY) PRIORITY,
       E.PRIORITY_MEMO,
       E.ORDER_SOURCE,
       E.ORD_LN_DLY_PK,
       E.PLN_DIVIDE_ID,
       E.R_NUM_ID,
       E.CRAFT_SEQ,
       E.CRAFT_FILE_NO,
       E.CRAFT_NO_V,
       (SELECT T1.CRAFT_NAME
          FROM CRAFT_ORD_DESIGN_APPOINT T1
         WHERE T1.ORD_LN_PK = T.ORD_LN_PK) CRAFT_FILE_MAN,
       (SELECT MAX(T1.CRAFT_NO)
          FROM CRAFT_ORD_DESIGN T1
         WHERE T1.ORD_LN_PK = T.ORD_LN_PK
           AND T1.VALIDFLAG = '1') CRAFT_NO_NEW,
       (SELECT MAX(T1.CRAFT_NO_V)
          FROM CRAFT_ORD_DESIGN T1
         WHERE T1.ORD_LN_PK = T.ORD_LN_PK
           AND T1.VALIDFLAG = '1') CRAFT_NO_V_NEW,
       DECODE(E.CRAFT_SEQ,
              NVL((SELECT MAX(T1.CRAFT_SEQ)
                    FROM CRAFT_ORD_DESIGN T1
                   WHERE T1.ORD_LN_PK = T.ORD_LN_PK
                     AND T1.VALIDFLAG = '1'),
                  E.CRAFT_SEQ),
              '无更新',
              DECODE(E.PLANSTATUS, '4', '无更新', '5', '无更新', '待替换')) CRAFT_RENEW_ST,
       E.INDEX_SEQ,
       E.PROCESS_SEQ,
       (SELECT P.WHOLE_BACKLOG_DESC
          FROM CRAFT_ORD_DESIGN_MSC_PL P
         WHERE P.DESGIN_KEY = M.DESGIN_KEY
           AND P.MSC_PLINE = E.INDEX_SEQ) WHOLE_BACKLOG_DESC,
       E.BOM,
       (SELECT B.BASENAME
          FROM COM_BASE_INFO B
         WHERE B.BASECODE = E.GROUP_JGX) GROUP_JGX,
       (SELECT B.BASENAME
          FROM COM_BASE_INFO B
         WHERE B.BASECODE = E.GROUP_RCL) GROUP_RCL,
       DECODE(E.PLANSTATUS,
              '1',
              '已接收',
              '2',
              '已下发',
              '3',
              '生产中',
              '4',
              '生产完成',
              '5',
              '缴库完成') PLANSTATUS,
       E.GRADECODE_ALL,
       (SELECT A.GRADENAME
          FROM COM_BASE_GRADE A
         WHERE A.GRADECODE = E.GRADECODE) GRADECODE,
       E.GROUP_ROLL_ALL,
       (SELECT A.PLINE_NAME
          FROM COM_BASE_PLINE A
         WHERE A.PLINE_CODE = E.GROUP_ROLL) GROUP_ROLL,
       E.BJ_TYPE,
       E.E_IN_MATERIAL_NO,
       E.E_IN_MATERIAL_DESC,
       E.DIMATER_YLG,
       E.HEIGHT_YLG,
       E.STUFF_PROPERTY,
       E.WEIGHT_PER_M,
       E.PLAN_TOT_LEN_D,
       E.ORDER_QTY_D,
       E.ORDER_UNIT,
       E.PLAN_WT_D,
       E.PLAN_NUM_D,
       E.FINISH_WT,
       E.PLAN_WT_BEGIN,
       E.PLAN_NUM_BEGIN,
       E.HEIGHT_NK_MIN,
       E.HEIGHT_NK_MAX,
       E.AIM_LEN_END,
       E.AIM_LEN_ROLL,
       E.TOT_LEN_ONE_P,
       E.CUT_NUM_P,
       E.AIM_WALLTHICK,
       E.ROLL_LENGTH,
       E.PLAN_P_MAIN,
       E.ISSUED_MAN,
       E.IF_EXPORT,
       TO_CHAR(E.ISSUED_TIME, 'YYYY-MM-DD HH24:MI:SS') ISSUED_TIME,
       DECODE(E.F_IS_OK, '0', '否', '1', '是', '2', '/') F_IS_OK,
       DECODE(E.IF_ALLOW_ISSUE, '0', '否', '1', '是') IF_ALLOW_ISSUE,
       DECODE(E.G_IS_OK, '0', '否', '1', '是', '2', '/') G_IS_OK,
       DECODE(E.GRADECODE_IS_OK, '0', '否', '1', '是') GRADECODE_IS_OK,
       DECODE(E.D_IS_OK, '0', '否', '1', '是', '2', '/') D_IS_OK,
       DECODE(E.PLAN_IS_OK, '0', '否', '1', '是') PLAN_IS_OK,
       DECODE(E.E_IS_OK, '0', '否', '1', '是', '2', '/') E_IS_OK,
       MC.UNIT_DESC_PROCESS UNIT_DESC,
       F.DEPARTNAME,
       E.LEN_ROLL_MAX,
       E.LEN_ROLL_MIN,
       Z1.Z_ORDERWEIGHT,
       Z1.Z_ORDERNUM,
       M2.DESIGN_STS,
       E.AIM_OUTDIAMETER,
       E.FEED_RATE,
       E.COEFFICIENT,
       E.COEFFICIENT_MIN,
       E.PLAN_P_MAIN_MIN,
       E.AIM_WT_END,
       E.WEIGHT_KZ_M,
       E.DELETE_NAME,
       E.CHECK_MOTH,
       TO_CHAR(E.DELETE_TIME,'YYYY-MM-DD HH:MM:SS')DELETE_TIME,
       NVL((SELECT T1.CHECK_J_VAL
             FROM COM_MSC_JG T1
            WHERE T1.CODE_JG = T.CODE_JG
              AND T1.VALIDFLAG = '1'),
           0) / 1000 CHECK_J_VAL,
       NVL((SELECT T1.WEIGHT_JG
             FROM COM_MSC_JG T1
            WHERE T1.CODE_JG = T.CODE_JG
              AND T1.VALIDFLAG = '1'),
           0) / 1000 WEIGHT_JG,
       E.PROC_DESC_C_RCL RCL_INFO,
       DECODE(BL.CODE_DJ_BL, '', BL.CODE_JG_BL, BL.CODE_DJ_BL) CODE_BL
  FROM PLN_SALEORD_PROC E
  LEFT JOIN (SELECT Z.ORD_LN_DLY_PK,
                    Z.PLN_DIVIDE_ID,
                    SUM(Z.ORDERWEIGHT) Z_ORDERWEIGHT,
                    SUM(Z.ORDERNUM) Z_ORDERNUM
               FROM PLN_ORDER_ZG Z
              GROUP BY Z.ORD_LN_DLY_PK, Z.PLN_DIVIDE_ID) Z1
    ON Z1.ORD_LN_DLY_PK = E.ORD_LN_DLY_PK
   AND Z1.PLN_DIVIDE_ID = E.PLN_DIVIDE_ID
  LEFT JOIN PLN_SALEORD T
    ON T.ORD_LN_DLY_PK = E.ORD_LN_DLY_PK
  LEFT JOIN SLM_ORDER_HEAD H
    ON H.ORD_PK = T.ORD_PK
   AND H.VALIDFLAG = '1'
  LEFT JOIN (SELECT DECODE(K.DESIGN_STS,
                           'W',
                           '等待',
                           'S',
                           '通过',
                           'F',
                           '失败') DESIGN_STS,
                    H.ORD_LN_PK,
                    H.AW,
                    H.ORDER_ADD_DESC
               FROM SLM_ORDER_LINE H, CRAFT_ORD_DESIGN M
               LEFT JOIN CRAFT_ORD_DESIGN_STS_TKLG K
                 ON K.DESGIN_KEY = M.DESGIN_KEY
                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 H.VALIDFLAG <> '0'
                AND M.ORD_LN_PK = H.ORD_LN_PK
                AND M.VALIDFLAG <> '0') M2
    ON M2.ORD_LN_PK = T.ORD_LN_PK
  LEFT JOIN COM_MSC MC
  LEFT JOIN CORE_APP_DEPARTMENT DP
    ON DP.DEPARTID = MC.UNIT_CODE_PROCESS
  LEFT JOIN CORE_APP_DEPARTMENT F
    ON F.DEPARTID = DP.PID ON T.MSC = MC.MSC
  LEFT JOIN CRAFT_ORD_DESIGN M
    ON M.ORD_LN_PK = T.ORD_LN_PK
   AND M.CRAFT_SEQ = E.CRAFT_SEQ
  LEFT JOIN PLN_SALEORDER_R_NUM R
    ON R.R_NUM_ID = E.R_NUM_ID
    LEFT JOIN PLN_PORDER_BL_REQ BL
    ON E.ORD_LN_DLY_PK = BL.REQ_BL_ID
 WHERE 1=1
		]]>
	</query>

	<query id = "CoreConfirmCraft.selectCrmProduct" desc = "查询Crm">
		SELECT T.*,S.PLAN_NUM_D,S.PLAN_WT_D
		FROM CRM_ORDER_PRODUCE T, PLN_SALEORD_PROC S
		WHERE T.ORD_LN_DLY_PK = S.ORD_LN_DLY_PK
		AND T.ORD_LN_DLY_PK = ?
		ORDER BY T.CREATE_TIME DESC
	</query>
	<query id = "CoreConfirmCraft.insertCrmProduct" desc = "排产下发、撤销时写CRM表">
		INSERT INTO CRM_ORDER_PRODUCE(
		WGT_ESTMT,
		DATA_STATUS,
		ORD_LN_DLY_PK,
		CREATE_NAME,
		CREATE_TIME,
		APP_NUM,
		APP_UNIT,
		PSS_NUM,
		PSS_WGT)
		VALUES(
		'#WGT_ESTMT#',
		'#DATA_STATUS#',
		'#ORD_LN_DLY_PK#',
		'#CREATE_NAME#',
		SYSDATE,
		'#APP_NUM#',
		'#APP_UNIT#',
		'#PLAN_NUM_D#',
		'#PLAN_WT_D#')
	</query>
	<query>

	</query>
	<query id="CoreConfirmCraft.querySaleProcStatus" desc="查询状态">
		<![CDATA[
			SELECT T.INDEX_SEQ,
			       T.CRAFT_FILE_NO,
			       T.CRAFT_NO_V,
			       T.CRAFT_SEQ,
			       (SELECT B.DESGIN_KEY
			          FROM CRAFT_ORD_DESIGN B
			         WHERE B.ORD_LN_PK = T1.ORD_LN_PK
			           AND B.CRAFT_SEQ = T.CRAFT_SEQ) DESGIN_KEY,
			       (SELECT MAX(B.CRAFT_SEQ)
			          FROM CRAFT_ORD_DESIGN B
			         WHERE B.ORD_LN_PK = T1.ORD_LN_PK
			           AND B.VALIDFLAG = '1') CRAFT_SEQ_NEW,
			       T.BOM,
			       T.E_IN_MATERIAL_NO,
			       T.GROUP_ROLL,
			       T.E_IS_OK,
			       T.D_IS_OK,
			       T.GRADECODE_IS_OK,
			       T.PLANSTATUS,
			       T1.CODE_JG,
			       T.ROLL_MONTH,
			       T1.OUTS_STL_PIPE_FL
			  FROM PLN_SALEORD_PROC T, PLN_SALEORD T1
			 WHERE T1.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK
			   AND T.ORD_LN_DLY_PK = ?
			   AND T.PLN_DIVIDE_ID = ?
		]]>
	</query>

	<query id="CoreConfirmCraft.queryCraftDesign" desc="查询工艺信息">
		<![CDATA[
			SELECT B.DESGIN_KEY, B.CRAFT_SEQ, A.CRAFT_NAME
			  FROM CRAFT_ORD_DESIGN B
			  LEFT JOIN CRAFT_ORD_DESIGN_APPOINT A
			    ON B.ORD_LN_PK = A.ORD_LN_PK
			 WHERE B.ORD_LN_PK = ?
			   AND B.CRAFT_SEQ = ?
			 ORDER BY B.CRAFT_SEQ DESC
		]]>
	</query>

	<query id="CoreConfirmCraft.queryIsNotIussedOrd" desc="查询交货行有无下发">
		<![CDATA[
			SELECT COUNT(*) IUSSED_NUM
		           FROM PLN_SALEORD_PROC T
		          WHERE TO_NUMBER(T.PLANSTATUS) > 1
		            AND T.ORDER_SOURCE = '销售合同'
		            AND T.ORD_LN_DLY_PK = ?
		]]>
	</query>

	<query id="CoreConfirmCraft.updateSaleOrdProcStatus" desc="更新拆分合同状态">
		<![CDATA[
			UPDATE PLN_SALEORD_PROC T
			   SET (T.CRAFT_FILE_NO, T.CRAFT_FILE_MAN, T.CRAFT_NO_V) =
			       (SELECT M.CRAFT_NO, A.CRAFT_NAME, M.CRAFT_NO_V
			          FROM CRAFT_ORD_DESIGN M, PLN_SALEORD T1
			          LEFT JOIN CRAFT_ORD_DESIGN_APPOINT A
			            ON A.ORD_LN_PK = T1.ORD_LN_PK
			         WHERE M.CRAFT_SEQ = T.CRAFT_SEQ
			           AND M.ORD_LN_PK = T1.ORD_LN_PK
			           AND T1.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK),
			       T.PLAN_WT_BEGIN = T.PLAN_WT_D,
			       T.PLAN_NUM_BEGIN = T.PLAN_NUM_D,
			       T.PLANSTATUS = ?,
			       T.ISSUED_MAN = ?,
			       T.ISSUED_TIME = SYSDATE
			 WHERE T.ORD_LN_DLY_PK = ?
			   AND T.PLN_DIVIDE_ID = ?
		]]>
	</query>

	<query id="CoreConfirmCraft.updatePlnSaleStatus" desc="下发撤销下发更改交货行状态">
		<![CDATA[
			UPDATE PLN_SALEORD T
			   SET T.PORDERSTATUS = ?
			 WHERE T.ORD_LN_DLY_PK = ?
		]]>
	</query>

	<query id="CoreConfirmCraft.updateCraftVersion" desc="替换工艺版本">
		<![CDATA[
			UPDATE PLN_SALEORD_PROC T
			   SET T.CRAFT_SEQ = '#CRAFT_SEQ#',
			       (T.CRAFT_FILE_NO, T.CRAFT_NO_V) =
			       (SELECT M.CRAFT_NO, M.CRAFT_NO_V
			          FROM CRAFT_ORD_DESIGN M, PLN_SALEORD T1
			         WHERE M.ORD_LN_PK = T1.ORD_LN_PK
			           AND T1.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK
			           AND M.CRAFT_SEQ = '#CRAFT_SEQ#'),
			       T.CRAFT_RENEW_ST = '2'
			 WHERE T.ORD_LN_DLY_PK = '#ORD_LN_DLY_PK#'
			   AND T.PLN_DIVIDE_ID = '#PLN_DIVIDE_ID#'
		]]>
	</query>

	<query id="CoreConfirmCraft.updateCraftVersionIndex" desc="替换工艺版本">
		<![CDATA[
			UPDATE PLN_SALEORD_PROC T
			   SET T.INDEX_SEQ          = '#INDEX_SEQ#',
			       T.PROCESS_SEQ        = '#PROCESS_SEQ#',
			       T.GRADECODE_ALL      = '#GRADECODE_ALL#',
			       T.BJ_TYPE            = '#BJ_TYPE#',
			       T.GRADECODE_IS_OK    = '#GRADECODE_IS_OK#',
			       T.D_IS_OK            = '#D_IS_OK#',
			       T.E_IS_OK            = '#E_IS_OK#'
			 WHERE T.ORD_LN_DLY_PK = '#ORD_LN_DLY_PK#'
			   AND T.PLN_DIVIDE_ID = '#PLN_DIVIDE_ID#'
		]]>
	</query>

	<query id="CoreConfirmCraft.updateCraftVersionBom" desc="替换工艺版本">
		<![CDATA[
			UPDATE PLN_SALEORD_PROC T
			   SET T.BOM                = '#BOM#',
			       T.GRADECODE          = '#GRADECODE#',
			       T.ABC                = '#ABC#',
			       T.E_IN_MATERIAL_NO   = '#E_IN_MATERIAL_NO#',
			       T.E_IN_MATERIAL_DESC = '#E_IN_MATERIAL_DESC#',
			       T.DIMATER_YLG        = '#DIMATER_YLG#',
			       T.HEIGHT_YLG         = '#HEIGHT_YLG#',
			       T.GROUP_JGX          = '#GROUP_JGX#',
			       T.GROUP_RCL          = '#GROUP_RCL#',
			       T.STUFF_PROPERTY     = '#STUFF_PROPERTY#',
			       T.PROC_DESC_C_RCL    ='#PROC_DESC_C_RCL#'
			 WHERE T.ORD_LN_DLY_PK = '#ORD_LN_DLY_PK#'
			   AND T.PLN_DIVIDE_ID = '#PLN_DIVIDE_ID#'
		]]>
	</query>

	<query id="CoreConfirmCraft.updateCraftVersionBomPline" desc="替换工艺版本">
		<![CDATA[
			UPDATE PLN_SALEORD_PROC T
			   SET T.GROUP_ROLL         = '#GROUP_ROLL#',
			       T.GROUP_ROLL_NAME    =
			       (SELECT B.PLINE_NAME
			          FROM COM_BASE_PLINE B
			         WHERE B.PLINE_CODE = '#GROUP_ROLL#')
			 WHERE T.ORD_LN_DLY_PK = '#ORD_LN_DLY_PK#'
			   AND T.PLN_DIVIDE_ID = '#PLN_DIVIDE_ID#'
		]]>
	</query>


	<query id="CoreConfirmCraft.updateCraftVersionAmout" desc="替换工艺版本更新合同量">
		<![CDATA[
			UPDATE PLN_SALEORD_PROC T
			   SET T.WEIGHT_PER_M       = '#WEIGHT_PER_M#',
			       T.PLAN_WT_D          = '#PLAN_WT_D#',
			       T.PLAN_NUM_D         = '#PLAN_NUM_D#',
			       T.AIM_LEN_ROLL       = '#AIM_LEN_ROLL#',
			       T.AIM_LEN_END        = '#AIM_LEN_END#',
			       T.PLAN_P_MAIN        = '#PLAN_P_MAIN#',
			       T.PLAN_TOT_LEN_D     = '#PLAN_TOT_LEN_D#',
			       T.TOT_LEN_ONE_P      = '#TOT_LEN_ONE_P#',
			       T.CUT_NUM_P          = '#CUT_NUM_P#',
			       T.AIM_WALLTHICK      = '#AIM_WALLTHICK#',
			       T.ROLL_LENGTH        = '#ROLL_LENGTH#'
			 WHERE T.ORD_LN_DLY_PK = '#ORD_LN_DLY_PK#'
			   AND T.PLN_DIVIDE_ID = '#PLN_DIVIDE_ID#'
		]]>
	</query>

	<query id="CoreConfirmCraft.updateProcessOrderMt" desc="更新进程表">
		<![CDATA[
			UPDATE PROCESS_ORDER_M T
			   SET T.PSS_NUM = T.PSS_NUM + ?, T.PSS_WGT = T.PSS_WGT + ?
			 where t.ord_ln_dly_pk = ?
		]]>
	</query>

	<query id="CoreConfirmCraft.insertCraftEditLog" desc="保存替换记录">
		<![CDATA[
			INSERT INTO PLN_SALEORD_CRF_EDIT_LOG
				  (CRF_EDIT_LOG_ID,
				   ORD_LN_DLY_PK,
				   PLN_DIVIDE_ID,
				   ORDER_SOURCE,
				   ORDER_NO,
				   ORDER_SEQ,
				   DELIVERY_NO,
				   R_NUM_ID,
				   CRAFT_FILE_NO_OLD,
				   CRAFT_SEQ_OLD,
				   CRAFT_NO_V_OLD,
				   CRAFT_FILE_NO_NEW,
				   CRAFT_SEQ_NEW,
				   CRAFT_NO_V_NEW,
				   CREATE_NAME,
				   CREATE_TIME)
				  SELECT (SELECT TO_CHAR(SYSDATE, 'YYYYMMDD') ||
				                 LPAD(NVL(MAX(TO_NUMBER(SUBSTR(l.CRF_EDIT_LOG_ID, 9)) + 1),
				                          '1'),
				                      12,
				                      '0')
				            FROM PLN_SALEORD_CRF_EDIT_LOG L
				           WHERE SUBSTR(L.CRF_EDIT_LOG_ID, 0, 8) =
				                 TO_CHAR(SYSDATE, 'YYYYMMDD')),
				         T.ORD_LN_DLY_PK,
				         T.PLN_DIVIDE_ID,
				         T.ORDER_SOURCE,
				         T.ORDER_NO,
				         T.ORDER_SEQ,
				         T.DELIVERY_NO,
				         T.R_NUM_ID,
				         (SELECT M.CRAFT_NO
				            FROM CRAFT_ORD_DESIGN M
				           WHERE M.ORD_LN_PK = T1.ORD_LN_PK
				             AND M.CRAFT_SEQ = '#CRAFT_SEQ_OLD#'),
				         '#CRAFT_SEQ_OLD#',
				         (SELECT M.CRAFT_NO_V
				            FROM CRAFT_ORD_DESIGN M
				           WHERE M.ORD_LN_PK = T1.ORD_LN_PK
				             AND M.CRAFT_SEQ = '#CRAFT_SEQ_OLD#'),
				         (SELECT M.CRAFT_NO
				            FROM CRAFT_ORD_DESIGN M
				           WHERE M.ORD_LN_PK = T1.ORD_LN_PK
				             AND M.CRAFT_SEQ = '#CRAFT_SEQ_NEW#'),
				         '#CRAFT_SEQ_NEW#',
				         (SELECT M.CRAFT_NO_V
				            FROM CRAFT_ORD_DESIGN M
				           WHERE M.ORD_LN_PK = T1.ORD_LN_PK
				             AND M.CRAFT_SEQ = '#CRAFT_SEQ_NEW#'),
				         '#CREATE_NAME#',
				         SYSDATE
				    FROM PLN_SALEORD_PROC T, PLN_SALEORD T1
				   WHERE T1.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK
				     AND T.ORD_LN_DLY_PK = '#ORD_LN_DLY_PK#'
				     AND T.PLN_DIVIDE_ID = '#PLN_DIVIDE_ID#'
		]]>
	</query>

	<query id="CoreConfirmCraft.selectPlnOrderStatus" desc="查询排产行工艺信息">
		<![CDATA[
			SELECT T.PLANSTATUS,
			       T.CRAFT_SEQ,
			       T.INDEX_SEQ,
			       T.PROCESS_SEQ,
			       T.GROUP_JGX,
			       T.GROUP_RCL,
			       T.G_IS_OK,
			       T.F_IS_OK,
			       T.BJ_TYPE,
			       T.BOM,
			       B.GRADECODE,
			       T.GROUP_ROLL,
			       B.D_IN_MATERIAL_NO,
			       B.D_OUT_MATERIAL_NO
			  FROM PLN_SALEORD_PROC T
			  LEFT JOIN SLM_ORD_DESIGN_BOM B
			    ON B.BOM = T.BOM
			   AND B.MATERIAL_NO = T.MATERIAL_NO, PLN_SALEORD T1
			 WHERE T1.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK
			   AND T.ORD_LN_DLY_PK = ?
			   AND T.PLN_DIVIDE_ID = ?
		]]>
	</query>

	<query id="CoreConfirmCraft.selectCraftDesgin" desc="查询工艺制程">
		<![CDATA[
			SELECT T.DESGIN_KEY,
			       T.MSC_PLINE,
			       T.WHOLE_BACKLOG,
			       T.WHOLE_BACKLOG_DESC,
			       (SELECT TO_CHAR(WM_CONCAT(B.GRADENAME))
			          FROM CRAFT_ORD_DESIGN_MSC_PL_GZ B
			         WHERE B.DESGIN_KEY = T.DESGIN_KEY
			           AND B.MSC_PLINE = T.MSC_PLINE) GRADENAME
			  FROM CRAFT_ORD_DESIGN_MSC_PL T, CRAFT_ORD_DESIGN M
			 WHERE M.DESGIN_KEY = T.DESGIN_KEY
			   AND T.VALIDFLAG = '1'
			   AND M.ORD_LN_PK = ?
			   AND M.CRAFT_SEQ = ?
			 ORDER BY T.MSC_PLINE
		]]>
	</query>

	<query id="CoreConfirmCraft.updateRefresCraft" desc="刷新工艺">
		<![CDATA[
			UPDATE PLN_SALEORD_PROC T
			   SET T.INDEX_SEQ          = '#INDEX_SEQ#',
			       T.PROCESS_SEQ        = '#PROCESS_SEQ#',
			       T.GRADECODE_ALL      = '#GRADECODE_ALL#',
			       T.F_IS_OK            = '#F_IS_OK#',
			       T.BOM                = '#BOM#',
			       T.GRADECODE          = '#GRADECODE#',
			       T.GROUP_ROLL_ALL     = '#GROUP_ROLL_ALL#',
			       T.E_IN_MATERIAL_NO   = '#E_IN_MATERIAL_NO#',
			       T.E_IN_MATERIAL_DESC = '#E_IN_MATERIAL_DESC#',
			       T.DIMATER_YLG        = '#DIMATER_YLG#',
			       T.HEIGHT_YLG         = '#HEIGHT_YLG#',
			       T.GROUP_JGX          = '#GROUP_JGX#',
			       T.GROUP_RCL          = '#GROUP_RCL#'
			 WHERE T.ORD_LN_DLY_PK = '#ORD_LN_DLY_PK#'
			   AND T.PLN_DIVIDE_ID = '#PLN_DIVIDE_ID#'
		]]>
	</query>


	<query id="CoreConfirmCraft.queryPlnOrderZg" desc="查询轧管工序合同状态">
		<![CDATA[
			SELECT T.ORDERSTATUS,
			       T.PRO_ORDER_NO,
			       M1.EXE_STATUS,
			       M1.GPREQ_ID,
			       (T.ORDER_NO || '/' || T.ORDER_SEQ) ORDER_NO_SEQ,
			        NVL(M1.IF_STOVE_ISSUED,0) IF_STOVE_ISSUED,
			       M1.PRO_PLAN_ID,
			       M1.GX_PLAN_NO,
			       M1.PRODUCTION_TH_FLAG
			  FROM PLN_ORDER_ZG T
			  LEFT JOIN PLN_ORDER_ZG_S M1
			    ON M1.PRO_PLAN_ID = T.PRO_PLAN_ID
			 WHERE T.ORD_LN_DLY_PK = ?
			   AND T.PLN_DIVIDE_ID = ?
		]]>
	</query>

	<query id="CoreConfirmCraft.queryPlnOrderDbk" desc="查询镦拔扩工序合同状态">
		<![CDATA[
			SELECT T.ORDERSTATUS,
			       T.PRO_ORDER_NO,
			       M1.EXE_STATUS,
			       (T.ORDER_NO || '/' || T.ORDER_SEQ) ORDER_NO_SEQ,
			       NVL(M1.IF_STOVE_ISSUED,0) IF_STOVE_ISSUED,
			       M1.PRO_PLAN_ID,
			       M1.GX_PLAN_NO
			  FROM PLN_ORDER_DBK T
			  LEFT JOIN PLN_ORDER_DBK_S M1
			    ON M1.PRO_PLAN_ID = T.PRO_PLAN_ID
			 WHERE T.ORD_LN_DLY_PK = ?
			   AND T.PLN_DIVIDE_ID = ?
		]]>
	</query>

	<query id="CoreConfirmCraft.queryPlnOrderRcl" desc="查询热处理工序合同状态">
		<![CDATA[
			SELECT T.ORDERSTATUS,
			       T.PRO_ORDER_NO,
			       M1.EXE_STATUS,
			       (T.ORDER_NO || '/' || T.ORDER_SEQ) ORDER_NO_SEQ,
			       NVL(M1.IF_STOVE_ISSUED,0) IF_STOVE_ISSUED,
			       M1.PRO_PLAN_ID,
			       M1.GX_PLAN_NO
			  FROM PLN_ORDER_RCL T
			  LEFT JOIN PLN_ORDER_RCL_S M1
			    ON M1.PRO_PLAN_ID = T.PRO_PLAN_ID
			 WHERE T.ORD_LN_DLY_PK = ?
			   AND T.PLN_DIVIDE_ID = ?
		]]>
	</query>

	<query id="CoreConfirmCraft.queryPlnOrderJgx" desc="查询加工线工序合同状态">
		<![CDATA[
			SELECT T.ORDERSTATUS,
			       T.PRO_ORDER_NO,
			       M1.EXE_STATUS,
			       (T.ORDER_NO || '/' || T.ORDER_SEQ) ORDER_NO_SEQ,
			       NVL(M1.IF_STOVE_ISSUED,0) IF_STOVE_ISSUED,
			       M1.PRO_PLAN_ID,
			       M1.GX_PLAN_NO
			  FROM PLN_ORDER_JGX T
			  LEFT JOIN PLN_ORDER_JGX_S M1
			    ON M1.PRO_PLAN_ID = T.PRO_PLAN_ID
			 WHERE T.ORD_LN_DLY_PK = ?
			   AND T.PLN_DIVIDE_ID = ?
		]]>
	</query>
	<query id="CoreConfirmCraft.queryPlnOrderJg" desc="查询接箍工序合同状态">
		<![CDATA[
		SELECT T.EXE_STATUS,
       T.REQ_BL_ID,
       NVL(T.IS_STOVE_ISSUED, 0) IF_STOVE_ISSUED,
       T.PRO_PLAN_ID,
       T.GX_PLAN_NO
  FROM PLN_GX_JG_PROP_S T
  WHERE T.ORD_LN_DLY_PK = ?
   AND T.PLN_DIVIDE_ID = ?
			]]>
	</query>
	<query id="CoreConfirmCraft.deletePlnOrderZg" desc="删除工序合同">
		<![CDATA[
			DELETE FROM PLN_ORDER_ZG T WHERE T.ORD_LN_DLY_PK = ? AND T.PLN_DIVIDE_ID = ?
		]]>
	</query>

	<query id="CoreConfirmCraft.deletePlnOrderDbk" desc="删除工序合同">
		<![CDATA[
			DELETE FROM PLN_ORDER_DBK T WHERE T.ORD_LN_DLY_PK = ? AND T.PLN_DIVIDE_ID = ?
		]]>
	</query>

	<query id="CoreConfirmCraft.deletePlnOrderRcl" desc="删除工序合同">
		<![CDATA[
			DELETE FROM PLN_ORDER_RCL T WHERE T.ORD_LN_DLY_PK = ? AND T.PLN_DIVIDE_ID = ?
		]]>
	</query>

	<query id="CoreConfirmCraft.deletePlnOrderJgx" desc="删除工序合同">
		<![CDATA[
			DELETE FROM PLN_ORDER_JGX T WHERE T.ORD_LN_DLY_PK = ? AND T.PLN_DIVIDE_ID = ?
		]]>
	</query>



	<query id="CoreConfirmCraft.updateBlReqSatus" desc="更新备料需求状态">
		<![CDATA[
			UPDATE PLN_PORDER_BL_REQ T SET T.PLANSTATUS = ? WHERE T.REQ_BL_ID = ?
		]]>
	</query>

	<query id="CoreConfirmCraft.selectOrdBlReq" desc="查询备料需求">
		<![CDATA[
			SELECT T.PLANSTATUS, T.BLTYPE
			  FROM PLN_PORDER_BL_REQ T
			 WHERE T.REQ_BL_ID = ?
		]]>
	</query>
	<query id="CoreConfirmCraft.updateRollMonth" desc="修改排产月份">
		<![CDATA[
UPDATE PLN_SALEORD_PROC T
   SET T.ROLL_MONTH = ?
 WHERE T.ORD_LN_DLY_PK = ?
   AND T.PLN_DIVIDE_ID = ?
		]]>
	</query>

<query id="CoreConfirmCraft.querySaleOrderProc" desc="查询">
		<![CDATA[
		 SELECT 
       T.ORD_LN_DLY_PK,
       T.PLN_DIVIDE_ID,
       T.ORDER_SOURCE,
       T.ORDER_NO,
       T.ORDER_SEQ,
       T.DELIVERY_NO,
       T.R_NUM_ID,
       T.PSC,
       T.CRAFT_FILE_NO,
       T.CRAFT_FILE_MAN,
       T.MSC,
       T.INDEX_SEQ,
       T.PROCESS_SEQ,
       T.BOM,
       T.GRADECODE_ALL,
       T.GRADECODE,
       T.G_IS_OK,
       T.GROUP_JGX,
       T.F_IS_OK,
       T.GROUP_RCL,
       T.GROUP_ROLL_ALL,
       T.GROUP_ROLL,
       T.BJ_TYPE,
       T.E_IN_MATERIAL_NO,
       T.E_IN_MATERIAL_DESC,
       T.DIMATER_YLG,
       T.HEIGHT_YLG,
       T.MATERIAL_NO,
       T.MATERIAL_DESC,
       T.STUFF_PROPERTY,
       T.GRADECODE_IS_OK,
       T.D_IS_OK,
       T.E_IS_OK,
       T.WEIGHT_PER_M,
       NVL(T.PLAN_WT_D,0) PLAN_WT_D,
       NVL(T.PLAN_NUM_D,0) PLAN_NUM_D,
       T.PLAN_TOT_LEN_D,
       T.FINISH_WT,
       T.IF_CHANGE,
        NVL(T.PLAN_WT_BEGIN,0) PLAN_WT_BEGIN,
        NVL(T.PLAN_NUM_BEGIN,0) PLAN_NUM_BEGIN,
       T.PLANSTATUS,
       T.IF_ALLOW_ISSUE,
       TO_CHAR(T.ISSUED_TIME, 'YYYY-MM-DD HH24:MI:SS') ISSUED_TIME,
       T.ISSUED_MAN,
       T.HEIGHT_NK_MIN,
       T.HEIGHT_NK_MAX,
       T.ORDER_QTY_D,
       T.ORDER_UNIT,
       T.AIM_LEN_ROLL,
       T.AIM_LEN_END,
       NVL(T.PLAN_P_MAIN,0) PLAN_P_MAIN,
       T.TOT_LEN_ONE_P,
       T.CUT_NUM_P,
       T.CRAFT_SEQ,
       T.CRAFT_NO_V,
       T.AIM_WALLTHICK,
       T.ROLL_LENGTH,
       T.CRAFT_RENEW_ST,
       T.CRAFT_NO_NEW,
       T.CRAFT_NO_V_NEW,
       T.GROUP_ROLL_NAME,
       T.PLAN_IS_OK,
       T.ABC,
       T.ROLL_MONTH,
       T.PRIORITY,
       T.PRIORITY_MEMO,
       T.PRDCRPRO,
       T.LEN_ROLL_MAX,
       T.LEN_ROLL_MIN,
       T.IF_EXPORT,
       T.VERSION_NO,
       TO_CHAR(T.LAST_UNDOWN_TIME, 'YYYY-MM-DD HH24:MI:SS') LAST_UNDOWN_TIME,
       T.LAST_UNDOWN_MAN,
       T.ADJUST_PRICE_NUM,
       T.TOTAL_COST,
       T.OUT_MULT_D,
       T.PROC_DESC_C_RCL,
       T.AIM_OUTDIAMETER,
       T.AIM_WALLTHICK_IS_OK,
       T.FEED_RATE,
       T.COEFFICIENT,
       T.COEFFICIENT_MIN,
       NVL(T.PLAN_P_MAIN_MIN,0) PLAN_P_MAIN_MIN,
       T.AIM_WT_END,
       T.WEIGHT_KZ_M,
       T.LEN_CUTHEAD_DBK,
       T.LEN_CUTEND_DBK,
       T.LEN_LONGER_DBK,
       T.RATIO_DBK,
       T.LEN_SCOPE
 FROM PLN_SALEORD_PROC T
 WHERE 1=1
		]]>
	</query>
<query id="CoreConfirmCraft.updateOrdProc" desc="拆分修改原排产合同行量">
		<![CDATA[
		UPDATE PLN_SALEORD_PROC T
   SET T.PLAN_WT_D       = '#PLAN_WT_D#',
       T.PLAN_NUM_D      = '#PLAN_NUM_D#',
       T.PLAN_TOT_LEN_D  = '#PLAN_TOT_LEN_D#',
       T.PLAN_WT_BEGIN   = '#PLAN_WT_BEGIN#',
       T.PLAN_NUM_BEGIN  = '#PLAN_NUM_BEGIN#',
       T.ORDER_QTY_D     = '#ORDER_QTY_D#',
       T.PLAN_P_MAIN     = '#PLAN_P_MAIN#',
       T.PLAN_P_MAIN_MIN = '#PLAN_P_MAIN_MIN#'
 WHERE T.ORD_LN_DLY_PK = '#ORD_LN_DLY_PK#'
   AND T.PLN_DIVIDE_ID = '#PLN_DIVIDE_ID#'
		]]>
	</query>
	
	<query id="CoreConfirmCraft.ADDOrdProc" desc="新增拆分排产合同">
		<![CDATA[
		 INSERT INTO PLN_SALEORD_PROC(
        ORD_LN_DLY_PK,
        PLN_DIVIDE_ID,
        ORDER_SOURCE,
        ORDER_NO,
        ORDER_SEQ,
        DELIVERY_NO,
        R_NUM_ID,
        PSC,
        CRAFT_FILE_NO,
        CRAFT_FILE_MAN,
        MSC,
        INDEX_SEQ,
        PROCESS_SEQ,
        BOM,
        GRADECODE_ALL,
        GRADECODE,
        G_IS_OK,
        GROUP_JGX,
        F_IS_OK,
        GROUP_RCL,
        GROUP_ROLL_ALL,
        GROUP_ROLL,
        BJ_TYPE,
        E_IN_MATERIAL_NO,
        E_IN_MATERIAL_DESC,
        DIMATER_YLG,
        HEIGHT_YLG,
        MATERIAL_NO,
        MATERIAL_DESC,
        STUFF_PROPERTY,
        GRADECODE_IS_OK,
        D_IS_OK,
        E_IS_OK,
        WEIGHT_PER_M,
        PLAN_WT_D,
        PLAN_NUM_D,
        PLAN_TOT_LEN_D,
        FINISH_WT,
        IF_CHANGE,
        PLAN_WT_BEGIN,
        PLAN_NUM_BEGIN,
        PLANSTATUS,
        IF_ALLOW_ISSUE,
        HEIGHT_NK_MIN,
        HEIGHT_NK_MAX,
        ORDER_QTY_D,
        ORDER_UNIT,
        AIM_LEN_ROLL,
        AIM_LEN_END,
        PLAN_P_MAIN,
        TOT_LEN_ONE_P,
        CUT_NUM_P,
        CRAFT_SEQ,
        CRAFT_NO_V,
        AIM_WALLTHICK,
        ROLL_LENGTH,
        CRAFT_RENEW_ST,
        CRAFT_NO_NEW,
        CRAFT_NO_V_NEW,
        GROUP_ROLL_NAME,
        PLAN_IS_OK,
        ABC,
        ROLL_MONTH,
        PRIORITY,
        PRIORITY_MEMO,
        PRDCRPRO,
        LEN_ROLL_MAX,
        LEN_ROLL_MIN,
        IF_EXPORT,
        VERSION_NO,
        LAST_UNDOWN_TIME,
        LAST_UNDOWN_MAN,
        ADJUST_PRICE_NUM,
        TOTAL_COST,
        OUT_MULT_D,
        PROC_DESC_C_RCL,
        AIM_OUTDIAMETER,
        AIM_WALLTHICK_IS_OK,
        FEED_RATE,
        COEFFICIENT,
        COEFFICIENT_MIN,
        PLAN_P_MAIN_MIN,
        AIM_WT_END,
        WEIGHT_KZ_M,
        LEN_CUTHEAD_DBK,
        LEN_CUTEND_DBK,
        LEN_LONGER_DBK,
        RATIO_DBK,
        LEN_SCOPE)
 VALUES( 
        '#ORD_LN_DLY_PK#',
        '#PLN_DIVIDE_ID#',
        '#ORDER_SOURCE#',
        '#ORDER_NO#',
        '#ORDER_SEQ#',
        '#DELIVERY_NO#',
        '#R_NUM_ID#',
        '#PSC#',
        '#CRAFT_FILE_NO#',
        '#CRAFT_FILE_MAN#',
        '#MSC#',
        '#INDEX_SEQ#',
        '#PROCESS_SEQ#',
        '#BOM#',
        '#GRADECODE_ALL#',
        '#GRADECODE#',
        '#G_IS_OK#',
        '#GROUP_JGX#',
        '#F_IS_OK#',
        '#GROUP_RCL#',
        '#GROUP_ROLL_ALL#',
        '#GROUP_ROLL#',
        '#BJ_TYPE#',
        '#E_IN_MATERIAL_NO#',
        '#E_IN_MATERIAL_DESC#',
        '#DIMATER_YLG#',
        '#HEIGHT_YLG#',
        '#MATERIAL_NO#',
        '#MATERIAL_DESC#',
        '#STUFF_PROPERTY#',
        '#GRADECODE_IS_OK#',
        '#D_IS_OK#',
        '#E_IS_OK#',
        '#WEIGHT_PER_M#',
        '#PLAN_WT_D#',
        '#PLAN_NUM_D#',
        '#PLAN_TOT_LEN_D#',
        '#FINISH_WT#',
        '#IF_CHANGE#',
        '#PLAN_WT_BEGIN#',
        '#PLAN_NUM_BEGIN#',
        '#PLANSTATUS#',
        '#IF_ALLOW_ISSUE#',
        '#HEIGHT_NK_MIN#',
        '#HEIGHT_NK_MAX#',
        '#ORDER_QTY_D#',
        '#ORDER_UNIT#',
        '#AIM_LEN_ROLL#',
        '#AIM_LEN_END#',
        '#PLAN_P_MAIN#',
        '#TOT_LEN_ONE_P#',
        '#CUT_NUM_P#',
        '#CRAFT_SEQ#',
        '#CRAFT_NO_V#',
        '#AIM_WALLTHICK#',
        '#ROLL_LENGTH#',
        '#CRAFT_RENEW_ST#',
        '#CRAFT_NO_NEW#',
        '#CRAFT_NO_V_NEW#',
        '#GROUP_ROLL_NAME#',
        '#PLAN_IS_OK#',
        '#ABC#',
        '#ROLL_MONTH#',
        '#PRIORITY#',
        '#PRIORITY_MEMO#',
        '#PRDCRPRO#',
        '#LEN_ROLL_MAX#',
        '#LEN_ROLL_MIN#',
        '#IF_EXPORT#',
        '#VERSION_NO#',
        SYSDATE,
        '#LAST_UNDOWN_MAN#',
        '#ADJUST_PRICE_NUM#',
        '#TOTAL_COST#',
        '#OUT_MULT_D#',
        '#PROC_DESC_C_RCL#',
        '#AIM_OUTDIAMETER#',
        '#AIM_WALLTHICK_IS_OK#',
        '#FEED_RATE#',
        '#COEFFICIENT#',
        '#COEFFICIENT_MIN#',
        '#PLAN_P_MAIN_MIN#',
        '#AIM_WT_END#',
        '#WEIGHT_KZ_M#',
        '#LEN_CUTHEAD_DBK#',
        '#LEN_CUTEND_DBK#',
        '#LEN_LONGER_DBK#',
        '#RATIO_DBK#',
        '#LEN_SCOPE#')
		]]>
	</query>
</queryMap>