<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc = "矫直">
<query id = "FrmStraighten.queryMinResult" desc = "查询">
<![CDATA[
SELECT T2.LOT_NO,
       REGEXP_REPLACE(T2.JUDGE_STOVE_NO, '-.*', '') JUDGE_STOVE_NO,
       T.PLINE_CODE,
       (SELECT B.PLINE_NAME
          FROM COM_BASE_PLINE B
         WHERE B.PLINE_CODE = T.PLINE_CODE) PLINE_NAME,
       T1.STEELNAME,
       T1.GRADENAME,
       T1.PIPE_SIZE,
       NVL(COUNT(*), 0) IN_MAT_NUM,
       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.JUDGE_STOVE_NO = T2.JUDGE_STOVE_NO),
           0) QA_TON,
       T.ROLLER_UP_ANGLE11 ROLLER_ENTER_UP_ANGLE1,
       T.ROLLER_UP_ANGLE21 ROLLER_ENTER_UP_ANGLE2,
       T.ROLLER_DOWN_ANGLE11 ROLLER_ENTER_DOWN_ANGLE1,
       T.ROLLER_DOWN_ANGLE21 ROLLER_ENTER_DOWN_ANGLE2,
       T.ROLLER_UP_ANGLE12 ROLLER_MIDDLE_UP_ANGLE1,
       T.ROLLER_UP_ANGLE22 ROLLER_MIDDLE_UP_ANGLE2,
       T.ROLLER_DOWN_ANGLE12 ROLLER_MIDDLE_DOWN_ANGLE1,
       T.ROLLER_DOWN_ANGLE22 ROLLER_MIDDLE_DOWN_ANGLE2,
       T.ROLLER_DOWN_ANGLE13 ROLLER_EXIT_UP_ANGLE1,
       T.ROLLER_DOWN_ANGLE23 ROLLER_EXIT_UP_ANGLE2,
       T.ROLLER_UP_ANGLE13 ROLLER_EXIT_DOWN_ANGLE1,
       T.ROLLER_UP_ANGLE23 ROLLER_EXIT_DOWN_ANGLE2,
       T.ROLLER_SPACE11 ROLLER_ENTER_SPACE1,
       T.ROLLER_SPACE21 ROLLER_ENTER_SPACE2,
       T.ROLLER_SPACE12 ROLLER_MIDDLE_SPACE1,
       T.ROLLER_SPACE22 ROLLER_MIDDLE_SPACE2,
       T.ROLLER_SPACE13 ROLLER_EXIT_SPACE1,
       T.ROLLER_SPACE23 ROLLER_EXIT_SPACE2,
       T.ROLLER_UP_ANGLE31 ROLLER_UP_ANGLE1,
       T.ROLLER_UP_ANGLE32 ROLLER_UP_ANGLE2,
       T.ROLLER_UP_ANGLE33 ROLLER_UP_ANGLE3,
       T.ROLLER_UP_ANGLE34 ROLLER_UP_ANGLE4,
       T.ROLLER_UP_ANGLE35 ROLLER_UP_ANGLE5,
       T.ROLLER_DOWN_ANGLE31 ROLLER_DOWN_ANGLE1,
       T.ROLLER_DOWN_ANGLE32 ROLLER_DOWN_ANGLE2,
       T.ROLLER_DOWN_ANGLE33 ROLLER_DOWN_ANGLE3,
       T.ROLLER_DOWN_ANGLE34 ROLLER_DOWN_ANGLE4,
       T.ROLLER_DOWN_ANGLE35 ROLLER_DOWN_ANGLE5,
       T.ROLLER_SPACE31 ROLLER_SPACE1,
       T.ROLLER_SPACE32 ROLLER_SPACE2,
       T.ROLLER_SPACE33 ROLLER_SPACE3,
       T.ROLLER_SPACE34 ROLLER_SPACE4,
       T.ROLLER_SPACE35 ROLLER_SPACE5,
       
       T.MIDDLE_ROLLER_SPACE,
       T.MAIN_MOTOR_SPEED,
       (SELECT NVL(COUNT(*), 0)
          FROM MIL_STRAIGH_RACK B
         WHERE B.JUDGE_STOVE_NO = T2.JUDGE_STOVE_NO
           AND B.RESULT_NO = T2.RESULT_NO
           AND B.COL_SHIFT = T2.COL_SHIFT
           AND B.COL_GROUP = T2.COL_GROUP
           AND B.STATUS != '1'
           AND B.COL_NO = '1'
           AND B.MAT_NO IS NOT NULL) QUALIFIED_NUM1,
       (SELECT NVL(COUNT(*), 0)
          FROM MIL_STRAIGH_RACK B
         WHERE B.JUDGE_STOVE_NO = T2.JUDGE_STOVE_NO
           AND B.RESULT_NO = T2.RESULT_NO
           AND B.COL_SHIFT = T2.COL_SHIFT
           AND B.COL_GROUP = T2.COL_GROUP
           AND B.STATUS != '1'
           AND B.COL_NO = '2'
           AND B.MAT_NO IS NOT NULL) QUALIFIED_NUM2,
       (SELECT NVL(COUNT(*), 0)
          FROM MIL_STRAIGH_RACK B
         WHERE B.JUDGE_STOVE_NO = T2.JUDGE_STOVE_NO
           AND B.RESULT_NO = T2.RESULT_NO
           AND B.COL_SHIFT = T2.COL_SHIFT
           AND B.COL_GROUP = T2.COL_GROUP
           AND B.STATUS = '1'
           AND B.COL_NO = '1'
           AND B.MAT_NO IS NOT NULL) SCRAP_NUM1,
       (SELECT NVL(COUNT(*), 0)
          FROM MIL_STRAIGH_RACK B
         WHERE B.JUDGE_STOVE_NO = T2.JUDGE_STOVE_NO
           AND B.RESULT_NO = T2.RESULT_NO
           AND B.COL_SHIFT = T2.COL_SHIFT
           AND B.COL_GROUP = T2.COL_GROUP
           AND B.STATUS = '1'
           AND B.COL_NO = '2'
           AND B.MAT_NO IS NOT NULL) SCRAP_NUM2,
       (SELECT NVL(COUNT(*), 0)
          FROM MIL_STRAIGH_RACK B
         WHERE B.JUDGE_STOVE_NO = T2.JUDGE_STOVE_NO
           AND B.RESULT_NO = T2.RESULT_NO
           AND B.COL_SHIFT = T2.COL_SHIFT
           AND B.COL_GROUP = T2.COL_GROUP
           AND B.MAT_NO IS NOT NULL) QUALIFIED_NUM,
       (SELECT NVL(COUNT(*), 0)
          FROM MIL_STRAIGH_RACK B
         WHERE B.JUDGE_STOVE_NO = T2.JUDGE_STOVE_NO
           AND B.RESULT_NO = T2.RESULT_NO
           AND B.COL_SHIFT = T2.COL_SHIFT
           AND B.COL_GROUP = T2.COL_GROUP
           AND B.STATUS = '1'
           AND B.MAT_NO IS NOT NULL) SCRAP_NUM,
       CASE T2.COL_SHIFT
         WHEN '0' THEN
          '常白班'
         WHEN '1' THEN
          '早班'
         WHEN '2' THEN
          '中班'
         WHEN '3' THEN
          '夜班'
       END AS COL_SHIFT,
       CASE T2.COL_GROUP
         WHEN '1' THEN
          '甲'
         WHEN '2' THEN
          '乙'
         WHEN '3' THEN
          '丙'
         WHEN '4' THEN
          '丁'
       END AS COL_GROUP,
       T2.COL_USER,
       TO_CHAR(Max(T2.END_STRAIGHTENING_TIME), 'YYYY-MM-DD HH24:MI:SS') START_TIME,
       TRIM(T.REMARK) REMARK
  FROM MIL_STRAIGH_RACK         T2,
       MIL_STRAIGHTENING_RESULT T,
       MIL_PLAN                 T1,
       MIL_SAW_RESULT           T3
 WHERE T2.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO
   AND T2.RESULT_NO = T.RESULT_NO
   AND T2.JUDGE_STOVE_NO = T1.JUDGE_STOVE_NO
   AND T2.RESULT_NO = T1.ID
   AND T.JUDGE_STOVE_NO = T3.JUDGE_STOVE_NO
   AND T2.MAT_NO IS NOT NULL
#SOMETHING#
 GROUP BY T2.LOT_NO,
          T2.RESULT_NO,
          T2.JUDGE_STOVE_NO,
          T.PLINE_CODE,
          T1.STEELNAME,
          T1.GRADENAME,
          T1.PIPE_SIZE,
          T.ROLLER_UP_ANGLE11,
          T.ROLLER_UP_ANGLE12,
          T.ROLLER_UP_ANGLE13,
          T.ROLLER_DOWN_ANGLE11,
          T.ROLLER_DOWN_ANGLE12,
          T.ROLLER_DOWN_ANGLE13,
          T.ROLLER_SPACE11,
          T.ROLLER_SPACE12,
          T.ROLLER_SPACE13,
          T.ROLLER_UP_ANGLE21,
          T.ROLLER_UP_ANGLE22,
          T.ROLLER_UP_ANGLE23,
          T.ROLLER_DOWN_ANGLE21,
          T.ROLLER_DOWN_ANGLE22,
          T.ROLLER_DOWN_ANGLE23,
          T.ROLLER_SPACE21,
          T.ROLLER_SPACE22,
          T.ROLLER_SPACE23,
          T.ROLLER_UP_ANGLE31,
          T.ROLLER_UP_ANGLE32,
          T.ROLLER_UP_ANGLE33,
          T.ROLLER_UP_ANGLE34,
          T.ROLLER_UP_ANGLE35,
          T.ROLLER_DOWN_ANGLE31,
          T.ROLLER_DOWN_ANGLE32,
          T.ROLLER_DOWN_ANGLE33,
          T.ROLLER_DOWN_ANGLE34,
          T.ROLLER_DOWN_ANGLE35,
          T.ROLLER_SPACE31,
          T.ROLLER_SPACE32,
          T.ROLLER_SPACE33,
          T.ROLLER_SPACE34,
          T.ROLLER_SPACE35,
          T.MIDDLE_ROLLER_SPACE,
          T.MAIN_MOTOR_SPEED,
          T2.COL_SHIFT,
          T2.COL_GROUP,
          T2.COL_USER,
          T.REMARK
 ORDER BY START_TIME ASC

]]>
</query>
</queryMap>