<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc = "再进加热炉实绩操作">
<query id = "FrmReFurResult.getRefurResult" desc = "查询再加热炉实绩信息">
 <![CDATA[
 SELECT OUT_FUR_NUM,
       RESULT_NO,
       LOT_NO,
       STOVE_NO,
       CHANGECLASSNUM,
       OUT_CHANGE_NUM,
       BURNINGRATE,
       PLINE_CODE,
       PROCESS_ROUTE,
       TO_CHAR(IN_FUR_TIME, 'YYYY-MM-DD HH24:MI:SS') IN_FUR_TIME,
       TO_CHAR(OUT_FUR_TIME, 'YYYY-MM-DD HH24:MI:SS') OUT_FUR_TIME,
       STEPPING_RHYTHM,
       TRANSFER_RHYTHM,
       FIRST_IN_TEMP,
       LAST_IN_TEMP,
       FIRST_OUT_TEMP,
       LAST_OUT_TEMP,
       TO_CHAR(FIRST_IN_TIME, 'YYYY-MM-DD HH24:MI:SS') FIRST_IN_TIME,
       TO_CHAR(LAST_IN_TIME, 'YYYY-MM-DD HH24:MI:SS') LAST_IN_TIME,
       TO_CHAR(FIRST_OUT_TIME, 'YYYY-MM-DD HH24:MI:SS') FIRST_OUT_TIME,
       TO_CHAR(LAST_OUT_TIME, 'YYYY-MM-DD HH24:MI:SS') LAST_OUT_TIME,
       SET_FUR_TEMP,
       IN_FUR_NUM,
       SCRAP_NUM,
       LHEAT_CRUVE1,
       LHEAT_CRUVE2,
       LHEAT_CRUVE3,
       LHEAT_CRUVE4,
       LHEAT_CRUVE5,
       LHEAT_CRUVE6,
       LHEAT_CRUVE7,
       LHEAT_CRUVE8,
       ACTUAL_LENGTH_OF_WASTE_PIPE,
       RESIDUAL_OXYGEN,
       FUR_PRESS,
       WIND_PRESS,
       GAS_PRESS,
       TO_CHAR(START_TIME, 'YYYY-MM-DD HH24:MI:SS') START_TIME,
       TO_CHAR(END_TIME, 'YYYY-MM-DD HH24:MI:SS') END_TIME,
       EXECUTIVE_PRODUCER,
       TO_CHAR(PRODUCER_TIME, 'YYYY-MM-DD HH24:MI:SS') PRODUCER_TIME,
       PRODUCER_TEL,
       NODE_FUR_FLAG,
       REMARK,
       COL_MODE,
       TO_CHAR(COL_TIME, 'YYYY-MM-DD HH24:MI:SS') COL_TIME,
       COL_USER,
       COL_SHIFT,
       COL_GROUP,
       BEGIN_ROLLING_TEMP

  FROM MIL_REFUR_RESULT
 WHERE JUDGE_STOVE_NO = ?
   AND PRO_PLAN_ID  || '&' LIKE '%' || ? || '%'
   AND GX_PLAN_NO  || '&' LIKE '%' || ? || '%'
   ]]>
</query>
<query id = "FrmReFurResult.updateMailPlanStatus" desc = "修改主计划状态为开始再入炉">
 <![CDATA[
UPDATE MIL_PLAN T
   SET T.STATUS = '45'
 WHERE T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
   AND NVL(T.PRO_PLAN_ID, '/') = NVL('#PRO_PLAN_ID#', '/')
   AND NVL(T.GX_PLAN_NO, '/') = NVL('#GX_PLAN_NO#', '/')
   ]]>
</query>
<query id = "FrmReFurResult.insertResultForMainPlan" desc = "新增再入炉实绩">
INSERT INTO MIL_REFUR_RESULT
  (RESULT_NO,
   LOT_NO,
   STOVE_NO,
   JUDGE_STOVE_NO,
   PLINE_CODE,
   PROCESS_ROUTE,
   IN_FUR_TIME,
   STEPPING_RHYTHM,
   TRANSFER_RHYTHM,
   FIRST_IN_TEMP,
   LAST_IN_TEMP,
   FIRST_OUT_TEMP,
   LAST_OUT_TEMP,
   SET_FUR_TEMP,
   IN_FUR_NUM,
   SCRAP_NUM,
   LHEAT_CRUVE1,
   LHEAT_CRUVE2,
   LHEAT_CRUVE3,
   LHEAT_CRUVE4,
   LHEAT_CRUVE5,
   LHEAT_CRUVE6,
   LHEAT_CRUVE7,
   LHEAT_CRUVE8,
   ACTUAL_LENGTH_OF_WASTE_PIPE,
   RESIDUAL_OXYGEN,
   FUR_PRESS,
   WIND_PRESS,
   GAS_PRESS,
   START_TIME,
   EXECUTIVE_PRODUCER,
   PRODUCER_TIME,
   PRODUCER_TEL,
   NODE_FUR_FLAG,
   REMARK,
   COL_MODE,
   COL_TIME,
   COL_USER,
   COL_SHIFT,
   COL_GROUP,
   
   CHANGECLASSNUM,
   BURNINGRATE,
   FIRST_IN_TIME,
   BEGIN_ROLLING_TEMP,
   PRO_PLAN_ID,
   GX_PLAN_NO)
VALUES
  ('#RESULT_NO#',
   '#LOT_NO#',
   '#STOVE_NO#',
   '#JUDGE_STOVE_NO#',
   '#PLINE_CODE#',
   '#PROCESS_ROUTE#',
   SYSDATE,
   '#STEPPING_RHYTHM#',
   '#TRANSFER_RHYTHM#',
   '#FIRST_IN_TEMP#',
   
   '#LAST_IN_TEMP#',
   '#FIRST_OUT_TEMP#',
   '#LAST_OUT_TEMP#',
   '#SET_FUR_TEMP#',
   '#IN_FUR_NUM#',
   '#SCRAP_NUM#',
   '#LHEAT_CRUVE1#',
   '#LHEAT_CRUVE2#',
   '#LHEAT_CRUVE3#',
   '#LHEAT_CRUVE4#',
   '#LHEAT_CRUVE5#',
   '#LHEAT_CRUVE6#',
   '#LHEAT_CRUVE7#',
   '#LHEAT_CRUVE8#',
   '#ACTUAL_LENGTH_OF_WASTE_PIPE#',
   '#RESIDUAL_OXYGEN#',
   '#FUR_PRESS#',
   '#WIND_PRESS#',
   '#GAS_PRESS#',
   to_date('#START_TIME#', 'yyyy-mm-dd hh24:mi:ss'),
   '#EXECUTIVE_PRODUCER#',
   SYSDATE,
   '#PRODUCER_TEL#',
   '#NODE_FUR_FLAG#',
   '#REMARK#',
   '#COL_MODE#',
   SYSDATE,
   '#COL_USER#',
   '#COL_SHIFT#',
   '#COL_GROUP#',
   
   '#CHANGECLASSNUM#',
   '#BURNINGRATE#',
   to_date('#FIRST_IN_TIME#', 'yyyy-mm-dd hh24:mi:ss'),
   '#BEGIN_ROLLING_TEMP#',
   '#PRO_PLAN_ID#',
   '#GX_PLAN_NO#')
</query>



<query id="FrmReFurResult.INFurPlanQuery" desc="查询待装炉计划">
        <![CDATA[
		select t1.*
  from (select t.JUDGE_STOVE_NO,
               REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '') as JUDGE_NO,
               f.CUT_NUM,
               t.LOT_NO,
               f.start_time,
               t.ID,
               ((select count(*)
                   from PORT_MIL_BATCH_SAMPLE_RESULT t2
                  where t2.judge_stove_no = t.JUDGE_STOVE_NO
                    and t2.status = '0') +
               (select count(*)
                   from PORT_MIL_BATCH_SAMPLE_RESULT t3
                  where t3.judge_stove_no = t.JUDGE_STOVE_NO
                    and trim(t3.op_process) >= 5)) plan_count,
               t.NODE_STATUS,
               IS_START,
               T.PRO_PLAN_ID,
               T.GX_PLAN_NO
          FROM (SELECT A.JUDGE_STOVE_NO,
                       A.LOT_NO,
                       A.ID,
                       CASE A.NODE_STATUS
                         WHEN '00' THEN
                          '正在锯切'
                         WHEN '10' THEN
                          '锯切完成'
                         WHEN '20' THEN
                          '锯切完成'
                         WHEN '30' THEN
                          '穿孔完成'
                         WHEN '40' THEN
                          '连轧完成'
                         WHEN '50' THEN
                          '再加热炉完成'
                       END AS NODE_STATUS,
                       
                       case Nvl((select b.IS_START
                              FROM mil_Refur_result b
                             where b.judge_stove_no = a.judge_Stove_no),
                            4)
                         WHEN '0' THEN
                          '已开始入炉'
                         WHEN '1' THEN
                          '已完成入炉'
                         WHEN '2' THEN
                          '已开始出炉'
                         WHEN '3' THEN
                          '已完成出炉'
                         WHEN '4' THEN
                          '未开始入炉'
                       END AS IS_START,
                       A.PRO_PLAN_ID,
                       A.GX_PLAN_NO
                  FROM MIL_PLAN A, MIL_REFUR_RESULT B
                 WHERE A.JUDGE_STOVE_NO = B.JUDGE_STOVE_NO(+)
                   AND A.PLINE_CODE = ?
                   AND A.NODE_STATUS < 50) t,
               MIL_FEEDSAW_RESULT f
         WHERE IS_START in ('已开始入炉', '未开始入炉')
           and t.ID = f.result_no(+)
           and t.JUDGE_STOVE_NO = f.judge_stove_no(+)
           AND t.lot_no || '&' LIKE '%' || ? || '%'
           AND t.judge_stove_no || '&' LIKE '%' || ? || '%'
         order by f.start_time) t1
 where t1.PLAN_COUNT > 0
        ]]>
	</query>
	
	<query id="FrmReFurResult.INFurOUTPlanQuery" desc="查询待出炉计划">
        <![CDATA[
  select A.JUDGE_STOVE_NO,
       REGEXP_REPLACE(A.JUDGE_STOVE_NO, '-.*', '') as JUDGE_NO,
       C.CUT_NUM,
       C.START_TIME,
       A.LOT_NO,
       A.ID,
       CASE A.NODE_STATUS
         WHEN '00' THEN
          '正在锯切'
         WHEN '10' THEN
          '锯切完成'
         WHEN '30' THEN
          '穿孔完成'
         WHEN '40' THEN
          '连轧完成'
         WHEN '50' THEN
          '再加热炉完成'
       END AS NODE_STATUS,
       case B.IS_START
         WHEN '0' THEN
          '已开始入炉'
         WHEN '1' THEN
          '已完成入炉'
         WHEN '2' THEN
          '已开始出炉'
         WHEN '3' THEN
          '已完成出炉'
       end as IS_START,
       A.PRO_PLAN_ID,
       A.GX_PLAN_NO
  FROM MIL_PLAN A, MIL_REFUR_RESULT B, MIL_FEEDSAW_RESULT C
 WHERE A.JUDGE_STOVE_NO = B.JUDGE_STOVE_NO
   AND A.PLINE_CODE = ?
   AND A.NODE_STATUS < 50
   AND B.IS_START > 0
   AND A.ID = C.RESULT_NO
   AND A.JUDGE_STOVE_NO = C.JUDGE_STOVE_NO
   AND a.lot_no || '&' LIKE '%' || ? || '%'
   AND a.judge_stove_no || '&' LIKE '%' || ? || '%'
 ORDER BY C.START_TIME
  
        ]]>
	</query>
	
		<query id="FrmReFurResult.OUTFurPlanQuery" desc="查询已出炉计划">
        <![CDATA[
  select t1.*
  from (select A.JUDGE_STOVE_NO,
               REGEXP_REPLACE(A.JUDGE_STOVE_NO, '-.*', '') as JUDGE_NO,
               C.CUT_NUM,
               A.LOT_NO,
               A.ID,
               ((select count(*)
                   from PORT_MIL_BATCH_SAMPLE_RESULT t2
                  where t2.judge_stove_no = A.JUDGE_STOVE_NO
                    and t2.status = '0') +
               (select count(*)
                   from PORT_MIL_BATCH_SAMPLE_RESULT t3
                  where t3.judge_stove_no = A.JUDGE_STOVE_NO
                    and trim(t3.op_process) >= 5)) plan_count,
               C.START_TIME,
               CASE A.NODE_STATUS
                 WHEN '00' THEN
                  '正在锯切'
                 WHEN '10' THEN
                  '锯切完成'
                 WHEN '20' THEN
                  '出炉'
                 WHEN '30' THEN
                  '穿孔完成'
                 WHEN '40' THEN
                  '连轧完成'
                 WHEN '50' THEN
                  '出再加热炉'
                 WHEN '60' THEN
                  '定径完成'
                 WHEN '70' THEN
                  '分切完成'
                 WHEN '80' THEN
                  '矫直完成 '
                 WHEN '90' THEN
                  '探伤完成'
                 WHEN '96' THEN
                  '人工质检完成'
                 WHEN '99' THEN
                  '交库'
               END AS NODE_STATUS,
               CASE B.IS_START
                 WHEN '0' THEN
                  '已开始入炉'
                 WHEN '1' THEN
                  '已完成入炉'
                 WHEN '2' THEN
                  '已开始出炉'
                 WHEN '3' THEN
                  '已完成出炉'
               END as IS_START,
               A.PRO_PLAN_ID,
               A.GX_PLAN_NO
          FROM MIL_PLAN A, MIL_REFUR_RESULT B, MIL_FEEDSAW_RESULT C
         WHERE A.JUDGE_STOVE_NO = B.JUDGE_STOVE_NO
           AND A.PLINE_CODE = ?
           AND A.NODE_STATUS > 40
           AND A.ID = C.RESULT_NO
           AND A.JUDGE_STOVE_NO = C.JUDGE_STOVE_NO
           AND a.lot_no || '&' LIKE '%' || ? || '%'
           AND a.judge_stove_no || '&' LIKE '%' || ? || '%'
         ORDER BY C.START_TIME) t1
 where t1.PLAN_COUNT > 0
        ]]>
	</query>
	
	
		<query id="FrmReFurResult.InFurNonEndIn" desc="查询炉内未装炉完成的计划">
    <![CDATA[
       SELECT JUDGE_STOVE_NO FROM MIL_REFUR_RESULT WHERE IS_START = ? and PLINE_CODE = ?
		   
        ]]>
	</query>
	
	
<query id = "FrmReFurResult.RackQueryForHeatNo" desc = "再加热炉跟踪信息查询">
 <![CDATA[
 SELECT SEQ,
       MAT_NO,
       LOT_NO,
       STOVE_NO,
       JUDGE_STOVE_NO,
       STEELCODE,
       STEELNAME,
       GRADECODE,
       GRADENAME,
       PLINE_CODE,
       END_TIME,
       DECODE(STATUS, '1', '剔除', '0', '正常轧制') STATUS,
       TO_CHAR(IN_REFUR_TIME, 'YYYY-MM-DD HH24:MI:SS') IN_REFUR_TIME,
       IN_REFUR_TEMP,
       TO_CHAR(OUT_REFUR_TIME, 'YYYY-MM-DD HH24:MI:SS') OUT_REFUR_TIME,
       OUT_REFUR_TEMP,
       GROUP_FLAG,
       BEFORE_HEAT_NO,
       BEFORE_MAT_NO,
       IN_USER,
       REMARK,
       COL_MODE,
       TO_CHAR(COL_TIME, 'YYYY-MM-DD HH24:MI:SS') COL_TIME,
       COL_USER,
       case COL_SHIFT
         WHEN '0' THEN
          '常白班'
         WHEN '1' THEN
          '早班'
         WHEN '2' THEN
          '中班'
         WHEN '3' THEN
          '夜班'
       end as COL_SHIFT,
       case COL_GROUP
         WHEN '1' THEN
          '甲'
         WHEN '2' THEN
          '乙'
         WHEN '3' THEN
          '丙'
         WHEN '4' THEN
          '丁'
       end as COL_GROUP,
       case IN_SHIFT
         WHEN '0' THEN
          '常白班'
         WHEN '1' THEN
          '早班'
         WHEN '2' THEN
          '中班'
         WHEN '3' THEN
          '夜班'
       end as IN_SHIFT,
       case IN_GROUP
         WHEN '1' THEN
          '甲'
         WHEN '2' THEN
          '乙'
         WHEN '3' THEN
          '丙'
         WHEN '4' THEN
          '丁'
       end as IN_GROUP,
       case OUT_CHANGE_FLAG
         WHEN '1' THEN
          '出炉接班确认'
         WHEN '2' THEN
          '出炉交班待确认'
       end as OUT_CHANGE_FLAG,
       case IN_CHANGE_FLAG
         WHEN '1' THEN
          '入炉接班确认'
         WHEN '2' THEN
          '入炉交班待确认'
       end as IN_CHANGE_FLAG,
       '入炉交班' IN_CHANGE_NUM,
       '出炉交班' OUT_CHANGE_NUM,
       '入炉接班确认' BTNINCHANGECOM,
       '出炉接班确认' BTNOUTCHANGECOM
  FROM MIL_REFUR_RACK
 WHERE JUDGE_STOVE_NO = ?
   AND PRO_PLAN_ID  || '&' LIKE '%' || ? || '%'
   AND GX_PLAN_NO  || '&' LIKE '%' || ? || '%'
 order by status, SEQ
 ]]>
</query>
<query id = "FrmReFurResult.scrapNumQuery" desc = "查询再入炉实绩表剔除支数">
<![CDATA[
SELECT COUNT(1) SCRAP_NUM
  FROM MIL_SLAB_SCRAP_SEQ T
 WHERE T.JUDGE_STOVE_NO = ?
   AND T.PRO_PLAN_ID  || '&' LIKE '%' || ? || '%'
   AND T.GX_PLAN_NO  || '&' LIKE '%' || ? || '%'
   AND T.PROCESS_NO = '5'
 ]]>
</query>



<query id = "FrmReFurResult.rackDelete" desc = "剔除再加热炉跟踪表信息">
UPDATE MIL_REFUR_RACK
   SET STATUS = '#STATUS#', SCRAP_TIME = SYSDATE
 WHERE JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
   AND NVL(PRO_PLAN_ID, '/') = NVL('#PRO_PLAN_ID#', '/')
   AND NVL(GX_PLAN_NO, '/') = NVL('#GX_PLAN_NO#', '/')
   AND SEQ = '#SEQ#'
 </query>
 <query id = "FrmReFurResult.resultScrapNumUpdate" desc = "修改实绩表轧废支数">
<![CDATA[
      	UPDATE MIL_REFUR_RESULT
   SET SCRAP_NUM   = '#SCRAP_NUM#',
       OUT_FUR_NUM =
       (case Nvl(OUT_FUR_NUM, 0)
         WHEN 0 THEN
          0
         else
          OUT_FUR_NUM - 1
       END)
 WHERE JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
   AND NVL(PRO_PLAN_ID, '/') = NVL('#PRO_PLAN_ID#', '/')
   AND NVL(GX_PLAN_NO, '/') = NVL('#GX_PLAN_NO#', '/')
        ]]>
</query>

	<query id="FrmReFurResult.InFurTimeQuery" desc="查询炉次最后一支入炉时间">
    <![CDATA[
        select LAST_IN_TIME from mil_refur_result where judge_stove_no = ?
		    
        ]]>
	</query>

<query id = "FrmReFurResult.insertScrapSlabSeq" desc = "新增序号剔除表">
INSERT INTO MIL_SLAB_SCRAP_SEQ
  (JUDGE_STOVE_NO,
   PROCESS_NO,
   SEQ,
   TIME,
   REMARK,
   COL_USER,
   COL_SHIFT,
   COL_GROUP,
   PRO_PLAN_ID,
   GX_PLAN_NO)
VALUES
  ('#JUDGE_STOVE_NO#',
   '5',
   '#SEQ#',
   SYSDATE,
   '',
   '#COL_USER#',
   '#COL_SHIFT#',
   '#COL_GROUP#',
   '#PRO_PLAN_ID#',
   '#GX_PLAN_NO#')
</query>
<query id="FrmReFurResult.UpdateFirstInFurTime" desc="修改第一支坯料入炉时间">
        <![CDATA[
        UPDATE MIL_REFUR_RESULT SET 
        FIRST_IN_TIME = sysdate
        WHERE 
        JUDGE_STOVE_NO = ?
        ]]>
	</query>
	<query id="FrmReFurResult.UpdateLastInFurTime" desc="修改最后一支坯料入炉时间">
        <![CDATA[
        UPDATE MIL_REFUR_RESULT SET 
        LAST_IN_TIME = sysdate
        WHERE 
        JUDGE_STOVE_NO = ?
        ]]>
	</query>
	
	<query id="FrmReFurResult.UpdateFirstOutFurTime" desc="修改第一支坯料出炉时间">
        <![CDATA[
        UPDATE MIL_REFUR_RESULT SET 
        FIRST_OUT_TIME = sysdate
        WHERE 
        JUDGE_STOVE_NO = ?
        ]]>
	</query>
	<query id="FrmReFurResult.UpdateLastOutFurTime" desc="修改最后一支坯料出炉时间">
        <![CDATA[
        UPDATE MIL_REFUR_RESULT SET 
        LAST_OUT_TIME = sysdate
        WHERE 
        JUDGE_STOVE_NO = ?
        ]]>
	</query>
	
	<query id = "FrmReFurResult.resultSave" desc = "保存再入炉实绩">
	 <![CDATA[
        UPDATE MIL_REFUR_RESULT
        SET 
        SCRAP_REASON = '#SCRAP_REASON#',
        PROCESS_ROUTE = '#PROCESS_ROUTE#',
        STEPPING_RHYTHM = '#STEPPING_RHYTHM#',
        TRANSFER_RHYTHM = '#TRANSFER_RHYTHM#',
        FIRST_IN_TIME=to_date('#FIRST_IN_TIME#','yyyy-mm-dd hh24:mi:ss'),
        LAST_IN_TIME=to_date('#LAST_IN_TIME#','yyyy-mm-dd hh24:mi:ss'),
        FIRST_OUT_TIME=to_date('#FIRST_OUT_TIME#','yyyy-mm-dd hh24:mi:ss'),
        LAST_OUT_TIME=to_date('#LAST_OUT_TIME#','yyyy-mm-dd hh24:mi:ss'),
        FIRST_IN_TEMP = '#FIRST_IN_TEMP#',
        LAST_IN_TEMP = '#LAST_IN_TEMP#',
        FIRST_OUT_TEMP = '#FIRST_OUT_TEMP#',
        LAST_OUT_TEMP = '#LAST_OUT_TEMP#',
        SET_FUR_TEMP = '#SET_FUR_TEMP#',
        IN_FUR_NUM = '#IN_FUR_NUM#',
        SCRAP_NUM = '#SCRAP_NUM#',
        LHEAT_CRUVE1 = '#LHEAT_CRUVE1#',
        LHEAT_CRUVE2 = '#LHEAT_CRUVE2#',
        LHEAT_CRUVE3 = '#LHEAT_CRUVE3#',
        LHEAT_CRUVE4 = '#LHEAT_CRUVE4#',
        LHEAT_CRUVE5 = '#LHEAT_CRUVE5#',
        LHEAT_CRUVE6 = '#LHEAT_CRUVE6#',
        LHEAT_CRUVE7 = '#LHEAT_CRUVE7#',
        LHEAT_CRUVE8 = '#LHEAT_CRUVE8#',
        ACTUAL_LENGTH_OF_WASTE_PIPE = '#ACTUAL_LENGTH_OF_WASTE_PIPE#',
        RESIDUAL_OXYGEN = '#RESIDUAL_OXYGEN#',
        FUR_PRESS = '#FUR_PRESS#',
        WIND_PRESS = '#WIND_PRESS#',
        GAS_PRESS = '#GAS_PRESS#',
        REMARK = '#REMARK#',
        OUT_FUR_NUM = '#OUT_FUR_NUM#',
        CHANGECLASSNUM = '#CHANGECLASSNUM#',
        BURNINGRATE = '#BURNINGRATE#',
        BEGIN_ROLLING_TEMP='#BEGIN_ROLLING_TEMP#',
        START_TIME=to_date('#START_TIME#','yyyy-mm-dd hh24:mi:ss'),
        END_TIME=to_date('#END_TIME#','yyyy-mm-dd hh24:mi:ss')
        WHERE
        1=1
        AND  JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
 ]]>
	</query>
	
		<query id="FrmReFurResult.UpdateEndTimeForRack" desc="保存跟踪表结炉时间">
    <![CDATA[
        update  mil_refur_rack  set OUT_REFUR_TIME = to_date('#END_TIME#','yyyy-mm-dd hh24:mi:ss') where 
        JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
       
        AND OUT_REFUR_TIME = (SELECT MAX(OUT_REFUR_TIME) FROM mil_refur_rack WHERE JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
      )
    
      ]]>
	</query>
	
	<query id = "FrmReFurResult.endStoveForMainPlan" desc = "再入加热炉结炉修改主计划">
<![CDATA[
      	 UPDATE MIL_PLAN
   SET NODE_STATUS = '50'
 WHERE JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
   AND NVL(PRO_PLAN_ID, '/') = NVL('#PRO_PLAN_ID#', '/')
   AND NVL(GX_PLAN_NO, '/') = NVL('#GX_PLAN_NO#', '/')
        ]]>
</query>
<query id = "FrmReFurResult.endStoveForResult" desc = "再入加热炉结炉修改实绩信息">
<![CDATA[
      	UPDATE MIL_REFUR_RESULT
   SET PROCESS_ROUTE               = '#PROCESS_ROUTE#',
       OUT_FUR_TIME                = SYSDATE,
       STEPPING_RHYTHM             = '#STEPPING_RHYTHM#',
       TRANSFER_RHYTHM             = '#TRANSFER_RHYTHM#',
       FIRST_IN_TEMP               = '#FIRST_IN_TEMP#',
       LAST_IN_TEMP                = '#LAST_IN_TEMP#',
       FIRST_OUT_TEMP              = '#FIRST_OUT_TEMP#',
       LAST_OUT_TEMP               = '#LAST_OUT_TEMP#',
       FIRST_IN_TIME               = to_date('#FIRST_IN_TIME#',
                                             'yyyy-mm-dd hh24:mi:ss'),
       LAST_IN_TIME                = to_date('#LAST_IN_TIME#',
                                             'yyyy-mm-dd hh24:mi:ss'),
       FIRST_OUT_TIME              = to_date('#FIRST_OUT_TIME#',
                                             'yyyy-mm-dd hh24:mi:ss'),
       LAST_OUT_TIME               = sysdate,
       SET_FUR_TEMP                = '#SET_FUR_TEMP#',
       IN_FUR_NUM                  = '#IN_FUR_NUM#',
       SCRAP_NUM                   = '#SCRAP_NUM#',
       LHEAT_CRUVE1                = '#LHEAT_CRUVE1#',
       LHEAT_CRUVE2                = '#LHEAT_CRUVE2#',
       LHEAT_CRUVE3                = '#LHEAT_CRUVE3#',
       LHEAT_CRUVE4                = '#LHEAT_CRUVE4#',
       LHEAT_CRUVE5                = '#LHEAT_CRUVE5#',
       LHEAT_CRUVE6                = '#LHEAT_CRUVE6#',
       LHEAT_CRUVE7                = '#LHEAT_CRUVE7#',
       LHEAT_CRUVE8                = '#LHEAT_CRUVE8#',
       ACTUAL_LENGTH_OF_WASTE_PIPE = '#ACTUAL_LENGTH_OF_WASTE_PIPE#',
       RESIDUAL_OXYGEN             = '#RESIDUAL_OXYGEN#',
       FUR_PRESS                   = '#FUR_PRESS#',
       WIND_PRESS                  = '#WIND_PRESS#',
       GAS_PRESS                   = '#GAS_PRESS#',
       START_TIME                  = to_date('#START_TIME#',
                                             'yyyy-mm-dd hh24:mi:ss'),
       END_TIME                    = SYSDATE,
       EXECUTIVE_PRODUCER          = '#EXECUTIVE_PRODUCER#',
       PRODUCER_TIME               = SYSDATE,
       PRODUCER_TEL                = '#PRODUCER_TEL#',
       REMARK                      = '#REMARK#',
       OUT_FUR_NUM                 = '#OUT_FUR_NUM#',
       NODE_FUR_FLAG               = '#NODE_FUR_FLAG#',
       CHANGECLASSNUM              = '#CHANGECLASSNUM#',
       BURNINGRATE                 = '#BURNINGRATE#',
       BEGIN_ROLLING_TEMP          = '#BEGIN_ROLLING_TEMP#',
       COL_SHIFT                   = '#COL_SHIFT#',
       COL_GROUP                   = '#COL_GROUP#',
       COL_USER                    = '#COL_USER#',
       USER_ID                     = '#USER_ID#',
       IS_START                    = 3,
       QA_TON                      = '#QA_TON#'
 WHERE 1 = 1
   AND JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
   AND NVL(PRO_PLAN_ID, '/') = NVL('#PRO_PLAN_ID#', '/')
   AND NVL(GX_PLAN_NO, '/') = NVL('#GX_PLAN_NO#', '/')
        ]]>
</query>
<query id = "FrmReFurResult.getRollingRackSeq" desc = "查询该毛管是否在连轧被剔除">
SELECT T.STATUS FROM MIL_ROLLING_RACK T WHERE T.JUDGE_STOVE_NO = ? AND T.SEQ = ?
</query>


<query id = "FrmReFurResult.UpdateNodeRackOutShift" desc = "结炉修改跟踪表出炉班次班组">
update MIL_REFUR_RACK
   set COL_SHIFT = '#COL_SHIFT#',
       COL_GROUP = '#COL_GROUP#',
       COL_USER  = '#COL_USER#'
 where JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
   AND NVL(PRO_PLAN_ID, '/') = NVL('#PRO_PLAN_ID#', '/')
   AND NVL(GX_PLAN_NO, '/') = NVL('#GX_PLAN_NO#', '/')
   and COL_SHIFT is null
   and COL_GROUP is null
   AND MAT_NO is not null
</query> 

<query id = "FrmReFurResult.UpdateNodeRackInShift" desc = "结炉修改跟踪表入炉班次班组">
update MIL_REFUR_RACK
   set IN_SHIFT = '#COL_SHIFT#', IN_GROUP = '#COL_GROUP#'
 where JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
   AND NVL(PRO_PLAN_ID, '/') = NVL('#PRO_PLAN_ID#', '/')
   AND NVL(GX_PLAN_NO, '/') = NVL('#GX_PLAN_NO#', '/')
   and IN_SHIFT is null
   and IN_GROUP is null
   AND MAT_NO is not null
</query>

<query id = "FrmReFurResult.UpdateNodeRackEndTime" desc = "结炉修改跟踪表结炉时间">
update MIL_REFUR_RACK
   set OUT_REFUR_TIME = SYSDATE
 where JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
   AND NVL(PRO_PLAN_ID, '/') = NVL('#PRO_PLAN_ID#', '/')
   AND NVL(GX_PLAN_NO, '/') = NVL('#GX_PLAN_NO#', '/')
   and OUT_REFUR_TIME is null
</query>


<query id="FrmReFurResult.UpdateInFurShift" desc="修改主计划结炉状态">
    <![CDATA[
       update mil_refur_rack set IN_SHIFT = ?,IN_GROUP =?,IN_USER = ? WHERE JUDGE_STOVE_NO = ? AND Result_no = ? 
			 and  IN_SHIFT is null  AND IN_GROUP is null
		   
        ]]>
	</query>

<query id="FrmReFurResult.GetReFurResultNodeQuery" desc="查询结炉实绩">
  <![CDATA[
 SELECT 
       a.BURNINGRATE,
       a.OUT_FUR_NUM,
       REGEXP_REPLACE(a.JUDGE_STOVE_NO, '-.*', '') as STOVE_NO,
       a.RESULT_NO,
       a.LOT_NO,
       a.JUDGE_STOVE_NO,
       a.PLINE_CODE,
       a.IN_FUR_NUM,
       a.SCRAP_NUM,
       TO_CHAR(a.START_TIME, 'YYYY-MM-DD HH24:MI:SS') START_TIME,
       TO_CHAR(a.END_TIME, 'YYYY-MM-DD HH24:MI:SS') END_TIME,
        b.DB_HEIGHT,
	       c.BURNINGRATE,
	       a.qa_ton,
	       a.remark,
	       a.col_shift,
	       a.col_group,
	       a.CHANGECLASSNUM,
	       a.OUT_CHANGE_NUM,
	       a.col_user
       FROM MIL_REFUR_RESULT a, mil_plan b,mil_refur_result c
       WHERE
       1=1
       AND b.PLINE_CODE=?
       AND a.COL_SHIFT=?
       AND a.COL_GROUP=?
       AND a.END_TIME BETWEEN TO_DATE(?,'YYYY-MM-DD HH24:MI:SS') AND TO_DATE(?,'YYYY-MM-DD HH24:MI:SS')
       AND a.NODE_FUR_FLAG='1'
       AND a.JUDGE_STOVE_NO = b.JUDGE_STOVE_NO
       and b.JUDGE_STOVE_NO = c.JUDGE_STOVE_NO
       	order by a.end_time
       	  ]]>
</query>


<query id="FrmReFurResult.insertFurnacesReslut" desc="插入荒管剔除待处理实绩表">
    <![CDATA[
      DECLARE
  V_OFFLINE_NUM    MIL_FURNACES_RESLUT.OFFLINE_NUM%TYPE := NULL;
  V_ZP_HEIGHT      MIL_FURNACES_RESLUT.ZP_HEIGHT%TYPE := NULL;
  V_COUNT          MIL_FURNACES_RESLUT.OFFLINE_NUM%TYPE := NULL;
  V_JUDGE_STOVE_NO MIL_FURNACES_RESLUT.JUDGE_STOVE_NO%TYPE := ?;
  V_PLINE_CODE     MIL_FURNACES_RESLUT.PLINE_CODE%TYPE := ?;
  V_PRO_PLAN_ID    MIL_FURNACES_RESLUT.PRO_PLAN_ID%TYPE := ?;
  V_GX_PLAN_NO     MIL_FURNACES_RESLUT.GX_PLAN_NO%TYPE := ?;
BEGIN

  SELECT T.SCRAP_NUM
    INTO V_OFFLINE_NUM
    FROM MIL_REFUR_RESULT T
   WHERE T.JUDGE_STOVE_NO = V_JUDGE_STOVE_NO
     AND NVL(T.PRO_PLAN_ID,'/') = NVL(V_PRO_PLAN_ID,'/')
     AND NVL(T.GX_PLAN_NO,'/') = NVL(V_GX_PLAN_NO,'/')
     AND T.PLINE_CODE = V_PLINE_CODE;

  SELECT T.QA_TON * T.SCRAP_NUM / T.IN_FUR_NUM
    INTO V_ZP_HEIGHT
    FROM MIL_REFUR_RESULT T
   WHERE T.JUDGE_STOVE_NO = V_JUDGE_STOVE_NO
     AND NVL(T.PRO_PLAN_ID,'/') = NVL(V_PRO_PLAN_ID,'/')
     AND NVL(T.GX_PLAN_NO,'/') = NVL(V_GX_PLAN_NO,'/')
     AND T.PLINE_CODE = V_PLINE_CODE;

  SELECT COUNT(1)
    INTO V_COUNT
    FROM MIL_FURNACES_RESLUT T
   WHERE T.JUDGE_STOVE_NO = V_JUDGE_STOVE_NO
     AND NVL(T.PRO_PLAN_ID,'/') = NVL(V_PRO_PLAN_ID,'/')
     AND NVL(T.GX_PLAN_NO,'/') = NVL(V_GX_PLAN_NO,'/')
     AND T.PLINE_CODE = V_PLINE_CODE;
  --判断是否有待处理支数
  IF (V_OFFLINE_NUM > 0) THEN
    --判断炉号是否已经存在
    IF (V_COUNT = 0) THEN
    
      FOR MYROW IN (SELECT *
                      FROM MIL_PLAN T
                     WHERE T.JUDGE_STOVE_NO = V_JUDGE_STOVE_NO
                       AND NVL(T.PRO_PLAN_ID,'/') = NVL(V_PRO_PLAN_ID,'/')
                       AND NVL(T.GX_PLAN_NO,'/') = NVL(V_GX_PLAN_NO,'/')
                       AND T.PLINE_CODE = V_PLINE_CODE) LOOP
        INSERT INTO MIL_FURNACES_RESLUT
          (LOT_NO,
           STOVE_NO,
           JUDGE_STOVE_NO,
           PLINE_CODE,
           OFFLINE_NUM,
           
           STATUS,
           COL_TIME,
           COL_USER,
           COL_SHIFT,
           COL_GROUP,
           ZP_HEIGHT,
           PRODUCNAME,
           STEELCODE,
           
           STEELNAME,
           GRADECODE,
           GRADENAME,
           SPEC_CODE,
           SPEC_NAME,
           
           MODEL_CODE,
           MODEL_DESC,
           STD_CODE,
           STD_NAME,
           STD_STYLE,
           
           STD_STYLE_DESC,
           CONTRACT_NO,
           PRODUCCODE,
           ACT_LEN_RANGE,
           TARGET,
           PRO_PLAN_ID,
           GX_PLAN_NO)
        VALUES
          (MYROW.LOT_NO,
           MYROW.STOVE_NO,
           MYROW.JUDGE_STOVE_NO,
           MYROW.PLINE_CODE,
           V_OFFLINE_NUM,
           
           '0',
           SYSDATE,
           ?,
           ?,
           ?,
           V_ZP_HEIGHT,
           MYROW.VARIETIES,
           MYROW.STEELCODE,
           
           MYROW.STEELNAME,
           MYROW.GRADECODE,
           MYROW.GRADENAME,
           MYROW.PIPE_SIZE_CODE,
           MYROW.PIPE_SIZE,
           
           MYROW.BUCKLE_TYPE_CODE,
           MYROW.BUCKLE_TYPE,
           MYROW.ROLL_STANDRAD_CODE,
           MYROW.ROLL_STANDRAD,
           MYROW.STD_STYLE,
           
           MYROW.STD_STYLE_DESC,
           MYROW.CONTRACT_NO,
           MYROW.VARIETIES_CODE,
           MYROW.LENGTHCP,
           MYROW.TARGET,
           MYROW.PRO_PLAN_ID,
           MYROW.GX_PLAN_NO);
      END LOOP;
    ELSE
      UPDATE MIL_FURNACES_RESLUT T
         SET T.OFFLINE_NUM = V_OFFLINE_NUM,
             T.ZP_HEIGHT   = V_ZP_HEIGHT,
             T.COL_TIME    = SYSDATE
       WHERE T.JUDGE_STOVE_NO = V_JUDGE_STOVE_NO
         AND NVL(T.PRO_PLAN_ID,'/') = NVL(V_PRO_PLAN_ID,'/')
         AND NVL(T.GX_PLAN_NO,'/') = NVL(V_GX_PLAN_NO,'/')
         AND T.PLINE_CODE = V_PLINE_CODE;
    END IF;
  END IF;
END;
        ]]>
	</query>
	
	<query id="FrmReFurResult.deleteFurnacesReslut" desc="删除荒管剔除待处理实绩表">
  <![CDATA[
 DELETE FROM MIL_FURNACES_RESLUT T
 WHERE T.JUDGE_STOVE_NO = ?
   AND T.PLINE_CODE = ?
   AND T.PRO_PLAN_ID  || '&' LIKE '%' || ? || '%'
   AND T.GX_PLAN_NO  || '&' LIKE '%' || ? || '%'
       	  ]]>
</query>

<query id="FrmReFurResult.queryFurnacesReslut" desc="删除荒管剔除待处理实绩表">
  <![CDATA[
 SELECT T.ZP_FLAG
  FROM MIL_FURNACES_RESLUT T
 WHERE T.JUDGE_STOVE_NO = ?
   AND T.PLINE_CODE = ?
   AND T.PRO_PLAN_ID  || '&' LIKE '%' || ? || '%'
   AND T.GX_PLAN_NO  || '&' LIKE '%' || ? || '%'
       	  ]]>
</query>
	
	
</queryMap>
