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

<query id="PipeSawResult.SingleSawResultQuery" desc="加热 炉实绩">
        <![CDATA[
           
		    
        ]]>
	</query>
	<query id="PipeSawResult.GetSawResult" desc="查询分切实绩主表">
	<![CDATA[
	SELECT RESULT_NO,
       LOT_NO,
       STOVE_NO,
       JUDGE_STOVE_NO,
       PLINE_CODE,
       SAW_NUM,
       ORDER_LENGTH_MAX,
       ORDER_LENGTH_MIN,
       ORDER_LENGTH,
       CUT_HEAD_LENGTH,
       CUT_TRAIL_LENGTH,
       CUT_HEAD_LENGTH_TOTAL,
       CUT_TRAIL_LENGTH_TOTAL,
       CUT_HEAD_HEIGHT_TOTAL,
       CUT_TRAIL_HEIGTH_TOTAL,
       SCRAP_NUM,
       CUT_NUM,
       SCRAP_DBNUM,
       CUT_DBNUM,
       CHANGE_NUM,
       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,
       NVL(REMARK,'/') REMARK,
       COL_MODE,
       TO_CHAR(COL_TIME, 'YYYY-MM-DD HH24:MI:SS') COL_TIME,
       COL_USER,
       COL_SHIFT,
       COL_GROUP,
       TARGET_LENGTH,
       COL_THICK,
       CUT_TYPE,
       OFFLINE_NUM
  FROM MIL_SAW_RESULT
 WHERE 1 = 1
   AND JUDGE_STOVE_NO = ?
   AND PRO_PLAN_ID  || '&' LIKE '%' || ? || '%'
   AND GX_PLAN_NO  || '&' LIKE '%' || ? || '%'
   ]]>
	</query>
	<query id="PipeSawResult.RackSeqQuery" desc="查询管号队列">
        <![CDATA[
          SELECT SCRAP_DBNUM,
       '切前剔除' SCRAP,
       '切后剔除' SCRAP_DB,
       '剔料回退' DELBACK,
       MAT_NO,
       LOT_NO,
       STOVE_NO,
       JUDGE_STOVE_NO,
       STEELCODE,
       STEELNAME,
       GRADECODE,
       GRADENAME,
       PLINE_CODE,
       ROW_NO,
       ORDER_LENGTH,
       CUT_HEAD_LENGTH,
       CUT_TRAIL_LENGTH,
       SAW_NO,
       SAW_NO_N,
       CASE STATUS
         WHEN '0' THEN
          '正常轧制'
         WHEN '3' THEN
          '切前剔除'
         WHEN '4' THEN
          '切后剔除'
       END AS STATUS,
       TO_CHAR(START_SAW_TIME, 'YYYY-MM-DD HH24:MI:SS') START_SAW_TIME,
       TO_CHAR(END_SAW_TIME, 'YYYY-MM-DD HH24:MI:SS') END_SAW_TIME,
       OFFLINE_FLAG,
       TO_CHAR(OFFLINE_TIME, 'YYYY-MM-DD HH24:MI:SS') OFFLINE_TIME,
       FOLLOW_FLAG,
       FOLLOW_HEAT_NO,
       TO_CHAR(FOLLOW_TIME, 'YYYY-MM-DD HH24:MI:SS') FOLLOW_TIME,
       GROUP_FLAG,
       BEFORE_HEAT_NO,
       BEFORE_MAT_NO,
       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,
       SEQ,
       LAST_ORDER_LENGTH,
       case CUT_TYPE
         WHEN '0' THEN
          '被动切尾'
         WHEN '1' THEN
          '主动切尾'
       END AS CUT_TYPE,
       REAL_ROLL_LENGTH,
       CASE CHANGE_FLAG
         WHEN '0' THEN
          ''
         WHEN '1' THEN
          '确认交班'
         WHEN '2' THEN
          '待接班确认'
       END AS CHANGE_FLAG,
       COL_NO,
       SCRAP_REASON
  FROM MIL_SAW_RACK
 WHERE JUDGE_STOVE_NO = ?
   AND PRO_PLAN_ID  || '&' LIKE '%' || ? || '%'
   AND GX_PLAN_NO  || '&' LIKE '%' || ? || '%'
        ]]>
	</query>
	
		<query id="PipeSawResult.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="PipeSawResult.AddResult" desc="新增管排锯实绩">
    <![CDATA[
        INSERT INTO MIL_SAW_RESULT
  (RESULT_NO,
   LOT_NO,
   STOVE_NO,
   JUDGE_STOVE_NO,
   PLINE_CODE,
   START_TIME,
   NODE_FUR_FLAG,
   COL_MODE,
   COL_TIME,
   COL_USER,
   COL_SHIFT,
   COL_GROUP,
   SAW_NUM,
   ORDER_LENGTH,
   CUT_HEAD_LENGTH,
   CUT_TRAIL_LENGTH,
   CUT_TYPE,
   PRO_PLAN_ID,
   GX_PLAN_NO)
VALUES
  ('#RESULT_NO#',
   '#LOT_NO#',
   '#STOVE_NO#',
   '#JUDGE_STOVE_NO#',
   '#PLINE_CODE#',
   SYSDATE,
   '#NODE_FUR_FLAG#',
   '#COL_MODE#',
   SYSDATE,
   '#COL_USER#',
   '#COL_SHIFT#',
   '#COL_GROUP#',
   '#SAW_NUM#',
   '#ORDER_LENGTH#',
   '#CUT_HEAD_LENGTH#',
   '#CUT_TRAIL_LENGTH#',
   '#CUT_TYPE#',
   '#PRO_PLAN_ID#',
   '#GX_PLAN_NO#')
        ]]>
	</query>
	
	
		<query id="PipeSawResult.AddRowResult" desc="新增排号实绩">
    <![CDATA[
       INSERT INTO MIL_SAW_RESULT_DEATIL(
        ROW_NO,
        LOT_NO,
        STOVE_NO,
        JUDGE_STOVE_NO,
        PLINE_CODE,
        SAW_NO,
        SAW_NO_N,
        ROW_COUNT,
        COL_TIME,
        COL_USER,
        COL_SHIFT,
        COL_GROUP)
 VALUES( 
        '#ROW_NO#',
        '#LOT_NO#',
        '#STOVE_NO#',
        '#JUDGE_STOVE_NO#',
        '#PLINE_CODE#',
        '#SAW_NO#',
        '#SAW_NO_N#',
        '#ROW_COUNT#',
        SYSDATE,
        '#COL_USER#',
        '#COL_SHIFT#',
        '#COL_GROUP#')
		    
        ]]>
	</query>
	
	
			<query id="PipeSawResult.UpdateRowResult" desc="新增排号实绩">
    <![CDATA[
       UPDATE MIL_SAW_RESULT_DEATIL
   		SET 
     
      
        ROW_COUNT = '#ROW_COUNT#',
        ORDER_LENGTH = '#ORDER_LENGTH#',
        CUT_HEAD_LENGTH = '#CUT_HEAD_LENGTH#',
        CUT_TRAIL_LENGTH = '#CUT_TRAIL_LENGTH#',
        CUT_HEAD_LENGTH_TOTAL = '#CUT_HEAD_LENGTH_TOTAL#',
        CUT_TRAIL_LENGTH_TOTAL = '#CUT_TRAIL_LENGTH_TOTAL#',
        CUT_HEAD_HEIGHT_TOTAL = '#CUT_HEAD_HEIGHT_TOTAL#',
        CUT_TRAIL_HEIGTH_TOTAL = '#CUT_TRAIL_HEIGTH_TOTAL#',
        COL_MODE = '0',
        COL_TIME = SYSDATE,
        COL_USER = '#COL_USER#',
        COL_SHIFT = '#COL_SHIFT#',
        COL_GROUP = '#COL_GROUP#'
 WHERE
   ROW_NO = '#ROW_NO#' 
   	AND  
    JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
		    
        ]]>
	</query>
	
			<query id="PipeSawResult.UpdateResult" desc="新增排号实绩">
    <![CDATA[
       UPDATE MIL_SAW_RESULT
   SET 
        SAW_NUM = '#SAW_NUM#',
        ORDER_LENGTH_MAX = '#ORDER_LENGTH_MAX#',
        ORDER_LENGTH_MIN = '#ORDER_LENGTH_MIN#',
        ORDER_LENGTH = '#ORDER_LENGTH#',
        CUT_HEAD_LENGTH = '#CUT_HEAD_LENGTH#',
        CUT_TRAIL_LENGTH = '#CUT_TRAIL_LENGTH#',
        CUT_HEAD_LENGTH_TOTAL = '#CUT_HEAD_LENGTH_TOTAL#',
        CUT_TRAIL_LENGTH_TOTAL = '#CUT_TRAIL_LENGTH_TOTAL#',
        CUT_HEAD_HEIGHT_TOTAL = '#CUT_HEAD_HEIGHT_TOTAL#',
        CUT_TRAIL_HEIGTH_TOTAL = '#CUT_TRAIL_HEIGTH_TOTAL#',
        SCRAP_NUM = '#SCRAP_NUM#',
        CUT_NUM = '#CUT_NUM#',
        SCRAP_DBNUM = '#SCRAP_DBNUM#',
        CUT_DBNUM = '#CUT_DBNUM#',
        CHANGE_NUM = '#CHANGE_NUM#',
        END_TIME = SYSDATE,
        NODE_FUR_FLAG = '#NODE_FUR_FLAG#',
        REMARK = '#REMARK#',
        COL_TIME = SYSDATE,
        COL_USER = '#COL_USER#',
        COL_SHIFT = '#COL_SHIFT#',
        COL_GROUP = '#COL_GROUP#',
        TARGET_LENGTH = '#TARGET_LENGTH#',
        COL_THICK = '#COL_THICK#',
        CUT_TYPE = '#CUT_TYPE#'
 WHERE
    JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
		    
        ]]>
	</query>
	
	
			<query id="PipeSawResult.UpdateMainPlanNodeStatue" desc="新增排号实绩">
    <![CDATA[
        update MIL_PLAN t set t.NODE_STATUS ='#STATUS#'
        where t.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#' 
		    
        ]]>
	</query>
	
	
	<query id="PipeSawResult.UpdateFeedFeedNumStatue" desc="上料剔除后修改上料管状态">
        <![CDATA[
         UPDATE MIL_SAW_RACK
         SET 
         STATUS = '#STATUS#' 
         WHERE 
         SEQ = '#SEQ#' 
         AND JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#' 
        ]]>
	</query>
	
	<query id="PipeSawResult.UpdateFeedRowFeedNum" desc="修改上料计划表上料剔除、合格支数">
        <![CDATA[
        UPDATE MIL_SAW_RACK SET FEED_NUM = FEED_NUM - 1,
        SCRAP_FEEDNUM = SCRAP_FEEDNUM + 1,
        QUALIFIED_NUM = QUALIFIED_NUM - DB_NUM
        WHERE 
        JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
        AND FEED_ROW_NO = '#FEED_ROW_NO#'
		    
        ]]>
	</query>
	
	<query id="PipeSawResult.UpdateFeedDBNumStatue" desc="单倍剔除后修改上料管状态">
        <![CDATA[
         UPDATE MIL_SAW_RACK
         SET 
         STATUS = '#STATUS#' ,
         SCRAP_DBNUM = #SCRAP_DBNUM#
         WHERE 
         SEQ = '#SEQ_FOR_UPDATE#' 
         AND JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#' 
        ]]>
	</query>
	
	<query id="PipeSawResult.UpdateFeedRowDBNum" desc="修改上料计划表单倍坯剔除、合格支数">
        <![CDATA[
        UPDATE MIL_SAW_RACK SET 
        SCRAP_DBNUM = SCRAP_DBNUM + 1,
         QUALIFIED_NUM =  QUALIFIED_NUM -1
        WHERE 
        JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
        AND FEED_ROW_NO = '#FEED_ROW_NO#'
		    
        ]]>
	</query>
	
	<query id="PipeSawResult.GetResultDetail" desc="查询该炉已切实绩明细">
	<![CDATA[
	 SELECT ROW_NO,
       LOT_NO,
       STOVE_NO,
       JUDGE_STOVE_NO,
       PLINE_CODE,
       SAW_NO,
       SAW_NO_N,
       ROW_COUNT,
       ORDER_LENGTH,
       CUT_HEAD_LENGTH,
       CUT_TRAIL_LENGTH,
       CUT_HEAD_LENGTH_TOTAL,
       CUT_TRAIL_LENGTH_TOTAL,
       CUT_HEAD_HEIGHT_TOTAL,
       CUT_TRAIL_HEIGTH_TOTAL,
       COL_MODE,
       TO_CHAR(COL_TIME, 'YYYY-MM-DD HH24:MI:SS') COL_TIME,
       COL_USER,
       COL_SHIFT,
       COL_GROUP,
       SAW_FLAG,
       COL_NO,
       CUT_SPEED,
       CUT_THICKNESS
  FROM MIL_SAW_RESULT_DEATIL
 WHERE 1 = 1
   AND JUDGE_STOVE_NO = ?
   AND PRO_PLAN_ID  || '&' LIKE '%' || ? || '%'
   AND GX_PLAN_NO  || '&' LIKE '%' || ? || '%'
 ORDER BY ROW_NO
 ]]>
	</query>
	<query id="PipeSawResult.AddResultDetail" desc="添加管排明细">
	 INSERT INTO MIL_SAW_RESULT_DEATIL(
        ROW_NO,
        LOT_NO,
        STOVE_NO,
        JUDGE_STOVE_NO,
        PLINE_CODE,
        SAW_NO,
        SAW_NO_N,
        ROW_COUNT,
        ORDER_LENGTH,
        CUT_HEAD_LENGTH,
        CUT_TRAIL_LENGTH,
        CUT_HEAD_LENGTH_TOTAL,
        CUT_TRAIL_LENGTH_TOTAL,
        CUT_HEAD_HEIGHT_TOTAL,
        CUT_TRAIL_HEIGTH_TOTAL,
        COL_MODE,
        COL_TIME,
        COL_USER,
        COL_SHIFT,
        COL_GROUP,
        SAW_FLAG)
 VALUES( 
        '#ROW_NO#',
        '#LOT_NO#',
        '#STOVE_NO#',
        '#JUDGE_STOVE_NO#',
        '#PLINE_CODE#',
        '#SAW_NO#',
        '#SAW_NO_N#',
        '#ROW_COUNT#',
        '#ORDER_LENGTH#',
        '#CUT_HEAD_LENGTH#',
        '#CUT_TRAIL_LENGTH#',
        '#CUT_HEAD_LENGTH_TOTAL#',
        '#CUT_TRAIL_LENGTH_TOTAL#',
        '#CUT_HEAD_HEIGHT_TOTAL#',
        '#CUT_TRAIL_HEIGTH_TOTAL#',
        '#COL_MODE#',
        SYSDATE,
        '#COL_USER#',
        '#COL_SHIFT#',
        '#COL_GROUP#',
        '#SAW_FLAG#')
	</query>
	<query id="PipeSawResult.UpdateResultDetail2#" desc="跟更新明细">
	 UPDATE MIL_SAW_RESULT_DEATIL
        SET 
        SAW_NO = '#SAW_NO#',
        SAW_NO_N = '#SAW_NO_N#',
        ROW_COUNT = '#ROW_COUNT#',
        ORDER_LENGTH = '#ORDER_LENGTH#',
        CUT_HEAD_LENGTH = '#CUT_HEAD_LENGTH#',
        CUT_TRAIL_LENGTH = '#CUT_TRAIL_LENGTH#',
        CUT_HEAD_LENGTH_TOTAL = '#CUT_HEAD_LENGTH_TOTAL#',
        CUT_TRAIL_LENGTH_TOTAL = '#CUT_TRAIL_LENGTH_TOTAL#',
        CUT_HEAD_HEIGHT_TOTAL = '#CUT_HEAD_HEIGHT_TOTAL#',
        CUT_TRAIL_HEIGTH_TOTAL = '#CUT_TRAIL_HEIGTH_TOTAL#',
        SAW_FLAG='2'
        WHERE
        SAW_FLAG='#SAW_FLAG#'
        AND SAW_NO_N='#SAW_NO_N#'
        AND JUDGE_STOVE_NO='#JUDGE_STOVE_NO#'
 
	</query>
	<query id="PipeSawResult.UpdateResultDetail1#" desc="跟更新明细">
	 UPDATE MIL_SAW_RESULT_DEATIL
        SET 
        SAW_NO = '#SAW_NO#',
        SAW_NO_N = '#SAW_NO_N#',
        ROW_COUNT = '#ROW_COUNT#',
        ORDER_LENGTH = '#ORDER_LENGTH#',
        CUT_HEAD_LENGTH = '#CUT_HEAD_LENGTH#',
        CUT_TRAIL_LENGTH = '#CUT_TRAIL_LENGTH#',
        CUT_HEAD_LENGTH_TOTAL = '#CUT_HEAD_LENGTH_TOTAL#',
        CUT_TRAIL_LENGTH_TOTAL = '#CUT_TRAIL_LENGTH_TOTAL#',
        CUT_HEAD_HEIGHT_TOTAL = '#CUT_HEAD_HEIGHT_TOTAL#',
        CUT_TRAIL_HEIGTH_TOTAL = '#CUT_TRAIL_HEIGTH_TOTAL#',
        SAW_FLAG='1'
        WHERE
        SAW_FLAG='#SAW_FLAG#'
        AND SAW_NO='#SAW_NO#'
        AND JUDGE_STOVE_NO='#JUDGE_STOVE_NO#'
 
	</query>

	<query id="PipeSawResult.UpdateResultDetailCUTEND" desc="锯切完成">
		UPDATE MIL_SAW_RESULT_DEATIL
		SET
		SAW_FLAG='3'
		WHERE
		ROW_NO='#ROW_NO#'
		AND JUDGE_STOVE_NO='#JUDGE_STOVE_NO#'
    </query>

	<query id="PipeSawResult.UpdateSawRackRowNo" desc="更新跟踪记录表排号(之前剔除的怎么弄？)">
		 update Mil_Saw_Rack  set 
         ROW_NO = '#ROW_NO#',
         CUT_HEAD_LENGTH = '#CUT_HEAD_LENGTH#',
         SAW_NO = '#SAW_NO#',
         SAW_NO_N = '#SAW_NO_N#'
		 where judge_stove_no='#JUDGE_STOVE_NO#'
		 AND Row_No is null 
		 AND STATUS='0'
		 AND ROWNUM between '1' AND '#ROW_COUNT#'
	</query >
	<query id="PipeSawResult.UpdateSawRack"  desc="更新跟踪记录表">
	     update Mil_Saw_Rack  set 
	     ORDER_LENGTH = '#ORDER_LENGTH#',
         CUT_TRAIL_LENGTH = '#CUT_TRAIL_LENGTH#',
         SAW_NO = '#SAW_NO#',
         SAW_NO_N = '#SAW_NO_N#'
         where judge_stove_no='#JUDGE_STOVE_NO#'
         AND ROW_NO = '#ROW_NO#'
	</query>
	<query id="PipeSawResult.GetSawRack" desc="获取跟踪记录表记录">
	 SELECT 
       MAT_NO,
       LOT_NO,
       STOVE_NO,
       JUDGE_STOVE_NO,
       STEELCODE,
       STEELNAME,
       GRADECODE,
       GRADENAME,
       PLINE_CODE,
       ROW_NO,
       ORDER_LENGTH,
       CUT_HEAD_LENGTH,
       CUT_TRAIL_LENGTH,
       SAW_NO,
       SAW_NO_N,
       STATUS,
       TO_CHAR(START_SAW_TIME, 'YYYY-MM-DD HH24:MI:SS') START_SAW_TIME,
       TO_CHAR(END_SAW_TIME, 'YYYY-MM-DD HH24:MI:SS') END_SAW_TIME,
       OFFLINE_FLAG,
       TO_CHAR(OFFLINE_TIME, 'YYYY-MM-DD HH24:MI:SS') OFFLINE_TIME,
       FOLLOW_FLAG,
       FOLLOW_HEAT_NO,
       TO_CHAR(FOLLOW_TIME, 'YYYY-MM-DD HH24:MI:SS') FOLLOW_TIME,
       GROUP_FLAG,
       BEFORE_HEAT_NO,
       BEFORE_MAT_NO,
       REMARK,
       COL_MODE,
       TO_CHAR(COL_TIME, 'YYYY-MM-DD HH24:MI:SS') COL_TIME,
       COL_USER,
       COL_SHIFT,
       COL_GROUP,
       SCRAP_DBNUM,
       SEQ
       FROM MIL_SAW_RACK
       WHERE
       1=1
       AND JUDGE_STOVE_NO='#JUDGE_STOVE_NO#'
	</query>
	<query id="PipeSawResult.AddScrapSlabSeq" desc="新增剔除管号序列">
	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,
   COL_NO,
   MAT_NO,
   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#',
   '#COL_NO#',
   '#MAT_NO#',
   '#PRO_PLAN_ID#',
   '#GX_PLAN_NO#')
	</query>
	<query id="PipeSawResult.UpdateFurStatue" desc="修改管排锯跟踪表物料状态">
	UPDATE Mil_Saw_Rack T
   SET STATUS       = '#STATUS#',
       SCRAP_REASON = '#SCRAP_REASON#',
       SCRAP_TIME   = SYSDATE
 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="PipeSawResult.UpdateFurScrapNum" desc="修改管排锯实绩表剔除支数">
	UPDATE Mil_SAW_Result
   SET SCRAP_NUM = SCRAP_NUM + 1,
       CUT_NUM  =
       (case nvl(CUT_NUM, 0)
         WHEN 0 THEN
          0
         ELSE
          CUT_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="PipeSawResult.UpdateFurStatueDB" desc="修改管排锯跟踪表物料状态">
	UPDATE Mil_Saw_Rack T
   SET STATUS       = '#STATUS#',
       SCRAP_REASON = '#SCRAP_REASON#',
       SCRAP_DBNUM  = '#SCRAP_DBNUM#',
       SCRAP_TIME   = SYSDATE
 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="PipeSawResult.UpdateFurScrapNumDB" desc="修改管排锯实绩表剔除支数">
	UPDATE Mil_SAW_Result
   SET SCRAP_DBNUM = SCRAP_DBNUM + '#SCRAP_DBNUM#',
       CUT_DBNUM  =
       (case nvl(CUT_DBNUM, 0)
         WHEN 0 THEN
          0
         ELSE
          CUT_DBNUM - #SCRAP_DBNUM#
       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="PipeSawResult.UpdateRackRowNo" desc="修改管号队列排号">
	 UPDATE MIL_SAW_RACK T
   SET T.ROW_NO = '#ROW_NO#'
 WHERE T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
   AND T.SEQ = '#SEQ#'
   AND NVL(T.PRO_PLAN_ID,'/') = NVL('#PRO_PLAN_ID#','/')
   AND NVL(T.GX_PLAN_NO,'/') = NVL('#GX_PLAN_NO#','/')
	</query>
	<query id="PipeSawResult.UpdateSawDetailRowNoafter" desc="修改排支数">
	 UPDATE MIL_SAW_RESULT_DEATIL T
   SET T.ROW_COUNT = T.ROW_COUNT + 1
 WHERE 1 = 1
   AND T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
   AND T.ROW_NO = '#ROW_NO#'
   AND NVL(T.PRO_PLAN_ID,'/') = NVL('#PRO_PLAN_ID#','/')
   AND NVL(T.GX_PLAN_NO,'/') = NVL('#GX_PLAN_NO#','/')
	</query>
	<query id="PipeSawResult.UpdateRackCutType" desc="">
	UPDATE MIL_SAW_RACK T 
    SET T.CUT_TYPE='#CUT_TYPE#',
    T.REAL_ROLL_LENGTH='#REAL_ROLL_LENGTH#',
    T.LAST_ORDER_LENGTH='#LAST_ORDER_LENGTH#'
    WHERE T.JUDGE_STOVE_NO='#JUDGE_STOVE_NO#'
    AND T.SEQ='#SEQ#'
	</query>
	
	<query id="PipeSawResult.UpdateSawResult" desc="插入实绩表">
	     UPDATE MIL_SAW_RESULT
   SET CUT_HEAD_LENGTH        = '#CUT_HEAD_LENGTH#',
       CUT_HEAD_LENGTH_TOTAL  = #CUT_HEAD_LENGTH# * #CUT_NUM# / 1000,
       CUT_TRAIL_LENGTH       = '#CUT_TRAIL_LENGTH#',
       CUT_TRAIL_LENGTH_TOTAL = #CUT_TRAIL_LENGTH# * #CUT_NUM# / 1000,
       SCRAP_NUM              = '#SCRAP_NUM#',
       CUT_NUM                = '#CUT_NUM#',
       SCRAP_DBNUM            = '#SCRAP_DBNUM#',
       CHANGE_NUM             = '#CHANGE_NUM#',
       REMARK                 = '#REMARK#',
       TARGET_LENGTH          = '#TARGET_LENGTH#',
       COL_THICK              = '#COL_THICK#',
       CUT_TYPE               = '#CUT_TYPE#',
       START_TIME             = to_date('#START_TIME#',
                                        'yyyy-mm-dd hh24:mi:ss')
 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="PipeSawResult.UpdateSawResultsaveflag" desc="更新实绩">
	UPDATE MIL_SAW_RESULT
   SET SAW_NUM          = '#SAW_NUM#',
       CUT_HEAD_LENGTH  = '#CUT_HEAD_LENGTH#',
       CUT_TRAIL_LENGTH = '#CUT_TRAIL_LENGTH#',
       REMARK           = '#REMARK#',
       TARGET_LENGTH    = '#TARGET_LENGTH#',
       COL_THICK        = '#COL_THICK#',
       CUT_TYPE         = '#CUT_TYPE#',
       START_TIME       = to_date('#START_TIME#', 'yyyy-mm-dd hh24:mi:ss')
 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="PipeSawResult.UpdateSawResultNode" desc="更新实绩表（包括结炉时间,结炉状态）">
	 UPDATE MIL_SAW_RESULT
   SET SAW_NUM                = '#SAW_NUM#',
       CUT_HEAD_LENGTH        = '#CUT_HEAD_LENGTH#',
       CUT_TRAIL_LENGTH       = '#CUT_TRAIL_LENGTH#',
       SCRAP_NUM              = '#SCRAP_NUM#',
       CUT_NUM                = '#CUT_NUM#',
       CUT_DBNUM              = '#CUT_DBNUM#',
       SCRAP_DBNUM            = '#SCRAP_DBNUM#',
       CHANGE_NUM             = '#CHANGE_NUM#',
       END_TIME               = SYSDATE,
       REMARK                 = '#REMARK#',
       TARGET_LENGTH          = '#TARGET_LENGTH#',
       COL_THICK              = '#COL_THICK#',
       CUT_TYPE               = '#CUT_TYPE#',
       NODE_FUR_FLAG          = '1',
       QA_TON                 = '#QA_TON#',
       CUT_HEAD_HEIGHT_TOTAL  = '#CUT_HEAD_HEIGHT_TOTAL#',
       CUT_TRAIL_HEIGTH_TOTAL = '#CUT_TRAIL_HEIGTH_TOTAL#',
       CUT_HEAD_LENGTH_TOTAL  = '#CUT_HEAD_LENGTH_TOTAL#',
       CUT_TRAIL_LENGTH_TOTAL = '#CUT_TRAIL_LENGTH_TOTAL#',
       USER_ID                = '#USER_ID#'
 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="PipeSawResult.UpdateMilPlanNode" desc="更新主表NODE_STATUS">
	    update MIL_PLAN t
   set t.node_status = '70'
 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="PipeSawResult.UpdateSawRackShift" desc="更新管号队列班次班组">
	 UPDATE MIL_SAW_RACK T
   SET T.COL_USER  = '#COL_USER#',
       T.COL_SHIFT = '#COL_SHIFT#',
       T.COL_GROUP = '#COL_GROUP#'
 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_USER is null
   AND T.COL_SHIFT is null
   AND T.COL_GROUP is null
   AND T.MAT_NO is not null
	</query>
	<query id="PipeSawResult.UpdateResultShift" desc="">
	UPDATE MIL_SAW_RESULT T
   SET T.COL_SHIFT = '#COL_SHIFT#',
       T.COL_GROUP = '#COL_GROUP#',
       T.COL_USER  = '#COL_USER#'
 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="PipeSawResult.GetMIL_SIZING_RESULT" desc="">
	<![CDATA[
	select t.Node_Fur_Flag
  from MIL_SIZING_RESULT t
 where t.judge_stove_no = ?
   AND T.PRO_PLAN_ID  || '&' LIKE '%' || ? || '%'
   AND T.GX_PLAN_NO  || '&' LIKE '%' || ? || '%'
   ]]>
	</query>
	<query id="PipeSawResult.GetSingleNodeResult" desc="查询结炉实绩">
	 SELECT 
       RESULT_NO,
       LOT_NO,
       STOVE_NO,
       JUDGE_STOVE_NO,
       PLINE_CODE,
       SAW_NUM,
       CUT_HEAD_LENGTH,
       CUT_TRAIL_LENGTH,
       CUT_HEAD_LENGTH_TOTAL,
       CUT_TRAIL_LENGTH_TOTAL,
       CUT_HEAD_HEIGHT_TOTAL,
       CUT_TRAIL_HEIGTH_TOTAL,
       SCRAP_NUM,
       CUT_NUM,
       SCRAP_DBNUM,
       CUT_DBNUM,
       NODE_FUR_FLAG,
      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,
               QA_TON,
               CHANGE_NUM,
               REMARK
       FROM MIL_SAW_RESULT
       WHERE
       1=1
       AND PLINE_CODE=?
       AND COL_SHIFT=?
       AND COL_GROUP=?
       AND END_TIME BETWEEN TO_DATE(?,'YYYY-MM-DD HH24:MI:SS') AND TO_DATE(?,'YYYY-MM-DD HH24:MI:SS')
       AND NODE_FUR_FLAG='1'
	</query>
	<query id="PipeSawResult.QuNum" desc="">
	UPDATE MIL_SAW_RESULT
        SET
        CUT_NUM = '#CUT_NUM#',
        CUT_DBNUM='#CUT_DBNUM#',
        QA_TON='#QA_TON#'
        WHERE
        1=1
        AND JUDGE_STOVE_NO='#JUDGE_STOVE_NO#'
	</query>
	<query id = "updateProcessP.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.PRO_PLAN_ID  || '&' LIKE '%' || ? || '%'
   AND T.GX_PLAN_NO  || '&' LIKE '%' || ? || '%'
   AND T.PROCESS_NO IN ('7', '8')
   ]]>
    </query>
    <query id = "updateProcessP.UpdateFlag" desc = "上料切前剔除修改进程表">
    <![CDATA[
    DECLARE
V_NUM MIL_SAW_RACK.SCRAP_DBNUM%TYPE := NULL;
BEGIN
  IF ('#PROCESS_NO#' = 7) THEN
    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#';
  ELSIF ('#PROCESS_NO#' = 8) THEN
    SELECT T.SCRAP_DBNUM INTO V_NUM FROM MIL_SAW_RACK T WHERE T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#' AND T.MAT_NO = '#MAT_NO#';
    UPDATE PORT_MIL_BATCH_SAMPLE_RESULT T
       SET T.STATUS = '2', T.OP_PROCESS = '#OP_PROCESS#'
     WHERE T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
       AND T.MAT_NO LIKE '%#MAT_NO#%'
       AND ROWNUM <= V_NUM;
  END IF;
END;
]]>
    </query>
    <query id = "PipeSawResult.updateMilSlab" desc = "结炉赋值材料号给剔废表">
    <![CDATA[
   DECLARE
BEGIN
  FOR MYROW IN (SELECT T.PROCESS_NO
                  FROM MIL_SLAB_SCRAP_SEQ T
                 WHERE T.JUDGE_STOVE_NO = ?
                   AND T.PRO_PLAN_ID  || '&' LIKE '%' || ? || '%'
                   AND T.GX_PLAN_NO  || '&' LIKE '%' || ? || '%'
                   AND T.PROCESS_NO IN ('7', '8')) LOOP
    IF (MYROW.PROCESS_NO = 7) THEN
      FOR MYROW1 IN (SELECT T.SEQ, T.MAT_NO, T.JUDGE_STOVE_NO
                       FROM MIL_SAW_RACK T
                      WHERE T.JUDGE_STOVE_NO = ?
                        AND T.PRO_PLAN_ID  || '&' LIKE '%' || ? || '%'
                        AND T.GX_PLAN_NO  || '&' LIKE '%' || ? || '%'
                        AND T.STATUS = '3'
                      ORDER BY T.SEQ) LOOP
        UPDATE MIL_SLAB_SCRAP_SEQ T
           SET T.MAT_NO = MYROW1.MAT_NO
         WHERE T.JUDGE_STOVE_NO = MYROW1.JUDGE_STOVE_NO
           AND T.SEQ = MYROW1.SEQ
           AND T.PROCESS_NO = '7';
      END LOOP;
    ELSE
      FOR MYROW2 IN (SELECT T.SEQ, T.MAT_NO, T.JUDGE_STOVE_NO, T.SCRAP_DBNUM
                       FROM MIL_SAW_RACK T
                      WHERE T.JUDGE_STOVE_NO = ?
                        AND T.PRO_PLAN_ID  || '&' LIKE '%' || ? || '%'
                        AND T.GX_PLAN_NO  || '&' LIKE '%' || ? || '%'
                        AND T.STATUS = '4'
                      ORDER BY T.SEQ) LOOP
        UPDATE MIL_SLAB_SCRAP_SEQ T
           SET T.MAT_NO = MYROW2.MAT_NO
         WHERE T.JUDGE_STOVE_NO = MYROW2.JUDGE_STOVE_NO
           AND T.PROCESS_NO = '8'
           AND T.MAT_NO IS NULL
           AND ROWNUM <= MYROW2.SCRAP_DBNUM;
      END LOOP;
    END IF;
  END LOOP;
END;
    ]]>
    </query>
    <query id = "doUpdatePorcess.updateLen" desc = "分切后修改长度修改进程表">
    DECLARE
BEGIN
  FOR MYROW IN (SELECT T3.SEQ, T3.M_MAT_NO, T.ORDER_LENGTH
                  FROM (SELECT ROWNUM SEQ, M_MAT_NO
                          FROM (SELECT T.M_MAT_NO
                                  FROM PORT_MIL_BATCH_SAMPLE_RESULT T
                                 WHERE T.JUDGE_STOVE_NO = ?
                                   AND T.STATUS = '0'
                                 GROUP BY T.M_MAT_NO
                                 ORDER BY T.M_MAT_NO ASC)) T3,
                       MIL_SAW_RACK T
                 WHERE T.JUDGE_STOVE_NO = ?
                   AND T.ORDER_LENGTH IS NOT NULL
                   AND T.SEQ = T3.SEQ
                   AND T.ROW_NO = ?) LOOP
    UPDATE PORT_MIL_BATCH_SAMPLE_RESULT T
       SET T.ORDER_LENGTH      = ?,
           T.ACT_THEORY_WEIGHT = ?
     WHERE T.JUDGE_STOVE_NO = ?
       AND T.M_MAT_NO = MYROW.M_MAT_NO;
  END LOOP;
END;
    </query>
    
    <query id = "PipeSawResult.assignmentMatNo" desc = "复制材料号">
    <![CDATA[
	DECLARE
  CURSOR OPOrder_Cursor IS
    SELECT ROWNUM SEQ, MAT_NO, ORDER_LENGTH
      from (SELECT T.SEQ, T.MAT_NO, T.ORDER_LENGTH
              FROM PORT_MIL_BATCH_SAMPLE_RESULT T
             WHERE T.JUDGE_STOVE_NO = ?
               AND T.PRO_PLAN_ID  || '&' LIKE '%' || ? || '%'
               AND T.GX_PLAN_NO  || '&' LIKE '%' || ? || '%'
               AND (T.STATUS = '0' OR T.STATUS = '3' AND T.OP_PROCESS = '12')
             ORDER BY T.BATCH_NO DESC, T.IS_SAMPLE_PIPE, T.SEQ ASC);
  curOPOrder OPOrder_Cursor%RowType;
BEGIN
  open OPOrder_Cursor;
  LOOP
    fetch OPOrder_Cursor
      into curOPOrder;
    EXIT WHEN OPOrder_Cursor%NOTFOUND;
    UPDATE MIL_STRAIGH_RACK T
       SET T.MAT_NO      = curOPOrder.MAT_NO,
           T.PIPE_LENGTH = curOPOrder.ORDER_LENGTH
     WHERE T.JUDGE_STOVE_NO = ?
       AND T.PRO_PLAN_ID  || '&' LIKE '%' || ? || '%'
       AND T.GX_PLAN_NO  || '&' LIKE '%' || ? || '%'
       AND T.SEQ = curOPOrder.SEQ;
  END LOOP;
  close OPOrder_Cursor;
END;
]]>
	</query>
	<query id = "PipeSawResult.insertScrapSlab" desc = "插入废管子表">
	<![CDATA[
	DECLARE
  CURSOR OPOrder_Cursor IS
    SELECT ROWNUM SEQ, MAT_NO, ORDER_LENGTH, JUDGE_STOVE_NO
      from (SELECT T.SEQ, T.MAT_NO, T.ORDER_LENGTH, T.JUDGE_STOVE_NO
              FROM MIL_SAW_RACK T
             WHERE T.JUDGE_STOVE_NO = ?
               AND T.PRO_PLAN_ID  || '&' LIKE '%' || ? || '%'
               AND T.GX_PLAN_NO  || '&' LIKE '%' || ? || '%'
               AND T.STATUS = '3'
             ORDER BY T.SEQ ASC);
  curOPOrder OPOrder_Cursor%RowType;

  CURSOR OPOrder_Cursor1 IS
    SELECT ROWNUM SEQ, MAT_NO, ORDER_LENGTH, JUDGE_STOVE_NO
      from (SELECT T.SEQ, T.MAT_NO, T.ORDER_LENGTH, T.JUDGE_STOVE_NO
              FROM MIL_SAW_RACK T
             WHERE T.JUDGE_STOVE_NO = ?
               AND T.PRO_PLAN_ID  || '&' LIKE '%' || ? || '%'
               AND T.GX_PLAN_NO  || '&' LIKE '%' || ? || '%'
               AND T.STATUS = '4'
             ORDER BY T.SEQ ASC);
  curOPOrder1 OPOrder_Cursor1%RowType;
BEGIN
  open OPOrder_Cursor;
  LOOP
    fetch OPOrder_Cursor
      into curOPOrder;
    EXIT WHEN OPOrder_Cursor%NOTFOUND;
    insert into mil_slab_scrap
      (judge_stove_no,
       process_no,
       mat_no,
       pline_code,
       PRO_PLAN_ID,
       GX_PLAN_NO)
    values
      (curOPOrder.JUDGE_STOVE_NO, '7', curOPOrder.MAT_NO, ?, ?, ?);
  END LOOP;
  close OPOrder_Cursor;

  open OPOrder_Cursor1;
  LOOP
    fetch OPOrder_Cursor1
      into curOPOrder1;
    EXIT WHEN OPOrder_Cursor1%NOTFOUND;
    insert into mil_slab_scrap
      (judge_stove_no,
       process_no,
       mat_no,
       pline_code,
       PRO_PLAN_ID,
       GX_PLAN_NO)
    values
      (curOPOrder1.JUDGE_STOVE_NO, '8', curOPOrder1.MAT_NO, ?, ?, ?);
  END LOOP;
  close OPOrder_Cursor1;
END;
]]>
	</query>
	<query id = "PipeSawResult.updateSlabSeq" desc = "清空废品支表材料号">
	<![CDATA[
	UPDATE MIL_SLAB_SCRAP_SEQ T
   SET T.MAT_NO = ''
 WHERE T.JUDGE_STOVE_NO = ?
   AND T.PRO_PLAN_ID  || '&' LIKE '%' || ? || '%'
   AND T.GX_PLAN_NO  || '&' LIKE '%' || ? || '%'
   AND T.PROCESS_NO IN ('7', '8')
   ]]>
	</query>
	</queryMap>