<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc = "连轧脱管实际操作">
<query id = "FrmRollingRPipeResult.RackQueryForHeatNo" desc = "根据判定炉号查询连轧跟踪">
<![CDATA[
 SELECT MAT_NO,
       LOT_NO,
       STOVE_NO,
       JUDGE_STOVE_NO,
       STEELCODE,
       STEELNAME,
       GRADECODE,
       GRADENAME,
       PLINE_CODE,
       DECODE(STATUS, '0', '正常轧制', '1', '剔除') STATUS,
       TO_CHAR(START_ROLLING_TIME, 'YYYY-MM-DD HH24:Mi:SS') START_ROLLING_TIME,
       TO_CHAR(END_ROLLING_TIME, 'YYYY-MM-DD HH24:Mi:SS') END_ROLLING_TIME,
       START_ROLLING_TEMP,
       END_ROLLING_TEMP,
       TUBE_DIAMETER,
       TUBE_WALL_THICKNESS,
       TUBE_LENGTH,
       DECODE(GROUP_FLAG, '0', '未组炉', '1', '组炉') GROUP_FLAG,
       BEFORE_HEAT_NO,
       BEFORE_MAT_NO,
       REMARK,
       DECODE(COL_MODE, '0', '接口采集', '1', '人工录入') COL_MODE,
       TO_CHAR(SCRAP_TIME, 'YYYY-MM-DD HH24:MI:SS') SCRAP_TIME,
       SCRAP_REASON,
       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,
       SEQ,
       '交班' CHANGE_NUM,
       '接班确认' BTNCHANGECOM,
       CASE CHANGE_FLAG
         WHEN '1' THEN
          '确认交班'
         WHEN '2' THEN
          '待接班确认'
       END AS CHANGE_FLAG,
       T.PRO_PLAN_ID,
       T.GX_PLAN_NO
  FROM MIL_ROLLING_RACK T
 WHERE T.JUDGE_STOVE_NO = ?
   AND T.PRO_PLAN_ID  || '&' LIKE '%' || ? || '%'
   AND T.GX_PLAN_NO  || '&' LIKE '%' || ? || '%'
 ORDER BY status, SEQ
]]>
</query>
<query id = "FrmRollingRPipeResult.insertResultForMainPlan" desc = "新增连轧实绩数据">
  INSERT INTO MIL_ROLLING_RESULT
  (JUDGE_STOVE_NO,
   PLINE_CODE,
   LIMIT_SPEED,
   INSERT_LENGTH,
   VRS_SPEED,
   RACK_SPEED1,
   RACK_SPEED2,
   RACK_SPEED3,
   RACK_SPEED4,
   RACK_SPEED5,
   RACK_SPEED6,
   RACK_SPEED7,
   RACK_SPACE1,
   RACK_SPACE2,
   RACK_SPACE3,
   RACK_SPACE4,
   RACK_SPACE5,
   RACK_SPACE6,
   RACK_SPACE7,
   ROLLING_FORCE1,
   ROLLING_FORCE2,
   ROLLING_FORCE3,
   ROLLING_FORCE4,
   ROLLING_FORCE5,
   ROLLING_FORCE6,
   ROLLING_FORCE7,
   QO_ROLLER_THROAT_DIAMETER,
   ROLLING_THROAT_DIAMETER,
   QC_ROLLER_THROAT_DIAMETER,
   ROLLING_SPEED,
   FEED_ANGLE,
   ROLLING_ANGLE,
   ROLLER_BITE_SPEED,
   EXT1_RACK_SPEED,
   EXT1_RACK_SPACE,
   START_ROLL_TEMP,
   END_ROLL_TEMP,
   DESCALING_WATER_PRESS,
   PQF2_RACK_WATER_FLOW,
   TUBE_DIAMETER,
   TUBE_WALL_THICKNESS,
   TUBE_LENGTH,
   CAPOLLARY_DIAMETER,
   CAPOLLARY_WALL_THICKNESS,
   MILL_ENTRANCE_TEMP,
   MILL_OUTLET_TEMP,
   MILL_WATER_PRESS,
   EXT_FRAME_TORQUE1,
   EXECUTIVE_PRODUCER,
   PRODUCER_TIME,
   PRODUCER_TEL,
   REMARK,
   COL_MODE,
   COL_TIME,
   START_TIME,
   COL_USER,
   COL_SHIFT,
   COL_GROUP,
   TUBESIZE,
   ROLLANGLE,
   EMSPEED,
   STATUS,
   RESULT_NO,
   LOT_NO,
   STOVE_NO,
   PRO_PLAN_ID,
   GX_PLAN_NO)
VALUES
  ('#JUDGE_STOVE_NO#',
   '#PLINE_CODE#',
   '#LIMIT_SPEED#',
   '#INSERT_LENGTH#',
   '#VRS_SPEED#',
   '#RACK_SPEED1#',
   '#RACK_SPEED2#',
   '#RACK_SPEED3#',
   '#RACK_SPEED4#',
   '#RACK_SPEED5#',
   '#RACK_SPEED6#',
   '#RACK_SPEED7#',
   '#RACK_SPACE1#',
   '#RACK_SPACE2#',
   '#RACK_SPACE3#',
   '#RACK_SPACE4#',
   '#RACK_SPACE5#',
   '#RACK_SPACE6#',
   '#RACK_SPACE7#',
   '#ROLLING_FORCE1#',
   '#ROLLING_FORCE2#',
   '#ROLLING_FORCE3#',
   '#ROLLING_FORCE4#',
   '#ROLLING_FORCE5#',
   '#ROLLING_FORCE6#',
   '#ROLLING_FORCE7#',
   '#QO_ROLLER_THROAT_DIAMETER#',
   '#ROLLING_THROAT_DIAMETER#',
   '#QC_ROLLER_THROAT_DIAMETER#',
   '#ROLLING_SPEED#',
   '#FEED_ANGLE#',
   '#ROLLING_ANGLE#',
   '#ROLLER_BITE_SPEED#',
   '#EXT1_RACK_SPEED#',
   '#EXT1_RACK_SPACE#',
   '#START_ROLL_TEMP#',
   '#END_ROLL_TEMP#',
   '#DESCALING_WATER_PRESS#',
   '#PQF2_RACK_WATER_FLOW#',
   '#TUBE_DIAMETER#',
   '#TUBE_WALL_THICKNESS#',
   '#TUBE_LENGTH#',
   '#CAPOLLARY_DIAMETER#',
   '#CAPOLLARY_WALL_THICKNESS#',
   '#MILL_ENTRANCE_TEMP#',
   '#MILL_OUTLET_TEMP#',
   '#MILL_WATER_PRESS#',
   '#EXT_FRAME_TORQUE1#',
   '#EXECUTIVE_PRODUCER#',
   SYSDATE,
   '#PRODUCER_TEL#',
   '#REMARK#',
   '#COL_MODE#',
   SYSDATE,
   SYSDATE,
   '#COL_USER#',
   '#COL_SHIFT#',
   '#COL_GROUP#',
   '#TUBESIZE#',
   '#ROLLANGLE#',
   '#EMSPEED#',
   '0',
   '#RESULT_NO#',
   '#LOT_NO#',
   '#STOVE_NO#',
   '#PRO_PLAN_ID#',
   '#GX_PLAN_NO#')
</query>
<query id = "FrmRollingRPipeResult.updateMailPlanStatus" desc = "修改主计划状态为开始连轧">
UPDATE MIL_PLAN T
   SET T.STATUS = '35'
 WHERE T.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 = "FrmRollingRPipeResult.getDBHeightBRate" desc = " 查询单倍重、烧损率">
<![CDATA[
select b.db_height as DB_HEIGHT, NVL(c.burnning_rate, 2) as burnning_rate
  from mil_plan b, mil_fur_result c
 where B.judge_stove_no = c.judge_stove_no(+)
   and B.ID = c.result_no(+)
   and b.judge_stove_no = ?
   and b.id = ?
   AND B.PRO_PLAN_ID  || '&' LIKE '%' || ? || '%'
   AND B.GX_PLAN_NO  || '&' LIKE '%' || ? || '%'
   ]]>
</query>

<query id = "FrmRollingRPipeResult.resultQuery" desc = "查询连轧实绩">
 <![CDATA[
 SELECT CHANGECLASSNUM,
       TUBESIZE,
       ROLLANGLE,
       EMSPEED,
       QUALIFIED_NUM,
       RESULT_NO,
       LOT_NO,
       STOVE_NO,
       JUDGE_STOVE_NO,
       PLINE_CODE,
       LIMIT_SPEED,
       INSERT_LENGTH,
       VRS_SPEED,
       RACK_SPEED1,
       RACK_SPEED2,
       RACK_SPEED3,
       RACK_SPEED4,
       RACK_SPEED5,
       RACK_SPEED6,
       RACK_SPEED7,
       RACK_SPACE1,
       RACK_SPACE2,
       RACK_SPACE3,
       RACK_SPACE4,
       RACK_SPACE5,
       RACK_SPACE6,
       RACK_SPACE7,
       ROLLING_FORCE1,
       ROLLING_FORCE2,
       ROLLING_FORCE3,
       ROLLING_FORCE4,
       ROLLING_FORCE5,
       ROLLING_FORCE6,
       ROLLING_FORCE7,
       QO_ROLLER_THROAT_DIAMETER,
       ROLLING_THROAT_DIAMETER,
       QC_ROLLER_THROAT_DIAMETER,
       ROLLING_SPEED,
       FEED_ANGLE,
       ROLLING_ANGLE,
       ROLLER_BITE_SPEED,
       EXT1_RACK_SPEED,
       EXT1_RACK_SPACE,
       START_ROLL_TEMP,
       END_ROLL_TEMP,
       DESCALING_WATER_PRESS,
       PQF2_RACK_WATER_FLOW,
       TUBE_DIAMETER,
       TUBE_WALL_THICKNESS,
       TUBE_LENGTH,
       CAPOLLARY_DIAMETER,
       CAPOLLARY_WALL_THICKNESS,
       MILL_ENTRANCE_TEMP,
       MILL_OUTLET_TEMP,
       MILL_WATER_PRESS,
       EXT_FRAME_TORQUE1,
       SCRAP_NUM,
       SCRAP_REASON,
       NODE_FUR_FLAG,
       EXECUTIVE_PRODUCER,
       TO_CHAR(PRODUCER_TIME, 'YYYY-MM-DD HH24:MI:SS') PRODUCER_TIME,
       PRODUCER_TEL,
       REMARK,
       COL_MODE,
       TO_CHAR(COL_TIME, 'YYYY-MM-DD HH24:MI:SS') COL_TIME,
       TO_CHAR(START_TIME, 'YYYY-MM-DD HH24:MI:SS') START_TIME,
       TO_CHAR(END_TIME, 'YYYY-MM-DD HH24:MI:SS') END_TIME,
       COL_USER,
       COL_SHIFT,
       COL_GROUP,
       ROLLINGNUM,
       PRO_PLAN_ID,
       GX_PLAN_NO
  FROM MIL_ROLLING_RESULT
 WHERE JUDGE_STOVE_NO = ?
   AND PRO_PLAN_ID  || '&' LIKE '%' || ? || '%'
   AND GX_PLAN_NO  || '&' LIKE '%' || ? || '%'
 ]]>
</query>
<query id = "FrmRollingRPipeResult.resultSave" desc = "保存连轧实绩（其他线）">
UPDATE MIL_ROLLING_RESULT
   SET TUBESIZE = '#TUBESIZE#',
       EMSPEED  = '#EMSPEED#',
       
       LIMIT_SPEED     = '#LIMIT_SPEED#',
       INSERT_LENGTH   = '#INSERT_LENGTH#',
       VRS_SPEED       = '#VRS_SPEED#',
       RACK_SPEED1     = '#RACK_SPEED1#',
       RACK_SPEED2     = '#RACK_SPEED2#',
       RACK_SPEED3     = '#RACK_SPEED3#',
       RACK_SPEED4     = '#RACK_SPEED4#',
       RACK_SPEED5     = '#RACK_SPEED5#',
       RACK_SPEED6     = '#RACK_SPEED6#',
       RACK_SPEED7     = '#RACK_SPEED7#',
       RACK_SPACE1     = '#RACK_SPACE1#',
       RACK_SPACE2     = '#RACK_SPACE2#',
       RACK_SPACE3     = '#RACK_SPACE3#',
       RACK_SPACE4     = '#RACK_SPACE4#',
       RACK_SPACE5     = '#RACK_SPACE5#',
       RACK_SPACE6     = '#RACK_SPACE6#',
       RACK_SPACE7     = '#RACK_SPACE7#',
       ROLLING_FORCE1  = '#ROLLING_FORCE1#',
       ROLLING_FORCE2  = '#ROLLING_FORCE2#',
       ROLLING_FORCE3  = '#ROLLING_FORCE3#',
       ROLLING_FORCE4  = '#ROLLING_FORCE4#',
       ROLLING_FORCE5  = '#ROLLING_FORCE5#',
       ROLLING_FORCE6  = '#ROLLING_FORCE6#',
       ROLLING_FORCE7  = '#ROLLING_FORCE7#',
       EXT1_RACK_SPEED = '#EXT1_RACK_SPEED#',
       
       REMARK          = '#REMARK#',
       START_ROLL_TEMP = '#START_ROLL_TEMP#',
       START_TIME      = to_date('#START_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="FrmRollingRPipeResult.SaveRackEndTime" desc="保存跟踪表结炉时间">
    <![CDATA[
        update MIL_ROLLING_RACK
   set END_ROLLING_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 END_ROLLING_TIME =
       (SELECT MAX(END_ROLLING_TIME)
          FROM MIL_ROLLING_RACK
         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 (SELECT MAX(START_ROLLING_TIME)
          FROM MIL_ROLLING_RACK
         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#', '/')) <
       (SELECT MAX(END_ROLLING_TIME)
          FROM MIL_ROLLING_RACK
         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="FrmRollingRPipeResult.SaveContralLogTime" desc="保存跟踪表结炉时间">
    <![CDATA[
       update MIL_CONTROL_LOG
   set LOGS_BEG = to_char(to_date('#START_TIME#', 'yyyy-mm-dd hh24:mi:ss'),
                          'YYYYMMDDhh24mi'),
       LOGS_END = to_char(to_date('#END_TIME#', 'yyyy-mm-dd hh24:mi:ss'),
                          'YYYYMMDDhh24mi')
 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 NVL(LOGS_END, '1') =
       (SELECT MIN(NVL(LOGS_END, '1'))
          FROM MIL_CONTROL_LOG
         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 Confirm_Flag = '0'
      ]]>
	</query>
	
	
	<query id="FrmRollingRPipeResult.changeGroupUpdateContralLog" desc="接班修改 连轧调度日志表">
    <![CDATA[
        UPDATE MIL_CONTROL_LOG T
   SET T.LOGS_END          = to_char(sysdate, 'YYYYMMDDhh24mi'),
       T.QUALIFIED_NUM     = '#QUALIFIED_NUM#',
       T.QUALIFIED_WT      = '#QUALIFIED_WT#',
       T.SCRAP_NUM         = '#SCRAP_NUM#',
       T.SCRAP_WT          = '#SCRAP_WT#',
       T.USER_NAME         = '#USER_NAME#',
       T.USER_ID           = '#USER_ID#',
       T.CHANGE_SHIFT_FLAG = '#CHANGE_SHIFT_FLAG#',
       T.PRO_BC            = '#PRO_BC#',
       T.PRO_BZ            = '#PRO_BZ#',
       T.USER_DATE         = SYSDATE
 WHERE T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
   AND T.LOT_NO = '#LOT_NO#'
   AND NVL(T.PRO_PLAN_ID,'/') = NVL('#PRO_PLAN_ID#','/')
   AND NVL(T.GX_PLAN_NO,'/') = NVL('#GX_PLAN_NO#','/')
   AND T.LOGS_END IS NULL
      ]]>
	</query>
	
	<query id="FrmRollingRPipeResult.UpdateMilControlLogDate" desc="修改 连轧调度日志表">
    <![CDATA[
     UPDATE MIL_CONTROL_LOG T
   SET T.Proc_Date = CASE
                       WHEN (substr(t.logs_beg, 9, 4) > '1200' AND
                            substr(t.logs_beg, 9, 4) <= '2400') AND
                            T.PRO_BC = '3' THEN
                        TO_CHAR(TRUNC(to_date(t.logs_beg,
                                              'YYYY-MM-DD HH24:MI:SS') + 1),
                                'YYYYMMDD')
                       WHEN (substr(t.logs_beg, 9, 4) >= '0000' AND
                            substr(t.logs_beg, 9, 4) < '1200') AND
                            T.PRO_BC = '3' THEN
                        TO_CHAR(TRUNC(to_date(t.logs_beg,
                                              'YYYY-MM-DD HH24:MI:SS')),
                                'YYYYMMDD')
                       ELSE
                        TO_CHAR(TRUNC(to_date(t.logs_beg,
                                              'YYYY-MM-DD HH24:MI:SS')),
                                'YYYYMMDD')
                     END,
       T.Bal_Year_Month = CASE
                            WHEN TO_DATE(T.LOGS_BEG, 'YYYY-MM-DD hh24:mi:ss') >
                                 TO_DATE(SUBSTR(T.LOGS_BEG, 1, 6) ||
                                         '-25 11:59:59',
                                         'YYYY-MM-DD hh24:mi:ss') THEN
                             TO_CHAR(TO_DATE(T.LOGS_BEG,
                                             'YYYY-MM-DD hh24:mi:ss') + 10,
                                     'YYYYMM')
                            ELSE
                             TO_CHAR(TO_DATE(T.LOGS_BEG,
                                             'YYYY-MM-DD hh24:mi:ss'),
                                     'YYYYMM')
                          END

      ]]>
	</query>
	
	
	<query id="FrmRollingRPipeResult.nodeChange" desc="结炉修改连轧调度日志表">
    <![CDATA[
       UPDATE MIL_CONTROL_LOG T
   SET T.LOGS_END          = to_char(sysdate, 'YYYYMMDDhh24mi'),
       T.QUALIFIED_NUM     = '#QUALIFIED_NUM#',
       T.QUALIFIED_WT      = '#QUALIFIED_WT#',
       T.SCRAP_NUM         = '#SCRAP_NUM#',
       T.SCRAP_WT          = '#SCRAP_WT#',
       T.USER_NAME         = '#USER_NAME#',
       T.USER_ID           = '#USER_ID#',
       T.NODE_FLAG         = '#NODE_FLAG#',
       T.CHANGE_SHIFT_FLAG = '#CHANGE_SHIFT_FLAG#',
       T.USER_DATE         = SYSDATE
 WHERE T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
   AND T.LOT_NO = '#LOT_NO#'
   AND T.PRO_BC = '#PRO_BC#'
   AND T.PRO_BZ = '#PRO_BZ#'
   AND T.LOGS_END IS NULL
    
      ]]>
	</query>
	
	<query id="FrmRollingRPipeResult.setNodeFlag" desc="修改调度结炉标识">
    <![CDATA[
        UPDATE MIL_CONTROL_LOG T SET T.NODE_FLAG = ? WHERE T.JUDGE_STOVE_NO = ?
      ]]>
	</query>
	
	
	<query id="FrmRollingRPipeResult.changeShiftGroupUpdateContralLog" desc="开始与结炉的班次班组不同时修改连轧调度日志表">
    <![CDATA[
       UPDATE MIL_CONTROL_LOG T
   SET T.LOGS_END       = to_char(sysdate, 'YYYYMMDDhh24mi'),
       T.QUALIFIED_NUM  = '#QUALIFIED_NUM#',
       T.QUALIFIED_WT   = '#QUALIFIED_WT#',
       T.SCRAP_NUM      = '#SCRAP_NUM#',
       T.SCRAP_WT       = '#SCRAP_WT#',
       T.USER_NAME      = '#USER_NAME#',
       T.USER_ID        = '#USER_ID#',
       T.USER_DATE      = SYSDATE,
       T.NODE_FLAG      = '#NODE_FLAG#',
       T.PRO_BC         = '#PRO_BC#',
       T.PRO_BZ         = '#PRO_BZ#',
       T.BAL_YEAR_MONTH = CASE
                            WHEN TO_DATE(T.LOGS_BEG, 'YYYY-MM-DD hh24:mi:ss') >
                                 TO_DATE(SUBSTR(T.LOGS_BEG, 1, 6) ||
                                         '-25 11:59:59',
                                         'YYYY-MM-DD hh24:mi:ss') THEN
                             TO_CHAR(TO_DATE(T.LOGS_BEG,
                                             'YYYY-MM-DD hh24:mi:ss') + 10,
                                     'YYYYMM')
                            ELSE
                             TO_CHAR(TO_DATE(T.LOGS_BEG,
                                             'YYYY-MM-DD hh24:mi:ss'),
                                     'YYYYMM')
                          END,
       T.PROC_DATE      = '#PROC_DATE#'
 WHERE T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
   AND T.LOT_NO = '#LOT_NO#'
   AND NVL(T.PRO_PLAN_ID, '/') = NVL('#PRO_PLAN_ID#', '/')
   AND NVL(T.GX_PLAN_NO, '/') = NVL('#GX_PLAN_NO#', '/')
   AND T.LOGS_END IS NULL
      ]]>
	</query>
	
	
	
	<query id="FrmRollingRPipeResult.getScrapNum" desc="查询穿孔跟踪表中指定序号范围内剔除管支数">
    <![CDATA[
   select count(t.seq)
  from mil_rolling_rack t
 where t.judge_stove_no = ?
   and t.result_no = ?
   and t.seq between ? and ?
   AND T.PRO_PLAN_ID  || '&' LIKE '%' || ? || '%'
   AND GX_PLAN_NO  || '&' LIKE '%' || ? || '%'
   and t.status = '1'
      ]]>
	</query>
	
		<query id="FrmRollingRPipeResult.getMaxSeq" desc="查询最大有效管序号">
    <![CDATA[
  select max(seq)
  from mil_rolling_rack t
 where t.judge_stove_no = ?
   and t.result_no = ?
   AND T.PRO_PLAN_ID  || '&' LIKE '%' || ? || '%'
   AND GX_PLAN_NO  || '&' LIKE '%' || ? || '%'
   and t.mat_no is not null
      ]]>
	</query>

<query id = "FrmRollingRPipeResult.resultSaveForNode" desc = "保存连轧实绩（其他线）">
<![CDATA[
UPDATE MIL_ROLLING_RESULT
   SET ROLLINGNUM      = '#ROLLINGNUM#',
       CHANGECLASSNUM  = '#CHANGECLASSNUM#',
       TUBESIZE        = '#TUBESIZE#',
       EMSPEED         = '#EMSPEED#',
       QUALIFIED_NUM   = '#QUALIFIED_NUM#',
       LIMIT_SPEED     = '#LIMIT_SPEED#',
       INSERT_LENGTH   = '#INSERT_LENGTH#',
       VRS_SPEED       = '#VRS_SPEED#',
       RACK_SPEED1     = '#RACK_SPEED1#',
       RACK_SPEED2     = '#RACK_SPEED2#',
       RACK_SPEED3     = '#RACK_SPEED3#',
       RACK_SPEED4     = '#RACK_SPEED4#',
       RACK_SPEED5     = '#RACK_SPEED5#',
       RACK_SPEED6     = '#RACK_SPEED6#',
       RACK_SPEED7     = '#RACK_SPEED7#',
       RACK_SPACE1     = '#RACK_SPACE1#',
       RACK_SPACE2     = '#RACK_SPACE2#',
       RACK_SPACE3     = '#RACK_SPACE3#',
       RACK_SPACE4     = '#RACK_SPACE4#',
       RACK_SPACE5     = '#RACK_SPACE5#',
       RACK_SPACE6     = '#RACK_SPACE6#',
       RACK_SPACE7     = '#RACK_SPACE7#',
       ROLLING_FORCE1  = '#ROLLING_FORCE1#',
       ROLLING_FORCE2  = '#ROLLING_FORCE2#',
       ROLLING_FORCE3  = '#ROLLING_FORCE3#',
       ROLLING_FORCE4  = '#ROLLING_FORCE4#',
       ROLLING_FORCE5  = '#ROLLING_FORCE5#',
       ROLLING_FORCE6  = '#ROLLING_FORCE6#',
       ROLLING_FORCE7  = '#ROLLING_FORCE7#',
       EXT1_RACK_SPEED = '#EXT1_RACK_SPEED#',
       SCRAP_NUM       = '#SCRAP_NUM#',
       NODE_FUR_FLAG   = '#NODE_FUR_FLAG#',
       REMARK          = '#REMARK#',
       START_ROLL_TEMP = '#START_ROLL_TEMP#',
       START_TIME      = to_date('#START_TIME#', 'yyyy-mm-dd hh24:mi:ss'),
       QA_TON          = '#QA_TON#',
       COL_SHIFT       = '#COL_SHIFT#',
       COL_GROUP       = '#COL_GROUP#',
       USER_ID         = '#USER_ID#',
       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#', '/')
   ]]>
</query>
<query id = "FrmRollingRPipe.Result1" desc = "保存连轧实绩1(阿塞尔线)">
UPDATE MIL_ROLLING_RESULT
   SET  ROLLINGNUM='#ROLLINGNUM#',
        CHANGECLASSNUM = '#CHANGECLASSNUM#',
        TUBESIZE = '#TUBESIZE#',
        ROLLANGLE = '#ROLLANGLE#',
        QUALIFIED_NUM = '#QUALIFIED_NUM#',
        QO_ROLLER_THROAT_DIAMETER = '#QO_ROLLER_THROAT_DIAMETER#',
        ROLLING_THROAT_DIAMETER = '#ROLLING_THROAT_DIAMETER#',
        QC_ROLLER_THROAT_DIAMETER = '#QC_ROLLER_THROAT_DIAMETER#',
        ROLLING_SPEED = '#ROLLING_SPEED#',
        FEED_ANGLE = '#FEED_ANGLE#',
        ROLLING_ANGLE = '#ROLLING_ANGLE#',
        ROLLER_BITE_SPEED = '#ROLLER_BITE_SPEED#',
        SCRAP_NUM = '#SCRAP_NUM#',
        REMARK = '#REMARK#',
    
        START_ROLL_TEMP='#START_ROLL_TEMP#',
        START_TIME=to_date('#START_TIME#','yyyy-mm-dd hh24:mi:ss'),
        WHERE  JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
</query>
<query id = "FrmRollingRPipe.resultSaveForNode1" desc = "保存连轧实绩1(阿塞尔线)">
UPDATE MIL_ROLLING_RESULT
   SET  ROLLINGNUM='#ROLLINGNUM#',
        CHANGECLASSNUM = '#CHANGECLASSNUM#',
        TUBESIZE = '#TUBESIZE#',
        ROLLANGLE = '#ROLLANGLE#',
        QUALIFIED_NUM = '#QUALIFIED_NUM#',
        QO_ROLLER_THROAT_DIAMETER = '#QO_ROLLER_THROAT_DIAMETER#',
        ROLLING_THROAT_DIAMETER = '#ROLLING_THROAT_DIAMETER#',
        QC_ROLLER_THROAT_DIAMETER = '#QC_ROLLER_THROAT_DIAMETER#',
        ROLLING_SPEED = '#ROLLING_SPEED#',
        FEED_ANGLE = '#FEED_ANGLE#',
        ROLLING_ANGLE = '#ROLLING_ANGLE#',
        ROLLER_BITE_SPEED = '#ROLLER_BITE_SPEED#',
        SCRAP_NUM = '#SCRAP_NUM#',
        REMARK = '#REMARK#',
        NODE_FUR_FLAG = '#NODE_FUR_FLAG#',
        START_ROLL_TEMP='#START_ROLL_TEMP#',
        START_TIME=to_date('#START_TIME#','yyyy-mm-dd hh24:mi:ss'),
        QA_TON = '#QA_TON#',
          	COL_SHIFT = '#COL_SHIFT#',
       	COL_GROUP = '#COL_GROUP#',
       	USER_ID = '#USER_ID#',
       	COL_USER = '#COL_USER#'
        WHERE  JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
</query>
<query id = "FrmRollingRPipeResult.rackDelete" desc = "剔除连轧跟踪表信息">
UPDATE MIL_ROLLING_RACK
   SET STATUS = '#STATUS#', SCRAP_REASON = '设备故障', SCRAP_TIME = SYSDATE
 WHERE JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
   AND SEQ = '#SEQ#'
</query>

<query id = "FrmRollingRPipeResult.endStoveForMainPlan" desc = "连轧结炉修改主计划">
<![CDATA[
      	 UPDATE MIL_PLAN
   SET NODE_STATUS = '40', STATUS = '40'
 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 = "FrmRollingRPipeResult.endStoveForRack" desc = "连轧结炉修改跟踪表">
<![CDATA[
      	 UPDATE MIL_ROLLING_RACK
   SET COL_SHIFT        = '#COL_SHIFT#',
       COL_GROUP        = '#COL_GROUP#',
       COL_USER         = '#COL_USER#',
       END_ROLLING_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 COL_SHIFT IS NULL
   AND COL_GROUP IS NULL
   AND END_ROLLING_TIME IS NULL
   AND mat_no is not null
        ]]>
</query>

<query id = "FrmRollingRPipeResult.endStoveForRackEndTime" desc = "交接班时上个班的结束时间为空时，补齐时间">
<![CDATA[
      	UPDATE MIL_ROLLING_RACK T
   SET T.END_ROLLING_TIME =
       (SELECT MAX(M.START_ROLLING_TIME)
          FROM MIL_ROLLING_RACK M
         WHERE M.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO)
 WHERE T.END_ROLLING_TIME IS NULL
   AND T.MAT_NO IS NOT NULL
   AND T.START_ROLLING_TIME IS NOT NULL
   AND T.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 = "FrmRollingRPipeResult.endStoveForResult" desc = "连轧结炉修改实绩信息">
<![CDATA[
      	  UPDATE MIL_ROLLING_RESULT
   SET NODE_FUR_FLAG = '1', END_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#', '/')
        ]]>
</query>
<query id = "FrmRollingRPipeResult.scrapNumQuery" desc = "查询连轧实绩表轧废支数">
<![CDATA[
 SELECT 
       SCRAP_NUM
 FROM MIL_ROLLING_RESULT
 WHERE JUDGE_STOVE_NO = ?
 ]]>
</query>
<query id = "FrmRollingRPipeResult.resultScrapNumUpdate" desc = "修改实绩表轧废支数">
<![CDATA[
      	  UPDATE MIL_ROLLING_RESULT
   SET 
        SCRAP_NUM = '#SCRAP_NUM#',
        qualified_num=( CASE  NVL(qualified_num,0) WHEN 0 then 0 else qualified_num-1 end)
 WHERE JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#' 
        ]]>
</query>
<query id = "FrmRollingRPipeResult.deleteStatusQuery" desc = "查询剔除表被剔除支数的序号">
SELECT SEQ FROM MIL_SLAB_SCRAP_SEQ WHERE JUDGE_STOVE_NO = ? 
</query>
<query id = "FrmRollingRPipeResult.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#',
   '4',
   '#SEQ#',
   SYSDATE,
   '',
   '#COL_USER#',
   '#COL_SHIFT#',
   '#COL_GROUP#',
   '#PRO_PLAN_ID#',
   '#GX_PLAN_NO#')
</query>

<query id="FrmRollingRPipeResult.UpdateFurHistory" desc="修改加热炉历史表管坯状态">
        <![CDATA[
         UPDATE MIL_ROLLING_HISTORY
   		SET 
        STATUS = '1'
 		WHERE
		SEQ = ?  
		AND  
		JUDGE_STOVE_NO = ?
        ]]>
	</query>
	<query id = "FrmRollingRPipeResult.perForationResultQuery" desc = "查询穿孔是否结炉">
	<![CDATA[
	SELECT T.NODE_FUR_FLAG
  FROM MIL_PERFORATION_RESULT T
 WHERE T.JUDGE_STOVE_NO = ?
   AND T.PRO_PLAN_ID  || '&' LIKE '%' || ? || '%'
   AND GX_PLAN_NO  || '&' LIKE '%' || ? || '%'
   ]]>
	</query>
	<query id = "FrmRollingRPipeResult.perForationResultStaus" desc = "查询该序号的毛管是否被剔除">
	SELECT T.STATUS FROM MIL_PERFORATION_RACK T WHERE T.JUDGE_STOVE_NO = ? AND T.SEQ = ?
	</query>
	
	<query id="FrmRollingRPipeResult.GetRollResultNodeQuery" desc="">
	SELECT a.JUDGE_STOVE_NO,
       a.LOT_NO,
       a.SCRAP_NUM,
       a.QUALIFIED_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,
       a.REMARK,
       b.DB_HEIGHT,
       c.BURNNING_RATE,
       a.col_shift,
       a.col_group,
       a.col_user,
       a.CHANGECLASSNUM,
       a.qa_ton
  FROM MIL_ROLLING_RESULT a, mil_plan b, mil_fur_result c
 WHERE 1 = 1
   AND 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 b.JUDGE_STOVE_NO = c.JUDGE_STOVE_NO
 order by a.end_time
	</query>
	
	<query id = "FrmRollingRPipeResult.UpdataResultPROCDATE" desc = "更新连轧实绩中的生产年月">
<![CDATA[
      	  update MIL_ROLLING_RESULT T
   SET T.Proc_Date = CASE
                       WHEN (TO_CHAR(T.START_TIME, 'HH24MI') > '1200' AND
                            TO_CHAR(T.START_TIME, 'HH24MI') <= '2400') AND
                            T.COL_SHIFT = '3' THEN
                        TO_CHAR(TRUNC(T.START_TIME) + 1, 'YYYYMMDD')
                       WHEN (TO_CHAR(T.START_TIME, 'HH24MI') >= '0000' AND
                            TO_CHAR(T.START_TIME, 'HH24MI') < '1200') AND
                            T.COL_SHIFT = '3' THEN
                        TO_CHAR(TRUNC(T.START_TIME), 'YYYYMMDD')
                       ELSE
                        TO_CHAR(TRUNC(T.START_TIME), 'YYYYMMDD')
                     END,
       t.bal_year_month = CASE
                            WHEN (TO_CHAR(T.START_TIME, 'HH24MI') > '1200' AND
                                 TO_CHAR(T.START_TIME, 'HH24MI') <= '2400') AND
                                 T.COL_SHIFT = '3' THEN
                             TO_CHAR(TRUNC(T.START_TIME) + 1, 'YYYYMM')
                            WHEN (TO_CHAR(T.START_TIME, 'HH24MI') >= '0000' AND
                                 TO_CHAR(T.START_TIME, 'HH24MI') < '1200') AND
                                 T.COL_SHIFT = '3' THEN
                             TO_CHAR(TRUNC(T.START_TIME), 'YYYYMM')
                            ELSE
                             TO_CHAR(TRUNC(T.START_TIME), 'YYYYMM')
                          END
 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 = "FrmRollingRPipeResult.UpdataControlPROCDATE" desc = "更新调度中的生产年月">
<![CDATA[
      	  UPDATE MIL_CONTROL_LOG T
   SET T.Proc_Date = CASE
                       WHEN (substr(t.logs_beg, 9, 4) > '1200' AND
                            substr(t.logs_beg, 9, 4) <= '2400') AND
                            T.PRO_BC = '3' THEN
                        TO_CHAR(TRUNC(to_date(t.logs_beg,
                                              'YYYY-MM-DD HH24:MI:SS')) + 1,
                                'YYYYMMDD')
                       WHEN (substr(t.logs_beg, 9, 4) >= '0000' AND
                            substr(t.logs_beg, 9, 4) < '1200') AND
                            T.PRO_BC = '3' THEN
                        TO_CHAR(TRUNC(to_date(t.logs_beg,
                                              'YYYY-MM-DD HH24:MI:SS')),
                                'YYYYMMDD')
                       ELSE
                        TO_CHAR(TRUNC(to_date(t.logs_beg,
                                              'YYYY-MM-DD HH24:MI:SS')),
                                'YYYYMMDD')
                     END,
       T.Bal_Year_Month = CASE
                            WHEN (substr(t.logs_beg, 9, 4) > '1200' AND
                                 substr(t.logs_beg, 9, 4) <= '2400') AND
                                 T.PRO_BC = '3' THEN
                             TO_CHAR(TRUNC(to_date(t.logs_beg,
                                                   'YYYY-MM-DD HH24:MI:SS')) + 1,
                                     'YYYYMM')
                            WHEN (substr(t.logs_beg, 9, 4) >= '0000' AND
                                 substr(t.logs_beg, 9, 4) < '1200') AND
                                 T.PRO_BC = '3' THEN
                             TO_CHAR(TRUNC(to_date(t.logs_beg,
                                                   'YYYY-MM-DD HH24:MI:SS')),
                                     'YYYYMM')
                            ELSE
                             TO_CHAR(TRUNC(to_date(t.logs_beg,
                                                   'YYYY-MM-DD HH24:MI:SS')),
                                     'YYYYMM')
                          END
 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 = "FrmRollingRPipeResult.doQueryRackGroup" desc = "查询最大交班序号班次班组">
SELECT T.COL_SHIFT, T.COL_GROUP
  FROM MIL_ROLLING_RACK T
 WHERE T.RESULT_NO = ?
   AND T.JUDGE_STOVE_NO = ?
   AND T.CHANGE_FLAG = '1'
 ORDER BY SEQ DESC
</query>

<query id = "FrmRollingRPipeResult.doQueryShiftGroup" desc = "查询实绩表中一炉开始的班次班组">
SELECT T.COL_SHIFT, T.COL_GROUP
  FROM MIL_ROLLING_RESULT T
 WHERE T.RESULT_NO = ?
   AND T.JUDGE_STOVE_NO = ?
</query>

<query id = "FrmRollingRPipeResult.doQueryRollingRackShiftGroup" desc = "查询跟踪表待交班管的班次班组">
SELECT T.COL_SHIFT, T.COL_GROUP
  FROM MIL_ROLLING_RACK T
 WHERE T.RESULT_NO = ?
   AND T.JUDGE_STOVE_NO = ?
   AND T.CHANGE_FLAG = '2'
</query>

<query id = "FrmRollingRPipeResult.selectStartTime" desc= "查询连轧开始时间">
	<![CDATA[
	SELECT TO_CHAR(MIN(DECODE(T.PLINE_CODE,
                          'C010',
                          T.START_TIME + 1 / 24,
                          T.START_TIME + 2 / 24)),
               'YYYY-MM-DD HH24:MI:SS') START_TIME
  FROM MIL_ROLLING_RESULT T
 WHERE REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '') = ?
   AND T.RESULT_NO = ?
   ]]>
	</query>
	
	<query id = "FrmRollingRPipeResult.UpdateTmsDemandMStartTime" desc = "更新运输需求起运启时间">
<![CDATA[
DECLARE
  V_JUDGE_STOVE_NO TMS_DEMAND_M.HEAT_NO%type := REGEXP_REPLACE(?, '-.*', '');
  V_CURRENT_JOB_NO TMS_DEMAND_M.CURRENT_JOB_NO%type := ?;
  V_LOAD_TIME      TMS_DEMAND_M.CREATE_NAME%type := ?;
BEGIN
  FOR MYROW IN (SELECT T.*
                  FROM TMS_DEMAND_M T
                 WHERE T.HEAT_NO = V_JUDGE_STOVE_NO
                   AND T.CURRENT_JOB_NO = V_CURRENT_JOB_NO
                   AND T.TRAN_CLASS_CODE = 'XX'
                 ORDER BY T.CREATE_TIME DESC) LOOP
    UPDATE TMS_DEMAND_M T
       SET T.TRANSPORT_START_TIME = TO_DATE(V_LOAD_TIME, 'YYYY-MM-DD HH24:MI:SS')
     WHERE T.DEMAND_NO = MYROW.DEMAND_NO;
  END LOOP;
END;
       ]]>
</query>

</queryMap>
