<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="热轧抽检记录">


    	<query id="HotCheck.CheckHotCheckDetail" desc="查询热取样详细记录">
    	  <![CDATA[
		select
		b.INSPECTOR,
		b.CHECK_DATE,
		b.COL_SHIFT,
		b.COL_GROUP,
		CASE t.PIPE_LOCATION 
		WHEN '0' THEN '管头'
		WHEN '1' THEN '管体'
		WHEN '2' THEN '管尾' end AS PIPE_LOCATION,
    t.judge_stove_no,t.PASS_SERIES,t.DOUBLE_B,t.d1,t.d2,t.d3,t.d4,t.dmax,t.dmin,t.s1,t.s2,t.s3,t.s4,t.s5,t.s6,t.s7,t.s8,t.smax,t.smin,
    case t.COL_SHIFT 
      WHEN '0' THEN '常白班'
       WHEN '1' THEN '早班'
       WHEN '2' THEN '中班'
       WHEN '3' THEN '夜班'
                end as COL_SHIFT_D,
       case t.COL_GROUP
       WHEN '1' THEN '甲'
       WHEN '2' THEN '乙'
       WHEN '3' THEN '丙'
       WHEN '4' THEN '丁'
               end as COL_GROUP_D,
      t.COL_USER,
      TO_CHAR(t.COL_TIME, 'YYYY-MM-DD HH24:MI:SS') COL_TIME
		from mil_hot_check_detail t  , 
		mil_hot_check b 
		where
		t.judge_stove_no=? 
		and t.result_no = ?
	    and t.COL_SHIFT || '&' LIKE '%' || ? || '%'
	    and t.COL_GROUP || '&' LIKE '%' || ? || '%'
		and t.judge_stove_no = b.judge_stove_no
		order by t.col_time,t.PIPE_LOCATION
		 ]]>
    </query> 
    
    
    	<query id="HotCheck.CheckHotCheck" desc="查询主表记录">
	select a.judge_stove_no,
       a.id,
       a.cut_head_lengthp,
       a.cut_trail_lengthp,
       a.target_length,
       a.cut_head_lengtha,
       a.cut_trail_lengtha,
       a.order_lengtha,
       b.PASS_SERIES1,
       b.PASS_SERIES2,
       b.PASS_SERIES3,
       b.PASS_SERIES4,
       b.DOUBLE_B1,
       b.DOUBLE_B2,
       b.DOUBLE_B3,
       b.DOUBLE_B4,
       b.START_TEMP,
       b.END_TEMP,
       B.OUTDIAMETER,
       B.WALLTHICK,
       b.inspector,
       b.check_date,
       b.remark
  from mil_plan a, mil_hot_check b
 where a.judge_stove_no = b.judge_stove_no(+)
   and a.id = b.result_no(+)
   and a.judge_stove_no = ?
   and a.id = ?
    </query>
    
    	<query id="HotCheck.getLotNoInFurPlan" desc="从中间表装炉计划中查询是否存在该批号">
		
    <![CDATA[
SELECT TOP 1 [id]
      ,[产线计划id]
      ,[序号]
      ,[炼钢计划跟踪号]
      ,[ZC]
      ,[轧批号]
      ,[上料炉号]
      ,[产出炉号]
      ,[钢种]
      ,[坯断面]
      ,[坯长度上料]
      ,[单倍尺长度]
      ,[坯标准]
      ,[坯子倍尺]
      ,[余长轧否轧切]
      ,[轧制长度m]
      ,[分切]
      ,[目标长度m]
      ,[成品计划支]
      ,[成品计划吨]
      ,[工艺状态]
      ,[产线]
      ,[计划年月]
      ,[合同号]
      ,[工艺号]
      ,[备注]
      ,[标识炉号]
      ,[管坯上料支]
      ,[管坯上料单倍尺支]
      ,[管坯上料吨]
      ,[定尺长度]
      ,[切余长度]
      ,[切余处理]
      ,[切余重]
      ,[使用长度]
      ,[上料切余重]
      ,[KIND]
      ,[STEELLEVEL]
      ,[WAIJING]
      ,[BIHOU]
      ,[ZGSTANDARD]
      ,[LGSTANDARD]
      ,[CUSTOMER]
      ,[pikind]
      ,[TARGET]
      ,[LENGTHMIN]
      ,[LENGTHMAX]
      ,[cxstu]
      ,[cxupdatedate]
      ,[changedate]
      ,[CREATEDATE]
      ,[QIET]
      ,[QIEW]
      ,[CPSTANDARD]
      ,[JZ]
      ,[LENGTHCP]
  FROM [dbo].[tabcxslsj] WHERE [产出炉号] = ?


 ]]>

    </query> 
    
    
    <query id="HotCheck.InsertHotCheck" desc="插入主表记录">
		 INSERT INTO MIL_HOT_CHECK(
        JUDGE_STOVE_NO,
        STANDARD,
        KIDN,
        STEEL,
        GRADE,
        PIPE_SIZE,
        SERAL_NUM,
        COL_SHIFT,
        COL_GROUP,
        INSPECTOR,
        CHECK_DATE,
        REMARK)
 VALUES( 
        '#JUDGE_STOVE_NO#',
        '#STANDARD#',
        '#KIDN#',
        '#STEEL#',
        '#GRADE#',
        '#PIPE_SIZE#',
        '#SERAL_NUM#',
        '#COL_SHIFT#',
        '#COL_GROUP#',
        '#INSPECTOR#',
        SYSDATE,
        '#REMARK#')
    </query>
    <query id="HotCheck.InsertHotCheckDetail" desc="新增子表主表记录">
		INSERT INTO MIL_HOT_CHECK_DETAIL(
        JUDGE_STOVE_NO,
        RESULT_NO,
        PIPE_LOCATION,
        PASS_SERIES,
        DOUBLE_B,
        D1,
        D2,
        D3,
        D4,
        S1,
        S2,
        S3,
        S4,
        S5,
        S6,
        S7,
        S8,
        COL_SHIFT,
        COL_GROUP,
        COL_USER,
        COL_TIME)
 VALUES( 
        '#JUDGE_STOVE_NO#',
         '#RESULT_NO#',
        '#PIPE_LOCATION#',
         '#PASS_SERIES#',
          '#DOUBLE_B#',
        '#D1#',
        '#D2#',
        '#D3#',
        '#D4#',

        '#S1#',
        '#S2#',
        '#S3#',
        '#S4#',
        '#S5#',
        '#S6#',
        '#S7#',
        '#S8#',
        '#COL_SHIFT#',
        '#COL_GROUP#',
        '#COL_USER#',

    </query>

	<query id="HotCheck.UpdateHotCheck" desc="查询主表记录">
		 UPDATE MIL_HOT_CHECK
   SET 
        JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#',
        STANDARD = '#STANDARD#',
        KIDN = '#KIDN#',
        STEEL = '#STEEL#',
        GRADE = '#GRADE#',
        PIPE_SIZE = '#PIPE_SIZE#',
        SERAL_NUM = '#SERAL_NUM#',
        COL_SHIFT = '#COL_SHIFT#',
        COL_GROUP = '#COL_GROUP#',
        INSPECTOR = '#INSPECTOR#',
        CHECK_DATE = SYSDATE,
        REMARK = '#REMARK#'
        WHERE JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
    </query>
    <query id="HotCheck.UpdateHotCheckDetail" desc="查询从表记录">
 UPDATE MIL_HOT_CHECK_DETAIL
   SET 
        JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#',
        PIPE_LOCATION = '#PIPE_LOCATION#',
        PASS_SERIES = '#PASS_SERIES#',
        DOUBLE_B = '#DOUBLE_B#',
        D1 = '#D1#',
        D2 = '#D2#',
        D3 = '#D3#',
        D4 = '#D4#',
        DMAX = '#DMAX#',
        DMIN = '#DMIN#',
        S1 = '#S1#',
        S2 = '#S2#',
        S3 = '#S3#',
        S4 = '#S4#',
        S5 = '#S5#',
        S6 = '#S6#',
        S7 = '#S7#',
        S8 = '#S8#',
        SMAX = '#SMAX#',
        SMIN = '#SMIN#'
 WHERE JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#' AND PIPE_LOCATION = '#PIPE_LOCATION#'
    </query>
    
      <query id="HotCheck.getHotPlan" desc="查询主表记录">
        <![CDATA[
  SELECT A.LOT_NI,A.JUDGE_STOVE_NO,A.HOT_CHECH_FLAG,A.NODE_STATUS,A.ID,substring(A.JUDGE_STOVE_NO,0,6) AS JUDGE_NO,B.CUT_NUM,'选择' CHECK   
   FROM MIL_PLAN A,MIL_FEEDSAW_RESULT B
    WHERE A.LOT_NO || '&' LIKE '%' || ? || '%'
    AND A.JUDGE_STOVE_NO || '&' LIKE '%' || ? || '%'
    AND A.PLINE_CODE || '&' LIKE '%' || ? || '%'
    AND A.JUDGE_STOVE_NO = B.JUDGE_STOVE_NO(+)
    AND A.ID = B.RESULT_NO(+)
    ]]>
    </query>
    
    	<query id="HotCheck.GetHotCheckMainResult" desc="查询主表记录">
		 UPDATE MIL_HOT_CHECK
   SET 
        JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#',
        STANDARD = '#STANDARD#',
        KIDN = '#KIDN#',
        STEEL = '#STEEL#',
        GRADE = '#GRADE#',
        PIPE_SIZE = '#PIPE_SIZE#',
        SERAL_NUM = '#SERAL_NUM#',
        COL_SHIFT = '#COL_SHIFT#',
        COL_GROUP = '#COL_GROUP#',
        INSPECTOR = '#INSPECTOR#',
        CHECK_DATE = SYSDATE,
        REMARK = '#REMARK#'
        WHERE JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
    </query>
    
    <query id="HotCheck.getBackSlab" desc="合同号查询回炉坯">
     <![CDATA[
		select DB_LENGTH,GRADENAME,PIPE_SECTION,count(judge_stove_no) AS SLAB_NUM from
		(select a.judge_stove_no, b.DB_LENGTH,b.GRADENAME,b.PIPE_SECTION
 		 from mil_slab_scrap a, mil_plan b
		 where a.judge_stove_no = b.judge_stove_no
 		and a.flag = 0 
 		and a.process_no in (2,3)
 		and b.BACK_SLAB_FLAG  = '0'
 		 AND b.pline_code = ?
 		 AND b.GRADENAME || '&' LIKE '%' || ? || '%'
 		 AND b.DB_LENGTH || '&' LIKE '%' || ? || '%'
 		 AND b.PIPE_SECTION || '&' LIKE '%' || ? || '%'
 		 AND TO_CHAR(A.TIME, 'YYYYMMDD') || '&' LIKE '%' || ? || '%')
 		group by DB_LENGTH,GRADENAME,PIPE_SECTION
 		  ]]>
    </query>
    	<query id="HotCheck.getBackSlabForContractNo" desc="钢种长度断面查询回炉坯">
		select 'False' CHK,
    'False' CHKMAIN,
       a.judge_stove_no,
       REGEXP_REPLACE(A.JUDGE_STOVE_NO, '-.*', '') as Judge_no,
       CASE a.process_no
         WHEN '2' THEN
          '环形炉'
         WHEN '3' THEN
          '穿孔'
       END AS process_no,
       
       a.mat_no,
       a.group_flag,
       a.new_heat_no,
       a.handle_result,
       a.flag,
       a.remark,
       a.scrap_user,
       a.scrap_shift,
       a.scrap_group,
       a.time,
       a.col_user,
       a.col_time,
       a.col_shift,
       a.col_group,
       b.contract_no,
       b.lot_no,
       b.steelcode,
       b.steelname,
       b.gradecode,
       b.gradename,
       b.pipe_section,
       b.db_length,
       b.db_height,
       b.varieties,
       b.buckle_type,
       B.FINISH_USER,
       B.PIPE_SIZE,
       B.ROLL_LENGTH,
       b.pro_plan_id,
       b.gx_plan_no,
       B.ID RESULT_NO
  from mil_slab_scrap a, mil_plan b
 where a.judge_stove_no = b.judge_stove_no
   and a.process_no in (2, 3)
   and a.flag = '0'
   and b.BACK_SLAB_FLAG = '0'
   and b.gradename = ?
   and b.db_length = ?
   and b.pipe_section = ?
   and b.pline_code = ?
    </query>
    
    <query id="HotCheck.getBackSlabForJudgeStoveNo" desc="炉号查询已组回炉坯">
		select a.judge_stove_no,
       REGEXP_REPLACE(A.JUDGE_STOVE_NO, '-.*', '') as Judge_no,
       CASE a.process_no
         WHEN '2' THEN
          '环形炉'
         WHEN '3' THEN
          '穿孔'
       END AS process_no,
       a.mat_no,
       a.group_flag,
       a.new_heat_no,
       a.handle_result,
       a.flag,
       a.remark,
       a.scrap_user,
       a.scrap_shift,
       a.scrap_group,
       a.col_user,
       a.col_time,
       a.col_shift,
       a.col_group,
       b.contract_no,
       b.lot_no,
       b.steelcode,
       b.steelname,
       b.gradecode,
       b.gradename,
       b.pipe_section,
       b.db_length,
       b.db_height,
       b.varieties,
       b.buckle_type,
       B.FINISH_USER,
       B.PIPE_SIZE,
       B.ROLL_LENGTH,
       b.pro_plan_id,
       b.gx_plan_no
  from mil_slab_scrap a, mil_plan b
 where a.new_heat_no = b.judge_stove_no
   and b.judge_stove_no = ?
    </query>
    
 <query id="HotCheck.getBackSlabPlan" desc="查询已组回炉坯计划">
     <![CDATA[
		select t.judge_stove_no,
       REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '') as judge_no,
       t.lot_no,
       t.contract_no,
       t.back_slab_time,
       t.status,
       b.feed_num_plan as slab_num,
       t.pro_plan_id,
       t.gx_plan_no
  from mil_plan t, mil_feed_plan b
 where t.back_slab_flag = 1
   AND t.Pline_Code = ?
   AND t.judge_stove_no || '&' LIKE '%' || ? || '%'
   AND t.lot_no || '&' LIKE '%' || ? || '%'
   AND t.contract_no || '&' LIKE '%' || ? || '%'
      
   AND t.status = '00'
   AND t.judge_stove_no = b.judge_stove_no(+)
 order by t.back_slab_time
 		  ]]>
    </query>
     <query id="HotCheck.getBackSlabPlanStart" desc="查询已组回炉坯计划">
     <![CDATA[
		select t.judge_stove_no,
       REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '') as judge_no,
       t.lot_no,
       t.contract_no,
       t.back_slab_time,
       t.status,
       b.feed_num_plan as slab_num,
       t.pro_plan_id,
       t.gx_plan_no
  from mil_plan t, mil_feed_plan b
 where t.back_slab_flag = 1
   AND t.Pline_Code = ?
   AND t.judge_stove_no || '&' LIKE '%' || ? || '%'
   AND t.lot_no || '&' LIKE '%' || ? || '%'
   AND t.contract_no || '&' LIKE '%' || ? || '%'
      
   AND t.status > '00'
   AND t.judge_stove_no = b.judge_stove_no(+)
 order by t.back_slab_time
 		  ]]>
    </query>
    
    
         <query id="HotCheck.MainPlanForJudgeStoveNo" desc="炉号查询主表计划">
     <![CDATA[
		  SELECT T.SEQ,
       T.STOVE_NO,
       T.JUDGE_STOVE_NO,
       T.LOT_NO,
       T.CONTRACT_NO,
       T.IMP_PROCESS,
       T.PLINE_CODE,
       T.PRODUCER,
       T.PROCESS_STATUS,
       T.DB_LENGTH,
       T.DB_HEIGHT,
       T.ROLL_LENGTH,
       T.SAW_NUM,
       T.TARGET_LENGTH,
       T.FINISH_USER,
       T.TARGET_LIABRARY,
       T.VARIETIES,
       T.PIPE_SIZE,
       T.BUCKLE_TYPE,
       T.LENGTH_RANGE,
       T.ROLL_STANDRAD,
       T.PIPE_SECTION,
       T.STEELCODE,
       T.STEELNAME,
       T.GRADECODE,
       T.GRADENAME,
       T.STEEL_STANDRAD,
       T.TARGET,
       T.CUT_HEAD_LENGTHP,
       T.CUT_TRAIL_LENGTHP,
       T.CONTROL_THICKP,
       T.PRODUCE_STANDRAD,
       T.CUT_TYPE,
       T.FEED_HEAT_NO,
       T.LENGTHCP,
       T.ORD_LN_DLY_PK,
       T.PRT_FLAG,
       T.PRO_PLAN_ID,
       T.GX_PLAN_NO,
       DECODE(T.CRAFT_SEQ, '', '', NULL, '', T.CRAFT_SEQ) CRAFT_SEQ,
       NVL(T.CIC, '') CIC,
       NVL(T.INDEX_SEQ, '') INDEX_SEQ,
       NVL(T.PIC, '') PIC,
       NVL(T.IF_PRODUCT, '') IF_PRODUCT,
       NVL(T.PRDCR_NO, '') PRDCR_NO,
       NVL(T.IF_MONITOR, '') IF_MONITOR,
       T.ID,
       
       T.CUT_TARGET,
       T.CUT_LENGTH,
       T.CUT_WEIGHT,
       T.DB_NUM,
       TO_CHAR(T.START_TIME, 'YYYY-MM-DD HH24:MI:SS') START_TIME,
       TO_CHAR(T.END_TIME, 'YYYY-MM-DD HH24:MI:SS') END_TIME,
       TO_CHAR(T.TOM, 'YYYY-MM-DD HH24:MI:SS') TOM,
       TO_CHAR(T.TOC, 'YYYY-MM-DD HH24:MI:SS') TOC,
       T.NODE_STATUS,
       T.OFFLINE_FLAG,
       T.IS_BATCH,
       TO_CHAR(T.OFFLINE_DATE, 'YYYY-MM-DD HH24:MI:SS') OFFLINE_DATE,
       
       T.ROLLING_STATUS,
       
       T.SIMPLE_PROCESS,
       T.BACK_LINE_FLAG,
       T.BACK_PLAN_FLAG,
       T.FEED_SEQ,
       TO_CHAR(T.FEED_TIME, 'YYYY-MM-DD HH24:MI:SS') FEED_TIME,
       T.LOT_SEQ,
       
       T.CUT_HEAD_LENGTHA,
       T.CUT_TRAIL_LENGTHA,
       T.ORDER_LENGTHA,
       T.HOT_CHECK_FLAG,
       T.BACK_SLAB_FLAG,
       TO_CHAR(T.BACK_SLAB_TIME, 'YYYY-MM-DD HH24:MI:SS') BACK_SLAB_TIME

  FROM MIL_PLAN T
 WHERE T.JUDGE_STOVE_NO = ?
   AND NVL(T.PRO_PLAN_ID, '/') = NVL(?, '/')
   AND NVL(T.GX_PLAN_NO, '/') = NVL(?, '/')

 		  ]]>
    </query>
    
     <query id="HotCheck.MainPlanForContactNo" desc="合同号查询主表计划">
     <![CDATA[
	SELECT T.CONTRACT_NO,
       T.FINISH_USER,
       T.PIPE_SIZE,
       T.IMP_PROCESS,
       T.VARIETIES,
       T.BUCKLE_TYPE,
       T.LENGTH_RANGE,
       T.ROLL_STANDRAD,
       T.CONTROL_THICKP,
       T.PROCESS_STATUS,
       T.SAW_NUM,
       T.ROLL_STANDRAD,
       T.TARGET,
       MAX(T.PRO_PLAN_ID) PRO_PLAN_ID,
       MAX(T.GX_PLAN_NO) GX_PLAN_NO
  FROM MIL_PLAN T
 WHERE T.CONTRACT_NO = ?
 GROUP BY T.CONTRACT_NO,
          T.FINISH_USER,
          T.PIPE_SIZE,
          T.IMP_PROCESS,
          T.VARIETIES,
          T.BUCKLE_TYPE,
          T.LENGTH_RANGE,
          T.ROLL_STANDRAD,
          T.CONTROL_THICKP,
          T.PROCESS_STATUS,
          T.SAW_NUM,
          T.ROLL_STANDRAD,
          T.TARGET
	 		  ]]>
    </query>
    
         <query id="HotCheck.InsertBackMainPlan" desc="插入回炉坯主计划">
     <![CDATA[
      INSERT INTO MIL_PLAN(
        ID,
        SEQ,
        JUDGE_STOVE_NO,
        LOT_NO,
        CONTRACT_NO,
        IMP_PROCESS,
       
        PRODUCER,
        PROCESS_STATUS,
        DB_LENGTH,
        DB_HEIGHT,
        ROLL_LENGTH,
        SAW_NUM,
        TARGET_LENGTH,
        FINISH_USER,
        TARGET_LIABRARY,
        VARIETIES,
        PIPE_SIZE,
        BUCKLE_TYPE,
        LENGTH_RANGE,
        ROLL_STANDRAD,
        PIPE_SECTION,
        STEELCODE,
        STEELNAME,
        GRADECODE,
        GRADENAME,
        STEEL_STANDRAD,
        TARGET,     
        CUT_HEAD_LENGTHP,
        CUT_TRAIL_LENGTHP,
        CONTROL_THICKP,
        CUT_TYPE,
        PRODUCE_STANDRAD,
        FEED_HEAT_NO,
        LENGTHCP,
         PLINE_CODE,
        BACK_SLAB_FLAG,
           DB_NUM,
        BACK_SLAB_TIME,
     
        START_TIME,
        TOM)
 VALUES( 
        substr(SYS_GUID(),0,20),
        ?,
        ?,
        ?,
        ?,
        ?,
        ?,
        ?,
        ?,
        ?,
        ?,
        ?,
        ?,
        ?,
        ?,
        ?,
        ?,
        ?,
        ?,
        ?,
        ?,
        ?,
        ?,
        ?,
        ?,
        ?,
        ?,
        ?,
        ?,    
        ?,
        ?,
        ?,
        ?,
        ?,
        ?,
        ?,
             ?,
        SYSDATE,
    
        SYSDATE,
        SYSDATE)
       ]]>
    </query>
    
     <query id="HotCheck.insertMilPlan" desc="插入回炉坯计划">
     <![CDATA[
    DECLARE
  V_JUDGE_STOVE_NO MIL_SLAB_SCRAP.JUDGE_STOVE_NO%TYPE := ?;
  V_PRO_PLAN_ID    MIL_SLAB_SCRAP.PRO_PLAN_ID%TYPE := ?;
  V_GX_PLAN_NO     MIL_SLAB_SCRAP.GX_PLAN_NO%TYPE := ?;
  V_NEW_HEAT_NO    MIL_SLAB_SCRAP.NEW_HEAT_NO%TYPE := ?;
  V_NEW_LOT_NO     MIL_SLAB_SCRAP.NEW_LOT_NO%TYPE := ?;
  V_DB_NUM         MIL_PLAN.DB_NUM%TYPE := ?;
BEGIN
  FOR MYROW IN (SELECT T.*
                  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, '/')) LOOP
  
    INSERT INTO MIL_PLAN
      (ID,
       SEQ,
       STOVE_NO,
       JUDGE_STOVE_NO,
       LOT_NO,
       CONTRACT_NO,
       IMP_PROCESS,
       PLINE_CODE,
       STATUS,
       PRODUCER,
       PROCESS_STATUS,
       DB_LENGTH,
       DB_HEIGHT,
       ROLL_LENGTH,
       SAW_NUM,
       TARGET_LENGTH,
       FINISH_USER,
       TARGET_LIABRARY,
       VARIETIES,
       PIPE_SIZE,
       BUCKLE_TYPE,
       LENGTH_RANGE,
       ROLL_STANDRAD,
       PIPE_SECTION,
       STEELCODE,
       STEELNAME,
       GRADECODE,
       GRADENAME,
       STEEL_STANDRAD,
       TARGET,
       BRANCH,
       TON,
       CUT_TARGET,
       CUT_LENGTH,
       CUT_WEIGHT,
       DB_NUM,
       START_TIME,
       END_TIME,
       TOM,
       TOC,
       NODE_STATUS,
       CUT_HEAD_LENGTHP,
       CUT_TRAIL_LENGTHP,
       CONTROL_THICKP,
       OFFLINE_FLAG,
       IS_BATCH,
       OFFLINE_DATE,
       CUT_TYPE,
       ROLLING_STATUS,
       PRODUCE_STANDRAD,
       SIMPLE_PROCESS,
       BACK_LINE_FLAG,
       BACK_PLAN_FLAG,
       FEED_SEQ,
       FEED_TIME,
       LOT_SEQ,
       FEED_HEAT_NO,
       LENGTHCP,
       CUT_HEAD_LENGTHA,
       CUT_TRAIL_LENGTHA,
       ORDER_LENGTHA,
       HOT_CHECK_FLAG,
       BACK_SLAB_FLAG,
       BACK_SLAB_TIME,
       BATCH_MAX,
       CODE_SAMPLE_FLAG,
       VARIETIES_CODE,
       PIPE_SIZE_CODE,
       BUCKLE_TYPE_CODE,
       ROLL_STANDRAD_CODE,
       STD_STYLE,
       STD_STYLE_DESC,
       CHECK_NO,
       ORD_LN_DLY_PK,
       PRT_FLAG,
       PRO_PLAN_ID,
       GX_PLAN_NO,
       TUBE_TYPE,
       TUBE_SUORCE,
       PREDICT_PIECE,
       PREDICT_TON,
       TYPE,
       IS_LOAD,
       COL_TIME,
       COL_USER,
       COL_SHIFT,
       COL_GROUP,
       USER_ID,
       BAL_YEAR_MONTH,
       CRAFT_SEQ,
       CIC,
       INDEX_SEQ,
       PIC,
       IF_PRODUCT,
       PRDCR_NO,
       IF_MONITOR)
    VALUES
      (to_char(sysdate, 'YYYYMMDD') ||
       TO_CHAR(SEQ_BACKFURSLAB.NEXTVAL, 'FM000'),
       '0001',
       MYROW.STOVE_NO,
       V_NEW_HEAT_NO || '-01', --MYROW.JUDGE_STOVE_NO,
       V_NEW_LOT_NO, --MYROW.LOT_NO,
       MYROW.CONTRACT_NO,
       MYROW.IMP_PROCESS,
       MYROW.PLINE_CODE,
       '00',
       MYROW.PRODUCER,
       MYROW.PROCESS_STATUS,
       MYROW.DB_LENGTH,
       MYROW.DB_HEIGHT,
       MYROW.ROLL_LENGTH,
       MYROW.SAW_NUM,
       MYROW.TARGET_LENGTH,
       MYROW.FINISH_USER,
       MYROW.TARGET_LIABRARY,
       MYROW.VARIETIES,
       MYROW.PIPE_SIZE,
       MYROW.BUCKLE_TYPE,
       MYROW.LENGTH_RANGE,
       MYROW.ROLL_STANDRAD,
       MYROW.PIPE_SECTION,
       MYROW.STEELCODE,
       MYROW.STEELNAME,
       MYROW.GRADECODE,
       MYROW.GRADENAME,
       MYROW.STEEL_STANDRAD,
       MYROW.TARGET,
       MYROW.BRANCH,
       MYROW.TON,
       MYROW.CUT_TARGET,
       MYROW.CUT_LENGTH,
       MYROW.CUT_WEIGHT,
       V_DB_NUM, --MYROW.DB_NUM,
       SYSDATE,
       SYSDATE,
       SYSDATE,
       SYSDATE,
       '00',
       MYROW.CUT_HEAD_LENGTHP,
       MYROW.CUT_TRAIL_LENGTHP,
       MYROW.CONTROL_THICKP,
       MYROW.OFFLINE_FLAG,
       '0', --MYROW.IS_BATCH,
       SYSDATE,
       MYROW.CUT_TYPE,
       MYROW.ROLLING_STATUS,
       MYROW.PRODUCE_STANDRAD,
       MYROW.SIMPLE_PROCESS,
       MYROW.BACK_LINE_FLAG,
       MYROW.BACK_PLAN_FLAG,
       MYROW.FEED_SEQ,
       SYSDATE,
       MYROW.LOT_SEQ,
       MYROW.FEED_HEAT_NO,
       MYROW.LENGTHCP,
       MYROW.CUT_HEAD_LENGTHA,
       MYROW.CUT_TRAIL_LENGTHA,
       MYROW.ORDER_LENGTHA,
       MYROW.HOT_CHECK_FLAG,
       '1', --MYROW.BACK_SLAB_FLAG,
       SYSDATE,
       MYROW.BATCH_MAX,
       MYROW.CODE_SAMPLE_FLAG,
       MYROW.VARIETIES_CODE,
       MYROW.PIPE_SIZE_CODE,
       MYROW.BUCKLE_TYPE_CODE,
       MYROW.ROLL_STANDRAD_CODE,
       MYROW.STD_STYLE,
       MYROW.STD_STYLE_DESC,
       '', --MYROW.CHECK_NO,
       MYROW.ORD_LN_DLY_PK,
       MYROW.PRT_FLAG,
       MYROW.PRO_PLAN_ID,
       MYROW.GX_PLAN_NO,
       MYROW.TUBE_TYPE,
       MYROW.TUBE_SUORCE,
       MYROW.PREDICT_PIECE,
       MYROW.PREDICT_TON,
       MYROW.TYPE,
       MYROW.IS_LOAD,
       SYSDATE,
       MYROW.COL_USER,
       MYROW.COL_SHIFT,
       MYROW.COL_GROUP,
       MYROW.USER_ID,
       MYROW.BAL_YEAR_MONTH,
       MYROW.CRAFT_SEQ,
       MYROW.CIC,
       MYROW.INDEX_SEQ,
       MYROW.PIC,
       MYROW.IF_PRODUCT,
       MYROW.PRDCR_NO,
       MYROW.IF_MONITOR);
  END LOOP;
END;
       ]]>
    </query>
    
    
      <query id="HotCheck.InsertBackFeedPlan" desc="插入回炉坯上料行计划">
     <![CDATA[
     INSERT INTO MIL_FEED_PLAN
  (FEED_ROW_NO,
   SEQ,
   LOT_NO,
   JUDGE_STOVE_NO,
   PLINE_CODE,
   DB_NUM,
   MAT_HEIGHT,
   MAT_TOTAL_HEIGHT,
   FEED_NUM,
   FEED_LENGTH,
   USE_LENGTH,
   DB_LENGTH,
   PIPE_SECTION,
   DB_HEIGHT,
   QUALIFIED_NUM,
   FEED_NUM_PLAN,
   PRO_PLAN_ID,
   GX_PLAN_NO)
VALUES
  (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
       ]]>
    </query>
    
     <query id="HotCheck.UpdateGroupFlag" desc="修改进程表组炉标识">
     <![CDATA[
     DECLARE
  V_JUDGE_STOVE_NO MIL_SLAB_SCRAP.JUDGE_STOVE_NO%TYPE := ?;

BEGIN
  FOR MYROW IN (SELECT S.JUDGE_STOVE_NO, S.MAT_NO
                  FROM MIL_SLAB_SCRAP S
                 WHERE S.NEW_HEAT_NO = V_JUDGE_STOVE_NO || '-01') LOOP
  
    UPDATE PORT_MIL_BATCH_SAMPLE_RESULT T
       SET T.GROUP_FLAG = '1'
     WHERE T.JUDGE_STOVE_NO = MYROW.JUDGE_STOVE_NO
       AND T.M_MAT_NO = MYROW.MAT_NO
       AND T.STATUS = '1'
       AND EXISTS (SELECT 1
              FROM MIL_SLAB_SCRAP S
             WHERE S.GROUP_FLAG = '1'
               AND S.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO
               AND S.MAT_NO = T.M_MAT_NO);
  END LOOP;
END;
       ]]>
    </query>
    
    <query id="HotCheck.sqlTotalHeight" desc="回写回炉坯原材料的重量">
     <![CDATA[
     DECLARE
  V_JUDGE_STOVE_NO MIL_SLAB_SCRAP.JUDGE_STOVE_NO%TYPE := ?;
  V_PLINE_CODE     MIL_SLAB_SCRAP.PLINE_CODE%TYPE := ?;
  V_INPUT_WEIGHT   PORT_MIL_BATCH_SAMPLE_RESULT.INPUT_WEIGHT%TYPE := 0;

BEGIN
  select SUM(t1.input_weight)
    INTO V_INPUT_WEIGHT
    from MIL_SLAB_SCRAP t, port_mil_batch_sample_result t1
   where t.group_flag = 1
     and t.judge_stove_no = t1.judge_stove_no
     and t.mat_no = t1.m_mat_no
     and t1.group_flag = 1
     and t.new_heat_no = V_JUDGE_STOVE_NO
     AND T.PLINE_CODE = V_PLINE_CODE;

  UPDATE MIL_FEED_PLAN M
     SET M.MAT_TOTAL_HEIGHT = V_INPUT_WEIGHT
   WHERE M.JUDGE_STOVE_NO = V_JUDGE_STOVE_NO
     AND M.PLINE_CODE = V_PLINE_CODE;
END;
       ]]>
    </query>
    
    <query id = "HotCheck.SelectFeedNum" desc = "查询上料之后母管支数,分切数">
	SELECT T.FEED_NUM, T.DB_NUM, S.SAW_NUM, S.PIPE_SIZE, S.TARGET_LENGTH
  FROM MIL_FEED_PLAN T, MIL_PLAN S
 WHERE T.JUDGE_STOVE_NO = S.JUDGE_STOVE_NO
   AND T.LOT_NO = S.LOT_NO
   AND S.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
   AND S.LOT_NO = '#LOT_NO#'
   AND S.BACK_SLAB_FLAG = '1'
 ORDER BY T.FEED_ROW_NO ASC
	</query>
	
	 <query id = "HotCheck.SelectRESULT_NO" desc = "查询ID">
	select t.*
  from mil_plan t
 where t.back_slab_flag = '1'
   and t.judge_stove_no = ?
   and t.lot_no = ?
   and t.pline_code = ?
	</query>
</queryMap>
