<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc = "环形加热炉">
<query id = "FrmAnnularFurnace.queryMinResult" desc = "查询">
<![CDATA[
SELECT T4.LOT_NO,
       T4.JUDGE_STOVE_NO,
       T4.COL_SHIFT,
       T4.COL_GROUP,
       T4.PLINE_CODE,
       T4.PLINE_NAME,
       MIN(T4.START_TIME) START_TIME,
       T4.SCRAP_NUM,
       T4.SCRAP_REASON,
       T4.PIPE_SECTION,
       T4.FIRST_IN_TIME,
       T4.LAST_IN_TIME,
       T4.FIRST_OUT_TIME,
       T4.LAST_OUT_TIME,
       T4.FIRST_SLAB_OUT_TEMP,
       T4.LAST_SLAB_OUT_TEMP,
       T4.SET_FUR_TEMP,
       T4.COL_USER,
       T4.STEELNAME,
       T4.GRADENAME,
       T4.REMARK,
       T4.BURNNING_RATE,
       SUM(T4.OUT_FUR_NUM) OUT_FUR_NUM,
       SUM(T4.IN_FUR_NUM) IN_FUR_NUM
  FROM (SELECT T3.LOT_NO,
               REGEXP_REPLACE(T3.JUDGE_STOVE_NO, '-.*', '') JUDGE_STOVE_NO,
               T3.RESULT_NO,
               DECODE(T3.COL_SHIFT,
                      1,
                      '早班',
                      2,
                      '中班',
                      3,
                      '夜班',
                      0,
                      '常白班') COL_SHIFT,
               DECODE(T3.COL_GROUP, 1, '甲', 2, '乙', 3, '丙', 4, '丁') COL_GROUP,
               T3.PLINE_CODE,
               (SELECT B.PLINE_NAME
                  FROM COM_BASE_PLINE B
                 WHERE B.PLINE_CODE = T3.PLINE_CODE) PLINE_NAME,
               TO_CHAR(MIN(T.START_TIME), 'YYYY-MM-DD HH24:MI:SS') START_TIME,
               (SELECT NVL(COUNT(*), 0)
                  FROM MIL_FUR_RACK B
                 WHERE B.JUDGE_STOVE_NO = T3.JUDGE_STOVE_NO
                   AND B.RESULT_NO = T3.RESULT_NO
                   AND B.COL_SHIFT = T3.COL_SHIFT
                   AND B.COL_GROUP = T3.COL_GROUP
                   AND B.IN_SHIFT = T3.IN_SHIFT
                   AND B.IN_GROUP = T3.IN_GROUP
                   AND B.STATUS = '1') SCRAP_NUM,
               TRIM(T.SCRAP_REASON) SCRAP_REASON,
               TO_CHAR(T2.PIPE_SECTION, 'FM99999990.000') || '*' ||
               TO_CHAR(T2.DB_LENGTH, 'FM99999990.000') PIPE_SECTION,
               TO_CHAR(MIN(T.FIRST_IN_TIME), 'HH24:MI') FIRST_IN_TIME,
               TO_CHAR(MAX(T.LAST_IN_TIME), 'HH24:MI') LAST_IN_TIME,
               TO_CHAR(MIN(T.FIRST_OUT_TIME), 'HH24:MI') FIRST_OUT_TIME,
               TO_CHAR(MAX(T.LAST_OUT_TIME), 'HH24:MI') LAST_OUT_TIME,
               T.FIRST_SLAB_OUT_TEMP,
               T.LAST_SLAB_OUT_TEMP,
               T.SET_FUR_TEMP,
               T3.COL_USER,
               T2.STEELNAME,
               T2.GRADENAME,
               TRIM(T.REMARK) REMARK,
               T.BURNNING_RATE,
               (SELECT NVL(COUNT(*), 0)
                  FROM MIL_FUR_RACK B
                 WHERE B.JUDGE_STOVE_NO = T3.JUDGE_STOVE_NO
                   AND B.RESULT_NO = T3.RESULT_NO
                   AND B.COL_SHIFT = T3.COL_SHIFT
                   AND B.COL_GROUP = T3.COL_GROUP
                   AND B.STATUS != '1') OUT_FUR_NUM,
               0 IN_FUR_NUM
          FROM MIL_FUR_RACK T3, MIL_FUR_RESULT T, MIL_PLAN T2
         WHERE T3.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO
           AND T3.RESULT_NO = T.RESULT_NO
           AND T3.JUDGE_STOVE_NO = T2.JUDGE_STOVE_NO
           AND T3.RESULT_NO = T2.ID
           AND T3.MAT_NO IS NOT NULL
           AND T3.OUT_FUR_TIME BETWEEN TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS') AND
               TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS')
           AND T3.COL_SHIFT LIKE '%' || ? || '%'
           AND T3.COL_GROUP LIKE '%' || ? || '%'
           AND T3.JUDGE_STOVE_NO LIKE '%' || ? || '%'
           #something#
         GROUP BY T3.LOT_NO,
                  T3.JUDGE_STOVE_NO,
                  T3.RESULT_NO,
                  T3.COL_SHIFT,
                  T3.COL_GROUP,
                   T3.IN_SHIFT,
                  T3.IN_GROUP,
                  T.SCRAP_REASON,
                  T2.PIPE_SECTION,
                  T2.DB_LENGTH,
                  T.FIRST_SLAB_OUT_TEMP,
                  T.LAST_SLAB_OUT_TEMP,
                  T.SET_FUR_TEMP,
                  T3.COL_USER,
                  T2.GRADENAME,
                  T2.STEELNAME,
                  T.SCRAP_NUM,
                  T.REMARK,
                  T3.PLINE_CODE,
                  T.BURNNING_RATE
        UNION
        SELECT T3.LOT_NO,
               REGEXP_REPLACE(T3.JUDGE_STOVE_NO, '-.*', '') JUDGE_STOVE_NO,
               T3.RESULT_NO,
               DECODE(T3.IN_SHIFT,
                      1,
                      '早班',
                      2,
                      '中班',
                      3,
                      '夜班',
                      0,
                      '常白班') COL_SHIFT,
               DECODE(T3.IN_GROUP, 1, '甲', 2, '乙', 3, '丙', 4, '丁') COL_GROUP,
               T3.PLINE_CODE,
               (SELECT B.PLINE_NAME
                  FROM COM_BASE_PLINE B
                 WHERE B.PLINE_CODE = T3.PLINE_CODE) PLINE_NAME,
               TO_CHAR(MIN(T.START_TIME), 'YYYY-MM-DD HH24:MI:SS') START_TIME,
               0 SCRAP_NUM,
               '' SCRAP_REASON,
               TO_CHAR(T2.PIPE_SECTION, 'FM99999990.000') || '*' ||
               TO_CHAR(T2.DB_LENGTH, 'FM99999990.000') PIPE_SECTION,
               TO_CHAR(MIN(T.FIRST_IN_TIME), 'HH24:MI') FIRST_IN_TIME,
               TO_CHAR(MAX(T.LAST_IN_TIME), 'HH24:MI') LAST_IN_TIME,
               TO_CHAR(MIN(T.FIRST_OUT_TIME), 'HH24:MI') FIRST_OUT_TIME,
               TO_CHAR(MAX(T.LAST_OUT_TIME), 'HH24:MI') LAST_OUT_TIME,
               T.FIRST_SLAB_OUT_TEMP,
               T.LAST_SLAB_OUT_TEMP,
               T.SET_FUR_TEMP,
               T3.IN_USER COL_USER,
               T2.STEELNAME,
               T2.GRADENAME,
               TRIM(T.REMARK) REMARK,
               T.BURNNING_RATE,
               0 OUT_FUR_NUM,
               (SELECT NVL(COUNT(*), 0)
                  FROM MIL_FUR_RACK B
                 WHERE B.JUDGE_STOVE_NO = T3.JUDGE_STOVE_NO
                   AND B.RESULT_NO = T3.RESULT_NO
                   AND B.IN_SHIFT = T3.IN_SHIFT
                   AND B.IN_GROUP = T3.IN_GROUP) IN_FUR_NUM
          FROM MIL_FUR_RACK T3, MIL_FUR_RESULT T, MIL_PLAN T2
         WHERE T3.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO
           AND T3.RESULT_NO = T.RESULT_NO
           AND T3.JUDGE_STOVE_NO = T2.JUDGE_STOVE_NO
           AND T3.RESULT_NO = T2.ID
           AND T3.MAT_NO IS NOT NULL
           AND T3.IN_FUR_TIME BETWEEN TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS') AND
               TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS')
           AND T3.IN_SHIFT LIKE '%' || ? || '%'
           AND T3.IN_GROUP LIKE '%' || ? || '%'
            AND T3.JUDGE_STOVE_NO LIKE '%' || ? || '%'
           #something#
         GROUP BY T3.LOT_NO,
                  T3.JUDGE_STOVE_NO,
                  T3.RESULT_NO,
                  T3.IN_SHIFT,
                  T3.IN_GROUP,
                  T.SCRAP_REASON,
                  T2.PIPE_SECTION,
                  T2.DB_LENGTH,
                  T.FIRST_SLAB_OUT_TEMP,
                  T.LAST_SLAB_OUT_TEMP,
                  T.SET_FUR_TEMP,
                  T3.IN_USER,
                  T2.GRADENAME,
                  T2.STEELNAME,
                  T.SCRAP_NUM,
                  T.REMARK,
                  T3.PLINE_CODE,
                  T.BURNNING_RATE) T4
 GROUP BY T4.LOT_NO,
          T4.JUDGE_STOVE_NO,
          T4.COL_SHIFT,
          T4.COL_GROUP,
          T4.PLINE_CODE,
          T4.PLINE_NAME,
          T4.SCRAP_NUM,
          T4.SCRAP_REASON,
          T4.PIPE_SECTION,
          T4.FIRST_IN_TIME,
          T4.LAST_IN_TIME,
          T4.FIRST_OUT_TIME,
          T4.LAST_OUT_TIME,
          T4.FIRST_SLAB_OUT_TEMP,
          T4.LAST_SLAB_OUT_TEMP,
          T4.SET_FUR_TEMP,
          T4.COL_USER,
          T4.STEELNAME,
          T4.GRADENAME,
          T4.REMARK,
          T4.BURNNING_RATE
 ORDER BY START_TIME ASC
]]>
</query>


<query id = "FrmAnnularFurnace.queryMinResultTest" desc = "查询">
<![CDATA[
SELECT T4.LOT_NO,
       T4.JUDGE_STOVE_NO,
       T4.COL_SHIFT,
       T4.COL_GROUP,
       T4.IN_SHIFT,
       T4.IN_GROUP,
       MIN(T4.START_TIME) START_TIME,
       T4.SCRAP_NUM,
       T4.SCRAP_REASON,
       T4.PIPE_SECTION,
       T4.FIRST_IN_TIME,
       T4.LAST_IN_TIME,
       T4.FIRST_OUT_TIME,
       T4.LAST_OUT_TIME,
       T4.FIRST_SLAB_OUT_TEMP,
       T4.LAST_SLAB_OUT_TEMP,
       T4.SET_FUR_TEMP,
       T4.COL_USER,
       T4.STEELNAME,
       T4.GRADENAME,
       T4.REMARK,
       T4.BURNNING_RATE,
       T4.OUT_FUR_NUM,
       T4.IN_FUR_NUM
  FROM (SELECT T3.LOT_NO,
               REGEXP_REPLACE(T3.JUDGE_STOVE_NO, '-.*', '') JUDGE_STOVE_NO,
               T3.RESULT_NO,
               DECODE(T3.COL_SHIFT,
                      1,
                      '早班',
                      2,
                      '中班',
                      3,
                      '夜班',
                      0,
                      '常白班') COL_SHIFT,
               DECODE(T3.COL_GROUP, 1, '甲', 2, '乙', 3, '丙', 4, '丁') COL_GROUP,
               DECODE(T3.IN_SHIFT,
                      1,
                      '早班',
                      2,
                      '中班',
                      3,
                      '夜班',
                      0,
                      '常白班') IN_SHIFT,
               DECODE(T3.IN_GROUP, 1, '甲', 2, '乙', 3, '丙', 4, '丁') IN_GROUP,
               TO_CHAR(MIN(T.START_TIME), 'YYYY-MM-DD HH24:MI:SS') START_TIME,
               (SELECT NVL(COUNT(*), 0)
                  FROM MIL_FUR_RACK B
                 WHERE B.JUDGE_STOVE_NO = T3.JUDGE_STOVE_NO
                   AND B.RESULT_NO = T3.RESULT_NO
                   AND B.STATUS = '1') SCRAP_NUM,
               TRIM(T.SCRAP_REASON) SCRAP_REASON,
               TO_CHAR(T2.PIPE_SECTION, 'FM99999990.000') || '*' ||
               TO_CHAR(T2.DB_LENGTH, 'FM99999990.000') PIPE_SECTION,
               TO_CHAR(MIN(T.FIRST_IN_TIME), 'HH24:MI') FIRST_IN_TIME,
               TO_CHAR(MAX(T.LAST_IN_TIME), 'HH24:MI') LAST_IN_TIME,
               TO_CHAR(MIN(T.FIRST_OUT_TIME), 'HH24:MI') FIRST_OUT_TIME,
               TO_CHAR(MAX(T.LAST_OUT_TIME), 'HH24:MI') LAST_OUT_TIME,
               T.FIRST_SLAB_OUT_TEMP,
               T.LAST_SLAB_OUT_TEMP,
               T.SET_FUR_TEMP,
               T3.COL_USER,
               T2.STEELNAME,
               T2.GRADENAME,
               TRIM(T.REMARK) REMARK,
               T.BURNNING_RATE,
               (SELECT NVL(COUNT(*), 0)
                  FROM MIL_FUR_RACK B
                 WHERE B.JUDGE_STOVE_NO = T3.JUDGE_STOVE_NO
                   AND B.RESULT_NO = T3.RESULT_NO
                   AND B.COL_SHIFT = T3.COL_SHIFT
                   AND B.COL_GROUP = T3.COL_GROUP
                   AND B.OUT_FUR_TIME BETWEEN
                       TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS') AND
                       TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS')
                   AND B.STATUS != '1') OUT_FUR_NUM,
               (SELECT NVL(COUNT(*), 0)
                  FROM MIL_FUR_RACK B
                 WHERE B.JUDGE_STOVE_NO = T3.JUDGE_STOVE_NO
                   AND B.RESULT_NO = T3.RESULT_NO
                   AND B.IN_SHIFT = T3.IN_SHIFT
                   AND B.IN_GROUP = T3.IN_GROUP
                   AND B.IN_FUR_TIME BETWEEN
                       TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS') AND
                       TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS')) IN_FUR_NUM
          FROM MIL_FUR_RACK T3, MIL_FUR_RESULT T, MIL_PLAN T2
         WHERE T3.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO
           AND T3.RESULT_NO = T.RESULT_NO
           AND T3.JUDGE_STOVE_NO = T2.JUDGE_STOVE_NO
           AND T3.RESULT_NO = T2.ID
           AND T3.MAT_NO IS NOT NULL
           AND (T3.OUT_FUR_TIME BETWEEN TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS') AND
               TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS') AND
               T3.COL_SHIFT LIKE '%' || ? || '%' AND
               T3.COL_GROUP LIKE '%' || ? || '%')
            OR (
            	T3.IN_FUR_TIME BETWEEN TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS') AND
                TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS')
            AND T3.IN_SHIFT LIKE '%' || ? || '%'
            AND T3.IN_GROUP LIKE '%' || ? || '%')
           AND T3.PLINE_CODE LIKE '%' || ? || '%'
         GROUP BY T3.LOT_NO,
                  T3.JUDGE_STOVE_NO,
                  T3.RESULT_NO,
                  T3.COL_SHIFT,
                  T3.COL_GROUP,
                  T3.IN_SHIFT,
                  T3.IN_GROUP,
                  T.SCRAP_REASON,
                  T2.PIPE_SECTION,
                  T2.DB_LENGTH,
                  T.FIRST_SLAB_OUT_TEMP,
                  T.LAST_SLAB_OUT_TEMP,
                  T.SET_FUR_TEMP,
                  T3.COL_USER,
                  T2.GRADENAME,
                  T2.STEELNAME,
                  T.SCRAP_NUM,
                  T.REMARK,
                  T3.PLINE_CODE,
                  T.BURNNING_RATE) T4
 GROUP BY T4.LOT_NO,
          T4.JUDGE_STOVE_NO,
          T4.COL_SHIFT,
          T4.COL_GROUP,
          T4.IN_SHIFT,
          T4.IN_GROUP,
          T4.SCRAP_NUM,
          T4.SCRAP_REASON,
          T4.PIPE_SECTION,
          T4.FIRST_IN_TIME,
          T4.LAST_IN_TIME,
          T4.FIRST_OUT_TIME,
          T4.LAST_OUT_TIME,
          T4.FIRST_SLAB_OUT_TEMP,
          T4.LAST_SLAB_OUT_TEMP,
          T4.SET_FUR_TEMP,
          T4.COL_USER,
          T4.STEELNAME,
          T4.GRADENAME,
          T4.REMARK,
          T4.BURNNING_RATE,
          T4.OUT_FUR_NUM,
          T4.IN_FUR_NUM
 ORDER BY START_TIME ASC

]]>
</query>
</queryMap>