<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="快速分切操作">
<query id="PipSawFast.Addsawdeatail" desc="插入sawdeatail">
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,
        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#',
        '#COL_MODE#',
        SYSDATE,
        '#COL_USER#',
        '#COL_SHIFT#',
        '#COL_GROUP#',
        '#SAW_FLAG#')
</query>
 
<query id="PipSawFast.UpdateSawRack" desc="更新管号队列">
 UPDATE MIL_SAW_RACK
   SET 
        ROW_NO = '#ROW_NO#',
        ORDER_LENGTH = '#ORDER_LENGTH#',
        CUT_HEAD_LENGTH = '#CUT_HEAD_LENGTH#',
        CUT_TRAIL_LENGTH = '#CUT_TRAIL_LENGTH#',
        SAW_NO = '#SAW_NO#',
        SAW_NO_N = '#SAW_NO_N#'
        WHERE
        1=1
        AND JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
        AND Row_No is null 
		AND STATUS='0'
		AND ROWNUM between '1' AND '#ROW_COUNT#' 
</query>
<query id = "PipSawFast.SelectsawdeatailNEW" desc = "查询是否已切头">
SELECT COUNT(1) ACOUNT
  FROM MIL_SAW_RESULT_DEATIL T
 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 = "PipSawFast.UpdatesawdeatailNEW" desc = "修改切头长度">
UPDATE MIL_SAW_RESULT_DEATIL T
   SET T.CUT_HEAD_LENGTH       = '#CUT_HEAD_LENGTH#',
       T.CUT_HEAD_LENGTH_TOTAL = '#CUT_HEAD_LENGTH_TOTAL#',
       T.CUT_SPEED = '#CUT_SPEED#',
       T.CUT_THICKNESS = '#CUT_THICKNESS#'
 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.PLINE_CODE = '#PLINE_CODE#'
</query>
<query id="PipSawFast.AddsawdeatailNEW" 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,
   CUT_HEAD_LENGTH,
   CUT_HEAD_LENGTH_TOTAL,
   COL_MODE,
   COL_TIME,
   COL_USER,
   COL_SHIFT,
   COL_GROUP,
   SAW_FLAG,
   PRO_PLAN_ID,
   GX_PLAN_NO,
   CUT_SPEED,
   CUT_THICKNESS)
VALUES
  ('#ROW_NO#',
   '#LOT_NO#',
   '#STOVE_NO#',
   '#JUDGE_STOVE_NO#',
   '#PLINE_CODE#',
   '#SAW_NO#',
   '#SAW_NO_N#',
   '#ROW_COUNT#',
   '#CUT_HEAD_LENGTH#',
   '#CUT_HEAD_LENGTH_TOTAL#',
   '#COL_MODE#',
   SYSDATE,
   '#COL_USER#',
   '#COL_SHIFT#',
   '#COL_GROUP#',
   '#SAW_FLAG#',
   '#PRO_PLAN_ID#',
   '#GX_PLAN_NO#',
   '#CUT_SPEED#',
   '#CUT_THICKNESS#')
</query>


<query id="PipSawFast.UpdateSawRackNEW" 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 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#','/')
   AND Row_No is null
   AND STATUS = '0'
   AND ROWNUM between '1' AND '#ROW_COUNT#'
</query>
<query id="PipSawFast.UpdateSawRackNEW1" desc="修改分切管号队列">
 UPDATE MIL_SAW_RACK T
   SET --ROW_NO = '#ROW_NO#',
       CUT_HEAD_LENGTH = '#CUT_HEAD_LENGTH#',
       SAW_NO          = '#SAW_NO#',
       SAW_NO_N        = '#SAW_NO_N#'
 WHERE 1 = 1
   AND 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 Row_No is not null
   AND STATUS = '0'
      --AND ROWNUM between '1' AND '#ROW_COUNT#' 
   AND ROW_NO = '#ROW_NO#'
</query>
<query id="PipSawFast.AddsawdeatailNEWBACK" desc="明细回退">
DELETE FROM MIL_SAW_RESULT_DEATIL t
 WHERE 1 = 1
   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#','/')
   AND t.SAW_FLAG = '1'
</query>

<query id="PipSawFast.UpdateSawRackNEWBACK" desc="管号队列回退">
 UPDATE MIL_SAW_RACK
   SET ROW_NO = '', CUT_HEAD_LENGTH = '', SAW_NO = '', SAW_NO_N = ''
 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#','/')
   AND Row_No is not null
   AND STATUS = '0'
</query>

<query id="PipSawFast.UpdatesawdeatailOrder" desc="更新明细定尺长">
 UPDATE MIL_SAW_RESULT_DEATIL t
   SET t.Order_Length = '#ORDER_LENGTH#'
 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="PipSawFast.UpdateSawRackOrder" desc="更新管号队列定尺长">
UPDATE MIL_SAW_RACK t
   SET t.Order_Length      = '#ORDER_LENGTH#',
       t.LAST_ORDER_LENGTH = '#ORDER_LENGTH#'
 WHERE 1 = 1
   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#','/')
   AND Row_No is not null
   AND STATUS = '0'
</query>
<query id="PipSawFast.UpdatesawdeatailTail" desc="更新明细尾长">
 UPDATE MIL_SAW_RESULT_DEATIL t
   SET t.CUT_TRAIL_LENGTH       = '#CUT_TRAIL_LENGTH#',
       t.CUT_TRAIL_LENGTH_TOTAL = #CUT_TRAIL_LENGTH# * ROW_COUNT / 1000
 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="PipSawFast.UpdateSawRackTail" desc="更新管号队列尾长">
UPDATE MIL_SAW_RACK t
   SET t.CUT_TRAIL_LENGTH = '#CUT_TRAIL_LENGTH#'
 WHERE 1 = 1
   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#','/')
   AND Row_No is not null
   AND STATUS = '0'
</query>
<query id = "updatePortOrderLength.selectPipSize" desc = "查询计划规格">
<![CDATA[
SELECT T.CONTROL_THICKP,
       NVL(S.AIMOUTDIAMETER, 0) AIMOUTDIAMETER,
       T.VARIETIES,
       CASE
         WHEN INSTR(T.PIPE_SIZE, '*', -1, 1) > 0 THEN
          SUBSTR(T.PIPE_SIZE, 0, INSTR(T.PIPE_SIZE, '*', -1, 1) - 1)
         ELSE
          SUBSTR(T.PIPE_SIZE, 0, INSTR(T.PIPE_SIZE, 'x', -1, 1) - 1)
       END OUTDIAMETER
  FROM MIL_PLAN T
  LEFT JOIN PLN_ORDER_ZG_S S
    ON SUBSTR(T.ORD_LN_DLY_PK, 0, length(T.ORD_LN_DLY_PK) - 3) =
       S.ORD_LN_DLY_PK
 WHERE T.JUDGE_STOVE_NO = ?
   AND T.PRO_PLAN_ID  || '&' LIKE '%' || ? || '%'
   AND T.GX_PLAN_NO  || '&' LIKE '%' || ? || '%'
   AND ROWNUM = 1
   ]]>
</query>
<query id = "updatePortOrderLength.selectPipSize2" desc = "查询计划规格">
<![CDATA[
SELECT T1.AIMOUTDIAMETER, T1.AIMWALLTHICK
  FROM MIL_PLAN T, PLN_ZY_ZG_M T1
 WHERE T.ID = T1.HEAT_PLAN_NO(+)
   AND T.JUDGE_STOVE_NO = ?
   AND T.PRO_PLAN_ID || '&' LIKE '%' || ? || '%'
   AND T.GX_PLAN_NO || '&' LIKE '%' || ? || '%'
   AND ROWNUM = 1
   ]]>
</query>
<query id = "updatePortOrderLength.updateLen" desc = "写进程表长度、重量">
<![CDATA[
UPDATE PORT_MIL_BATCH_SAMPLE_RESULT T
    SET T.ORDER_LENGTH      = ?,
        T.ACT_THEORY_WEIGHT = DECODE(ROUND(TO_NUMBER(?) * TO_NUMBER(?) / 1000,
                                           3),
                                     '0',
                                     T.INPUT_WEIGHT,
                                     '',
                                     T.INPUT_WEIGHT,
                                     ROUND(TO_NUMBER(?) * TO_NUMBER(?) / 1000,
                                           3))
  WHERE T.JUDGE_STOVE_NO = ?
    AND T.PRO_PLAN_ID || '&' LIKE '%' || ? || '%'
    AND T.GX_PLAN_NO || '&' LIKE '%' || ? || '%'
   ]]>
</query>
<!-- 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) LOOP
    UPDATE PORT_MIL_BATCH_SAMPLE_RESULT T
       SET T.ORDER_LENGTH      = MYROW.ORDER_LENGTH,
           T.ACT_THEORY_WEIGHT = ROUND(TO_NUMBER(?) * TO_NUMBER(MYROW.ORDER_LENGTH)/1000,3) WHERE T.JUDGE_STOVE_NO = ? AND T.M_MAT_NO = MYROW.M_MAT_NO;
  END LOOP;
END; -->
<query id ="PipSawFast.doQuerySlabCount" desc = "查询锯切前剔除支数">
<![CDATA[
SELECT SUM(ACOUNT) ACOUNT
  FROM (SELECT COUNT(1) ACOUNT
          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 < 7
           AND T.PROCESS_NO <> 0
        
        UNION ALL
        
        SELECT SUM(T2.DB_NUM) ACOUNT
          FROM MIL_SLAB_SCRAP_SEQ T, MIL_FEED_RACK T2
         WHERE T.JUDGE_STOVE_NO = T2.JUDGE_STOVE_NO
           AND T.MAT_NO = T2.MAT_NO
           AND T.JUDGE_STOVE_NO = ?
           AND T.PROCESS_NO = 0
           AND T.PRO_PLAN_ID || '&' LIKE '%' || ? || '%'
           AND T.GX_PLAN_NO || '&' LIKE '%' || ? || '%')
]]>
</query>
</queryMap>

