<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="">
	<query id="ComPlanFurnace.querySteOrdPln" desc="查询连铸炉次订单">
             <![CDATA[
               SELECT T.FURNACENO,
       T.SEQUENCENO,
       T.FURNACENO_SEQ,
       CASE
         WHEN T.MERGE_NO IS NULL THEN
          T.PRO_PLAN_ID
         ELSE
          T1.PRO_PLAN_ID
       END PRO_PLAN_ID,
       CASE
         WHEN T.MERGE_NO IS NULL THEN
          T.GX_PLAN_NO
         ELSE
          T1.GX_PLAN_NO
       END GX_PLAN_NO,
       T.CAST_NO,
       T.CAST_SEQ,
       T.CAST_STOVE_SEQ,
       T.CCM_SEQ,
       T.STOVE_NO,
       T.JUDGE_STOVE_NO,
       T.JUDGE_STOVE_NO_SEQ,
       T.FLAG_STOVE_NO,
       T.STATUS,
       T.CCM_STATE,
       T.CCM_PLN_TYPE,
       T.GPTYPE,
       T.CASTINGTYPE,
       T.PLINE_CODE,
       T.PLINE_NAME,
       T.CCMID,
       T.FLOWNO,
       T.EF_PLINE_CODE,
       T.EF_PLINE_NAME,
       T.WLID_IN,
       T.WLDESC_IN,
       T.MATERIAL_NO,
       T.MATERIAL_NAME,
       T.GRADECODE,
       T.GRADENAME,
       T.DIAMETER,
       CASE
         WHEN T.MERGE_NO IS NULL THEN
          T.LEN_GP_SINGLE
         ELSE
          T1.LEN_GP_SINGLE
       END LEN_GP_SINGLE,
       CASE
         WHEN T.MERGE_NO IS NULL THEN
          T.CUT_NUM_GP
         ELSE
          T1.CUT_NUM_GP
       END CUT_NUM_GP,
       T.LENGTH_M,
       CASE
         WHEN T.MERGE_NO IS NULL THEN
          T.WEIGHT_GP_ONE
         ELSE
          T1.WEIGHT_GP_ONE
       END WEIGHT_GP_ONE,
       T.WEIGHT_M,
       CASE
         WHEN T.MERGE_NO IS NULL THEN
          T.TOT_MUM_M
         ELSE
          T1.TOT_MUM_M
       END TOT_MUM_M,
       CASE
         WHEN T.MERGE_NO IS NULL THEN
          T.TOT_WEIGHT_M
         ELSE
          T1.TOT_WEIGHT_M
       END TOT_WEIGHT_M,
       T.ACT_WEIGHT_M,
       T.ACT_MUM_M,
       T.SURPLUSFLAG,
       T.SURPLUS_TYPE,
       T.IF_SURPLUS_ALLOTED,
       CASE
         WHEN T.MERGE_NO IS NULL THEN
          T.CIC
         ELSE
          T1.CIC
       END CIC,
       CASE
         WHEN T.MERGE_NO IS NULL THEN
          T.PIC
         ELSE
          T1.PIC
       END PIC,
       CASE
         WHEN T.MERGE_NO IS NULL THEN
          T.SIC
         ELSE
          T1.SIC
       END SIC,
       CASE
         WHEN T.MERGE_NO IS NULL THEN
          T.DIC
         ELSE
          T1.DIC
       END DIC,
       T.MEMO,
       T.MAKEMAN,
       TO_CHAR(T.MAKETIME, 'YYYY-MM-DD HH24:MI:SS') MAKETIME,
       T.DOWNMAN,
       TO_CHAR(T.DOWNTIME, 'YYYY-MM-DD HH24:MI:SS') DOWNTIME,
       T.CHEM_JUDGE_ID,
       T.PHY_JUDGE_ID,
       T.COLLIGATE_JUDGE_ID,
       T.EXCESS_WT,
       T.EXCESS_NUM,
       T.PRO_MONTH,
       T.ISENDGX,
       T.STATE_LK,
       CASE
         WHEN T.MERGE_NO IS NULL THEN
          T.ORDER_NO
         ELSE
          T1.ORDER_NO
       END ORDER_NO,
       CASE
         WHEN T.MERGE_NO IS NULL THEN
          T.FINAL_USER_DESC
         ELSE
          T1.FINAL_USER_DESC
       END FINAL_USER_DESC,
       CASE
         WHEN T.MERGE_NO IS NULL THEN
          T.STEELCODE
         ELSE
          T1.STEELCODE
       END STEELCODE,
       CASE
         WHEN T.MERGE_NO IS NULL THEN
          T.STEELNAME
         ELSE
          T1.STEELNAME
       END STEELNAME,
       CASE
         WHEN T.MERGE_NO IS NULL THEN
          T.PRODUCCODE
         ELSE
          T1.PRODUCCODE
       END PRODUCCODE,
       CASE
         WHEN T.MERGE_NO IS NULL THEN
          T.PRODUCNAME
         ELSE
          T1.PRODUCNAME
       END PRODUCNAME,
       T.GOWHERE_CODE,
       T.GOWHERE_NAME,
       CASE
         WHEN T.MERGE_NO IS NULL THEN
          T.IF_MONITOR_LG
         ELSE
          T1.IF_MONITOR_LG
       END IF_MONITOR_LG,
       CASE
         WHEN T.MERGE_NO IS NULL THEN
          T.PRDCR_NO
         ELSE
          T1.PRDCR_NO
       END PRDCR_NO,
       T.MERGE_NO,
       CASE
         WHEN T.MERGE_NO IS NULL THEN
          T.PDEPT_NAME
         ELSE
          T1.PDEPT_NAME
       END PDEPT_NAME,
       CASE
         WHEN T.MERGE_NO IS NULL THEN
          T.PRDCR_MAN
         ELSE
          T1.PRDCR_MAN
       END PRDCR_MAN
  FROM PLN_STEELFOR_ORD T,
       (SELECT M.PRO_PLAN_ID,
               M.GX_PLAN_NO,
               M.PDEPT_NAME,
               M.PRDCR_MAN,
               M.PRDCR_NO,
               M.IF_MONITOR_LG,
               M.PRODUCNAME,
               M.PRODUCCODE,
               M.LEN_GP_SINGLE,
               M.CUT_NUM_GP,
               M.ORDER_NO,
               M.CIC,
               M.PIC,
               M.SIC,
               M.DIC,
               M.FINAL_USER_DESC,
               M.STEELCODE,
               M.STEELNAME,
               M.FURNACENO,
               M.MERGE_NO,M.WEIGHT_GP_ONE,
               SUM(M.TOT_MUM_M) TOT_MUM_M,
               SUM(M.TOT_WEIGHT_M) TOT_WEIGHT_M   
          FROM PLN_STEELFOR_MERGE M
         GROUP BY M.PRO_PLAN_ID,
                  M.GX_PLAN_NO,
                  M.PDEPT_NAME,
                  M.PRDCR_NO,
                  M.IF_MONITOR_LG,
                  M.PRODUCNAME,
                  M.PRODUCCODE,
                  M.LEN_GP_SINGLE,
                  M.CUT_NUM_GP,
                  M.ORDER_NO,
                  M.CIC,
                  M.PIC,
                  M.SIC,
                  M.DIC,
                  M.FINAL_USER_DESC,
                  M.STEELCODE,
                  M.STEELNAME,
                  M.FURNACENO,
                  M.MERGE_NO,
                  M.PRDCR_MAN,M.WEIGHT_GP_ONE) T1
 WHERE T.MERGE_NO = T1.MERGE_NO(+)
                 ]]>
	</query>
	<query id="ComPlanFurnace.queryPlnOrderDzS" desc="通过铸造订单号PRO_PLAN_ID查询锻造订单个数">
             <![CDATA[
              SELECT 
       T.PRO_PLAN_ID,
       T.GX_PLAN_NO,
       T.PLINE_CODE,
       T.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_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.DZ_LOSE_ADD,
       T.DZ_CUT_HEAD_END,
       T.DZ_BURN_LOSE,
       T.CIC,
       T.PIC,
       T.SIC,
       T.DIC,
       T.WIC,
       T.GIC,
       T.GX_PRO_SEQ,
       T.PRO_MONTH,
       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.ZY_BATCH_ID,
       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.PROCESSING_COST,
       T.TOTAL_COST,
       T.GPREQ_ID,
       TO_CHAR(T.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       T.IF_CRAFT_LOCKED,
       T.CREATE_NAME,T.ISENDGX
 FROM PLN_ORDER_DZ_S T
 WHERE T.PRO_PLAN_ID = ?
 AND T.EXE_STATUS='0'

                      ]]>
	</query>
	<query id="ComPlanFurnace.queryPlnOrderZgS" desc="通过铸造订单号PRO_PLAN_ID查询锻造订单个数">
             <![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,
       NVL(T.ADD_WT_IN,0) ADD_WT_IN,
       NVL(T.ADD_NUM_IN,0) ADD_NUM_IN,
       NVL(T.MATCH_WT_IN,0) MATCH_WT_IN,
       NVL(T.MATCH_NUM_IN,0) 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,
       NVL(T.BATCHED_WT,0) BATCHED_WT,
       NVL(T.BATCHED_NUM,0) BATCHED_NUM,
       NVL(T.BATCHED_WT_G,0) BATCHED_WT_G,
       NVL(T.BATCHED_NUM_G,0) BATCHED_NUM_G,
       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,
       DECODE(T.IF_STOVE_ISSUED,'1','1','0') 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,
       T.PROCESS_CODE_C,
       T.PROCESS_DESC_C,
       T.MSC,
       T.INDEX_SEQ,
       T.BOM,
       T.WHOLE_BACKLOG_DESC,
       T.IF_CRAFT_LOCKED,
       T.IF_LEN_CONTROL,
       T.IF_MINUS_SIC_ROLL,
       T.AIMWALLTHICK_OLD,
       T.WEIGTH_S_OLD,
       T.NUM_S_OLD,
       T.WALL_UPDATE_USER,
       TO_CHAR(T.WALL_UPDATE_TIME, 'YYYY-MM-DD HH24:MI:SS') WALL_UPDATE_TIME,
       T.TUBE_END_RATIO,
       T.GPREQ_NUM,
       T.GPREQ_WEIGHT,
       T.VERIFY1,
       T.VERIFY2,
       T.VERIFY3,
       T.WEIGTH_S_MIN,
       T.PRIORITY,
       T.PRIORITY_MEMO,
       T.PLANS_NUM,
       T.ORIGINAL_NUMBER,
       T.PROD_STANDARD,
       T.OUTPUT_STANDARD,
       T.PIPE_LENGTH_MIN,
       T.PIPE_LENGTH_MAX,
       T.THICKNESS_WALL,
       T.DECISION,
       T.APPLY_NO,
       T.APPLY_STATUS,
       T.ISSUED_MEMO,
       T.PROGY_MEMO,
       T.OUTS_BILLET_FL,
       T.ACTUAL_WEIGHT,
       T.STATE_SINGLE,
       T.PASSIVE,
       T.TAKE_NUM,
       T.TAKE_WT,
       T.PLINE_CODE_ZZ,
       T.PLINE_NAME_ZZ,
       T.GPREQ_IF_DZ,
       T.GRADECODE_LK,
       T.GRADENAME_LK,
       T.CIC_GROUP_LK,
       T.VALIDFLAG,
       T.GPREQ_WEIGHT_MIN,
 (SELECT S1.CRAFT_PATH
          FROM CRAFT_FILE_LV2 S1
         WHERE INSTR(T1.CRAFT_FILE_LV2_D, S1.PK) > 0
           AND INSTR(S1.PLINE_CODE, T.PLINE_CODE) > 0
           AND S1.VALIDFLAG = '1'
           AND S1.PROCESS_CODE = 'D') SEC_CRAFT_FILE_NO,
       T1.PRODUCCODE,
       T1.PRODUCNAME,
       T1.STD_CODE,
       T1.STD_NAME,
       T1.STD_STYLE_DESC,
       (SELECT D.STD_STYLE FROM COM_BASE_STD_STYLE D WHERE D.STD_STYLE_DESC=T1.STD_STYLE_DESC AND D.VALIDFLAG='1')  STD_STYLE,
       T1.SPEC_CODE,
       T1.SPEC_NAME,
       T1.MODEL_DESC,
       T1.MODEL_CODE,
       T2.PROCESS_SEQ  WHOLE_BACKLOG,
       T1.SIGL_LEN,
       T1.ENDLEN_SPECSTD
  FROM PLN_ORDER_ZG_S T,
       (SELECT Q1.PRODUCCODE,
               Q1.PRODUCNAME,
               Q1.STD_CODE,
               Q1.STD_NAME,
               Q1.STD_STYLE_DESC,
               Q1.SPEC_CODE,
               Q1.SPEC_NAME,
               Q1.ORD_LN_DLY_PK,
               Q1.MODEL_DESC,
               Q1.MODEL_CODE,           
               Q2.CRAFT_FILE_LV2_D,
               Q1.SIGL_LEN,
               Q1.ENDLEN_SPECSTD
          FROM PLN_SALEORD              Q1,
               CRAFT_ORD_DESIGN         Q2,
               CRAFT_ORD_DESIGN_APPOINT Q3,
               SLM_BASE_CUSTOMER        Q4
         WHERE Q1.ORD_LN_PK = Q3.ORD_LN_PK(+)
           AND Q1.FINAL_USER = Q4.CUSTOMER_NO(+)
           AND Q1.ORD_LN_PK = Q2.ORD_LN_PK(+)
           AND Q2.VALIDFLAG(+) = '1') T1,PLN_SALEORD_PROC T2
 WHERE T.ORD_LN_DLY_PK = T1.ORD_LN_DLY_PK(+)
 AND T.ORD_LN_DLY_PK=T2.ORD_LN_DLY_PK
 AND T.PLN_DIVIDE_ID=T2.PLN_DIVIDE_ID

 ]]>
	</query>
	<query id="ComPlanFurnace.queryPlinCodeGroup" desc="查询产线去向仓库分组">
             <![CDATA[  
SELECT DECODE(T.ISENDGX,
              '1',
              (CASE
                WHEN D.TRANSIT_TYP = '110501' THEN
                 '汽运' || '  ' ||
                 (SELECT D1.DELVRY_ADDR
                    FROM SLM_ORDER_LINE_DELIVERY D1
                   WHERE D1.VALIDFLAG = '1'
                     AND INSTR(D1.DELVRY_ADDR, '客户库') > 0
                     AND D1.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK)
                WHEN D.TRANSIT_TYP = '110502' THEN
                 '铁运' || '  ' ||
                 (SELECT C.STATION_NM
                    FROM SLM_ORDER_DELIVERY_TRANSIT Y, SLM_BASE_STATION C
                   WHERE Y.VALIDFLAG = '1'
                     AND Y.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK
                     AND Y.STATION_NO = C.STATION_NO
                     AND C.VALIDFLAG = '1'
                     AND Y.INDEX_SEQ = '1')
                ELSE
                 (SELECT  MAX(M.PLINE_NAME)
                    FROM PLN_GX_JG_M M, PLN_JG_AND_BL B
                   WHERE M.PRO_PLAN_ID = B.PRO_PLAN_ID
                     AND B.REQ_BL_ID = T.ORD_LN_DLY_PK)
              END),
              (CASE WHEN T.WHOLE_BACKLOG_DESC LIKE '%镦拔扩%' THEN
                 (SELECT MAX(S3.PLINE_NAME)
                    FROM PLN_ORDER_DBK_S S3
                   WHERE S3.PREV_GXPLAN_ID= T.PRO_PLAN_ID)
               WHEN T.WHOLE_BACKLOG_DESC LIKE '%热处理%' THEN
                 (SELECT MAX(S3.PLINE_NAME)
                    FROM PLN_ORDER_RCL_S S3
                   WHERE S3.PREV_GXPLAN_ID= T.PRO_PLAN_ID)
               WHEN T.WHOLE_BACKLOG_DESC LIKE '%加工%' THEN
                 (SELECT MAX(S3.PLINE_NAME)
                    FROM PLN_ORDER_JGX_S S3
                   WHERE S3.PREV_GXPLAN_ID= T.PRO_PLAN_ID)
                ELSE
                 ''
              END)) AF_INFO

  FROM PLN_ORDER_ZG_S T,
       
       (SELECT MIN(S.NEXT_GX) NEXT_GX,
               S.PRO_PLAN_ID,
               MIN(S.PLAN_GROUP_ID) PLAN_GROUP_ID
          FROM PLN_ORDER_ZG S
         GROUP BY S.PRO_PLAN_ID) T2,
       SLM_ORDER_LINE_DELIVERY D
 WHERE T.PRO_PLAN_ID = T2.PRO_PLAN_ID(+)
   AND T.ORD_LN_DLY_PK = D.ORD_LN_DLY_PK(+)
   AND T.PLINE_CODE =?
   AND T.PRO_PLAN_ID = ?
   AND T.GX_PLAN_NO = ?
              ]]>
	</query>
	<query id="ComPlanFurnace.getMaxGxPlnSeq" desc="查询最大炉次顺序号">
             <![CDATA[
            SELECT TO_NUMBER(NVL(MAX(T.GX_PRO_SEQ),0))+1 AS GX_PRO_SEQ
                 ]]>
	</query>
	<query id="ComPlanFurnace.addPlnZyDzM" desc="新增铸造虚拟炉计划信息">
             <![CDATA[
              INSERT INTO PLN_ZY_DZ_M(
        HEAT_PLAN_NO,
        GX_PRO_SEQ,
        ZY_BATCH_ID,
        STOVE_NO,
        JUDGE_STOVE_NO,
        FLAG_STOVE_NO,
        UPPER_HEATPLAN_ID,
        PLANSTATUS,
        UPPER_PROCESS_CODE,
        NEXT_PROCESS_CODE,
        ISENDGX,
        IF_MATCH_ODD,
        IF_DO_HEAT_PLAN,
        PRO_PLAN_ID,
        CCM_PRO_PLAN_ID,
        GOWHERE_CODE,
        GOWHERE_NAME,
        PLINE_CODE,
        PLINE_NAME,
        CASTINGTYPE,
        GRADECODE,
        GRADENAME,
        STEELCODE,
        STEELNAME,
        WLID_IN,
        WLDESC_IN,
        OUTWL_ID,
        OUTWL_DESC,
        DIAMETER_IN,
        LENGTH_IN,
        WT_ONE_IN,
        LEN_GP_SINGLE,
        WT_GP_SINGLE,
        CUT_NUM_GP,
        PLN_INDOUBLE_NUM,
        PLN_INDOUBLE_WT,
        DIAMETER_OUT,
        LENGTH_OUT,
        OUT_WT_ONE,
        CUT_NUM_OUT,
        PLN_OUTDOUBLE_NUM,
        PLN_OUTDOUBLE_W,
        PRDCR_NO,
        MONITOR_POINT,
        CIC,
        PIC,
        SIC,
        DIC,
        STATION_ROAD,
        PRO_DAY,
        BAL_YEAR_MONTH,
        CREATE_NAME,
        CREATE_TIME,
        GX_PLAN_NO, CCM_GX_PLAN_NO,PLN_INSINGLE_NUM,PLN_INSINGLE_WT,PLN_OUTSINGLE_NUM,PLN_OUTSINGLE_W,LEN_GP_SINGLE_OUT)
 VALUES( 
        '#HEAT_PLAN_NO#',
        '#GX_PRO_SEQ#',
        '#ZY_BATCH_ID#',
        '#STOVE_NO#',
        '#JUDGE_STOVE_NO#',
        '#FLAG_STOVE_NO#',
        '#UPPER_HEATPLAN_ID#',
        '#PLANSTATUS#',
        '#UPPER_PROCESS_CODE#',
        '#NEXT_PROCESS_CODE#',
        '#ISENDGX#',
        '#IF_MATCH_ODD#',
        '#IF_DO_HEAT_PLAN#',
        '#PRO_PLAN_ID#',
        '#CCM_PRO_PLAN_ID#',
        '#GOWHERE_CODE#',
        '#GOWHERE_NAME#',
        '#PLINE_CODE#',
        '#PLINE_NAME#',
        '#CASTINGTYPE#',
        '#GRADECODE#',
        '#GRADENAME#',
        '#STEELCODE#',
        '#STEELNAME#',
        '#WLID_IN#',
        '#WLDESC_IN#',
        '#OUTWL_ID#',
        '#OUTWL_DESC#',
        '#DIAMETER_IN#',
        '#LENGTH_IN#',
        '#WT_ONE_IN#',
        '#LEN_GP_SINGLE#',
        '#WT_GP_SINGLE#',
        '#CUT_NUM_GP#',
        '#PLN_INDOUBLE_NUM#',
        '#PLN_INDOUBLE_WT#',
        '#DIAMETER_OUT#',
        '#LENGTH_OUT#',
        '#OUT_WT_ONE#',
        '#CUT_NUM_OUT#',
        '#PLN_OUTDOUBLE_NUM#',
        '#PLN_OUTDOUBLE_W#',
        '#PRDCR_NO#',
        '#MONITOR_POINT#',
        '#CIC#',
        '#PIC#',
        '#SIC#',
        '#DIC#',
        '#STATION_ROAD#',
        '#PRO_DAY#',
        '#BAL_YEAR_MONTH#',
        '#CREATE_NAME#',
        TO_DATE('#CREATE_TIME#','YYYY-MM-DD HH24:MI:SS'),
        '#GX_PLAN_NO#','#CCM_GX_PLAN_NO#','#PLN_INSINGLE_NUM#','#PLN_INSINGLE_WT#',
        '#PLN_OUTSINGLE_NUM#','#PLN_OUTSINGLE_W#','#LEN_GP_SINGLE_OUT#')
              ]]>
	</query>
	<query id="ComPlanFurnace.addPlnZyZgM" desc="新增轧管虚拟炉计划信息">
             <![CDATA[ INSERT INTO PLN_ZY_ZG_M(
        HEAT_PLAN_NO,
        GX_PRO_SEQ,
        ZY_BATCH_ID,
        STOVE_NO,
        JUDGE_STOVE_NO,
        PLANSTATUS,
        UPPER_HEATPLAN_ID,
        PRO_PLAN_ID,
        GX_PLAN_NO,
        CCM_PRO_PLAN_ID,
        CCM_GX_PLAN_NO,
        PLINE_CODE,
        PLINE_NAME,
        PROCESS_CODE_C,
        PROCESS_DESC_C,
        UPPER_PROCESS_CODE,
        NEXT_PROCESS_CODE,
        ISENDGX,
        IF_MATCH_ODD,
        IF_DO_HEAT_PLAN,
        ORDER_SOURCE,
        ORD_LN_DLY_PK,
        ORDER_NO,
        ORDER_SEQ,
        DELIVERY_NO,
        REQ_BL_ID,
        IF_EXPORT,
        PRIORITY,
        PRIORITY_MEMO,
        PRO_MONTH,
        IF_LEN_CONTROL,
        IF_MINUS_SIC_ROLL,
        PROD_STANDARD,
        OUTPUT_STANDARD,
        DECISION,
        PROGY_MEMO,
        GOWHERE_CODE,
        GOWHERE_NAME,
        OUTS_BILLET_FL,
        GPTYPE,
        INWL_ID,
        INWL_DESC,
        OUTWL_ID,
        OUTWL_DESC,
        GRADECODE,
        GRADENAME,
        STEELCODE,
        STEELNAME,
        PRODUCCODE,
        PRODUCNAME,
        MODEL_CODE,
        MODEL_DESC,
        DIAMETER,
        LEN_GP_SINGLE,
        WT_GP_SINGLE,
        PLN_INSINGLE_NUM,
        PLN_INSINGLE_WT,
        PLN_OUTSINGLE_NUM,
        PLN_OUTSINGLE_W,
        OUTDIAMETER,
        WALLTHICK,
        OUTDIAMETER_ZG,
        WALLTHICK_ZG,
        AIMOUTDIAMETER,
        AIMWALLTHICK,
        THICKNESS_WALL,
        LEN_ROLL_MAX,
        LEN_ROLL_MIN,
        AIMLENGTH,
        ROLL_LENGTH,
        OUTNUM_CUT,
        CUT_TYPE,
        LEN_CUTEND,
        LEN_CUTHEAD,
        DIAMETER_MANDREL,
        PASS_CODE,
        PASS_NAME,
        IF_MONITOR,
        PRDCR_NO,
        MONITOR_POINT,
        BOM,
        WHOLE_BACKLOG,
        WHOLE_BACKLOG_DESC,
        CIC,
        PIC,
        SIC,
        DIC,
        CRAFT_FILE_NO,
        CRAFT_FILE_MAN,
        CRAFT_SEQ,
        SEC_CRAFT_FILE_NO,
        STATION_ROAD,
        PRO_DAY,
        BAL_YEAR_MONTH,
        CREATE_NAME,
        CREATE_TIME,
        FLAG_STOVE_NO,
        INDEX_SEQ,FEED_HEAT_NO,MEMO,REDUCED_WT)
 VALUES( 
        '#HEAT_PLAN_NO#',
        '#GX_PRO_SEQ#',
        '#ZY_BATCH_ID#',
        '#STOVE_NO#',
        '#JUDGE_STOVE_NO#',
        '#PLANSTATUS#',
        '#UPPER_HEATPLAN_ID#',
        '#PRO_PLAN_ID#',
        '#GX_PLAN_NO#',
        '#CCM_PRO_PLAN_ID#',
        '#CCM_GX_PLAN_NO#',
        '#PLINE_CODE#',
        '#PLINE_NAME#',
        '#PROCESS_CODE_C#',
        '#PROCESS_DESC_C#',
        '#UPPER_PROCESS_CODE#',
        '#NEXT_PROCESS_CODE#',
        '#ISENDGX#',
        '#IF_MATCH_ODD#',
        '#IF_DO_HEAT_PLAN#',
        '#ORDER_SOURCE#',
        '#ORD_LN_DLY_PK#',
        '#ORDER_NO#',
        '#ORDER_SEQ#',
        '#DELIVERY_NO#',
        '#REQ_BL_ID#',
        '#IF_EXPORT#',
        '#PRIORITY#',
        '#PRIORITY_MEMO#',
        '#PRO_MONTH#',
        '#IF_LEN_CONTROL#',
        '#IF_MINUS_SIC_ROLL#',
        '#PROD_STANDARD#',
        '#OUTPUT_STANDARD#',
        '#DECISION#',
        '#PROGY_MEMO#',
        '#GOWHERE_CODE#',
        '#GOWHERE_NAME#',
        '#OUTS_BILLET_FL#',
        '#GPTYPE#',
        '#INWL_ID#',
        '#INWL_DESC#',
        '#OUTWL_ID#',
        '#OUTWL_DESC#',
        '#GRADECODE#',
        '#GRADENAME#',
        '#STEELCODE#',
        '#STEELNAME#',
        '#PRODUCCODE#',
        '#PRODUCNAME#',
        '#MODEL_CODE#',
        '#MODEL_DESC#',
        '#DIAMETER#',
        '#LEN_GP_SINGLE#',
        '#WT_GP_SINGLE#',
        '#PLN_INSINGLE_NUM#',
        '#PLN_INSINGLE_WT#',
        '#PLN_OUTSINGLE_NUM#',
        '#PLN_OUTSINGLE_W#',
        '#OUTDIAMETER#',
        '#WALLTHICK#',
        '#OUTDIAMETER_ZG#',
        '#WALLTHICK_ZG#',
        '#AIMOUTDIAMETER#',
        '#AIMWALLTHICK#',
        '#THICKNESS_WALL#',
        '#LEN_ROLL_MAX#',
        '#LEN_ROLL_MIN#',
        '#AIMLENGTH#',
        '#ROLL_LENGTH#',
        '#OUTNUM_CUT#',
        '#CUT_TYPE#',
        '#LEN_CUTEND#',
        '#LEN_CUTHEAD#',
        '#DIAMETER_MANDREL#',
        '#PASS_CODE#',
        '#PASS_NAME#',
        '#IF_MONITOR#',
        '#PRDCR_NO#',
        '#MONITOR_POINT#',
        '#BOM#',
        '#WHOLE_BACKLOG#',
        '#WHOLE_BACKLOG_DESC#',
        '#CIC#',
        '#PIC#',
        '#SIC#',
        '#DIC#',
        '#CRAFT_FILE_NO#',
        '#CRAFT_FILE_MAN#',
        '#CRAFT_SEQ#',
        '#SEC_CRAFT_FILE_NO#',
        '#STATION_ROAD#',
        '#PRO_DAY#',
        '#BAL_YEAR_MONTH#',
        '#CREATE_NAME#',
        TO_DATE('#CREATE_TIME#','YYYY-MM-DD HH24:MI:SS'), 
        '#FLAG_STOVE_NO#',
        '#INDEX_SEQ#','#FEED_HEAT_NO#','#MEMO#','#REDUCED_WT#')
             ]]>
	</query>
	<query id="ComPlanFurnace.queryPlnZyZgM" desc="查询轧管虚拟炉计划信息">
             <![CDATA[ 
             SELECT T.* FROM PLN_ZY_ZG_M T WHERE 1 = 1 AND (SELECT CASE
                         WHEN T1.JUDGE_STOVE_NO IS NULL AND
                              T1.UPPER_PROCESS_CODE = 'B' THEN
                          (SELECT O.JUDGE_STOVE_NO
                             FROM PLN_STEELFOR_ORD O
                            WHERE O.FURNACENO || '/' || O.SEQUENCENO =
                                  T1.UPPER_HEATPLAN_ID)
                         ELSE
                          T1.JUDGE_STOVE_NO
                       END JUDGE_STOVE_NO
                  FROM PLN_ZY_ZG_M T1
                 WHERE T1.HEAT_PLAN_NO = T.HEAT_PLAN_NO) = ?
             ]]>
	</query>
	<query id="ComPlanFurnace.queryPlnZyDzM" desc="查询锻造虚拟炉计划信息">
             <![CDATA[ 
            SELECT T.*
  FROM PLN_ZY_DZ_M T
 WHERE 1 = 1
   AND (SELECT CASE
                 WHEN T1.JUDGE_STOVE_NO IS NULL THEN
                  (SELECT O.JUDGE_STOVE_NO
                     FROM PLN_STEELFOR_ORD O
                    WHERE O.FURNACENO || '/' || O.SEQUENCENO =
                          T1.UPPER_HEATPLAN_ID)
                 ELSE
                  T1.JUDGE_STOVE_NO
               END JUDGE_STOVE_NO
          FROM PLN_ZY_DZ_M T1
         WHERE T1.HEAT_PLAN_NO = T.HEAT_PLAN_NO) = ?
         AND T.PRO_PLAN_ID=?
         AND T.GX_PLAN_NO=?

             ]]>
	</query>
	<query id="ComPlanFurnace.getHeatPlanSeq" desc="获取上料行ID">
             <![CDATA[ 
   SELECT ? ||LPAD(SUBSTR(NVL(MAX(T.HEAT_PLAN_SQE),'00'),-2,2) + 1, 2, '0') AS HEAT_PLAN_SQE  ]]>
	</query>
	<query id="ComPlanFurnace.addPlnZyDzC" desc="新增锻造实际炉计划">
             <![CDATA[ 
  INSERT INTO PLN_ZY_DZ_C(
        HEAT_PLAN_NO,
        HEAT_PLAN_SQE,
        JUGDE_APPLY_CODE,
        ZY_BATCH_ID,
        STOVE_NO,
        JUDGE_STOVE_NO,
        PRO_PLAN_ID,
        GX_PLAN_NO,
        PLINE_CODE,
        PLINE_NAME,
        DIAMETER,
        LEN_GP_SINGLE,
        WT_GP_SINGLE,
        CUT_NUM_GP,
        LENGTH_M,
        WEIGHT_M,
        PLAN_INDOUBLE_NUM,
        PLAN_INDOUBLE_WT,
        REAL_INDOUBLE_NUM,
        REAL_INDOUBLE_WT,
        FLAG_STOVE_NO,
        CREATE_NAME,
        CREATE_TIME)
 VALUES( 
        '#HEAT_PLAN_NO#',
        '#HEAT_PLAN_SQE#',
        '#JUGDE_APPLY_CODE#',
        '#ZY_BATCH_ID#',
        '#STOVE_NO#',
        '#JUDGE_STOVE_NO#',
        '#PRO_PLAN_ID#',
        '#GX_PLAN_NO#',
        '#PLINE_CODE#',
        '#PLINE_NAME#',
        '#DIAMETER#',
        '#LEN_GP_SINGLE#',
        '#WT_GP_SINGLE#',
        '#CUT_NUM_GP#',
        '#LENGTH_M#',
        '#WEIGHT_M#',
        '#PLAN_INDOUBLE_NUM#',
        '#PLAN_INDOUBLE_WT#',
        '#REAL_INDOUBLE_NUM#',
        '#REAL_INDOUBLE_WT#',
        '#FLAG_STOVE_NO#',
        '#CREATE_NAME#',
        TO_DATE('#CREATE_TIME#','YYYY-MM-DD HH24:MI:SS'))
              ]]>
	</query>
	<query id="ComPlanFurnace.addPlnZyZgC" desc="新增轧管实际炉计划">
             <![CDATA[  
              INSERT INTO PLN_ZY_ZG_C(
        HEAT_PLAN_NO,
        HEAT_PLAN_SQE,
        JUGDE_APPLY_CODE,
        ZY_BATCH_ID,
        STOVE_NO,
        JUDGE_STOVE_NO,
        PRO_PLAN_ID,
        GX_PLAN_NO,
        PLINE_CODE,
        PLINE_NAME,
        DIAMETER,
        LEN_GP_SINGLE,
        WT_GP_SINGLE,
        CUT_NUM_GP,
        LENGTH_M,
        WEIGHT_M,
        PLAN_INDOUBLE_NUM,
        PLAN_INDOUBLE_WT,
        REAL_INDOUBLE_NUM,
        REAL_INDOUBLE_WT,
        FLAG_STOVE_NO,
        CREATE_NAME,
        CREATE_TIME,FEED_HEAT_NO,CUT_NUM_OLD,LEN_GP_SINGLE_OLD,LENGTH_M_OLD,PLAN_WEIGTH,CUT_TARGET,CUT_LENGTH,CUT_WEIGHT)
 VALUES( 
        '#HEAT_PLAN_NO#',
        '#HEAT_PLAN_SQE#',
        '#JUGDE_APPLY_CODE#',
        '#ZY_BATCH_ID#',
        '#STOVE_NO#',
        '#JUDGE_STOVE_NO#',
        '#PRO_PLAN_ID#',
        '#GX_PLAN_NO#',
        '#PLINE_CODE#',
        '#PLINE_NAME#',
        '#DIAMETER#',
        '#LEN_GP_SINGLE#',
        '#WT_GP_SINGLE#',
        '#CUT_NUM_GP#',
        '#LENGTH_M#',
        '#WEIGHT_M#',
        '#PLAN_INDOUBLE_NUM#',
        '#PLAN_INDOUBLE_WT#',
        '#REAL_INDOUBLE_NUM#',
        '#REAL_INDOUBLE_WT#',
        '#FLAG_STOVE_NO#',
        '#CREATE_NAME#',
        TO_DATE('#CREATE_TIME#','YYYY-MM-DD HH24:MI:SS'),
        '#FEED_HEAT_NO#','#CUT_NUM_OLD#','#LEN_GP_SINGLE_OLD#','#LENGTH_M_OLD#','#PLAN_WEIGTH#',
        '#CUT_TARGET#','#CUT_LENGTH#','#CUT_WEIGHT#')
              ]]>
	</query>
	<query id="ComPlanFurnace.getMatGpMEntity" desc="查询管坯物料信息">
             <![CDATA[
             SELECT T.MATERIAL_NO,
       T.MATERIAL_NAME,
       T.FLAG_STOVE_NO,
       T.JUDGE_STOVE_NO,
       T.STOVE_NO,
       T.PRO_PLAN_ID,
       T.GX_PLAN_NO,
       T.PRO_PLAN_ID_ZG,
       T.GX_PLAN_NO_ZG,
       T.GRADECODE,
       T.GRADENAME,
       T.DIMATER,
       T.ACT_LEN,
       T.FIX_NUM,
       T.FIX_LEN,
       SUM(T.ACT_COUNT) ACT_COUNT,
       SUM(T.ACT_WEIGHT) ACT_WEIGHT,
       SUM(T.DB_ACT_COUNT) DB_ACT_COUNT,
       T.CHEM_JUDGE_ID,
       T.GPTYPE,T.ISENDGX
  FROM MAT_GP_M T
 WHERE T.JUDGE_STOVE_NO = ?
   AND T.FURNACENO = ?
   AND T.SEQUENCENO = ?
   AND T.GPTYPE=?
   AND T.MAT_STATUS ='80150102'    
   AND T.MNG_LOCK_FLAG='0'
               ]]>
	</query>
	<query id="ComPlanFurnace.updateMatGpMEntity" desc="修改管坯物料挂料信息">
             <![CDATA[
DECLARE
BEGIN
  FOR MYROW IN (SELECT MAT_NO
                  FROM (SELECT T.MAT_NO
                          FROM MAT_GP_M T
                         WHERE T.JUGDE_APPLY_CODE = ?
                           AND T.JUDGE_STOVE_NO=?
                           AND T.FIX_NUM = TO_NUMBER(?)
                           AND T.PRO_PLAN_ID_ZG = ?
                           AND T.GX_PLAN_NO_ZG = ?
                           AND T.MNG_LOCK_FLAG='0'
                           AND T.HANGING_FLAG='0'
                         ORDER BY T.MAT_NO ASC)
                 WHERE ROWNUM <= ?) LOOP
    UPDATE MAT_GP_M T SET T.HANGING_FLAG = ?,T.MAT_STATUS=?,T.CUT_YU_LONG=? WHERE T.MAT_NO = MYROW.MAT_NO;
  END LOOP;
END; 
               ]]>
	</query>
	
	<query id="ComPlanFurnace.updateMatGpNewEntity" desc="修改管坯物料挂料信息">
             <![CDATA[
DECLARE
BEGIN
  FOR MYROW IN (SELECT MAT_NO
                  FROM (SELECT T.MAT_NO
                          FROM MAT_GP_M T
                         WHERE T.JUGDE_APPLY_CODE = ?
                           AND T.JUDGE_STOVE_NO=?
                           AND T.FIX_NUM = TO_NUMBER(?)
                           AND T.PRO_PLAN_ID_ZG = ?
                           AND T.GX_PLAN_NO_ZG = ?
                           AND T.MNG_LOCK_FLAG='0'
                           AND T.HANGING_FLAG='1'
                         ORDER BY T.MAT_NO ASC)
                 WHERE ROWNUM <= ?) LOOP
    UPDATE MAT_GP_M T SET T.HANGING_FLAG = ?,T.MAT_STATUS=?,T.CUT_YU_LONG=? WHERE T.MAT_NO = MYROW.MAT_NO;
  END LOOP;
END; 
               ]]>
	</query>
	
	<query id="ComPlanFurnace.QueryQcmGpApply" desc="新增查询申请判定单信息">
             <![CDATA[ 
              SELECT 
       T.JUGDE_APPLY_CODE,
       T.JUGDE_APPLY_SQE,
       T.STOVE_NO,
       T.CAST_NO,
       T.CCMID,
       T.JUDGE_STOVE_NO,
       T.BATCH_GROUD_NO,
       T.PROCESS_CODE,
       T.PLINE_CODE,
       T.LEN_GP_SINGLE,
       T.MULTIPLE_NUM,
       T.ACT_COUNT,
       T.ACT_DIMATER,
       T.ACT_LEN,
       T.ACT_WEIGHT,
       T.ACT_THEORY_WEIGHT,
       T.FACE_RESULT_CODE,
       T.SPEC_RESULT_CODE,
       T.CHEM_RESULT_CODE,
       T.PHY_RESULT_CODE,
       T.DETECT_RESULT_CODE,
       T.FACE_RESULT_PATH,
       T.SPEC_RESULT_PATH,
       T.CHEM_RESULT_PATH,
       T.PHY_RESULT_PATH,
       T.DETECT_RESULT_PATH,
       T.MATERIAL_NO,
       T.MATERIAL_NAME,
       T.GRADECODE,
       T.GRADENAME,
       T.STD_CODE,
       T.STD_NAME,
       T.PLINE_NAME,
       T.PRO_ORDER_NO,
       T.MAT_GOWHERE_CODE,
       T.MAT_GOWHERE_NAME,
       T.JUDGE_RESULT_CODE,
       T.JUDGE_RESULT,
       TO_CHAR(T.JUDGE_RESULT_TIME, 'YYYY-MM-DD HH24:MI:SS') JUDGE_RESULT_TIME,
       T.JUDGE_MAKER,
       T.IF_SET_ZY_PLAN,
       T.ORD_LN_DLY_PK,
       T.APPLY_FLAG,
       T.BACK_JUGDE_MEMO,
       T.VALIDFLAG,
       T.APPLY_NAME,
       TO_CHAR(T.APPLY_TIME, 'YYYY-MM-DD HH24:MI:SS') APPLY_TIME,
       T.MEMO,
       T.BAL_YEAR_MONTH,
       T.IS_FLAG,
       T.IS_ALL_SCRAP,
       T.PRO_PLAN_ID,
       T.GX_PLAN_NO,
       T.GPREQ_ID,
       T.BELONG_CODE_JUGDE,
       T.BELONG_NAME_JUGDE,
       T.FURNACENO,
       T.SEQUENCENO,
       T.CRAFT_NO,
       T.ISENDGX,
       T.GPTYPE,
       T.PRO_PLAN_ID_NEXT,
       T.GX_PLAN_NO_NEXT,
       T.JUGDE_APPLY_SEQUENO,
       T.HEAT_PLAN_NO_NEXT
       
 FROM QCM_GP_JUDGE_APPLY T
 WHERE T.JUGDE_APPLY_CODE =?
AND T.JUGDE_APPLY_SQE = ?
AND T.JUDGE_STOVE_NO = ?
ORDER BY TO_NUMBER(T.JUGDE_APPLY_SEQUENO) ASC
              ]]>
	</query>
	<query id="ComPlanFurnace.querySteOrdPlnFurn" desc="查询连铸炉次订单">
             <![CDATA[   
              SELECT 
       T.FURNACENO,
       T.SEQUENCENO,
       T.FURNACENO_SEQ,
       T.PRO_PLAN_ID,
       T.GX_PLAN_NO,
       T.CAST_NO,
       T.CAST_SEQ,
       T.CAST_STOVE_SEQ,
       T.CCM_SEQ,
       T.STOVE_NO,
       T.JUDGE_STOVE_NO,
       T.JUDGE_STOVE_NO_SEQ,
       T.FLAG_STOVE_NO,
       T.STATUS,
       T.CCM_STATE,
       T.CCM_PLN_TYPE,
       T.GPTYPE,
       T.CASTINGTYPE,
       T.PLINE_CODE,
       T.PLINE_NAME,
       T.CCMID,
       T.FLOWNO,
       T.EF_PLINE_CODE,
       T.EF_PLINE_NAME,
       T.WLID_IN,
       T.WLDESC_IN,
       T.MATERIAL_NO,
       T.MATERIAL_NAME,
       T.GRADECODE,
       T.GRADENAME,
       T.DIAMETER,
       T.LEN_GP_SINGLE,
       T.CUT_NUM_GP,
       T.LENGTH_M,
       T.WEIGHT_GP_ONE,
       T.WEIGHT_M,
       T.TOT_MUM_M,
       T.TOT_WEIGHT_M,
       T.ACT_WEIGHT_M,
       T.ACT_MUM_M,
       T.SURPLUSFLAG,
       T.EXCESS_WT,
       T.EXCESS_NUM,
       T.SURPLUS_TYPE,
       T.IF_SURPLUS_ALLOTED,
       T.CIC,
       T.PIC,
       T.SIC,
       T.DIC,
       T.CHEM_JUDGE_ID,
       T.PHY_JUDGE_ID,
       T.COLLIGATE_JUDGE_ID,
       T.MEMO,
       T.MAKEMAN,
       TO_CHAR(T.MAKETIME, 'YYYY-MM-DD HH24:MI:SS') MAKETIME,
       T.DOWNMAN,
       TO_CHAR(T.DOWNTIME, 'YYYY-MM-DD HH24:MI:SS') DOWNTIME,
       T.PRO_MONTH,
       T.ORDER_NO,
       T.FINAL_USER_DESC,
       T.STEELCODE,
       T.STEELNAME,
       T.PRODUCCODE,
       T.PRODUCNAME,
       T.GOWHERE_CODE,
       T.GOWHERE_NAME,
       T.ISENDGX,
       T.STATE_LK,
       T.IF_MONITOR_LG,
       T.PRDCR_NO,
       T.MERGE_NO,
       T.PDEPT_NAME,
       T.PRDCR_MAN,
       T.CUT_NUM
 FROM PLN_STEELFOR_ORD T
 WHERE T.FURNACENO =? AND T.SEQUENCENO = ?

             ]]>
	</query>
	<query id="ComPlanFurnace.QueryMatGp" desc="根据管坯需求，判定炉号查询库存">
             <![CDATA[ 
             SELECT T.JUDGE_STOVE_NO,
       T.PRO_PLAN_ID_ZG,
       T.GX_PLAN_NO_ZG,
       T.GPREQ_ID,
       SUM(T.ACT_COUNT*T.FIX_NUM) ACT_COUNT,
       SUM(T.ACT_WEIGHT) ACT_WEIGHT,
       T.STOVE_NO,
       T.FLAG_STOVE_NO,
       T.DIMATER,T.FIX_LEN,T.GPTYPE
  FROM MAT_GP_M T
 WHERE T.MAT_ORIGIN_CODE = '801301'
   AND T.JUDGE_STOVE_NO = ?
   AND T.MNG_LOCK_FLAG='0'
   AND T.LOCK_FLAG='0'
   AND T.QCM_STAUS='00'
 GROUP BY T.JUDGE_STOVE_NO,
          T.PRO_PLAN_ID_ZG,
          T.GX_PLAN_NO_ZG,
          T.GPREQ_ID,
          T.STOVE_NO,
          T.FLAG_STOVE_NO,
          T.DIMATER,T.FIX_LEN,T.GPTYPE
             ]]>
	</query>
	<query id="ComPlanFurnace.QueryMatGpDelete" desc="撤销外购查询库存">
             <![CDATA[ 
           SELECT T.JUDGE_STOVE_NO,
       T.PRO_PLAN_ID_ZG,
       T.GX_PLAN_NO_ZG,
       T.GPREQ_ID,
       SUM(T.ACT_COUNT * T.FIX_NUM) ACT_COUNT,
       SUM(T.ACT_WEIGHT) ACT_WEIGHT,
       T.STOVE_NO,
       T.FLAG_STOVE_NO,
       T.DIMATER,
       T.FIX_LEN,
       T.GPTYPE,
       T.HEAT_PLAN_NO_NEXT
  FROM MAT_GP_M T
 WHERE T.MAT_NO IN (SELECT T1.MAT_NO
                      FROM YDM_GP_INLIST T1
                     WHERE T1.JUDGE_STOVE_NO = ?
                         AND DECODE(?,'','/',T1.INSTOCK_DOC) =  NVL(?,'/')
                       AND T1.MAT_ORIGIN_CODE = '801301')
   AND T.QCM_STAUS = '00'
 GROUP BY T.JUDGE_STOVE_NO,
          T.PRO_PLAN_ID_ZG,
          T.GX_PLAN_NO_ZG,
          T.GPREQ_ID,
          T.STOVE_NO,
          T.FLAG_STOVE_NO,
          T.DIMATER,
          T.FIX_LEN,
          T.GPTYPE,
          T.HEAT_PLAN_NO_NEXT

             ]]>
	</query>
		<query id="ComPlanFurnace.updatePlnZgM" desc="修改轧管虚拟炉计划">
		<![CDATA[
DECLARE
BEGIN
  FOR MYROW IN (select SUM(T.PLAN_INDOUBLE_NUM * T.CUT_NUM_GP) V_NUM,
                       SUM(T.PLAN_INDOUBLE_WT) V_WT
                  from PLN_ZY_ZG_C T
                 where T.HEAT_PLAN_NO = ?) LOOP
    UPDATE PLN_ZY_ZG_M T1
       SET T1.PLN_INSINGLE_NUM  = MYROW.V_NUM,
           T1.PLN_INSINGLE_WT   = MYROW.V_WT,
           T1.PLN_OUTSINGLE_NUM = MYROW.V_NUM*T1.OUTNUM_CUT,
           T1.PLN_OUTSINGLE_W   =MYROW.V_NUM*?,
           T1.REDUCED_WT   =MYROW.V_NUM*?
     WHERE T1.HEAT_PLAN_NO = ?;
  END LOOP;
END;
		]]>
	</query>
	<query id="ComPlanFurnace.updateMilPlan" desc="修改炉计划接收表">
		<![CDATA[
DECLARE
BEGIN
  FOR MYROW IN (SELECT SUM(T.PLAN_INDOUBLE_NUM * T.CUT_NUM_GP) V_NUM,
                       SUM(T.PLAN_INDOUBLE_WT) V_WT
                  FROM PLN_ZY_ZG_C T
                 WHERE T.HEAT_PLAN_NO = ?) LOOP
    UPDATE MIL_PLAN T
       SET T.BRANCH = MYROW.V_NUM,
           T.TON    = MYROW.V_WT,
           T.DB_NUM = MYROW.V_NUM
     WHERE T.ID = ?;
  END LOOP;
END;
		]]>
	</query>
	<query id="ComPlanFurnace.UpdateMatGp" desc="修改坯子库存信息">
             <![CDATA[     
    UPDATE MAT_GP_M T
       SET T.MAT_STATUS     = ?,
           T.HANGING_FLAG   = ?
     WHERE T.MAT_NO =?
             ]]>
	</query>
	<query id="ComPlanFurnace.queryPlanZgOld" desc="通过判定炉号+锻造订单查询轧管虚拟炉计划是否存在记录">
             <![CDATA[     
   SELECT T.HEAT_PLAN_NO, T.PRO_PLAN_ID, T.CCM_PRO_PLAN_ID
  FROM PLN_ZY_ZG_M T
 WHERE  INSTR(T.PRO_PLAN_ID || '/' || T.GX_PLAN_NO, ?) > 0
             ]]>
	</query>
	<query id="ComPlanFurnace.updateWgZgM" desc="修改外购炉计划">
             <![CDATA[  
	UPDATE PLN_ZY_ZG_M T
   SET T.PLN_INSINGLE_NUM  = TO_NUMBER(NVL(T.PLN_INSINGLE_NUM, 0)) -
                             TO_NUMBER(?),
       T.PLN_INSINGLE_WT   = TO_NUMBER(NVL(T.PLN_INSINGLE_WT, 0)) -
                             TO_NUMBER(?),
       T.PLN_OUTSINGLE_NUM = TO_NUMBER(NVL(T.PLN_OUTSINGLE_NUM, 0)) -
                             TO_NUMBER(?),
       T.PLN_OUTSINGLE_W   = TO_NUMBER(NVL(T.PLN_OUTSINGLE_W, 0)) -
                             TO_NUMBER(?),
       T.REDUCED_WT        = TO_NUMBER(NVL(T.REDUCED_WT, 0)) - TO_NUMBER(?)
 WHERE T.HEAT_PLAN_NO = ?
	  ]]>
	</query>
</queryMap>