<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc = "组炉管理">
<query id = "FrmStuffFurnace.doQueryMat" desc = "查询收料实绩">
<![CDATA[
 SELECT 
       max(TO_CHAR(T.INSTOCK_TIME, 'YYYY-MM-DD HH24:MI:SS')) INSTOCK_TIME,
       T.MEMO,
       T.PRODUCT_FLAG,
       T.MAT_STATUS,
       T.STOVE_NO,
       T.JUDGE_STOVE_NO,
       T.BATCH_NO,
       T.CAST_NO,
       T.CCMID,
       T.SAMPLE_FLAG,
       T.CUTTING_FLAG,
       T.CUTTING_NUM,
       T.MATERIAL_NO,
       T.MATERIAL_NAME,
       T.PRODUCCODE,
       T.PRODUCNAME,
       T.JUDGE_GRADECODE,
       T.JUDGE_GRADENAME,
       T.JUDGE_STD_CODE,
       T.JUDGE_STD_NAME,
       T.PRO_ORDER_NO,
       T.PRO_ORDER_ID,
       T.PLINE_CODE,
       T.PLINE_NAME,
       T.ACT_DIMATER,
       sum(nvl(T.ACT_LEN,0))ACT_LEN,
       T.ACT_LEN_MIN,
       T.ACT_LEN_MAX,
       T.ACT_FIX_NUM,
       T.ACT_FIX_LEN,
       sum(T.ACT_COUNT)ACT_COUNT,
       sum(T.ACT_THEORY_WEIGHT)ACT_THEORY_WEIGHT,
       T.BELONG_CODE,
       T.BELONG_NAME 
 FROM MAT_GP_M T
 WHERE T.Stove_No || '&'LIKE ('%'||?||'%')
 AND T.JUDGE_STOVE_NO || '&' LIKE ('%' || ? || '%')
 group by 
 T.MEMO,
       T.PRODUCT_FLAG,
       T.MAT_STATUS,
       T.STOVE_NO,
       T.JUDGE_STOVE_NO,
       T.BATCH_NO,
       T.CAST_NO,
       T.CCMID,
       T.SAMPLE_FLAG,
       T.CUTTING_FLAG,
       T.CUTTING_NUM,
       T.MATERIAL_NO,
       T.MATERIAL_NAME,
       T.PRODUCCODE,
       T.PRODUCNAME,
       T.JUDGE_GRADECODE,
       T.JUDGE_GRADENAME,
       T.JUDGE_STD_CODE,
       T.JUDGE_STD_NAME,
       T.PRO_ORDER_NO,
       T.PRO_ORDER_ID,
       T.PLINE_CODE,
       T.PLINE_NAME,
       T.ACT_DIMATER,
       T.ACT_LEN_MIN,
       T.ACT_LEN_MAX,
       T.ACT_FIX_NUM,
       T.ACT_FIX_LEN,
       T.BELONG_CODE,
       T.BELONG_NAME 
 ]]>
</query>
<query id = "FrmStuffFurnace.doQueryTrack" desc = "查询组炉实绩">
<![CDATA[
SELECT EVENT_DESC,
       PRODUCT_FLAG,
       MAT_STATUS,
       STOVE_NO,
       FLAG_STOVE_NO,
       LOT_NO,
       JUDGE_STOVE_NO,
       GROUD_NO,
       BATCH_NO,
       CAST_NO,
       CCMID,
       GRADECODE,
       GRADENAME,
       STD_CODE,
       STD_NAME,
       ACT_DIMATER,
       ACT_HEIGHT,
       sum(ACT_LEN) ACT_LEN,
       ACT_LEN_MIN,
       ACT_LEN_MAX,
       ACT_FIX_NUM,
       ACT_FIX_LEN,
       sum(ACT_COUNT) ACT_COUNT,
       sum(ACT_WEIGHT) ACT_WEIGHT,
       sum(ACT_THEORY_WEIGHT) ACT_THEORY_WEIGHT,
       PRO_ORDER_NO,
       PRO_ORDER_ID,
       ORD_PK,
       ORD_LN_PK,
       ORD_LN_DLY_PK,
       ORDER_NO,
       ORDER_SEQ,
       ORDER_SEQ_NO,
       OLD_ORD_PK,
       OLD_ORD_LN_PK,
       OLD_ORD_LN_DLY_PK,
       OLD_ORDER_NO,
       OLD_ORDER_SEQ,
       OLD_ORDER_SEQ_NO,
       BELONG_CODE,
       BELONG_NAME,
       MEMO,
       CREATE_NAME,
       max(TO_CHAR(CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS')) CREATE_TIME,
       DEPARTMENT_CODE,
       DEPARTMENT_DESC,
       MANAGEMENT_NO,
       MANAGEMENT_NAME,
       OLD_JUDGE_STOVE_NO,
       OLD_GROUD_NO,
       OLD_BATCH_NO,
       OLD_GRADECODE,
       OLD_GRADENAME,
       OLD_STD_CODE,
       OLD_STD_NAME,
       OLD_STOVE_NO
  FROM MAT_GP_TRACK
 WHERE Stove_No || '&' LIKE ('%' || ? || '%')
   AND JUDGE_STOVE_NO || '&' LIKE ('%' || ? || '%')
 group by EVENT_DESC,
          PRODUCT_FLAG,
          MAT_STATUS,
          STOVE_NO,
          FLAG_STOVE_NO,
          LOT_NO,
          JUDGE_STOVE_NO,
          GROUD_NO,
          BATCH_NO,
          CAST_NO,
          CCMID,
          GRADECODE,
          GRADENAME,
          STD_CODE,
          STD_NAME,
          ACT_DIMATER,
          ACT_HEIGHT,
          ACT_LEN_MIN,
          ACT_LEN_MAX,
          ACT_FIX_NUM,
          ACT_FIX_LEN,
          PRO_ORDER_NO,
          PRO_ORDER_ID,
          ORD_PK,
          ORD_LN_PK,
          ORD_LN_DLY_PK,
          ORDER_NO,
          ORDER_SEQ,
          ORDER_SEQ_NO,
          OLD_ORD_PK,
          OLD_ORD_LN_PK,
          OLD_ORD_LN_DLY_PK,
          OLD_ORDER_NO,
          OLD_ORDER_SEQ,
          OLD_ORDER_SEQ_NO,
          BELONG_CODE,
          BELONG_NAME,
          MEMO,
          CREATE_NAME,
          DEPARTMENT_CODE,
          DEPARTMENT_DESC,
          MANAGEMENT_NO,
          MANAGEMENT_NAME,
          OLD_JUDGE_STOVE_NO,
          OLD_GROUD_NO,
          OLD_BATCH_NO,
          OLD_GRADECODE,
          OLD_GRADENAME,
          OLD_STD_CODE,
          OLD_STD_NAME,
          OLD_STOVE_NO
 ]]>
</query>
<query id = "FrmStuffFurnace.doFurnace" desc = "确认组炉">
<![CDATA[
DECLARE
  v_RESUME_SEQ mat_gp_track.resume_seq%type := null; --流水号
  v_RESUME_SEQ1 mat_gp_track.resume_seq%type := null; --流水号
  v_Icount      NUMBER := 1;
  v_GroupNo     mat_gp_m.groud_no%type :=null;--组号
  v_time        ymd_gp_inlist.create_time%type := sysdate;
BEGIN
select to_char(sysdate, 'yyyymmddHHmmss') ||
         Lpad(NVL(MAX(substr(t.resume_seq, 14)), 0) + 1, 10, 0) resume_seq
    into v_RESUME_SEQ
    from mat_gp_track t
   where to_char(t.CREATE_TIME, 'YYYY-MM-DD') =
         to_char(sysdate, 'YYYY-MM-DD');
         
 SELECT Lpad(NVL(MAX(t.groud_no), 0) + 1, 3, 0)
      into v_GroupNo
      FROM mat_gp_m T
     WHERE T.JUDGE_STOVE_NO = ?;
  FOR MYROW IN (Select * from (SELECT T.*
                  FROM Mat_Gp_m T
                 WHERE T.STOVE_NO = ?
                   AND T.JUDGE_STOVE_NO = ?
                   AND T.Groud_No = ?
                   AND NVL(T.Act_Len_Min, 0) = NVL(?, 0)
                   AND NVL(T.Act_Len_Max, 0) = NVL(?, 0)
                   AND NVL(T.Act_Fix_Num, 0) = NVL(?, 0)
                   AND NVL(T.Act_Fix_Len, 0) = NVL(?, 0)
                 ORDER BY T.MAT_NO DESC) where rownum <?) LOOP
             v_RESUME_SEQ1 :=  substr(v_RESUME_SEQ,0,14)||Lpad(v_Icount,10,0); 
              INSERT INTO MAT_GP_TRACK(
        RESUME_SEQ,
        EVENT_ID,
        EVENT_DESC,
        FORM_NAME,
        CALL_FUNC_CODING,
        KEYVALUE_1,
        KEYVALUE_1_DESC,
        KEYVALUE_2,
        KEYVALUE_2_DESC2,
        KEYVALUE_3,
        KEYVALUE_3_DESC3,
        KEYVALUE_4,
        KEYVALUE_4_DESC4,
        KEYVALUE_5,
        KEYVALUE_5_DESC5,
        KEYVALUE_6,
        KEYVALUE_6_DESC6,
        KEYVALUE_7,
        KEYVALUE_7_DESC7,
        MAT_NO,
        MAT_SQE_NO,
        PRODUCT_FLAG,
        MAT_STATUS,
        STOVE_NO,
        FLAG_STOVE_NO,
        LOT_NO,
        JUDGE_STOVE_NO,
        GROUD_NO,
        BATCH_NO,
        CAST_NO,
        CCMID,
        GRADECODE,
        GRADENAME,
        STD_CODE,
        STD_NAME,
        ACT_DIMATER,
        ACT_HEIGHT,
        ACT_LEN,
        ACT_LEN_MIN,
        ACT_LEN_MAX,
        ACT_FIX_NUM,
        ACT_FIX_LEN,
        ACT_COUNT,
        ACT_WEIGHT,
        ACT_THEORY_WEIGHT,
        PRO_ORDER_NO,
        PRO_ORDER_ID,
        PRO_ORDER_NO1,
        PRO_ORDER_ID1,
        ORD_PK,
        ORD_LN_PK,
        ORD_LN_DLY_PK,
        ORDER_NO,
        ORDER_SEQ,
        ORDER_SEQ_NO,
        OLD_ORD_PK,
        OLD_ORD_LN_PK,
        OLD_ORD_LN_DLY_PK,
        OLD_ORDER_NO,
        OLD_ORDER_SEQ,
        OLD_ORDER_SEQ_NO,
        BELONG_CODE,
        BELONG_NAME,
        MEMO,
        CREATE_NAME,
        CREATE_TIME,
        DEPARTMENT_CODE,
        DEPARTMENT_DESC,
        MANAGEMENT_NO,
        MANAGEMENT_NAME,
        OLD_JUDGE_STOVE_NO,
        OLD_GROUD_NO,
        OLD_BATCH_NO,
        OLD_GRADECODE,
        OLD_GRADENAME,
        OLD_STD_CODE,
        OLD_STD_NAME,
        OLD_STOVE_NO)
 VALUES( 
        v_RESUME_SEQ1,
        '900104',
        '组炉',
        'com.steering.pss.ydm.Stuffmanage.FrmStuffFurnace',
        'doFurnace',
        '',
        '',
        '',
        '',
        '',
        '',
        '',
        '',
        '',
        '',
        '',
        '',
        '',
        '',
        myrow.mat_no,
        myrow.mat_sqe_no,
        myrow.PRODUCT_FLAG,
        myrow.MAT_STATUS,
        ?,
        myrow.FLAG_STOVE_NO,
        myrow.LOT_NO,
        ?,
        v_GroupNo,
        myrow.BATCH_NO,
        myrow.CAST_NO,
        myrow.CCMID,
        myrow.judge_gradecode,
        myrow.judge_gradename,
        myrow.judge_std_code,
        myrow.judge_std_name,
        myrow.ACT_DIMATER,
        myrow.ACT_HEIGHT,
        myrow.ACT_LEN,
        myrow.ACT_LEN_MIN,
        myrow.ACT_LEN_MAX,
        myrow.ACT_FIX_NUM,
        myrow.ACT_FIX_LEN,
        myrow.ACT_COUNT,
        myrow.ACT_WEIGHT,
        myrow.ACT_THEORY_WEIGHT,
        myrow.PRO_ORDER_NO,
        myrow.PRO_ORDER_ID,
        myrow.PRO_ORDER_NO1,
        myrow.PRO_ORDER_ID1,
        myrow.ORD_PK,
        myrow.ORD_LN_PK,
        myrow.ORD_LN_DLY_PK,
        myrow.ORDER_NO,
        myrow.ORDER_SEQ,
        myrow.ORDER_SEQ_NO,
        '',
        '',
        '',
        '',
        '',
        '',
        myrow.BELONG_CODE,
        myrow.BELONG_NAME,
        myrow.MEMO,
        ?,
        v_time,
        ?,
        ?,
        ?,
        ?,
        myrow.judge_stove_no,
        myrow.groud_no,
        myrow.batch_no,
        myrow.judge_gradecode,
        myrow.judge_gradename,
        myrow.judge_std_code,
        myrow.judge_std_name,
        myrow.STOVE_NO);
        
        update mat_gp_m t set 
        t.old_judge_stove_no = myrow.judge_stove_no,t.old_groud_no = myrow.groud_no,
        t.old_batch_no = myrow.batch_no,t.old_gradecode = myrow.judge_gradecode,
        t.old_gradename = myrow.judge_gradename,t.judge_stove_no = ?,t.stove_no = ?,
        t.groud_no = v_GroupNo,t.STOVE_NO = myrow.STOVE_NO where t.mat_no = myrow.mat_no;
        v_Icount := v_Icount + 1;
  END LOOP;
END;
]]>
</query>
<query id = "FrmStuffFurnace.cancelFurnace" desc = "撤销组炉">
<![CDATA[
DECLARE
BEGIN
  FOR MYROW IN (SELECT T.*
                  FROM MAT_GP_TRACK T
                 WHERE T.STOVE_NO = ?
                   AND T.JUDGE_STOVE_NO = ?
                   AND T.GROUD_NO = ?
                   AND T.OLD_JUDGE_STOVE_NO = ?
                   AND T.OLD_GROUD_NO = ?
                   AND T.OLD_STOVE_NO = ?
                   AND NVL(T.ACT_LEN_MIN, 0) = NVL(?, 0)
                   AND NVL(T.ACT_LEN_MAX, 0) = NVL(?, 0)
                   AND NVL(T.ACT_FIX_NUM, 0) = NVL(?, 0)
                   AND NVL(T.ACT_FIX_LEN, 0) = NVL(?, 0)
                 ORDER BY T.MAT_NO DESC) LOOP
  
    UPDATE MAT_GP_M T
       SET T.JUDGE_STOVE_NO = T.OLD_JUDGE_STOVE_NO,
           T.GROUD_NO       = T.OLD_GROUD_NO,
           T.STOVE_NO       = T.OLD_STOVE_NO,
           T.GRADECODE      = T.OLD_GRADECODE,
           T.GRADENAME      = T.OLD_GRADENAME,
           T.STD_CODE       = T.OLD_STD_CODE,
           T.STD_NAME       = T.OLD_STD_NAME
     WHERE T.MAT_NO = MYROW.MAT_NO;
  
    DELETE MAT_GP_TRACK T WHERE T.MAT_NO = MYROW.MAT_NO;
  END LOOP;
END;

]]>
</query>
</queryMap>