<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="加热炉实绩操作">

<query id="FurResult.SingleFurResultQuery" desc="加热炉实绩">
        <![CDATA[
      	SELECT RESULT_NO,
       LOT_NO,
       STOVE_NO,
       JUDGE_STOVE_NO,
       PLINE_CODE,
       IN_FUR_LENGTH,
       IN_FUR_NUM,
       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,
       OUT_FUR_NUM,
       SCRAP_NUM,
       SCRAP_REASON,
       BURNNING_RATE,
       CHANGE_NUM,
       SLAB_DIAMETER,
       SLAB_LENGTH,
       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,
       FIRST_SLAB_OUT_TEMP,
       LAST_SLAB_OUT_TEMP,
       SET_FUR_TEMP,
       LHEAT_CRUVE1,
       LHEAT_CRUVE2,
       LHEAT_CRUVE3,
       LHEAT_CRUVE4,
       LHEAT_CRUVE5,
       LHEAT_CRUVE6,
       LHEAT_CRUVE7,
       LHEAT_CRUVE8,
       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,
       RHYTHM,
       COL_MODE,
       TO_CHAR(COL_TIME, 'YYYY-MM-DD HH24:MI:SS') COL_TIME,
       COL_USER,
       COL_SHIFT,
       COL_GROUP,
       OUT_CHANGE_NUM,
       PRO_PLAN_ID,
       GX_PLAN_NO
  FROM MIL_FUR_RESULT
 WHERE JUDGE_STOVE_NO = ?
   AND PRO_PLAN_ID  || '&' LIKE '%' || ? || '%'
   AND GX_PLAN_NO  || '&' LIKE '%' || ? || '%'
        ]]>
	</query>
	
	<query id="FurResult.InFurTimeQuery" desc="查询炉次最后一支入炉时间">
    <![CDATA[
        select LAST_IN_TIME from mil_fur_result where judge_stove_no = ?
		    
        ]]>
	</query>
	
	
	<query id="FurResult.getIsStartStats" desc=" 查询炉计划状态">
    <![CDATA[
        select IS_START
  from mil_fur_result
 where judge_stove_no = ?
   and Result_no = ?
   AND PRO_PLAN_ID  || '&' LIKE '%' || ? || '%'
   AND GX_PLAN_NO  || '&' LIKE '%' || ? || '%'
        ]]>
	</query>

	
	<query id="FurResult.UpdateMainPlanNodeStatue" desc="修改主计划结炉状态">
    <![CDATA[
        update MIL_PLAN t set t.NODE_STATUS ='#STATUS#',T.STATUS = '20'
        where t.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#' 
		    
        ]]>
	</query>
	<query id="FurResult.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) >= 2)) 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
                          '锯切完成'
                       END AS NODE_STATUS,
                       A.FEED_TIME,
                       case Nvl((select b.IS_START
                              FROM mil_fur_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_FUR_RESULT B
                 WHERE A.JUDGE_STOVE_NO = B.JUDGE_STOVE_NO(+)
                   AND A.IS_LOAD = '1'
                   AND A.BACK_SLAB_FLAG <> '2'
                   AND A.PLINE_CODE = '#PLINE_CODE#'
                   AND A.NODE_STATUS < 20) t,
               MIL_FEEDSAW_RESULT f
         WHERE IS_START in ('已开始入炉', '未开始入炉')
           and t.ID = f.result_no
           AND T.JUDGE_STOVE_NO = F.JUDGE_STOVE_NO #something1#
         order by T.feed_time, f.start_time) t1
 where t1.PLAN_COUNT > 0

        ]]>
	</query>
	
	<query id="FurResult.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
          '锯切完成'
       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_FUR_RESULT B, MIL_FEEDSAW_RESULT C
 WHERE A.JUDGE_STOVE_NO = B.JUDGE_STOVE_NO
   AND A.PLINE_CODE = '#PLINE_CODE#'
   AND A.NODE_STATUS < 20
   AND A.BACK_SLAB_FLAG <> '2'
   AND A.IS_LOAD = '1'
   AND B.IS_START > 0
   AND A.ID = C.RESULT_NO
   AND A.JUDGE_STOVE_NO = C.JUDGE_STOVE_NO
   #something1#
 ORDER BY A.feed_time
        ]]>
	</query>
	
		<query id="FurResult.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,
               C.START_TIME,
               ((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) >= 2)) plan_count,
               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
                  '人工质检完成'
               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_FUR_RESULT B, MIL_FEEDSAW_RESULT C
         WHERE A.JUDGE_STOVE_NO = B.JUDGE_STOVE_NO
           AND A.PLINE_CODE = '#PLINE_CODE#'
           AND A.NODE_STATUS > 10
           AND A.BACK_SLAB_FLAG <> '2'
           AND A.ID = C.RESULT_NO
           AND A.JUDGE_STOVE_NO = C.JUDGE_STOVE_NO
           #something1#
         ORDER BY A.feed_time,C.START_TIME) t1
 where t1.PLAN_COUNT > 0
        ]]>
	</query>
	
	
		<query id="FurResult.InFurNonEndIn" desc="查询炉内未装炉完成的计划">
    <![CDATA[
       SELECT JUDGE_STOVE_NO FROM MIL_FUR_RESULT WHERE IS_START = ? and PLINE_CODE = ?
		   
        ]]>
	</query>
	
	
	
			<query id="FurResult.InFurStatus" desc="查询炉次炉内状态">
    <![CDATA[
       SELECT IS_START FROM MIL_FUR_RESULT WHERE JUDGE_STOVE_NO = ?
		   
        ]]>
	</query>
	
	<query id="FurResult.UpdateInFurShift" desc="修改主计划结炉状态">
    <![CDATA[
       update mil_fur_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="FurResult.AddFurResult" desc="新增加热炉实绩">
    <![CDATA[
        INSERT INTO MIL_FUR_RESULT
  (EXECUTIVE_PRODUCER,
   PRODUCER_TIME,
   PRODUCER_TEL,
   
   REMARK,
   RHYTHM,
   COL_MODE,
   COL_TIME,
   COL_USER,
   COL_SHIFT,
   COL_GROUP,
   BURNNING_RATE,
   RESULT_NO,
   LOT_NO,
   STOVE_NO,
   JUDGE_STOVE_NO,
   PLINE_CODE,
   IN_FUR_LENGTH,
   IN_FUR_NUM,
   IN_FUR_TIME,
   
   SCRAP_REASON,
   SLAB_DIAMETER,
   SLAB_LENGTH,
   FIRST_IN_TIME,
   FIRST_SLAB_OUT_TEMP,
   LAST_SLAB_OUT_TEMP,
   SET_FUR_TEMP,
   LHEAT_CRUVE1,
   LHEAT_CRUVE2,
   LHEAT_CRUVE3,
   LHEAT_CRUVE4,
   LHEAT_CRUVE5,
   LHEAT_CRUVE6,
   LHEAT_CRUVE7,
   LHEAT_CRUVE8,
   RESIDUAL_OXYGEN,
   FUR_PRESS,
   WIND_PRESS,
   GAS_PRESS,
   FIRST_IN_SHIFT,
   FIRST_IN_GROUP,
   START_TIME,
   PRO_PLAN_ID,
   GX_PLAN_NO)
VALUES
  ('#EXECUTIVE_PRODUCER#',
   SYSDATE,
   '#PRODUCER_TEL#',
   
   '#REMARK#',
   '#RHYTHM#',
   '#COL_MODE#',
   SYSDATE,
   '#COL_USER#',
   '#COL_SHIFT#',
   '#COL_GROUP#',
   '#BURNNING_RATE#',
   '#RESULT_NO#',
   '#LOT_NO#',
   '#STOVE_NO#',
   '#JUDGE_STOVE_NO#',
   '#PLINE_CODE#',
   '#IN_FUR_LENGTH#',
   '#IN_FUR_NUM#',
   SYSDATE,
   
   '#SCRAP_REASON#',
   '#SLAB_DIAMETER#',
   '#SLAB_LENGTH#',
   to_date('#FIRST_IN_TIME#', 'yyyy-mm-dd hh24:mi:ss'),
   '#FIRST_SLAB_OUT_TEMP#',
   '#LAST_SLAB_OUT_TEMP#',
   '#SET_FUR_TEMP#',
   '#LHEAT_CRUVE1#',
   '#LHEAT_CRUVE2#',
   '#LHEAT_CRUVE3#',
   '#LHEAT_CRUVE4#',
   '#LHEAT_CRUVE5#',
   '#LHEAT_CRUVE6#',
   '#LHEAT_CRUVE7#',
   '#LHEAT_CRUVE8#',
   '#RESIDUAL_OXYGEN#',
   '#FUR_PRESS#',
   '#WIND_PRESS#',
   '#GAS_PRESS#',
   
   '#FIRST_IN_SHIFT#',
   '#FIRST_IN_GROUP#',
   to_date('#START_TIME#', 'yyyy-mm-dd hh24:mi:ss'),
   '#PRO_PLAN_ID#',
   '#GX_PLAN_NO#')
        ]]>
	</query>
	
	
	<query id="FurResult.UpdateMainPlanStatue" desc="修改主计划 开始状态">
    <![CDATA[
        update MIL_PLAN t
   set t.STATUS = '#STATUS#'
 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="FurResult.UpdateFurResultEndTime" desc="结炉时修改结束时间和最后一支出炉时间">
    <![CDATA[
        update MIL_FUR_RESULT t set t.END_TIME = SYSDATE , T.LAST_OUT_TIME = SYSDATE
        where t.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#' 
		    
        ]]>
	</query>
	
	
	<query id="FurResult.UpdateInChangeShit" desc="结炉时修改结入炉班次班组">
    <![CDATA[
        update MIL_FUR_RACK t set t.IN_SHIFT = '#COL_SHIFT#' ,t.IN_USER='#COL_USER#', T.IN_GROUP = '#COL_GROUP#'
        where t.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#' AND t.IN_SHIFT is null AND  T.IN_GROUP is null and MAT_NO IS NOT NULL
		    
        ]]>
	</query>
	
	<query id="FurResult.UpdateOutChangeShit" desc="结炉时修改结出炉班次班组">
    <![CDATA[
        update MIL_FUR_RACK t set t.COL_SHIFT = '#COL_SHIFT#' ,t.COL_USER = '#COL_USER#', T.COL_GROUP = '#COL_GROUP#',t.OUT_FUR_TIME = sysdate 
        where t.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#' AND t.COL_SHIFT is null AND  T.COL_GROUP is null AND MAT_NO is not null
		    
        ]]>
	</query>
	
	
	<query id="FurResult.UpdateEndTime" desc="结炉时修改结出炉时间">
    <![CDATA[
        update MIL_FUR_RACK t set t.OUT_FUR_TIME = sysdate 
        where t.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#' AND t.END_TIME is null 
		    
        ]]>
	</query>
	
	<query id="FurResult.SingleFurNodeResult" desc="查询上料锯切实绩表">
        <![CDATA[
       SELECT 
       b.DB_HEIGHT,
       a.CHANGE_NUM,
       a.OUT_CHANGE_NUM,
       a.BURNNING_RATE,
       a.RESULT_NO,
       a.LOT_NO,
       a.STOVE_NO,
       a.JUDGE_STOVE_NO,
       a.PLINE_CODE,
       a.IN_FUR_LENGTH,
       a.IN_FUR_NUM,
       TO_CHAR(a.IN_FUR_TIME, 'YYYY-MM-DD HH24:MI:SS') IN_FUR_TIME,
       TO_CHAR(a.OUT_FUR_TIME, 'YYYY-MM-DD HH24:MI:SS') OUT_FUR_TIME,
       a.OUT_FUR_NUM,
       a.SCRAP_NUM,
       a.SCRAP_REASON,
       a.SLAB_DIAMETER,
       a.SLAB_LENGTH,
       TO_CHAR(a.FIRST_IN_TIME, 'YYYY-MM-DD HH24:MI:SS') FIRST_IN_TIME,
       TO_CHAR(a.LAST_IN_TIME, 'YYYY-MM-DD HH24:MI:SS') LAST_IN_TIME,
       TO_CHAR(a.FIRST_OUT_TIME, 'YYYY-MM-DD HH24:MI:SS') FIRST_OUT_TIME,
       TO_CHAR(a.LAST_OUT_TIME, 'YYYY-MM-DD HH24:MI:SS') LAST_OUT_TIME,
       a.FIRST_SLAB_OUT_TEMP,
       a.LAST_SLAB_OUT_TEMP,
       a.SET_FUR_TEMP,
       a.LHEAT_CRUVE1,
       a.LHEAT_CRUVE2,
       a.LHEAT_CRUVE3,
       a.LHEAT_CRUVE4,
       a.LHEAT_CRUVE5,
       a.LHEAT_CRUVE6,
       a.LHEAT_CRUVE7,
       a.LHEAT_CRUVE8,
       a.RESIDUAL_OXYGEN,
       a.FUR_PRESS,
       a.WIND_PRESS,
       a.GAS_PRESS,
       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,
       a.EXECUTIVE_PRODUCER,
       TO_CHAR(a.PRODUCER_TIME, 'YYYY-MM-DD HH24:MI:SS') PRODUCER_TIME,
       a.PRODUCER_TEL,
       a.NODE_FUR_FLAG,
       a.REMARK,
       a.RHYTHM,
       a.COL_MODE,
       to_char(a.COL_TIME, 'YYYY-MM-DD HH24:MI:SS') COL_TIME,
       a.COL_USER,
       a.COL_SHIFT,
       a.COL_GROUP,
       A.QA_TON
 FROM MIL_FUR_RESULT  a, MIL_PLAN b
 WHERE
 		a.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 a.RESULT_NO = b.ID
	   	order by a.end_time
		    
        ]]>
	</query>

	
	<query id="FurResult.UpdateFurResult" desc="保存加热炉实绩信息">
    <![CDATA[
        UPDATE MIL_FUR_RESULT
   SET BURNNING_RATE       = '#BURNNING_RATE#',
       FIRST_SLAB_OUT_TEMP = '#FIRST_SLAB_OUT_TEMP#',
       LAST_SLAB_OUT_TEMP  = '#LAST_SLAB_OUT_TEMP#',
       SET_FUR_TEMP        = '#SET_FUR_TEMP#',
       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#',
       RESIDUAL_OXYGEN     = '#RESIDUAL_OXYGEN#',
       FUR_PRESS           = '#FUR_PRESS#',
       WIND_PRESS          = '#WIND_PRESS#',
       GAS_PRESS           = '#GAS_PRESS#',
       REMARK              = '#REMARK#',
       RHYTHM              = '#RHYTHM#',
       START_TIME          = to_date('#START_TIME#', 'yyyy-mm-dd hh24:mi:ss'),
       END_TIME            = to_date('#END_TIME#', 'yyyy-mm-dd hh24:mi:ss'),
       FIRST_IN_TIME       = to_date('#FIRST_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'),
       LAST_IN_TIME        = to_date('#LAST_IN_TIME#',
                                     'yyyy-mm-dd hh24:mi:ss')

 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="FurResult.UpdateEndTimeForRack" desc="保存跟踪表结炉时间">
    <![CDATA[
        update mil_fur_rack
   set out_fur_time = to_date('#END_TIME#', 'yyyy-mm-dd hh24:mi:ss')
 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_fur_time =
       (SELECT MAX(out_fur_time)
          FROM mil_fur_rack
         WHERE JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#')
      ]]>
	</query>
		<query id="FurResult.UpdateFurResultForNode" desc="保存加热炉实绩信息">
    <![CDATA[
       UPDATE MIL_FUR_RESULT
   SET CHANGE_NUM          = '#CHANGE_NUM#',
       BURNNING_RATE       = '#BURNNING_RATE#',
       IN_FUR_NUM          = '#IN_FUR_NUM#',
       OUT_FUR_NUM         = '#OUT_FUR_NUM#',
       SCRAP_NUM           = '#SCRAP_NUM#',
       FIRST_SLAB_OUT_TEMP = '#FIRST_SLAB_OUT_TEMP#',
       LAST_SLAB_OUT_TEMP  = '#LAST_SLAB_OUT_TEMP#',
       SET_FUR_TEMP        = '#SET_FUR_TEMP#',
       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#',
       RESIDUAL_OXYGEN     = '#RESIDUAL_OXYGEN#',
       FUR_PRESS           = '#FUR_PRESS#',
       WIND_PRESS          = '#WIND_PRESS#',
       GAS_PRESS           = '#GAS_PRESS#',
       NODE_FUR_FLAG       = '#NODE_FUR_FLAG#',
       REMARK              = '#REMARK#',
       RHYTHM              = '#RHYTHM#',
       START_TIME          = to_date('#START_TIME#', 'yyyy-mm-dd hh24:mi:ss'),
       END_TIME            = sysdate,
       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,
       COL_USER            = '#COL_USER#',
       COL_SHIFT           = '#COL_SHIFT#',
       COL_GROUP           = '#COL_GROUP#',
       QA_TON              = '#QA_TON#',
       USER_ID             = '#USER_ID#',
       IS_START            = '3'
 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="FurResult.UpdateFurStatue" desc="加热炉管坯状态">
        <![CDATA[
         UPDATE MIL_FUR_RACK T
   SET STATUS = '1', SCRAP_TIME = SYSDATE, T.REMARK = '#REMARK#'
 WHERE SEQ = '#SEQ#'
   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="FurResult.UpdateFurScrapNum" desc="修改加热炉实绩表剔除支数">
        <![CDATA[
        UPDATE MIL_FUR_RESULT
   SET SCRAP_NUM   = SCRAP_NUM + 1,
       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="FurResult.UpdateFirstInFurTime" desc="修改第一支坯料入炉时间">
        <![CDATA[
        UPDATE MIL_FUR_RESULT SET 
        FIRST_IN_TIME = sysdate
        WHERE 
        JUDGE_STOVE_NO = ?
        ]]>
	</query>
	<query id="FurResult.UpdateLastOutFurTime" desc="修改最后一支坯料出炉时间">
        <![CDATA[
        UPDATE MIL_FUR_RESULT SET 
        LAST_OUT_TIME = sysdate
        WHERE 
        JUDGE_STOVE_NO = ?
        ]]>
	</query>
	<query id="FurResult.UpdateFirstOutFurTime" desc="修改第一支坯料出炉时间班次班组 温度">
        <![CDATA[
        UPDATE MIL_FUR_RESULT SET 
        FIRST_OUT_TIME = sysdate,
        FIRST_OUT_SHIFT = ?,
        FIRST_OUT_GROUP = ?,
        FIRST_SLAB_OUT_TEMP = ?,
        IS_START = '2'
        WHERE 
        JUDGE_STOVE_NO = ?
        ]]>
	</query>
	<query id="FurResult.UpdateLastInFurTime" desc="修改最后一支坯料入炉时间 班次班组">
        <![CDATA[
        UPDATE MIL_FUR_RESULT SET 
        LAST_IN_TIME = sysdate,
        LAST_IN_SHIFT = ?,
        LAST_IN_GROUP = ?,
		 IS_START = '1'
        WHERE 
        JUDGE_STOVE_NO = ?
        ]]>
	</query>
	
	<query id="FurResult.SingleFeedResultNodeFlagQuery" desc="修改最后一支坯料入炉时间">
        <![CDATA[
        UPDATE MIL_FUR_RESULT SET 
        LAST_IN_TIME = sysdate
        WHERE 
        JUDGE_STOVE_NO = ?
        ]]>
	</query>
	
	
	<query id="FurResult.UpdateFurHistory" desc="修改加热炉历史表管坯状态">
        <![CDATA[
         UPDATE MIL_FUR_HISTORY
   		SET 
        STATUS = '1'
 		WHERE
		SEQ = ?  
		AND  
		JUDGE_STOVE_NO = ?
        ]]>
	</query>
	
	
		<query id="FurResult.ClearShitAfterNode" desc="结炉后清空材料号为空的班次班组">
        <![CDATA[
         UPDATE MIL_FUR_Rack
   		SET 
        IN_SHIFT = '',IN_GROUP = '',IN_USER = '',IN_FUR_TIME = '',COL_SHIFT = '',COL_GROUP = '',COL_USER = '',OUT_FUR_TIME = ''
 		WHERE	
		
		JUDGE_STOVE_NO = ?
		AND RESULT_NO = ?
		AND MAT_NO IS NULL
        ]]>
	</query>
	
	<query id="FurResult.getBurnningRate" desc="得到烧损率">
        <![CDATA[
       select case
         when ? = 'C072' THEN
          CASE
            WHEN (select t1.pass_name
                    from pln_zy_zg_m t1
                   where t1.heat_plan_no = ?) = '383' then
             1.5
            when (select t1.pass_name
                    from pln_zy_zg_m t1
                   where t1.heat_plan_no = ?) = '454' then
             1.8
            else
             T.BURNOUT_RATE
          end
         ELSE
          T.BURNOUT_RATE
       END BURNOUT_RATE
  FROM com_base_pline t
 WHERE pline_code = ?
        ]]>
	</query>
	
	
	<query id="FurResult.FurRackSeqQuery" desc="上料管号队列查询">
        <![CDATA[
     SELECT SEQ,
       MAT_NO,
       LOT_NO,
       STOVE_NO,
       JUDGE_STOVE_NO,
       STEELCODE,
       STEELNAME,
       GRADECODE,
       GRADENAME,
       PLINE_CODE,
       CASE STATUS
         WHEN '0' THEN
          '正常轧制'
         WHEN '1' THEN
          '剔除'
       END AS STATUS,
       TARGET_DIAMETER,
       '剔除管坯' SCRAP_SLAB,
       TARGET_LENGTH,
       TARGET_HEIGHT,
       COL_DIAMETER,
       COL_LENGTH,
       COL_HEIGHT,
       TO_CHAR(IN_FUR_TIME, 'YYYY-MM-DD HH24:MI:SS') IN_FUR_TIME,
       START_POS,
       MAT_POS,
       TO_CHAR(OUT_FUR_TIME, 'YYYY-MM-DD HH24:MI:SS') OUT_FUR_TIME,
       OUT_FUR_TEMP,
       GROUP_FLAG,
       BEFORE_HEAT_NO,
       BEFORE_MAT_NO,
       TO_CHAR(SCRAP_TIME, 'YYYY-MM-DD HH24:MI:SS') SCRAP_TIME,
       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,
       IN_USER,
       SCRAP_REASON,
       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,
       PRO_PLAN_ID,
       GX_PLAN_NO
  FROM MIL_FUR_RACK
 WHERE JUDGE_STOVE_NO = ?
   and PRO_PLAN_ID  || '&' LIKE '%' || ? || '%'
   and GX_PLAN_NO || '&' LIKE '%' || ? || '%'
 ORDER BY status, SEQ
        ]]>
	</query>
	<query id = "updateProcess.UpdateFlag" desc = "结炉时剔除管号队列进程表">
  UPDATE PORT_MIL_BATCH_SAMPLE_RESULT T SET T.STATUS = '1',T.OP_PROCESS = '#OP_PROCESS#' WHERE T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#' AND T.M_MAT_NO = '#MAT_NO#'
	</query>
	<!-- DECLARE
BEGIN
  FOR MYROW1 IN (SELECT M_MAT_NO
                   FROM (SELECT ROWNUM SEQ, M_MAT_NO
                           FROM (SELECT T.M_MAT_NO,
                                        T.IS_SAMPLE_PIPE,
                                        T.INSTORE_FLAG,
                                        ROW_NUMBER() OVER(PARTITION BY M_MAT_NO ORDER BY IS_SAMPLE_PIPE DESC,INSTORE_FLAG DESC) RN
                                   FROM PORT_MIL_BATCH_SAMPLE_RESULT T
                                  WHERE T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
                                    AND (T.OP_PROCESS IS NULL OR
                                        T.OP_PROCESS = '#OP_PROCESS#')
                                    )
                          WHERE RN = '1'
                            
                            AND INSTORE_FLAG = '0')
                  WHERE SEQ = '#SEQ#') LOOP
  UPDATE PORT_MIL_BATCH_SAMPLE_RESULT T SET T.STATUS = '1',T.OP_PROCESS = '#OP_PROCESS#' WHERE T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#' AND T.M_MAT_NO = MYROW1.M_MAT_NO;
 END LOOP;
END; 

FOR MYROW1 IN (SELECT M_MAT_NO
                   FROM (SELECT ROWNUM SEQ, M_MAT_NO
  FROM (
        
        SELECT *
          FROM (SELECT M_MAT_NO
                   FROM (SELECT ROWNUM SEQ, M_MAT_NO
                           FROM (select M_MAT_NO, count(1) cnt
                                   from (SELECT T1.M_MAT_NO, t1.is_sample_pipe
                                           FROM (SELECT T.M_MAT_NO,
                                                        t.is_sample_pipe
                                                   FROM PORT_MIL_BATCH_SAMPLE_RESULT T
                                                  WHERE T.JUDGE_STOVE_NO =
                                                        '570834-01'
                                                    AND T.STATUS = '0'
                                                    AND T.INSTORE_FLAG = '0'
                                                  ORDER BY T.MAT_NO ASC) T1
                                          GROUP BY T1.M_MAT_NO, t1.is_sample_pipe)
                                  group by M_MAT_NO)
                          where cnt = 1)
                  ORDER BY M_MAT_NO)
        union all
        SELECT M_MAT_NO
          FROM (SELECT ROWNUM SEQ, M_MAT_NO
                  FROM (select M_MAT_NO, count(1) cnt
                          from (SELECT T1.M_MAT_NO, t1.is_sample_pipe
                                  FROM (SELECT T.M_MAT_NO, t.is_sample_pipe
                                          FROM PORT_MIL_BATCH_SAMPLE_RESULT T
                                         WHERE T.JUDGE_STOVE_NO = '570834-01'
                                           AND T.STATUS = '0'
                                           AND T.INSTORE_FLAG = '0'
                                         ORDER BY T.IS_SAMPLE_PIPE, T.MAT_NO ASC) T1
                                 GROUP BY T1.M_MAT_NO, t1.is_sample_pipe)
                         group by M_MAT_NO)
                 where cnt > 1))
 WHERE ROWNUM = 1
                   )) LOOP
  UPDATE PORT_MIL_BATCH_SAMPLE_RESULT T SET T.STATUS = '1',T.OP_PROCESS = '#OP_PROCESS#' WHERE T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#' AND T.M_MAT_NO = MYROW1.M_MAT_NO;
 END LOOP;
END;
-->
	<query id = "updateProcess.selectScrap" desc = "上料锯切查询剔除序号">
	<![CDATA[
    SELECT T.PROCESS_NO, T.SEQ, T.JUDGE_STOVE_NO, T.MAT_NO
  FROM MIL_SLAB_SCRAP_SEQ T
 WHERE T.JUDGE_STOVE_NO = ?
   AND T.PROCESS_NO = ?
   AND T.PRO_PLAN_ID  || '&' LIKE '%' || ? || '%'
   AND T.GX_PLAN_NO  || '&' LIKE '%' || ? || '%'
   ]]>
    </query>
    <query id = "FurResult.updateMilSlab" desc = "赋值材料号到剔废表">
    <![CDATA[
    DECLARE
BEGIN
  FOR MYROW IN (SELECT T.SEQ, T.MAT_NO, T.JUDGE_STOVE_NO
                  FROM #RACK# T
                 WHERE T.JUDGE_STOVE_NO = ?
                   AND T.PRO_PLAN_ID  || '&' LIKE '%' || ? || '%'
                   AND T.GX_PLAN_NO  || '&' LIKE '%' || ? || '%'
                   AND T.STATUS = '1'
                 ORDER BY T.SEQ) LOOP
    UPDATE MIL_SLAB_SCRAP_SEQ T
       SET T.MAT_NO = MYROW.MAT_NO
     WHERE T.JUDGE_STOVE_NO = MYROW.JUDGE_STOVE_NO
       AND T.SEQ = MYROW.SEQ
       AND T.PROCESS_NO = ?;
  END LOOP;
END;
]]>
    </query>
    <query id = "FurResult.selectPortBacthSlample" desc = "查询样管信息">
    SELECT T.M_MAT_NO FROM PORT_MIL_BATCH_SAMPLE_RESULT T WHERE T.M_MAT_NO = ? AND T.IS_SAMPLE_PIPE = '1'
    </query>
    
    <query id = "FurResult.selectStartTime" desc= "查询第一支出炉时间">
	<![CDATA[
	SELECT TO_CHAR(MIN(DECODE(T.PLINE_CODE,
                          'C010',
                          T.FIRST_OUT_TIME + 1 / 24,
                          T.FIRST_OUT_TIME + 2 / 24)),
               'YYYY-MM-DD HH24:MI:SS') START_TIME
  FROM MIL_FUR_RESULT T
 WHERE REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '') = ?
   AND T.RESULT_NO = ?
   ]]>
	</query>
	</queryMap>