<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc = "探伤">
<query id = "FrmRepInspection.queryMinResult" desc = "查询">
<![CDATA[
SELECT REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '') JUDGE_STOVE_NO,
       DECODE(T.COL_SHIFT, 1, '早班', 2, '中班', 3, '夜班', 0, '常白班') COL_SHIFT1,
       DECODE(T.COL_GROUP, 1, '甲', 2, '乙', 3, '丙', 4, '丁') COL_GROUP1,
       T.COL_SHIFT,
       T.COL_GROUP,
       T.PLINE_CODE,
       (SELECT B.PLINE_NAME
          FROM COM_BASE_PLINE B
         WHERE B.PLINE_CODE = T.PLINE_CODE) PLINE_NAME,
       T.LOT_NO,
       MAX(TO_CHAR(T.END_INSPECTION_TIME, 'YYYY-MM-DD HH24:MI:SS')) END_INSPECTION_TIME,
       MAX(T3.STEELNAME) STEELNAME,
       MAX(T3.GRADENAME) GRADENAME,
       MAX(T3.PIPE_SIZE) PIPE_SIZE,
       MAX(T2.LO_SURFACE) LO_SURFACE,
       MAX(T2.LI_SURFACE) LI_SURFACE,
       MAX(T2.SPEED1) SPEED1,
       MAX(T2.SPEED2) SPEED2,
       MAX(T2.LONGITUDINAL_CURRENT1) LONGITUDINAL_CURRENT1,
       MAX(T2.LONGITUDINAL_CURRENT2) LONGITUDINAL_CURRENT2,
       MAX(T2.TO_SURFACE) TO_SURFACE,
       MAX(T2.TI_SURFACE) TI_SURFACE,
       MAX(T2.TRANSVERSE_CURRENT1) TRANSVERSE_CURRENT1,
       MAX(T2.TRANSVERSE_CURRENT2) TRANSVERSE_CURRENT2,
       (SELECT SUM(C.REASON_NUMBER)
          FROM MIL_TESTING_RESULT_DETAIL_DES C
         WHERE C.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO
           AND C.COL_SHIFT = T.COL_SHIFT
           AND C.COL_GROUP = T.COL_GROUP
           AND C.PLINE_CODE = T.PLINE_CODE
           AND C.REASON_FLAG = '可疑'
           AND C.REASON = 'TID') ZHI1,
       
       (SELECT SUM(C.REASON_NUMBER)
          FROM MIL_TESTING_RESULT_DETAIL_DES C
         WHERE C.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO
           AND C.COL_SHIFT = T.COL_SHIFT
           AND C.COL_GROUP = T.COL_GROUP
           AND C.PLINE_CODE = T.PLINE_CODE
           AND C.REASON_FLAG = '可疑'
           AND C.REASON = 'TOD') ZHI2,
       
       (SELECT SUM(C.REASON_NUMBER)
          FROM MIL_TESTING_RESULT_DETAIL_DES C
         WHERE C.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO
           AND C.COL_SHIFT = T.COL_SHIFT
           AND C.COL_GROUP = T.COL_GROUP
           AND C.PLINE_CODE = T.PLINE_CODE
           AND C.REASON_FLAG = '可疑'
           AND C.REASON = 'LID') ZHI3,
       
       (SELECT SUM(C.REASON_NUMBER)
          FROM MIL_TESTING_RESULT_DETAIL_DES C
         WHERE C.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO
           AND C.COL_SHIFT = T.COL_SHIFT
           AND C.COL_GROUP = T.COL_GROUP
           AND C.PLINE_CODE = T.PLINE_CODE
           AND C.REASON_FLAG = '可疑'
           AND C.REASON = 'LOD') ZHI4,
       
       (SELECT SUM(C.REASON_NUMBER)
          FROM MIL_TESTING_RESULT_DETAIL_DES C
         WHERE C.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO
           AND C.COL_SHIFT = T.COL_SHIFT
           AND C.COL_GROUP = T.COL_GROUP
           AND C.PLINE_CODE = T.PLINE_CODE
           AND C.REASON_FLAG = '剔除'
           AND C.REASON1 = 'TID') FEI1,
       
       (SELECT SUM(C.REASON_NUMBER)
          FROM MIL_TESTING_RESULT_DETAIL_DES C
         WHERE C.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO
           AND C.COL_SHIFT = T.COL_SHIFT
           AND C.COL_GROUP = T.COL_GROUP
           AND C.PLINE_CODE = T.PLINE_CODE
           AND C.REASON_FLAG = '剔除'
           AND C.REASON1 = 'TOD') FEI2,
       
       (SELECT SUM(C.REASON_NUMBER)
          FROM MIL_TESTING_RESULT_DETAIL_DES C
         WHERE C.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO
           AND C.COL_SHIFT = T.COL_SHIFT
           AND C.COL_GROUP = T.COL_GROUP
           AND C.PLINE_CODE = T.PLINE_CODE
           AND C.REASON_FLAG = '剔除'
           AND C.REASON1 = 'LID') FEI3,
       
       (SELECT SUM(C.REASON_NUMBER)
          FROM MIL_TESTING_RESULT_DETAIL_DES C
         WHERE C.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO
           AND C.COL_SHIFT = T.COL_SHIFT
           AND C.COL_GROUP = T.COL_GROUP
           AND C.PLINE_CODE = T.PLINE_CODE
           AND C.REASON_FLAG = '剔除'
           AND C.REASON1 = 'LOD') FEI4,
       NVL(COUNT(*), 0) - NVL((SELECT SUM(C.REASON_NUMBER)
                                FROM MIL_TESTING_RESULT_DETAIL_DES C
                               WHERE C.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO
                                 AND C.COL_SHIFT = T.COL_SHIFT
                                 AND C.COL_GROUP = T.COL_GROUP
                                 AND C.PLINE_CODE = T.PLINE_CODE
                                 AND C.REASON_FLAG = '剔除'
                                 AND C.REASON1 = 'TID'),
                              0) -
       NVL((SELECT SUM(C.REASON_NUMBER)
             FROM MIL_TESTING_RESULT_DETAIL_DES C
            WHERE C.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO
              AND C.COL_SHIFT = T.COL_SHIFT
              AND C.COL_GROUP = T.COL_GROUP
              AND C.PLINE_CODE = T.PLINE_CODE
              AND C.REASON_FLAG = '剔除'
              AND C.REASON1 = 'TOD'),
           0) - NVL((SELECT SUM(C.REASON_NUMBER)
                      FROM MIL_TESTING_RESULT_DETAIL_DES C
                     WHERE C.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO
                       AND C.COL_SHIFT = T.COL_SHIFT
                       AND C.COL_GROUP = T.COL_GROUP
                       AND C.PLINE_CODE = T.PLINE_CODE
                       AND C.REASON_FLAG = '剔除'
                       AND C.REASON1 = 'LID'),
                    0) - NVL((SELECT SUM(C.REASON_NUMBER)
                               FROM MIL_TESTING_RESULT_DETAIL_DES C
                              WHERE C.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO
                                AND C.COL_SHIFT = T.COL_SHIFT
                                AND C.COL_GROUP = T.COL_GROUP
                                AND C.PLINE_CODE = T.PLINE_CODE
                                AND C.REASON_FLAG = '剔除'
                                AND C.REASON1 = 'LOD'),
                             0) QUALIFIED_PCS,
       /*(SELECT NVL(COUNT(*), 0)
        FROM MIL_TESTING_RACK B
       WHERE REGEXP_REPLACE(B.JUDGE_STOVE_NO, '-.*', '') =
             REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '')
         AND B.COL_SHIFT = T.COL_SHIFT
         AND B.COL_GROUP = T.COL_GROUP
         AND B.PLINE_CODE = T.PLINE_CODE
         AND B.MAT_NO IS NOT NULL
         AND B.STATUS != '1'
         AND B.STATUS != '3') QUALIFIED_PCS,*/
       
       NVL(COUNT(*), 0) DETECTION_NUM,
       MAX(T.COL_USER) COL_USER,
       MAX(T2.REMARK) REMARK
  FROM MIL_TESTING_RACK T, MIL_MT_RESULT T2, MIL_PLAN T3
 WHERE T.JUDGE_STOVE_NO = T2.JUDGE_STOVE_NO
   AND T2.JUDGE_STOVE_NO = T3.JUDGE_STOVE_NO
   AND T.COL_SHIFT IS NOT NULL
   AND T.MAT_NO IS NOT NULL
   AND T.END_INSPECTION_TIME BETWEEN TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS') AND
       TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS')
   --AND T.PLINE_CODE = ? 
   #someThing#
 GROUP BY T.JUDGE_STOVE_NO,
          T.LOT_NO,
          T.COL_SHIFT,
          T.COL_GROUP,
          T.PLINE_CODE,
          T.END_INSPECTION_TIME
 ORDER BY T.END_INSPECTION_TIME ASC

]]>
</query>


<query id = "FrmRepInspection.queryMinResult168" desc = "查询">
<![CDATA[
select REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '') JUDGE_STOVE_NO,
       T.LOT_NO,
       T.COL_SHIFT || T.COL_GROUP || T.PLINE_CODE TID,
       DECODE(T.COL_SHIFT, 1, '早班', 2, '中班', 3, '夜班', 0, '常白班') COL_SHIFT1,
       DECODE(T.COL_GROUP, 1, '甲班', 2, '乙班', 3, '丙班', 4, '丁班') COL_GROUP1,
       T.COL_SHIFT,
       T.COL_GROUP,
       TO_CHAR(MIN(T.END_INSPECTION_TIME), 'YYYY-MM-DD') DATE1,
       T.END_INSPECTION_TIME,
       T.PLINE_CODE,
       (SELECT B.PLINE_NAME
          FROM COM_BASE_PLINE B
         WHERE B.PLINE_CODE = T.PLINE_CODE) PLINE_NAME,
       NVL(MAX(T5.STEELNAME), '/') STEELNAME,
       NVL(MAX(T5.GRADENAME), '/') GRADENAME,
       NVL(MAX(T5.PIPE_SIZE), '/') PIPE_SIZE,
       MAX(T4.EXCITATION_FREQUENCY1) EXCITATION_FREQUENCY1,
       MAX(T4.EXCITATION_FREQUENCY2) EXCITATION_FREQUENCY2,
       MAX(T4.EXCITATION_FREQUENCY3) EXCITATION_FREQUENCY3,
       T3.DETECTION_NUM1,
       T3.DETECTION_NUM2,
       T3.DETECTION_NUM3,
       T3.SUSPECT_PRODUCT_NUM1,
       T3.SUSPECT_PRODUCT_NUM2,
       T3.SUSPECT_PRODUCT_NUM3,
       T3.SCRAP_NUM1 + T3.SCRAP_NUM2 + T3.SCRAP_NUM3 SCRAP_NUM,
       T3.QUALIFIED_NUM1 + T3.QUALIFIED_NUM2 + T3.QUALIFIED_NUM3 QUALIFIED_NUM,
       MAX(T4.REMARK2) REMARK
  from MIL_TESTING_RACK          T,
       MIL_TESTING_RESULT_DETAIL T3,
       MIL_ET_RESULT             T4,
       MIL_PLAN                  T5
 WHERE 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.COL_SHIFT = T3.COL_SHIFT
   AND T.COL_GROUP = T3.COL_GROUP
   AND T.END_INSPECTION_TIME BETWEEN TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS') AND
       TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS')
   --AND T.PLINE_CODE = ?
   #someThing#
 GROUP BY REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', ''),
          T.LOT_NO,
          T.COL_SHIFT,
          T.COL_GROUP,
          T.PLINE_CODE,
          T.END_INSPECTION_TIME,
          T3.DETECTION_NUM1,
          T3.DETECTION_NUM2,
          T3.DETECTION_NUM3,
          T3.SUSPECT_PRODUCT_NUM1,
          T3.SUSPECT_PRODUCT_NUM2,
          T3.SUSPECT_PRODUCT_NUM3,
          T3.SCRAP_NUM1,
          T3.SCRAP_NUM2,
          T3.SCRAP_NUM3,
          T3.QUALIFIED_NUM1,
          T3.QUALIFIED_NUM2,
          T3.QUALIFIED_NUM3
 ORDER BY END_INSPECTION_TIME
]]>
</query>
</queryMap>