<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="工序耗时">

	<query id="CorePlnOrdProUseTime.queryProcessAPine" desc="查询电炉产线">
		<![CDATA[
			SELECT T.PLINE_CODE,
       T.PLINE_NAME,
       T1.IN_MATERIAL_NO,
       T1.IN_MATERIAL_DESC,
       T1.OUT_MATERIAL_NO,
       T1.OUT_MATERIAL_DESC
  FROM SLM_BASE_MATERIAL_A_PL T
  LEFT JOIN SLM_BASE_MATERIAL_A T1
    ON T1.IN_MATERIAL_NO = T.IN_MATERIAL_NO
   AND T1.OUT_MATERIAL_NO = T.OUT_MATERIAL_NO
 WHERE (T.DISABLE_FL != '1' OR T.DISABLE_FL IS NULL)
   AND T.OUT_MATERIAL_NO = ?
   AND T.PLINE_CODE = (SELECT B.PLINE_CODE_A
                         FROM PLN_BASE_PLINE_LZ B
                        WHERE B.PLINE_CODE = ?)
 ORDER BY T.PLINE_LEVEL ASC, T.PLINE_CODE ASC
		]]>
	</query>
	<query id="CorePlnOrdProUseTime.queryPlnBasePlineA" desc="查询基础铸造对应电炉产线">
		<![CDATA[
		SELECT T.PLINE_CODE_A, T.PLINE_NAME_A
  FROM PLN_BASE_PLINE_LZ T
 WHERE T.PLINE_CODE = ?
 AND DEF_VAL='1'	
		]]>
	</query>
	<query id="CorePlnOrdProUseTime.queryDzPineHrCapcty" desc="查询锻造产线能力">
		<![CDATA[
			SELECT DECODE(M.HR_CAPCTY,
			              NULL,
			              0,
			              0,
			              0,
			              CEIL(60 * T.OUT_NUM_TOT / M.HR_CAPCTY)) USE_TIME,
			              M.HR_CAPCTY,
			              T.OUT_WT_TOT
			  FROM PLN_GX_DP_M T
			  LEFT JOIN SLM_BASE_MATERIAL_C_PL M
			    ON M.IN_MATERIAL_NO = T.WLID_IN
			   AND M.OUT_MATERIAL_NO = T.OUTWL_ID
			   AND M.PLINE_CODE = T.PLINE_CODE
			 WHERE T.PRO_PLAN_ID = ?
		]]>
	</query>

	<query id="CorePlnOrdProUseTime.queryCastPineHrCapcty" desc="查询铸造产线能力">
		<![CDATA[
			SELECT T.GRADECODE,
				   T.GRADENAME,
				   DECODE(M.HR_CAPCTY,
			              NULL,
			              0,
			              0,
			              0,
			              CEIL(60 * T.PLAN_NUM / M.HR_CAPCTY)) USE_TIME,
			              M.HR_CAPCTY,
			              T.PLAN_WT
			  FROM PLN_GX_CAST_M T
			  LEFT JOIN PLN_REQINF_GP T1
			    ON T1.GPREQ_ID = T.GPREQ_ID
			  LEFT JOIN SLM_BASE_MATERIAL_B_PL M
			    ON M.IN_MATERIAL_NO = T.GRADECODE
			   AND M.OUT_MATERIAL_NO = T.MATERIAL_NO
			   AND M.PLINE_CODE = T1.PLINE_CODE_ZZ
			 WHERE T.PRO_PLAN_ID = ?
		]]>
	</query>


	<query id="CorePlnOrdProUseTime.queryJgxPineHrCapcty" desc="查询加工产线小时能力">
		<![CDATA[
			SELECT M.HR_CAPCTY,
			       T.IN_NUM,
			       T.IN_WEIGHT,
			       M.WASTE_RATE,
			       T.PLANNUM,
			       DECODE(M.HR_CAPCTY,
			              NULL,
			              0,
			              0,
			              0,
			              CEIL(60 * T.PLANNUM / M.HR_CAPCTY)) USE_TIME,
			      CASE
         WHEN C1.CIC IS NULL THEN
          C1.CIC
          WHEN  (SELECT P.CIC
             FROM CRAFT_ORD_DESIGN_MSC_PL_PRC P
            WHERE P.DESGIN_KEY = C.DESGIN_KEY
              AND P.MSC_PLINE = T2.INDEX_SEQ
              AND P.PROCESS_CODE = 'A') IS NULL THEN 
                C1.CIC
          WHEN  (SELECT P.CIC
             FROM CRAFT_ORD_DESIGN_MSC_PL_PRC P
            WHERE P.DESGIN_KEY = C.DESGIN_KEY
              AND P.MSC_PLINE = T2.INDEX_SEQ
              AND P.PROCESS_CODE = 'A') IS NOT NULL THEN 
          (SELECT P.CIC
             FROM CRAFT_ORD_DESIGN_MSC_PL_PRC P
            WHERE P.DESGIN_KEY = C.DESGIN_KEY
              AND P.MSC_PLINE = T2.INDEX_SEQ
              AND P.PROCESS_CODE = 'A')
       END CIC,
			       C1.PIC,
			       C1.SIC,
			       C1.DIC,
			       C1.WIC,
			       C1.GIC,
			       (SELECT LISTAGG(S.STATION_DESC, ',') WITHIN GROUP(ORDER BY S.STATION_CODE)
			          FROM CRAFT_ORD_DESIGN_MSC_PL_STI S
			         WHERE S.DESGIN_KEY = C1.DESGIN_KEY
			           AND S.MSC_PLINE = C1.MSC_PLINE
			           AND S.PROCESS_CODE = C1.PROCESS_CODE) STATION_ROAD
			  FROM PLN_GX_JGX_M T
			  LEFT JOIN PLN_SALEORD T1
			    ON T1.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK
			  LEFT JOIN PLN_SALEORD_PROC T2
			    ON T2.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK
			   AND T2.PLN_DIVIDE_ID = T.PLN_DIVIDE_ID
			  LEFT JOIN CRAFT_ORD_DESIGN C
			    ON C.ORD_LN_PK = T1.ORD_LN_PK
			   AND C.CRAFT_SEQ = T2.CRAFT_SEQ
			  LEFT JOIN CRAFT_ORD_DESIGN_MSC_PL_PRC C1
			    ON C1.DESGIN_KEY = C.DESGIN_KEY
			   AND C1.MSC_PLINE = T2.INDEX_SEQ
			   AND C1.PROCESS_CODE = 'G'
			  LEFT JOIN SLM_BASE_MATERIAL_K_PL M
			    ON M.PLINE_CODE = T.PLINE_CODE
			   AND M.OUT_MATERIAL_NO = T.OUTWL_ID
			   AND M.IN_MATERIAL_NO = T.INWL_ID
			 WHERE T.PRO_PLAN_ID = ?
		]]>
	</query>

	<query id="CorePlnOrdProUseTime.queryRclPineHrCapcty" desc="查询热处理产线小时能力">
		<![CDATA[
			SELECT M.HR_CAPCTY,
			       T.IN_NUM,
			       T.IN_WEIGHT,
			       T1.LENGTHDISC,
			       M.WASTE_RATE,
			       B.GRADECODE,
			       B.GRADENAME,
			       T.PLANNUM,
			       DECODE(M.HR_CAPCTY,
			              NULL,
			              0,
			              0,
			              0,
			              CEIL(60 * T.PLANNUM / M.HR_CAPCTY)) USE_TIME,
			     CASE
         WHEN C1.CIC IS NULL THEN
          C1.CIC
          WHEN (SELECT P.CIC
             FROM CRAFT_ORD_DESIGN_MSC_PL_PRC P
            WHERE P.DESGIN_KEY = C.DESGIN_KEY
              AND P.MSC_PLINE = T2.INDEX_SEQ
              AND P.PROCESS_CODE = 'A') IS NULL THEN 
                 C1.CIC
       WHEN (SELECT P.CIC
             FROM CRAFT_ORD_DESIGN_MSC_PL_PRC P
            WHERE P.DESGIN_KEY = C.DESGIN_KEY
              AND P.MSC_PLINE = T2.INDEX_SEQ
              AND P.PROCESS_CODE = 'A') IS NOT NULL THEN 
          (SELECT P.CIC
             FROM CRAFT_ORD_DESIGN_MSC_PL_PRC P
            WHERE P.DESGIN_KEY = C.DESGIN_KEY
              AND P.MSC_PLINE = T2.INDEX_SEQ
              AND P.PROCESS_CODE = 'A')
       END CIC,
			       C1.PIC,
			       C1.SIC,
			       C1.DIC,
			       C1.WIC,
			       C1.GIC,
			       (SELECT LISTAGG(S.STATION_DESC, ',') WITHIN GROUP(ORDER BY S.STATION_CODE)
			          FROM CRAFT_ORD_DESIGN_MSC_PL_STI S
			         WHERE S.DESGIN_KEY = C1.DESGIN_KEY
			           AND S.MSC_PLINE = C1.MSC_PLINE
			           AND S.PROCESS_CODE = C1.PROCESS_CODE) STATION_ROAD
			  FROM PLN_GX_RCL_M T
			  LEFT JOIN PLN_SALEORD T1
			    ON T1.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK
			  LEFT JOIN PLN_SALEORD_PROC T2
			    ON T2.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK
			   AND T2.PLN_DIVIDE_ID = T.PLN_DIVIDE_ID
			  LEFT JOIN COM_BASE_GRADE B
				ON B.GRADECODE = T2.GRADECODE
			  LEFT JOIN CRAFT_ORD_DESIGN C
			    ON C.ORD_LN_PK = T1.ORD_LN_PK
			   AND C.CRAFT_SEQ = T2.CRAFT_SEQ
			  LEFT JOIN CRAFT_ORD_DESIGN_MSC_PL_PRC C1
			    ON C1.DESGIN_KEY = C.DESGIN_KEY
			   AND C1.MSC_PLINE = T2.INDEX_SEQ
			   AND C1.PROCESS_CODE = 'F'
			  LEFT JOIN SLM_BASE_MATERIAL_F_PL M
			    ON M.PLINE_CODE = T.PLINE_CODE
			   AND M.IN_MATERIAL_NO = T.INWL_ID
			   AND M.OUT_MATERIAL_NO = T.OUTWL_ID
			 WHERE T.PRO_PLAN_ID = ?
		]]>
	</query>

	<query id="CorePlnOrdProUseTime.queryDbkPineHrCapcty" desc="查询镦拔扩产线小时能力">
		<![CDATA[
			SELECT M.HR_CAPCTY,
			       M.CROP_HEAD,
			       M.CROP_END,
			       T.IN_NUM,
			       T.IN_WEIGHT,
			       M.WASTE_RATE,
			       T.PLANNUM,
			       DECODE(M.HR_CAPCTY,
			              NULL,
			              0,
			              0,
			              0,
			              CEIL(60 * T.PLANNUM / M.HR_CAPCTY)) USE_TIME,
			      CASE
         WHEN C1.CIC IS NULL THEN
          C1.CIC
          WHEN (SELECT P.CIC
             FROM CRAFT_ORD_DESIGN_MSC_PL_PRC P
            WHERE P.DESGIN_KEY = C.DESGIN_KEY
              AND P.MSC_PLINE = T2.INDEX_SEQ
              AND P.PROCESS_CODE = 'A') IS NULL THEN
               C1.CIC
          WHEN (SELECT P.CIC
             FROM CRAFT_ORD_DESIGN_MSC_PL_PRC P
            WHERE P.DESGIN_KEY = C.DESGIN_KEY
              AND P.MSC_PLINE = T2.INDEX_SEQ
              AND P.PROCESS_CODE = 'A') IS NOT NULL THEN
          (SELECT P.CIC
             FROM CRAFT_ORD_DESIGN_MSC_PL_PRC P
            WHERE P.DESGIN_KEY = C.DESGIN_KEY
              AND P.MSC_PLINE = T2.INDEX_SEQ
              AND P.PROCESS_CODE = 'A')
       END CIC,
			       C1.PIC,
			       C1.SIC,
			       C1.DIC,
			       C1.WIC,
			       C1.GIC,
			       (SELECT LISTAGG(S.STATION_DESC, ',') WITHIN GROUP(ORDER BY S.STATION_CODE)
			          FROM CRAFT_ORD_DESIGN_MSC_PL_STI S
			         WHERE S.DESGIN_KEY = C1.DESGIN_KEY
			           AND S.MSC_PLINE = C1.MSC_PLINE
			           AND S.PROCESS_CODE = C1.PROCESS_CODE) STATION_ROAD
			  FROM PLN_GX_DBK_M T
			  LEFT JOIN PLN_SALEORD T1
			    ON T1.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK
			  LEFT JOIN PLN_SALEORD_PROC T2
			    ON T2.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK
			   AND T2.PLN_DIVIDE_ID = T.PLN_DIVIDE_ID
			  LEFT JOIN CRAFT_ORD_DESIGN C
			    ON C.ORD_LN_PK = T1.ORD_LN_PK
			   AND C.CRAFT_SEQ = T2.CRAFT_SEQ
			  LEFT JOIN CRAFT_ORD_DESIGN_MSC_PL_PRC C1
			    ON C1.DESGIN_KEY = C.DESGIN_KEY
			   AND C1.MSC_PLINE = T2.INDEX_SEQ
			   AND C1.PROCESS_CODE = 'E'
			  LEFT JOIN SLM_BASE_MATERIAL_E_PL M
			    ON M.PLINE_CODE = T.PLINE_CODE
			   AND M.IN_MATERIAL_NO = T.INWL_ID
			   AND M.OUT_MATERIAL_NO = T.OUTWL_ID
			 WHERE T.PRO_PLAN_ID = ?
		]]>
	</query>

	<query id="CorePlnOrdProUseTime.queryZgPineHrCapcty" desc="查询轧管产线小时能力">
		<![CDATA[
			SELECT M.HR_CAPCTY,
			       M.CROP_HEAD,
			       M.CROP_END,
			       T.IN_NUM,
			       T.IN_WT,
			       T.OUTNUM_SINGLE,
			       M.WASTE_RATE,
			       M.MANDREL_SIZE,
			       T3.PASS_CODE,
			       T3.PASS_NAME,
			       T3.IN_NUM,
			       T3.ADD_NUM_IN,
			       DECODE(M.HR_CAPCTY,
                    NULL,
                    0,
                    0,
                    0,
                    CEIL(60 * ((NVL(T3.IN_NUM,0)+NVL(T3.ADD_NUM_IN,0)) / M.HR_CAPCTY))) USE_TIME,
			     CASE
   WHEN C1.CIC IS NULL THEN
    C1.CIC
   WHEN (SELECT P.CIC
           FROM CRAFT_ORD_DESIGN_MSC_PL_PRC P
          WHERE P.DESGIN_KEY = C.DESGIN_KEY
            AND P.MSC_PLINE = T2.INDEX_SEQ
            AND P.PROCESS_CODE = 'A') IS NULL THEN
    C1.CIC
   WHEN (SELECT P.CIC
           FROM CRAFT_ORD_DESIGN_MSC_PL_PRC P
          WHERE P.DESGIN_KEY = C.DESGIN_KEY
            AND P.MSC_PLINE = T2.INDEX_SEQ
            AND P.PROCESS_CODE = 'A') IS NOT NULL THEN
    (SELECT P.CIC
       FROM CRAFT_ORD_DESIGN_MSC_PL_PRC P
      WHERE P.DESGIN_KEY = C.DESGIN_KEY
        AND P.MSC_PLINE = T2.INDEX_SEQ
        AND P.PROCESS_CODE = 'A')
 END CIC,
			       C1.PIC,
			       C1.SIC,
			       C1.DIC,
			       C1.WIC,
			       C1.GIC,
			       (SELECT LISTAGG(S.STATION_DESC, ',') WITHIN GROUP(ORDER BY S.STATION_CODE)
			          FROM CRAFT_ORD_DESIGN_MSC_PL_STI S
			         WHERE S.DESGIN_KEY = C1.DESGIN_KEY
			           AND S.MSC_PLINE = C1.MSC_PLINE
			           AND S.PROCESS_CODE = C1.PROCESS_CODE) STATION_ROAD
			  FROM PLN_GX_ZG_M T
			  LEFT JOIN PLN_SALEORD T1
			    ON T1.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK
			  LEFT JOIN PLN_SALEORD_PROC T2
			    ON T2.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK
			   AND T2.PLN_DIVIDE_ID = T.PLN_DIVIDE_ID
			  LEFT JOIN PLN_ORDER_ZG T3
			    ON T3.PRO_ORDER_NO = T.PRO_ORDER_NO
			  LEFT JOIN CRAFT_ORD_DESIGN C
			    ON C.ORD_LN_PK = T1.ORD_LN_PK
			   AND C.CRAFT_SEQ = T2.CRAFT_SEQ
			  LEFT JOIN CRAFT_ORD_DESIGN_MSC_PL_PRC C1
			    ON C1.DESGIN_KEY = C.DESGIN_KEY
			   AND C1.MSC_PLINE = T2.INDEX_SEQ
			   AND C1.PROCESS_CODE = 'D'
			  LEFT JOIN SLM_BASE_MATERIAL_D_PL M
			    ON M.PLINE_CODE = T.PLINE_CODE
			   AND M.IN_MATERIAL_NO = T.INWL_GP
			   AND M.OUT_MATERIAL_NO = T.OUTWL_ID
			 WHERE T.PRO_PLAN_ID = ?
		]]>
	</query>

	<query id="CorePlnOrdProUseTime.selectGpIcList" desc="查询管坯需求内控标准项集合">
		<![CDATA[
			SELECT T.PRO_PLAN_ID,
			       M1.PROCESS_CODE,
			       M1.PROCESS_DESC,
			       M1.CIC,
			       M1.PIC,
			       M1.SIC,
			       M1.DIC,
			       M1.WIC,
			       M1.GIC,
			       T.GRADECODE
			  FROM PLN_GX_ZG_M T
			  LEFT JOIN PLN_ORDER_ZG T2
			    ON T2.PRO_ORDER_NO = T.PRO_ORDER_NO
			  LEFT JOIN PLN_SALEORD T1
			    ON T1.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK
			  LEFT JOIN SLM_ORD_DESIGN_BOM B
			    ON B.BOM = T2.BOM
			   AND B.MATERIAL_NO = T1.MATERIAL_NO
			  LEFT JOIN CRAFT_ORD_DESIGN M
			    ON M.ORD_LN_PK = T1.ORD_LN_PK
			   AND M.CRAFT_SEQ = T2.CRAFT_SEQ
			  LEFT JOIN CRAFT_ORD_DESIGN_MSC_PL_PRC M1
			    ON M1.DESGIN_KEY = M.DESGIN_KEY
			   AND M1.MSC_PLINE = T2.INDEX_SEQ
			   --AND M1.BACKLOG_SEQ = (T2.BACKLOG_SEQ - 1)
			   AND M1.PROCESS_CODE IN ('A','B','C')
			 WHERE T.PRO_PLAN_ID = ?
		]]>
	</query>



	<query id="CorePlnOrdProUseTime.addOrderCastS" desc="新增铸造耗时工序">
		<![CDATA[
			INSERT INTO PLN_ORDER_CAST_S
				  (PRO_PLAN_ID,
				   GX_PLAN_NO,
				   GPTYPE,
				   CASTINGTYPE,
				   PLINE_CODE,
				   PLINE_NAME,
				   PLINE_CODE_A,
				   PLINE_NAME_A,
				   GRADECODE,
				   GRADENAME,
				   DIAMETER_LZ,
				   LEN_GP_SINGLE,
				   CUT_NUM_GP,
				   CUT_LOSE_LEN,
				   LENGTH_LZ,
				   MATERIAL_NO,
				   MATERIAL_NAME,
				   WLID_IN,
				   WLDESC_IN,
				   CIC,
				   PIC,
				   SIC,
				   DIC,
				   WIC,
				   GIC,
				   IF_MONITOR_LG,
				   PRDCR_NO,
				   MONITOR_POINT,
				   WT_CAST_ONE,
				   PLAN_WT_S,
				   PLAN_NUM_S,
				   GX_PRO_SEQ,
				   PRO_MONTH,
				   PLAN_USETIME,
				   PLAN_TIME_B,
				   PLAN_TIME_E,
				   EXE_STATUS,
				   IS_REPAIR_PLN,
				   IS_PLAN_OK,
				   CREATE_NAME,
				   CREATE_TIME,PLAN_WT_MIN,GOWHERE_CODE,GOWHERE_NAME)
				  SELECT T.PRO_PLAN_ID,
				         '1',
				         T.GPTYPE,
				         T.CASTINGTYPE,
				         '#PLINE_CODE#',
				         '#PLINE_NAME#',
				         '#PLINE_CODE_A#',
				         '#PLINE_NAME_A#',
				         T.GRADECODE,
				         T.GRADENAME,
				         T.DIAMETER_LZ,
				         T.LEN_GP_SINGLE,
				         T.CUT_NUM_GP,
				         T.CUT_LOSE_LEN,
				         T.LENGTH_LZ,
				         T.MATERIAL_NO,
				         T.MATERIAL_NAME,
				         T.GRADECODE,
				         T.GRADENAME,
				         T.CIC,
				         T.PIC,
				         T.SIC,
				         T.DIC,
				         T.WIC,
				         T.GIC,
				         T.IF_MONITOR_LG,
				         T.PRDCR_NO,
				         T.MONITOR_POINT,
				         T.WT_CAST_ONE,
				         T.PLAN_WT,
				         T.PLAN_NUM,
				        '#GX_PRO_SEQ#',
				         '#PRO_MONTH#',
				         '#PLAN_USETIME#',
				         TO_DATE('#PLAN_TIME_B#','YYYY-MM-DD HH24:MI:SS'),
				         TO_DATE('#PLAN_TIME_E#','YYYY-MM-DD HH24:MI:SS'),		
				         '0',
				         '0',
				         '0',
				         '#CREATE_NAME#',
				         TO_DATE('#CREATE_TIME#','YYYY-MM-DD HH24:MI:SS'),?	,?,?
				    FROM PLN_GX_CAST_M T
				   WHERE T.PRO_PLAN_ID = '#PRO_PLAN_ID#'
		]]>
	</query>

	<query id="CorePlnOrdProUseTime.addOrderDzS" desc="新增锻造耗时工序">
		<![CDATA[
			INSERT INTO PLN_ORDER_DZ_S
  (PRO_PLAN_ID,
   GX_PLAN_NO,
   PLINE_CODE,
   PLINE_NAME,
   CASTINGTYPE,
   GRADECODE,
   GRADENAME,
   DIAMETER_OUT,
   LENGTH_OUT,
   OUTWL_ID,
   OUTWL_DESC,
   OUT_WT_ONE,
   OUT_WT_TOT,
   OUT_NUM_TOT,
   DIAMETER_IN,
   LENGTH_IN,
   WT_ONE_IN,
   WLID_IN,
   WLDESC_IN,
   IN_WEIGHT_S,
   IN_NUM_S,
   WEIGTH_S,
   NUM_S,
   DZ_LOSE_ADD,
   DZ_CUT_HEAD_END,
   DZ_BURN_LOSE,
   CIC,
   PIC,
   SIC,
   DIC,
   WIC,
   GIC,
   GX_PRO_SEQ,
   PRO_MONTH,
   PLAN_USETIME,
   PLAN_TIME_B,
   PLAN_TIME_E,
   EXE_STATUS,
   IS_REPAIR_PLN,
   IS_PLAN_OK,
   CREATE_TIME,
   CREATE_NAME)
  SELECT T.PRO_PLAN_ID,
         '1',
         '#PLINE_CODE#',
         '#PLINE_NAME#',
         T.CASTINGTYPE,
         T.GRADECODE,
         T.GRADENAME,
         T.DIAMETER_OUT,
         T.LENGTH_OUT,
         T.OUTWL_ID,
         T.OUTWL_DESC,
         T.OUT_WT_ONE,
         T.OUT_WT_TOT,
         T.OUT_NUM_TOT,
         T.DIAMETER_IN,
         T.LENGTH_IN,
         T.WT_ONE_IN,
         T.WLID_IN,
         T.WLDESC_IN,
         T.IN_WT,
         T.IN_NUM,
         T.OUT_WT_TOT,
         T.OUT_NUM_TOT,
         '#DZ_LOSE_ADD#',
         '#DZ_CUT_HEAD_END#',
         '#DZ_BURN_LOSE#',
         T.CIC,
         T.PIC,
         T.SIC,
         T.DIC,
         T.WIC,
         T.GIC,
         '#GX_PRO_SEQ#',
         '#PRO_MONTH#',
         '#PLAN_USETIME#',
         TO_DATE('#PLAN_TIME_B#', 'YYYY-MM-DD HH24:MI:SS'),
         TO_DATE('#PLAN_TIME_E#', 'YYYY-MM-DD HH24:MI:SS'),
         '0',
         '0',
         '0',
         TO_DATE('#CREATE_TIME#', 'YYYY-MM-DD HH24:MI:SS'),
         '#CREATE_NAME#'
    FROM PLN_GX_DP_M T
   WHERE T.PRO_PLAN_ID = '#PRO_PLAN_ID#'
		]]>
	</query>

	<query id="CorePlnOrdProUseTime.addOrderJgxS" desc="新增加工耗时工序">
		<![CDATA[
			INSERT INTO PLN_ORDER_JGX_S
				  (VERSION_NO,PRO_ORDER_NO,
				   PRO_PLAN_ID,
				   GX_PLAN_NO,
				   PLAN_GROUP_ID,
				   ORDER_SOURCE,
				   ORD_LN_DLY_PK,
				   PLN_DIVIDE_ID,
				   ORDER_NO,
				   ORDER_SEQ,
				   DELIVERY_NO,
				   REQ_BL_ID,
				   PLINE_CODE,
				   PLINE_NAME,
				   INWL_ID,
				   INWL_DESC,
				   OUTWL_ID,
				   OUTWL_DESC,
				   WEIGTH_S,
				   NUM_S,
				   GX_PRO_SEQ,
				   PLAN_USETIME,
				   PLAN_TIME_B,
				   PLAN_TIME_E,
				   EXE_STATUS,
				   IS_REPAIR_PLN,
				   STEELCODE,
				   STEELNAME,
				   OUTDIAMETER,
				   WALLTHICK,
				   LENGTHMAX,
				   LENGTHMIN,
				   LENGTHDISC,
				   AIMWALLTHICK,
				   AIMLENGTH,
				   SHRT_LEN_RATO,
				   SHORTEST,
				   LONG_LEN_RATO,
				   LONGEST,
				   SHRT_STOVE,
				   AVG_LEN_MIN,
				   DIFRNC_LEN_MAX,
				   SIGL_LEN,
				   ENDLEN_SPECSTD,
				   MODEL_CODE,
				   MODEL_DESC,
				   LENGTHMAX_IN,
				   LENGTHMIN_IN,
				   LENGTH_IN,
				   OUTNUM_CUT,
				   IN_WEIGHT_S,
				   IN_NUM_S,
				   ADD_WT_IN,
				   ADD_NUM_IN,
				   IF_MONITOR_JGX,
				   PRDCR_NO,
				   MONITOR_POINT,
				   CIC,
				   PIC,
				   SIC,
				   DIC,
				   WIC,
				   GIC,
				   CRAFT_FILE_NO,
				   CRAFT_FILE_MAN,
				   CRAFT_SEQ,
				   STATION_ROAD,
				   PRO_MONTH,
				   PREVIOUS_GX,
				   PREV_GXPLAN_ID,
				   IF_EXPORT,
				   FINAL_USER_DESC,
				   PROCESS_DESC_C_ZG,
				   GROUP_ROLL_NAME,
				   PRDCR_ADVC_DAY,
				   WHOLE_BACKLOG_DESC,
				   PRIORITY,
				   PRIORITY_MEMO,
				   DELVRY_EDATE,
				   STATION_NM,
				   CREATE_TIME,
				   PROCESS_CODE_C,
				   PROCESS_DESC_C,MSC,INDEX_SEQ,BOM,DECISION,GROUP_JGX)
				  SELECT '#VERSION_NO#',T.PRO_ORDER_NO,
				         T.PRO_PLAN_ID,
				         '1',
				         T.PLAN_GROUP_ID,
				         T.ORDER_SOURCE,
				         T.ORD_LN_DLY_PK,
				         T.PLN_DIVIDE_ID,
				         T.ORDER_NO,
				         T.ORDER_SEQ,
				         T.DELIVERY_NO,
				         T.REQ_BL_ID,
				         '#PLINE_CODE#',
				         '#PLINE_NAME#',
				         T.INWL_ID,
				         T.INWL_DESC,
				         T.OUTWL_ID,
				         T.OUTWL_DESC,
				         T.PLANWEIGHT,
				         T.PLANNUM,
				         '#GX_PRO_SEQ#',
				         ?,
				         TO_DATE('#PLAN_TIME_B#','YYYY-MM-DD HH24:MI:SS'),
				         TO_DATE('#PLAN_TIME_E#','YYYY-MM-DD HH24:MI:SS'),				        
				         '0',
				         '0',
				         T.STEELCODE,
				         T.STEELNAME,
				         T.OUTDIAMETER,
				         T.WALLTHICK,
				         T.LENGTHMAX,
				         T.LENGTHMIN,
				         T.LENGTHDISC,
				         T.AIMWALLTHICK,
				         T.AIMLENGTH,
				         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.MODEL_CODE,
				         T.MODEL_DESC,
				         T.LENGTHMAX_IN,
				         T.LENGTHMIN_IN,
				         (T.AIMLENGTH + T.LENGTHMAX_IN - T.LENGTHMAX),
				         '#OUTNUM_CUT#',
				         '#IN_WEIGHT_S#',
				         '#IN_NUM_S#',
				         '#ADD_WT_IN#',
				         '#ADD_NUM_IN#',
				         T.IF_MONITOR_JGX,
				         T.PRDCR_NO,
				         T.MONITOR_POINT,
				         '#CIC#',
				         '#PIC#',
				         '#SIC#',
				         '#DIC#',
				         '#WIC#',
				         '#GIC#',
				         T.CRAFT_FILE_NO,
				         T.CRAFT_FILE_MAN,
				         T.CRAFT_SEQ,
				         '#STATION_ROAD#',
				         T.PRO_MONTH, 
				         T.PREVIOUS_GX,
				         T.PREV_GXPLAN_ID,
				         '#IF_EXPORT#',
				         '#FINAL_USER_DESC#',
				         '#PROCESS_DESC_C_ZG#',
				         '#GROUP_ROLL_NAME#',
				         '#PRDCR_ADVC_DAY#',
				         '#WHOLE_BACKLOG_DESC#',
				         '#PRIORITY#',
				         '#PRIORITY_MEMO#',
				         TO_DATE('#DELVRY_EDATE#', 'YYYY-MM-DD'),
				         '#STATION_NM#',
				         SYSDATE,
				         (select MAX(PROCESS_CODE_C) from PLN_ORDER_JGX  where PLAN_GROUP_ID=T.PLAN_GROUP_ID),
				         (select MAX(PROCESS_DESC_C) from PLN_ORDER_JGX  where PLAN_GROUP_ID=T.PLAN_GROUP_ID),
				         '#MSC#','#INDEX_SEQ#','#BOM#','#DECISION#',T.GROUP_JGX
				    FROM PLN_GX_JGX_M T
				   WHERE T.PRO_PLAN_ID = '#PRO_PLAN_ID#' 
		]]>
	</query>

	<query id="CorePlnOrdProUseTime.addOrderRclS" desc="新增热处理耗时工序">
		<![CDATA[
			INSERT INTO PLN_ORDER_RCL_S
				  (VERSION_NO,PRO_ORDER_NO,
				   PRO_PLAN_ID,
				   GX_PLAN_NO,
				   PLAN_GROUP_ID,
				   ORDER_SOURCE,
				   ORD_LN_DLY_PK,
				   PLN_DIVIDE_ID,
				   ORDER_NO,
				   ORDER_SEQ,
				   DELIVERY_NO,
				   REQ_BL_ID,
				   PLINE_CODE,
				   PLINE_NAME,
				   INWL_ID,
				   INWL_DESC,
				   OUTWL_ID,
				   OUTWL_DESC,
				   GRADECODE,
				   GRADENAME,
				   OUTDIAMETER,
				   WALLTHICK,
				   LENGTHDISC,
				   LENGTHMAX_IN,
				   LENGTHMIN_IN,
				   LENGTH_IN,
				   AIMLENGTH,
				   IN_WEIGHT_S,
				   IN_NUM_S,
				   WEIGTH_S,
				   NUM_S,
				   IF_MONITOR_RCL,
				   PRDCR_NO,
				   MONITOR_POINT,
				   CRAFT_FILE_NO,
				   CRAFT_FILE_MAN,
				   CRAFT_SEQ,
				   STATION_ROAD,
				   GX_PRO_SEQ,
				   PLAN_USETIME,
				   PLAN_TIME_B,
				   PLAN_TIME_E,
				   EXE_STATUS,
				   IS_REPAIR_PLN,
				   ADD_WT_IN,
				   ADD_NUM_IN,
				   ISENDGX,
				   CIC,
				   PIC,
				   SIC,
				   DIC,
				   WIC,
				   GIC,
				   STEELCODE,
				   STEELNAME,
				   PRO_MONTH,
				   PREVIOUS_GX,
				   PREV_GXPLAN_ID,
				   PROCESS_CODE_C,
				   PROCESS_DESC_C,MSC,INDEX_SEQ,BOM,WHOLE_BACKLOG_DESC,WEIGTH_S_MIN,DECISION,PRDCR_ADVC_DAY,GROUP_RCL)
				  SELECT '#VERSION_NO#',T.PRO_ORDER_NO,
				         T.PRO_PLAN_ID,
				         '1',
				         T.PLAN_GROUP_ID,
				         T.ORDER_SOURCE,
				         T.ORD_LN_DLY_PK,
				         T.PLN_DIVIDE_ID,
				         T.ORDER_NO,
				         T.ORDER_SEQ,
				         T.DELIVERY_NO,
				         T.REQ_BL_ID,
				         '#PLINE_CODE#',
				         '#PLINE_NAME#',
				         T.INWL_ID,
				         T.INWL_DESC,
				         T.OUTWL_ID,
				         T.OUTWL_DESC,
				         '#GRADECODE#',
				         '#GRADENAME#',
				         T.OUTDIAMETER,
				         T.WALLTHICK,
				         '#LENGTHDISC#',
				         T.LENGTHMAX_IN,
				         T.LENGTHMIN_IN,
				         (T.AIMLENGTH + T.LENGTHMAX_IN - T.LENGTHMAX),
				         T.AIMLENGTH,
				         '#IN_WEIGHT_S#',
				         '#IN_NUM_S#',
				         T.PLANWEIGHT,
				         T.PLANNUM,
				         T.IF_MONITOR_RCL,
				         T.PRDCR_NO,
				         T.MONITOR_POINT,
				         T.CRAFT_FILE_NO,
				         T.CRAFT_FILE_MAN,
				         T.CRAFT_SEQ,
				         '#STATION_ROAD#',
				        '#GX_PRO_SEQ#',
				         ?,
				         TO_DATE('#PLAN_TIME_B#','YYYY-MM-DD HH24:MI:SS'),
				         TO_DATE('#PLAN_TIME_E#','YYYY-MM-DD HH24:MI:SS'),					        
				         '0',
				         '0',
				         '#ADD_WT_IN#',
				         '#ADD_NUM_IN#',
				         '#ISENDGX#',
				         '#CIC#',
				         '#PIC#',
				         '#SIC#',
				         '#DIC#',
				         '#WIC#',
				         '#GIC#',
				         T.STEELCODE,
				         T.STEELNAME,
				         T.PRO_MONTH, 
				         T.PREVIOUS_GX,
				         T.PREV_GXPLAN_ID,
				         (select MAX(PROCESS_CODE_C) from PLN_ORDER_RCL  where PLAN_GROUP_ID=T.PLAN_GROUP_ID),
				         (select MAX(PROCESS_DESC_C) from PLN_ORDER_RCL  where PLAN_GROUP_ID=T.PLAN_GROUP_ID),
				         '#MSC#','#INDEX_SEQ#','#BOM#',
				         '#WHOLE_BACKLOG_DESC#',
				         '#WEIGTH_S_MIN#','#DECISION#','#PRDCR_ADVC_DAY#',T.GROUP_RCL
				    FROM PLN_GX_RCL_M T
				   WHERE T.PRO_PLAN_ID = '#PRO_PLAN_ID#'
		]]>
	</query>

	<query id="CorePlnOrdProUseTime.addOrderDbkS" desc="新增镦拔扩耗时工序">
		<![CDATA[
			INSERT INTO PLN_ORDER_DBK_S
				  (VERSION_NO,PRO_ORDER_NO,
				   PRO_PLAN_ID,
				   GX_PLAN_NO,
				   PLAN_GROUP_ID,
				   ORDER_SOURCE,
				   ORD_LN_DLY_PK,
				   PLN_DIVIDE_ID,
				   ORDER_NO,
				   ORDER_SEQ,
				   DELIVERY_NO,
				   REQ_BL_ID,
				   PLINE_CODE,
				   PLINE_NAME,
				   INWL_ID,
				   INWL_DESC,
				   OUTWL_ID,
				   OUTWL_DESC,
				   WEIGTH_S,
				   NUM_S,
				   GX_PRO_SEQ,
				   PLAN_USETIME,
				   PLAN_TIME_B,
				   PLAN_TIME_E,
				   EXE_STATUS,
				   IS_REPAIR_PLN,
				   OUTDIAMETER,
				   WALLTHICK,
				   LENGTHDISC,
				   AIMOUTDIAMETER,
				   AIMWALLTHICK,
				   AIMLENGTH,
				   OUTDIAMETER_IN,
				   WALLTHICK_IN,
				   LENGTH_IN,
				   LEN_CUTHEAD,
				   LEN_CUTEND,
				   LENGTHMAX_IN,
				   LENGTHMIN_IN,
				   IN_WEIGHT_S,
				   IN_NUM_S,
				   ADD_WT_IN,
				   ADD_NUM_IN,
				   ISENDGX,
				   IF_MONITOR_DBK,
				   PRDCR_NO,
				   MONITOR_POINT,
				   CIC,
				   PIC,
				   SIC,
				   DIC,
				   WIC,
				   GIC,
				   CRAFT_FILE_NO,
				   CRAFT_FILE_MAN,
				   CRAFT_SEQ,
				   STATION_ROAD,
				   GRADECODE,
				   GRADENAME,
				   PRO_MONTH,
				   PREVIOUS_GX,
				   PREV_GXPLAN_ID,
				   PROCESS_CODE_C,
				   PROCESS_DESC_C,MSC,INDEX_SEQ,BOM,WHOLE_BACKLOG_DESC,WEIGTH_S_MIN,DECISION,
				   IF_EXPORT,PRIORITY,PRIORITY_MEMO,FINAL_USER_DESC,PASS_CODE,PASS_NAME)
				  SELECT '#VERSION_NO#',T.PRO_ORDER_NO,
				         T.PRO_PLAN_ID,
				         '1',
				         T.PLAN_GROUP_ID,
				         T.ORDER_SOURCE,
				         T.ORD_LN_DLY_PK,
				         T.PLN_DIVIDE_ID,
				         T.ORDER_NO,
				         T.ORDER_SEQ,
				         T.DELIVERY_NO,
				         T.REQ_BL_ID,
				        '#PLINE_CODE#',
				        '#PLINE_NAME#',
				         T.INWL_ID,
				         T.INWL_DESC,
				         T.OUTWL_ID,
				         T.OUTWL_DESC,
				         T.PLANWEIGHT,
				         T.PLANNUM,
				        '#GX_PRO_SEQ#',
				         ?,
				         TO_DATE('#PLAN_TIME_B#','YYYY-MM-DD HH24:MI:SS'),
				         TO_DATE('#PLAN_TIME_E#','YYYY-MM-DD HH24:MI:SS'),		        
				         '0',
				         '0',
				         T1.OUTDIAMETER,
				         T1.WALLTHICK,
				         T1.LENGTHDISC,
				         T.OUTDIAMETER,
				         T.WALLTHICK,
				         T.AIMLENGTH,
				         T.OUTDIAMETER_IN,
				         T.WALLTHICK_IN,
				         (T.AIMLENGTH + (T.LENGTHMAX_IN - T.LENGTHMAX)),
				         '#LEN_CUTHEAD#',
				         '#LEN_CUTEND#',
				         T.LENGTHMAX_IN,
				         T.LENGTHMIN_IN,
				         '#IN_WEIGHT_S#',
				         '#IN_NUM_S#',
				         '#ADD_WT_IN#',
				         '#ADD_NUM_IN#',
				         '#ISENDGX#',
				         T.IF_MONITOR_DBK,
				         T.PRDCR_NO,
				         T.MONITOR_POINT,
				         '#CIC#',
				         '#PIC#',
				         '#SIC#',
				         '#DIC#',
				         '#WIC#',
				         '#GIC#',
				         T.CRAFT_FILE_NO,
				         T.CRAFT_FILE_MAN,
				         T.CRAFT_SEQ,
				         '#STATION_ROAD#',
				         T.GRADECODE,
				         T.GRADENAME,
				         T.PRO_MONTH, 
				         T.PREVIOUS_GX,
				         T.PREV_GXPLAN_ID,
				         (select MAX(PROCESS_CODE_C) from PLN_ORDER_DBK where PLAN_GROUP_ID=T.PLAN_GROUP_ID),
				         (select MAX(PROCESS_DESC_C) from PLN_ORDER_DBK where PLAN_GROUP_ID=T.PLAN_GROUP_ID),
				         '#MSC#','#INDEX_SEQ#','#BOM#','#WHOLE_BACKLOG_DESC#','#WEIGTH_S_MIN#','#DECISION#',
				         '#IF_EXPORT#','#PRIORITY#','#PRIORITY_MEMO#',
				         '#FINAL_USER_DESC#','#PASS_CODE#','#PASS_NAME#'
				    FROM PLN_GX_DBK_M T
				    LEFT JOIN PLN_SALEORD T1
				      ON T1.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK
				   WHERE T.PRO_PLAN_ID = '#PRO_PLAN_ID#'
		]]>
	</query>

	<query id="CorePlnOrdProUseTime.addOrderZgS" desc="新增轧管耗时工序">
		<![CDATA[
			INSERT INTO PLN_ORDER_ZG_S
				  (VERSION_NO,PRO_ORDER_NO,
				   PRO_PLAN_ID,
				   GX_PLAN_NO,
				   PLAN_GROUP_ID,
				   ORDER_SOURCE,
				   ORD_LN_DLY_PK,
				   PLN_DIVIDE_ID,
				   ORDER_NO,
				   ORDER_SEQ,
				   DELIVERY_NO,
				   REQ_BL_ID,
				   PLINE_CODE,
				   PLINE_NAME,
				   STEELCODE,
				   STEELNAME,
				   GRADECODE,
				   GRADENAME,
				   OUTDIAMETER,
				   WALLTHICK,
				   LENGTHDISC,
				   INWL_ID,
				   INWL_DESC,
				   OUTWL_ID,
				   OUTWL_DESC,
				   LEN_ROLL_MAX,
				   LEN_ROLL_MIN,
				   AIMOUTDIAMETER,
				   AIMWALLTHICK,
				   AIMLENGTH,
				   DIAMETER_GP,
				   LEN_GP_SINGLE,
				   ROLL_LENGTH,
				   LEN_CUTHEAD,
				   LEN_CUTEND,
				   OUTNUM_CUT,
				   DIAMETER_MANDREL,
				   PASS_CODE,
				   PASS_NAME,
				   IN_WEIGHT_S,
				   IN_NUM_S,
				   WEIGTH_S,
				   NUM_S,
				   ADD_WT_IN,
				   ADD_NUM_IN,
				   ISENDGX,
				   IF_MONITOR_ZG,
				   PRDCR_NO,
				   MONITOR_POINT,
				   CRAFT_FILE_NO,
				   CRAFT_FILE_MAN,
				   CRAFT_SEQ,
				   STATION_ROAD,
				   PRO_MONTH,
				   CIC,
				   PIC,
				   SIC,
				   DIC,
				   WIC,
				   GIC,
				   GX_PRO_SEQ,
				   PLAN_USETIME,
				   PLAN_TIME_B,
				   PLAN_TIME_E,
				   EXE_STATUS,
				   IS_REPAIR_PLN,
			        CIC_GROUP_GP,
			        PIC_GROUP_GP,
			        SIC_GROUP_GP,
			        DIC_GROUP_GP,
			        WIC_GROUP_GP,
			        GIC_GROUP_GP,
			        CIC_GP,
			        PIC_GP,
			        SIC_GP,
			        DIC_GP,
			        WIC_GP,
			        GIC_GP,
			        PROCESS_CODE_C,
				    PROCESS_DESC_C,MSC,INDEX_SEQ,BOM,WHOLE_BACKLOG_DESC,OUTDIAMETER_ZG,
				    WALLTHICK_ZG,IF_LEN_CONTROL,IF_MINUS_SIC_ROLL,TUBE_END_RATIO,GPREQ_NUM,GPREQ_WEIGHT,VERIFY1,
				    VERIFY2,VERIFY3,WEIGTH_S_MIN,PLANS_NUM,PROD_STANDARD,OUTPUT_STANDARD,DECISION,THICKNESS_WALL,
				    IS_PLAN_OK,OUTS_BILLET_FL,PLINE_CODE_ZZ,PLINE_NAME_ZZ,APPLY_NO,APPLY_STATUS,ISSUED_MEMO,
				    GRADECODE_LK,GRADENAME_LK,CIC_GROUP_LK,GPREQ_WEIGHT_MIN)
				  SELECT '#VERSION_NO#',T.PRO_ORDER_NO,
				         T.PRO_PLAN_ID,
				         '1',
				         T.PLAN_GROUP_ID,
				         T.ORDER_SOURCE,
				         T.ORD_LN_DLY_PK,
				         T.PLN_DIVIDE_ID,
				         T.ORDER_NO,
				         T.ORDER_SEQ,
				         T.DELIVERY_NO,
				         T.REQ_BL_ID,
				         '#PLINE_CODE#',
				         '#PLINE_NAME#',
				         T.STEELCODE,
				         T.STEELNAME,
				         T.GRADECODE,
				         T.GRADENAME,
				         T1.OUTDIAMETER,
				         T1.WALLTHICK,
				         COALESCE(l.len_desc, T1.LENGTHDISC) AS LENGTHDISC,
				         T.INWL_GP,
				         T.INWL_DESC,
				         T.OUTWL_ID,
				         T.OUTWL_DESC,
				         COALESCE(l.len_max, T.LENGTHMAX) AS LENGTHMAX,
       				     COALESCE(l.len_min, T.LENGTHMIN) AS LENGTHMIN,
				         '#AIMOUTDIAMETER#',
				         T.AIMWALLTHICK,
				         T.AIMLENGTH,
				         DECODE('#PLINE_CODE#','C072',
				         	DECODE('#PASS_NAME#','383','380','454','450',T.DIAMETER_GP),
				         	T.DIAMETER_GP),
				         T.LENGTH_GP,
				         T.ROLL_LENGTH,
				         '#LEN_CUTHEAD#',
				         '#LEN_CUTEND#',
				         T.OUTNUM_SINGLE,
				         '#DIAMETER_MANDREL#',
				         '#PASS_CODE#',
				         '#PASS_NAME#',
				         '#IN_WEIGHT_S#',
				         '#IN_NUM_S#',
				         T.PLAN_WT,
				         T.PLAN_NUM,
				         '#ADD_WT_IN#',
				         '#ADD_NUM_IN#',
				         '#ISENDGX#',
				         T.IF_MONITOR_ZG,
				         T.PRDCR_NO,
				         T.MONITOR_POINT,
				         T.CRAFT_FILE_NO,
				         T.CRAFT_FILE_MAN,
				         T.CRAFT_SEQ,
				         '#STATION_ROAD#',
				         T.PRO_MONTH,
				         '#CIC#',
				         '#PIC#',
				         '#SIC#',
				         '#DIC#',
				         '#WIC#',
				         '#GIC#',
				         '#GX_PRO_SEQ#',
				         ?,
				         TO_DATE('#PLAN_TIME_B#','YYYY-MM-DD HH24:MI:SS'),
				         TO_DATE('#PLAN_TIME_E#','YYYY-MM-DD HH24:MI:SS'),		       
				         '0',
				         '0',
				        '#CIC_GROUP_GP#',
				        '#PIC_GROUP_GP#',
				        '#SIC_GROUP_GP#',
				        '#DIC_GROUP_GP#',
				        '#WIC_GROUP_GP#',
				        '#GIC_GROUP_GP#',
				        '#CIC_GP#',
				        '#PIC_GP#',
				        '#SIC_GP#',
				        '#DIC_GP#',
				        '#WIC_GP#',
				        '#GIC_GP#',
				        (select MAX(PROCESS_CODE_C) from PLN_ORDER_ZG where PLAN_GROUP_ID=T.PLAN_GROUP_ID),
				        (select MAX(PROCESS_DESC_C) from PLN_ORDER_ZG where PLAN_GROUP_ID=T.PLAN_GROUP_ID),
				        '#MSC#','#INDEX_SEQ#','#BOM#','#WHOLE_BACKLOG_DESC#','#OUTDIAMETER_ZG#','#WALLTHICK_ZG#',
				        '#IF_LEN_CONTROL#','#IF_MINUS_SIC_ROLL#','#TUBE_END_RATIO#','#GPREQ_NUM#','#GPREQ_WEIGHT#'
				        ,'#VERIFY1#',
				        '#VERIFY2#','#VERIFY3#','#WEIGTH_S_MIN#','#PLANS_NUM#','#PROD_STANDARD#','#OUTPUT_STANDARD#',
				        '#DECISION#','#THICKNESS_WALL#'	,'0','#OUTS_BILLET_FL#',?,?,?,?,?,'#GRADECODE_LK#','#GRADENAME_LK#'
				        ,'#CIC_GROUP_LK#','#GPREQ_WEIGHT_MIN#'    
				    FROM PLN_GX_ZG_M T
				    LEFT JOIN PLN_SALEORD T1
				      ON T1.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK
				    LEFT JOIN slm_order_head h 
					  ON h.validflag = '1'
					  AND h.order_no = 'MG' || T.order_no
					LEFT JOIN slm_order_line l 
					  ON l.validflag = '1'
					  AND l.order_seq = T.order_seq
					  AND l.ord_pk = h.ord_pk
				   WHERE T.PRO_PLAN_ID = '#PRO_PLAN_ID#'
		]]>
	</query>

	<query id="CorePlnOrdProUseTime.deleteOrderCastS" desc="删除铸造工序排产">
		<![CDATA[
			DELETE FROM PLN_ORDER_CAST_S T WHERE T.PRO_PLAN_ID = ? AND T.GX_PLAN_NO = ?
		]]>
	</query>

	<query id="CorePlnOrdProUseTime.deleteOrderDzS" desc="删除铸造工序排产">
		<![CDATA[
			DELETE FROM PLN_ORDER_DZ_S T WHERE T.PRO_PLAN_ID = ? AND T.GX_PLAN_NO = ?
		]]>
	</query>

	<query id="CorePlnOrdProUseTime.deleteOrderZgS" desc="删除轧管耗时工序">
		<![CDATA[
			DELETE FROM PLN_ORDER_ZG_S T WHERE T.PRO_PLAN_ID = ? AND T.GX_PLAN_NO = ?
		]]>
	</query>
	<query id="CorePlnOrdProUseTime.deleteOrderDbkS" desc="删除镦拔扩耗时工序">
		<![CDATA[
			DELETE FROM PLN_ORDER_DBK_S T WHERE T.PRO_PLAN_ID = ? AND T.GX_PLAN_NO = ?
		]]>
	</query>
	<query id="CorePlnOrdProUseTime.deleteOrderRclS" desc="删除热处理耗时工序">
		<![CDATA[
			DELETE FROM PLN_ORDER_RCL_S T WHERE T.PRO_PLAN_ID = ? AND T.GX_PLAN_NO = ?
		]]>
	</query>
	<query id="CorePlnOrdProUseTime.deleteOrderJgxS" desc="删除管加工耗时工序">
		<![CDATA[
			DELETE FROM PLN_ORDER_JGX_S T WHERE T.PRO_PLAN_ID = ? AND T.GX_PLAN_NO = ?
		]]>
	</query>



	<query id="CorePlnOrdProUseTime.selectPlnGxZgM" desc="查询加工订单">
		<![CDATA[
			SELECT T.PLAN_WT, T.PLAN_NUM FROM PLN_GX_ZG_M T WHERE T.PRO_PLAN_ID = ?
		]]>
	</query>
	<query id="CorePlnOrdProUseTime.selectPlnGxDbkM" desc="查询加工订单">
		<![CDATA[
			SELECT T.PLANWEIGHT, T.PLANNUM FROM PLN_GX_DBK_M T WHERE T.PRO_PLAN_ID = ?
		]]>
	</query>
	<query id="CorePlnOrdProUseTime.selectPlnGxRclM" desc="查询加工订单">
		<![CDATA[
			SELECT T.PLANWEIGHT, T.PLANNUM FROM PLN_GX_RCL_M T WHERE T.PRO_PLAN_ID = ?
		]]>
	</query>
	<query id="CorePlnOrdProUseTime.selectPlnGxJgxM" desc="查询加工订单">
		<![CDATA[
			SELECT T.PLANWEIGHT, T.PLANNUM FROM PLN_GX_JGX_M T WHERE T.PRO_PLAN_ID = ?
		]]>
	</query>


	<query id="CorePlnOrdProUseTime.updateOrderZgS" desc="更新轧管耗时工序">
		<![CDATA[
			UPDATE PLN_ORDER_ZG_S T
			   SET T.WEIGTH_S    = NVL(T.WEIGTH_S, 0) * (1 + '#RATE#'),
			       T.NUM_S       = NVL(T.NUM_S, 0) * (1 + '#RATE#'),
			       T.ADD_WT_IN   = NVL(T.ADD_WT_IN, 0) * (1 + '#RATE#'),
			       T.ADD_NUM_IN  = NVL(T.ADD_NUM_IN, 0) * (1 + '#RATE#'),
			       T.IN_WEIGHT_S = NVL(T.IN_WEIGHT_S, 0) * (1 + '#RATE#'),
			       T.IN_NUM_S    = NVL(T.IN_NUM_S, 0) * (1 + '#RATE#')
			 WHERE T.PRO_PLAN_ID = ?
		]]>
	</query>
	<query id="CorePlnOrdProUseTime.updateOrderDbkS" desc="更新镦拔扩耗时工序">
		<![CDATA[
			UPDATE PLN_ORDER_DBK_S T
			   SET T.WEIGTH_S    = NVL(T.WEIGTH_S, 0) * (1 + '#RATE#'),
			       T.NUM_S       = NVL(T.NUM_S, 0) * (1 + '#RATE#'),
			       T.ADD_WT_IN   = NVL(T.ADD_WT_IN, 0) * (1 + '#RATE#'),
			       T.ADD_NUM_IN  = NVL(T.ADD_NUM_IN, 0) * (1 + '#RATE#'),
			       T.IN_WEIGHT_S = NVL(T.IN_WEIGHT_S, 0) * (1 + '#RATE#'),
			       T.IN_NUM_S    = NVL(T.IN_NUM_S, 0) * (1 + '#RATE#')
			 WHERE T.PRO_PLAN_ID = ?
		]]>
	</query>
	<query id="CorePlnOrdProUseTime.updateOrderRclS" desc="更新热处理耗时工序">
		<![CDATA[
			UPDATE PLN_ORDER_RCL_S T
			   SET T.WEIGTH_S    = NVL(T.WEIGTH_S, 0) * (1 + '#RATE#'),
			       T.NUM_S       = NVL(T.NUM_S, 0) * (1 + '#RATE#'),
			       T.ADD_WT_IN   = NVL(T.ADD_WT_IN, 0) * (1 + '#RATE#'),
			       T.ADD_NUM_IN  = NVL(T.ADD_NUM_IN, 0) * (1 + '#RATE#'),
			       T.IN_WEIGHT_S = NVL(T.IN_WEIGHT_S, 0) * (1 + '#RATE#'),
			       T.IN_NUM_S    = NVL(T.IN_NUM_S, 0) * (1 + '#RATE#')
			 WHERE T.PRO_PLAN_ID = ?
		]]>
	</query>
	<query id="CorePlnOrdProUseTime.updateOrderJgxS" desc="更新管加工耗时工序">
		<![CDATA[
			UPDATE PLN_ORDER_JGX_S T
			   SET T.WEIGTH_S    = NVL(T.WEIGTH_S, 0) * (1 + '#RATE#'),
			       T.NUM_S       = NVL(T.NUM_S, 0) * (1 + '#RATE#'),
			       T.ADD_WT_IN   = NVL(T.ADD_WT_IN, 0) * (1 + '#RATE#'),
			       T.ADD_NUM_IN  = NVL(T.ADD_NUM_IN, 0) * (1 + '#RATE#'),
			       T.IN_WEIGHT_S = NVL(T.IN_WEIGHT_S, 0) * (1 + '#RATE#'),
			       T.IN_NUM_S    = NVL(T.IN_NUM_S, 0) * (1 + '#RATE#')
			 WHERE T.PRO_PLAN_ID = ?
		]]>
	</query>


	<query id="CorePlnOrdProUseTime.selectOrderCastS" desc="查询轧管耗时工序">
		<![CDATA[
			SELECT TO_NUMBER(T.GX_PRO_SEQ) GX_PRO_SEQ,
			       T.PLINE_CODE,
			       T.PLINE_NAME,
			       TO_CHAR(T.PLAN_TIME_B, 'YYYY-MM-DD HH24:MI:SS') PLAN_TIME_B,
			       TO_CHAR(T.PLAN_TIME_E,'YYYY-MM-DD HH24:MI:SS') PLAN_TIME_E,
			       T.GX_PLAN_NO
			  FROM PLN_ORDER_CAST_S T
			 WHERE T.PRO_PLAN_ID = ?
		]]>
	</query>

	<query id="CorePlnOrdProUseTime.selectOrderDzS" desc="查询轧管耗时工序">
		<![CDATA[
			SELECT TO_NUMBER(T.GX_PRO_SEQ) GX_PRO_SEQ,
			       T.PLINE_CODE,
			       T.PLINE_NAME,
			       TO_CHAR(T.PLAN_TIME_B, 'YYYY-MM-DD HH24:MI:SS') PLAN_TIME_B,
			       TO_CHAR(T.PLAN_TIME_E,'YYYY-MM-DD HH24:MI:SS') PLAN_TIME_E,
			       T.GX_PLAN_NO
			  FROM PLN_ORDER_DZ_S T
			 WHERE T.PRO_PLAN_ID = ?
		]]>
	</query>

	<query id="CorePlnOrdProUseTime.selectOrderZgS" desc="查询轧管耗时工序">
		<![CDATA[
			SELECT TO_NUMBER(T.GX_PRO_SEQ) GX_PRO_SEQ,
			       T.PLINE_CODE,
			       T.PLINE_NAME,
			       TO_CHAR(T.PLAN_TIME_B,'YYYY-MM-DD HH24:MI:SS') PLAN_TIME_B,
			        TO_CHAR(T.PLAN_TIME_E,'YYYY-MM-DD HH24:MI:SS') PLAN_TIME_E,
			       T.GX_PLAN_NO
			  FROM PLN_ORDER_ZG_S T
			 WHERE T.PRO_PLAN_ID = ?
		]]>
	</query>
	<query id="CorePlnOrdProUseTime.selectOrderDbkS" desc="查询镦拔扩耗时工序">
		<![CDATA[
			 SELECT TO_NUMBER(T.GX_PRO_SEQ) GX_PRO_SEQ,
			       T.PLINE_CODE,
			       T.PLINE_NAME,
			       TO_CHAR(T.PLAN_TIME_B,'YYYY-MM-DD HH24:MI:SS') PLAN_TIME_B,
			       TO_CHAR(T.PLAN_TIME_E,'YYYY-MM-DD HH24:MI:SS') PLAN_TIME_E,
			       T.GX_PLAN_NO
			  FROM PLN_ORDER_DBK_S T
			 WHERE T.PRO_PLAN_ID = ?
		]]>
	</query>
	<query id="CorePlnOrdProUseTime.selectOrderRclS" desc="查询热处理耗时工序">
		<![CDATA[
			 SELECT TO_NUMBER(T.GX_PRO_SEQ) GX_PRO_SEQ,
			       T.PLINE_CODE,
			       T.PLINE_NAME,
			       TO_CHAR(T.PLAN_TIME_B,'YYYY-MM-DD HH24:MI:SS') PLAN_TIME_B,
			       TO_CHAR(T.PLAN_TIME_E,'YYYY-MM-DD HH24:MI:SS') PLAN_TIME_E,
			       T.GX_PLAN_NO
			  FROM PLN_ORDER_RCL_S T
			 WHERE T.PRO_PLAN_ID = ?
		]]>
	</query>
	<query id="CorePlnOrdProUseTime.selectOrderJgxS" desc="查询管加工耗时工序">
		<![CDATA[
			 SELECT TO_NUMBER(T.GX_PRO_SEQ) GX_PRO_SEQ,
			       T.PLINE_CODE,
			       T.PLINE_NAME,
			       TO_CHAR(T.PLAN_TIME_B,'YYYY-MM-DD HH24:MI:SS') PLAN_TIME_B,
			       TO_CHAR(T.PLAN_TIME_E,'YYYY-MM-DD HH24:MI:SS') PLAN_TIME_E,
			       T.GX_PLAN_NO
			  FROM PLN_ORDER_JGX_S T
			 WHERE T.PRO_PLAN_ID = ?
		]]>
	</query>


	<query id="CorePlnOrdProUseTime.getPlnGxJgxM" desc="查询管加工耗时工序">
		<![CDATA[
			SELECT T1.IF_EXPORT,
			       C.ABRVITION,
			       (SELECT B.PLINE_NAME
			          FROM COM_BASE_PLINE B
			         WHERE B.PLINE_CODE = T1.GROUP_ROLL) D_PLINE_NAME,
			       (SELECT MAX(TO_NUMBER(L.PRDCR_ADVC_DAY))
			          FROM SLM_ORDER_LINE_PRDCR P, SLM_ORDER_LINE_PRDCR_LST L
			         WHERE L.PRDCR_NO = P.PRDCR_NO
			           AND L.PRDCR_INDEX = P.PRDCR_INDEX
			           AND P.CODE_JG IS NULL
			           AND P.CODE_BL IS NULL
			           AND L.PROCESS_CODE = 'G'
			           AND P.PRDCR_NO = T.PRDCR_NO
			           AND P.MSC_PLINE = T1.INDEX_SEQ) PRDCR_ADVC_DAY,
       			   TO_CHAR(T2.DELVRY_EDATE, 'YYYY-MM-DD') DELVRY_EDATE,
			       T2.STATION_NM,
			       T1.PRIORITY,
			       T1.PRIORITY_MEMO
			  FROM PLN_GX_JGX_M T
			  LEFT JOIN PLN_SALEORD_PROC T1
			    ON T1.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK
			   AND T1.PLN_DIVIDE_ID = T.PLN_DIVIDE_ID
			  LEFT JOIN PLN_SALEORD T2
			    ON T2.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK
			  LEFT JOIN SLM_BASE_CUSTOMER C
			    ON C.CUSTOMER_NO = NVL(T2.FINAL_USER, T2.BUYER_ID)
			 WHERE T.PRO_PLAN_ID = ?
		]]>
	</query>
	<query id="CorePlnOrdProUseTime.getPlnGxRclM" desc="查询管热处理耗时工序">
		<![CDATA[
			SELECT T1.IF_EXPORT,
			       C.ABRVITION,
			       (SELECT B.PLINE_NAME
			          FROM COM_BASE_PLINE B
			         WHERE B.PLINE_CODE = T1.GROUP_ROLL) D_PLINE_NAME,
			       (SELECT MAX(TO_NUMBER(L.PRDCR_ADVC_DAY))
			          FROM SLM_ORDER_LINE_PRDCR P, SLM_ORDER_LINE_PRDCR_LST L
               WHERE L.PRDCR_NO = P.PRDCR_NO
                 AND L.PRDCR_INDEX = P.PRDCR_INDEX
                 AND P.CODE_JG IS NULL
                 AND P.CODE_BL IS NULL
                 AND L.PROCESS_CODE = 'F'
                 AND P.PRDCR_NO = T.PRDCR_NO
                 AND P.MSC_PLINE = T1.INDEX_SEQ) PRDCR_ADVC_DAY,
                TO_CHAR(T2.DELVRY_EDATE, 'YYYY-MM-DD') DELVRY_EDATE,
             T2.STATION_NM,
             T1.PRIORITY,
             T1.PRIORITY_MEMO
        FROM PLN_GX_RCL_M T
        LEFT JOIN PLN_SALEORD_PROC T1
          ON T1.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK
         AND T1.PLN_DIVIDE_ID = T.PLN_DIVIDE_ID
        LEFT JOIN PLN_SALEORD T2
          ON T2.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK
        LEFT JOIN SLM_BASE_CUSTOMER C
          ON C.CUSTOMER_NO = NVL(T2.FINAL_USER, T2.BUYER_ID)
       WHERE T.PRO_PLAN_ID = ?
		]]>
	</query>
<query id="CorePlnOrdProUseTime.getPlnGxDbkM" desc="查询管镦拔扩耗时工序">
		<![CDATA[
			SELECT T1.IF_EXPORT,
             C.ABRVITION,
             (SELECT B.PLINE_NAME
                FROM COM_BASE_PLINE B
               WHERE B.PLINE_CODE = T1.GROUP_ROLL) D_PLINE_NAME,
             (SELECT MAX(TO_NUMBER(L.PRDCR_ADVC_DAY))
                FROM SLM_ORDER_LINE_PRDCR P, SLM_ORDER_LINE_PRDCR_LST L
               WHERE L.PRDCR_NO = P.PRDCR_NO
                 AND L.PRDCR_INDEX = P.PRDCR_INDEX
                 AND P.CODE_JG IS NULL
                 AND P.CODE_BL IS NULL
                 AND L.PROCESS_CODE = 'E'
                 AND P.PRDCR_NO = T.PRDCR_NO
                 AND P.MSC_PLINE = T1.INDEX_SEQ) PRDCR_ADVC_DAY,
                TO_CHAR(T2.DELVRY_EDATE, 'YYYY-MM-DD') DELVRY_EDATE,
             T2.STATION_NM,
             T1.PRIORITY,
             T1.PRIORITY_MEMO
        FROM PLN_GX_DBK_M T
        LEFT JOIN PLN_SALEORD_PROC T1
          ON T1.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK
         AND T1.PLN_DIVIDE_ID = T.PLN_DIVIDE_ID
        LEFT JOIN PLN_SALEORD T2
          ON T2.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK
        LEFT JOIN SLM_BASE_CUSTOMER C
          ON C.CUSTOMER_NO = NVL(T2.FINAL_USER, T2.BUYER_ID)
       WHERE T.PRO_PLAN_ID = ?
		]]>
	</query>
	<query id="CorePlnOrdProUseTime.getPlnGxJgxMPl" desc="查询管加工耗时工序制程">
		<![CDATA[
			SELECT M1.WHOLE_BACKLOG_DESC, M1.PROCESS_CODE, M1.PROCESS_DESC_C
			  FROM PLN_GX_JGX_M T
			  LEFT JOIN PLN_SALEORD_PROC T1
			    ON T1.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK
			   AND T1.PLN_DIVIDE_ID = T.PLN_DIVIDE_ID
			  LEFT JOIN PLN_SALEORD T2
			    ON T2.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK
			  LEFT JOIN CRAFT_ORD_DESIGN M
			    ON M.ORD_LN_PK = T2.ORD_LN_PK
			   AND M.CRAFT_SEQ = T.CRAFT_SEQ
			  LEFT JOIN CRAFT_ORD_DESIGN_MSC_PL_PRC M1
			    ON M1.DESGIN_KEY = M.DESGIN_KEY
			   AND M1.MSC_PLINE = T1.INDEX_SEQ
			 WHERE T.PRO_PLAN_ID = ?
		]]>
	</query>

	<query id="CorePlnOrdProUseTime.getPlineCodeB" desc="查询铸造产线">
		<![CDATA[
		SELECT T.PLINE_CODE, T.PLINE_NAME FROM PLN_GX_CAST_M T WHERE T.PRO_PLAN_ID=?
		]]>
	</query>

	<query id="CorePlnOrdProUseTime.getPlineCodeC" desc="查询锻造产线">
		<![CDATA[
		SELECT T.PLINE_CODE,T.PLINE_NAME FROM PLN_GX_DP_M T WHERE T.PRO_PLAN_ID=?
		]]>
	</query>

	<query id="CorePlnOrdProUseTime.getPlineCodeD" desc="查询轧管产线">
		<![CDATA[
		SELECT T.PLINE_CODE,T.PLINE_NAME FROM PLN_GX_ZG_M T WHERE T.PRO_PLAN_ID=?
		]]>
	</query>

	<query id="CorePlnOrdProUseTime.getPlineCodeE" desc="查询镦拔扩产线">
		<![CDATA[
		SELECT T.PLINE_CODE,T.PLINE_NAME FROM PLN_GX_DBK_M T WHERE T.PRO_PLAN_ID=?
		]]>
	</query>

	<query id="CorePlnOrdProUseTime.getPlineCodeF" desc="查询热处理产线">
		<![CDATA[
		SELECT T.PLINE_CODE,T.PLINE_NAME FROM PLN_GX_RCL_M T WHERE T.PRO_PLAN_ID=?
		]]>
	</query>

	<query id="CorePlnOrdProUseTime.getPlineCodeG" desc="查询加工线产线">
		<![CDATA[
		SELECT T.PLINE_CODE,T.PLINE_NAME FROM PLN_GX_JGX_M T WHERE T.PRO_PLAN_ID=?
		]]>
	</query>

	<query id="CorePlnOrdProUseTime.getPlanOrderF" desc="查询热处理排产">
             <![CDATA[
             SELECT T.PRO_ORDER_NO,
       T.PRO_PLAN_ID,
       T.GX_PLAN_NO,
       T.PLAN_GROUP_ID,
       T.ORDER_SOURCE,
       T.ORD_LN_DLY_PK,
       T.PLN_DIVIDE_ID,
       T.ORDER_NO,
       T.ORDER_SEQ,
       T.DELIVERY_NO,
       T.REQ_BL_ID,
       T.PLINE_CODE,
       T.PLINE_NAME,
       T.INWL_ID,
       T.INWL_DESC,
       T.OUTWL_ID,
       T.OUTWL_DESC,
       T.GRADECODE,
       T.GRADENAME,
       T.OUTDIAMETER,
       T.WALLTHICK,
       T.LENGTHDISC,
       T.LENGTHMAX_IN,
       T.LENGTHMIN_IN,
       T.LENGTH_IN,
       T.AIMLENGTH,
       T.IN_WEIGHT_S,
       T.IN_NUM_S,
       T.WEIGTH_S,
       T.NUM_S,
       T.MATCH_WT_IN,
       T.MATCH_NUM_IN,
       T.IF_MONITOR_RCL,
       T.PRDCR_NO,
       T.MONITOR_POINT,
       T.CRAFT_FILE_NO,
       T.CRAFT_FILE_MAN,
       T.CRAFT_SEQ,
       T.STATION_ROAD,
       T.GX_PRO_SEQ,
       T.PLAN_USETIME,
       TO_CHAR(T.PLAN_TIME_B, 'YYYY-MM-DD HH24:MI:SS') PLAN_TIME_B,
       TO_CHAR(T.PLAN_TIME_E, 'YYYY-MM-DD HH24:MI:SS') PLAN_TIME_E,
       T.BATCHED_WT,
       T.BATCHED_NUM,
       T.FINISHWEIGHT,
       T.FINISHNUM,
       T.EXE_STATUS,
       T.IS_REPAIR_PLN,
       T.REPAIR_TYPE,
       T.ZY_BATCH_ID,
       T.ADD_WT_IN,
       T.ADD_NUM_IN,
       T.ISENDGX,
       T.CIC,
       T.PIC,
       T.SIC,
       T.DIC,
       T.WIC,
       T.GIC,
       T.IS_PLAN_OK,
       T.STEELCODE,
       T.STEELNAME,
       T.PRO_MONTH,
       T.PREVIOUS_GX,
       T.PREV_GXPLAN_ID,
       T.IF_EXPORT,
       TO_CHAR(T.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       T.MEMO,
       TO_CHAR(T.ISSUED_TIME, 'YYYY-MM-DD HH24:MI:SS') ISSUED_TIME,
       T.ISSUED_MAN,
       TO_CHAR(T.LAST_UNDOWN_TIME, 'YYYY-MM-DD HH24:MI:SS') LAST_UNDOWN_TIME,
       T.LAST_UNDOWN_MAN,
       T.VERSION_NO,
       T.PROCESSING_COST,
       T.TOTAL_COST,T.PRDCR_ADVC_DAY,T.DECISION
  FROM PLN_ORDER_RCL_S T
 WHERE 1=1
               ]]>
	</query>
	<query id="CorePlnOrdProUseTime.getPlanOrderG" desc="查询加工排产">
             <![CDATA[
             SELECT T.PRO_ORDER_NO,
       T.PRO_PLAN_ID,
       T.GX_PLAN_NO,
       T.PLAN_GROUP_ID,
       T.ORDER_SOURCE,
       T.ORD_LN_DLY_PK,
       T.PLN_DIVIDE_ID,
       T.ORDER_NO,
       T.ORDER_SEQ,
       T.DELIVERY_NO,
       T.REQ_BL_ID,
       T.PLINE_CODE,
       T.PLINE_NAME,
       T.INWL_ID,
       T.INWL_DESC,
       T.OUTWL_ID,
       T.OUTWL_DESC,
       T.WEIGTH_S,
       T.NUM_S,
       T.GX_PRO_SEQ,
       T.PLAN_USETIME,
       TO_CHAR(T.PLAN_TIME_B, 'YYYY-MM-DD HH24:MI:SS') PLAN_TIME_B,
       TO_CHAR(T.PLAN_TIME_E, 'YYYY-MM-DD HH24:MI:SS') PLAN_TIME_E,
       T.EXE_STATUS,
       T.IS_REPAIR_PLN,
       T.REPAIR_TYPE,
       T.STEELCODE,
       T.STEELNAME,
       T.OUTDIAMETER,
       T.WALLTHICK,
       T.LENGTHMAX,
       T.LENGTHMIN,
       T.LENGTHDISC,
       T.AIMWALLTHICK,
       T.AIMLENGTH,
       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.MODEL_CODE,
       T.MODEL_DESC,
       T.LENGTHMAX_IN,
       T.LENGTHMIN_IN,
       T.LENGTH_IN,
       T.OUTNUM_CUT,
       T.IN_WEIGHT_S,
       T.IN_NUM_S,
       T.ADD_WT_IN,
       T.ADD_NUM_IN,
       T.MATCH_WT_IN,
       T.MATCH_NUM_IN,
       T.IF_MONITOR_JGX,
       T.PRDCR_NO,
       T.MONITOR_POINT,
       T.CIC,
       T.PIC,
       T.SIC,
       T.DIC,
       T.WIC,
       T.GIC,
       T.CRAFT_FILE_NO,
       T.CRAFT_FILE_MAN,
       T.CRAFT_SEQ,
       T.STATION_ROAD,
       T.BATCHED_WT,
       T.BATCHED_NUM,
       T.FINISHWEIGHT,
       T.FINISHNUM,
       T.IS_PLAN_OK,
       T.ZY_BATCH_ID,
       T.PRO_MONTH,
       T.PREVIOUS_GX,
       T.PREV_GXPLAN_ID,
       T.IF_EXPORT,
       T.FINAL_USER_DESC,
       T.PROCESS_DESC_C_ZG,
       T.GROUP_ROLL_NAME,
       TO_CHAR(T.BEGIN_TIME_ZG, 'YYYY-MM-DD HH24:MI:SS') BEGIN_TIME_ZG,
       T.PRDCR_ADVC_DAY,
       T.WHOLE_BACKLOG_DESC,
       T.PRIORITY,
       T.PRIORITY_MEMO,
       TO_CHAR(T.DELVRY_EDATE, 'YYYY-MM-DD') DELVRY_EDATE,
       T.STATION_NM,
       T.OUTLINE_SITE_250,
       TO_CHAR(T.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       T.MEMO,
       TO_CHAR(T.ISSUED_TIME, 'YYYY-MM-DD HH24:MI:SS') ISSUED_TIME,
       T.ISSUED_MAN,
       TO_CHAR(T.LAST_UNDOWN_TIME, 'YYYY-MM-DD HH24:MI:SS') LAST_UNDOWN_TIME,
       T.LAST_UNDOWN_MAN,
       T.VERSION_NO,
       T.PROCESSING_COST,
       T.TOTAL_COST 
  FROM PLN_ORDER_JGX_S T
 WHERE  1=1
               ]]>
	</query>
	<query id="CorePlnOrdProUseTime.getPlanOrderE" desc="查询镦拔扩排产">
             <![CDATA[
  
SELECT T.PRO_ORDER_NO,
       T.PRO_PLAN_ID,
       T.GX_PLAN_NO,
       T.PLAN_GROUP_ID,
       T.ORDER_SOURCE,
       T.ORD_LN_DLY_PK,
       T.PLN_DIVIDE_ID,
       T.ORDER_NO,
       T.ORDER_SEQ,
       T.DELIVERY_NO,
       T.REQ_BL_ID,
       T.PLINE_CODE,
       T.PLINE_NAME,
       T.INWL_ID,
       T.INWL_DESC,
       T.OUTWL_ID,
       T.OUTWL_DESC,
       T.WEIGTH_S,
       T.NUM_S,
       T.GX_PRO_SEQ,
       T.PLAN_USETIME,
       TO_CHAR(T.PLAN_TIME_B, 'YYYY-MM-DD HH24:MI:SS') PLAN_TIME_B,
       TO_CHAR(T.PLAN_TIME_E, 'YYYY-MM-DD HH24:MI:SS') PLAN_TIME_E,
       T.EXE_STATUS,
       T.IS_REPAIR_PLN,
       T.REPAIR_TYPE,
       T.OUTDIAMETER,
       T.WALLTHICK,
       T.LENGTHDISC,
       T.AIMOUTDIAMETER,
       T.AIMWALLTHICK,
       T.AIMLENGTH,
       T.OUTDIAMETER_IN,
       T.WALLTHICK_IN,
       T.LENGTH_IN,
       T.LEN_CUTHEAD,
       T.LEN_CUTEND,
       T.LENGTHMAX_IN,
       T.LENGTHMIN_IN,
       T.IN_WEIGHT_S,
       T.IN_NUM_S,
       T.ADD_WT_IN,
       T.ADD_NUM_IN,
       T.MATCH_WT_IN,
       T.MATCH_NUM_IN,
       T.ISENDGX,
       T.IF_MONITOR_DBK,
       T.PRDCR_NO,
       T.MONITOR_POINT,
       T.CIC,
       T.PIC,
       T.SIC,
       T.DIC,
       T.WIC,
       T.GIC,
       T.CRAFT_FILE_NO,
       T.CRAFT_FILE_MAN,
       T.CRAFT_SEQ,
       T.STATION_ROAD,
       T.BATCHED_WT,
       T.BATCHED_NUM,
       T.FINISHWEIGHT,
       T.FINISHNUM,
       T.IS_PLAN_OK,
       T.ZY_BATCH_ID,
       T.GRADECODE,
       T.GRADENAME,
       T.PRO_MONTH,
       T.PREVIOUS_GX,
       T.PREV_GXPLAN_ID,
       T.IF_EXPORT,
       TO_CHAR(T.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       T.MEMO,
       TO_CHAR(T.ISSUED_TIME, 'YYYY-MM-DD HH24:MI:SS') ISSUED_TIME,
       T.ISSUED_MAN,
       TO_CHAR(T.LAST_UNDOWN_TIME, 'YYYY-MM-DD HH24:MI:SS') LAST_UNDOWN_TIME,
       T.LAST_UNDOWN_MAN,
       T.VERSION_NO,
       T.PROCESSING_COST,
       T.TOTAL_COST,
       T.REAL_BATCH_WT,
       T.REAL_BATCH_NUM,
       T.IF_STOVE_ISSUED,
       TO_CHAR(T.STOVE_ISSUED_TIME, 'YYYY-MM-DD HH24:MI:SS') STOVE_ISSUED_TIME,
       T.STOVE_ISSUED_MAN
  FROM PLN_ORDER_DBK_S T
 WHERE 1=1
               ]]>
	</query>

	<query id="CorePlnOrdProUseTime.getPlanOrderD" desc="查询轧管排产">
             <![CDATA[
            SELECT T.PRO_ORDER_NO,
       T.PRO_PLAN_ID,
       T.GX_PLAN_NO,
       T.PLAN_GROUP_ID,
       T.ORDER_SOURCE,
       T.ORD_LN_DLY_PK,
       T.PLN_DIVIDE_ID,
       T.ORDER_NO,
       T.ORDER_SEQ,
       T.DELIVERY_NO,
       T.REQ_BL_ID,
       T.PLINE_CODE,
       T.PLINE_NAME,
       T.STEELCODE,
       T.STEELNAME,
       T.GRADECODE,
       T.GRADENAME,
       T.OUTDIAMETER,
       T.WALLTHICK,
       T.LENGTHDISC,
       T.INWL_ID,
       T.INWL_DESC,
       T.OUTWL_ID,
       T.OUTWL_DESC,
       T.LEN_ROLL_MAX,
       T.LEN_ROLL_MIN,
       T.AIMOUTDIAMETER,
       T.AIMWALLTHICK,
       T.AIMLENGTH,
       T.DIAMETER_GP,
       T.LEN_GP_SINGLE,
       T.ROLL_LENGTH,
       T.LEN_CUTHEAD,
       T.LEN_CUTEND,
       T.OUTNUM_CUT,
       T.DIAMETER_MANDREL,
       T.PASS_CODE,
       T.PASS_NAME,
       T.IN_WEIGHT_S,
       T.IN_NUM_S,
       T.WEIGTH_S,
       T.NUM_S,
       T.ADD_WT_IN,
       T.ADD_NUM_IN,
       T.MATCH_WT_IN,
       T.MATCH_NUM_IN,
       T.ISENDGX,
       T.IF_MONITOR_ZG,
       T.PRDCR_NO,
       T.MONITOR_POINT,
       T.CRAFT_FILE_NO,
       T.CRAFT_FILE_MAN,
       T.CRAFT_SEQ,
       T.STATION_ROAD,
       T.PRO_MONTH,
       T.CIC,
       T.PIC,
       T.SIC,
       T.DIC,
       T.WIC,
       T.GIC,
       T.GX_PRO_SEQ,
       T.PLAN_USETIME,
       TO_CHAR(T.PLAN_TIME_B, 'YYYY-MM-DD HH24:MI:SS') PLAN_TIME_B,
       TO_CHAR(T.PLAN_TIME_E, 'YYYY-MM-DD HH24:MI:SS') PLAN_TIME_E,
       T.BATCHED_WT,
       T.BATCHED_NUM,
       T.FINISHWEIGHT,
       T.FINISHNUM,
       T.EXE_STATUS,
       T.IS_REPAIR_PLN,
       T.REPAIR_TYPE,
       T.IS_PLAN_OK,
       T.GPREQ_IF_OK,
       T.GPREQ_ID,
       T.ZY_BATCH_ID,
       T.CIC_GROUP_GP,
       T.PIC_GROUP_GP,
       T.SIC_GROUP_GP,
       T.DIC_GROUP_GP,
       T.WIC_GROUP_GP,
       T.GIC_GROUP_GP,
       T.CIC_GP,
       T.PIC_GP,
       T.SIC_GP,
       T.DIC_GP,
       T.WIC_GP,
       T.GIC_GP,
       T.IF_EXPORT,
       TO_CHAR(T.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       T.MEMO,
       TO_CHAR(T.ISSUED_TIME, 'YYYY-MM-DD HH24:MI:SS') ISSUED_TIME,
       T.ISSUED_MAN,
       TO_CHAR(T.LAST_UNDOWN_TIME, 'YYYY-MM-DD HH24:MI:SS') LAST_UNDOWN_TIME,
       T.LAST_UNDOWN_MAN,
       T.VERSION_NO,
       T.PROCESSING_COST,
       T.TOTAL_COST,
       T.IF_STOVE_ISSUED,
       TO_CHAR(T.STOVE_ISSUED_TIME, 'YYYY-MM-DD HH24:MI:SS') STOVE_ISSUED_TIME,
       T.STOVE_ISSUED_MAN,
       T.IS_ONLOAD_LINE,
       T.OUTDIAMETER_ZG,
       T.WALLTHICK_ZG  
  FROM PLN_ORDER_ZG_S T
 WHERE 1 = 1
               ]]>
	</query>
	<query id="CorePlnOrdProUseTime.queryZgProApplyNo" desc="查询补量合同是否存在长度申请">
		<![CDATA[
		SELECT T.APPLY_NO, T.ISSUED_MEMO, T.APPLY_STATUS
  FROM PLN_ORDER_ZG_S T
 WHERE T.ORDER_NO = ?
   AND T.ORDER_SEQ = ?
   AND T.APPLY_NO IS  NOT NULL
		   ]]>
	</query>
	<query id="CorePlnOrdProUseTime.selectGpIcListlk" desc="查询利库钢种CIC">
		<![CDATA[		
SELECT LISTAGG(CIC, ',') WITHIN GROUP(ORDER BY GRADECODE) CIC
  FROM (SELECT DISTINCT C.CIC, D.GRADECODE
          FROM PLN_GX_ZG_M              T,
               PLN_ORDER_ZG             T2,
               PLN_SALEORD              T1,
               CRAFT_ORD_DESIGN         M,
               CRAFT_ORD_DESIGN_STD_CIC C,
               COM_MSC_STD_CIC          D
         WHERE T2.PRO_ORDER_NO = T.PRO_ORDER_NO
           AND T1.ORD_LN_DLY_PK = T2.ORD_LN_DLY_PK
           AND M.ORD_LN_PK = T1.ORD_LN_PK
           AND M.CRAFT_SEQ = T2.CRAFT_SEQ
           AND C.DESGIN_KEY = M.DESGIN_KEY
           AND C.MSC_PLINE = T2.INDEX_SEQ
            AND C.PROCESS_CODE IN ('A')
           AND C.CIC = D.CIC
           AND T.PRO_PLAN_ID = ?
		]]>
	</query>
<query id="CorePlnOrdProUseTime.addOrderZgSP" desc="新增轧管S">
		<![CDATA[	
		
INSERT INTO PLN_ORDER_ZG_S
  (PRO_ORDER_NO,
   PRO_PLAN_ID,
   GX_PLAN_NO,
   PLAN_GROUP_ID,
   ORDER_SOURCE,
   ORD_LN_DLY_PK,
   PLN_DIVIDE_ID,
   ORDER_NO,
   ORDER_SEQ,
   DELIVERY_NO,
   GRADECODE,
   GRADENAME,
   CIC,
   GX_PRO_SEQ,
   EXE_STATUS,
   GPREQ_IF_OK,
   GPREQ_ID,
   CIC_GROUP_GP,
   CIC_GP,
   MSC,
   INDEX_SEQ,
   CRAFT_FILE_NO,
   CRAFT_SEQ)
VALUES
  ('#PRO_ORDER_NO#',
   '#PRO_PLAN_ID#',
   '#GX_PLAN_NO#',
   '#PLAN_GROUP_ID#',
   '#ORDER_SOURCE#',
   '#ORD_LN_DLY_PK#',
   '#PLN_DIVIDE_ID#',
   '#ORDER_NO#',
   '#ORDER_SEQ#',
   '#DELIVERY_NO#',
   '#GRADECODE#',
   '#GRADENAME#',
   '#CIC#',
   '-2',
   '2',
   '1',
   '#GPREQ_ID#',
   '#CIC_GROUP_GP#',
   '#CIC_GP#',
   '#MSC#',
   '#INDEX_SEQ#',
   '#CRAFT_FILE_NO#',
   '#CRAFT_SEQ#')
		]]>
	</query>
</queryMap>