<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="穿孔实绩操作">

	<query id="PerforationResult.PlanQueryCKTC" desc="查询简单作业计划">
		<![CDATA[
			select t.mat_no,
       t.lot_no,
       t.stove_no,
       t.judge_stove_no,
       t.pline_code,
       CASE t.status
         WHEN '0' THEN
          '正常轧制'
         WHEN '1' THEN
          '剔除'
       END AS status,
       t.start_roll_temp,
       TO_CHAR(t.start_perforation_time, 'YYYY-MM-DD HH24:MI:SS') START_PERFORATION_TIME,
       TO_CHAR(t.end_perforation_time, 'YYYY-MM-DD HH24:MI:SS') END_PERFORATION_TIME,
       t.start_perforation_temp,
       t.end_perforation_temp,
       t.capollary_diameter,
       t.capollary_wall_thickness,
       t.capollary_length,
       t.remark,
       t.col_mode,
       t.col_time,
       t.col_user,
       TO_CHAR(t.SCRAP_TIME, 'YYYY-MM-DD HH24:MI:SS') SCRAP_TIME,
       t.SCRAP_REASON,
       case t.COL_SHIFT
         WHEN '0' THEN
          '常白班'
         WHEN '1' THEN
          '早班'
         WHEN '2' THEN
          '中班'
         WHEN '3' THEN
          '夜班'
       end as COL_SHIFT,
       case t.COL_GROUP
         WHEN '1' THEN
          '甲'
         WHEN '2' THEN
          '乙'
         WHEN '3' THEN
          '丙'
         WHEN '4' THEN
          '丁'
       end as COL_GROUP,
       t.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_perforation_rack t
 where t.judge_stove_no = ? 
   and NVL(t.PRO_PLAN_ID,'/')  = NVL(?,'/') 
   and NVL(t.GX_PLAN_NO,'/')  = NVL(?,'/') 
 order by status, SEQ
		]]>
	</query>
	<query id="PerforationResult.SingleFurResultQuery" desc="穿孔实绩">
        <![CDATA[
select scrap_num,
       jzb_num,
       perforation_num,
       front_extending_quantity,
       roller_space,
       guide_space,
       capollary_diameter capollary_wall_thickness,
       bite_angle,
       guide_disc_motor_speed,
       head_diameter,
       roll_motor_speed,
       roll_motor_sjb,
       kz_temp,
       AMOUNT_OF_BORAX,
       Remark,
       start_time,
       end_time,
       CAPOLLARY_DIAMETER,
       borax_pressure,
       guide_disc_motor_loca,
       db_loca,
       dp_gg,
       dt_code,
       zg_zj,
       zg_loca_up,
       zg_loca_down,
       db_loca_down,
       capillary_size,
       BEGIN_ROLLING_TEMP,
       PRO_PLAN_ID,
       GX_PLAN_NO
  from mil_perforation_result
 WHERE JUDGE_STOVE_NO = ?
   AND PRO_PLAN_ID  = ? 
   AND GX_PLAN_NO  = ? 
		]]>
	</query>
	<query id="PerforationResult.Addperforation_result" desc="新增穿孔实绩">
        <![CDATA[
          INSERT INTO MIL_PERFORATION_RESULT
  (RESULT_NO,
   LOT_NO,
   STOVE_NO,
   JUDGE_STOVE_NO,
   PLINE_CODE,
   ROLLER_SPACE,
   GUIDE_SPACE,
   FRONT_EXTENDING_QUANTITY,
   BITE_ANGLE,
   HEAD_DIAMETER,
   ROLL_MOTOR_SPEED,
   GUIDE_DISC_MOTOR_SPEED,
   BORAX_TANK,
   BORAX_PRESSURE,
   AMOUNT_OF_BORAX,
   
   CAPOLLARY_WALL_THICKNESS,
   BEGIN_ROLLING_TEMP,
   SLAB_DIAMETER,
   SLAB_LENGTH,
   PERFORATION_NUM,
   
   SCRAP_REASON,
   START_TIME,
   EXECUTIVE_PRODUCER,
   PRODUCER_TIME,
   PRODUCER_TEL,
   REMARK,
   COL_MODE,
   COL_TIME,
   COL_USER,
   COL_SHIFT,
   COL_GROUP,
   JZB_NUM,
   KZ_TEMP,
   DP_GG,
   GUIDE_DISC_MOTOR_LOCA,
   DB_LOCA,
   ROLL_MOTOR_SJB,
   ZG_ZJ,
   DT_CODE,
   ZG_LOCA_UP,
   ZG_LOCA_DOWN,
   NODE_FUR_FLAG,
   Capillary_Size,
   PRO_PLAN_ID,
   GX_PLAN_NO)
VALUES
  ('#RESULT_NO#',
   '#LOT_NO#',
   '#STOVE_NO#',
   '#JUDGE_STOVE_NO#',
   '#PLINE_CODE#',
   '#ROLLER_SPACE#',
   '#GUIDE_SPACE#',
   '#FRONT_EXTENDING_QUANTITY#',
   '#BITE_ANGLE#',
   '#HEAD_DIAMETER#',
   '#ROLL_MOTOR_SPEED#',
   '#GUIDE_DISC_MOTOR_SPEED#',
   '#BORAX_TANK#',
   '#BORAX_PRESSURE#',
   '#AMOUNT_OF_BORAX#',
   
   '#CAPOLLARY_WALL_THICKNESS#',
   '#BEGIN_ROLLING_TEMP#',
   '#SLAB_DIAMETER#',
   '#SLAB_LENGTH#',
   '#PERFORATION_NUM#',
   
   '#SCRAP_REASON#',
   SYSDATE,
   '#EXECUTIVE_PRODUCER#',
   SYSDATE,
   '#PRODUCER_TEL#',
   '#REMARK#',
   '#COL_MODE#',
   SYSDATE,
   '#COL_USER#',
   '#COL_SHIFT#',
   '#COL_GROUP#',
   '#JZB_NUM#',
   '#KZ_TEMP#',
   '#DP_GG#',
   '#GUIDE_DISC_MOTOR_LOCA#',
   '#DB_LOCA#',
   '#ROLL_MOTOR_SJB#',
   '#ZG_ZJ#',
   '#DT_CODE#',
   '#ZG_LOCA_UP#',
   '#ZG_LOCA_DOWN#',
   '0',
   '#CAPILLARY_SIZE#',
   '#PRO_PLAN_ID#',
   '#GX_PLAN_NO#')
        ]]>
	</query>
	<query id="PerforationResult.UpdatePerforationStatue" desc="修改上料行标识">
        <![CDATA[
        update mil_plan t
   set t.status = '25'
 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="PerforationResult.AddScrapSlabSeq" desc="新增管号剔除序号表">
        <![CDATA[
       INSERT INTO MIL_SLAB_SCRAP_SEQ
  (JUDGE_STOVE_NO,
   PROCESS_NO,
   SEQ,
   TIME,
   FLAG,
   REMARK,
   COL_MODE,
   COL_TIME,
   COL_USER,
   COL_SHIFT,
   COL_GROUP,
   PRO_PLAN_ID,
   GX_PLAN_NO)
VALUES
  ('#JUDGE_STOVE_NO#',
   '#PROCESS_NO#',
   '#SEQ#',
   SYSDATE,
   '#FLAG#',
   '#REMARK#',
   '#COL_MODE#',
   SYSDATE,
   '#COL_USER#',
   '#COL_SHIFT#',
   '#COL_GROUP#',
   '#PRO_PLAN_ID#',
   '#GX_PLAN_NO#')
        ]]>
	</query>
	<query id="PerforationResult.UpdateFurStatue" desc="加热炉管坯状态">
        <![CDATA[
         UPDATE mil_perforation_rack
   SET STATUS = '1', SCRAP_TIME = SYSDATE, SCRAP_REASON = '设备故障'
 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="PerforationResult.UpdateFurScrapNum" desc="修改穿孔实绩表剔除支数">
        <![CDATA[
        UPDATE mil_perforation_result
   SET SCRAP_NUM = SCRAP_NUM + 1
 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="PerforationResult.savePerResult" desc="保存穿孔实绩信息">
    <![CDATA[
          UPDATE MIL_PERFORATION_RESULT
   SET 
        JZB_NUM = '#JZB_NUM#',
        KZ_TEMP = '#KZ_TEMP#',
        DP_GG = '#DP_GG#',
        GUIDE_DISC_MOTOR_LOCA = '#GUIDE_DISC_MOTOR_LOCA#',
        DB_LOCA = '#DB_LOCA#',
        ROLL_MOTOR_SJB = '#ROLL_MOTOR_SJB#',
        ZG_ZJ = '#ZG_ZJ#',
        DT_CODE = '#DT_CODE#',
        ZG_LOCA_UP = '#ZG_LOCA_UP#',
        ZG_LOCA_DOWN = '#ZG_LOCA_DOWN#',
        COL_TIME = SYSDATE,
        COL_USER = '#COL_USER#',
        COL_SHIFT = '#COL_SHIFT#',
        COL_GROUP = '#COL_GROUP#',
        LOT_NO = '#LOT_NO#',
        STOVE_NO = '#STOVE_NO#',
        JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#',
        PLINE_CODE = '#PLINE_CODE#',
        ROLLER_SPACE = '#ROLLER_SPACE#',
        GUIDE_SPACE = '#GUIDE_SPACE#',
        FRONT_EXTENDING_QUANTITY = '#FRONT_EXTENDING_QUANTITY#',
        BITE_ANGLE = '#BITE_ANGLE#',
        HEAD_DIAMETER = '#HEAD_DIAMETER#',
        ROLL_MOTOR_SPEED = '#ROLL_MOTOR_SPEED#',
        GUIDE_DISC_MOTOR_SPEED = '#GUIDE_DISC_MOTOR_SPEED#',
        BORAX_TANK = '#BORAX_TANK#',
        BORAX_PRESSURE = '#BORAX_PRESSURE#',
        AMOUNT_OF_BORAX = '#AMOUNT_OF_BORAX#',
        CAPOLLARY_DIAMETER = '',
        CAPOLLARY_WALL_THICKNESS = '',
        BEGIN_ROLLING_TEMP = '#BEGIN_ROLLING_TEMP#',
        SLAB_DIAMETER = '#SLAB_DIAMETER#',
        SLAB_LENGTH = '#SLAB_LENGTH#',
        PERFORATION_NUM = '#PERFORATION_NUM#',
        SCRAP_NUM = '#SCRAP_NUM#',
        SCRAP_REASON = '#SCRAP_REASON#',
        NODE_FUR_FLAG = '#NODE_FUR_FLAG#',
        EXECUTIVE_PRODUCER = '#EXECUTIVE_PRODUCER#',
        PRODUCER_TIME = SYSDATE,
        PRODUCER_TEL = '#PRODUCER_TEL#',
        REMARK = '#REMARK#',
        COL_MODE = '#COL_MODE#'
 WHERE JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#' 
		    
        ]]>
	</query>
	<query id="PerforationResult.UpdatePerResult" desc="保存穿孔实绩信息">
    <![CDATA[
          UPDATE MIL_PERFORATION_RESULT
   SET 
      
        KZ_TEMP = '#KZ_TEMP#',
        DP_GG = '#DP_GG#',
        GUIDE_DISC_MOTOR_LOCA = '#GUIDE_DISC_MOTOR_LOCA#',
        DB_LOCA = '#DB_LOCA#',
         DB_LOCA_DOWN = '#DB_LOCA_DOWN#',
        ROLL_MOTOR_SJB = '#ROLL_MOTOR_SJB#',
        ZG_ZJ = '#ZG_ZJ#',
        DT_CODE = '#DT_CODE#',
        ZG_LOCA_UP = '#ZG_LOCA_UP#',
        ZG_LOCA_DOWN = '#ZG_LOCA_DOWN#',
        ROLLER_SPACE = '#ROLLER_SPACE#',
        GUIDE_SPACE = '#GUIDE_SPACE#',
        FRONT_EXTENDING_QUANTITY = '#FRONT_EXTENDING_QUANTITY#',
        BITE_ANGLE = '#BITE_ANGLE#',
        HEAD_DIAMETER = '#HEAD_DIAMETER#',
        ROLL_MOTOR_SPEED = '#ROLL_MOTOR_SPEED#',
        GUIDE_DISC_MOTOR_SPEED = '#GUIDE_DISC_MOTOR_SPEED#',
        BORAX_TANK = '#BORAX_TANK#',
        BORAX_PRESSURE = '#BORAX_PRESSURE#',
        AMOUNT_OF_BORAX = '#AMOUNT_OF_BORAX#',
        CAPOLLARY_DIAMETER = '',
        CAPOLLARY_WALL_THICKNESS = '',
        BEGIN_ROLLING_TEMP = '#BEGIN_ROLLING_TEMP#',
        SLAB_DIAMETER = '#SLAB_DIAMETER#',
        SLAB_LENGTH = '#SLAB_LENGTH#',
      
        SCRAP_REASON = '#SCRAP_REASON#',
        EXECUTIVE_PRODUCER = '#EXECUTIVE_PRODUCER#',
        PRODUCER_TIME = SYSDATE,
        PRODUCER_TEL = '#PRODUCER_TEL#',
        CAPILLARY_SIZE = '#CAPILLARY_SIZE#',
        REMARK = '#REMARK#',
        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 JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'  
        ]]>
	</query>
	<query id="PerforationResult.UpdatePerRackEndTime" desc="保存穿孔跟踪表结炉时间">
    <![CDATA[
       update MIL_PERFORATION_RACK
   set END_PERFORATION_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_PERFORATION_TIME =
       (SELECT MAX(END_PERFORATION_TIME)
          FROM MIL_PERFORATION_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="PerforationResult.UpdatePerResultNode" desc="穿孔结炉">
		UPDATE MIL_PERFORATION_RESULT
   SET ROLLER_SPACE             = '#ROLLER_SPACE#',
       GUIDE_SPACE              = '#GUIDE_SPACE#',
       FRONT_EXTENDING_QUANTITY = '#FRONT_EXTENDING_QUANTITY#',
       BITE_ANGLE               = '#BITE_ANGLE#',
       HEAD_DIAMETER            = '#HEAD_DIAMETER#',
       ROLL_MOTOR_SPEED         = '#ROLL_MOTOR_SPEED#',
       GUIDE_DISC_MOTOR_SPEED   = '#GUIDE_DISC_MOTOR_SPEED#',
       BORAX_TANK               = '#BORAX_TANK#',
       BORAX_PRESSURE           = '#BORAX_PRESSURE#',
       AMOUNT_OF_BORAX          = '#AMOUNT_OF_BORAX#',
       CAPOLLARY_DIAMETER       = '#CAPOLLARY_DIAMETER#',
       CAPOLLARY_WALL_THICKNESS = '#CAPOLLARY_WALL_THICKNESS#',
       BEGIN_ROLLING_TEMP       = '#BEGIN_ROLLING_TEMP#',
       SLAB_DIAMETER            = '#SLAB_DIAMETER#',
       SLAB_LENGTH              = '#SLAB_LENGTH#',
       PERFORATION_NUM          = '#PERFORATION_NUM#',
       SCRAP_NUM                = '#SCRAP_NUM#',
       SCRAP_REASON             = '#SCRAP_REASON#',
       END_TIME                 = SYSDATE,
       NODE_FUR_FLAG            = '#NODE_FUR_FLAG#',
       REMARK                   = '#REMARK#',
       JZB_NUM                  = '#JZB_NUM#',
       KZ_TEMP                  = '#KZ_TEMP#',
       DP_GG                    = '#DP_GG#',
       GUIDE_DISC_MOTOR_LOCA    = '#GUIDE_DISC_MOTOR_LOCA#',
       DB_LOCA                  = '#DB_LOCA#',
       DB_LOCA_DOWN             = '#DB_LOCA_DOWN#',
       ROLL_MOTOR_SJB           = '#ROLL_MOTOR_SJB#',
       ZG_ZJ                    = '#ZG_ZJ#',
       DT_CODE                  = '#DT_CODE#',
       ZG_LOCA_UP               = '#ZG_LOCA_UP#',
       ZG_LOCA_DOWN             = '#ZG_LOCA_DOWN#',
       CAPILLARY_SIZE           = '#CAPILLARY_SIZE#',
       QA_TON                   = '#QA_TON#',
       COL_SHIFT                = '#COL_SHIFT#',
       COL_GROUP                = '#COL_GROUP#',
       USER_ID                  = '#USER_ID#',
       COL_USER                 = '#COL_USER#'
 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="PerforationResult.UpdateMainPlanStatue" desc="修改主计划状态">
    <![CDATA[
        update MIL_PLAN t
   set t.node_status = '30', T.STATUS = '30'
 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="PerforationResult.UpdateNodeRack" desc="修改跟踪表班次班组 结炉时间">
    <![CDATA[
		       update MIL_PERFORATION_RACK t
   set t.COL_SHIFT            = '#COL_SHIFT#',
       T.COL_GROUP            = '#COL_GROUP#',
       T.COL_USER             = '#COL_USER#',
       T.END_PERFORATION_TIME = SYSDATE
 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#','/')
   and t.COL_SHIFT is null
   and T.COL_GROUP is null
   and T.END_PERFORATION_TIME is null
   and mat_no is not null
        ]]>
	</query>
	
	<query id="PerforationResult.UpdateNodeRackEndTime" desc="交接班时上个班的结束时间为空时，补齐时间">
    <![CDATA[
		        UPDATE MIL_PERFORATION_RACK T
   SET T.END_PERFORATION_TIME =
       (SELECT MAX(M.START_PERFORATION_TIME)
          FROM MIL_PERFORATION_RACK M
         WHERE M.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO)
 WHERE T.END_PERFORATION_TIME IS NULL
   AND T.MAT_NO IS NOT NULL
   AND T.START_PERFORATION_TIME IS NOT NULL
   AND 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="PerforationResult.SingleFeedSawResult" desc="查询穿孔结炉标识实绩表">
        <![CDATA[
      SELECT NODE_FUR_FLAG
  FROM mil_fur_result
 WHERE JUDGE_STOVE_NO = ?
   AND PRO_PLAN_ID  || '&' LIKE '%' || ? || '%'
   AND GX_PLAN_NO  || '&' LIKE '%' || ? || '%'
        ]]>
	</query>
	<query id="PerforationResult.GetResult" desc="查询穿孔结炉标识实绩表">
        <![CDATA[
	       SELECT NODE_FUR_FLAG
  FROM MIL_PERFORATION_RESULT
 WHERE JUDGE_STOVE_NO || '&' LIKE '%' || ? || '%'
   AND PRO_PLAN_ID  || '&' LIKE '%' || ? || '%'
   AND GX_PLAN_NO  || '&' LIKE '%' || ? || '%'
        ]]>
	</query>


	<query id="PerforationResult.GetETResultNodeQuery" desc="结炉实绩查询">
        <![CDATA[
      SELECT 
       a.LOT_NO,
       a.JUDGE_STOVE_NO,
       a.PERFORATION_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,
       a.JZB_NUM,
       a.REMARK,
       b.DB_HEIGHT,
       c.BURNNING_RATE,
	       a.col_shift,
	       a.col_group,
	       a.col_user,
       a.QA_TON
 FROM MIL_PERFORATION_RESULT a,MIL_PLAN b,MIL_FUR_RESULT c
 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 B.JUDGE_STOVE_NO = C.JUDGE_STOVE_NO
	   	order by a.end_time
		    
        ]]>
	</query>




</queryMap>