<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc = "修改交接班">
<query id = "FrmColUpdate.doQueryColUser" desc = "查询操作人">
<![CDATA[
SELECT T.USER_NAME,T.USER_ID FROM MIL_SIGNATURE T WHERE T.PLINE_CODE || '&' LIKE ('%' || ? || '%')
AND T.PROCESS_NO || '&' LIKE ('%' || ? || '%')
AND T.COL_GROUP || '&' LIKE ('%' || ? || '%')
]]>
</query>
<query id = "FrmColUpdate.doQueryRack" desc = "查询所有Rack表">
<![CDATA[
SELECT T.JUDGE_STOVE_NO,
       T.LOT_NO,
       --T.COL_USER,
       --DECODE(T.COL_SHIFT,'1','早班','2','中班','3','晚班')COL_SHIFT,
       --DECODE(T.COL_GROUP,'1','甲','2','乙','3','丙','4','丁')COL_GROUP,
       --TO_CHAR(#START_TIME#,'YYYY-MM-DD HH:MM:SS') AS START_PERFORATION_TIME,
       --TO_CHAR(#END_TIME#,'YYYY-MM-DD HH:MM:SS') AS END_PERFORATION_TIME,
       T.RESULT_NO, 
       MAX(NVL(#JZB_NUM#,'0')) AS ACOUNT,
       MAX(NVL(#JZB_NUM2#,'0')) AS BCOUNT,
       DECODE(M.NODE_STATUS,
              '10',
              '锯切完成',
              '20',
              '出炉',
              '30',
              '穿孔完成',
              '40',
              '连轧完成',
              '50',
              '出再加热炉',
              '60',
              '出定径',
              '70',
              '分切完成','80','矫直完成','90','探伤完成','96','质检完成','99','入库完成','未结炉')STATUS
  FROM (SELECT COUNT(1)ACOUNT,T.JUDGE_STOVE_NO, T.LOT_NO, T.RESULT_NO,T.PLINE_CODE,MAX(#END_TIME1#)#END_TIME1#
          FROM #RACK# T
         GROUP BY T.JUDGE_STOVE_NO, T.LOT_NO, T.RESULT_NO,T.PLINE_CODE) T, MIL_PLAN M,#RESULT# S
 WHERE T.JUDGE_STOVE_NO = M.JUDGE_STOVE_NO
   AND T.LOT_NO = M.LOT_NO
   AND T.RESULT_NO = M.ID
   AND T.JUDGE_STOVE_NO = S.JUDGE_STOVE_NO
   AND T.LOT_NO = S.LOT_NO
   AND T.RESULT_NO = S.RESULT_NO
   AND T.JUDGE_STOVE_NO || '&' LIKE ('%' || ? || '%')
   AND T.LOT_NO || '&' LIKE ('%' || ? || '%')
]]>
</query>
<query id = "FrmColUpdate.doQueryPlan" desc = "查询锯切信息">
<![CDATA[
SELECT T.JUDGE_STOVE_NO,
       T.LOT_NO,
       T.RESULT_NO, 
       DECODE(M.NODE_STATUS,
              '10',
              '锯切完成',
              '20',
              '出炉',
              '30',
              '穿孔完成',
              '40',
              '连轧完成',
              '50',
              '出再加热炉',
              '60',
              '出定径',
              '70',
              '分切完成','80','矫直完成','90','探伤完成','96','质检完成','99','入库完成','未结炉')STATUS,
              NVL(S.CHANGE_NUM,'0') ACOUNT
  FROM (SELECT COUNT(1)ACOUNT,T.JUDGE_STOVE_NO, T.LOT_NO, T.RESULT_NO,T.PLINE_CODE,MAX(T.END_TIME)END_TIME
          FROM MIL_FEED_RACK T
         GROUP BY T.JUDGE_STOVE_NO, T.LOT_NO, T.RESULT_NO,T.PLINE_CODE) T, MIL_PLAN M,MIL_FEEDSAW_RESULT S
 WHERE T.JUDGE_STOVE_NO = M.JUDGE_STOVE_NO
   AND T.LOT_NO = M.LOT_NO
   AND T.RESULT_NO = M.ID
   AND T.JUDGE_STOVE_NO = S.JUDGE_STOVE_NO
   AND T.LOT_NO = S.LOT_NO
   AND T.RESULT_NO = S.RESULT_NO
   AND T.JUDGE_STOVE_NO || '&' LIKE ('%' || ? || '%')
   AND T.LOT_NO || '&' LIKE ('%' || ? || '%')
   ]]>
</query>
<query id = "FrmColUpdate.doQueryFeedPlan" desc = "查询上料行信息">
<![CDATA[
 SELECT 
       FEED_NUM_PLAN,
       FEED_ROW_NO,
       LOT_NO,
       JUDGE_STOVE_NO,
       PLINE_CODE,
       NVL(CHANGE_NUM,'0')CHANGE_NUM
 FROM MIL_FEED_PLAN
 WHERE JUDGE_STOVE_NO || '&' LIKE ('%' || ? || '%')
   AND LOT_NO || '&' LIKE ('%' || ? || '%')
   ]]>
</query>
<query id = "FrmColUpdate.queryRack" desc = "管号队列">
<![CDATA[
SELECT T.SEQ,
       T.COL_USER,
       DECODE(T.COL_SHIFT,'1','早班','2','中班','3','晚班')COL_SHIFT,
       DECODE(T.COL_GROUP,'1','甲','2','乙','3','丙','4','丁')COL_GROUP,
       DECODE(#FLAG#,'0','未交班','1','交班点')CHANGE_FLAG,
       DECODE(#FLAGS#,'0','未交班','1','交班点')CHANGE_FLAGS,
       TO_CHAR(#START_TIME#,'YYYY-MM-DD HH24:MI:SS') START_PERFORATION_TIME,
       TO_CHAR(#END_TIME#,'YYYY-MM-DD HH24:MI:SS') END_PERFORATION_TIME,
       T.MAT_NO
  FROM #RACK# T WHERE
   T.JUDGE_STOVE_NO || '&' LIKE ('%' || ? || '%')
   AND T.LOT_NO || '&' LIKE ('%' || ? || '%')
   AND T.STATUS = '0'
   ORDER BY T.SEQ ASC
]]>
</query>
<query id = "FrmColUpdate.queryFurRack" desc = "管号队列">
<![CDATA[
SELECT T.SEQ,
       T.COL_USER,
       DECODE(T.COL_SHIFT,'1','早班','2','中班','3','晚班')COL_SHIFT,
       DECODE(T.COL_GROUP,'1','甲','2','乙','3','丙','4','丁')COL_GROUP,
       T.IN_USER,
       DECODE(T.IN_SHIFT,'1','早班','2','中班','3','晚班')IN_SHIFT,
       DECODE(T.IN_GROUP,'1','甲','2','乙','3','丙','4','丁')IN_GROUP,
       DECODE(#FLAG#,'0','未交班','1','交班点')CHANGE_FLAG,
       DECODE(#FLAGS#,'0','未交班','1','交班点')CHANGE_FLAGS,
       TO_CHAR(#START_TIME#,'YYYY-MM-DD HH24:MI:SS') START_PERFORATION_TIME,
       TO_CHAR(#END_TIME#,'YYYY-MM-DD HH24:MI:SS') END_PERFORATION_TIME,
       T.MAT_NO
  FROM #RACK# T WHERE
   T.JUDGE_STOVE_NO || '&' LIKE ('%' || ? || '%')
   AND T.LOT_NO || '&' LIKE ('%' || ? || '%')
   AND T.STATUS = '0'
   ORDER BY T.SEQ ASC
]]>
</query>
<query id = "FrmColUpdate.queryFeedRack" desc = "查询锯切管号队列">
<![CDATA[
SELECT T.SEQ,
       T.COL_USER,
       DECODE(T.COL_SHIFT,'1','早班','2','中班','3','晚班')COL_SHIFT,
       DECODE(T.COL_GROUP,'1','甲','2','乙','3','丙','4','丁')COL_GROUP,
       DECODE(T.CHANGE_FLAG,'0','未交班','1','交班点')CHANGE_FLAG,
       TO_CHAR(T.FEED_TIME,'YYYY-MM-DD HH:MM:SS') START_PERFORATION_TIME,
       TO_CHAR(T.END_TIME,'YYYY-MM-DD HH24:MI:SS') END_PERFORATION_TIME,
       T.MAT_NO
  FROM MIL_FEED_RACK T WHERE
   T.JUDGE_STOVE_NO =?
   AND T.LOT_NO =?
   AND T.FEED_ROW_NO = ? 
   AND T.STATUS NOT IN('3','4')
   ORDER BY T.SEQ ASC
   ]]>
</query>
<query id = "FrmColUpdate.updateData" desc = "交班">
<![CDATA[
DECLARE
  V_TIME MIL_MODIFY_CHANGE_RESUME.MODIFY_TIME%TYPE := SYSDATE;
  V_CHANGE_NUM_BEFORE MIL_MODIFY_CHANGE_RESUME.CHANGE_NUM_BEFORE%TYPE := 0;
BEGIN
  SELECT NVL(MAX(T.SEQ),'0') SEQ
    INTO V_CHANGE_NUM_BEFORE
    FROM #RACK# T
   WHERE T.JUDGE_STOVE_NO = ?
     AND T.LOT_NO = ?
     AND T.COL_SHIFT = ?
     AND T.COL_GROUP = ?;
  INSERT INTO MIL_MODIFY_CHANGE_RESUME
    (JUDGE_STOVE_NO,
     LOT_NO,
     PROCESS_NO,
     FEED_ROW_NO,
     COL_NO,
     IN_FUR_NUM_BEFORE,
     OUT_FUR_NUM_BEFORE,
     CHANGE_NUM_BEFORE,
     IN_FUR_NUM,
     OUT_FUR_NUM,
     CHANGE_NUM,
     MODIFY_TIME,
     MODIFY_USER,
     REMARK,
     PLINE_CODE,
     COL_SHIFT,
     COL_GROUP)
  VALUES
    (?, ?, ?, ?, ?, '0', '0', V_CHANGE_NUM_BEFORE, '0', '0',TO_NUMBER(?), V_TIME, ?, ?,?,?,?);
  UPDATE #RACK# T
     SET T.COL_USER             = ?,
         T.COL_SHIFT            = ?,
         T.COL_GROUP            = ?,
         #END_TIME#             = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'),
         #START_TIME#           = TO_DATE(?,'YYYY-MM-DD HH24:MI:SS')
         WHERE T.JUDGE_STOVE_NO = ?
         AND T.LOT_NO = ?
         AND T.SEQ >= ?
         AND T.SEQ <= ?;
END;
]]>
</query>
<query id = "FrmColUpdate.updateFeedData" desc = "锯切修改交班">
<![CDATA[
DECLARE
  V_TIME MIL_MODIFY_CHANGE_RESUME.MODIFY_TIME%TYPE := SYSDATE;
  V_CHANGE_NUM_BEFORE MIL_MODIFY_CHANGE_RESUME.CHANGE_NUM_BEFORE%TYPE := 0;
BEGIN
  SELECT NVL(MAX(T.SEQ),'0') SEQ
    INTO V_CHANGE_NUM_BEFORE
    FROM MIL_FEED_RACK T
   WHERE T.JUDGE_STOVE_NO = ?
     AND T.LOT_NO = ?
     AND T.COL_SHIFT = ?
     AND T.COL_GROUP = ?;
  INSERT INTO MIL_MODIFY_CHANGE_RESUME
    (JUDGE_STOVE_NO,
     LOT_NO,
     PROCESS_NO,
     FEED_ROW_NO,
     COL_NO,
     IN_FUR_NUM_BEFORE,
     OUT_FUR_NUM_BEFORE,
     CHANGE_NUM_BEFORE,
     IN_FUR_NUM,
     OUT_FUR_NUM,
     CHANGE_NUM,
     MODIFY_TIME,
     MODIFY_USER,
     REMARK,
     PLINE_CODE,
     COL_SHIFT,
     COL_GROUP)
  VALUES
    (?, ?, ?, ?, ?, '0', '0', V_CHANGE_NUM_BEFORE, '0', '0',TO_NUMBER(?), V_TIME, ?, ?,?,?,?);
  UPDATE MIL_FEED_RACK T
     SET T.COL_USER             = ?,
         T.COL_SHIFT            = ?,
         T.COL_GROUP            = ?,
         T.END_TIME             = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'),
         T.FEED_TIME            = TO_DATE(?,'YYYY-MM-DD HH24:MI:SS')
         WHERE T.JUDGE_STOVE_NO = ?
         AND T.LOT_NO = ?
         AND T.SEQ >= ?
         AND T.SEQ <= ?
         AND T.FEED_ROW_NO = ?;
END;
]]>
</query>
<query id = "FrmColUpdate.updateDataHeating1" desc = "修改加热炉的班次班组(入)">
<![CDATA[
DECLARE
  V_TIME MIL_MODIFY_CHANGE_RESUME.MODIFY_TIME%TYPE := SYSDATE;
  V_CHANGE_NUM_BEFORE MIL_MODIFY_CHANGE_RESUME.CHANGE_NUM_BEFORE%TYPE := 0;
BEGIN
  SELECT NVL(MAX(T.SEQ),'0') SEQ
    INTO V_CHANGE_NUM_BEFORE
    FROM #RACK# T
   WHERE T.JUDGE_STOVE_NO = ?
     AND T.LOT_NO = ?
     AND #COL_SHIFT# = ?
     AND #COL_GROUP# = ?;
  INSERT INTO MIL_MODIFY_CHANGE_RESUME
    (JUDGE_STOVE_NO,
     LOT_NO,
     PROCESS_NO,
     FEED_ROW_NO,
     COL_NO,
     IN_FUR_NUM_BEFORE,
     OUT_FUR_NUM_BEFORE,
     CHANGE_NUM_BEFORE,
     IN_FUR_NUM,
     OUT_FUR_NUM,
     CHANGE_NUM,
     MODIFY_TIME,
     MODIFY_USER,
     REMARK,
     PLINE_CODE,
     COL_SHIFT,
     COL_GROUP)
  VALUES
    (?, ?, ?, ?, ?, V_CHANGE_NUM_BEFORE, '0', '0', TO_NUMBER(?), '0', '0', V_TIME, ?, ?,?,?,?);
  UPDATE #RACK# T
     SET #COL_USER#             = ?,
         #COL_SHIFT#            = ?,
         #COL_GROUP#            = ?,
         #END_TIME#         = TO_DATE(?,'YYYY-MM-DD HH24:MI:SS'),
         #START_TIME#       = TO_DATE(?,'YYYY-MM-DD HH24:MI:SS')
         WHERE T.JUDGE_STOVE_NO = ?
         AND T.LOT_NO = ?
         AND T.SEQ >= ?
         AND T.SEQ <= ?;
END;
]]>
</query>
<query id = "FrmColUpdate.updateDataHeating4" desc = "修改加热炉的班次班组(出)">
<![CDATA[
DECLARE
  V_TIME MIL_MODIFY_CHANGE_RESUME.MODIFY_TIME%TYPE := SYSDATE;
  V_CHANGE_NUM_BEFORE MIL_MODIFY_CHANGE_RESUME.CHANGE_NUM_BEFORE%TYPE := 0;
BEGIN
  SELECT NVL(MAX(T.SEQ),'0') SEQ
    INTO V_CHANGE_NUM_BEFORE
    FROM #RACK# T
   WHERE T.JUDGE_STOVE_NO = ?
     AND T.LOT_NO = ?
     AND #COL_SHIFT# = ?
     AND #COL_GROUP# = ?;
  INSERT INTO MIL_MODIFY_CHANGE_RESUME
    (JUDGE_STOVE_NO,
     LOT_NO,
     PROCESS_NO,
     FEED_ROW_NO,
     COL_NO,
     IN_FUR_NUM_BEFORE,
     OUT_FUR_NUM_BEFORE,
     CHANGE_NUM_BEFORE,
     IN_FUR_NUM,
     OUT_FUR_NUM,
     CHANGE_NUM,
     MODIFY_TIME,
     MODIFY_USER,
     REMARK,
     PLINE_CODE,
     COL_SHIFT,
     COL_GROUP)
  VALUES
    (?, ?, ?, ?, ?, '0', V_CHANGE_NUM_BEFORE, '0', '0',TO_NUMBER(?), '0', V_TIME, ?, ?,?,?,?);
  UPDATE #RACK# T
     SET #COL_USER#             = ?,
         #COL_SHIFT#            = ?,
         #COL_GROUP#            = ?,
         #END_TIME#         = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'),
         #START_TIME#       = TO_DATE(?,'YYYY-MM-DD HH24:MI:SS')
         WHERE T.JUDGE_STOVE_NO = ?
         AND T.LOT_NO = ?
         AND T.SEQ >= ?
         AND T.SEQ <= ?;
END;
]]>
</query>
<query id = "FrmColUpdate.updateFlag" desc = "修改交班标识">
UPDATE #RACK# T
     SET #FLAG# = ?
         WHERE T.JUDGE_STOVE_NO = ?
         AND T.LOT_NO = ?
         AND T.SEQ = ?
</query>
<query id = "FrmColUpdate.updateFlagFeed" desc = "修改锯切交班标识">
UPDATE MIL_FEED_RACK T
     SET T.CHANGE_FLAG = ?
         WHERE T.JUDGE_STOVE_NO = ?
         AND T.LOT_NO = ?
         AND T.SEQ = ?
         AND T.FEED_ROW_NO = ?
</query>
<query id = "FrmColUpdate.updateResult" desc = "修改实绩表交班支数">
DECLARE
  V_JZB_NUM #RESULT#.#JZB_NUM#%TYPE := NULL;
BEGIN
  SELECT MAX(T.SEQ) SEQ
    INTO V_JZB_NUM
    FROM #RACK# T
   WHERE T.JUDGE_STOVE_NO = ?
     AND T.LOT_NO = ?
     AND T.CHANGE_FLAG = '1';
     UPDATE #RESULT#
     SET #JZB_NUM# = V_JZB_NUM
         WHERE JUDGE_STOVE_NO = ?
         AND LOT_NO = ?;
END;
</query>
<query id = "FrmColUpdate.updateResultFeed" desc = "修改实绩、上料行交班支数">
DECLARE
  V_JZB_NUM    MIL_FEEDSAW_RESULT.Change_Num%TYPE := NULL;
  V_CHANGE_NUM MIL_FEED_PLAN.CHANGE_NUM%TYPE := NULL;
BEGIN
  SELECT MAX(T.SEQ) SEQ
    INTO V_JZB_NUM
    FROM MIL_FEED_RACK T
   WHERE T.JUDGE_STOVE_NO = ?
     AND T.LOT_NO = ?
     AND T.CHANGE_FLAG = '1';
  SELECT TO_NUMBER(MAX(T.SEQ)) - TO_NUMBER(MIN(T.SEQ)) + 1
    INTO V_CHANGE_NUM
    FROM MIL_FEED_RACK T
   WHERE T.JUDGE_STOVE_NO = ?
     AND T.LOT_NO = ?
     AND T.FEED_ROW_NO = ?;
  UPDATE MIL_FEEDSAW_RESULT
     SET CHANGE_NUM = V_JZB_NUM
   WHERE JUDGE_STOVE_NO = ?
     AND LOT_NO = ?;
  UPDATE MIL_FEED_PLAN T
     SET T.CHANGE_NUM = V_CHANGE_NUM
   WHERE T.JUDGE_STOVE_NO = ?
     AND T.LOT_NO = ?
     AND T.FEED_ROW_NO = ?;
END;
</query>
<query id = "updateFlag.selectRack" desc = "查询下一支班次班组">
SELECT 
  DECODE(T.COL_SHIFT,'1','早班','2','中班','3','晚班')COL_SHIFT,
  DECODE(T.COL_GROUP,'1','甲','2','乙','3','丙','4','丁')COL_GROUP
  FROM #RACK# T
 WHERE T.JUDGE_STOVE_NO = ?
   AND T.LOT_NO = ?
   AND T.SEQ = ?
</query>
<query id = "updateFlag.selectRackFeed" desc = "查询锯切下一支班次班组">
SELECT 
  DECODE(T.COL_SHIFT,'1','早班','2','中班','3','晚班')COL_SHIFT,
  DECODE(T.COL_GROUP,'1','甲','2','乙','3','丙','4','丁')COL_GROUP
  FROM MIL_FEED_RACK T
 WHERE T.JUDGE_STOVE_NO = ?
   AND T.LOT_NO = ?
   AND T.SEQ = ?
   AND T.FEED_ROW_NO = ?
</query>
<query id = "FrmColUpdate.doQueryModifyData" desc = "查询历史信息">
<![CDATA[
 SELECT 
       JUDGE_STOVE_NO,
       LOT_NO,
       DECODE(PROCESS_NO,'0','锯切','1','加热炉','2','穿孔','3','连轧','4','再加热','5','定径','6','管排距','7','矫直','8','探伤')PROCESS_NO,
       FEED_ROW_NO,
       COL_NO,
       IN_FUR_NUM_BEFORE,
       OUT_FUR_NUM_BEFORE,
       CHANGE_NUM_BEFORE,
       IN_FUR_NUM,
       OUT_FUR_NUM,
       CHANGE_NUM,
       TO_CHAR(MODIFY_TIME, 'YYYY-MM-DD HH24:MI:SS') MODIFY_TIME,
       MODIFY_USER,
       REMARK,
       PLINE_CODE,
       DECODE(COL_SHIFT,'1','早班','2','中班','3','晚班')COL_SHIFT,
       DECODE(COL_GROUP,'1','甲','2','乙','3','丙','4','丁')COL_GROUP
 FROM MIL_MODIFY_CHANGE_RESUME
 WHERE JUDGE_STOVE_NO || '&' LIKE ('%' || ? || '%')
   AND LOT_NO || '&' LIKE ('%' || ? || '%')
   AND PROCESS_NO || '&' LIKE ('%' || ? || '%')
 ]]>
</query>
</queryMap>