<?xml version="1.0" encoding="UTF-8"?>

<queryMap desc = "轧管统计">
<!-- tzh 24.11.9 -->

<query id = "FrmMilDateStatistics.getMilDateStatisticsActual" desc = "查询各工序的实际数据">
<![CDATA[
	select REGEXP_REPLACE(T1.JUDGE_STOVE_NO, '-.*', '') JUDGE_STOVE_NO,
       T1.LOT_NO,
       T.PLINE_CODE,
       (SELECT A.PLINE_NAME
          FROM COM_BASE_PLINE A
         WHERE A.PLINE_CODE = T.PLINE_CODE) PLINE_CODE1,
       T1.CONTRACT_NO,
       T1.VARIETIES,
       T1.STEELNAME,
       T1.GRADENAME,
       T1.TARGET,
       T1.TUBE_SUORCE,
       REPLACE(T1.PIPE_SIZE, '*', 'x') PIPE_SIZE,
       (SELECT SUM(B.FEED_NUM)
          FROM MIL_FEED_PLAN B
         WHERE B.JUDGE_STOVE_NO = T1.JUDGE_STOVE_NO) SLZ,
       
       (SELECT SUM(B.MAT_TOTAL_HEIGHT - DECODE(B.CUT_TARGET,
                                               '返废',
                                               NVL(round(B.CUT_WEIGHT, 3), 0),
                                               
                                               0))
          FROM MIL_FEED_PLAN B
         WHERE B.JUDGE_STOVE_NO = T1.JUDGE_STOVE_NO) SLD,
       
       (SELECT SUM(B.FEED_NUM * B.DB_NUM) * T1.SAW_NUM
          FROM MIL_FEED_PLAN B
         WHERE B.JUDGE_STOVE_NO = T1.JUDGE_STOVE_NO) YJZ,
       
       NVL((select sum(A.ACT_THEORY_WEIGHT)
             from PORT_MIL_BATCH_SAMPLE_RESULT A
            WHERE 1 = 1
              AND A.IS_VALID = '1'
              AND A.STATUS NOT IN ('3', '4')
              AND A.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO),
           0) YJD,
       
       ((NVL(T.AFTER_SCRAP_NUM, 0) + NVL(T3.SCRAP_NUM, 0) +
       NVL(T4.SCRAP_NUM, 0) + NVL(T5.SCRAP_NUM, 0) + NVL(R.SCRAP_NUM, 0) +
       NVL(T6.SCRAP_NUM, 0)) * T1.SAW_NUM) undeterminedNum,
       
       (NVL(T7.SCRAP_DBNUM, 0) + NVL((SELECT SUM(T8.SCRAP_NUM)
                                       FROM MIL_STRAIGHTENING_RESULT T8
                                      WHERE T8.RESULT_NO = T1.ID),
                                     0) +
       NVL((SELECT SUM(T9.SCRAP_NUM)
              FROM MIL_MT_RESULT T9
             WHERE T9.RESULT_NO = T1.ID),
            0) + (SELECT SUM(T10.WASTE_QUANTITY)
                     FROM MIL_SURFACE_RESULT T10
                    WHERE T10.RESULT_NO = T1.ID) +
       NVL((SELECT SUM(T11.SCRAP_NUM)
              FROM MIL_ET_RESULT T11
             WHERE T11.RESULT_NO = T1.ID),
            0)) ScrapNum,
       
       NVL((select sum(A.act_count)
             from PORT_MIL_BATCH_SAMPLE_RESULT A
            WHERE 1 = 1
              AND A.IS_VALID = '1'
              AND A.STATUS = '3'
              AND A.PLAN_ID = T.RESULT_NO),
           0) LXZ,
       
       DECODE((SELECT MAX(M.NODE_FUR_FLAG)
                FROM MIL_INSTORE_RESULT M
               WHERE M.RESULT_NO = T.RESULT_NO),
              '1',
              (DECODE((SELECT SUM(B.FEED_NUM * B.DB_NUM) * T1.SAW_NUM
                         FROM MIL_FEED_PLAN B
                        WHERE B.JUDGE_STOVE_NO = T1.JUDGE_STOVE_NO) -
                      ((NVL(T.AFTER_SCRAP_NUM, 0) + NVL(T3.SCRAP_NUM, 0) +
                      NVL(T4.SCRAP_NUM, 0) + NVL(T5.SCRAP_NUM, 0) +
                      NVL(R.SCRAP_NUM, 0) + NVL(T6.SCRAP_NUM, 0)) *
                      T1.SAW_NUM) -
                      (NVL(T7.SCRAP_DBNUM, 0) +
                      NVL((SELECT SUM(T8.SCRAP_NUM)
                             FROM MIL_STRAIGHTENING_RESULT T8
                            WHERE T8.RESULT_NO = T1.ID),
                           0) + NVL((SELECT SUM(T9.SCRAP_NUM)
                                       FROM MIL_MT_RESULT T9
                                      WHERE T9.RESULT_NO = T1.ID),
                                     0) +
                      (SELECT SUM(T10.WASTE_QUANTITY)
                          FROM MIL_SURFACE_RESULT T10
                         WHERE T10.RESULT_NO = T1.ID) +
                      NVL((SELECT SUM(T11.SCRAP_NUM)
                             FROM MIL_ET_RESULT T11
                            WHERE T11.RESULT_NO = T1.ID),
                           0)) - NVL((SELECT NVL(SUM(T12.QUALIFIED_NUM), 0)
                                       FROM MIL_INSTORE_RESULT T12
                                      WHERE T12.RESULT_NO = T.RESULT_NO
                                        AND T12.NODE_FUR_FLAG = '1'),
                                     0) -
                      (NVL((select sum(A.act_count)
                             from PORT_MIL_BATCH_SAMPLE_RESULT A
                            WHERE 1 = 1
                              AND A.IS_VALID = '1'
                              AND A.STATUS = '3'
                              AND A.PLAN_ID = T.RESULT_NO),
                           0)),
                      0,
                      'OK',
                      '有问题需要查明')),
              '无') PH,
       
       T1.BUCKLE_TYPE,
       T1.LENGTH_RANGE,
       T1.ROLL_STANDRAD,
       T.START_TIME,
       T.FEED_NUM,
       (SELECT SUM(M.MAT_TOTAL_HEIGHT)
          FROM MIL_FEED_PLAN M
         WHERE M.JUDGE_STOVE_NO = T1.JUDGE_STOVE_NO) MAT_TOTAL_HEIGHT,
       T.BEFORE_SCRAP_NUM,
       T.CUT_NUM,
       T.QA_TON,
       T.AFTER_SCRAP_NUM,
       T3.IN_FUR_NUM,
       T3.OUT_FUR_NUM,
       T3.QA_TON QA_TON3,
       T3.SCRAP_NUM SCRAP_NUM3,
       T4.PERFORATION_NUM,
       T4.QA_TON QA_TON4,
       T4.SCRAP_NUM SCRAP_NUM4,
       T5.QUALIFIED_NUM,
       T5.QA_TON QA_TON5,
       T5.SCRAP_NUM SCRAP_NUM5,
       R.OUT_FUR_NUM RHGZ,
       R.QA_TON RHGD,
       R.SCRAP_NUM RFPZ,
       T6.PRODUCT_NUM,
       T6.QA_TON QA_TON6,
       T6.SCRAP_NUM SCRAP_NUM6,
       T7.CUT_NUM CUT_NUM7,
       T7.SCRAP_NUM SCRAP_NUM7,
       T7.CUT_DBNUM,
       T7.QA_TON QA_TON7,
       T7.SCRAP_DBNUM SCRAP_DBNUM7,
       
       (SELECT SUM(T8.QUALIFIED_NUM)
          FROM MIL_STRAIGHTENING_RESULT T8
         WHERE T8.RESULT_NO = T1.ID
           AND LENGTH(T8.USER_ID) > 10) QUALIFIED_NUM8,
       (SELECT SUM(T8.OFFLINE_NUM_TOTAL)
          FROM MIL_STRAIGHTENING_RESULT T8
         WHERE T8.RESULT_NO = T1.ID
           AND LENGTH(T8.USER_ID) > 10) OFFLINE_NUM_TOTAL8,
       (SELECT SUM(T8.QA_TON)
          FROM MIL_STRAIGHTENING_RESULT T8
         WHERE T8.RESULT_NO = T1.ID
           AND LENGTH(T8.USER_ID) > 10) QA_TON8,
       (SELECT SUM(T8.SCRAP_NUM)
          FROM MIL_STRAIGHTENING_RESULT T8
         WHERE T8.RESULT_NO = T1.ID
           AND LENGTH(T8.USER_ID) > 10) SCRAP_NUM8,
       
       DECODE(T.PLINE_CODE,
              'C010',
              (SELECT SUM(T11.QUALIFIED_NUM)
                 FROM MIL_ET_RESULT T11
                WHERE T11.RESULT_NO = T1.ID),
              (SELECT SUM(T9.QUALIFIED_NUM)
                 FROM MIL_MT_RESULT T9
                WHERE T9.RESULT_NO = T1.ID)) QUALIFIED_NUM9,
       
       DECODE(T.PLINE_CODE, 'C010', T11.OFFLINE_NUM, T9.OFFLINE_NUM) OFFLINE_NUM9,
       
       DECODE(T.PLINE_CODE,
              'C010',
              (SELECT SUM(T11.QA_TON)
                 FROM MIL_ET_RESULT T11
                WHERE T11.RESULT_NO = T1.ID),
              (SELECT SUM(T9.QA_TON)
                 FROM MIL_MT_RESULT T9
                WHERE T9.RESULT_NO = T1.ID)) QA_TON9,
       
       DECODE(T.PLINE_CODE,
              'C010',
              (SELECT SUM(T11.SCRAP_NUM) + SUM(T11.SAMPLE_NUM)
                 FROM MIL_ET_RESULT T11
                WHERE T11.RESULT_NO = T1.ID),
              (SELECT SUM(T9.SCRAP_NUM) + SUM(T9.SAMPLE_NUM)
                 FROM MIL_MT_RESULT T9
                WHERE T9.RESULT_NO = T1.ID)) SCRAP_NUM9,
       
       T10.DIRECTOR_QUANTITY,
       (SELECT SUM(T10.QUALIFIED_BRANCH)
          FROM MIL_SURFACE_RESULT T10
         WHERE T10.RESULT_NO = T1.ID) QUALIFIED_BRANCH,
       (SELECT SUM(T10.QUALIFIED_TONS)
          FROM MIL_SURFACE_RESULT T10
         WHERE T10.RESULT_NO = T1.ID) QUALIFIED_TONS,
       (SELECT SUM(T10.WASTE_QUANTITY)
          FROM MIL_SURFACE_RESULT T10
         WHERE T10.RESULT_NO = T1.ID) WASTE_QUANTITY,
       
       CASE T1.NODE_STATUS
         WHEN '10' THEN
          '锯切完成'
         WHEN '20' THEN
          '出炉'
         WHEN '30' THEN
          '穿孔完成'
         WHEN '40' THEN
          '连轧完成'
         WHEN '50' THEN
          '出再加热炉'
         WHEN '60' THEN
          '出定径'
         WHEN '70' THEN
          '分切完成'
         WHEN '80' THEN
          '矫直完成'
         WHEN '90' THEN
          '探伤完成'
         WHEN '96' THEN
          '质检完成'
         WHEN '99' THEN
          '下线'
       END NODE_STATUS1,
       
       (SELECT NVL(SUM(T12.QUALIFIED_NUM), 0)
          FROM MIL_INSTORE_RESULT T12
         WHERE T12.RESULT_NO = T.RESULT_NO) QUALIFIED_NUM12,
       
       (SELECT NVL(SUM(T12.QUALIFIED_TONS), 0)
          FROM MIL_INSTORE_RESULT T12
         WHERE T12.RESULT_NO = T.RESULT_NO) QUALIFIED_TONS12,
       
       (SELECT NVL(SUM(T12.SCRAP_NUM), 0)
          FROM MIL_INSTORE_RESULT T12
         WHERE T12.RESULT_NO = T.RESULT_NO) SCRAP_NUM12,
       
       (SELECT NVL(SUM(T12.QUALIFIED_NUM), 0)
          FROM MIL_INSTORE_RESULT T12
         WHERE T12.RESULT_NO = T.RESULT_NO
           AND REGEXP_REPLACE(T12.JUDGE_STOVE_NO, '-.*', '') =
               REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '')
           AND T12.NODE_FUR_FLAG = '1') XXZ,
       
       (SELECT NVL(SUM(T12.QUALIFIED_TONS), 0)
          FROM MIL_INSTORE_RESULT T12
         WHERE T12.RESULT_NO = T.RESULT_NO
           AND REGEXP_REPLACE(T12.JUDGE_STOVE_NO, '-.*', '') =
               REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '')
           AND T12.NODE_FUR_FLAG = '1') XXD,
       
       NVL((SELECT SUM(Q.ACT_COUNT)
             FROM QCM_ZG_JUGDE_APPLY Q
            WHERE Q.JUDGE_STOVE_NO = REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '')
              AND Q.PROCESS_CODE = 'D'
              AND Q.APPLY_FLAG = '0'),
           0) QUALIFIED_NUM13,
       NVL((SELECT SUM(DECODE(Q.ACT_WEIGHT,
                             NULL,
                             Q.ACT_THEORY_WEIGHT,
                             Q.ACT_WEIGHT))
             FROM QCM_ZG_JUGDE_APPLY Q
            WHERE Q.JUDGE_STOVE_NO = REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '')
              AND Q.PROCESS_CODE = 'D'
              AND Q.APPLY_FLAG = '0'),
           0) QUALIFIED_TONS13,
       '' SCRAP_NUM13,
       NVL((select SUM(Q.ACT_COUNT)
             from QCM_ZG_JUGDE_APPLY Q
            WHERE 1 = 1
              AND Q.VALIDFLAG = '20'
              AND Q.APPLY_FLAG = '0'
              AND Q.PROCESS_CODE = 'D'
              AND Q.JUDGE_STOVE_NO = REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '')),
           0) PDZ,
       
       NVL((select DECODE(NVL(SUM(Q.ACT_WEIGHT), 0),
                         0,
                         SUM(Q.ACT_THEORY_WEIGHT),
                         SUM(Q.ACT_WEIGHT))
             from QCM_ZG_JUGDE_APPLY Q
            WHERE 1 = 1
              AND Q.VALIDFLAG = '20'
              AND Q.APPLY_FLAG = '0'
              AND Q.PROCESS_CODE = 'D'
              AND Q.JUDGE_STOVE_NO = REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '')),
           0) PDD

  from MIL_FEEDSAW_RESULT       T,
       MIL_PLAN                 T1,
       MIL_FUR_RESULT           T3,
       MIL_PERFORATION_RESULT   T4,
       MIL_ROLLING_RESULT       T5,
       MIL_SIZING_RESULT        T6,
       MIL_SAW_RESULT           T7,
       MIL_STRAIGHTENING_RESULT T8,
       MIL_MT_RESULT            T9,
       MIL_ET_RESULT            T11,
       MIL_SURFACE_RESULT       T10,
       MIL_INSTORE_RESULT       T12,
       MIL_REFUR_RESULT         R

 WHERE T.JUDGE_STOVE_NO = T1.JUDGE_STOVE_NO
   AND T1.BACK_SLAB_FLAG <> '2'
   AND T.JUDGE_STOVE_NO = T3.JUDGE_STOVE_NO(+)
   AND T.JUDGE_STOVE_NO = T4.JUDGE_STOVE_NO(+)
   AND T.JUDGE_STOVE_NO = T5.JUDGE_STOVE_NO(+)
   AND T.JUDGE_STOVE_NO = T6.JUDGE_STOVE_NO(+)
   AND T.JUDGE_STOVE_NO = T7.JUDGE_STOVE_NO(+)
   AND T.JUDGE_STOVE_NO = T8.JUDGE_STOVE_NO(+)
   AND T.JUDGE_STOVE_NO = T9.JUDGE_STOVE_NO(+)
   AND T.JUDGE_STOVE_NO = T10.JUDGE_STOVE_NO(+)
   AND T.JUDGE_STOVE_NO = T11.JUDGE_STOVE_NO(+)
   AND T.JUDGE_STOVE_NO = R.JUDGE_STOVE_NO(+)
   AND REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '') = T12.JUDGE_STOVE_NO(+)

]]>
</query>

<query id = "FrmMilDateStatistics.doQueryQcmZgApplyData" desc = "查询加工线前紧急放行数据">
<![CDATA[
SELECT  T.*
  FROM QCM_ZG_JUGDE_APPLY T
 WHERE T.INSTANCY_FLAG = '1'
   AND (T.JUDGE_RESULT is null OR T.JUDGE_RESULT = '不合格')
   AND T.JUDGE_STOVE_NO = ?
 ]]>
</query>

<query id = "FrmMilDateStatistics.getMilOutputStatistics" desc = "轧管产出统计">
<![CDATA[
	select REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '') JUDGE_STOVE_NO1,
       T.FEED_TIME,
       T.LOT_NO,
       T.VARIETIES,
       T.CONTRACT_NO,
       SUBSTR(T.CONTRACT_NO, 1, INSTR(T.CONTRACT_NO, '/') - 1),
       SUBSTR(T.CONTRACT_NO, INSTR(T.CONTRACT_NO, '/') + 1),
       (SELECT L.FINAL_USER_DESC
          FROM SLM_ORDER_LINE L, SLM_ORDER_HEAD H
         WHERE H.ORD_PK = L.ORD_PK
           AND H.ORDER_NO =
               SUBSTR(T.CONTRACT_NO, 1, INSTR(T.CONTRACT_NO, '/') - 1)
           AND L.ORDER_SEQ =
               SUBSTR(T.CONTRACT_NO, INSTR(T.CONTRACT_NO, '/') + 1)
           AND H.VALIDFLAG = '1'
           AND L.VALIDFLAG = '1') FINAL_USER_DESC,
       REPLACE(T.PIPE_SIZE, '*', 'x') PIPE_SIZE,
       T.BUCKLE_TYPE,
       T.STEELNAME,
       T.GRADENAME,
       
       (SELECT B.PLINE_NAME
          FROM COM_BASE_PLINE B
         WHERE B.PLINE_CODE = T.PLINE_CODE) PLINE_CODE1,
       CASE T.NODE_STATUS
         WHEN '10' THEN
          '锯切完成'
         WHEN '20' THEN
          '出炉'
         WHEN '30' THEN
          '穿孔完成'
         WHEN '40' THEN
          '连轧完成'
         WHEN '50' THEN
          '出再加热炉'
         WHEN '60' THEN
          '出定径'
         WHEN '70' THEN
          '分切完成'
         WHEN '80' THEN
          '矫直完成'
         WHEN '90' THEN
          '探伤完成'
         WHEN '96' THEN
          '质检完成'
         WHEN '99' THEN
          '下线'
       END NODE_STATUS1,
       DECODE(T.TARGET, 'A', '成品', '在制品') TARGET1,
       SUM(T1.FEED_NUM) TR,
       SUM(T1.FEED_NUM * T1.DB_NUM) * T.SAW_NUM YJ,
       
       (SELECT NVL(SUM(M.QUALIFIED_NUM), 0)
          FROM MIL_INSTORE_RESULT M
         where 1 = 1
           AND M.RESULT_NO = T.ID) CC,
       
       (select nvl(sum(M.QUALIFIED_TONS), 0)
          from MIL_INSTORE_RESULT M
         where 1 = 1
           AND M.RESULT_NO = T.ID) HGD,
       
       (select count(1)
          from port_mil_batch_sample_result A
         where 1 = 1
           and A.status in ('1', '2')
           AND A.PLAN_ID = T.ID) FEI,
       
       (select nvl(sum(A.ACT_THEORY_WEIGHT), 0)
          from port_mil_batch_sample_result A
         where 1 = 1
           and A.status in ('1', '2')
           AND A.PLAN_ID = T.ID) FPD

  from MIL_PLAN T, MIL_FEED_PLAN T1
 WHERE 1 = 1
   AND T.JUDGE_STOVE_NO = T1.JUDGE_STOVE_NO
   AND T.BACK_SLAB_FLAG <> '2'
]]>
</query>


<query id = "FrmMilDateStatistics.getQcmZgJugdeApply" desc = "申请判定表">
<![CDATA[
	SELECT DISTINCT T.JUGDE_APPLY_CODE,
                T.JUDGE_STOVE_NO,
                T.BATCH_NO,
                T.BATCH_GROUD_NO,
                T.PROCESS_CODE,
                T.PLINE_CODE,
                T.ACT_COUNT,
                T.ACT_WEIGHT,
                DECODE(T.ACT_WEIGHT,NULL,T.ACT_THEORY_WEIGHT,T.ACT_WEIGHT) ACT_THEORY_WEIGHT,
                T.PRO_ORDER_ID,
                DECODE(T.VALIDFLAG,
                       '00',
                       '待判定',
                       '10',
                       '判定中',
                       '20',
                       '已判定') VALIDFLAG,
                T.APPLY_NAME,
                TO_CHAR(T.APPLY_TIME, 'YYYY-MM-DD HH24:MI:SS') APPLY_TIME,
                TO_CHAR(T1.FEED_TIME, 'YYYY-MM-DD HH24:MI:SS') FEED_TIME,
                T.MEMO,
                TO_CHAR(T.QUALITY_GROUP) QUALITY_GROUP,
                T.PRODUCNAME,
                T.STEELNAME,
                T.GRADENAME,
                REPLACE(T.SPEC_NAME, '*', 'x') SPEC_NAME,
                T.MODEL_DESC,
                (SELECT SUBSTR(L.STD_NAME, 1, 70) ||
                        decode(L.USE_DESC,
                               '/',
                               '',
                               '',
                               '',
                               ',' || L.USE_DESC)
                   FROM SLM_ORDER_HEAD H, SLM_ORDER_LINE L
                  WHERE H.ORD_PK = L.ORD_PK
                    AND H.ORDER_NO =
                        SUBSTR(T1.CONTRACT_NO,
                               1,
                               INSTR(T1.CONTRACT_NO, '/') - 1)
                    AND L.ORDER_SEQ =
                        SUBSTR(T1.CONTRACT_NO, INSTR(T1.CONTRACT_NO, '/') + 1)
                    AND H.VALIDFLAG = '1'
                    AND L.VALIDFLAG = '1') STD_NAME,
                T.STD_STYLE_DESC,
                T.CRAF_NO,
                T.LOT_NO,
                T.PLINE_NAME,
                T.PRO_ORDER_NO,
                T.TARGET,
                T.PROCESS_STATUS,
                T.MAT_GOWHERE_NAME,
                TO_CHAR(T.ACT_DIMATER) ACT_DIMATER,
                TO_CHAR(T.ACT_HEIGHT) ACT_HEIGHT,
                T.ACT_LEN_MIN,
                T.ACT_LEN_MAX,
                T.JUDGE_RESULT,
                TO_CHAR(T.JUDGE_RESULT_TIME, 'YYYY-MM-DD HH24:MI:SS') JUDGE_RESULT_TIME,
                T.JUDGE_MAKER

  FROM QCM_ZG_JUGDE_APPLY T, MIL_PLAN T1
 WHERE T.PROCESS_CODE = 'D'
   AND T.JUDGE_STOVE_NO = REGEXP_REPLACE(T1.JUDGE_STOVE_NO, '-.*', '')
   AND T1.BACK_SLAB_FLAG <> '2'
]]>
</query>

<query id = "FrmMilDateStatistics.getNoQcmZgJugdeApply" desc = "待送判的数据">
<![CDATA[
	select distinct '' JUGDE_APPLY_CODE,
                t1.judge_stove_no,
                t1.batch_no,
                '' BATCH_GROUD_NO,
                'D' PROCESS_CODE,
                P.PLINE_CODE,
                t1.act_count -
                (select nvl(sum(a.act_count), 0)
                   from QCM_ZG_JUGDE_APPLY a
                  where a.judge_stove_no = t1.judge_stove_no
                    and a.pline_code = t1.pline_code) ACT_COUNT,
                
                0 ACT_WEIGHT,
                
                t1.act_theory_weight -
                (select nvl(sum(a.ACT_THEORY_WEIGHT), 0)
                   from QCM_ZG_JUGDE_APPLY a
                  where a.judge_stove_no = t1.judge_stove_no
                    and a.pline_code = t1.pline_code) ACT_THEORY_WEIGHT,
                
                '' PRO_ORDER_ID,
                '待送判' VALIDFLAG,
                '' APPLY_NAME,
                '' APPLY_TIME,
                TO_CHAR(P.FEED_TIME, 'YYYY-MM-DD HH24:MI:SS') FEED_TIME,
                '' MEMO,
                '' QUALITY_GROUP,
                P.VARIETIES PRODUCNAME,
                P.STEELNAME,
                P.GRADENAME,
                REPLACE(P.pipe_size, '*', 'x') SPEC_NAME,
                P.BUCKLE_TYPE_CODE MODEL_DESC,
                (SELECT SUBSTR(L.STD_NAME, 1, 70) ||
                        decode(L.USE_DESC,
                               '/',
                               '',
                               '',
                               '',
                               ',' || L.USE_DESC)
                   FROM SLM_ORDER_HEAD H, SLM_ORDER_LINE L
                  WHERE H.ORD_PK = L.ORD_PK
                    AND H.ORDER_NO =
                        SUBSTR(P.CONTRACT_NO,
                               1,
                               INSTR(P.CONTRACT_NO, '/') - 1)
                    AND L.ORDER_SEQ =
                        SUBSTR(P.CONTRACT_NO, INSTR(P.CONTRACT_NO, '/') + 1)
                    AND H.VALIDFLAG = '1'
                    AND L.VALIDFLAG = '1') STD_NAME,
                P.STD_STYLE_DESC,
                '' CRAF_NO,
                P.LOT_NO,
                (SELECT B.PLINE_NAME
                   FROM COM_BASE_PLINE B
                  WHERE B.PLINE_CODE = T1.PLINE_CODE) PLINE_NAME,
                P.CONTRACT_NO PRO_ORDER_NO,
                P.TARGET,
                '' PROCESS_STATUS,
                '' MAT_GOWHERE_NAME,
                SUBSTR(P.PIPE_SIZE, 1, INSTR(P.PIPE_SIZE, '*') - 1) ACT_DIMATER,
                SUBSTR(P.PIPE_SIZE, INSTR(P.PIPE_SIZE, '*') + 1) ACT_HEIGHT,
                SUBSTR(P.LENGTH_RANGE, 1, INSTR(P.LENGTH_RANGE, '-') - 1) ACT_LEN_MIN,
                SUBSTR(P.LENGTH_RANGE, INSTR(P.LENGTH_RANGE, '-') + 1) ACT_LEN_MAX,
                '' JUDGE_RESULT,
                '' JUDGE_RESULT_TIME,
                '' JUDGE_MAKER
  from (select t.plan_id,
               t.lot_no,
               t.bal_year_month,
               t.BATCH_NO,
               REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '') judge_stove_no,
               t.pline_code,
               sum(t.act_count) act_count,
               sum(t.act_theory_weight) act_theory_weight
          from PORT_MIL_BATCH_SAMPLE_RESULT t, MIL_INSTORE_RESULT m
         where t.INSTORE_FLAG = '1'
           and t.PLAN_ID = m.result_no
           and m.NODE_FUR_FLAG = '1'
         group by t.plan_id,
                  t.lot_no,
                  t.bal_year_month,
                  t.BATCH_NO,
                  REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', ''),
                  t.pline_code) t1,
       mil_plan p

 where 1 = 1
 AND P.BACK_SLAB_FLAG <> '2'
   and t1.plan_id = p.id
   AND t1.act_count > (select nvl(sum(a.act_count), 0)
                         from QCM_ZG_JUGDE_APPLY a
                        where a.judge_stove_no = t1.judge_stove_no
                          and a.pline_code = t1.pline_code)
]]>
</query>


<query id = "FrmMilDateStatistics.getQcmZgJugdeApplyAll" desc = "申请判定表综合">
<![CDATA[
	select t.*,
       (SELECT B.PLINE_NAME
          FROM COM_BASE_PLINE B
         WHERE B.PLINE_CODE = T.PLINE_CODE) PLINE_NAME,
       
       (t.act_count - (select nvl(sum(a.act_count), 0)
                         from QCM_ZG_JUGDE_APPLY a
                        where a.judge_stove_no = t.judge_stove_no
                          and a.batch_no = t.BATCH_NO
                          AND A.PROCESS_CODE = 'D'
                          and a.pline_code = t.pline_code)) wsp,
                          
       (t.act_theory_weight -
       (select nvl(sum(a.ACT_THEORY_WEIGHT),0)
           from QCM_ZG_JUGDE_APPLY a
          where a.judge_stove_no = t.judge_stove_no
            and a.batch_no = t.BATCH_NO
            AND A.PROCESS_CODE = 'D'
            and a.pline_code = t.pline_code)) wspd,
            
       (select nvl(sum(a.act_count), 0)
          from QCM_ZG_JUGDE_APPLY a
         where a.judge_stove_no = t.judge_stove_no
           and a.batch_no = t.BATCH_NO
           AND A.PROCESS_CODE = 'D'
           and a.pline_code = t.pline_code
           and a.VALIDFLAG = '00') wpd,
       (select nvl(sum(decode(a.act_weight,
                              null,
                              a.ACT_THEORY_WEIGHT,
                              a.act_weight)),
                   0)
          from QCM_ZG_JUGDE_APPLY a
         where a.judge_stove_no = t.judge_stove_no
           and a.batch_no = t.BATCH_NO
           AND A.PROCESS_CODE = 'D'
           and a.pline_code = t.pline_code
           and a.VALIDFLAG = '00') wpdd,
       
       (select nvl(sum(a.act_count), 0)
          from QCM_ZG_JUGDE_APPLY a
         where a.judge_stove_no = t.judge_stove_no
           and a.batch_no = t.BATCH_NO
           AND A.PROCESS_CODE = 'D'
           and a.pline_code = t.pline_code
           and a.VALIDFLAG = '10') pdz,
       (select nvl(sum(decode(a.act_weight,
                              null,
                              a.ACT_THEORY_WEIGHT,
                              a.act_weight)),
                   0)
          from QCM_ZG_JUGDE_APPLY a
         where a.judge_stove_no = t.judge_stove_no
           and a.batch_no = t.BATCH_NO
           AND A.PROCESS_CODE = 'D'
           and a.pline_code = t.pline_code
           and a.VALIDFLAG = '10') pdzd,
       
       (select nvl(sum(a.act_count), 0)
          from QCM_ZG_JUGDE_APPLY a
         where a.judge_stove_no = t.judge_stove_no
           and a.batch_no = t.BATCH_NO
           AND A.PROCESS_CODE = 'D'
           and a.pline_code = t.pline_code
           and a.VALIDFLAG = '20') ypd,
           
       (select nvl(sum(a.act_weight),0)
          from QCM_ZG_JUGDE_APPLY a
         where a.judge_stove_no = t.judge_stove_no
           and a.batch_no = t.BATCH_NO
           AND A.PROCESS_CODE = 'D'
           and a.pline_code = t.pline_code
           and a.VALIDFLAG = '20') ypdsz,
           
       (select nvl(sum(a.ACT_THEORY_WEIGHT),0)
          from QCM_ZG_JUGDE_APPLY a
         where a.judge_stove_no = t.judge_stove_no
           and a.batch_no = t.BATCH_NO
           AND A.PROCESS_CODE = 'D'
           and a.pline_code = t.pline_code
           and a.VALIDFLAG = '20') ypdlz,
       
       (select to_char(f.start_time, 'yyyy-MM-dd HH24:mi:ss')
          from mil_feedsaw_result f
         where f.result_no = t.plan_id
           and f.pline_code = t.pline_code) start_time,
       
       (select a.MATERIAL_NO
          from QCM_ZG_JUGDE_APPLY a
         where a.judge_stove_no = t.judge_stove_no
           and a.pline_code = t.pline_code
           AND A.PROCESS_CODE = 'D'
         group by a.MATERIAL_NO) MATERIAL_NO,
       
       decode(p.varieties, null, '', p.varieties || ',') ||
       decode(p.STD_STYLE_DESC, null, '', p.STD_STYLE_DESC || ',') ||
       decode(p.steelname, null, '', p.steelname || ',') ||
       decode(p.pipe_size, null, '', p.pipe_size || ',') || p.BUCKLE_TYPE MATERIAL_NAME,
       p.varieties,
       p.STD_STYLE_DESC,
       p.steelname,
       REPLACE(p.pipe_size, '*', 'x') pipe_size,
       p.BUCKLE_TYPE,
       p.TARGET

  from (select t.plan_id,
               t.lot_no,
               t.bal_year_month,
               t.BATCH_NO,
               REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '') judge_stove_no,
               t.pline_code,
               sum(t.act_count) act_count,
               sum(t.act_theory_weight) act_theory_weight
          from PORT_MIL_BATCH_SAMPLE_RESULT t
         where t.INSTORE_FLAG = '1'
         group by t.plan_id,
                  t.lot_no,
                  t.bal_year_month,
                  t.BATCH_NO,
                  REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', ''),
                  t.pline_code) t,
       mil_plan p

 where 1 = 1
 AND P.BACK_SLAB_FLAG <> '2'
   and t.plan_id = p.id(+)
]]>
</query>

<query id = "FrmMilDateStatistics.getQcmZgJugdeApplyTest" desc = "申请判定表Test">
<![CDATA[
	SELECT T.JUGDE_APPLY_CODE,
       T.JUDGE_STOVE_NO,
       T.BATCH_NO,
       T.BATCH_GROUD_NO,
       T.PROCESS_CODE,
       T.PLINE_CODE,
       T.ACT_COUNT,
       DECODE(T.ACT_WEIGHT, NULL, T.ACT_THEORY_WEIGHT, T.ACT_WEIGHT) ACT_WEIGHT,
       T.PRO_ORDER_ID,
       T.FACE_RESULT_CODE,
       T.SPEC_RESULT_CODE,
       T.CHEM_RESULT_CODE,
       T.PHY_RESULT_CODE,
       T.DETECT_RESULT_CODE,
       T.WPRESSURE_RESULT_CODE,
       T.PROCESS_RESULT_CODE,
       T.FACE_RESULT_PATH,
       T.SPEC_RESULT_PATH,
       T.CHEM_RESULT_PATH,
       T.PHY_RESULT_PATH,
       T.DETECT_RESULT_PATH,
       T.WPRESSURE_RESULT_PATH,
       T.PROCESS_RESULT_PATH,
       DECODE(T.VALIDFLAG, '00', '待判定', '10', '判定中', '20', '已判定') VALIDFLAG,
       T.APPLY_NAME,
       TO_CHAR(T.APPLY_TIME, 'YYYY-MM-DD HH24:MI:SS') APPLY_TIME,
       T.MEMO,
       T.QUALITY_GROUP,
       T.MATERIAL_NO,
       T.MATERIAL_NAME,
       T.PRODUCCODE,
       T.PRODUCNAME,
       T.STEELCODE,
       T.STEELNAME,
       T.GRADECODE,
       T.GRADENAME,
       T.SPEC_CODE,
       T.SPEC_NAME,
       T.MODEL_CODE,
       T.MODEL_DESC,
       T.STD_CODE,
       T.STD_NAME,
       T.STD_STYLE,
       T.STD_STYLE_DESC,
       T.CRAF_NO,
       T.LOT_NO,
       T.PLINE_NAME,
       T.PRO_ORDER_NO,
       T.TARGET,
       T.PROCESS_STATUS,
       T.MAT_GOWHERE_CODE,
       T.MAT_GOWHERE_NAME,
       T.ACT_DIMATER,
       T.ACT_HEIGHT,
       T.ACT_LEN_MIN,
       T.ACT_LEN_MAX,
       T.JUDGE_RESULT_CODE,
       T.JUDGE_RESULT,
       TO_CHAR(T.JUDGE_RESULT_TIME, 'YYYY-MM-DD HH24:MI:SS') JUDGE_RESULT_TIME,
       T.JUDGE_MAKER,
       T.IF_SET_ZY_PLAN,
       T.TESTING_GRADE,
       T.TESTING_TYPE,
       T.TESTING_GRADE1,
       T.TESTING_TYPE1,
       T.DETECT_RESULT_CODE1,
       T.DETECT_RESULT_PATH1,
       T.ORD_LN_DLY_PK,
       T.APPLY_FLAG,
       T.BACK_JUGDE_MEMO
  FROM QCM_ZG_JUGDE_APPLY T
 WHERE 1 = 1
   AND T.APPLY_TIME >= to_date(?, 'yyyy-MM-dd HH24:mi:ss')
   AND T.APPLY_TIME <= to_date(?, 'yyyy-MM-dd HH24:mi:ss')
   AND T.JUGDE_APPLY_CODE || '&' LIKE ('%' || ? || '%')
   AND T.LOT_NO || '&' LIKE ('%' || ? || '%')
   AND T.PLINE_CODE || '&' LIKE ('%' || ? || '%')
]]>
</query>


<query id = "FrmMilDateStatistics.getMilScrapStatistics" desc = "轧管废品统计">
<![CDATA[
	select REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '') JUDGE_STOVE_NO1,
       T.FEED_TIME,
       T.LOT_NO,
       T.VARIETIES,
       T.CONTRACT_NO,
       REPLACE(T.PIPE_SIZE, '*', 'x') PIPE_SIZE,
       T.BUCKLE_TYPE,
       T.STEELNAME,
       T.GRADENAME,
       (SELECT B.PLINE_NAME
          FROM COM_BASE_PLINE B
         WHERE B.PLINE_CODE = T.PLINE_CODE) PLINE_CODE1,
       CASE T.NODE_STATUS
         WHEN '10' THEN
          '锯切完成'
         WHEN '20' THEN
          '出炉'
         WHEN '30' THEN
          '穿孔完成'
         WHEN '40' THEN
          '连轧完成'
         WHEN '50' THEN
          '出再加热炉'
         WHEN '60' THEN
          '出定径'
         WHEN '70' THEN
          '分切完成'
         WHEN '80' THEN
          '矫直完成'
         WHEN '90' THEN
          '探伤完成'
         WHEN '96' THEN
          '质检完成'
         WHEN '99' THEN
          '下线'
       END NODE_STATUS1,
       DECODE(T.TARGET, 'A', '成品', '在制品') TARGET1,
       SUM(T1.FEED_NUM) TR,
       SUM(T1.FEED_NUM * T1.DB_NUM) * T.SAW_NUM YJ,
       
       (select count(1)
          from port_mil_batch_sample_result A
         where 1 = 1
           and A.status NOT IN ('1', '2')
           and A.instore_flag = '1'
           AND A.IS_VALID = '1'
           AND A.PLAN_ID = T.ID) -
       (select count(1)
          from port_mil_batch_sample_result A
         where 1 = 1
           AND A.PLAN_ID = T.ID
           AND SUBSTR(A.JUDGE_STOVE_NO, -2) != '01') CC,
       
       (select nvl(sum(A.ACT_THEORY_WEIGHT), 0)
          from port_mil_batch_sample_result A
         where 1 = 1
           and A.status NOT IN ('1', '2')
           and A.instore_flag = '1'
           AND A.IS_VALID = '1'
           AND A.PLAN_ID = T.ID) -
       (select nvl(sum(A.ACT_THEORY_WEIGHT), 0)
          from port_mil_batch_sample_result A
         where 1 = 1
           AND A.PLAN_ID = T.ID
           AND SUBSTR(A.JUDGE_STOVE_NO, -2) != '01') HGD,
       
       SUM(T1.FEED_NUM_PLAN) SLZ,
       SUM(T1.MAT_TOTAL_HEIGHT) SLD,
       CASE
         WHEN SUM(T1.MAT_TOTAL_HEIGHT) = 0 THEN
          '%'
         ELSE
          TRIM(TO_CHAR((nvl((select SUM(A.ACT_THEORY_WEIGHT)
                              from port_mil_batch_sample_result A
                             where A.PLAN_ID = T.ID
                               AND REGEXP_REPLACE(A.JUDGE_STOVE_NO,
                                                  '-.*',
                                                  '') =
                                   REGEXP_REPLACE(T.JUDGE_STOVE_NO,
                                                  '-.*',
                                                  '')
                               AND A.STATUS IN ('1', '2', '6')),
                            0) * 100 / SUM(T1.MAT_TOTAL_HEIGHT)),
                       '990.999') || '%')
       END RATE,
       (select count(1)
          from port_mil_batch_sample_result A
         where A.PLAN_ID = T.ID
           AND REGEXP_REPLACE(A.JUDGE_STOVE_NO, '-.*', '') =
               REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '')
           AND A.STATUS IN ('1', '2', '6')) FEI,
       (select SUM(A.ACT_THEORY_WEIGHT)
          from port_mil_batch_sample_result A
         where A.PLAN_ID = T.ID
           AND REGEXP_REPLACE(A.JUDGE_STOVE_NO, '-.*', '') =
               REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '')
           AND A.STATUS IN ('1', '2', '6')) FPD

  from MIL_PLAN T, MIL_FEED_PLAN T1
 WHERE T.BACK_SLAB_FLAG <> '2'
   AND T.JUDGE_STOVE_NO = T1.JUDGE_STOVE_NO
]]>
</query>


<query id = "FrmMilDateStatistics.getMilDateStatisticsBatchSample" desc = "统计PORT_MIL_BATCH_SAMPLE_RESULT表中剔管数据">
<![CDATA[
 SELECT AA.*,
       CASE AA.NODE_STATUS
         WHEN '10' THEN
          '锯切完成'
         WHEN '20' THEN
          '出炉'
         WHEN '30' THEN
          '穿孔完成'
         WHEN '40' THEN
          '连轧完成'
         WHEN '50' THEN
          '出再加热炉'
         WHEN '60' THEN
          '出定径'
         WHEN '70' THEN
          '分切完成'
         WHEN '80' THEN
          '矫直完成'
         WHEN '90' THEN
          '探伤完成'
         WHEN '96' THEN
          '质检完成'
         WHEN '99' THEN
          '下线'
       END NODE_STATUS1,
       CASE
         WHEN AA.NODE_STATUS < 20 THEN
          0
         ELSE
          AA.HGZ1 - AA.FPZ2
       END HGZ2,
       CASE
         WHEN AA.NODE_STATUS < 20 THEN
          0
         ELSE
          AA.HGD1 - AA.FPD2
       END HGD2,
       
       CASE
         WHEN AA.NODE_STATUS < 30 THEN
          0
         ELSE
          AA.HGZ1 - AA.FPZ2 - AA.FPZ3
       END HGZ3,
       CASE
         WHEN AA.NODE_STATUS < 30 THEN
          0
         ELSE
          AA.HGD1 - AA.FPD2 - AA.FPD3
       END HGD3,
       
       CASE
         WHEN AA.NODE_STATUS < 40 THEN
          0
         ELSE
          AA.HGZ1 - AA.FPZ2 - AA.FPZ3 - AA.FPZ4
       END HGZ4,
       CASE
         WHEN AA.NODE_STATUS < 40 THEN
          0
         ELSE
          AA.HGD1 - AA.FPD2 - AA.FPD3 - AA.FPD4
       END HGD4,
       
       CASE
         WHEN AA.NODE_STATUS < 50 THEN
          0
         ELSE
          AA.HGZ1 - AA.FPZ2 - AA.FPZ3 - AA.FPZ4 - AA.FPZ5
       END HGZ5,
       CASE
         WHEN AA.NODE_STATUS < 50 THEN
          0
         ELSE
          AA.HGD1 - AA.FPD2 - AA.FPD3 - AA.FPD4 - AA.FPD5
       END HGD5,
       
       CASE
         WHEN AA.NODE_STATUS < 60 THEN
          0
         ELSE
          AA.HGZ1 - AA.FPZ2 - AA.FPZ3 - AA.FPZ4 - AA.FPZ5 - AA.FPZ6
       END HGZ6,
       CASE
         WHEN AA.NODE_STATUS < 60 THEN
          0
         ELSE
          AA.HGD1 - AA.FPD2 - AA.FPD3 - AA.FPD4 - AA.FPD5 - AA.FPD6
       END HGD6,
       
       CASE
         WHEN AA.NODE_STATUS < 80 THEN
          0
         ELSE
          AA.HGZ7 - AA.FPZ9 - AA.XXZ9 - AA.ZLZ9
       END HGZ9,
       CASE
         WHEN AA.NODE_STATUS < 80 THEN
          0
         ELSE
          AA.HGD7 - AA.FPD9 - AA.XXD9 - AA.ZLD9
       END HGD9,
       
       CASE
         WHEN AA.NODE_STATUS < 90 THEN
          0
         ELSE
          AA.HGZ7 - AA.FPZ9 - AA.XXZ9 - AA.FPZ10 - AA.XXZ10 - AA.ZLZ10
       END HGZ10,
       CASE
         WHEN AA.NODE_STATUS < 90 THEN
          0
         ELSE
          AA.HGD7 - AA.FPD9 - AA.XXD9 - AA.FPD10 - AA.XXD10 - AA.ZLD10
       END HGD10,
       
       CASE
         WHEN AA.NODE_STATUS < 96 THEN
          0
         ELSE
          AA.HGZ7 - AA.FPZ9 - AA.XXZ9 - AA.FPZ10 - AA.XXZ10 - AA.FPZ11 -
          AA.XXZ11 - AA.ZLZ11
       END HGZ11,
       CASE
         WHEN AA.NODE_STATUS < 96 THEN
          0
         ELSE
          AA.HGD7 - AA.FPD9 - AA.XXD9 - AA.FPD10 - AA.XXD10 - AA.FPD11 -
          AA.XXD11 - AA.ZLD11
       END HGD11

  FROM (select REGEXP_REPLACE(T1.JUDGE_STOVE_NO, '-.*', '') JUDGE_STOVE_NO,
               T1.LOT_NO,
               T.PLINE_CODE,
               (SELECT A.PLINE_NAME
                  FROM COM_BASE_PLINE A
                 WHERE A.PLINE_CODE = T.PLINE_CODE) PLINE_CODE1,
               T1.CONTRACT_NO,
               --MAX(H.ORDER_TYP_DESC) ORDER_TYP_DESC,
               (SELECT MAX(H.ORDER_TYP_DESC)
                  FROM SLM_ORDER_HEAD H
                 WHERE H.ORDER_NO =
                       SUBSTR(T1.CONTRACT_NO,
                              1,
                              INSTR(T1.CONTRACT_NO, '/') - 1)) ORDER_TYP_DESC,
               MAX(M.PASS_NAME) PASS_NAME,
               MAX(T1.VARIETIES) VARIETIES,
               MAX(T1.STEELNAME) STEELNAME,
               MAX(T1.GRADENAME) GRADENAME,
               REPLACE(MAX(T1.PIPE_SIZE), '*', 'x') PIPE_SIZE,
               MAX(T1.BUCKLE_TYPE) BUCKLE_TYPE,
               MAX(T1.LENGTH_RANGE) LENGTH_RANGE,
               MAX(T1.ROLL_STANDRAD) ROLL_STANDRAD,
               MIN(T.START_TIME) START_TIME,
               --MAX(T1.NODE_STATUS) NODE_STATUS,
               MAX(T1.TARGET) TARGET,
               
               (SELECT MAX(NODE_STATUS) FROM MIL_PLAN WHERE ID = T1.ID) NODE_STATUS,
               
               (SELECT count(1)
                  from (SELECT B.JUDGE_STOVE_NO,
                               B.m_mat_no,
                               SUM(B.ACT_THEORY_WEIGHT) ACT_THEORY_WEIGHT
                          FROM PORT_MIL_BATCH_SAMPLE_RESULT B
                         WHERE B.IS_VALID = '1'
                           AND (TRIM(B.Op_Process) != '0' OR
                               B.Op_Process IS NULL)
                         group by B.m_mat_no, B.JUDGE_STOVE_NO) A
                 WHERE A.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO
                 GROUP BY A.JUDGE_STOVE_NO) HGZ1,
               
               (SELECT SUM(A.ACT_THEORY_WEIGHT)
                  from (SELECT B.JUDGE_STOVE_NO,
                               B.m_mat_no,
                               SUM(B.ACT_THEORY_WEIGHT) ACT_THEORY_WEIGHT
                          FROM PORT_MIL_BATCH_SAMPLE_RESULT B
                         WHERE B.IS_VALID = '1'
                           AND (TRIM(B.Op_Process) != '0' OR
                               B.Op_Process IS NULL)
                         group by B.m_mat_no, B.JUDGE_STOVE_NO) A
                 WHERE A.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO
                 GROUP BY A.JUDGE_STOVE_NO) HGD1,
               
               (select COUNT(1)
                  from (select B.JUDGE_STOVE_NO,
                               TRIM(B.OP_PROCESS) OP_PROCESS,
                               B.m_mat_no,
                               SUM(B.ACT_THEORY_WEIGHT) ACT_THEORY_WEIGHT
                          from PORT_MIL_BATCH_SAMPLE_RESULT B
                         WHERE B.IS_VALID = '1'
                           AND B.STATUS = '1'
                         group by B.JUDGE_STOVE_NO, B.m_mat_no, B.op_process) A
                 WHERE A.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO
                   AND A.OP_PROCESS = '0') FPZ1,
               
               NVL((select SUM(A.ACT_THEORY_WEIGHT)
                     from (select B.JUDGE_STOVE_NO,
                                  TRIM(B.OP_PROCESS) OP_PROCESS,
                                  B.m_mat_no,
                                  SUM(B.ACT_THEORY_WEIGHT) ACT_THEORY_WEIGHT
                             from PORT_MIL_BATCH_SAMPLE_RESULT B
                            WHERE B.IS_VALID = '1'
                              AND B.STATUS = '1'
                            group by B.JUDGE_STOVE_NO,
                                     B.m_mat_no,
                                     B.op_process) A
                    WHERE A.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO
                      AND A.OP_PROCESS = '0'),
                   0) FPD1,
               
               (select COUNT(1)
                  from (select B.JUDGE_STOVE_NO,
                               TRIM(B.OP_PROCESS) OP_PROCESS,
                               B.m_mat_no,
                               SUM(B.ACT_THEORY_WEIGHT) ACT_THEORY_WEIGHT
                          from PORT_MIL_BATCH_SAMPLE_RESULT B
                         WHERE B.IS_VALID = '1'
                           AND B.STATUS = '1'
                         group by B.JUDGE_STOVE_NO, B.m_mat_no, B.op_process) A
                 WHERE A.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO
                   AND A.OP_PROCESS = '2') FPZ2,
               
               NVL((select SUM(A.ACT_THEORY_WEIGHT)
                     from (select B.JUDGE_STOVE_NO,
                                  TRIM(B.OP_PROCESS) OP_PROCESS,
                                  B.m_mat_no,
                                  SUM(B.ACT_THEORY_WEIGHT) ACT_THEORY_WEIGHT
                             from PORT_MIL_BATCH_SAMPLE_RESULT B
                            WHERE B.IS_VALID = '1'
                              AND B.STATUS = '1'
                            group by B.JUDGE_STOVE_NO,
                                     B.m_mat_no,
                                     B.op_process) A
                    WHERE A.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO
                      AND A.OP_PROCESS = '2'),
                   0) FPD2,
               
               (select COUNT(1)
                  from (select B.JUDGE_STOVE_NO,
                               TRIM(B.OP_PROCESS) OP_PROCESS,
                               B.m_mat_no,
                               SUM(B.ACT_THEORY_WEIGHT) ACT_THEORY_WEIGHT
                          from PORT_MIL_BATCH_SAMPLE_RESULT B
                         WHERE B.IS_VALID = '1'
                           AND B.STATUS = '1'
                         group by B.JUDGE_STOVE_NO, B.m_mat_no, B.op_process) A
                 WHERE A.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO
                   AND A.OP_PROCESS = '3') FPZ3,
               
               NVL((select SUM(A.ACT_THEORY_WEIGHT)
                     from (select B.JUDGE_STOVE_NO,
                                  TRIM(B.OP_PROCESS) OP_PROCESS,
                                  B.m_mat_no,
                                  SUM(B.ACT_THEORY_WEIGHT) ACT_THEORY_WEIGHT
                             from PORT_MIL_BATCH_SAMPLE_RESULT B
                            WHERE B.IS_VALID = '1'
                              AND B.STATUS = '1'
                            group by B.JUDGE_STOVE_NO,
                                     B.m_mat_no,
                                     B.op_process) A
                    WHERE A.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO
                      AND A.OP_PROCESS = '3'),
                   0) FPD3,
               
               (select COUNT(1)
                  from (select B.JUDGE_STOVE_NO,
                               TRIM(B.OP_PROCESS) OP_PROCESS,
                               B.m_mat_no,
                               SUM(B.ACT_THEORY_WEIGHT) ACT_THEORY_WEIGHT
                          from PORT_MIL_BATCH_SAMPLE_RESULT B
                         WHERE B.IS_VALID = '1'
                           AND B.STATUS = '1'
                         group by B.JUDGE_STOVE_NO, B.m_mat_no, B.op_process) A
                 WHERE A.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO
                   AND A.OP_PROCESS = '4') FPZ4,
               
               NVL((select SUM(A.ACT_THEORY_WEIGHT)
                     from (select B.JUDGE_STOVE_NO,
                                  TRIM(B.OP_PROCESS) OP_PROCESS,
                                  B.m_mat_no,
                                  SUM(B.ACT_THEORY_WEIGHT) ACT_THEORY_WEIGHT
                             from PORT_MIL_BATCH_SAMPLE_RESULT B
                            WHERE B.IS_VALID = '1'
                              AND B.STATUS = '1'
                            group by B.JUDGE_STOVE_NO,
                                     B.m_mat_no,
                                     B.op_process) A
                    WHERE A.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO
                      AND A.OP_PROCESS = '4'),
                   0) FPD4,
               
               (select COUNT(1)
                  from (select B.JUDGE_STOVE_NO,
                               TRIM(B.OP_PROCESS) OP_PROCESS,
                               B.m_mat_no,
                               SUM(B.ACT_THEORY_WEIGHT) ACT_THEORY_WEIGHT
                          from PORT_MIL_BATCH_SAMPLE_RESULT B
                         WHERE 1 = 1
                           AND B.IS_VALID = '1'
                           AND B.STATUS = '1'
                         group by B.JUDGE_STOVE_NO, B.m_mat_no, B.op_process) A
                 WHERE A.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO
                   AND A.OP_PROCESS = '5') FPZ5,
               
               NVL((select SUM(A.ACT_THEORY_WEIGHT)
                     from (select B.JUDGE_STOVE_NO,
                                  TRIM(B.OP_PROCESS) OP_PROCESS,
                                  B.m_mat_no,
                                  SUM(B.ACT_THEORY_WEIGHT) ACT_THEORY_WEIGHT
                             from PORT_MIL_BATCH_SAMPLE_RESULT B
                            WHERE B.IS_VALID = '1'
                              AND B.STATUS = '1'
                            group by B.JUDGE_STOVE_NO,
                                     B.m_mat_no,
                                     B.op_process) A
                    WHERE A.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO
                      AND A.OP_PROCESS = '5'),
                   0) FPD5,
               
               (select COUNT(1)
                  from (select B.JUDGE_STOVE_NO,
                               TRIM(B.OP_PROCESS) OP_PROCESS,
                               B.m_mat_no,
                               SUM(B.ACT_THEORY_WEIGHT) ACT_THEORY_WEIGHT
                          from PORT_MIL_BATCH_SAMPLE_RESULT B
                         WHERE B.IS_VALID = '1'
                           AND B.STATUS = '1'
                         group by B.JUDGE_STOVE_NO, B.m_mat_no, B.op_process) A
                 WHERE A.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO
                   AND A.OP_PROCESS = '6') FPZ6,
               
               NVL((select SUM(A.ACT_THEORY_WEIGHT)
                     from (select B.JUDGE_STOVE_NO,
                                  TRIM(B.OP_PROCESS) OP_PROCESS,
                                  B.m_mat_no,
                                  SUM(B.ACT_THEORY_WEIGHT) ACT_THEORY_WEIGHT
                             from PORT_MIL_BATCH_SAMPLE_RESULT B
                            WHERE B.IS_VALID = '1'
                              AND B.STATUS = '1'
                            group by B.JUDGE_STOVE_NO,
                                     B.m_mat_no,
                                     B.op_process) A
                    WHERE A.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO
                      AND A.OP_PROCESS = '6'),
                   0) FPD6,
               
               (SELECT sum(A.act_count)
                  FROM PORT_MIL_BATCH_SAMPLE_RESULT A
                 WHERE A.IS_VALID = '1'
                   AND A.STATUS <> '1'
                                   AND (TRIM(A.OP_PROCESS) <> '7' OR
                                       A.OP_PROCESS IS NULL)
                   AND SUBSTR(A.JUDGE_STOVE_NO, -2) = '01'
                   AND A.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO) HGZ7,
               
               (SELECT SUM(A.ACT_THEORY_WEIGHT)
                  FROM PORT_MIL_BATCH_SAMPLE_RESULT A
                 WHERE A.IS_VALID = '1'
                   AND A.STATUS <> '1'
                                   AND (TRIM(A.OP_PROCESS) <> '7' OR
                                       A.OP_PROCESS IS NULL)
                   AND SUBSTR(A.JUDGE_STOVE_NO, -2) = '01'
                   AND A.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO) HGD7,
               
               NVL((select sum(A.act_count)
                     from PORT_MIL_BATCH_SAMPLE_RESULT A
                    WHERE A.IS_VALID = '1'
                      AND A.STATUS = '2'
                      AND TRIM(A.OP_PROCESS) = '7'
                      AND A.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO),
                   0) FPZ7,
               
               NVL((select SUM(A.ACT_THEORY_WEIGHT)
                     from PORT_MIL_BATCH_SAMPLE_RESULT A
                    WHERE A.IS_VALID = '1'
                      AND A.STATUS = '2'
                      AND TRIM(A.OP_PROCESS) = '7'
                      AND A.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO),
                   0) FPD7,
               
               NVL((select sum(1)
                     from PORT_MIL_BATCH_SAMPLE_RESULT A
                    WHERE A.IS_VALID = '1'
                      AND A.STATUS = '2'
                      AND TRIM(A.OP_PROCESS) = '9'
                      AND A.PLAN_ID = T.RESULT_NO
                      AND REGEXP_REPLACE(A.JUDGE_STOVE_NO, '-.*', '') =
                          REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '')),
                   0) FPZ9,
               
               NVL((select sum(A.act_count)
                     from PORT_MIL_BATCH_SAMPLE_RESULT A
                    WHERE A.IS_VALID = '1'
                      AND A.STATUS = '2'
                      AND TRIM(A.OP_PROCESS) = '9'
                      AND A.PLAN_ID = T.RESULT_NO
                      AND REGEXP_REPLACE(A.JUDGE_STOVE_NO, '-.*', '') =
                          REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '')),
                   0) FPD9,
               
               NVL((select sum(A.act_count)
                     from PORT_MIL_BATCH_SAMPLE_RESULT A
                    WHERE A.IS_VALID = '1'
                      AND A.STATUS = '3'
                      AND TRIM(A.OP_PROCESS) = '9'
                      AND A.PLAN_ID = T.RESULT_NO
                      AND REGEXP_REPLACE(A.JUDGE_STOVE_NO, '-.*', '') =
                          REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '')),
                   0) XXZ9,
               
               NVL((select SUM(A.ACT_THEORY_WEIGHT)
                     from PORT_MIL_BATCH_SAMPLE_RESULT A
                    WHERE A.IS_VALID = '1'
                      AND A.STATUS = '3'
                      AND TRIM(A.OP_PROCESS) = '9'
                      AND A.PLAN_ID = T.RESULT_NO
                      AND REGEXP_REPLACE(A.JUDGE_STOVE_NO, '-.*', '') =
                          REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '')),
                   0) XXD9,
               
               NVL((select sum(A.act_count)
                     from PORT_MIL_BATCH_SAMPLE_RESULT A
                    WHERE A.IS_VALID = '1'
                      AND A.STATUS IN ('2', '5')
                      AND TRIM(A.OP_PROCESS) = '10'
                      AND A.PLAN_ID = T.RESULT_NO
                      AND REGEXP_REPLACE(A.JUDGE_STOVE_NO, '-.*', '') =
                          REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '')),
                   0) FPZ10,
               
               NVL((select SUM(A.ACT_THEORY_WEIGHT)
                     from PORT_MIL_BATCH_SAMPLE_RESULT A
                    WHERE A.IS_VALID = '1'
                      AND A.STATUS IN ('2', '5')
                      AND TRIM(A.OP_PROCESS) = '10'
                      AND A.PLAN_ID = T.RESULT_NO
                      AND REGEXP_REPLACE(A.JUDGE_STOVE_NO, '-.*', '') =
                          REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '')),
                   0) FPD10,
               
               NVL((select sum(A.act_count)
                     from PORT_MIL_BATCH_SAMPLE_RESULT A
                    WHERE A.IS_VALID = '1'
                      AND A.STATUS = '3'
                      AND TRIM(A.OP_PROCESS) = '10'
                      AND A.PLAN_ID = T.RESULT_NO
                      AND REGEXP_REPLACE(A.JUDGE_STOVE_NO, '-.*', '') =
                          REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '')),
                   0) XXZ10,
               
               NVL((select SUM(A.ACT_THEORY_WEIGHT)
                     from PORT_MIL_BATCH_SAMPLE_RESULT A
                    WHERE A.IS_VALID = '1'
                      AND A.STATUS = '3'
                      AND TRIM(A.OP_PROCESS) = '10'
                      AND A.PLAN_ID = T.RESULT_NO
                      AND REGEXP_REPLACE(A.JUDGE_STOVE_NO, '-.*', '') =
                          REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '')),
                   0) XXD10,
               
               NVL((select sum(A.act_count)
                     from PORT_MIL_BATCH_SAMPLE_RESULT A
                    WHERE A.IS_VALID = '1'
                      AND A.STATUS = '2'
                      AND TRIM(A.OP_PROCESS) = '11'
                      AND A.PLAN_ID = T.RESULT_NO
                      AND REGEXP_REPLACE(A.JUDGE_STOVE_NO, '-.*', '') =
                          REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '')),
                   0) FPZ11,
               
               NVL((select SUM(A.ACT_THEORY_WEIGHT)
                     from PORT_MIL_BATCH_SAMPLE_RESULT A
                    WHERE A.IS_VALID = '1'
                      AND A.STATUS = '2'
                      AND TRIM(A.OP_PROCESS) = '11'
                      AND A.PLAN_ID = T.RESULT_NO
                      AND REGEXP_REPLACE(A.JUDGE_STOVE_NO, '-.*', '') =
                          REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '')),
                   0) FPD11,
               
               NVL((select sum(A.act_count)
                     from PORT_MIL_BATCH_SAMPLE_RESULT A
                    WHERE A.IS_VALID = '1'
                      AND A.STATUS = '3'
                      AND TRIM(A.OP_PROCESS) = '11'
                      AND A.PLAN_ID = T.RESULT_NO
                      AND REGEXP_REPLACE(A.JUDGE_STOVE_NO, '-.*', '') =
                          REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '')),
                   0) XXZ11,
               
               NVL((select SUM(A.ACT_THEORY_WEIGHT)
                     from PORT_MIL_BATCH_SAMPLE_RESULT A
                    WHERE A.IS_VALID = '1'
                      AND A.STATUS = '3'
                      AND TRIM(A.OP_PROCESS) = '11'
                      AND A.PLAN_ID = T.RESULT_NO
                      AND REGEXP_REPLACE(A.JUDGE_STOVE_NO, '-.*', '') =
                          REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '')),
                   0) XXD11,
               
               NVL((select sum(1)
                     from PORT_MIL_BATCH_SAMPLE_RESULT A
                    WHERE A.IS_VALID = '1'
                      AND A.GROUP_FLAG = '1'
                      AND TRIM(A.OP_PROCESS) = '9'
                      AND A.PLAN_ID = T.RESULT_NO
                      AND REGEXP_REPLACE(A.JUDGE_STOVE_NO, '-.*', '') =
                          REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '')),
                   0) ZLZ9,
               
               NVL((select sum(A.ACT_THEORY_WEIGHT)
                     from PORT_MIL_BATCH_SAMPLE_RESULT A
                    WHERE A.IS_VALID = '1'
                      AND A.GROUP_FLAG = '1'
                      AND TRIM(A.OP_PROCESS) = '9'
                      AND A.PLAN_ID = T.RESULT_NO
                      AND REGEXP_REPLACE(A.JUDGE_STOVE_NO, '-.*', '') =
                          REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '')),
                   0) ZLD9,
               
               NVL((select sum(1)
                     from PORT_MIL_BATCH_SAMPLE_RESULT A
                    WHERE A.IS_VALID = '1'
                      AND A.GROUP_FLAG = '1'
                      AND TRIM(A.OP_PROCESS) = '10'
                      AND A.PLAN_ID = T.RESULT_NO
                      AND REGEXP_REPLACE(A.JUDGE_STOVE_NO, '-.*', '') =
                          REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '')),
                   0) ZLZ10,
               
               NVL((select sum(A.ACT_THEORY_WEIGHT)
                     from PORT_MIL_BATCH_SAMPLE_RESULT A
                    WHERE A.IS_VALID = '1'
                      AND A.GROUP_FLAG = '1'
                      AND TRIM(A.OP_PROCESS) = '10'
                      AND A.PLAN_ID = T.RESULT_NO
                      AND REGEXP_REPLACE(A.JUDGE_STOVE_NO, '-.*', '') =
                          REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '')),
                   0) ZLD10,
               
               NVL((select sum(1)
                     from PORT_MIL_BATCH_SAMPLE_RESULT A
                    WHERE A.IS_VALID = '1'
                      AND A.GROUP_FLAG = '1'
                      AND TRIM(A.OP_PROCESS) = '11'
                      AND A.PLAN_ID = T.RESULT_NO
                      AND REGEXP_REPLACE(A.JUDGE_STOVE_NO, '-.*', '') =
                          REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '')),
                   0) ZLZ11,
               
               NVL((select sum(A.ACT_THEORY_WEIGHT)
                     from PORT_MIL_BATCH_SAMPLE_RESULT A
                    WHERE A.IS_VALID = '1'
                      AND A.GROUP_FLAG = '1'
                      AND TRIM(A.OP_PROCESS) = '11'
                      AND A.PLAN_ID = T.RESULT_NO
                      AND REGEXP_REPLACE(A.JUDGE_STOVE_NO, '-.*', '') =
                          REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '')),
                   0) ZLD11,
               
               (SELECT DECODE(B.DIRECTOR_QUANTITY,
                              0,
                              '',
                              TO_CHAR(NVL(B.QUALIFIED_BRANCH, 0) * 100 /
                                      B.DIRECTOR_QUANTITY,
                                      'FM990.00') || '%')
                  FROM mil_surface_result B
                 WHERE B.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO) qualifiedRate,
               
               SUM(B.FEED_NUM_PLAN) SLZ,
               SUM(B.MAT_TOTAL_HEIGHT - B.FEED_NUM * DECODE(B.CUT_TARGET,
                                               '返废',
                                               NVL(round(B.CUT_WEIGHT, 3), 0),
                                               
                                               0)) SLD,
               SUM(B.FEED_NUM_PLAN * B.DB_NUM) * MAX(T1.SAW_NUM) YJZ,
               
               NVL((select sum(A.act_count)
                     from PORT_MIL_BATCH_SAMPLE_RESULT A
                    WHERE A.IS_VALID = '1'
                      AND A.STATUS = '1'
                      AND A.PLAN_ID = T.RESULT_NO
                      AND REGEXP_REPLACE(A.JUDGE_STOVE_NO, '-.*', '') =
                          REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '')),
                   0) undeterminedNum,
               
               NVL((select sum(A.INPUT_WEIGHT)
                     from PORT_MIL_BATCH_SAMPLE_RESULT A
                    WHERE A.IS_VALID = '1'
                      AND A.STATUS = '1'
                      AND A.PLAN_ID = T.RESULT_NO
                      AND REGEXP_REPLACE(A.JUDGE_STOVE_NO, '-.*', '') =
                          REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '')),
                   0) undeterminedD,
               
               NVL((select sum(A.act_count)
                     from PORT_MIL_BATCH_SAMPLE_RESULT A
                    WHERE A.IS_VALID = '1'
                      AND A.STATUS IN ('2', '5')
                      AND A.OP_PROCESS <> '14'
                      AND A.PLAN_ID = T.RESULT_NO
                      AND REGEXP_REPLACE(A.JUDGE_STOVE_NO, '-.*', '') =
                          REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '')),
                   0) ScrapNum,
               
               NVL((select sum(A.ACT_THEORY_WEIGHT)
                     from PORT_MIL_BATCH_SAMPLE_RESULT A
                    WHERE A.IS_VALID = '1'
                      AND A.STATUS IN ('2', '5')
                      AND A.OP_PROCESS <> '14'
                      AND A.PLAN_ID = T.RESULT_NO
                      AND REGEXP_REPLACE(A.JUDGE_STOVE_NO, '-.*', '') =
                          REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '')),
                   0) ScrapD,
               
               NVL((select sum(A.act_count)
                     from PORT_MIL_BATCH_SAMPLE_RESULT A
                    WHERE A.IS_VALID = '1'
                      AND A.STATUS = '2'
                      AND A.OP_PROCESS = '14'
                      AND A.PLAN_ID = T.RESULT_NO
                      AND REGEXP_REPLACE(A.JUDGE_STOVE_NO, '-.*', '') =
                          REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '')),
                   0) FQY,
               
               NVL((select sum(A.act_count)
                     from PORT_MIL_BATCH_SAMPLE_RESULT A
                    WHERE A.IS_VALID = '1'
                      AND A.STATUS = '6'
                      AND A.PLAN_ID = T.RESULT_NO
                      AND REGEXP_REPLACE(A.JUDGE_STOVE_NO, '-.*', '') =
                          REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '')),
                   0) WWFPZ,
               
               NVL((SELECT NVL(SUM(T12.QUALIFIED_NUM), 0)
                     FROM MIL_INSTORE_RESULT T12
                    WHERE T12.RESULT_NO = T.RESULT_NO
                      AND REGEXP_REPLACE(T12.JUDGE_STOVE_NO, '-.*', '') =
                          REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '')
                      AND T12.NODE_FUR_FLAG = '1'),
                   0) XXZ,
               
               NVL((SELECT NVL(SUM(T12.QUALIFIED_TONS), 0)
                     FROM MIL_INSTORE_RESULT T12
                    WHERE T12.RESULT_NO = T.RESULT_NO
                      AND REGEXP_REPLACE(T12.JUDGE_STOVE_NO, '-.*', '') =
                          REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '')
                      AND T12.NODE_FUR_FLAG = '1'),
                   0) XXD,
               
               NVL((SELECT NVL(SUM(T12.QUALIFIED_NUM), 0)
                     FROM MIL_INSTORE_RESULT T12
                    WHERE T12.RESULT_NO = T.RESULT_NO
                      AND REGEXP_REPLACE(T12.JUDGE_STOVE_NO, '-.*', '') =
                          REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '')),
                   0) HGZ12,
               
               NVL((SELECT NVL(SUM(T12.QUALIFIED_TONS), 0)
                     FROM MIL_INSTORE_RESULT T12
                    WHERE T12.RESULT_NO = T.RESULT_NO
                      AND REGEXP_REPLACE(T12.JUDGE_STOVE_NO, '-.*', '') =
                          REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '')),
                   0) HGD12,
               
               0 HGM12,
               
               NVL((select SUM(Q.ACT_COUNT)
                     from QCM_ZG_JUGDE_APPLY Q
                    WHERE Q.VALIDFLAG = '20'
                      AND Q.APPLY_FLAG = '0'
                      AND Q.PROCESS_CODE = 'D'
                      AND Q.JUDGE_STOVE_NO =
                          REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '')),
                   0) PDZ,
               
               NVL((select DECODE(NVL(SUM(Q.ACT_WEIGHT), 0),
                                 0,
                                 SUM(Q.ACT_THEORY_WEIGHT),
                                 SUM(Q.ACT_WEIGHT))
                     from QCM_ZG_JUGDE_APPLY Q
                    WHERE Q.VALIDFLAG = '20'
                      AND Q.APPLY_FLAG = '0'
                      AND Q.PROCESS_CODE = 'D'
                      AND Q.JUDGE_STOVE_NO =
                          REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '')),
                   0) PDD,
               
               NVL((select SUM(Q.ACT_LEN)
                     from QCM_ZG_JUGDE_APPLY Q
                    WHERE 1 = 1
                      AND Q.VALIDFLAG = '20'
                      AND Q.APPLY_FLAG = '0'
                      AND Q.PROCESS_CODE = 'D'
                      AND Q.JUDGE_STOVE_NO =
                          REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '')),
                   0) PDM,
               
               NVL((select SUM(Q.ACT_COUNT)
                     from QCM_ZG_JUGDE_APPLY Q
                    WHERE Q.APPLY_FLAG = '0'
                      AND Q.PROCESS_CODE = 'D'
                      AND Q.JUDGE_STOVE_NO =
                          REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '')),
                   0) SPZ,
               
               NVL((select DECODE(NVL(SUM(Q.ACT_WEIGHT), 0),
                                 0,
                                 SUM(Q.ACT_THEORY_WEIGHT),
                                 SUM(Q.ACT_WEIGHT))
                     from QCM_ZG_JUGDE_APPLY Q
                    WHERE Q.APPLY_FLAG = '0'
                      AND Q.PROCESS_CODE = 'D'
                      AND Q.JUDGE_STOVE_NO =
                          REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '')),
                   0) SPD,
               
               NVL((select SUM(Q.ACT_LEN)
                     from QCM_ZG_JUGDE_APPLY Q
                    WHERE Q.APPLY_FLAG = '0'
                      AND Q.PROCESS_CODE = 'D'
                      AND Q.JUDGE_STOVE_NO =
                          REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '')),
                   0) SPM,
               
               (NVL((select sum(A.act_count)
                      from PORT_MIL_BATCH_SAMPLE_RESULT A
                     WHERE A.IS_VALID = '1'
                       AND A.STATUS IN ('3', '4')
                       AND A.OP_PROCESS <> '12'
                       AND A.PLAN_ID = T.RESULT_NO
                       AND REGEXP_REPLACE(A.JUDGE_STOVE_NO, '-.*', '') =
                           REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '')),
                    0) +
               NVL((SELECT NVL(SUM(T12.OFFLINE_NUM), 0)
                      FROM MIL_INSTORE_RESULT T12
                     WHERE T12.RESULT_NO = T.RESULT_NO
                       AND REGEXP_REPLACE(T12.JUDGE_STOVE_NO, '-.*', '') =
                           REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '')),
                    0)) LXZ,
               
               NVL((select sum(A.act_count)
                     from PORT_MIL_BATCH_SAMPLE_RESULT A
                    WHERE A.IS_VALID = '1'
                      AND A.STATUS = '4'
                      AND A.GROUP_FLAG = '0'
                      AND A.PLAN_ID = T.RESULT_NO
                      AND REGEXP_REPLACE(A.JUDGE_STOVE_NO, '-.*', '') =
                          REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '')),
                   0) - NVL((select sum(A.act_count)
                     from PORT_MIL_BATCH_SAMPLE_RESULT A
                    WHERE A.IS_VALID = '1'
                      AND A.STATUS = '6'
                      AND A.PLAN_ID = T.RESULT_NO
                      AND REGEXP_REPLACE(A.JUDGE_STOVE_NO, '-.*', '') =
                          REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '')),
                   0) FXZ,
               
               NVL((select sum(A.act_count)
                     from PORT_MIL_BATCH_SAMPLE_RESULT A
                    WHERE A.IS_VALID = '1'
                      AND A.GROUP_FLAG = '1'
                      AND TRIM(A.OP_PROCESS) > 6
                      AND A.PLAN_ID = T.RESULT_NO
                      AND REGEXP_REPLACE(A.JUDGE_STOVE_NO, '-.*', '') =
                          REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '')),
                   0) ZLZ,
               
               NVL((select sum(A.ACT_THEORY_WEIGHT)
                     from PORT_MIL_BATCH_SAMPLE_RESULT A
                    WHERE A.IS_VALID = '1'
                      AND A.GROUP_FLAG = '1'
                      AND TRIM(A.OP_PROCESS) > 6
                      AND A.PLAN_ID = T.RESULT_NO
                      AND REGEXP_REPLACE(A.JUDGE_STOVE_NO, '-.*', '') =
                          REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '')),
                   0) ZLD,
               
               (select MAX(A.BAL_YEAR_MONTH)
                  from PORT_MIL_BATCH_SAMPLE_RESULT A
                 WHERE A.PLAN_ID = T.RESULT_NO) BAL_YEAR_MONTH,
               
               TO_CHAR(NVL((select SUM(A.ACT_THEORY_WEIGHT)
                             from PORT_MIL_BATCH_SAMPLE_RESULT A
                            WHERE A.IS_VALID = '1'
                              AND A.STATUS <> '2'
                              AND A.STATUS <> '3'
                              AND A.STATUS <> '6'
                              AND A.JUDGE_STOVE_NO = T1.JUDGE_STOVE_NO),
                           0) / SUM(B.MAT_TOTAL_HEIGHT) * 100,
                       'FM990.00') || '%' RATE,
               
               SUM(B.MAT_TOTAL_HEIGHT) *
               (1 - NVL((select R.BURNNING_RATE
                           from MIL_FUR_RESULT R
                          WHERE R.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO) / 100,
                        0)) -
               DECODE(MAX(T1.CONTROL_THICKP),
                      0,
                      0,
                      (MAX(T1.CUT_HEAD_LENGTHP) + MAX(T1.CUT_TRAIL_LENGTHP)) / 1000 *
                      (0.02466 * MAX(T1.CONTROL_THICKP) / 1000 * 1.02 *
                      ((SUBSTR(MAX(T1.PIPE_SIZE),
                                1,
                                INSTR(MAX(T1.PIPE_SIZE), '*') - 1)) * (CASE
                        WHEN INSTR(MAX(T1.VARIETIES), '套管') > 0 THEN
                         1.005
                        WHEN INSTR(MAX(T1.VARIETIES), '油管') > 0 THEN
                         1.005
                        ELSE
                         1
                      END) - (MAX(T1.CONTROL_THICKP) / 1000 * 1.02)) *
                      SUM(B.FEED_NUM_PLAN * B.DB_NUM))) YJD,
               
               TO_CHAR(NVL((SELECT CASE
                                    WHEN SUM(M.ponder_gross_wt) > 0 THEN
                                     SUM(M.ponder_gross_wt)
                                    ELSE
                                     SUM(M.ACT_WEIGHT)
                                  END
                             FROM MAT_BC_M M
                            WHERE M.JUDGE_STOVE_NO =
                                  REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '')
                              AND M.LOT_NO = T1.LOT_NO
                              AND M.PLINE_CODE = T.PLINE_CODE),
                           0) * 100 / SUM(B.MAT_TOTAL_HEIGHT),
                       'FM990.00') || '%' RATE2
        
          from MIL_FEEDSAW_RESULT T, MIL_PLAN T1
          --LEFT JOIN SLM_ORDER_HEAD H
            --ON T1.CONTRACT_NO LIKE H.ORDER_NO || '%'
          LEFT JOIN PLN_ZY_ZG_M M
            ON M.HEAT_PLAN_NO = T1.ID, MIL_FEED_PLAN B
         WHERE T.JUDGE_STOVE_NO = T1.JUDGE_STOVE_NO
           AND T.JUDGE_STOVE_NO = B.JUDGE_STOVE_NO
           AND T1.BACK_SLAB_FLAG <> '2'
           AND T1.PRO_PLAN_ID = B.PRO_PLAN_ID 
           #something#
         GROUP BY T1.JUDGE_STOVE_NO,
                  T1.LOT_NO,
                  T.PLINE_CODE,
                  T.JUDGE_STOVE_NO,
                  T.RESULT_NO,
                  T1.PRO_PLAN_ID,
                  t1.gx_plan_no,
                  T1.ID,
                  T1.CONTRACT_NO) AA
 ORDER BY AA.START_TIME ASC
]]>
</query>

<query id = "FrmMilDateStatistics.getMilDateStatisticsBatchSampleNew" desc = "统计静态进程表">
 SELECT T.ID,
       T.JUDGE_STOVE_NO,
       T.LOT_NO,
       T.PRO_PLAN_ID,
       T.GX_PLAN_NO,
       (SELECT A.PLINE_NAME
          FROM COM_BASE_PLINE A
         WHERE A.PLINE_CODE = T.PLINE_CODE) PLINE_CODE,
       T.TARGET,
       T.VARIETIES,
       T.VARIETIES_CODE,
       T.STEELCODE,
       T.STEELNAME,
       T.GRADECODE,
       T.GRADENAME,
       T.PIPE_SIZE,
       T.PIPE_SIZE_CODE,
       T.BUCKLE_TYPE,
       T.BUCKLE_TYPE_CODE,
       TO_CHAR(T.FEED_TIME, 'YYYY-MM-DD HH24:MI:SS') FEED_TIME,
       T.SLZ,
       T.SLD,
       T.YJZ,
       T.YJD,
       T.UNDETERMINEDNUM,
       T.UNDETERMINEDD,
       T.SCRAPNUM,
       T.SCRAPD,
       T.WWFPZ,
       T.FQY,
       T.LXZ,
       T.FXZ,
       T.ZLZ,
       T.ZLD,
       T.ZZL,
       T.ZZZ,
       T.SPZ,
       T.SPD,
       T.SPM,
       T.PDZ,
       T.PDD,
       T.PDM,
       T.HGZ1,
       T.HGD1,
       T.FPZ1,
       T.FPD1,
       T.HGZ2,
       T.HGD2,
       T.FPZ2,
       T.FPD2,
       T.HGZ3,
       T.HGD3,
       T.FPZ3,
       T.FPD3,
       T.HGZ4,
       T.HGD4,
       T.FPZ4,
       T.FPD4,
       T.HGZ5,
       T.HGD5,
       T.FPZ5,
       T.FPD5,
       T.HGZ6,
       T.HGD6,
       T.FPZ6,
       T.FPD6,
       T.HGZ7,
       T.HGD7,
       T.FPZ7,
       T.FPD7,
       T.HGZ9,
       T.HGD9,
       T.FPZ9,
       T.FPD9,
       T.HGZ10,
       T.HGD10,
       T.FPZ10,
       T.FPD10,
       T.HGZ11,
       T.HGD11,
       T.FPZ11,
       T.FPD11,
       T.HGZ12,
       T.HGD12,
       T.RATE,
       T.QUALIFIEDRATE,
       T.RATE2,
       T.ZLC,
       DECODE(T.ISCLOSE, '0', '未关闭', '1', '已关闭') ISCLOSE,
       T.CONTRACT_NO,
       (SELECT MAX(H.ORDER_TYP_DESC)
          FROM SLM_ORDER_HEAD H
         WHERE H.ORDER_NO =
               SUBSTR(T.CONTRACT_NO, 1, INSTR(T.CONTRACT_NO, '/') - 1)) ORDER_TYP_DESC,
       M.PASS_NAME,
       (SELECT MAX(FINISH_USER)
          FROM MIL_PLAN T1
         WHERE T1.ID = T.ID
           AND REGEXP_REPLACE(T1.JUDGE_STOVE_NO, '-.*', '') =
               T.JUDGE_STOVE_NO) FINISH_USER,
       T.BAL_YEAR_MONTH,
       T.NODE_STATUS1
  FROM MIL_PROCESSES T
  LEFT JOIN PLN_ZY_ZG_M M
    ON M.HEAT_PLAN_NO = T.ID
 WHERE 1 = 1
</query>
<query id = "FrmMilDateStatistics.getMilPlanProcessData" desc = "统计进程表中剔管数据">
<![CDATA[
 SELECT AA.*,
       CASE AA.NODE_STATUS
         WHEN '10' THEN
          '锯切完成'
         WHEN '20' THEN
          '出炉'
         WHEN '30' THEN
          '穿孔完成'
         WHEN '40' THEN
          '连轧完成'
         WHEN '50' THEN
          '出再加热炉'
         WHEN '60' THEN
          '出定径'
         WHEN '70' THEN
          '分切完成'
         WHEN '80' THEN
          '矫直完成'
         WHEN '90' THEN
          '探伤完成'
         WHEN '96' THEN
          '质检完成'
         WHEN '99' THEN
          '下线'
       END NODE_STATUS1,
       CASE
         WHEN AA.NODE_STATUS < 20 THEN
          0
         ELSE
          AA.HGZ1 - AA.FPZ2
       END HGZ2,
       CASE
         WHEN AA.NODE_STATUS < 20 THEN
          0
         ELSE
          AA.HGD1 - AA.FPD2
       END HGD2,
       
       CASE
         WHEN AA.NODE_STATUS < 30 THEN
          0
         ELSE
          AA.HGZ1 - AA.FPZ2 - AA.FPZ3
       END HGZ3,
       CASE
         WHEN AA.NODE_STATUS < 30 THEN
          0
         ELSE
          AA.HGD1 - AA.FPD2 - AA.FPD3
       END HGD3,
       
       CASE
         WHEN AA.NODE_STATUS < 40 THEN
          0
         ELSE
          AA.HGZ1 - AA.FPZ2 - AA.FPZ3 - AA.FPZ4
       END HGZ4,
       CASE
         WHEN AA.NODE_STATUS < 40 THEN
          0
         ELSE
          AA.HGD1 - AA.FPD2 - AA.FPD3 - AA.FPD4
       END HGD4,
       
       CASE
         WHEN AA.NODE_STATUS < 50 THEN
          0
         ELSE
          AA.HGZ1 - AA.FPZ2 - AA.FPZ3 - AA.FPZ4 - AA.FPZ5
       END HGZ5,
       CASE
         WHEN AA.NODE_STATUS < 50 THEN
          0
         ELSE
          AA.HGD1 - AA.FPD2 - AA.FPD3 - AA.FPD4 - AA.FPD5
       END HGD5,
       
       CASE
         WHEN AA.NODE_STATUS < 60 THEN
          0
         ELSE
          AA.HGZ1 - AA.FPZ2 - AA.FPZ3 - AA.FPZ4 - AA.FPZ5 - AA.FPZ6
       END HGZ6,
       CASE
         WHEN AA.NODE_STATUS < 60 THEN
          0
         ELSE
          AA.HGD1 - AA.FPD2 - AA.FPD3 - AA.FPD4 - AA.FPD5 - AA.FPD6
       END HGD6,
       
       CASE
         WHEN AA.NODE_STATUS < 80 THEN
          0
         ELSE
          AA.HGZ7 - AA.FPZ9 - AA.XXZ9 - AA.ZLZ9
       END HGZ9,
       CASE
         WHEN AA.NODE_STATUS < 80 THEN
          0
         ELSE
          AA.HGD7 - AA.FPD9 - AA.XXD9 - AA.ZLD9
       END HGD9,
       
       CASE
         WHEN AA.NODE_STATUS < 90 THEN
          0
         ELSE
          AA.HGZ7 - AA.FPZ9 - AA.XXZ9 - AA.FPZ10 - AA.XXZ10 - AA.ZLZ10
       END HGZ10,
       CASE
         WHEN AA.NODE_STATUS < 90 THEN
          0
         ELSE
          AA.HGD7 - AA.FPD9 - AA.XXD9 - AA.FPD10 - AA.XXD10 - AA.ZLD10
       END HGD10,
       
       CASE
         WHEN AA.NODE_STATUS < 96 THEN
          0
         ELSE
          AA.HGZ7 - AA.FPZ9 - AA.XXZ9 - AA.FPZ10 - AA.XXZ10 - AA.FPZ11 -
          AA.XXZ11 - AA.ZLZ11
       END HGZ11,
       CASE
         WHEN AA.NODE_STATUS < 96 THEN
          0
         ELSE
          AA.HGD7 - AA.FPD9 - AA.XXD9 - AA.FPD10 - AA.XXD10 - AA.FPD11 -
          AA.XXD11 - AA.ZLD11
       END HGD11

  FROM (select REGEXP_REPLACE(T1.JUDGE_STOVE_NO, '-.*', '') JUDGE_STOVE_NO,
               T1.LOT_NO,
               T.PLINE_CODE,
               (SELECT A.PLINE_NAME
                  FROM COM_BASE_PLINE A
                 WHERE A.PLINE_CODE = T.PLINE_CODE) PLINE_CODE1,
               T1.CONTRACT_NO,
               MAX(T1.VARIETIES) VARIETIES,
               MAX(T1.STEELNAME) STEELNAME,
               MAX(T1.GRADENAME) GRADENAME,
               REPLACE(MAX(T1.PIPE_SIZE), '*', 'x') PIPE_SIZE,
               MAX(T1.BUCKLE_TYPE) BUCKLE_TYPE,
               MAX(T1.LENGTH_RANGE) LENGTH_RANGE,
               MAX(T1.ROLL_STANDRAD) ROLL_STANDRAD,
               MIN(T.START_TIME) START_TIME,
               --MAX(T1.NODE_STATUS) NODE_STATUS,
               MAX(T1.TARGET) TARGET,
               
               (SELECT MAX(NODE_STATUS) FROM MIL_PLAN WHERE ID = T1.ID) NODE_STATUS,
               
               (SELECT count(1)
                  from (SELECT B.JUDGE_STOVE_NO,
                               B.m_mat_no,
                               SUM(B.ACT_THEORY_WEIGHT) ACT_THEORY_WEIGHT
                          FROM PORT_MIL_BATCH_SAMPLE_RESULT B
                         WHERE B.IS_VALID = '1'
                           AND (TRIM(B.Op_Process) != '0' OR
                               B.Op_Process IS NULL)
                         group by B.m_mat_no, B.JUDGE_STOVE_NO) A
                 WHERE A.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO
                 GROUP BY A.JUDGE_STOVE_NO) HGZ1,
               
               (SELECT SUM(A.ACT_THEORY_WEIGHT)
                  from (SELECT B.JUDGE_STOVE_NO,
                               B.m_mat_no,
                               SUM(B.ACT_THEORY_WEIGHT) ACT_THEORY_WEIGHT
                          FROM PORT_MIL_BATCH_SAMPLE_RESULT B
                         WHERE B.IS_VALID = '1'
                           AND (TRIM(B.Op_Process) != '0' OR
                               B.Op_Process IS NULL)
                         group by B.m_mat_no, B.JUDGE_STOVE_NO) A
                 WHERE A.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO
                 GROUP BY A.JUDGE_STOVE_NO) HGD1,
               
               (select COUNT(1)
                  from (select B.JUDGE_STOVE_NO,
                               TRIM(B.OP_PROCESS) OP_PROCESS,
                               B.m_mat_no,
                               SUM(B.ACT_THEORY_WEIGHT) ACT_THEORY_WEIGHT
                          from PORT_MIL_BATCH_SAMPLE_RESULT B
                         WHERE B.IS_VALID = '1'
                           AND B.STATUS = '1'
                         group by B.JUDGE_STOVE_NO, B.m_mat_no, B.op_process) A
                 WHERE A.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO
                   AND A.OP_PROCESS = '0') FPZ1,
               
               NVL((select SUM(A.ACT_THEORY_WEIGHT)
                     from (select B.JUDGE_STOVE_NO,
                                  TRIM(B.OP_PROCESS) OP_PROCESS,
                                  B.m_mat_no,
                                  SUM(B.ACT_THEORY_WEIGHT) ACT_THEORY_WEIGHT
                             from PORT_MIL_BATCH_SAMPLE_RESULT B
                            WHERE B.IS_VALID = '1'
                              AND B.STATUS = '1'
                            group by B.JUDGE_STOVE_NO,
                                     B.m_mat_no,
                                     B.op_process) A
                    WHERE A.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO
                      AND A.OP_PROCESS = '0'),
                   0) FPD1,
               
               (select COUNT(1)
                  from (select B.JUDGE_STOVE_NO,
                               TRIM(B.OP_PROCESS) OP_PROCESS,
                               B.m_mat_no,
                               SUM(B.ACT_THEORY_WEIGHT) ACT_THEORY_WEIGHT
                          from PORT_MIL_BATCH_SAMPLE_RESULT B
                         WHERE B.IS_VALID = '1'
                           AND B.STATUS = '1'
                         group by B.JUDGE_STOVE_NO, B.m_mat_no, B.op_process) A
                 WHERE A.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO
                   AND A.OP_PROCESS = '2') FPZ2,
               
               NVL((select SUM(A.ACT_THEORY_WEIGHT)
                     from (select B.JUDGE_STOVE_NO,
                                  TRIM(B.OP_PROCESS) OP_PROCESS,
                                  B.m_mat_no,
                                  SUM(B.ACT_THEORY_WEIGHT) ACT_THEORY_WEIGHT
                             from PORT_MIL_BATCH_SAMPLE_RESULT B
                            WHERE B.IS_VALID = '1'
                              AND B.STATUS = '1'
                            group by B.JUDGE_STOVE_NO,
                                     B.m_mat_no,
                                     B.op_process) A
                    WHERE A.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO
                      AND A.OP_PROCESS = '2'),
                   0) FPD2,
               
               (select COUNT(1)
                  from (select B.JUDGE_STOVE_NO,
                               TRIM(B.OP_PROCESS) OP_PROCESS,
                               B.m_mat_no,
                               SUM(B.ACT_THEORY_WEIGHT) ACT_THEORY_WEIGHT
                          from PORT_MIL_BATCH_SAMPLE_RESULT B
                         WHERE B.IS_VALID = '1'
                           AND B.STATUS = '1'
                         group by B.JUDGE_STOVE_NO, B.m_mat_no, B.op_process) A
                 WHERE A.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO
                   AND A.OP_PROCESS = '3') FPZ3,
               
               NVL((select SUM(A.ACT_THEORY_WEIGHT)
                     from (select B.JUDGE_STOVE_NO,
                                  TRIM(B.OP_PROCESS) OP_PROCESS,
                                  B.m_mat_no,
                                  SUM(B.ACT_THEORY_WEIGHT) ACT_THEORY_WEIGHT
                             from PORT_MIL_BATCH_SAMPLE_RESULT B
                            WHERE B.IS_VALID = '1'
                              AND B.STATUS = '1'
                            group by B.JUDGE_STOVE_NO,
                                     B.m_mat_no,
                                     B.op_process) A
                    WHERE A.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO
                      AND A.OP_PROCESS = '3'),
                   0) FPD3,
               
               (select COUNT(1)
                  from (select B.JUDGE_STOVE_NO,
                               TRIM(B.OP_PROCESS) OP_PROCESS,
                               B.m_mat_no,
                               SUM(B.ACT_THEORY_WEIGHT) ACT_THEORY_WEIGHT
                          from PORT_MIL_BATCH_SAMPLE_RESULT B
                         WHERE B.IS_VALID = '1'
                           AND B.STATUS = '1'
                         group by B.JUDGE_STOVE_NO, B.m_mat_no, B.op_process) A
                 WHERE A.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO
                   AND A.OP_PROCESS = '4') FPZ4,
               
               NVL((select SUM(A.ACT_THEORY_WEIGHT)
                     from (select B.JUDGE_STOVE_NO,
                                  TRIM(B.OP_PROCESS) OP_PROCESS,
                                  B.m_mat_no,
                                  SUM(B.ACT_THEORY_WEIGHT) ACT_THEORY_WEIGHT
                             from PORT_MIL_BATCH_SAMPLE_RESULT B
                            WHERE B.IS_VALID = '1'
                              AND B.STATUS = '1'
                            group by B.JUDGE_STOVE_NO,
                                     B.m_mat_no,
                                     B.op_process) A
                    WHERE A.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO
                      AND A.OP_PROCESS = '4'),
                   0) FPD4,
               
               (select COUNT(1)
                  from (select B.JUDGE_STOVE_NO,
                               TRIM(B.OP_PROCESS) OP_PROCESS,
                               B.m_mat_no,
                               SUM(B.ACT_THEORY_WEIGHT) ACT_THEORY_WEIGHT
                          from PORT_MIL_BATCH_SAMPLE_RESULT B
                         WHERE 1 = 1
                           AND B.IS_VALID = '1'
                           AND B.STATUS = '1'
                         group by B.JUDGE_STOVE_NO, B.m_mat_no, B.op_process) A
                 WHERE A.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO
                   AND A.OP_PROCESS = '5') FPZ5,
               
               NVL((select SUM(A.ACT_THEORY_WEIGHT)
                     from (select B.JUDGE_STOVE_NO,
                                  TRIM(B.OP_PROCESS) OP_PROCESS,
                                  B.m_mat_no,
                                  SUM(B.ACT_THEORY_WEIGHT) ACT_THEORY_WEIGHT
                             from PORT_MIL_BATCH_SAMPLE_RESULT B
                            WHERE B.IS_VALID = '1'
                              AND B.STATUS = '1'
                            group by B.JUDGE_STOVE_NO,
                                     B.m_mat_no,
                                     B.op_process) A
                    WHERE A.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO
                      AND A.OP_PROCESS = '5'),
                   0) FPD5,
               
               (select COUNT(1)
                  from (select B.JUDGE_STOVE_NO,
                               TRIM(B.OP_PROCESS) OP_PROCESS,
                               B.m_mat_no,
                               SUM(B.ACT_THEORY_WEIGHT) ACT_THEORY_WEIGHT
                          from PORT_MIL_BATCH_SAMPLE_RESULT B
                         WHERE B.IS_VALID = '1'
                           AND B.STATUS = '1'
                         group by B.JUDGE_STOVE_NO, B.m_mat_no, B.op_process) A
                 WHERE A.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO
                   AND A.OP_PROCESS = '6') FPZ6,
               
               NVL((select SUM(A.ACT_THEORY_WEIGHT)
                     from (select B.JUDGE_STOVE_NO,
                                  TRIM(B.OP_PROCESS) OP_PROCESS,
                                  B.m_mat_no,
                                  SUM(B.ACT_THEORY_WEIGHT) ACT_THEORY_WEIGHT
                             from PORT_MIL_BATCH_SAMPLE_RESULT B
                            WHERE B.IS_VALID = '1'
                              AND B.STATUS = '1'
                            group by B.JUDGE_STOVE_NO,
                                     B.m_mat_no,
                                     B.op_process) A
                    WHERE A.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO
                      AND A.OP_PROCESS = '6'),
                   0) FPD6,
               
               (SELECT sum(A.act_count)
                  FROM PORT_MIL_BATCH_SAMPLE_RESULT A
                 WHERE A.IS_VALID = '1'
                   AND A.STATUS <> '1'
                                   AND (TRIM(A.OP_PROCESS) <> '7' OR
                                       A.OP_PROCESS IS NULL)
                   AND SUBSTR(A.JUDGE_STOVE_NO, -2) = '01'
                   AND A.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO) HGZ7,
               
               (SELECT SUM(A.ACT_THEORY_WEIGHT)
                  FROM PORT_MIL_BATCH_SAMPLE_RESULT A
                 WHERE A.IS_VALID = '1'
                   AND A.STATUS <> '1'
                                   AND (TRIM(A.OP_PROCESS) <> '7' OR
                                       A.OP_PROCESS IS NULL)
                   AND SUBSTR(A.JUDGE_STOVE_NO, -2) = '01'
                   AND A.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO) HGD7,
               
               NVL((select sum(A.act_count)
                     from PORT_MIL_BATCH_SAMPLE_RESULT A
                    WHERE A.IS_VALID = '1'
                      AND A.STATUS = '2'
                      AND TRIM(A.OP_PROCESS) = '7'
                      AND A.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO),
                   0) FPZ7,
               
               NVL((select SUM(A.ACT_THEORY_WEIGHT)
                     from PORT_MIL_BATCH_SAMPLE_RESULT A
                    WHERE A.IS_VALID = '1'
                      AND A.STATUS = '2'
                      AND TRIM(A.OP_PROCESS) = '7'
                      AND A.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO),
                   0) FPD7,
               
               NVL((select sum(1)
                     from PORT_MIL_BATCH_SAMPLE_RESULT A
                    WHERE A.IS_VALID = '1'
                      AND A.STATUS = '2'
                      AND TRIM(A.OP_PROCESS) = '9'
                      AND A.PLAN_ID = T.RESULT_NO
                      AND REGEXP_REPLACE(A.JUDGE_STOVE_NO, '-.*', '') =
                          REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '')),
                   0) FPZ9,
               
               NVL((select sum(A.act_count)
                     from PORT_MIL_BATCH_SAMPLE_RESULT A
                    WHERE A.IS_VALID = '1'
                      AND A.STATUS = '2'
                      AND TRIM(A.OP_PROCESS) = '9'
                      AND A.PLAN_ID = T.RESULT_NO
                      AND REGEXP_REPLACE(A.JUDGE_STOVE_NO, '-.*', '') =
                          REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '')),
                   0) FPD9,
               
               NVL((select sum(A.act_count)
                     from PORT_MIL_BATCH_SAMPLE_RESULT A
                    WHERE A.IS_VALID = '1'
                      AND A.STATUS = '3'
                      AND TRIM(A.OP_PROCESS) = '9'
                      AND A.PLAN_ID = T.RESULT_NO
                      AND REGEXP_REPLACE(A.JUDGE_STOVE_NO, '-.*', '') =
                          REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '')),
                   0) XXZ9,
               
               NVL((select SUM(A.ACT_THEORY_WEIGHT)
                     from PORT_MIL_BATCH_SAMPLE_RESULT A
                    WHERE A.IS_VALID = '1'
                      AND A.STATUS = '3'
                      AND TRIM(A.OP_PROCESS) = '9'
                      AND A.PLAN_ID = T.RESULT_NO
                      AND REGEXP_REPLACE(A.JUDGE_STOVE_NO, '-.*', '') =
                          REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '')),
                   0) XXD9,
               
               NVL((select sum(A.act_count)
                     from PORT_MIL_BATCH_SAMPLE_RESULT A
                    WHERE A.IS_VALID = '1'
                      AND A.STATUS IN ('2', '5')
                      AND TRIM(A.OP_PROCESS) = '10'
                      AND A.PLAN_ID = T.RESULT_NO
                      AND REGEXP_REPLACE(A.JUDGE_STOVE_NO, '-.*', '') =
                          REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '')),
                   0) FPZ10,
               
               NVL((select SUM(A.ACT_THEORY_WEIGHT)
                     from PORT_MIL_BATCH_SAMPLE_RESULT A
                    WHERE A.IS_VALID = '1'
                      AND A.STATUS IN ('2', '5')
                      AND TRIM(A.OP_PROCESS) = '10'
                      AND A.PLAN_ID = T.RESULT_NO
                      AND REGEXP_REPLACE(A.JUDGE_STOVE_NO, '-.*', '') =
                          REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '')),
                   0) FPD10,
               
               NVL((select sum(A.act_count)
                     from PORT_MIL_BATCH_SAMPLE_RESULT A
                    WHERE A.IS_VALID = '1'
                      AND A.STATUS = '3'
                      AND TRIM(A.OP_PROCESS) = '10'
                      AND A.PLAN_ID = T.RESULT_NO
                      AND REGEXP_REPLACE(A.JUDGE_STOVE_NO, '-.*', '') =
                          REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '')),
                   0) XXZ10,
               
               NVL((select SUM(A.ACT_THEORY_WEIGHT)
                     from PORT_MIL_BATCH_SAMPLE_RESULT A
                    WHERE A.IS_VALID = '1'
                      AND A.STATUS = '3'
                      AND TRIM(A.OP_PROCESS) = '10'
                      AND A.PLAN_ID = T.RESULT_NO
                      AND REGEXP_REPLACE(A.JUDGE_STOVE_NO, '-.*', '') =
                          REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '')),
                   0) XXD10,
               
               NVL((select sum(A.act_count)
                     from PORT_MIL_BATCH_SAMPLE_RESULT A
                    WHERE A.IS_VALID = '1'
                      AND A.STATUS = '2'
                      AND TRIM(A.OP_PROCESS) = '11'
                      AND A.PLAN_ID = T.RESULT_NO
                      AND REGEXP_REPLACE(A.JUDGE_STOVE_NO, '-.*', '') =
                          REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '')),
                   0) FPZ11,
               
               NVL((select SUM(A.ACT_THEORY_WEIGHT)
                     from PORT_MIL_BATCH_SAMPLE_RESULT A
                    WHERE A.IS_VALID = '1'
                      AND A.STATUS = '2'
                      AND TRIM(A.OP_PROCESS) = '11'
                      AND A.PLAN_ID = T.RESULT_NO
                      AND REGEXP_REPLACE(A.JUDGE_STOVE_NO, '-.*', '') =
                          REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '')),
                   0) FPD11,
               
               NVL((select sum(A.act_count)
                     from PORT_MIL_BATCH_SAMPLE_RESULT A
                    WHERE A.IS_VALID = '1'
                      AND A.STATUS = '3'
                      AND TRIM(A.OP_PROCESS) = '11'
                      AND A.PLAN_ID = T.RESULT_NO
                      AND REGEXP_REPLACE(A.JUDGE_STOVE_NO, '-.*', '') =
                          REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '')),
                   0) XXZ11,
               
               NVL((select SUM(A.ACT_THEORY_WEIGHT)
                     from PORT_MIL_BATCH_SAMPLE_RESULT A
                    WHERE A.IS_VALID = '1'
                      AND A.STATUS = '3'
                      AND TRIM(A.OP_PROCESS) = '11'
                      AND A.PLAN_ID = T.RESULT_NO
                      AND REGEXP_REPLACE(A.JUDGE_STOVE_NO, '-.*', '') =
                          REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '')),
                   0) XXD11,
               
               NVL((select sum(1)
                     from PORT_MIL_BATCH_SAMPLE_RESULT A
                    WHERE A.IS_VALID = '1'
                      AND A.GROUP_FLAG = '1'
                      AND TRIM(A.OP_PROCESS) = '9'
                      AND A.PLAN_ID = T.RESULT_NO
                      AND REGEXP_REPLACE(A.JUDGE_STOVE_NO, '-.*', '') =
                          REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '')),
                   0) ZLZ9,
               
               NVL((select sum(A.ACT_THEORY_WEIGHT)
                     from PORT_MIL_BATCH_SAMPLE_RESULT A
                    WHERE A.IS_VALID = '1'
                      AND A.GROUP_FLAG = '1'
                      AND TRIM(A.OP_PROCESS) = '9'
                      AND A.PLAN_ID = T.RESULT_NO
                      AND REGEXP_REPLACE(A.JUDGE_STOVE_NO, '-.*', '') =
                          REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '')),
                   0) ZLD9,
               
               NVL((select sum(1)
                     from PORT_MIL_BATCH_SAMPLE_RESULT A
                    WHERE A.IS_VALID = '1'
                      AND A.GROUP_FLAG = '1'
                      AND TRIM(A.OP_PROCESS) = '10'
                      AND A.PLAN_ID = T.RESULT_NO
                      AND REGEXP_REPLACE(A.JUDGE_STOVE_NO, '-.*', '') =
                          REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '')),
                   0) ZLZ10,
               
               NVL((select sum(A.ACT_THEORY_WEIGHT)
                     from PORT_MIL_BATCH_SAMPLE_RESULT A
                    WHERE A.IS_VALID = '1'
                      AND A.GROUP_FLAG = '1'
                      AND TRIM(A.OP_PROCESS) = '10'
                      AND A.PLAN_ID = T.RESULT_NO
                      AND REGEXP_REPLACE(A.JUDGE_STOVE_NO, '-.*', '') =
                          REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '')),
                   0) ZLD10,
               
               NVL((select sum(1)
                     from PORT_MIL_BATCH_SAMPLE_RESULT A
                    WHERE A.IS_VALID = '1'
                      AND A.GROUP_FLAG = '1'
                      AND TRIM(A.OP_PROCESS) = '11'
                      AND A.PLAN_ID = T.RESULT_NO
                      AND REGEXP_REPLACE(A.JUDGE_STOVE_NO, '-.*', '') =
                          REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '')),
                   0) ZLZ11,
               
               NVL((select sum(A.ACT_THEORY_WEIGHT)
                     from PORT_MIL_BATCH_SAMPLE_RESULT A
                    WHERE A.IS_VALID = '1'
                      AND A.GROUP_FLAG = '1'
                      AND TRIM(A.OP_PROCESS) = '11'
                      AND A.PLAN_ID = T.RESULT_NO
                      AND REGEXP_REPLACE(A.JUDGE_STOVE_NO, '-.*', '') =
                          REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '')),
                   0) ZLD11,
               
               (SELECT DECODE(B.DIRECTOR_QUANTITY,
                              0,
                              '',
                              TO_CHAR(NVL(B.QUALIFIED_BRANCH, 0) * 100 /
                                      B.DIRECTOR_QUANTITY,
                                      'FM990.00') || '%')
                  FROM mil_surface_result B
                 WHERE B.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO) qualifiedRate,
               
               SUM(B.FEED_NUM_PLAN) SLZ,
               SUM(B.MAT_TOTAL_HEIGHT - B.FEED_NUM * DECODE(B.CUT_TARGET,
                                       '返废',
                                       NVL(round(B.CUT_WEIGHT , 3), 0),
                                       
                                       0)) SLD,
               SUM(B.FEED_NUM_PLAN * B.DB_NUM) * MAX(T1.SAW_NUM) YJZ,
               
               NVL((select sum(A.act_count)
                     from PORT_MIL_BATCH_SAMPLE_RESULT A
                    WHERE A.IS_VALID = '1'
                      AND A.STATUS = '1'
                      AND A.PLAN_ID = T.RESULT_NO
                      AND REGEXP_REPLACE(A.JUDGE_STOVE_NO, '-.*', '') =
                          REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '')),
                   0) undeterminedNum,
               
               NVL((select sum(A.INPUT_WEIGHT)
                     from PORT_MIL_BATCH_SAMPLE_RESULT A
                    WHERE A.IS_VALID = '1'
                      AND A.STATUS = '1'
                      AND A.PLAN_ID = T.RESULT_NO
                      AND REGEXP_REPLACE(A.JUDGE_STOVE_NO, '-.*', '') =
                          REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '')),
                   0) undeterminedD,
               
               NVL((select sum(A.act_count)
                     from PORT_MIL_BATCH_SAMPLE_RESULT A
                    WHERE A.IS_VALID = '1'
                      AND A.STATUS IN ('2', '5')
                      AND A.OP_PROCESS <> '14'
                      AND A.PLAN_ID = T.RESULT_NO
                      AND REGEXP_REPLACE(A.JUDGE_STOVE_NO, '-.*', '') =
                          REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '')),
                   0) ScrapNum,
               
               NVL((select sum(A.ACT_THEORY_WEIGHT)
                     from PORT_MIL_BATCH_SAMPLE_RESULT A
                    WHERE A.IS_VALID = '1'
                      AND A.STATUS IN ('2', '5')
                      AND A.OP_PROCESS <> '14'
                      AND A.PLAN_ID = T.RESULT_NO
                      AND REGEXP_REPLACE(A.JUDGE_STOVE_NO, '-.*', '') =
                          REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '')),
                   0) ScrapD,
               
               NVL((select sum(A.act_count)
                     from PORT_MIL_BATCH_SAMPLE_RESULT A
                    WHERE A.IS_VALID = '1'
                      AND A.STATUS = '2'
                      AND A.OP_PROCESS = '14'
                      AND A.PLAN_ID = T.RESULT_NO
                      AND REGEXP_REPLACE(A.JUDGE_STOVE_NO, '-.*', '') =
                          REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '')),
                   0) FQY,
               
               NVL((select sum(A.act_count)
                     from PORT_MIL_BATCH_SAMPLE_RESULT A
                    WHERE A.IS_VALID = '1'
                      AND A.STATUS = '6'
                      AND A.PLAN_ID = T.RESULT_NO
                      AND REGEXP_REPLACE(A.JUDGE_STOVE_NO, '-.*', '') =
                          REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '')),
                   0) WWFPZ,
               
               NVL((SELECT NVL(SUM(T12.QUALIFIED_NUM), 0)
                     FROM MIL_INSTORE_RESULT T12
                    WHERE T12.RESULT_NO = T.RESULT_NO
                      AND REGEXP_REPLACE(T12.JUDGE_STOVE_NO, '-.*', '') =
                          REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '')
                      AND T12.NODE_FUR_FLAG = '1'),
                   0) XXZ,
               
               NVL((SELECT NVL(SUM(T12.QUALIFIED_TONS), 0)
                     FROM MIL_INSTORE_RESULT T12
                    WHERE T12.RESULT_NO = T.RESULT_NO
                      AND REGEXP_REPLACE(T12.JUDGE_STOVE_NO, '-.*', '') =
                          REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '')
                      AND T12.NODE_FUR_FLAG = '1'),
                   0) XXD,
               
               NVL((SELECT NVL(SUM(T12.QUALIFIED_NUM), 0)
                     FROM MIL_INSTORE_RESULT T12
                    WHERE T12.RESULT_NO = T.RESULT_NO
                      AND REGEXP_REPLACE(T12.JUDGE_STOVE_NO, '-.*', '') =
                          REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '')),
                   0) HGZ12,
               
               NVL((SELECT NVL(SUM(T12.QUALIFIED_TONS), 0)
                     FROM MIL_INSTORE_RESULT T12
                    WHERE T12.RESULT_NO = T.RESULT_NO
                      AND REGEXP_REPLACE(T12.JUDGE_STOVE_NO, '-.*', '') =
                          REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '')),
                   0) HGD12,
               
               0 HGM12,
               
               NVL((select SUM(Q.ACT_COUNT)
                     from QCM_ZG_JUGDE_APPLY Q
                    WHERE Q.VALIDFLAG = '20'
                      AND Q.APPLY_FLAG = '0'
                      AND Q.JUDGE_STOVE_NO = REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '')),
                   0) PDZ,
               
               NVL((select DECODE(NVL(SUM(Q.ACT_WEIGHT), 0),
                                 0,
                                 SUM(Q.ACT_THEORY_WEIGHT),
                                 SUM(Q.ACT_WEIGHT))
                     from QCM_ZG_JUGDE_APPLY Q
                    WHERE Q.VALIDFLAG = '20'
                      AND Q.APPLY_FLAG = '0'
                      AND Q.JUDGE_STOVE_NO = REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '')),
                   0) PDD,
               
               NVL((select SUM(Q.ACT_LEN)
                     from QCM_ZG_JUGDE_APPLY Q
                    WHERE 1 = 1
                      AND Q.VALIDFLAG = '20'
                      AND Q.APPLY_FLAG = '0'
                      AND Q.JUDGE_STOVE_NO = REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '')),
                   0) PDM,
               
               NVL((select SUM(Q.ACT_COUNT)
                     from QCM_ZG_JUGDE_APPLY Q
                    WHERE Q.APPLY_FLAG = '0'
                      AND Q.JUDGE_STOVE_NO = REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '')),
                   0) SPZ,
               
               NVL((select DECODE(NVL(SUM(Q.ACT_WEIGHT), 0),
                                 0,
                                 SUM(Q.ACT_THEORY_WEIGHT),
                                 SUM(Q.ACT_WEIGHT))
                     from QCM_ZG_JUGDE_APPLY Q
                    WHERE Q.APPLY_FLAG = '0'
                      AND Q.JUDGE_STOVE_NO = REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '')),
                   0) SPD,
               
               NVL((select SUM(Q.ACT_LEN)
                     from QCM_ZG_JUGDE_APPLY Q
                    WHERE Q.APPLY_FLAG = '0'
                      AND Q.JUDGE_STOVE_NO = REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '')),
                   0) SPM,
               
               (NVL((select sum(A.act_count)
                      from PORT_MIL_BATCH_SAMPLE_RESULT A
                     WHERE A.IS_VALID = '1'
                       AND A.STATUS IN ('3', '4')
                       AND A.OP_PROCESS <> '12'
                       AND A.PLAN_ID = T.RESULT_NO),
                    0) + NVL((SELECT NVL(SUM(T12.OFFLINE_NUM), 0)
                                FROM MIL_INSTORE_RESULT T12
                               WHERE T12.RESULT_NO = T.RESULT_NO
                                 AND REGEXP_REPLACE(T12.JUDGE_STOVE_NO, '-.*', '') =
                                     REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '')),
                              0)) LXZ,
               
               NVL((select sum(A.act_count)
                     from PORT_MIL_BATCH_SAMPLE_RESULT A
                    WHERE A.IS_VALID = '1'
                      AND A.STATUS = '4'
                      AND A.GROUP_FLAG = '0'
                      AND A.PLAN_ID = T.RESULT_NO),
                   0) FXZ,
               
               NVL((select sum(A.act_count)
                     from PORT_MIL_BATCH_SAMPLE_RESULT A
                    WHERE A.IS_VALID = '1'
                      AND A.GROUP_FLAG = '1'
                      AND TRIM(A.OP_PROCESS) <> '5'
                      AND A.PLAN_ID = T.RESULT_NO),
                   0) ZLZ,
               
               NVL((select sum(A.ACT_THEORY_WEIGHT)
                     from PORT_MIL_BATCH_SAMPLE_RESULT A
                    WHERE A.IS_VALID = '1'
                      AND A.GROUP_FLAG = '1'
                      AND TRIM(A.OP_PROCESS) <> '5'
                      AND A.PLAN_ID = T.RESULT_NO),
                   0) ZLD,
               
               (select MAX(A.BAL_YEAR_MONTH)
                  from PORT_MIL_BATCH_SAMPLE_RESULT A
                 WHERE A.PLAN_ID = T.RESULT_NO) BAL_YEAR_MONTH,
               
               TO_CHAR(NVL((select SUM(A.ACT_THEORY_WEIGHT)
                             from PORT_MIL_BATCH_SAMPLE_RESULT A
                            WHERE A.IS_VALID = '1'
                              AND A.STATUS NOT IN( '2', '3', '6')
                              AND A.JUDGE_STOVE_NO = T1.JUDGE_STOVE_NO),
                           0) / SUM(B.MAT_TOTAL_HEIGHT) * 100,
                       'FM990.00') || '%' RATE,
               
               SUM(B.MAT_TOTAL_HEIGHT) *
               (1 - NVL((select R.BURNNING_RATE
                           from MIL_FUR_RESULT R
                          WHERE R.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO) / 100,
                        0)) -
               DECODE(MAX(T1.CONTROL_THICKP),
                      0,
                      0,
                      (MAX(T1.CUT_HEAD_LENGTHP) + MAX(T1.CUT_TRAIL_LENGTHP)) / 1000 *
                      (0.02466 * MAX(T1.CONTROL_THICKP) / 1000 * 1.02 *
                      ((SUBSTR(MAX(T1.PIPE_SIZE),
                                1,
                                INSTR(MAX(T1.PIPE_SIZE), '*') - 1)) * (CASE
                        WHEN INSTR(MAX(T1.VARIETIES), '套管') > 0 THEN
                         1.005
                        WHEN INSTR(MAX(T1.VARIETIES), '油管') > 0 THEN
                         1.005
                        ELSE
                         1
                      END) - (MAX(T1.CONTROL_THICKP) / 1000 * 1.02)) *
                      SUM(B.FEED_NUM_PLAN * B.DB_NUM))) YJD,
               
               TO_CHAR(NVL((SELECT CASE
                                    WHEN SUM(M.ponder_gross_wt) > 0 THEN
                                     SUM(M.ponder_gross_wt)
                                    ELSE
                                     SUM(M.ACT_WEIGHT)
                                  END
                             FROM MAT_BC_M M
                            WHERE M.JUDGE_STOVE_NO =
                                  REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '')
                              AND M.LOT_NO = T1.LOT_NO
                              AND M.PLINE_CODE = T.PLINE_CODE),
                           0) * 100 / SUM(B.MAT_TOTAL_HEIGHT),
                       'FM990.00') || '%' RATE2
        
          from MIL_FEEDSAW_RESULT T, MIL_PLAN T1, MIL_FEED_PLAN B
         WHERE T.JUDGE_STOVE_NO = T1.JUDGE_STOVE_NO
           AND T.JUDGE_STOVE_NO = B.JUDGE_STOVE_NO 
           AND T1.BACK_SLAB_FLAG <> '2'
           AND NVL(T1.PRO_PLAN_ID,'/') = NVL('#PRO_PLAN_ID#','/')
           AND NVL(T1.GX_PLAN_NO,'/') = NVL('#GX_PLAN_NO#','/')
           AND REGEXP_REPLACE(T1.JUDGE_STOVE_NO, '-.*', '') = '#JUDGE_STOVE_NO#'
           AND T1.LOT_NO = '#LOT_NO#'
         GROUP BY T1.JUDGE_STOVE_NO,
                  T1.LOT_NO,
                  T.PLINE_CODE,
                  T.JUDGE_STOVE_NO,
                  T.RESULT_NO,
                  T1.PRO_PLAN_ID,
                  t1.gx_plan_no,
                  T1.ID,
                  T1.CONTRACT_NO) AA
 ORDER BY AA.START_TIME ASC

]]>
</query>

<query id = "FrmMilDateStatistics.getMilControlLog" desc = "调  度  统  计">
<![CDATA[
 select T.PROC_DATE PROC_DATE1,
       (SELECT B.PLINE_NAME
          FROM COM_BASE_PLINE B
         WHERE B.PLINE_CODE = T.PLINE_CODE) PLINE_CODE1,
       REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '') JUDGE_STOVE_NO1,
       DECODE(T.PRO_BC, 1, '早班', 2, '中班', 3, '夜班', 0, '常白班') PRO_BC1,
       DECODE(T.PRO_BZ, 1, '甲班', 2, '乙班', 3, '丙班', 4, '丁班') PRO_BZ1,
       T.VARIETIES ||
       DECODE(T.STEELNAME, NULL, '', '', '', ',' || T.STEELNAME) ||
       DECODE(T.PIPE_SIZE, NULL, '', '', '', ',' || T.PIPE_SIZE) ||
       DECODE(T.BUCKLE_TYPE, NULL, '', ' ', '', ',' || T.BUCKLE_TYPE) WL,
       ROUND(DECODE(T.LOGS_END,
                    NULL,
                    '',
                    TO_DATE(T.LOGS_END, 'YYYY-MM-DD HH24:MI') -
                    TO_DATE(T.LOGS_BEG, 'YYYY-MM-DD HH24:MI')) * 24 * 60) SJ,
       
       REPLACE(T.PIPE_SIZE, '*', 'x') PIPE_SIZE1,
       
       DECODE(ROUND(DECODE(T.LOGS_END,
                           NULL,
                           '',
                           TO_DATE(T.LOGS_END, 'YYYY-MM-DD HH24:MI') -
                           TO_DATE(T.LOGS_BEG, 'YYYY-MM-DD HH24:MI')) * 24 * 60),
              0,
              0,
              ROUND(T.QUALIFIED_NUM * 60 /
                    ROUND(DECODE(T.LOGS_END,
                                 NULL,
                                 '',
                                 TO_DATE(T.LOGS_END, 'YYYY-MM-DD HH24:MI') -
                                 TO_DATE(T.LOGS_BEG, 'YYYY-MM-DD HH24:MI')) * 24 * 60))) XSJZ,
       T2.HR_CAPCTY,
       
       T.*

  from MIL_CONTROL_LOG t,
       (SELECT DISTINCT A.INWL_ID,
                        A.INWL_DESC,
                        A.OUTWL_ID,
                        A.OUTWL_DESC,
                        A.PLINE_CODE,
                        A.PRO_PLAN_ID,
                        A.GX_PLAN_NO,
                        A.ORDER_NO || '/' || A.ORDER_SEQ CONTRACT_NO1,
                        D.HR_CAPCTY
          FROM PLN_ORDER_ZG_S A, SLM_BASE_MATERIAL_D_PL D
         WHERE A.INWL_ID = D.IN_MATERIAL_NO
           AND A.OUTWL_ID = D.OUT_MATERIAL_NO
           AND A.PLINE_CODE = D.PLINE_CODE) T2
 WHERE 1 = 1
   and t.PRO_TYPE = '1'
   and t.CONFIRM_FLAG = '1'
   AND T.CONTRACT_NO = T2.CONTRACT_NO1
   AND T.PRO_PLAN_ID = T2.PRO_PLAN_ID
   AND T.GX_PLAN_NO = T2.GX_PLAN_NO
   AND T.PLINE_CODE = T2.PLINE_CODE
]]>
</query>

<query id = "FrmMilDateStatistics.getMilControlLogStop" desc = "调度停机统计">
<![CDATA[
select control_id,
       to_char(to_date(logs_beg, 'yyyymmddhh24mi'), 'YYYY-MM-DD HH24:MI') logs_beg,
       to_char(to_date(logs_end, 'yyyymmddhh24mi'), 'YYYY-MM-DD HH24:MI') logs_end,
       (SELECT B.PLINE_NAME
          FROM COM_BASE_PLINE B
         WHERE B.PLINE_CODE = T.PLINE_CODE) pline_code,
         ROUND(DECODE(T.LOGS_END,
                    NULL,
                    '',
                    TO_DATE(T.LOGS_END, 'YYYY-MM-DD HH24:MI') -
                    TO_DATE(T.LOGS_BEG, 'YYYY-MM-DD HH24:MI')) * 24 * 60) SJ,
       stove_no,
       judge_stove_no,
       lot_no,
       contract_no,
       imp_process,
       producer,
       finish_user,
       target_liabrary,
       varieties,
       pipe_size,
       buckle_type,
       length_range,
       roll_standrad,
       pipe_section,
       steelcode,
       steelname,
       gradecode,
       gradename,
       steel_standrad,
       target,
       pro_bc,
       pro_bz,
       qualified_num,
       qualified_wt,
       scrap_num,
       scrap_wt,
       decode(pro_type, '1', '正常', '2', '停机') pro_type,
       (select c.basename from com_base_info c where c.basecode = stop_type) stop_type,
       (select c.basename
          from com_base_info c
         where c.basecode = stop_reason) stop_reason,
       (select c.basename from com_base_info c where c.basecode = stop_small) stop_small,
       user_date,
       user_name,
       user_id,
       
       confirm_time,
       confirm_name,
       decode(confirm_flag, '1', '确认', '0', '未确认') confirm_flag,
       memo,
       bal_year_month,
       proc_date,
       change_shift_flag,
       node_flag,
       pro_plan_id,
       gx_plan_no
  from mil_control_log t
 where t.PRO_TYPE = '2'
]]>
</query>

<query id = "FrmMilDateStatistics.getMilControlLog2" desc = "调  度  统  计(小时能力)">
<![CDATA[
 SELECT S.PLINE_CODE,
       S.PLINE_CODE1,
       S.INWL_ID,
       S.INWL_DESC,
       S.OUTWL_ID,
       S.OUTWL_DESC,
       SUM(S.QUALIFIED_NUM) QUALIFIED_NUM,
       SUM(S.QUALIFIED_WT) QUALIFIED_WT,
       SUM(S.SJ) SJ,
       DECODE(SUM(S.SJ),0,0,ROUND(SUM(S.QUALIFIED_NUM) * 60 / SUM(S.SJ))) XSJZ

  FROM (select T.PROC_DATE PROC_DATE1,
               (SELECT B.PLINE_NAME
                  FROM COM_BASE_PLINE B
                 WHERE B.PLINE_CODE = T.PLINE_CODE) PLINE_CODE1,
               REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '') JUDGE_STOVE_NO1,
               DECODE(T.PRO_BC, 1, '早班', 2, '中班', 3, '夜班', 0, '常白班') PRO_BC1,
               DECODE(T.PRO_BZ, 1, '甲班', 2, '乙班', 3, '丙班', 4, '丁班') PRO_BZ1,
               T.VARIETIES ||
               DECODE(T.STEELNAME, NULL, '', '', '', ',' || T.STEELNAME) ||
               DECODE(T.PIPE_SIZE, NULL, '', '', '', ',' || T.PIPE_SIZE) ||
               DECODE(T.BUCKLE_TYPE, NULL, '', ' ', '', ',' || T.BUCKLE_TYPE) WL,
               ROUND(DECODE(T.LOGS_END,
                            NULL,
                            '',
                            TO_DATE(T.LOGS_END, 'YYYY-MM-DD HH24:MI') -
                            TO_DATE(T.LOGS_BEG, 'YYYY-MM-DD HH24:MI')) * 24 * 60) SJ,
               
               REPLACE(T.PIPE_SIZE, '*', 'x') PIPE_SIZE1,
               
               T.*,
               T2.INWL_ID,
               T2.INWL_DESC,
               T2.OUTWL_ID,
               T2.OUTWL_DESC
        
          from MIL_CONTROL_LOG t,
               (SELECT DISTINCT A.INWL_ID,
                                A.INWL_DESC,
                                A.OUTWL_ID,
                                A.OUTWL_DESC,
                                A.PLINE_CODE,
                                A.ORDER_NO || '/' || A.ORDER_SEQ CONTRACT_NO1
                  FROM PLN_ORDER_ZG_S A) T2
         WHERE 1 = 1
           AND T.PRO_TYPE = '1'
           AND T.CONFIRM_FLAG = '1'
           AND T.CONTRACT_NO = T2.CONTRACT_NO1
           AND T.PLINE_CODE = T2.PLINE_CODE
           #something#) S
 GROUP BY S.PLINE_CODE,
          S.PLINE_CODE1,
          S.INWL_ID,
          S.INWL_DESC,
          S.OUTWL_ID,
          S.OUTWL_DESC
 ORDER BY S.PLINE_CODE, S.INWL_ID, S.OUTWL_ID

]]>
</query>

<query id = "FrmMilDateStatistics.getMilControlLog3" desc = "调  度  统  计(停机汇总)">
<![CDATA[
 select a.pline_name,
       to_char(to_date(t.proc_date, 'yyyy-mm-dd'), 'yyyy-mm-dd') proc_date,
       b.basename DowntimeBT,
       d.basename DowntimeST,
       c.basename DowntimeReasons,
       E.BASENAME Dept,
       decode(t.pro_bc, '1', '早', '2', '中', '3', '夜', '') pro_bc,
       decode(t.pro_bz, '1', '甲', '2', '乙', '3', '丙', '丁') pro_bz,
       
       to_date(t.logs_beg, 'yyyy-mm-dd hh24:mi:ss') logs_beg,
       to_date(t.logs_end, 'yyyy-mm-dd hh24:mi:ss') logs_end,
       ROUND(TO_NUMBER(to_date(t.logs_end, 'yyyy-mm-dd hh24:mi:ss') -
                       to_date(t.logs_beg, 'yyyy-mm-dd hh24:mi:ss')) * 24 * 60) Downtime,
       t.MEMO
  from mil_control_log t,
       com_base_pline  a,
       com_base_info   b,
       com_base_info   c,
       com_base_info   d,
       com_base_info   E
 where t.PRO_TYPE = '2'
--and t.bal_year_month > '201705'
 #something#
   and t.pline_code = a.pline_code(+)
   and t.stop_type = b.basecode(+)
   and t.stop_reason = c.basecode(+)
   and t.STOP_SMALL = d.basecode(+)
   and t.Dept = E.basecode(+)
 order by t.pline_code, t.bal_year_month, t.proc_date, t.logs_beg
]]>
</query>




<query id = "FrmMilDateStatistics.updateMilControlLog" desc = "回报小时能力">
<![CDATA[
DECLARE
  V_HR_CAPCTY SLM_BASE_MATERIAL_D_PL.HR_CAPCTY%type := ?;
  V_NUM       SLM_BASE_MATERIAL_D_PL.PLINE_LEVEL%type := ?;
BEGIN
  UPDATE SLM_BASE_MATERIAL_D_PL T
     SET T.HR_CAPCTY = DECODE(T.HR_CAPCTY,
                              '',
                              V_HR_CAPCTY,
                              '99.99',
                              V_HR_CAPCTY,
                              (5000 * T.HR_CAPCTY + V_NUM * V_HR_CAPCTY) /
                              (5000 + V_NUM))
   WHERE T.IN_MATERIAL_NO = ?
     AND T.OUT_MATERIAL_NO = ?
     AND T.PLINE_CODE = ?;
END;
]]>
</query>

<query id = "FrmMilDateStatistics.updateMilStaProductRate" desc = "回报成材率">
<![CDATA[
DECLARE
  V_PRD_RATE SLM_BASE_MATERIAL_D_PL.PRD_RATE%type := ?;
  V_NUM      SLM_BASE_MATERIAL_D_PL.HR_CAPCTY%type := ?;
BEGIN
  UPDATE #TABLE# T
     SET T.PRD_RATE = DECODE(T.PRD_RATE,
                             '',
                             V_PRD_RATE,
                             '81.11',
                             V_PRD_RATE,
                             (5000 * T.PRD_RATE + V_NUM * V_PRD_RATE) /
                             (5000 + V_NUM))
   WHERE T.IN_MATERIAL_NO = ?
     AND T.OUT_MATERIAL_NO = ?
     AND T.PLINE_CODE = ?;
END;
]]>
</query>

<query id = "FrmMilDateStatistics.getMilGodownData" desc = "入库单数据查询">
<![CDATA[
SELECT * FROM
（select T.JUDGE_STOVE_NO,
       T.LOT_NO,
       T.PLINE_CODE,
       T.PLINE_NAME,
       T.BAL_YEAR_MONTH,
       DECODE(T.JUGDE_APPLY_FLAG, '0', '未判定', '1', '已判定') JUGDE_APPLY_FLAG,
       T2.CONTRACT_NO,
       T2.TARGET_LIABRARY,
       T.GRADENAME,
       T.PRODUCNAME || DECODE(T.STEELNAME, NULL, '', ',' || T.STEELNAME) ||
       DECODE(T.SPEC_NAME, NULL, '', ',' || T.SPEC_NAME) ||
       DECODE(T.MODEL_DESC, NULL, '', ',' || T.MODEL_DESC) MATERIAL_NAME,
       (SELECT SUBSTR(L.STD_NAME, 1, 70) ||
               decode(L.USE_DESC, '/', '', '', '', ',' || L.USE_DESC)
          FROM SLM_ORDER_HEAD H, SLM_ORDER_LINE L
         WHERE H.ORD_PK = L.ORD_PK
           AND H.ORDER_NO =
               SUBSTR(T2.CONTRACT_NO, 1, INSTR(T2.CONTRACT_NO, '/') - 1)
           AND L.ORDER_SEQ =
               SUBSTR(T2.CONTRACT_NO, INSTR(T2.CONTRACT_NO, '/') + 1)
           AND H.VALIDFLAG = '1'
           AND L.VALIDFLAG = '1') STD_NAME,
       T2.IMP_PROCESS,
       T.MEMO,
       T.MAT_GOWHERE_CODE,
       T.MAT_GOWHERE_NAME,
       T.ACT_LEN,
       SUM(T.ACT_COUNT) ACT_COUNT,
       SUM(DECODE(T.PONDER_GROSS_WT,
                  NULL,
                  NVL(T.ACT_WEIGHT, 0),
                  NVL(T.PONDER_GROSS_WT, 0))) ACT_WEIGHT
  from MAT_BC_M t, MIL_PLAN T2, YDM_BC_INLIST T3
 WHERE T.HEAT_PLAN_NO = T2.ID(+)
   AND T.ZG_STOVE_SQE = T2.JUDGE_STOVE_NO(+)
   AND T2.BACK_SLAB_FLAG(+) <> '2'
   AND T.MAT_NO = T3.MAT_NO
   AND T.PLINE_CODE = T3.PLINE_CODE
   AND T.PROCESS_CDOE = 'D'
   AND T3.INSTOCK_TYPE_CODE = '800701'
   AND T.QCM_STAUS IN ('00', '10')
    #something#
 GROUP BY T.JUDGE_STOVE_NO,
          T.LOT_NO,
          T.PLINE_CODE,
          T.PLINE_NAME,
          T.JUGDE_APPLY_FLAG,
          T.BAL_YEAR_MONTH,
          T2.CONTRACT_NO,
          T2.TARGET_LIABRARY,
          T.GRADENAME,
          T.PRODUCNAME,
          T.STEELNAME,
          T.SPEC_NAME,
          T.MODEL_DESC,
          T.STD_NAME,
          T2.IMP_PROCESS,
          T.MEMO,
          T.MAT_GOWHERE_CODE,
          T.MAT_GOWHERE_NAME,
          T.ACT_LEN
 
 UNION ALL
 
 select T.JUDGE_STOVE_NO,
       T.LOT_NO,
       T.PLINE_CODE,
       T.PLINE_NAME,
       T.BAL_YEAR_MONTH,
       DECODE(T.JUGDE_APPLY_FLAG, '0', '未判定', '1', '已判定') JUGDE_APPLY_FLAG,
       T2.CONTRACT_NO,
       T2.TARGET_LIABRARY,
       T.GRADENAME,
       T.PRODUCNAME || DECODE(T.STEELNAME, NULL, '', ',' || T.STEELNAME) ||
       DECODE(T.SPEC_NAME, NULL, '', ',' || T.SPEC_NAME) ||
       DECODE(T.MODEL_DESC, NULL, '', ',' || T.MODEL_DESC) MATERIAL_NAME,
       (SELECT SUBSTR(L.STD_NAME, 1, 70) ||
               decode(L.USE_DESC, '/', '', '', '', ',' || L.USE_DESC)
          FROM SLM_ORDER_HEAD H, SLM_ORDER_LINE L
         WHERE H.ORD_PK = L.ORD_PK
           AND H.ORDER_NO =
               SUBSTR(T2.CONTRACT_NO, 1, INSTR(T2.CONTRACT_NO, '/') - 1)
           AND L.ORDER_SEQ =
               SUBSTR(T2.CONTRACT_NO, INSTR(T2.CONTRACT_NO, '/') + 1)
           AND H.VALIDFLAG = '1'
           AND L.VALIDFLAG = '1') STD_NAME,
       T2.IMP_PROCESS,
       T.MEMO,
       T.MAT_GOWHERE_CODE,
       T.MAT_GOWHERE_NAME,
       T.ACT_LEN,
       SUM(T.ACT_COUNT) ACT_COUNT,
       SUM(DECODE(T.PONDER_GROSS_WT,
                  NULL,
                  NVL(T.ACT_WEIGHT, 0),
                  NVL(T.PONDER_GROSS_WT, 0))) ACT_WEIGHT
  from MAT_BC_BACKUP t, MIL_PLAN T2, YDM_BC_INLIST T3
 WHERE T.HEAT_PLAN_NO = T2.ID(+)
   AND T.ZG_STOVE_SQE = T2.JUDGE_STOVE_NO(+)
   AND T2.BACK_SLAB_FLAG(+) <> '2'
   AND T.MAT_NO = T3.MAT_NO
   AND T.PLINE_CODE = T3.PLINE_CODE
   AND T.PROCESS_CDOE = 'D'
   AND T3.INSTOCK_TYPE_CODE = '800701'
   AND T.QCM_STAUS IN ('00', '10') 
   #something#
 GROUP BY T.JUDGE_STOVE_NO,
          T.LOT_NO,
          T.PLINE_CODE,
          T.PLINE_NAME,
          T.JUGDE_APPLY_FLAG,
          T.BAL_YEAR_MONTH,
          T2.CONTRACT_NO,
          T2.TARGET_LIABRARY,
          T.GRADENAME,
          T.PRODUCNAME,
          T.STEELNAME,
          T.SPEC_NAME,
          T.MODEL_DESC,
          T.STD_NAME,
          T2.IMP_PROCESS,
          T.MEMO,
          T.MAT_GOWHERE_CODE,
          T.MAT_GOWHERE_NAME,
          T.ACT_LEN）
 ORDER BY PLINE_CODE, JUDGE_STOVE_NO
]]>
</query>

<query id = "FrmMilDateStatistics.getOnlineInventory" desc = "在线品库存台账查询">
<![CDATA[
select REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '') JUDGE_STOVE_NO,
       T.LOT_NO,
       (SELECT C.PLINE_NAME
          FROM COM_BASE_PLINE C
         WHERE C.PLINE_CODE = T.PLINE_CODE) PLINE_CODE,
       
       NVL(SUM(T.ACT_COUNT), 0) ACT_COUNT,
       NVL(SUM(T.ACT_THEORY_WEIGHT),0) ACT_THEORY_WEIGHT,
       A.GRADENAME,
       A.PIPE_SECTION,
       A.FEED_TIME,
       A.VARIETIES,
       A.STEELNAME,
       A.PIPE_SIZE,
       A.BUCKLE_TYPE,
       CASE A.NODE_STATUS
         WHEN '10' THEN
          '锯切完成'
         WHEN '20' THEN
          '出炉'
         WHEN '30' THEN
          '穿孔完成'
         WHEN '40' THEN
          '连轧完成'
         WHEN '50' THEN
          '出再加热炉'
         WHEN '60' THEN
          '出定径'
         WHEN '70' THEN
          '分切完成'
         WHEN '80' THEN
          '矫直完成'
         WHEN '90' THEN
          '探伤完成'
         WHEN '96' THEN
          '质检完成'
         WHEN '99' THEN
          '下线'
       END NODE_STATUS,
       B.STUFF_PROPERTY
  from PORT_MIL_BATCH_SAMPLE_RESULT t,
       MIL_PLAN                     A,
       PLN_SALEORD_PROC             B
 WHERE 1 = 1
   AND T.STATUS != 3
   AND A.BACK_SLAB_FLAG <> '2'
   AND A.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO(+)
   AND A.ORD_LN_DLY_PK = B.ORD_LN_DLY_PK(+)
   AND A.NODE_STATUS < 99
   #JUDGE_STOVE_NO#
 GROUP BY REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', ''),
          T.LOT_NO,
          T.PLINE_CODE,
          A.GRADENAME,
          A.PIPE_SECTION,
          A.FEED_TIME,
          A.VARIETIES,
          A.STEELNAME,
          A.PIPE_SIZE,
          A.BUCKLE_TYPE,
          A.NODE_STATUS,
          B.STUFF_PROPERTY
 ORDER BY T.PLINE_CODE, A.FEED_TIME
]]>
</query>

<query id = "FrmMilDateStatistics.getInputOutputStatement" desc = "轧管投入产出报表 ">
<![CDATA[
select REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '') JUDGE_STOVE_NO,
       T.LOT_NO,
       (SELECT C.PLINE_NAME
          FROM COM_BASE_PLINE C
         WHERE C.PLINE_CODE = T.PLINE_CODE) PLINE_CODE,
       
       SUM(B.FEED_NUM_PLAN) SLZ,
       SUM(B.MAT_TOTAL_HEIGHT) SLD,
       SUM(B.FEED_NUM_PLAN * B.DB_NUM) * A.SAW_NUM YJZ,
       NVL(SUM(D.QUALIFIED_NUM), 0) QUALIFIED_NUM,
       NVL(SUM(D.QUALIFIED_TONS), 0) QUALIFIED_TONS,
       NVL(SUM(T.ACT_COUNT), 0) ACT_COUNT,
       NVL(SUM(T.ACT_THEORY_WEIGHT), 0) ACT_THEORY_WEIGHT,
       A.GRADENAME,
       A.PIPE_SECTION,
       A.FEED_TIME,
       A.VARIETIES,
       A.STEELNAME,
       A.PIPE_SIZE,
       A.BUCKLE_TYPE,
       E.STUFF_PROPERTY
  from (SELECT M.JUDGE_STOVE_NO,
               M.LOT_NO,
               M.PLAN_ID,
               M.PLINE_CODE,
               P.ACT_COUNT,
               P.ACT_THEORY_WEIGHT
          FROM PORT_MIL_BATCH_SAMPLE_RESULT M,
               (SELECT P.JUDGE_STOVE_NO,
                       SUM(P.ACT_COUNT) ACT_COUNT,
                       SUM(P.ACT_THEORY_WEIGHT) ACT_THEORY_WEIGHT
                  FROM PORT_MIL_BATCH_SAMPLE_RESULT P
                 WHERE 1 = 1
                   AND P.STATUS = 3
                 GROUP BY P.JUDGE_STOVE_NO) P
         WHERE 1 = 1
           AND M.JUDGE_STOVE_NO = P.JUDGE_STOVE_NO(+)
            #BAL_YEAR_MONTH#
         GROUP BY M.JUDGE_STOVE_NO,
                  M.LOT_NO,
                  M.PLAN_ID,
                  M.PLINE_CODE,
                  P.ACT_COUNT,
                  P.ACT_THEORY_WEIGHT) T,
       MIL_PLAN A,
       MIL_FEED_PLAN B,
       MIL_INSTORE_RESULT D,
       PLN_SALEORD_PROC E
 WHERE 1 = 1
 AND A.BACK_SLAB_FLAG <> '2'
   AND T.JUDGE_STOVE_NO = A.JUDGE_STOVE_NO(+)
   AND REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '') || '-01' = B.JUDGE_STOVE_NO 
   AND T.JUDGE_STOVE_NO = D.JUDGE_STOVE_NO(+)
   AND A.ORD_LN_DLY_PK = E.ORD_LN_DLY_PK(+)
   AND A.NODE_STATUS = 99
   AND D.NODE_FUR_FLAG(+) = 1

 GROUP BY REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', ''),
          T.LOT_NO,
          T.PLINE_CODE,
          A.GRADENAME,
          A.PIPE_SECTION,
          A.FEED_TIME,
          A.VARIETIES,
          A.STEELNAME,
          A.PIPE_SIZE,
          A.BUCKLE_TYPE,
          E.STUFF_PROPERTY,
          A.SAW_NUM
 ORDER BY T.PLINE_CODE, A.FEED_TIME
]]>
</query>

<query id = "FrmMilDateStatistics.getMilOfflineGroup" desc = "查询组炉数据">
<![CDATA[
SELECT DECODE(F.ZP_COUNT2 - F.FPZ - F.PDZ, 0, 'OK', '清线不齐') PH, F.*
  FROM (SELECT REGEXP_REPLACE(T1.ZP_JUDGE_STOVE_NO, '-.*', '') ZP_JUDGE_STOVE_NO,
               T1.ZP_LOT_NO,
               REGEXP_REPLACE(T1.ZP_M_LH, '-.*', '') ZP_M_LH,
               T1.ZP_COUNT,
               T1.MEMO,
               T1.ZL_TYPE,
               T2.SAW_NUM,
               T2.PLINE_CODE,
               T2.TOM,
               CASE T1.ZL_TYPE
                 WHEN '离线组炉(管子)' THEN
                  T1.ZP_COUNT
                 WHEN '荒管组炉(单倍坯)' THEN
                  T1.ZP_COUNT * T2.SAW_NUM
                 WHEN '回炉坯组炉(单倍坯)' THEN
                  T1.ZP_COUNT * T2.SAW_NUM
               END ZP_COUNT2,
               
               (SELECT C.PLINE_NAME
                  FROM COM_BASE_PLINE C
                 WHERE C.PLINE_CODE = T2.PLINE_CODE) PLINE_NAME,
               CASE T2.NODE_STATUS
                 WHEN '10' THEN
                  '锯切完成'
                 WHEN '20' THEN
                  '出炉'
                 WHEN '30' THEN
                  '穿孔完成'
                 WHEN '40' THEN
                  '连轧完成'
                 WHEN '50' THEN
                  '出再加热炉'
                 WHEN '60' THEN
                  '出定径'
                 WHEN '70' THEN
                  '分切完成'
                 WHEN '80' THEN
                  '矫直完成'
                 WHEN '90' THEN
                  '探伤完成'
                 WHEN '96' THEN
                  '质检完成'
                 WHEN '99' THEN
                  '下线'
               END NODE_STATUS,
               
               NVL((select sum(A.act_count)
                     from PORT_MIL_BATCH_SAMPLE_RESULT A
                    WHERE 1 = 1
                      AND A.IS_VALID = '1'
                      AND A.STATUS IN ('1', '2', '5', '6')
                      AND A.PLAN_ID = T2.ID
                      AND REGEXP_REPLACE(A.JUDGE_STOVE_NO, '-.*', '') =
                          REGEXP_REPLACE(T1.ZP_JUDGE_STOVE_NO, '-.*', '')),
                   0) FPZ,
               
               NVL((select sum(A.ACT_THEORY_WEIGHT)
                     from PORT_MIL_BATCH_SAMPLE_RESULT A
                    WHERE 1 = 1
                      AND A.IS_VALID = '1'
                      AND A.STATUS IN ('1', '2', '5', '6')
                      AND A.PLAN_ID = T2.ID
                      AND REGEXP_REPLACE(A.JUDGE_STOVE_NO, '-.*', '') =
                          REGEXP_REPLACE(T1.ZP_JUDGE_STOVE_NO, '-.*', '')),
                   0) FPD,
               
               NVL((SELECT NVL(SUM(T12.QUALIFIED_NUM), 0)
                     FROM MIL_INSTORE_RESULT T12
                    WHERE 1 = 1
                      AND REGEXP_REPLACE(T12.JUDGE_STOVE_NO, '-.*', '') =
                          REGEXP_REPLACE(T1.ZP_JUDGE_STOVE_NO, '-.*', '')),
                   0) HGZ12,
               
               NVL((SELECT NVL(SUM(T12.QUALIFIED_TONS), 0)
                     FROM MIL_INSTORE_RESULT T12
                    WHERE 1 = 1
                      AND REGEXP_REPLACE(T12.JUDGE_STOVE_NO, '-.*', '') =
                          REGEXP_REPLACE(T1.ZP_JUDGE_STOVE_NO, '-.*', '')),
                   0) HGD12,
               
               NVL((select SUM(Q.ACT_COUNT)
                     from QCM_ZG_JUGDE_APPLY Q
                    WHERE 1 = 1
                      AND Q.VALIDFLAG = '20'
                      AND Q.APPLY_FLAG = '0'
                      AND Q.JUDGE_STOVE_NO =
                          REGEXP_REPLACE(T1.ZP_JUDGE_STOVE_NO, '-.*', '')),
                   0) PDZ,
               
               NVL((select DECODE(NVL(SUM(Q.ACT_WEIGHT), 0),
                                 0,
                                 SUM(Q.ACT_THEORY_WEIGHT),
                                 SUM(Q.ACT_WEIGHT))
                     from QCM_ZG_JUGDE_APPLY Q
                    WHERE 1 = 1
                      AND Q.VALIDFLAG = '20'
                      AND Q.APPLY_FLAG = '0'
                      AND Q.JUDGE_STOVE_NO =
                          REGEXP_REPLACE(T1.ZP_JUDGE_STOVE_NO, '-.*', '')),
                   0) PDD
        
          FROM (SELECT A.ZP_JUDGE_STOVE_NO,
                       A.ZP_LOT_NO,
                       A.ZP_M_LH,
                       A.ZL_TYPE,
                       SUM(A.ZP_COUNT) ZP_COUNT,
                       A.MEMO
                  FROM (SELECT T.ZP_JUDGE_STOVE_NO,
                               T.ZP_LOT_NO,
                               T.ZP_COUNT,
                               T.ZP_M_LH,
                               '离线组炉(管子)' ZL_TYPE,
                               LISTAGG(T.OLD_ZP_JUDGE_STOVE_NO || '：' ||
                                       T.ZP_COUNT || '支',
                                       ',') within GROUP(order by T.ZP_JUDGE_STOVE_NO) over(partition by T.ZP_JUDGE_STOVE_NO, T.ZP_LOT_NO) MEMO
                          FROM MIL_OFFLINE_GROUP T
                         WHERE 1 = 1 #something1#
                        
                        union all
                        
                        SELECT ZP_JUDGE_STOVE_NO,
                               ZP_LOT_NO,
                               SUM(GROUP_NUM) ZP_COUNT,
                               MAX(JUDGE_STOVE_NO) ZP_M_LH,
                               ZL_TYPE,
                               MEMO
                          FROM (SELECT T.ZP_JUDGE_STOVE_NO,
                                       T.ZP_LOT_NO,
                                       T.GROUP_NUM,
                                       T.JUDGE_STOVE_NO,
                                       '荒管组炉(单倍坯)' ZL_TYPE,
                                       LISTAGG(T.JUDGE_STOVE_NO || '：' ||
                                               T.GROUP_NUM || '支',
                                               ',') within GROUP(order by T.ZP_JUDGE_STOVE_NO) over(partition by T.ZP_JUDGE_STOVE_NO, T.ZP_LOT_NO) MEMO
                                  FROM MIL_FURNACES_RESLUT_DETIA T
                                 WHERE 1 = 1 #something2#)
                         GROUP BY ZP_JUDGE_STOVE_NO, ZP_LOT_NO, ZL_TYPE, MEMO
                        
                        UNION ALL
                        
                        SELECT T.NEW_HEAT_NO ZP_JUDGE_STOVE_NO,
                               T.NEW_LOT_NO ZP_LOT_NO,
                               COUNT(1) ZP_COUNT,
                               '' ZP_M_LH,
                               '回炉坯组炉(单倍坯)' ZL_TYPE,
                               LISTAGG(T.JUDGE_STOVE_NO || '：' || COUNT(1) || '支',
                                       ',') within GROUP(order by T.NEW_HEAT_NO) over(partition by T.NEW_HEAT_NO) MEMO
                          FROM MIL_SLAB_SCRAP T
                         WHERE T.GROUP_FLAG = 1 #something3#
                         GROUP BY T.NEW_HEAT_NO,
                                  T.NEW_LOT_NO,
                                  T.JUDGE_STOVE_NO) A
                 GROUP BY A.ZP_JUDGE_STOVE_NO,
                          A.ZP_LOT_NO,
                          A.ZP_M_LH,
                          A.ZL_TYPE,
                          A.MEMO) T1,
               MIL_PLAN T2
         WHERE T1.ZP_JUDGE_STOVE_NO = T2.JUDGE_STOVE_NO
         AND T2.BACK_SLAB_FLAG <> '2') F
 WHERE 1 = 1 #something4#
]]>
</query>

<query id = "FrmMilDateStatistics.getPlineName" desc = "查询加工产线">
<![CDATA[
SELECT A.PLINE_CODE, A.PLINE_NAME
  FROM COM_BASE_PLINE A, COM_BASE_INFO B
 WHERE A.GROUP_PLAN = B.BASECODE
   AND B.SORTCODE = '2004'
]]>
</query>
<query id = "FrmMilDateStatistics.getPlineNameZG" desc = "查询轧管产线">
<![CDATA[
SELECT A.PLINE_CODE, A.PLINE_NAME
  FROM COM_BASE_PLINE A
 WHERE A.PROCESS_CODE = 'D'
   AND A.VALIDFLAG = '1'
]]>
</query>

<query id = "FrmMilDateStatistics.getProductionSchedulingAndCoupling" desc = "加工排产一级与接箍订单查询">
<![CDATA[
SELECT (CASE T.PREVIOUS_GX
         WHEN '轧制' THEN
          (SELECT TO_CHAR((T.PLAN_TIME_B - MIN(TP.PLAN_TIME_B)), 'fm9990.00') || '天,' ||
                  MIN(TP.PLINE_NAME) || ',' || COUNT(1) || '条'
             FROM PLN_ORDER_ZG_S TP
            WHERE TP.PRO_PLAN_ID = T.PREV_GXPLAN_ID)
         WHEN '镦拔扩' THEN
          (SELECT TO_CHAR((T.PLAN_TIME_B - MIN(TP.PLAN_TIME_B)), 'fm9990.00') || '天,' ||
                  MIN(TP.PLINE_NAME) || ',' || COUNT(1) || '条'
             FROM PLN_ORDER_DBK_S TP
            WHERE TP.PRO_PLAN_ID = T.PREV_GXPLAN_ID)
         WHEN '热处理' THEN
          (SELECT TO_CHAR((T.PLAN_TIME_B - MIN(TP.PLAN_TIME_B)), 'fm9990.00') || '天,' ||
                  MIN(TP.PLINE_NAME) || ',' || COUNT(1) || '条'
             FROM PLN_ORDER_RCL_S TP
            WHERE TP.PRO_PLAN_ID = T.PREV_GXPLAN_ID)
         ELSE
          ''
       END) PRE_INFO,
       T.IF_EXPORT,
       T.PROCESS_DESC_C_ZG,
       T.GROUP_ROLL_NAME,
       TO_CHAR(T.BEGIN_TIME_ZG, 'YYYY-MM-DD HH24:MI:SS') BEGIN_TIME_ZG,
       T.PRDCR_ADVC_DAY,
       T.WHOLE_BACKLOG_DESC,
       T.MSC,
       T.INDEX_SEQ,
       T.BOM,
       (SELECT T9.BASENAME
          FROM COM_BASE_INFO T9
         WHERE T9.BASECODE = T.PRIORITY) PRIORITY,
       T.PRIORITY_MEMO,
       TO_CHAR(T.DELVRY_EDATE, 'YYYY-MM-DD') DELVRY_EDATE,
       T.STATION_NM,
       T.OUTLINE_SITE_250,
       TO_CHAR(T.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       T.MEMO,
       T.PRO_ORDER_NO,
       T.PRO_PLAN_ID,
       T.GX_PLAN_NO,
       NULLIF(T.ORDER_NO || '/' || T.ORDER_SEQ, '/') PRO_PLAN_NO,
       T.PLAN_GROUP_ID,
       T.ORDER_SOURCE,
       T.ORD_LN_DLY_PK,
       T.PLN_DIVIDE_ID,
       NULLIF(T.ORDER_NO || '/' || T.ORDER_SEQ, '/') ORDER_NO1,
       T.ORDER_SEQ,
       T.DELIVERY_NO,
       T.REQ_BL_ID,
       T.PLINE_CODE,
       T.PLINE_NAME,
       (SELECT B.BASENAME
          FROM COM_BASE_PLINE A, COM_BASE_INFO B
         WHERE A.GROUP_PLAN = B.BASECODE
           AND B.SORTCODE = '2004'
           AND A.PLINE_CODE = T.PLINE_CODE) JGFZ,
       T.STEELCODE,
       T.STEELNAME,
       T.OUTDIAMETER,
       T.WALLTHICK,
       T.LENGTHMAX,
       T.LENGTHMIN,
       T.LENGTHDISC,
       T.AIMWALLTHICK,
       T.AIMLENGTH,
       T.SHRT_LEN_RATO,
       T.SHORTEST,
       T.LONG_LEN_RATO,
       T.LONGEST,
       T.SHRT_STOVE,
       T.AVG_LEN_MIN,
       T.DIFRNC_LEN_MAX,
       T.SIGL_LEN,
       T.ENDLEN_SPECSTD,
       T.MODEL_CODE,
       T.MODEL_DESC,
       T.LENGTHMAX_IN,
       T.LENGTHMIN_IN,
       T.LENGTH_IN,
       T.INWL_ID,
       T.INWL_DESC,
       T.OUTWL_ID,
       T.OUTWL_DESC,
       T.IN_WEIGHT_S,
       T.IN_NUM_S,
       T.WEIGTH_S,
       T.NUM_S,
       T.MATCH_WT_IN,
       T.MATCH_NUM_IN,
       DECODE(T.IF_MONITOR_JGX, '1', 'Y', '') IF_MONITOR_JGX,
       T.PRDCR_NO,
       T.MONITOR_POINT,
       T.CIC,
       T.PIC,
       T.SIC,
       T.DIC,
       T.WIC,
       T.GIC,
       T.STATION_ROAD,
       T.GX_PRO_SEQ,
       TO_CHAR(round(TO_NUMBER(NVL(T.PLAN_USETIME, '0')) / 60, 2)) PLAN_USETIME,
       TO_CHAR(T.PLAN_TIME_B, 'YYYY-MM-DD HH24:MI:SS') PLAN_TIME_B,
       TO_CHAR(T.PLAN_TIME_E, 'YYYY-MM-DD HH24:MI:SS') PLAN_TIME_E,
       T.BATCHED_WT,
       T.BATCHED_NUM,
       T.FINISHWEIGHT,
       T.FINISHNUM,
       DECODE(T.EXE_STATUS,
              '0',
              '计划',
              '1',
              '生产中',
              '2',
              '已生产',
              '3',
              '关闭A',
              '') EXE_STATUS,
       DECODE(T.IS_REPAIR_PLN, '1', 'Y', '') IS_REPAIR_PLN,
       T.REPAIR_TYPE,
       DECODE(T.IS_PLAN_OK, '1', 'Y', '') IS_PLAN_OK,
       T.ZY_BATCH_ID,
       T.PRO_MONTH,
       T.PREVIOUS_GX,
       T.PREV_GXPLAN_ID,
       T1.GROUP_JGX,
       T.FINAL_USER_DESC,
       T2.SALE_ORG_DESC,
       T2.PRODUCCODE,
       T2.PRODUCNAME,
       T2.STD_CODE,
       T2.STD_NAME,
       T2.STD_STYLE,
       T2.STD_STYLE_DESC,
       T2.ORDER_SPEC_CODE,
       T2.ORDER_SPEC_DESC,
       T2.SPEC_CODE,
       T2.SPEC_NAME,
       T2.CRAFT_PATH,
       T2.CRAFT_SEQ,
       T2.CRAFT_NO AS CRAFT_FILE_NO,
       T2.CRAFT_NAME AS CRAFT_FILE_MAN,
       (SELECT LV.CRAFT_PATH
          FROM CRAFT_FILE_LV2 LV
         WHERE INSTR(T2.CRAFT_FILE_LV2_G, LV.PK) > 0
           AND INSTR(LV.PLINE_CODE, T.PLINE_CODE) > 0
           AND LV.VALIDFLAG = '1'
           AND LV.PROCESS_CODE = 'G') CRAFT_FILE_LV2_G,
       T3.ADD_ASK1,
       T3.ADD_ASK2,
       T3.ADD_ASK3,
       T3.ADD_ASK4,
       T3.ADD_ASK5,
       T3.ADD_ASK6,
       T3.ADD_ASK7,
       T3.ADD_ASK8,
       T3.ADD_ASK9,
       T3.ADD_ASK10,
       T3.ADD_ASK11,
       T3.ADD_ASK12,
       T3.ADD_ASK13,
       DECODE(T4.JGORDERSTATUS,
              '0',
              '待处理',
              '1',
              '已组订单',
              '2',
              '已完成') JGORDERSTATUS,
       T4.JG_ORDERNO,
       T4.ORDERWEIGHT,
       T4.ORDERNUM,
       T4.CODE_JG,
       DECODE(T4.IF_MONITOR_JG, '0', '否', '1', '是') IF_MONITOR_JG,
       DECODE(T4.DEMAND_DETECTION,
              '0',
              '否',
              '1',
              '是',
              (SELECT B.BASENAME
                 FROM COM_BASE_INFO B
                WHERE B.BASECODE = T4.DEMAND_DETECTION)) DEMAND_DETECTION,
       DECODE(T4.DEMAND_BONDERIZING,
              '0',
              '否',
              '1',
              '是',
              (SELECT B.BASENAME
                 FROM COM_BASE_INFO B
                WHERE B.BASECODE = T4.DEMAND_BONDERIZING)) DEMAND_BONDERIZING,
       DECODE(T4.DEMAND_COPPER,
              '0',
              '否',
              '1',
              '是',
              (SELECT B.BASENAME
                 FROM COM_BASE_INFO B
                WHERE B.BASECODE = T4.DEMAND_COPPER)) DEMAND_COPPER,
       DECODE(T4.DEMAND_BLAST,
              '0',
              '否',
              '1',
              '是',
              (SELECT B.BASENAME
                 FROM COM_BASE_INFO B
                WHERE B.BASECODE = T4.DEMAND_BLAST)) DEMAND_BLAST,
       T4.SPEC_JG_DESC,
       T4.STEELNAME STEELNAME_JG,
       T4.MODEL_DESC MODEL_DESC_JG,
       T4.STYLE_JG,
       T4.PRODUCCODE_JG_DESC,
       T4.STD_NAME STD_NAME_JG,
       T4.STD_STYLE_DESC STD_STYLE_DESC_JG
  FROM PLN_ORDER_JGX_S T,
       PLN_GX_JGX_M T1,
       (SELECT Q1.PRODUCCODE,
               Q1.PRODUCNAME,
               Q1.STD_CODE,
               Q1.STD_NAME,
               Q1.STD_STYLE,
               Q1.STD_STYLE_DESC,
               Q1.ORDER_SPEC_CODE,
               Q1.ORDER_SPEC_DESC,
               Q1.SPEC_CODE,
               Q1.SPEC_NAME,
               Q2.ORD_LN_DLY_PK,
               Q2.ORD_LN_PK,
               Q1.STEELCODE,
               Q1.STEELNAME,
               Q1.DELVRY_RANGE_TPE,
               Q1.DELVRY_RANGE_MAX,
               Q1.DELVRY_RANGE_MIN,
               Q2.DELVRY_QTY,
               Q3.CRAFT_SEQ,
               Q3.CRAFT_NO,
               Q4.CRAFT_NAME,
               Q5.SALE_ORG_DESC,
               Q1.FINAL_USER_DESC,
               NVL(Q3.CRAFT_PATH,
                   (SELECT C1.CRAFT_PATH
                      FROM CRAFT_ORD_DESIGN C2, CRAFT_ORD_DESIGN_FILE C1
                     WHERE C1.CRAFT_NO = C2.CRAFT_NO
                       AND C1.CRAFT_NO_V = C2.CRAFT_NO_V
                       AND C1.VALIDFLAG = '1'
                       AND C2.VALIDFLAG = '1'
                       AND C2.ORD_LN_PK = Q1.ORD_LN_PK)) AS CRAFT_PATH,
               Q3.CRAFT_FILE_LV2_G
          FROM SLM_ORDER_LINE           Q1,
               SLM_ORDER_LINE_DELIVERY  Q2,
               CRAFT_ORD_DESIGN         Q3,
               CRAFT_ORD_DESIGN_APPOINT Q4,
               SLM_ORDER_HEAD           Q5
         WHERE Q1.ORD_LN_PK = Q2.ORD_LN_PK
           AND Q1.ORD_LN_PK = Q3.ORD_LN_PK(+)
           AND Q1.ORD_LN_PK = Q4.ORD_LN_PK(+)
           AND Q1.ORD_PK = Q5.ORD_PK
           AND Q3.VALIDFLAG(+) = '1') T2,
       (SELECT *
          FROM (SELECT Q.ASK_ITME_DESC,
                       Q.ASK_SUB_ITME_VAL_DESC,
                       Q.ORD_LN_DLY_PK
                  FROM (SELECT Q3.ASK_ITME_DESC,
                               Q1.ORD_LN_DLY_PK,
                               LISTAGG(Q3.ASK_SUB_ITME_VAL_DESC, ' ** ') WITHIN GROUP(ORDER BY Q3.ASK_ITME) ASK_SUB_ITME_VAL_DESC
                          FROM SLM_ORDER_LINE_DELIVERY Q1,
                               SLM_ORDER_LINE          Q2,
                               SLM_ORDER_ADD_ASK       Q3
                         WHERE Q1.ORD_LN_PK = Q2.ORD_LN_PK
                           AND Q2.ADD_ASK_NO = Q3.ADD_ASK_NO
                           AND Q1.VALIDFLAG = '1'
                           AND Q2.VALIDFLAG = '1'
                           AND Q2.CREATE_NAME IS NOT NULL
                           AND Q3.VALIDFLAG = '1'
                         GROUP BY Q3.ASK_ITME_DESC, Q1.ORD_LN_DLY_PK) Q) PIVOT(MAX(ASK_SUB_ITME_VAL_DESC) FOR ASK_ITME_DESC IN('喷标' AS
                                                                                                                               ADD_ASK1,
                                                                                                                               '涂漆' AS
                                                                                                                               ADD_ASK2,
                                                                                                                               '保护帽' AS
                                                                                                                               ADD_ASK3,
                                                                                                                               '丝扣油' AS
                                                                                                                               ADD_ASK4,
                                                                                                                               '计重方式' AS
                                                                                                                               ADD_ASK5,
                                                                                                                               '打捆' AS
                                                                                                                               ADD_ASK6,
                                                                                                                               '质量' AS
                                                                                                                               ADD_ASK7,
                                                                                                                               '交货材料' AS
                                                                                                                               ADD_ASK8,
                                                                                                                               '发货结算约定' AS
                                                                                                                               ADD_ASK9,
                                                                                                                               '特殊通径' AS
                                                                                                                               ADD_ASK10,
                                                                                                                               '特殊端部加工' AS
                                                                                                                               ADD_ASK11,
                                                                                                                               '取样备注' AS
                                                                                                                               ADD_ASK12,
                                                                                                                               '表面质量' AS
                                                                                                                               ADD_ASK13))) T3,
       (SELECT C1.ORD_LN_DLY_PK,
               C1.JGORDERSTATUS,
               C1.JG_ORDERNO,
               C1.ORDERWEIGHT,
               C1.ORDERNUM,
               C1.CODE_JG,
               C1.IF_MONITOR_JG,
               C1.DEMAND_DETECTION,
               C1.DEMAND_BONDERIZING,
               C1.DEMAND_COPPER,
               C1.DEMAND_BLAST,
               C1.SPEC_JG_DESC,
               C1.STEELNAME,
               C1.MODEL_DESC,
               C1.STYLE_JG,
               C2.PRODUCCODE_JG_DESC,
               C2.STD_NAME,
               C2.STD_STYLE_DESC
          FROM PLN_ORDER_JG C1, COM_MSC_JG C2
         WHERE C1.CODE_JG = C2.CODE_JG(+)) T4

 WHERE T.PRO_PLAN_ID = T1.PRO_PLAN_ID(+)
   AND T.ORD_LN_DLY_PK = T2.ORD_LN_DLY_PK(+)
   AND T.ORD_LN_DLY_PK = T3.ORD_LN_DLY_PK(+)
   AND T.ORD_LN_DLY_PK = T4.ORD_LN_DLY_PK(+)
   AND T.EXE_STATUS = '0'
   AND T.MODEL_DESC <> 'BE'
   AND T.MODEL_DESC <> 'PE'
   AND T.MODEL_DESC <> '/'
   AND T.MODEL_DESC IS NOT NULL
   #something#
]]>
</query>

<query id = "FrmMilDateStatistics.getMilStaOutput" desc = "查询产量报表">
<![CDATA[
select t.PRODUCNAME,
       t.STEELNAME,
       t.gradename,
       t.SPEC_NAME,
       t.pline_code,
       t.pline_name,
       TO_CHAR(T.JUDGE_RESULT_TIME, 'YYYYMM'),
       sum(decode(t.act_weight, null, t.act_theory_weight, t.act_weight)) act_weight,
       sum(decode(t.act_weight, null, t.act_theory_weight, t.act_weight)) act_weight1,
       '' act_weight2,
       '' act_weight3
  from QCM_ZG_JUGDE_APPLY t
 where 1 = 1
  #something#
 GROUP BY t.PRODUCNAME,
          t.STEELNAME,
          t.gradename,
          t.SPEC_NAME,
          TO_CHAR(T.JUDGE_RESULT_TIME, 'YYYYMM'),
          t.pline_name,
          t.pline_code
 order by t.pline_name,t.PRODUCNAME, t.STEELNAME, t.gradename, t.SPEC_NAME
]]>
</query>

<query id = "FrmMilDateStatistics.getMilTestReport" desc = "查询探伤、表检报告">
<![CDATA[
SELECT A.*,
       (SELECT MAX(T1.DETECT_RESULT_PATH)
          FROM QCM_INSPECTION_REPORT T1
         WHERE T1.JUDGE_STOVE_NO = A.judge_stove_no
           AND T1.LOT_NO = A.LOT_NO
           AND T1.PLINE_CODE = A.PLINE_CODE
           AND T1.VALIDFLAG = '10'
           AND NVL(T1.PRO_PLAN_ID, '/') = NVL(A.pro_plan_id, '/')
           AND NVL(T1.GX_PLAN_NO, '/') = NVL(A.gx_plan_no, '/')) DETECT_RESULT_PATH,
       
       (SELECT MAX(T2.FACE_RESULT_PATH)
          FROM QCM_SURFACE_REPORT T2
         WHERE T2.JUDGE_STOVE_NO = A.judge_stove_no
           AND T2.LOT_NO = A.LOT_NO
           AND T2.PLINE_CODE = A.PLINE_CODE
           AND T2.VALIDFLAG = '10'
           AND NVL(T2.PRO_PLAN_ID, '/') = NVL(A.pro_plan_id, '/')
           AND NVL(T2.GX_PLAN_NO, '/') = NVL(A.gx_plan_no, '/')) FACE_RESULT_PATH
  FROM (select T.JUDGE_STOVE_NO,
               T.LOT_NO,
               T.PLINE_CODE,
               T.PLINE_NAME,
               T.PROCESS_CODE,
               T.CRAF_NO,
               T.PRO_ORDER_NO,
               T.PRO_PLAN_ID,
               T.GX_PLAN_NO
          from QCM_INSPECTION_REPORT t
        UNION
        SELECT T.JUDGE_STOVE_NO,
               T.LOT_NO,
               T.PLINE_CODE,
               T.PLINE_NAME,
               T.PROCESS_CODE,
               T.CRAF_NO,
               T.PRO_ORDER_NO,
               T.PRO_PLAN_ID,
               T.GX_PLAN_NO
          FROM QCM_SURFACE_REPORT T) A
 WHERE 1 = 1
 #something#
]]>
</query>
<query id = "FrmMilDateStatistics.getMilPlanIsClose" desc = "查询炉计划状态">
SELECT T.ISCLOSE
  FROM MIL_PROCESSES T
 WHERE T.PRO_PLAN_ID = '#PRO_PLAN_ID#'
   AND T.GX_PLAN_NO = '#GX_PLAN_NO#'
   AND T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
   AND T.LOT_NO = '#LOT_NO#'
</query>
<query id = "FrmMilDateStatistics.getTakeNum" desc = "查询脱单支数">
   SELECT NVL(SUM(T.TAKE_NUM), 0)TAKE_NUM
     FROM MIL_TAKE_RESLUT T
    WHERE NVL(T.PRO_PLAN_ID,'/') = NVL('#PRO_PLAN_ID#','/')
      AND NVL(T.GX_PLAN_NO,'/') = NVL('#GX_PLAN_NO#','/')
      AND REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '') = '#JUDGE_STOVE_NO#'
      AND T.LOT_NO = '#LOT_NO#'
</query>
<query id = "FrmMilDateStatistics.updateIsClose" desc = "修改静态炉计划状态">
UPDATE MIL_PROCESSES T SET T.ISCLOSE = '#ISCLOSE#'
WHERE NVL(T.PRO_PLAN_ID,'/') = NVL('#PRO_PLAN_ID#','/')
      AND NVL(T.GX_PLAN_NO,'/') = NVL('#GX_PLAN_NO#','/')
      AND T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
      AND T.LOT_NO = '#LOT_NO#'
</query>


<query id = "FrmMilDateStatistics.getFrmMilDateWaitingDecision" desc = "轧管生产按炉跟踪判定情况查询">
<![CDATA[
SELECT T.COL_TIME,
       T.PLINE_CODE,
       (SELECT P.PLINE_NAME
          FROM COM_BASE_PLINE P
         WHERE P.PLINE_CODE = T.PLINE_CODE) PLINE_NAME,
       DECODE(T.IF_MONITOR, 0, '不监制', 1, '监制') IF_MONITOR,
       MAX(T.FINISH_USER) FINISH_USER,
       MAX(T.TARGET) TARGET,
       MAX(T.IS_VISIBLE) IS_VISIBLE,
       MAX(T.CONTRACT_NO) CONTRACT_NO,
       ROUND(NVL(MAX(T2.JUDGE_RESULT_TIME), SYSDATE) - T.COL_TIME) TIME_C,
       T.LOT_NO,
       REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '') JUDGE_STOVE_NO,
       MAX(T.PRO_PLAN_ID) PRO_PLAN_ID,
       MAX(T.GX_PLAN_NO) GX_PLAN_NO,
       MAX(T.VARIETIES) VARIETIES,
       MAX(T.STEELNAME) STEELNAME,
       MAX(T.GRADENAME) GRADENAME,
       MAX(T.PIPE_SIZE) PIPE_SIZE,
       CASE MAX(T.NODE_STATUS)
         WHEN '10' THEN
          '锯切完成'
         WHEN '20' THEN
          '出炉'
         WHEN '30' THEN
          '穿孔完成'
         WHEN '40' THEN
          '连轧完成'
         WHEN '50' THEN
          '出再加热炉'
         WHEN '60' THEN
          '出定径'
         WHEN '70' THEN
          '分切完成'
         WHEN '80' THEN
          '矫直完成'
         WHEN '90' THEN
          '探伤完成'
         WHEN '96' THEN
          '质检完成'
         WHEN '99' THEN
          '下线'
       END STATUS,
       (SELECT SUM(B.FEED_NUM_PLAN * B.DB_NUM) * MAX(T.SAW_NUM)
          FROM MIL_FEED_PLAN B
         WHERE B.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO) FEED_NUM,
       
       ROUND((SELECT SUM(B.MAT_TOTAL_HEIGHT -
                         B.FEED_NUM * DECODE(B.CUT_TARGET,
                                '返废',
                                NVL(round(B.CUT_WEIGHT, 3), 0),
                                
                                0))
                FROM MIL_FEED_PLAN B
               WHERE B.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO) *
             (1 - NVL((select R.BURNNING_RATE
                         from MIL_FUR_RESULT R
                        WHERE R.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO) / 100,
                      0)) -
             DECODE(MAX(T.CONTROL_THICKP),
                    0,
                    0,
                    (MAX(T.CUT_HEAD_LENGTHP) + MAX(T.CUT_TRAIL_LENGTHP)) / 1000 *
                    (0.02466 * MAX(T.CONTROL_THICKP) / 1000 * 1.02 *
                    ((SUBSTR(MAX(T.PIPE_SIZE),
                              1,
                              INSTR(MAX(T.PIPE_SIZE), '*') - 1)) * (CASE
                      WHEN INSTR(MAX(T.VARIETIES), '套管') > 0 THEN
                       1.005
                      WHEN INSTR(MAX(T.VARIETIES), '油管') > 0 THEN
                       1.005
                      ELSE
                       1
                    END) - (MAX(T.CONTROL_THICKP) / 1000 * 1.02)) *
                    (SELECT SUM(B.FEED_NUM_PLAN * B.DB_NUM)
                        FROM MIL_FEED_PLAN B
                       WHERE B.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO))),
             3) MAT_TOTAL_HEIGHT,
       
       NVL((select SUM(Q.ACT_COUNT)
             from QCM_ZG_JUGDE_APPLY Q
            WHERE Q.APPLY_FLAG = '0'
              AND Q.PROCESS_CODE = 'D'
              AND Q.JUDGE_STOVE_NO =
                  REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '')),
           0) SPZ,
       
       NVL((select DECODE(NVL(SUM(Q.ACT_WEIGHT), 0),
                         0,
                         SUM(Q.ACT_THEORY_WEIGHT),
                         SUM(Q.ACT_WEIGHT))
             from QCM_ZG_JUGDE_APPLY Q
            WHERE Q.APPLY_FLAG = '0'
              AND Q.PROCESS_CODE = 'D'
              AND Q.JUDGE_STOVE_NO =
                  REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '')),
           0) SPD,
       DECODE(MAX(T2.JUDGE_RESULT_CODE),
              '40740701',
              '通过',
              '40740709',
              '通过') VALIDFLAG,
       MAX(T.WAITING_DECISION_MEMO) WAITING_DECISION_MEMO,
       MAX(T.AGAIN_MEMO) AGAIN_MEMO,
       MAX(T3.QUALIFIED_BRANCH) ZHZ,
       MAX(T3.QUALIFIED_TONS) ZHD,
       
       MAX(T4.OFFLINE_PRODUCT) XXZ,
       MAX(T4.MEMO) XXYY,
       
       DECODE(MIN(T5.QUOTE_STATE),
              '0',
              '未报出',
              '1',
              '部分报出',
              '2',
              '报齐') QUOTE_STATE,
              MIN(T2.APPLY_TIME) APPLY_TIME,
              MAX(T2.JUDGE_RESULT_TIME) JUDGE_RESULT_TIME

  FROM MIL_PLAN T,
       QCM_ZG_JUGDE_APPLY T2,
       (select REGEXP_REPLACE(T3.JUDGE_STOVE_NO, '-.*', '') JUDGE_STOVE_NO,
               T3.PLINE_CODE,
               SUM(NVL(T3.QUALIFIED_BRANCH, 0)) QUALIFIED_BRANCH,
               SUM(NVL(QUALIFIED_TONS, 0)) QUALIFIED_TONS
          from MIL_SURFACE_RESULT T3
         WHERE T3.QUALIFIED_BRANCH > 0
           AND T3.QUALIFIED_TONS > 0
         GROUP BY REGEXP_REPLACE(T3.JUDGE_STOVE_NO, '-.*', ''),
                  T3.PLINE_CODE) T3,
       (SELECT JUDGE_STOVE_NO, SUM(OFFLINE_PRODUCT) OFFLINE_PRODUCT, MEMO
          FROM (select REGEXP_REPLACE(JUDGE_STOVE_NO, '-.*', '') JUDGE_STOVE_NO,
                       OFFLINE_PRODUCT,
                       LISTAGG(DEFECT_ITEM || OFFLINE_PRODUCT || '支', ',') within GROUP(order by REPLACE(JUDGE_STOVE_NO, SUBSTR(JUDGE_STOVE_NO, -3), '')) over(partition by REPLACE(JUDGE_STOVE_NO, SUBSTR(JUDGE_STOVE_NO, -3), '')) MEMO
                  from MIL_CHECK_DEATIL_SIMPLE
                 WHERE OFFLINE_PRODUCT > 0)
         GROUP BY JUDGE_STOVE_NO, MEMO) T4,
       (select T.JUDGE_STOVE_NO,
               T.PLINE_CODE,
               MIN(T.QUOTE_STATE) QUOTE_STATE
          from QCM_ZC_CHECKCONSIGN t
         WHERE IS_FLAG = '0'
           AND CRAFT_SOURCE = '0'
         GROUP BY T.JUDGE_STOVE_NO, T.PLINE_CODE) T5

 WHERE SUBSTR(T.JUDGE_STOVE_NO, -3) = '-01'
   AND REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '') = T2.JUDGE_STOVE_NO(+)
   AND T2.PROCESS_CODE(+) = 'D'
   AND T2.IS_ALL_SCRAP(+) <> '1'
   AND T.BACK_SLAB_FLAG <> '2'
   AND REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '') = T3.JUDGE_STOVE_NO(+)
   AND T.PLINE_CODE = T3.PLINE_CODE(+)
   AND REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '') = T4.JUDGE_STOVE_NO(+)
   AND REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '') = T5.JUDGE_STOVE_NO(+)
   AND T.PLINE_CODE = T5.PLINE_CODE(+)

]]>
</query>

<query id = "FrmMilDateStatistics.saveMilDateWaitingDecision" desc = "保存轧管待判原因">
<![CDATA[
UPDATE MIL_PLAN T
   SET T.WAITING_DECISION_MEMO = ?, T.AGAIN_MEMO = ?, T.IS_VISIBLE = ?
 WHERE REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '') = ?
   AND NVL(T.PRO_PLAN_ID, '/') = NVL(?, '/')
   AND NVL(T.GX_PLAN_NO, '/') = NVL(?, '/')
]]>
</query>

<query id = "FrmMilDateStatistics.doQueryPlineCode" desc = "查产线">
	SELECT T.PLINE_CODE,T.PLINE_NAME FROM COM_BASE_PLINE T WHERE T.PROCESS_CODE = ?
</query>

<query id = "FrmMilDateStatistics.JudgeBaseInfo" desc = "查产线">
<![CDATA[
	SELECT T.PLINE_CODE   plineCode,
       T.PLINE_NAME   plineName,
       T.PROCESS_DESC processDesc,
       T2.BASENAME    factoryDesc,
       T3.BASENAME    checkStationDesc
  FROM COM_BASE_PLINE T
  LEFT JOIN COM_BASE_INFO T2
    ON T2.BASECODE = T.FACTORY_CODE
  LEFT JOIN COM_BASE_INFO T3
    ON T3.BASECODE = T.CHECK_STATION
 WHERE T.VALIDFLAG = '1'
   AND T.PROCESS_CODE IN (?)
 ORDER BY T.PROCESS_CODE, T.FACTORY_CODE, T.PLINE_NAME
 ]]>
</query>

<query id = "FrmMilDateStatistics.doQueryFactory" desc = "查加工部的厂">
	select t.* from COM_BASE_INFO t WHERE T.SORTCODE = '4105'
</query>

<query id = "FrmMilDateStatistics.SelectVrpWaitingDecision" desc = "查询镦拔扩数据">
<![CDATA[
SELECT *
  FROM (select T1.LOAD_TIME,
               T.HEAT_PLAN_NO,
               --ROUND(SYSDATE - T1.LOAD_TIME) TIME_C,
               ROUND(NVL((SELECT MAX(Q.JUDGE_RESULT_TIME)
                           FROM QCM_ZG_JUGDE_APPLY Q
                          WHERE Q.HEAT_PLAN_NO = T.HEAT_PLAN_NO
                            AND Q.PROCESS_CODE = 'E'
                            AND Q.BATCH_NO = P.PHY_BATCH_NO
                            AND Q.APPLY_FLAG = '0'),
                         SYSDATE) - T1.LOAD_TIME) TIME_C,
               T.PLINE_CODE,
               T.PLINE_NAME,
               T.DECISION,
               (SELECT C2.BASENAME
                  FROM COM_BASE_PLINE C, COM_BASE_INFO C2
                 WHERE C.PLINE_CODE = T.PLINE_CODE
                   AND C.CHECK_STATION = C2.BASECODE) CHECK_STATION,
               DECODE(T.IF_MONITOR, 0, '不监制', 1, '监制') IF_MONITOR,
               MAX(H.FINAL_USER_DESC) CUSTOMER_NM,
               MAX(T.ORDER_NO) || '/' || MAX(T.ORDER_SEQ) ORDER_NO,
               T.ZY_BATCH_ID,
               T.JUDGE_STOVE_NO,
               P.PHY_BATCH_NO BATCH_NO,
               MAX(T.IS_VISIBLE) IS_VISIBLE,
               MAX(T.MODEL_DESC) MODEL_DESC,
               MAX(T.PRODUCNAME) PRODUCNAME,
               MAX(T.STEELNAME) STEELNAME,
               MAX(T.GRADENAME) GRADENAME,
               MAX(T.SPEC_NAME) SPEC_NAME,
               SUM(P.ACT_COUNT) SCZ,
               SUM(P.ACT_THEORY_WEIGHT) SCD,
               (SELECT SUM(Q.ACT_COUNT)
                  FROM QCM_ZG_JUGDE_APPLY Q
                 WHERE Q.HEAT_PLAN_NO = T.HEAT_PLAN_NO
                   AND Q.PROCESS_CODE = 'E'
                   AND Q.BATCH_NO = P.PHY_BATCH_NO
                   AND Q.APPLY_FLAG = '0') SPZ,
               (SELECT SUM(Q.ACT_WEIGHT)
                  FROM QCM_ZG_JUGDE_APPLY Q
                 WHERE Q.HEAT_PLAN_NO = T.HEAT_PLAN_NO
                   AND Q.PROCESS_CODE = 'E'
                   AND Q.BATCH_NO = P.PHY_BATCH_NO
                   AND Q.APPLY_FLAG = '0') SPD,
               CASE
                 WHEN (SELECT COUNT(1)
                         FROM QCM_ZG_JUGDE_APPLY Q
                        WHERE (Q.INSTANCY_FLAG = '1' OR
                              Q.TOL_INSTANCY_FLAG = '1')
                          AND Q.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO
                          AND (Q.JUDGE_RESULT IS NULL OR
                              Q.JUDGE_RESULT = '不合格')) > 0 THEN
                  '是'
                 ELSE
                  '否'
               END IS_FLAG,
               (SELECT MAX(CASE
                             WHEN Q.IS_FLAG = '0' AND Q.IS_ALL_SCRAP IN ('0', '2') AND
                                  ((Q.VALIDFLAG = '20' AND
                                  Q.JUDGE_RESULT_CODE IN
                                  ('40740701', '40740709')) OR
                                  Q.INSTANCY_FLAG = '1') THEN
                              '通过'
                           END)
                  FROM QCM_ZG_JUGDE_APPLY Q
                 WHERE Q.HEAT_PLAN_NO = T.HEAT_PLAN_NO
                   AND Q.PROCESS_CODE = 'E'
                   AND Q.BATCH_NO = P.PHY_BATCH_NO
                   AND Q.APPLY_FLAG = '0') VALIDFLAG,
               MAX(T.WAITING_DECISION_MEMO) WAITING_DECISION_MEMO
          from PLN_ZY_DBK_M t,
               (SELECT T1.HEAT_PLAN_NO, MAX(T1.LOAD_TIME) LOAD_TIME
                  FROM VRP_LOADING_RESULT T1
                 WHERE 1 = 1 #LOAD_TIME#
                 GROUP BY T1.HEAT_PLAN_NO) T1,
               (SELECT DISTINCT T2.ORDER_NO, T3.ORDER_SEQ, T3.FINAL_USER_DESC
                  FROM SLM_ORDER_HEAD T2, SLM_ORDER_LINE T3
                 WHERE T2.ORD_PK = T3.ORD_PK) H,
               PORT_VRP_BATCH_SAMPLE_RESULT P
         WHERE T.HEAT_PLAN_NO = T1.HEAT_PLAN_NO
           AND T.ORDER_NO = H.ORDER_NO(+)
           AND T.ORDER_SEQ = H.ORDER_SEQ(+)
           AND T.HEAT_PLAN_NO = P.HEAT_PLAN_NO #LOAD_TIME# #SOMETHING#
         GROUP BY T1.LOAD_TIME,
                  T.HEAT_PLAN_NO,
                  T.HEAT_PLAN_NO,
                  T.PLINE_CODE,
                  T.PLINE_NAME,
                  T.DECISION,
                  T.IF_MONITOR,
                  T.ZY_BATCH_ID,
                  T.JUDGE_STOVE_NO,
                  P.PHY_BATCH_NO
         ORDER BY T1.LOAD_TIME)
 WHERE 1 = 1 #VALIDFLAG#
]]>
</query>

<query id = "FrmMilDateStatistics.SelectHttWaitingDecision" desc = "查询热处理数据">
<![CDATA[
SELECT *
  FROM (select T1.LOAD_TIME,
               T.HEAT_PLAN_NO,
               --ROUND(SYSDATE - T1.LOAD_TIME) TIME_C,
               ROUND(NVL((SELECT MAX(Q.JUDGE_RESULT_TIME)
                           FROM QCM_ZG_JUGDE_APPLY Q
                          WHERE Q.HEAT_PLAN_NO = T.HEAT_PLAN_NO
                            AND Q.PROCESS_CODE = 'F'
                            AND Q.BATCH_NO = P.PHY_BATCH_NO
                            AND Q.APPLY_FLAG = '0'),
                         SYSDATE) - T1.LOAD_TIME) TIME_C,
               T.PLINE_CODE,
               T.PLINE_NAME,
               T.DECISION,
               (SELECT C2.BASENAME
                  FROM COM_BASE_PLINE C, COM_BASE_INFO C2
                 WHERE C.PLINE_CODE = T.PLINE_CODE
                   AND C.CHECK_STATION = C2.BASECODE) CHECK_STATION,
               DECODE(T.IF_MONITOR, 0, '不监制', 1, '监制') IF_MONITOR,
               MAX(H.FINAL_USER_DESC) CUSTOMER_NM,
               MAX(T.ORDER_NO) || '/' || MAX(T.ORDER_SEQ) ORDER_NO,
               T.ZY_BATCH_ID,
               T.JUDGE_STOVE_NO,
               P.PHY_BATCH_NO BATCH_NO,
               MAX(T.IS_VISIBLE) IS_VISIBLE,
               MAX(T.MODEL_DESC) MODEL_DESC,
               MAX(T.PRODUCNAME) PRODUCNAME,
               MAX(T.STEELNAME) STEELNAME,
               MAX(T.GRADENAME) GRADENAME,
               MAX(T.SPEC_NAME) SPEC_NAME,
               SUM(P.ACT_COUNT) SCZ,
               SUM(P.ACT_THEORY_WEIGHT) SCD,
               (SELECT SUM(Q.ACT_COUNT)
                  FROM QCM_ZG_JUGDE_APPLY Q
                 WHERE Q.JUGDE_APPLY_CODE = P.JUGDE_APPLY_CODE
                   AND Q.PROCESS_CODE = 'F'
                   AND Q.BATCH_NO = P.PHY_BATCH_NO
                   AND Q.APPLY_FLAG = '0') SPZ,
               (SELECT SUM(Q.ACT_WEIGHT)
                  FROM QCM_ZG_JUGDE_APPLY Q
                 WHERE Q.JUGDE_APPLY_CODE = P.JUGDE_APPLY_CODE
                   AND Q.PROCESS_CODE = 'F'
                   AND Q.BATCH_NO = P.PHY_BATCH_NO
                   AND Q.APPLY_FLAG = '0') SPD,
               CASE
                 WHEN (SELECT COUNT(1)
                         FROM QCM_ZG_JUGDE_APPLY Q
                        WHERE (Q.INSTANCY_FLAG = '1' OR
                              Q.TOL_INSTANCY_FLAG = '1')
                          AND Q.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO
                          AND (Q.JUDGE_RESULT IS NULL OR
                              Q.JUDGE_RESULT = '不合格')) > 0 THEN
                  '是'
                 ELSE
                  '否'
               END IS_FLAG,
               (SELECT MAX(CASE
                             WHEN Q.IS_FLAG = '0' AND Q.IS_ALL_SCRAP IN ('0', '2') AND
                                  ((Q.VALIDFLAG = '20' AND
                                  Q.JUDGE_RESULT_CODE IN
                                  ('40740701', '40740709')) OR
                                  Q.INSTANCY_FLAG = '1') THEN
                              '通过'
                           END)
                  FROM QCM_ZG_JUGDE_APPLY Q
                 WHERE Q.JUGDE_APPLY_CODE = P.JUGDE_APPLY_CODE
                   AND Q.PROCESS_CODE = 'F'
                   AND Q.BATCH_NO = P.PHY_BATCH_NO
                   AND Q.APPLY_FLAG = '0') VALIDFLAG,
               MAX(T.WAITING_DECISION_MEMO) WAITING_DECISION_MEMO
          from PLN_ZY_RCL_M t,
               (SELECT T1.HEAT_PLAN_NO, MAX(T1.LOAD_TIME) LOAD_TIME
                  FROM HTT_LOADING_RESULT T1
                 WHERE 1 = 1 #LOAD_TIME#
                 GROUP BY T1.HEAT_PLAN_NO) T1,
               (SELECT DISTINCT T2.ORDER_NO, T3.ORDER_SEQ, T3.FINAL_USER_DESC
                  FROM SLM_ORDER_HEAD T2, SLM_ORDER_LINE T3
                 WHERE T2.ORD_PK = T3.ORD_PK) H,
               PORT_HTT_BATCH_SAMPLE_RESULT P
         WHERE T.HEAT_PLAN_NO = T1.HEAT_PLAN_NO
           AND T.ORDER_NO = H.ORDER_NO(+)
           AND T.ORDER_SEQ = H.ORDER_SEQ(+)
           AND SUBSTR(P.PHY_BATCH_NO,-3) <> '000'
           AND T.HEAT_PLAN_NO = P.HEAT_PLAN_NO #LOAD_TIME# #SOMETHING#
         GROUP BY T1.LOAD_TIME,
                  T.HEAT_PLAN_NO,
                  T.HEAT_PLAN_NO,
                  T.PLINE_CODE,
                  T.PLINE_NAME,
                  T.DECISION,
                  T.IF_MONITOR,
                  T.ZY_BATCH_ID,
                  P.JUGDE_APPLY_CODE,
                  T.JUDGE_STOVE_NO,
                  P.PHY_BATCH_NO
         ORDER BY T1.LOAD_TIME)
 WHERE 1 = 1 #VALIDFLAG#
]]>
</query>

<query id = "FrmMilDateStatistics.SelectMchWaitingDecision" desc = "查询加工线数据">
<![CDATA[
SELECT AA.*, M.XXZ, M.XXD, M.INSTOCK_TIME, N.BUNDLING_NUM, P.MEMO
  FROM (select T1.LOAD_TIME,
               T.HEAT_PLAN_NO,
               --ROUND(SYSDATE - T1.LOAD_TIME) TIME_C,
               ROUND(NVL((SELECT MAX(Q.JUDGE_RESULT_TIME)
                           FROM QCM_ZG_JUGDE_APPLY Q
                          WHERE Q.HEAT_PLAN_NO = T.HEAT_PLAN_NO
                            AND Q.PROCESS_CODE = 'G'
                            AND Q.BATCH_NO = P.PHY_BATCH_NO
                            AND Q.APPLY_FLAG = '0'),
                         SYSDATE) - T1.LOAD_TIME) TIME_C,
               T.PLINE_CODE,
               T.PLINE_NAME,
               T.DECISION,
               (SELECT C2.BASENAME
                  FROM COM_BASE_PLINE C, COM_BASE_INFO C2
                 WHERE C.PLINE_CODE = T.PLINE_CODE
                   AND C.CHECK_STATION = C2.BASECODE) CHECK_STATION,
               DECODE(T.IF_MONITOR, '0', '不监制', '1', '监制') IF_MONITOR,
               (SELECT MAX(T3.FINAL_USER_DESC)
                  FROM SLM_ORDER_HEAD T2, SLM_ORDER_LINE T3
                 WHERE T2.ORD_PK = T3.ORD_PK
                   AND T2.ORDER_NO = T.ORDER_NO
                   AND T3.ORDER_SEQ = T.ORDER_SEQ) CUSTOMER_NM,
               MAX(T.ORDER_NO) || '/' || MAX(T.ORDER_SEQ) ORDER_NO,
               T.ZY_BATCH_ID,
               T.JUDGE_STOVE_NO,
               P.PHY_BATCH_NO BATCH_NO,
               MAX(T.IS_VISIBLE) IS_VISIBLE,
               MAX(T.MODEL_DESC) MODEL_DESC,
               MAX(T.PRODUCNAME) PRODUCNAME,
               MAX(T.STEELNAME) STEELNAME,
               MAX(T.GRADENAME) GRADENAME,
               MAX(T.SPEC_NAME) SPEC_NAME,
               SUM(P.ACT_COUNT) SCZ,
               SUM(P.ACT_THEORY_WEIGHT) SCD,
               (SELECT SUM(Q.ACT_COUNT)
                  FROM QCM_ZG_JUGDE_APPLY Q
                 WHERE Q.HEAT_PLAN_NO = T.HEAT_PLAN_NO
                   AND Q.PROCESS_CODE = 'G'
                   AND Q.BATCH_NO = P.PHY_BATCH_NO
                   AND Q.APPLY_FLAG = '0') SPZ,
               (SELECT SUM(Q.ACT_WEIGHT)
                  FROM QCM_ZG_JUGDE_APPLY Q
                 WHERE Q.HEAT_PLAN_NO = T.HEAT_PLAN_NO
                   AND Q.PROCESS_CODE = 'G'
                   AND Q.BATCH_NO = P.PHY_BATCH_NO
                   AND Q.APPLY_FLAG = '0') SPD,
               CASE
                 WHEN (SELECT COUNT(1)
                         FROM QCM_ZG_JUGDE_APPLY Q
                        WHERE (Q.INSTANCY_FLAG = '1' OR
                              Q.TOL_INSTANCY_FLAG = '1')
                          AND Q.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO
                          AND (Q.JUDGE_RESULT IS NULL OR
                              Q.JUDGE_RESULT = '不合格')) > 0 THEN
                  '是'
                 ELSE
                  '否'
               END IS_FLAG,
               CASE
                 WHEN SUM(CASE
                            WHEN P.MAT_STATUS = '00' OR P.MAT_STATUS = '20' THEN
                             P.ACT_COUNT
                            ELSE
                             0
                          END) > (SELECT SUM(Q.ACT_COUNT)
                                    FROM QCM_ZG_JUGDE_APPLY Q
                                   WHERE Q.HEAT_PLAN_NO = T.HEAT_PLAN_NO
                                     AND Q.PROCESS_CODE = 'G'
                                     AND Q.BATCH_NO = P.PHY_BATCH_NO
                                     AND Q.APPLY_FLAG = '0') THEN
                  ''
                 ELSE
                  (SELECT MIN(CASE
                                WHEN Q.IS_FLAG = '0' AND
                                     Q.IS_ALL_SCRAP IN ('0', '2') AND
                                     ((Q.VALIDFLAG = '20' AND
                                     Q.JUDGE_RESULT_CODE IN
                                     ('40740701', '40740709')) OR
                                     Q.INSTANCY_FLAG = '1') THEN
                                 '通过'
                                ELSE
                                 ''
                              END)
                     FROM QCM_ZG_JUGDE_APPLY Q
                    WHERE Q.HEAT_PLAN_NO = T.HEAT_PLAN_NO
                      AND Q.PROCESS_CODE = 'G'
                      AND Q.BATCH_NO = P.PHY_BATCH_NO
                      AND Q.APPLY_FLAG = '0'
                      AND Q.IS_ALL_SCRAP <> '2')
               END VALIDFLAG,
               MAX(T.WAITING_DECISION_MEMO) WAITING_DECISION_MEMO,
               MAX(T.Memo2) Memo2 ,
               (SELECT SUM(R.OFFLINE_NUM - R.RE_NUM - R.GROUP_NUM)
                  FROM MCH_OFFLINE_RESULT R
                 WHERE R.HEAT_PLAN_NO = T.HEAT_PLAN_NO
                   AND R.BATCH_NO = P.PHY_BATCH_NO
                   AND R.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO) LXZ,
               (SELECT SUM(R.OFFLINE_WT - R.RE_WT - R.GROUP_WT)
                  FROM MCH_OFFLINE_RESULT R
                 WHERE R.HEAT_PLAN_NO = T.HEAT_PLAN_NO
                   AND R.BATCH_NO = P.PHY_BATCH_NO
                   AND R.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO) LXD,
               (SELECT SUM(R.GROUP_NUM)
                  FROM MCH_OFFLINE_RESULT R
                 WHERE R.HEAT_PLAN_NO = T.HEAT_PLAN_NO
                   AND R.BATCH_NO = P.PHY_BATCH_NO
                   AND R.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO) ZLZ
          from PLN_ZY_JGX_M t,
               (SELECT T1.HEAT_PLAN_NO, T1.JUDGE_STOVE_NO, MAX(T1.LOAD_TIME) LOAD_TIME
                  FROM MCH_LOADING_RESULT T1
                 WHERE 1 = 1 #LOAD_TIME#
                 GROUP BY T1.HEAT_PLAN_NO, T1.JUDGE_STOVE_NO) T1,
               PORT_MCH_BATCH_SAMPLE_RESULT P
         WHERE T.HEAT_PLAN_NO = T1.HEAT_PLAN_NO(+)
           AND P.VALIDFLAG = '1'
           AND T.HEAT_PLAN_NO = P.HEAT_PLAN_NO #LOAD_TIME# #SOMETHING#
         GROUP BY T1.LOAD_TIME,
                  T.HEAT_PLAN_NO,
                  T.HEAT_PLAN_NO,
                  T.PLINE_CODE,
                  T.PLINE_NAME,
                  T.DECISION,
                  T.ORDER_NO,
                  T.ORDER_SEQ,
                  T.IF_MONITOR,
                  T.ZY_BATCH_ID,
                  T.JUDGE_STOVE_NO,
                  P.PHY_BATCH_NO
         ORDER BY T1.LOAD_TIME) AA,
       (select M.HEAT_PLAN_NO,
               M.JUDGE_STOVE_NO,
               M.BATCH_NO,
               M.PLINE_CODE,
               MAX(M.INSTOCK_TIME) INSTOCK_TIME,
               SUM(M.ACT_COUNT) XXZ,
               SUM(M.ACT_WEIGHT) XXD
          from MAT_BC_M M
         WHERE M.HEAT_PLAN_NO IN
               (SELECT T1.HEAT_PLAN_NO
                  FROM MCH_LOADING_RESULT T1
                 WHERE 1 = 1 #LOAD_TIME#
                 GROUP BY T1.HEAT_PLAN_NO)
           AND M.QCM_STAUS = '00'
         GROUP BY M.HEAT_PLAN_NO, M.PLINE_CODE, M.JUDGE_STOVE_NO, M.BATCH_NO
        
        UNION ALL
        select M.HEAT_PLAN_NO,
               M.JUDGE_STOVE_NO,
               M.BATCH_NO,
               M.PLINE_CODE,
               MAX(M.INSTOCK_TIME) INSTOCK_TIME,
               SUM(M.ACT_COUNT) XXZ,
               SUM(M.ACT_WEIGHT) XXD
          from MAT_BC_BACKUP M
         WHERE M.HEAT_PLAN_NO IN
               (SELECT T1.HEAT_PLAN_NO
                  FROM MCH_LOADING_RESULT T1
                 WHERE 1 = 1 #LOAD_TIME#
                 GROUP BY T1.HEAT_PLAN_NO)
           AND M.QCM_STAUS = '00'
         GROUP BY M.HEAT_PLAN_NO, M.PLINE_CODE, M.JUDGE_STOVE_NO, M.BATCH_NO) M,
       (select DISTINCT N.JUDGE_STOVE_NO, N.BATCH_NO, '打捆' BUNDLING_NUM
          from HTT_ENTRUST_RESULT N
         WHERE N.BUNDLING_NUM > 0) N,
       (select DISTINCT P.JUDGE_STOVE_NO,
                        P.BATCH_NO,
                        LISTAGG(P.MEMO || ':' ||
                                SUM(NVL(P.OFFLINE_NUM, 0) - NVL(P.RE_NUM, 0)) || '支',
                                ',') WITHIN GROUP(ORDER BY P.JUDGE_STOVE_NO, P.BATCH_NO) OVER(PARTITION BY P.JUDGE_STOVE_NO, P.BATCH_NO) MEMO
          from MCH_OFFLINE_RESULT P
         where P.OFFLINE_NUM - P.RE_NUM > 0
        --AND P.JUDGE_STOVE_NO = '699362'
         GROUP BY P.JUDGE_STOVE_NO, P.BATCH_NO, P.MEMO) P
 WHERE AA.HEAT_PLAN_NO = M.HEAT_PLAN_NO(+)
   AND AA.JUDGE_STOVE_NO = M.JUDGE_STOVE_NO(+)
   AND AA.BATCH_NO = M.BATCH_NO(+)
   AND AA.PLINE_CODE = M.PLINE_CODE(+)
   AND AA.JUDGE_STOVE_NO = P.JUDGE_STOVE_NO(+)
   AND AA.BATCH_NO = P.BATCH_NO(+)
   AND AA.JUDGE_STOVE_NO = N.JUDGE_STOVE_NO(+)
   AND AA.BATCH_NO = N.BATCH_NO(+) #VALIDFLAG#
]]>
</query>

<query id = "FrmMilDateStatistics.saveVrpWaitingDecision" desc = "保存镦拔扩待判原因">
<![CDATA[
UPDATE PLN_ZY_DBK_M T
   SET T.WAITING_DECISION_MEMO = ?, T.IS_VISIBLE = ? 
 WHERE T.JUDGE_STOVE_NO = ?
   AND T.HEAT_PLAN_NO = ?
]]>
</query>

<query id = "FrmMilDateStatistics.saveHttWaitingDecision" desc = "保存热处理待判原因">
<![CDATA[
UPDATE PLN_ZY_RCL_M T
   SET T.WAITING_DECISION_MEMO = ?, T.IS_VISIBLE = ?
 WHERE T.JUDGE_STOVE_NO = ?
   AND T.HEAT_PLAN_NO = ?
]]>
</query>

<query id = "FrmMilDateStatistics.saveMchWaitingDecision" desc = "保存加工线待判原因">
<![CDATA[
UPDATE PLN_ZY_JGX_M T
   SET T.WAITING_DECISION_MEMO = ?, T.IS_VISIBLE = ? ,T.MEMO2 = ?
 WHERE T.JUDGE_STOVE_NO = ?
   AND T.HEAT_PLAN_NO = ?
]]>
</query>

<query id = "FrmMilDateStatistics.getMilStaProductRateZG" desc = "查询各工序成材率-轧管">
<![CDATA[
SELECT *
  FROM (select t.judge_stove_no,
               T.JUGDE_APPLY_CODE,
               t.lot_no,
               t.pro_order_no,
               t.pline_code,
               t.pline_name,
               t.producname,
               t.steelname,
               t.GRADENAME,
               t.spec_name,
               t.model_desc,
               t.std_name,
               t.target,
               MAX(T2.INWL_ID) INWL_ID,
               MAX(T2.INWL_DESC) INWL_DESC,
               MAX(T2.OUTWL_ID) OUTWL_ID,
               MAX(T2.OUTWL_DESC) OUTWL_DESC,
               MAX(T1.PIPE_SECTION) PIPE_SECTION,
               MAX(T1.TUBE_TYPE) TUBE_TYPE,
               MAX(T1.TUBE_SUORCE) TUBE_SUORCE,
               
               TO_CHAR(max(t.JUDGE_RESULT_TIME), 'YYYY-MM-DD') JUDGE_RESULT_TIME,
               SUM(DECODE(t.ACT_WEIGHT,
                          NULL,
                          t.ACT_THEORY_WEIGHT,
                          t.ACT_WEIGHT)) HGD,
               sum(t.INPUT_WEIGHT) INPUT_WEIGHT,
               sum(t.OUTPUT_WEIGHT) OUTPUT_WEIGHT,
               ROUND(SUM(DECODE(t.ACT_WEIGHT,
                                NULL,
                                t.ACT_THEORY_WEIGHT,
                                t.ACT_WEIGHT)) * 100 / sum(t.OUTPUT_WEIGHT),
                     2)  OK_RATE
        
          from QCM_ZG_JUGDE_APPLY t, MIL_PLAN T1, PLN_ZY_ZG_M T2
         where T.IS_FLAG = '0'
           AND T.IS_ALL_SCRAP IN ('0', '1', '2')
           AND ((T.VALIDFLAG = '20' AND
               T.JUDGE_RESULT_CODE IN ('40740701', '40740705', '40740709')) OR
               T.INSTANCY_FLAG = '1')
           AND T.PROCESS_CODE = 'D'
           AND T.JUDGE_STOVE_NO = REGEXP_REPLACE(T1.JUDGE_STOVE_NO, '-.*', '')
           AND T.JUDGE_STOVE_NO = T2.FEED_HEAT_NO(+)
           AND T2.PLANSTATUS = '40'
           AND SUBSTR(T1.JUDGE_STOVE_NO, -2) = '01' #SOMETHING#
         group by t.judge_stove_no,
                  T.JUGDE_APPLY_CODE,
                  t.lot_no,
                  t.pro_order_no,
                  t.pline_code,
                  t.pline_name,
                  t.producname,
                  t.steelname,
                  t.GRADENAME,
                  t.spec_name,
                  t.model_desc,
                  t.std_name,
                  t.target
         order by T.PLINE_CODE, t.judge_stove_no, T.JUGDE_APPLY_CODE)
 WHERE OUTPUT_WEIGHT > 0
]]>
</query>

<query id = "FrmMilDateStatistics.getMilStaProductRateBC" desc = "查询各工序成材率-半成品">
<![CDATA[
SELECT *
  FROM (select t.judge_stove_no,
               T.JUGDE_APPLY_CODE,
               t.lot_no,
               t.pro_order_no,
               t.pline_code,
               t.pline_name,
               t.producname,
               t.steelname,
               t.GRADENAME,
               t.spec_name,
               t.model_desc,
               t.std_name,
               t.target,
               MAX(T2.INWL_ID) INWL_ID,
               MAX(T2.INWL_DESC) INWL_DESC,
               MAX(T2.OUTWL_ID) OUTWL_ID,
               MAX(T2.OUTWL_DESC) OUTWL_DESC,
               TO_CHAR(max(t.JUDGE_RESULT_TIME), 'YYYY-MM-DD') JUDGE_RESULT_TIME,
               SUM(DECODE(t.ACT_WEIGHT,
                          NULL,
                          t.ACT_THEORY_WEIGHT,
                          t.ACT_WEIGHT)) HGD,
               SUM(t.OUTPUT_WEIGHT) OUTPUT_WEIGHT,
               ROUND(SUM(DECODE(t.ACT_WEIGHT,
                                NULL,
                                t.ACT_THEORY_WEIGHT,
                                t.ACT_WEIGHT)) * 100 / SUM(t.INPUT_WEIGHT),
                     2)|| '%' OK_RATE
        
          from QCM_ZG_JUGDE_APPLY t, #TABLE# T2
         where T.IS_FLAG = 0
           AND T.APPLY_FLAG = 0
           AND T.VALIDFLAG = '20'
           AND T.HEAT_PLAN_NO = T2.HEAT_PLAN_NO
           AND (T.JUDGE_RESULT_CODE = '40740701' OR T.IS_ALL_SCRAP > 0)
           AND T.JUDGE_STOVE_NO = T2.JUDGE_STOVE_NO #SOMETHING#
         group by t.judge_stove_no,
                  T.JUGDE_APPLY_CODE,
                  t.lot_no,
                  t.pro_order_no,
                  t.pline_code,
                  t.pline_name,
                  t.producname,
                  t.steelname,
                  t.GRADENAME,
                  t.spec_name,
                  t.model_desc,
                  t.std_name,
                  t.target
         order by T.PLINE_CODE, t.judge_stove_no, T.JUGDE_APPLY_CODE)
 WHERE OUTPUT_WEIGHT > 0
]]>
</query>

<query id = "FrmMilDateStatistics.getMilStaProductRateBCNew" desc = "查询各工序成材率-半成品">
<![CDATA[
SELECT *
  FROM (select t.pline_code,
               t.pline_name,
               T2.INWL_ID,
               T2.INWL_DESC,
               T2.OUTWL_ID,
               T2.OUTWL_DESC,
               SUM(DECODE(t.ACT_WEIGHT,
                          NULL,
                          t.ACT_THEORY_WEIGHT,
                          t.ACT_WEIGHT)) HGD,
               SUM(t.OUTPUT_WEIGHT) OUTPUT_WEIGHT,
               ROUND(SUM(DECODE(t.ACT_WEIGHT,
                                NULL,
                                t.ACT_THEORY_WEIGHT,
                                t.ACT_WEIGHT)) * 100 / SUM(T.INPUT_WEIGHT),
                     2)  OK_RATE
        
          from QCM_ZG_JUGDE_APPLY t, #TABLE# T2
         where T.IS_FLAG = 0
           AND T.APPLY_FLAG = 0
           AND T.VALIDFLAG = '20'
           AND T2.PLANSTATUS = '40'
           AND T2.IF_FLAG = '0'
           AND T.HEAT_PLAN_NO = T2.HEAT_PLAN_NO
           AND (T.JUDGE_RESULT_CODE = '40740701' OR T.IS_ALL_SCRAP > 0)
           AND T.JUDGE_STOVE_NO = T2.JUDGE_STOVE_NO
        --AND T.BAL_YEAR_MONTH = '201904'
         #SOMETHING#
         group by t.pline_code,
                  t.pline_name,
                  T2.INWL_ID,
                  T2.INWL_DESC,
                  T2.OUTWL_ID,
                  T2.OUTWL_DESC)
 WHERE OUTPUT_WEIGHT > 0
]]>
</query>

<query id = "FrmMilDateStatistics.getMilStaProductRateBCNew2" desc = "查询各工序成材率-半成品">
<![CDATA[
select t.pline_code,
       t.pline_name,
       T2.INWL_ID,
       T2.INWL_DESC,
       T2.OUTWL_ID,
       T2.OUTWL_DESC,
       SUM(DECODE(t.ACT_WEIGHT, NULL, t.ACT_THEORY_WEIGHT, t.ACT_WEIGHT)) HGD,
       SUM(DECODE(t.ACT_WEIGHT, NULL, t.ACT_THEORY_WEIGHT, t.ACT_WEIGHT)) +
       SUM(NVL(T3.ACT_THEORY_WEIGHT, 0)) OUTPUT_WEIGHT,
       ROUND(SUM(DECODE(t.ACT_WEIGHT,
                        NULL,
                        t.ACT_THEORY_WEIGHT,
                        t.ACT_WEIGHT)) * 100 /
             (SUM(DECODE(t.ACT_WEIGHT,
                         NULL,
                         t.ACT_THEORY_WEIGHT,
                         t.ACT_WEIGHT)) + SUM(NVL(T3.ACT_THEORY_WEIGHT, 0))),
             2) OK_RATE

  from QCM_ZG_JUGDE_APPLY t,
       #TABLE# T2,
       (SELECT T3.JUDGE_STOVE_NO,
               T3.PHY_BATCH_NO,
               T3.HEAT_PLAN_NO,
               T3.BAL_YEAR_MONTH,
               SUM(T3.ACT_THEORY_WEIGHT) ACT_THEORY_WEIGHT
          FROM #TABLE2# T3
         WHERE T3.MAT_STATUS IN ('10', '40')
         --AND T3.VALIDFLAG = '1'
         #SOMETHING1#
         GROUP BY T3.JUDGE_STOVE_NO, T3.PHY_BATCH_NO, T3.BAL_YEAR_MONTH,T3.HEAT_PLAN_NO) T3
 where T.IS_FLAG = 0
   AND T.APPLY_FLAG = 0
   AND T.VALIDFLAG = '20'
   AND T2.PLANSTATUS = '40'
   AND T2.IF_FLAG = '0'
   AND T.HEAT_PLAN_NO = T2.HEAT_PLAN_NO
   AND (T.JUDGE_RESULT_CODE = '40740701' OR T.IS_ALL_SCRAP > 0)
   AND T.JUDGE_STOVE_NO = T2.JUDGE_STOVE_NO
   AND T.HEAT_PLAN_NO = T3.HEAT_PLAN_NO(+)
   AND T.JUDGE_STOVE_NO = T3.JUDGE_STOVE_NO(+)
   AND T.BATCH_NO = T3.PHY_BATCH_NO(+)
   AND T2.PLANSTATUS = '40'
--AND T.BAL_YEAR_MONTH = '201904'
 #SOMETHING#
 group by t.pline_code,
          t.pline_name,
          T2.INWL_ID,
          T2.INWL_DESC,
          T2.OUTWL_ID,
          T2.OUTWL_DESC
]]>
</query>

<query id = "FrmMilDateStatistics.getMilStaProductRateDBK" desc = "查询各工序成材率-镦拔扩">
<![CDATA[
SELECT *
  FROM (select t.pline_code,
               t.pline_name,
               
               T2.INWL_ID,
               T2.INWL_DESC,
               T2.OUTWL_ID,
               T2.OUTWL_DESC,
               
               SUM(DECODE(t.ACT_WEIGHT,
                          NULL,
                          t.ACT_THEORY_WEIGHT,
                          t.ACT_WEIGHT)) HGD,
               SUM(t.OUTPUT_WEIGHT) OUTPUT_WEIGHT,
               ROUND(SUM(DECODE(t.ACT_WEIGHT,
                                NULL,
                                t.ACT_THEORY_WEIGHT,
                                t.ACT_WEIGHT)) * 100 / SUM(t.INPUT_WEIGHT),
                     2) || '%' OK_RATE
        
          from QCM_ZG_JUGDE_APPLY t, PLN_ZY_DBK_M T2
         where T.IS_FLAG = 0
           AND T.APPLY_FLAG = 0
           AND T.VALIDFLAG = '20'
           AND T.HEAT_PLAN_NO = T2.HEAT_PLAN_NO
           AND (T.JUDGE_RESULT_CODE = '40740701' OR T.IS_ALL_SCRAP > 0)
           AND T.JUDGE_STOVE_NO = T2.JUDGE_STOVE_NO
        --AND T.BAL_YEAR_MONTH = '201904'
         #SOMETHING#
         group by t.pline_code,
                  t.pline_name,
                  T2.INWL_ID,
                  T2.INWL_DESC,
                  T2.OUTWL_ID,
                  T2.OUTWL_DESC)
 WHERE OUTPUT_WEIGHT > 0
]]>
</query>

<query id = "FrmMilDateStatistics.InspectionReportGoDown" desc = "探伤报告查询（批量下载）">
<![CDATA[
	select t.* from QCM_INSPECTION_REPORT t WHERE 1=1 
]]>
</query>

<query id = "FrmMilDateStatistics.getBcControlLog" desc = "查询小时能力（镦拔扩、热处理、加工）">
<![CDATA[
SELECT S.PLINE_CODE,
       S.PLINE_NAME,
       S.INWL_ID,
       S.INWL_DESC,
       S.OUTWL_ID,
       S.OUTWL_DESC,
       SUM(S.QUALIFIED_NUM) QUALIFIED_NUM,
       SUM(S.QUALIFIED_WT) QUALIFIED_WT,
       SUM(S.SJ) SJ,
       DECODE(SUM(S.SJ), 0, 0, ROUND(SUM(S.QUALIFIED_NUM) * 60 / SUM(S.SJ))) XSJZ
  FROM (select T.PLINE_CODE,
               T.PLINE_NAME,
               T.LOGS_BEG,
               T.LOGS_END,
               ROUND(DECODE(T.LOGS_END,
                            NULL,
                            '',
                            TO_DATE(T.LOGS_END, 'YYYY-MM-DD HH24:MI') -
                            TO_DATE(T.LOGS_BEG, 'YYYY-MM-DD HH24:MI')) * 24 * 60) SJ,
               T1.INWL_ID,
               T1.INWL_DESC,
               T1.OUTWL_ID,
               T1.OUTWL_DESC,
               T.QUALIFIED_NUM,
               T.QUALIFIED_WT
        
          from HTT_CONTROL_LOG t, #TABLE# T1
         WHERE T.HEAT_PLAN_NO = T1.HEAT_PLAN_NO
           AND T.PRO_TYPE = '1'
           AND T.CONFIRM_FLAG = '1'
        --AND T.BAL_YEAR_MONTH = '201904'
         #SOMETHING#) S
 GROUP BY S.PLINE_CODE,
          S.PLINE_NAME,
          S.INWL_ID,
          S.INWL_DESC,
          S.OUTWL_ID,
          S.OUTWL_DESC
 ORDER BY S.PLINE_CODE, S.INWL_ID, S.OUTWL_ID
]]>
</query>

<query id = "FrmMilDateStatistics.updateBcControlLog" desc = "回报小时能力（镦拔扩、热处理、加工）">
<![CDATA[
DECLARE
  V_HR_CAPCTY SLM_BASE_MATERIAL_D_PL.HR_CAPCTY%type := ?;
  V_NUM       SLM_BASE_MATERIAL_D_PL.PLINE_LEVEL%type := ?;
BEGIN
  UPDATE #TABLE# T
     SET T.HR_CAPCTY = DECODE(T.HR_CAPCTY,
                              '',
                              V_HR_CAPCTY,
                              '99.99',
                              V_HR_CAPCTY,
                              (5000 * T.HR_CAPCTY + V_NUM * V_HR_CAPCTY) /
                              (5000 + V_NUM))
   WHERE T.IN_MATERIAL_NO = ?
     AND T.OUT_MATERIAL_NO = ?
     AND T.PLINE_CODE = ?;
END;
]]>
</query>

<query id = "FrmMilDateStatistics.getMilInitalZg" desc = "查询轧管期初表">
<![CDATA[
select initial_id,
       judge_stove_no,
       batch_no,
       batch_groud_no,
       (SELECT C.BASENAME
          FROM COM_BASE_INFO C
         WHERE C.BASECODE = T.PRODUCT_FLAG) PRODUCT_FLAG,
       (SELECT D.BASENAME
          FROM COM_BASE_INFO D
         WHERE D.BASECODE = T.MAT_STATUS) MAT_STATUS,
       material_no,
       material_name,
       produccode,
       producname,
       steelcode,
       steelname,
       spec_code,
       spec_name,
       model_code,
       model_desc,
       std_code,
       std_name,
       std_style,
       std_style_desc,
       dimater,
       height,
       len,
       len_min,
       len_max,
       act_count,
       act_weight,
       act_theory_weight,
       storage_no,
       storage_name,
       location_no,
       pro_order_no,
       pro_order_id,
       ord_pk,
       ord_ln_pk,
       ord_ln_dly_pk,
       order_no,
       order_seq,
       order_seq_no,
       department_code,
       department_desc,
       management_no,
       management_name,
       memo,
       create_name,
       create_time,
       original_date,
       bal_year_month,
       gradecode,
       gradename,
       pline_code,
       pline_name,
       handle_log,
       instock_time,
       belong_code,
       belong_name,
       gp_dimater,
       gp_len,
       pass_code,
       pass_name,
       lot_no,
       tube_type,
       tube_suorce,
       pipe_section
  from ydm_zc_initial_zg T
 WHERE 1 = 1

]]>
</query>

<query id = "FrmMilDateStatistics.doQueryZyJgxM" desc = "查询加工线计划">
<![CDATA[
select t.*
  from PLN_ZY_JGX_M t, MCH_LOADING_RESULT T1
 WHERE T.HEAT_PLAN_NO = T1.HEAT_PLAN_NO 
]]>
</query>

<query id = "FrmMilDateStatistics.doQueryPortMchBatchSampleResult" desc = "查询加工线进程表">
<![CDATA[
select t.*
  from PORT_MCH_BATCH_SAMPLE_RESULT t
 WHERE T.TR_FLAG = '1'
   AND T.VALIDFLAG = '1'
]]>
</query>

<query id = "FrmMilDateStatistics.doRefresh" desc = "刷新">
<![CDATA[
DECLARE
  V_COUNT MIL_PROCESSES.YJZ%TYPE := NULL;
BEGIN
  FOR MYROW IN (SELECT AA.*,
                       CASE
                         WHEN AA.NODE_STATUS < 20 THEN
                          0
                         ELSE
                          AA.HGZ1 - AA.FPZ2
                       END HGZ2,
                       CASE
                         WHEN AA.NODE_STATUS < 20 THEN
                          0
                         ELSE
                          AA.HGD1 - AA.FPD2
                       END HGD2,
                      
                       CASE
                         WHEN AA.NODE_STATUS < 30 THEN
                          0
                         ELSE
                          AA.HGZ1 - AA.FPZ2 - AA.FPZ3
                       END HGZ3,
                       CASE
                         WHEN AA.NODE_STATUS < 30 THEN
                          0
                         ELSE
                          AA.HGD1 - AA.FPD2 - AA.FPD3
                       END HGD3,
                      
                       CASE
                         WHEN AA.NODE_STATUS < 40 THEN
                          0
                         ELSE
                          AA.HGZ1 - AA.FPZ2 - AA.FPZ3 - AA.FPZ4
                       END HGZ4,
                       CASE
                         WHEN AA.NODE_STATUS < 40 THEN
                          0
                         ELSE
                          AA.HGD1 - AA.FPD2 - AA.FPD3 - AA.FPD4
                       END HGD4,
                      
                       CASE
                         WHEN AA.NODE_STATUS < 50 THEN
                          0
                         ELSE
                          AA.HGZ1 - AA.FPZ2 - AA.FPZ3 - AA.FPZ4 - AA.FPZ5
                       END HGZ5,
                       CASE
                         WHEN AA.NODE_STATUS < 50 THEN
                          0
                         ELSE
                          AA.HGD1 - AA.FPD2 - AA.FPD3 - AA.FPD4 - AA.FPD5
                       END HGD5,
                      
                       CASE
                         WHEN AA.NODE_STATUS < 60 THEN
                          0
                         ELSE
                          AA.HGZ1 - AA.FPZ2 - AA.FPZ3 - AA.FPZ4 - AA.FPZ5 -
                          AA.FPZ6
                       END HGZ6,
                       CASE
                         WHEN AA.NODE_STATUS < 60 THEN
                          0
                         ELSE
                          AA.HGD1 - AA.FPD2 - AA.FPD3 - AA.FPD4 - AA.FPD5 -
                          AA.FPD6
                       END HGD6,
                      
                       CASE
                         WHEN AA.NODE_STATUS < 80 THEN
                          0
                         ELSE
                          AA.HGZ7 - AA.FPZ9 - AA.XXZ9 - AA.ZLZ9
                       END HGZ9,
                       CASE
                         WHEN AA.NODE_STATUS < 80 THEN
                          0
                         ELSE
                          AA.HGD7 - AA.FPD9 - AA.XXD9 - AA.ZLD9
                       END HGD9,
                      
                       CASE
                         WHEN AA.NODE_STATUS < 90 THEN
                          0
                         ELSE
                          AA.HGZ7 - AA.FPZ9 - AA.XXZ9 - AA.FPZ10 - AA.XXZ10 -
                          AA.ZLZ10
                       END HGZ10,
                       CASE
                         WHEN AA.NODE_STATUS < 90 THEN
                          0
                         ELSE
                          AA.HGD7 - AA.FPD9 - AA.XXD9 - AA.FPD10 - AA.XXD10 -
                          AA.ZLD10
                       END HGD10,
                      
                       CASE
                         WHEN AA.NODE_STATUS < 96 THEN
                          0
                         ELSE
                          AA.HGZ7 - AA.FPZ9 - AA.XXZ9 - AA.FPZ10 - AA.XXZ10 -
                          AA.FPZ11 - AA.XXZ11 - AA.ZLZ11
                       END HGZ11,
                       CASE
                         WHEN AA.NODE_STATUS < 96 THEN
                          0
                         ELSE
                          AA.HGD7 - AA.FPD9 - AA.XXD9 - AA.FPD10 - AA.XXD10 -
                          AA.FPD11 - AA.XXD11 - AA.ZLD11
                       END HGD11,
                       CASE AA.NODE_STATUS
                         WHEN '10' THEN
                          '锯切完成'
                         WHEN '20' THEN
                          '出炉'
                         WHEN '30' THEN
                          '穿孔完成'
                         WHEN '40' THEN
                          '连轧完成'
                         WHEN '50' THEN
                          '出再加热炉'
                         WHEN '60' THEN
                          '出定径'
                         WHEN '70' THEN
                          '分切完成'
                         WHEN '80' THEN
                          '矫直完成'
                         WHEN '90' THEN
                          '探伤完成'
                         WHEN '96' THEN
                          '质检完成'
                         WHEN '99' THEN
                          '下线'
                       END NODE_STATUS1
               
                  FROM (select REGEXP_REPLACE(T1.JUDGE_STOVE_NO, '-.*', '') JUDGE_STOVE_NO,
                               T1.ID,
                               T1.LOT_NO,
                               T1.PLINE_CODE,
                               (SELECT A.PLINE_NAME
                                  FROM COM_BASE_PLINE A
                                 WHERE A.PLINE_CODE = T1.PLINE_CODE) PLINE_CODE1,
                               T1.CONTRACT_NO,
                               MAX(T1.TARGET) TARGET,
                               MAX(T1.VARIETIES) VARIETIES,
                               MAX(T1.VARIETIES_CODE) VARIETIES_CODE,
                               MAX(T1.STEELNAME) STEELNAME,
                               MAX(T1.STEELCODE) STEELCODE,
                               MAX(T1.GRADENAME) GRADENAME,
                               MAX(T1.GRADECODE) GRADECODE,
                               REPLACE(MAX(T1.PIPE_SIZE), '*', 'x') PIPE_SIZE,
                               MAX(T1.PIPE_SIZE_CODE) PIPE_SIZE_CODE,
                               MAX(T1.BUCKLE_TYPE) BUCKLE_TYPE,
                               MAX(T1.BUCKLE_TYPE_CODE) BUCKLE_TYPE_CODE,
                               MAX(T1.LENGTH_RANGE) LENGTH_RANGE,
                               MAX(T1.ROLL_STANDRAD) ROLL_STANDRAD,
                               MIN(T1.FEED_TIME) FEED_TIME,
                              
                               --MAX(T1.NODE_STATUS) NODE_STATUS,
                               MAX(T1.PRO_PLAN_ID) PRO_PLAN_ID,
                               MAX(T1.GX_PLAN_NO) GX_PLAN_NO,
                              
                               (SELECT MAX(NODE_STATUS)
                                  FROM MIL_PLAN
                                 WHERE ID = T1.ID) NODE_STATUS,
                              
                               (SELECT count(1)
                                  from (SELECT B.JUDGE_STOVE_NO,
                                               B.m_mat_no,
                                               SUM(B.ACT_THEORY_WEIGHT) ACT_THEORY_WEIGHT
                                          FROM PORT_MIL_BATCH_SAMPLE_RESULT B
                                         WHERE B.IS_VALID = '1'
                                           AND (TRIM(B.Op_Process) != '0' OR
                                               B.Op_Process IS NULL)
                                         group by B.m_mat_no, B.JUDGE_STOVE_NO) A
                                 WHERE A.JUDGE_STOVE_NO = T1.JUDGE_STOVE_NO
                                 GROUP BY A.JUDGE_STOVE_NO) HGZ1,
                              
                               (SELECT SUM(A.ACT_THEORY_WEIGHT)
                                  from (SELECT B.JUDGE_STOVE_NO,
                                               B.m_mat_no,
                                               SUM(B.ACT_THEORY_WEIGHT) ACT_THEORY_WEIGHT
                                          FROM PORT_MIL_BATCH_SAMPLE_RESULT B
                                         WHERE B.IS_VALID = '1'
                                           AND (TRIM(B.Op_Process) != '0' OR
                                               B.Op_Process IS NULL)
                                         group by B.m_mat_no, B.JUDGE_STOVE_NO) A
                                 WHERE A.JUDGE_STOVE_NO = T1.JUDGE_STOVE_NO
                                 GROUP BY A.JUDGE_STOVE_NO) HGD1,
                              
                               (select COUNT(1)
                                  from (select B.JUDGE_STOVE_NO,
                                               TRIM(B.OP_PROCESS) OP_PROCESS,
                                               B.m_mat_no,
                                               SUM(B.ACT_THEORY_WEIGHT) ACT_THEORY_WEIGHT
                                          from PORT_MIL_BATCH_SAMPLE_RESULT B
                                         WHERE B.IS_VALID = '1'
                                           AND B.STATUS = '1'
                                         group by B.JUDGE_STOVE_NO,
                                                  B.m_mat_no,
                                                  B.op_process) A
                                 WHERE A.JUDGE_STOVE_NO = T1.JUDGE_STOVE_NO
                                   AND A.OP_PROCESS = '0') FPZ1,
                              
                               NVL((select SUM(A.ACT_THEORY_WEIGHT)
                                     from (select B.JUDGE_STOVE_NO,
                                                  TRIM(B.OP_PROCESS) OP_PROCESS,
                                                  B.m_mat_no,
                                                  SUM(B.ACT_THEORY_WEIGHT) ACT_THEORY_WEIGHT
                                             from PORT_MIL_BATCH_SAMPLE_RESULT B
                                            WHERE B.IS_VALID = '1'
                                              AND B.STATUS = '1'
                                            group by B.JUDGE_STOVE_NO,
                                                     B.m_mat_no,
                                                     B.op_process) A
                                    WHERE A.JUDGE_STOVE_NO =
                                          T1.JUDGE_STOVE_NO
                                      AND A.OP_PROCESS = '0'),
                                   0) FPD1,
                              
                               (select COUNT(1)
                                  from (select B.JUDGE_STOVE_NO,
                                               TRIM(B.OP_PROCESS) OP_PROCESS,
                                               B.m_mat_no,
                                               SUM(B.ACT_THEORY_WEIGHT) ACT_THEORY_WEIGHT
                                          from PORT_MIL_BATCH_SAMPLE_RESULT B
                                         WHERE B.IS_VALID = '1'
                                           AND B.STATUS = '1'
                                         group by B.JUDGE_STOVE_NO,
                                                  B.m_mat_no,
                                                  B.op_process) A
                                 WHERE A.JUDGE_STOVE_NO = T1.JUDGE_STOVE_NO
                                   AND A.OP_PROCESS = '2') FPZ2,
                              
                               NVL((select SUM(A.ACT_THEORY_WEIGHT)
                                     from (select B.JUDGE_STOVE_NO,
                                                  TRIM(B.OP_PROCESS) OP_PROCESS,
                                                  B.m_mat_no,
                                                  SUM(B.ACT_THEORY_WEIGHT) ACT_THEORY_WEIGHT
                                             from PORT_MIL_BATCH_SAMPLE_RESULT B
                                            WHERE B.IS_VALID = '1'
                                              AND B.STATUS = '1'
                                            group by B.JUDGE_STOVE_NO,
                                                     B.m_mat_no,
                                                     B.op_process) A
                                    WHERE A.JUDGE_STOVE_NO =
                                          T1.JUDGE_STOVE_NO
                                      AND A.OP_PROCESS = '2'),
                                   0) FPD2,
                              
                               (select COUNT(1)
                                  from (select B.JUDGE_STOVE_NO,
                                               TRIM(B.OP_PROCESS) OP_PROCESS,
                                               B.m_mat_no,
                                               SUM(B.ACT_THEORY_WEIGHT) ACT_THEORY_WEIGHT
                                          from PORT_MIL_BATCH_SAMPLE_RESULT B
                                         WHERE B.IS_VALID = '1'
                                           AND B.STATUS = '1'
                                         group by B.JUDGE_STOVE_NO,
                                                  B.m_mat_no,
                                                  B.op_process) A
                                 WHERE A.JUDGE_STOVE_NO = T1.JUDGE_STOVE_NO
                                   AND A.OP_PROCESS = '3') FPZ3,
                              
                               NVL((select SUM(A.ACT_THEORY_WEIGHT)
                                     from (select B.JUDGE_STOVE_NO,
                                                  TRIM(B.OP_PROCESS) OP_PROCESS,
                                                  B.m_mat_no,
                                                  SUM(B.ACT_THEORY_WEIGHT) ACT_THEORY_WEIGHT
                                             from PORT_MIL_BATCH_SAMPLE_RESULT B
                                            WHERE B.IS_VALID = '1'
                                              AND B.STATUS = '1'
                                            group by B.JUDGE_STOVE_NO,
                                                     B.m_mat_no,
                                                     B.op_process) A
                                    WHERE A.JUDGE_STOVE_NO =
                                          T1.JUDGE_STOVE_NO
                                      AND A.OP_PROCESS = '3'),
                                   0) FPD3,
                              
                               (select COUNT(1)
                                  from (select B.JUDGE_STOVE_NO,
                                               TRIM(B.OP_PROCESS) OP_PROCESS,
                                               B.m_mat_no,
                                               SUM(B.ACT_THEORY_WEIGHT) ACT_THEORY_WEIGHT
                                          from PORT_MIL_BATCH_SAMPLE_RESULT B
                                         WHERE B.IS_VALID = '1'
                                           AND B.STATUS = '1'
                                         group by B.JUDGE_STOVE_NO,
                                                  B.m_mat_no,
                                                  B.op_process) A
                                 WHERE A.JUDGE_STOVE_NO = T1.JUDGE_STOVE_NO
                                   AND A.OP_PROCESS = '4') FPZ4,
                              
                               NVL((select SUM(A.ACT_THEORY_WEIGHT)
                                     from (select B.JUDGE_STOVE_NO,
                                                  TRIM(B.OP_PROCESS) OP_PROCESS,
                                                  B.m_mat_no,
                                                  SUM(B.ACT_THEORY_WEIGHT) ACT_THEORY_WEIGHT
                                             from PORT_MIL_BATCH_SAMPLE_RESULT B
                                            WHERE B.IS_VALID = '1'
                                              AND B.STATUS = '1'
                                            group by B.JUDGE_STOVE_NO,
                                                     B.m_mat_no,
                                                     B.op_process) A
                                    WHERE A.JUDGE_STOVE_NO =
                                          T1.JUDGE_STOVE_NO
                                      AND A.OP_PROCESS = '4'),
                                   0) FPD4,
                              
                               (select COUNT(1)
                                  from (select B.JUDGE_STOVE_NO,
                                               TRIM(B.OP_PROCESS) OP_PROCESS,
                                               B.m_mat_no,
                                               SUM(B.ACT_THEORY_WEIGHT) ACT_THEORY_WEIGHT
                                          from PORT_MIL_BATCH_SAMPLE_RESULT B
                                         WHERE 1 = 1
                                           AND B.IS_VALID = '1'
                                           AND B.STATUS = '1'
                                         group by B.JUDGE_STOVE_NO,
                                                  B.m_mat_no,
                                                  B.op_process) A
                                 WHERE A.JUDGE_STOVE_NO = T1.JUDGE_STOVE_NO
                                   AND A.OP_PROCESS = '5') FPZ5,
                              
                               NVL((select SUM(A.ACT_THEORY_WEIGHT)
                                     from (select B.JUDGE_STOVE_NO,
                                                  TRIM(B.OP_PROCESS) OP_PROCESS,
                                                  B.m_mat_no,
                                                  SUM(B.ACT_THEORY_WEIGHT) ACT_THEORY_WEIGHT
                                             from PORT_MIL_BATCH_SAMPLE_RESULT B
                                            WHERE B.IS_VALID = '1'
                                              AND B.STATUS = '1'
                                            group by B.JUDGE_STOVE_NO,
                                                     B.m_mat_no,
                                                     B.op_process) A
                                    WHERE A.JUDGE_STOVE_NO =
                                          T1.JUDGE_STOVE_NO
                                      AND A.OP_PROCESS = '5'),
                                   0) FPD5,
                              
                               (select COUNT(1)
                                  from (select B.JUDGE_STOVE_NO,
                                               TRIM(B.OP_PROCESS) OP_PROCESS,
                                               B.m_mat_no,
                                               SUM(B.ACT_THEORY_WEIGHT) ACT_THEORY_WEIGHT
                                          from PORT_MIL_BATCH_SAMPLE_RESULT B
                                         WHERE B.IS_VALID = '1'
                                           AND B.STATUS = '1'
                                         group by B.JUDGE_STOVE_NO,
                                                  B.m_mat_no,
                                                  B.op_process) A
                                 WHERE A.JUDGE_STOVE_NO = T1.JUDGE_STOVE_NO
                                   AND A.OP_PROCESS = '6') FPZ6,
                              
                               NVL((select SUM(A.ACT_THEORY_WEIGHT)
                                     from (select B.JUDGE_STOVE_NO,
                                                  TRIM(B.OP_PROCESS) OP_PROCESS,
                                                  B.m_mat_no,
                                                  SUM(B.ACT_THEORY_WEIGHT) ACT_THEORY_WEIGHT
                                             from PORT_MIL_BATCH_SAMPLE_RESULT B
                                            WHERE B.IS_VALID = '1'
                                              AND B.STATUS = '1'
                                            group by B.JUDGE_STOVE_NO,
                                                     B.m_mat_no,
                                                     B.op_process) A
                                    WHERE A.JUDGE_STOVE_NO =
                                          T1.JUDGE_STOVE_NO
                                      AND A.OP_PROCESS = '6'),
                                   0) FPD6,
                              
                               (SELECT sum(A.act_count)
                                  FROM PORT_MIL_BATCH_SAMPLE_RESULT A
                                 WHERE A.IS_VALID = '1'
                                   AND A.STATUS <> '1'
                                   AND (TRIM(A.OP_PROCESS) <> '7' OR
                                       A.OP_PROCESS IS NULL)
                                   AND SUBSTR(A.JUDGE_STOVE_NO, -2) = '01'
                                   AND A.JUDGE_STOVE_NO = T1.JUDGE_STOVE_NO) HGZ7,
                              
                               (SELECT SUM(A.ACT_THEORY_WEIGHT)
                                  FROM PORT_MIL_BATCH_SAMPLE_RESULT A
                                 WHERE A.IS_VALID = '1'
                                   AND A.STATUS <> '1'
                                   AND (TRIM(A.OP_PROCESS) <> '7' OR
                                       A.OP_PROCESS IS NULL)
                                   AND SUBSTR(A.JUDGE_STOVE_NO, -2) = '01'
                                   AND A.JUDGE_STOVE_NO = T1.JUDGE_STOVE_NO) HGD7,
                              
                               NVL((select sum(A.act_count)
                                     from PORT_MIL_BATCH_SAMPLE_RESULT A
                                    WHERE A.IS_VALID = '1'
                                      AND A.STATUS = '2'
                                      AND TRIM(A.OP_PROCESS) = '7'
                                      AND A.JUDGE_STOVE_NO =
                                          T1.JUDGE_STOVE_NO),
                                   0) FPZ7,
                              
                               NVL((select SUM(A.ACT_THEORY_WEIGHT)
                                     from PORT_MIL_BATCH_SAMPLE_RESULT A
                                    WHERE A.IS_VALID = '1'
                                      AND A.STATUS = '2'
                                      AND TRIM(A.OP_PROCESS) = '7'
                                      AND A.JUDGE_STOVE_NO =
                                          T1.JUDGE_STOVE_NO),
                                   0) FPD7,
                              
                               NVL((select sum(1)
                                     from PORT_MIL_BATCH_SAMPLE_RESULT A
                                    WHERE A.IS_VALID = '1'
                                      AND A.STATUS = '2'
                                      AND TRIM(A.OP_PROCESS) = '9'
                                      AND A.PLAN_ID = T1.ID
                                      AND REGEXP_REPLACE(A.JUDGE_STOVE_NO,
                                                         '-.*',
                                                         '') =
                                          REGEXP_REPLACE(T1.JUDGE_STOVE_NO,
                                                         '-.*',
                                                         '')),
                                   0) FPZ9,
                              
                               NVL((select sum(A.act_count)
                                     from PORT_MIL_BATCH_SAMPLE_RESULT A
                                    WHERE A.IS_VALID = '1'
                                      AND A.STATUS = '2'
                                      AND TRIM(A.OP_PROCESS) = '9'
                                      AND A.PLAN_ID = T1.ID
                                      AND REGEXP_REPLACE(A.JUDGE_STOVE_NO,
                                                         '-.*',
                                                         '') =
                                          REGEXP_REPLACE(T1.JUDGE_STOVE_NO,
                                                         '-.*',
                                                         '')),
                                   0) FPD9,
                              
                               NVL((select sum(A.act_count)
                                     from PORT_MIL_BATCH_SAMPLE_RESULT A
                                    WHERE A.IS_VALID = '1'
                                      AND A.STATUS = '3'
                                      AND TRIM(A.OP_PROCESS) = '9'
                                      AND A.PLAN_ID = T1.ID
                                      AND REGEXP_REPLACE(A.JUDGE_STOVE_NO,
                                                         '-.*',
                                                         '') =
                                          REGEXP_REPLACE(T1.JUDGE_STOVE_NO,
                                                         '-.*',
                                                         '')),
                                   0) XXZ9,
                              
                               NVL((select SUM(A.ACT_THEORY_WEIGHT)
                                     from PORT_MIL_BATCH_SAMPLE_RESULT A
                                    WHERE A.IS_VALID = '1'
                                      AND A.STATUS = '3'
                                      AND TRIM(A.OP_PROCESS) = '9'
                                      AND A.PLAN_ID = T1.ID
                                      AND REGEXP_REPLACE(A.JUDGE_STOVE_NO,
                                                         '-.*',
                                                         '') =
                                          REGEXP_REPLACE(T1.JUDGE_STOVE_NO,
                                                         '-.*',
                                                         '')),
                                   0) XXD9,
                              
                               NVL((select sum(A.act_count)
                                     from PORT_MIL_BATCH_SAMPLE_RESULT A
                                    WHERE A.IS_VALID = '1'
                                      AND A.STATUS IN ('2', '5')
                                      AND TRIM(A.OP_PROCESS) = '10'
                                      AND A.PLAN_ID = T1.ID
                                      AND REGEXP_REPLACE(A.JUDGE_STOVE_NO,
                                                         '-.*',
                                                         '') =
                                          REGEXP_REPLACE(T1.JUDGE_STOVE_NO,
                                                         '-.*',
                                                         '')),
                                   0) FPZ10,
                              
                               NVL((select SUM(A.ACT_THEORY_WEIGHT)
                                     from PORT_MIL_BATCH_SAMPLE_RESULT A
                                    WHERE A.IS_VALID = '1'
                                      AND A.STATUS IN ('2', '5')
                                      AND TRIM(A.OP_PROCESS) = '10'
                                      AND A.PLAN_ID = T1.ID
                                      AND REGEXP_REPLACE(A.JUDGE_STOVE_NO,
                                                         '-.*',
                                                         '') =
                                          REGEXP_REPLACE(T1.JUDGE_STOVE_NO,
                                                         '-.*',
                                                         '')),
                                   0) FPD10,
                              
                               NVL((select sum(A.act_count)
                                     from PORT_MIL_BATCH_SAMPLE_RESULT A
                                    WHERE A.IS_VALID = '1'
                                      AND A.STATUS = '3'
                                      AND TRIM(A.OP_PROCESS) = '10'
                                      AND A.PLAN_ID = T1.ID
                                      AND REGEXP_REPLACE(A.JUDGE_STOVE_NO,
                                                         '-.*',
                                                         '') =
                                          REGEXP_REPLACE(T1.JUDGE_STOVE_NO,
                                                         '-.*',
                                                         '')),
                                   0) XXZ10,
                              
                               NVL((select SUM(A.ACT_THEORY_WEIGHT)
                                     from PORT_MIL_BATCH_SAMPLE_RESULT A
                                    WHERE A.IS_VALID = '1'
                                      AND A.STATUS = '3'
                                      AND TRIM(A.OP_PROCESS) = '10'
                                      AND A.PLAN_ID = T1.ID
                                      AND REGEXP_REPLACE(A.JUDGE_STOVE_NO,
                                                         '-.*',
                                                         '') =
                                          REGEXP_REPLACE(T1.JUDGE_STOVE_NO,
                                                         '-.*',
                                                         '')),
                                   0) XXD10,
                              
                               NVL((select sum(A.act_count)
                                     from PORT_MIL_BATCH_SAMPLE_RESULT A
                                    WHERE A.IS_VALID = '1'
                                      AND A.STATUS = '2'
                                      AND TRIM(A.OP_PROCESS) = '11'
                                      AND A.PLAN_ID = T1.ID
                                      AND REGEXP_REPLACE(A.JUDGE_STOVE_NO,
                                                         '-.*',
                                                         '') =
                                          REGEXP_REPLACE(T1.JUDGE_STOVE_NO,
                                                         '-.*',
                                                         '')),
                                   0) FPZ11,
                              
                               NVL((select SUM(A.ACT_THEORY_WEIGHT)
                                     from PORT_MIL_BATCH_SAMPLE_RESULT A
                                    WHERE A.IS_VALID = '1'
                                      AND A.STATUS = '2'
                                      AND TRIM(A.OP_PROCESS) = '11'
                                      AND A.PLAN_ID = T1.ID
                                      AND REGEXP_REPLACE(A.JUDGE_STOVE_NO,
                                                         '-.*',
                                                         '') =
                                          REGEXP_REPLACE(T1.JUDGE_STOVE_NO,
                                                         '-.*',
                                                         '')),
                                   0) FPD11,
                              
                               NVL((select sum(A.act_count)
                                     from PORT_MIL_BATCH_SAMPLE_RESULT A
                                    WHERE A.IS_VALID = '1'
                                      AND A.STATUS = '3'
                                      AND TRIM(A.OP_PROCESS) = '11'
                                      AND A.PLAN_ID = T1.ID
                                      AND REGEXP_REPLACE(A.JUDGE_STOVE_NO,
                                                         '-.*',
                                                         '') =
                                          REGEXP_REPLACE(T1.JUDGE_STOVE_NO,
                                                         '-.*',
                                                         '')),
                                   0) XXZ11,
                              
                               NVL((select SUM(A.ACT_THEORY_WEIGHT)
                                     from PORT_MIL_BATCH_SAMPLE_RESULT A
                                    WHERE A.IS_VALID = '1'
                                      AND A.STATUS = '3'
                                      AND TRIM(A.OP_PROCESS) = '11'
                                      AND A.PLAN_ID = T1.ID
                                      AND REGEXP_REPLACE(A.JUDGE_STOVE_NO,
                                                         '-.*',
                                                         '') =
                                          REGEXP_REPLACE(T1.JUDGE_STOVE_NO,
                                                         '-.*',
                                                         '')),
                                   0) XXD11,
                              
                               NVL((select sum(1)
                                     from PORT_MIL_BATCH_SAMPLE_RESULT A
                                    WHERE A.IS_VALID = '1'
                                      AND A.GROUP_FLAG = '1'
                                      AND TRIM(A.OP_PROCESS) = '9'
                                      AND A.PLAN_ID = T1.ID
                                      AND REGEXP_REPLACE(A.JUDGE_STOVE_NO,
                                                         '-.*',
                                                         '') =
                                          REGEXP_REPLACE(T1.JUDGE_STOVE_NO,
                                                         '-.*',
                                                         '')),
                                   0) ZLZ9,
                              
                               NVL((select sum(A.ACT_THEORY_WEIGHT)
                                     from PORT_MIL_BATCH_SAMPLE_RESULT A
                                    WHERE A.IS_VALID = '1'
                                      AND A.GROUP_FLAG = '1'
                                      AND TRIM(A.OP_PROCESS) = '9'
                                      AND A.PLAN_ID = T1.ID
                                      AND REGEXP_REPLACE(A.JUDGE_STOVE_NO,
                                                         '-.*',
                                                         '') =
                                          REGEXP_REPLACE(T1.JUDGE_STOVE_NO,
                                                         '-.*',
                                                         '')),
                                   0) ZLD9,
                              
                               NVL((select sum(1)
                                     from PORT_MIL_BATCH_SAMPLE_RESULT A
                                    WHERE A.IS_VALID = '1'
                                      AND A.GROUP_FLAG = '1'
                                      AND TRIM(A.OP_PROCESS) = '10'
                                      AND A.PLAN_ID = T1.ID
                                      AND REGEXP_REPLACE(A.JUDGE_STOVE_NO,
                                                         '-.*',
                                                         '') =
                                          REGEXP_REPLACE(T1.JUDGE_STOVE_NO,
                                                         '-.*',
                                                         '')),
                                   0) ZLZ10,
                              
                               NVL((select sum(A.ACT_THEORY_WEIGHT)
                                     from PORT_MIL_BATCH_SAMPLE_RESULT A
                                    WHERE A.IS_VALID = '1'
                                      AND A.GROUP_FLAG = '1'
                                      AND TRIM(A.OP_PROCESS) = '10'
                                      AND A.PLAN_ID = T1.ID
                                      AND REGEXP_REPLACE(A.JUDGE_STOVE_NO,
                                                         '-.*',
                                                         '') =
                                          REGEXP_REPLACE(T1.JUDGE_STOVE_NO,
                                                         '-.*',
                                                         '')),
                                   0) ZLD10,
                              
                               NVL((select sum(1)
                                     from PORT_MIL_BATCH_SAMPLE_RESULT A
                                    WHERE A.IS_VALID = '1'
                                      AND A.GROUP_FLAG = '1'
                                      AND TRIM(A.OP_PROCESS) = '11'
                                      AND A.PLAN_ID = T1.ID
                                      AND REGEXP_REPLACE(A.JUDGE_STOVE_NO,
                                                         '-.*',
                                                         '') =
                                          REGEXP_REPLACE(T1.JUDGE_STOVE_NO,
                                                         '-.*',
                                                         '')),
                                   0) ZLZ11,
                              
                               NVL((select sum(A.ACT_THEORY_WEIGHT)
                                     from PORT_MIL_BATCH_SAMPLE_RESULT A
                                    WHERE A.IS_VALID = '1'
                                      AND A.GROUP_FLAG = '1'
                                      AND TRIM(A.OP_PROCESS) = '11'
                                      AND A.PLAN_ID = T1.ID
                                      AND REGEXP_REPLACE(A.JUDGE_STOVE_NO,
                                                         '-.*',
                                                         '') =
                                          REGEXP_REPLACE(T1.JUDGE_STOVE_NO,
                                                         '-.*',
                                                         '')),
                                   0) ZLD11,
                              
                               (SELECT DECODE(B.DIRECTOR_QUANTITY,
                                              0,
                                              '',
                                              TO_CHAR(NVL(B.QUALIFIED_BRANCH, 0) * 100 /
                                                      B.DIRECTOR_QUANTITY,
                                                      'FM990.00') || '%')
                                  FROM mil_surface_result B
                                 WHERE B.JUDGE_STOVE_NO = T1.JUDGE_STOVE_NO) qualifiedRate,
                              
                               SUM(B.FEED_NUM_PLAN) SLZ,
                               SUM(B.MAT_TOTAL_HEIGHT -
                                   B.FEED_NUM *DECODE(B.CUT_TARGET,
                                          '返废',
                                          NVL(round(B.CUT_WEIGHT ,
                                                    3),
                                              0),

                                          0)) SLD,
                               SUM(B.FEED_NUM_PLAN * B.DB_NUM) *
                               MAX(T1.SAW_NUM) YJZ,
                              
                               NVL((select sum(A.act_count)
                                     from PORT_MIL_BATCH_SAMPLE_RESULT A
                                    WHERE A.IS_VALID = '1'
                                      AND A.STATUS = '1'
                                      AND A.PLAN_ID = T1.ID
                                      AND REGEXP_REPLACE(A.JUDGE_STOVE_NO,
                                                         '-.*',
                                                         '') =
                                          REGEXP_REPLACE(T1.JUDGE_STOVE_NO,
                                                         '-.*',
                                                         '')),
                                   0) undeterminedNum,
                              
                               NVL((select sum(A.INPUT_WEIGHT)
                                     from PORT_MIL_BATCH_SAMPLE_RESULT A
                                    WHERE A.IS_VALID = '1'
                                      AND A.STATUS = '1'
                                      AND A.PLAN_ID = T1.ID
                                      AND REGEXP_REPLACE(A.JUDGE_STOVE_NO,
                                                         '-.*',
                                                         '') =
                                          REGEXP_REPLACE(T1.JUDGE_STOVE_NO,
                                                         '-.*',
                                                         '')),
                                   0) undeterminedD,
                              
                               NVL((select sum(A.act_count)
                                     from PORT_MIL_BATCH_SAMPLE_RESULT A
                                    WHERE A.IS_VALID = '1'
                                      AND A.STATUS IN ('2', '5')
                                      AND A.OP_PROCESS <> '14'
                                      AND A.PLAN_ID = T1.ID
                                      AND REGEXP_REPLACE(A.JUDGE_STOVE_NO,
                                                         '-.*',
                                                         '') =
                                          REGEXP_REPLACE(T1.JUDGE_STOVE_NO,
                                                         '-.*',
                                                         '')),
                                   0) ScrapNum,
                              
                               NVL((select sum(A.ACT_THEORY_WEIGHT)
                                     from PORT_MIL_BATCH_SAMPLE_RESULT A
                                    WHERE A.IS_VALID = '1'
                                      AND A.STATUS IN ('2', '5')
                                      AND A.OP_PROCESS <> '14'
                                      AND A.PLAN_ID = T1.ID
                                      AND REGEXP_REPLACE(A.JUDGE_STOVE_NO,
                                                         '-.*',
                                                         '') =
                                          REGEXP_REPLACE(T1.JUDGE_STOVE_NO,
                                                         '-.*',
                                                         '')),
                                   0) ScrapD,
                              
                               NVL((select sum(A.act_count)
                                     from PORT_MIL_BATCH_SAMPLE_RESULT A
                                    WHERE A.IS_VALID = '1'
                                      AND A.STATUS = '2'
                                      AND A.OP_PROCESS = '14'
                                      AND A.PLAN_ID = T1.ID
                                      AND REGEXP_REPLACE(A.JUDGE_STOVE_NO,
                                                         '-.*',
                                                         '') =
                                          REGEXP_REPLACE(T1.JUDGE_STOVE_NO,
                                                         '-.*',
                                                         '')),
                                   0) FQY,
                              
                               NVL((select sum(A.act_count)
                                     from PORT_MIL_BATCH_SAMPLE_RESULT A
                                    WHERE A.IS_VALID = '1'
                                      AND A.STATUS = '6'
                                      AND A.PLAN_ID = T1.ID
                                      AND REGEXP_REPLACE(A.JUDGE_STOVE_NO,
                                                         '-.*',
                                                         '') =
                                          REGEXP_REPLACE(T1.JUDGE_STOVE_NO,
                                                         '-.*',
                                                         '')),
                                   0) WWFPZ,
                              
                               NVL((SELECT NVL(SUM(T12.QUALIFIED_NUM), 0)
                                     FROM MIL_INSTORE_RESULT T12
                                    WHERE T12.RESULT_NO = T1.ID
                                      AND REGEXP_REPLACE(T12.JUDGE_STOVE_NO,
                                                         '-.*',
                                                         '') =
                                          REGEXP_REPLACE(T1.JUDGE_STOVE_NO,
                                                         '-.*',
                                                         '')
                                      AND T12.NODE_FUR_FLAG = '1'),
                                   0) XXZ,
                              
                               NVL((SELECT NVL(SUM(T12.QUALIFIED_TONS), 0)
                                     FROM MIL_INSTORE_RESULT T12
                                    WHERE T12.RESULT_NO = T1.ID
                                      AND REGEXP_REPLACE(T12.JUDGE_STOVE_NO,
                                                         '-.*',
                                                         '') =
                                          REGEXP_REPLACE(T1.JUDGE_STOVE_NO,
                                                         '-.*',
                                                         '')
                                      AND T12.NODE_FUR_FLAG = '1'),
                                   0) XXD,
                              
                               NVL((SELECT NVL(SUM(T12.QUALIFIED_NUM), 0)
                                     FROM MIL_INSTORE_RESULT T12
                                    WHERE T12.RESULT_NO = T1.ID
                                      AND REGEXP_REPLACE(T12.JUDGE_STOVE_NO,
                                                         '-.*',
                                                         '') =
                                          REGEXP_REPLACE(T1.JUDGE_STOVE_NO,
                                                         '-.*',
                                                         '')),
                                   0) HGZ12,
                              
                               NVL((SELECT NVL(SUM(T12.QUALIFIED_TONS), 0)
                                     FROM MIL_INSTORE_RESULT T12
                                    WHERE T12.RESULT_NO = T1.ID
                                      AND REGEXP_REPLACE(T12.JUDGE_STOVE_NO,
                                                         '-.*',
                                                         '') =
                                          REGEXP_REPLACE(T1.JUDGE_STOVE_NO,
                                                         '-.*',
                                                         '')),
                                   0) HGD12,
                              
                               0 HGM12,
                              
                               NVL((select SUM(Q.ACT_COUNT)
                                     from QCM_ZG_JUGDE_APPLY Q
                                    WHERE Q.VALIDFLAG = '20'
                                      AND Q.APPLY_FLAG = '0'
                                      AND Q.JUDGE_STOVE_NO =
                                          REGEXP_REPLACE(T1.JUDGE_STOVE_NO,
                                                         '-.*',
                                                         '')),
                                   0) PDZ,
                              
                               NVL((select DECODE(NVL(SUM(Q.ACT_WEIGHT), 0),
                                                 0,
                                                 SUM(Q.ACT_THEORY_WEIGHT),
                                                 SUM(Q.ACT_WEIGHT))
                                     from QCM_ZG_JUGDE_APPLY Q
                                    WHERE Q.VALIDFLAG = '20'
                                      AND Q.APPLY_FLAG = '0'
                                      AND Q.JUDGE_STOVE_NO =
                                          REGEXP_REPLACE(T1.JUDGE_STOVE_NO,
                                                         '-.*',
                                                         '')),
                                   0) PDD,
                              
                               NVL((select SUM(Q.ACT_LEN)
                                     from QCM_ZG_JUGDE_APPLY Q
                                    WHERE 1 = 1
                                      AND Q.VALIDFLAG = '20'
                                      AND Q.APPLY_FLAG = '0'
                                      AND Q.JUDGE_STOVE_NO =
                                          REGEXP_REPLACE(T1.JUDGE_STOVE_NO,
                                                         '-.*',
                                                         '')),
                                   0) PDM,
                              
                               NVL((select SUM(Q.ACT_COUNT)
                                     from QCM_ZG_JUGDE_APPLY Q
                                    WHERE Q.APPLY_FLAG = '0'
                                      AND Q.JUDGE_STOVE_NO =
                                          REGEXP_REPLACE(T1.JUDGE_STOVE_NO,
                                                         '-.*',
                                                         '')),
                                   0) SPZ,
                              
                               NVL((select DECODE(NVL(SUM(Q.ACT_WEIGHT), 0),
                                                 0,
                                                 SUM(Q.ACT_THEORY_WEIGHT),
                                                 SUM(Q.ACT_WEIGHT))
                                     from QCM_ZG_JUGDE_APPLY Q
                                    WHERE Q.APPLY_FLAG = '0'
                                      AND Q.JUDGE_STOVE_NO =
                                          REGEXP_REPLACE(T1.JUDGE_STOVE_NO,
                                                         '-.*',
                                                         '')),
                                   0) SPD,
                              
                               NVL((select SUM(Q.ACT_LEN)
                                     from QCM_ZG_JUGDE_APPLY Q
                                    WHERE Q.APPLY_FLAG = '0'
                                      AND Q.JUDGE_STOVE_NO =
                                          REGEXP_REPLACE(T1.JUDGE_STOVE_NO,
                                                         '-.*',
                                                         '')),
                                   0) SPM,
                              
                               (NVL((select sum(A.act_count)
                                      from PORT_MIL_BATCH_SAMPLE_RESULT A
                                     WHERE A.IS_VALID = '1'
                                       AND A.STATUS IN ('3', '4')
                                       AND A.OP_PROCESS <> '12'
                                       AND A.PLAN_ID = T1.ID),
                                    0) +
                               NVL((SELECT NVL(SUM(T12.OFFLINE_NUM), 0)
                                      FROM MIL_INSTORE_RESULT T12
                                     WHERE T12.RESULT_NO = T1.ID
                                       AND REGEXP_REPLACE(T12.JUDGE_STOVE_NO,
                                                          '-.*',
                                                          '') =
                                           REGEXP_REPLACE(T1.JUDGE_STOVE_NO,
                                                          '-.*',
                                                          '')),
                                    0)) LXZ,
                              
                               NVL((select sum(A.act_count)
                                     from PORT_MIL_BATCH_SAMPLE_RESULT A
                                    WHERE A.IS_VALID = '1'
                                      AND A.STATUS = '4'
                                      AND A.GROUP_FLAG = '0'
                                      AND A.PLAN_ID = T1.ID
                                      AND REGEXP_REPLACE(A.JUDGE_STOVE_NO,
                                                         '-.*',
                                                         '') =
                                          REGEXP_REPLACE(T1.JUDGE_STOVE_NO,
                                                         '-.*',
                                                         '')),
                                   0) FXZ,
                              
                               NVL((select sum(A.act_count)
                                     from PORT_MIL_BATCH_SAMPLE_RESULT A
                                    WHERE A.IS_VALID = '1'
                                      AND A.GROUP_FLAG = '1'
                                      AND TRIM(A.OP_PROCESS) > 6
                                      AND A.PLAN_ID = T1.ID
                                      AND REGEXP_REPLACE(A.JUDGE_STOVE_NO,
                                                         '-.*',
                                                         '') =
                                          REGEXP_REPLACE(T1.JUDGE_STOVE_NO,
                                                         '-.*',
                                                         '')),
                                   0) ZLZ,
                              
                               NVL((select sum(A.ACT_THEORY_WEIGHT)
                                     from PORT_MIL_BATCH_SAMPLE_RESULT A
                                    WHERE A.IS_VALID = '1'
                                      AND A.GROUP_FLAG = '1'
                                      AND TRIM(A.OP_PROCESS) > 6
                                      AND A.PLAN_ID = T1.ID
                                      AND REGEXP_REPLACE(A.JUDGE_STOVE_NO,
                                                         '-.*',
                                                         '') =
                                          REGEXP_REPLACE(T1.JUDGE_STOVE_NO,
                                                         '-.*',
                                                         '')),
                                   0) ZLD,
                              
                               (select MAX(A.BAL_YEAR_MONTH)
                                  from PORT_MIL_BATCH_SAMPLE_RESULT A
                                 WHERE A.PLAN_ID = T1.ID) BAL_YEAR_MONTH,
                              
                               TO_CHAR(NVL((select SUM(A.ACT_THEORY_WEIGHT)
                                             from PORT_MIL_BATCH_SAMPLE_RESULT A
                                            WHERE A.IS_VALID = '1'
                                              AND A.STATUS <> '2'
                                              AND A.STATUS <> '3'
                                              AND A.STATUS <> '6'
                                              AND A.JUDGE_STOVE_NO =
                                                  T1.JUDGE_STOVE_NO),
                                           0) / SUM(B.MAT_TOTAL_HEIGHT) * 100,
                                       'FM990.00') || '%' RATE,
                              
                               SUM(B.MAT_TOTAL_HEIGHT) *
                               (1 - NVL((select R.BURNNING_RATE
                                           from MIL_FUR_RESULT R
                                          WHERE R.JUDGE_STOVE_NO =
                                                T1.JUDGE_STOVE_NO) / 100,
                                        0)) -
                               DECODE(MAX(T1.CONTROL_THICKP),
                                      0,
                                      0,
                                      (MAX(T1.CUT_HEAD_LENGTHP) +
                                      MAX(T1.CUT_TRAIL_LENGTHP)) / 1000 *
                                      (0.02466 * MAX(T1.CONTROL_THICKP) / 1000 * 1.02 *
                                      ((SUBSTR(MAX(T1.PIPE_SIZE),
                                                1,
                                                INSTR(MAX(T1.PIPE_SIZE), '*') - 1)) *
                                      (CASE
                                        WHEN INSTR(MAX(T1.VARIETIES), '套管') > 0 THEN
                                         1.005
                                        WHEN INSTR(MAX(T1.VARIETIES), '油管') > 0 THEN
                                         1.005
                                        ELSE
                                         1
                                      END) -
                                      (MAX(T1.CONTROL_THICKP) / 1000 * 1.02)) *
                                      SUM(B.FEED_NUM_PLAN * B.DB_NUM))) YJD,
                              
                               TO_CHAR(NVL((select DECODE(NVL(SUM(Q.ACT_WEIGHT),
                                                             0),
                                                         0,
                                                         SUM(Q.ACT_THEORY_WEIGHT),
                                                         SUM(Q.ACT_WEIGHT))
                                             from QCM_ZG_JUGDE_APPLY Q
                                            WHERE Q.VALIDFLAG = '20'
                                              AND Q.APPLY_FLAG = '0'
                                              AND Q.JUDGE_STOVE_NO =
                                                  REGEXP_REPLACE(T1.JUDGE_STOVE_NO,
                                                                 '-.*',
                                                                 '')),
                                           0) * 100 / SUM(B.MAT_TOTAL_HEIGHT),
                                       'FM990.00') || '%' RATE2
                       
                          from MIL_PLAN T1, MIL_FEED_PLAN B
                         WHERE T1.JUDGE_STOVE_NO = B.JUDGE_STOVE_NO
                           AND T1.PRO_PLAN_ID = B.PRO_PLAN_ID
                           AND T1.BACK_SLAB_FLAG <> '2'
                           AND REGEXP_REPLACE(T1.JUDGE_STOVE_NO, '-.*', '') IN('#JUDGE_STOVE_NO#')
                       
                         GROUP BY T1.JUDGE_STOVE_NO,
                                  T1.LOT_NO,
                                  T1.PLINE_CODE,
                                  T1.JUDGE_STOVE_NO,
                                  T1.ID,
                                  T1.PRO_PLAN_ID,
                                  t1.gx_plan_no,
                                  T1.ID,
                                  T1.CONTRACT_NO) AA
                 ORDER BY AA.FEED_TIME ASC) LOOP
 
    UPDATE MIL_PROCESSES T
       SET T.YJZ             = MYROW.YJZ,
           T.YJD             = MYROW.YJD,
           T.SLZ             = MYROW.SLZ,
           T.SLD             = MYROW.SLD,
           T.ZZL            =
           (SELECT SUM(TR.QUALIFIED_WT)
              FROM MIL_CONTROL_LOG TR
             WHERE TR.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO || '-01'),
           T.ZZZ            =
           (SELECT SUM(TR.QUALIFIED_NUM)
              FROM MIL_CONTROL_LOG TR
             WHERE TR.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO || '-01'),
           T.UNDETERMINEDNUM = MYROW.UNDETERMINEDNUM,
           T.UNDETERMINEDD   = MYROW.UNDETERMINEDD,
           T.SCRAPNUM        = MYROW.SCRAPNUM,
           T.SCRAPD          = MYROW.SCRAPD,
           T.WWFPZ           = MYROW.WWFPZ,
           T.FQY             = MYROW.FQY,
           T.LXZ             = MYROW.LXZ,
           T.FXZ             = MYROW.FXZ,
           T.ZLZ             = MYROW.ZLZ,
           T.ZLD             = MYROW.ZLD,
           T.SPZ             = MYROW.SPZ,
           T.SPD             = MYROW.SPD,
           T.SPM             = MYROW.SPM,
           T.PDZ             = MYROW.PDZ,
           T.PDD             = MYROW.PDD,
           T.PDM             = MYROW.PDM,
           T.HGZ1            = MYROW.HGZ1,
           T.HGD1            = MYROW.HGD1,
           T.FPZ1            = MYROW.FPZ1,
           T.FPD1            = MYROW.FPD1,
           T.HGZ2            = MYROW.HGZ2,
           T.HGD2            = MYROW.HGD2,
           T.FPZ2            = MYROW.FPZ2,
           T.FPD2            = MYROW.FPD2,
           T.HGZ3            = MYROW.HGZ3,
           T.HGD3            = MYROW.HGD3,
           T.FPZ3            = MYROW.FPZ3,
           T.FPD3            = MYROW.FPD3,
           T.HGZ4            = MYROW.HGZ4,
           T.HGD4            = MYROW.HGD4,
           T.FPZ4            = MYROW.FPZ4,
           T.FPD4            = MYROW.FPD4,
           T.HGZ5            = MYROW.HGZ5,
           T.HGD5            = MYROW.HGD5,
           T.FPZ5            = MYROW.FPZ5,
           T.FPD5            = MYROW.FPD5,
           T.HGZ6            = MYROW.HGZ6,
           T.HGD6            = MYROW.HGD6,
           T.FPZ6            = MYROW.FPZ6,
           T.FPD6            = MYROW.FPD6,
           T.HGZ7            = MYROW.HGZ7,
           T.HGD7            = MYROW.HGD7,
           T.FPZ7            = MYROW.FPZ7,
           T.FPD7            = MYROW.FPD7,
           T.HGZ9            = MYROW.HGZ9,
           T.HGD9            = MYROW.HGD9,
           T.FPZ9            = MYROW.FPZ9,
           T.FPD9            = MYROW.FPD9,
           T.HGZ10           = MYROW.HGZ10,
           T.HGD10           = MYROW.HGD10,
           T.FPZ10           = MYROW.FPZ10,
           T.FPD10           = MYROW.FPD10,
           T.HGZ11           = MYROW.HGZ11,
           T.HGD11           = MYROW.HGD11,
           T.FPZ11           = MYROW.FPZ11,
           T.FPD11           = MYROW.FPD11,
           T.HGZ12           = MYROW.HGZ12,
           T.HGD12           = MYROW.HGD12,
           T.RATE            = MYROW.RATE,
           T.QUALIFIEDRATE   = MYROW.QUALIFIEDRATE,
           T.RATE2           = MYROW.RATE2,
           T.NODE_STATUS1    = MYROW.NODE_STATUS1
     WHERE T.JUDGE_STOVE_NO = MYROW.JUDGE_STOVE_NO
       AND T.LOT_NO = MYROW.LOT_NO
       AND T.PLINE_CODE = MYROW.PLINE_CODE
       AND NVL(T.PRO_PLAN_ID, '/') = NVL(MYROW.PRO_PLAN_ID, '/')
       AND NVL(T.GX_PLAN_NO, '/') = NVL(MYROW.GX_PLAN_NO, '/');
 
    IF (MYROW.YJD > MYROW.HGD12) THEN
      UPDATE MIL_PROCESSES T
         SET T.ZLC = NVL(MYROW.YJD, 0) - NVL(MYROW.HGD12, 0)
       WHERE T.JUDGE_STOVE_NO = MYROW.JUDGE_STOVE_NO
         AND T.LOT_NO = MYROW.LOT_NO
         AND T.PLINE_CODE = MYROW.PLINE_CODE
         AND NVL(T.PRO_PLAN_ID, '/') = NVL(MYROW.PRO_PLAN_ID, '/')
         AND NVL(T.GX_PLAN_NO, '/') = NVL(MYROW.GX_PLAN_NO, '/');
    ELSE
      UPDATE MIL_PROCESSES T
         SET T.ZLC = 0
       WHERE T.JUDGE_STOVE_NO = MYROW.JUDGE_STOVE_NO
         AND T.LOT_NO = MYROW.LOT_NO
         AND T.PLINE_CODE = MYROW.PLINE_CODE
         AND NVL(T.PRO_PLAN_ID, '/') = NVL(MYROW.PRO_PLAN_ID, '/')
         AND NVL(T.GX_PLAN_NO, '/') = NVL(MYROW.GX_PLAN_NO, '/');
    END IF;
  END LOOP;
END;
]]>
</query>

<query id = "FrmMilDateStatistics.getMilCheckDeatilSimple" desc = "查询天淮表检缺项数据">
<![CDATA[
SELECT T.JUDGE_STOVE_NO,
       T.DEFECT_ITEM,
       T.WASTE_BRANCH,
       T.WASTE_TONS,
       T.OFFLINE_PRODUCT,
       T.DEFECT_CODE,
       T.RESULT_NO,
       T.SIMPLE_LOT_NO,
       T.PRO_PLAN_ID,
       T.GX_PLAN_NO,
       T.VALIDFLAG
  FROM MIL_CHECK_DEATIL_SIMPLE T, MIL_SURFACE_RESULT T1
 WHERE T.OFFLINE_PRODUCT > 0
   AND T.JUDGE_STOVE_NO = T1.JUDGE_STOVE_NO
   AND T1.PLINE_CODE = 'C072'
]]>
</query>

<query id = "FrmMilDateStatistics.doUpdateMilCheckDeatilSimple" desc = "修改天淮表检缺项数据">
<![CDATA[
UPDATE MIL_CHECK_DEATIL_SIMPLE T
   SET T.OFFLINE_PRODUCT = '#OFFLINE_PRODUCT#', T.VALIDFLAG = '#VALIDFLAG#'
 WHERE T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
   AND T.DEFECT_CODE = '#DEFECT_CODE#'
   AND T.RESULT_NO = '#RESULT_NO#'
]]>
</query>

</queryMap>
