<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc = "管排锯">
<query id = "FrmTubeAccord.queryMinResult" desc = "查询">
<![CDATA[
SELECT T.LOT_NO,
       REGEXP_REPLACE(T.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,
       COUNT(T2.SEQ) AS CUT_NUM,
       (SELECT COUNT(*)
          FROM MIL_SAW_RACK T3
         WHERE T3.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO
           AND T3.COL_USER = T2.COL_USER
           AND T3.COL_SHIFT = T2.COL_SHIFT
           AND T3.COL_GROUP = T2.COL_GROUP
           AND T3.STATUS = 1) ASSCRAP_NUM,
       (COUNT(T2.SEQ) * T1.SAW_NUM) AS CUT_DBNUM,
       T1.LENGTH_RANGE AS ORDER_LENGTH_MIN,
       T.CUT_HEAD_LENGTH,
       T.CUT_TRAIL_LENGTH,
       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(T2.END_SAW_TIME, 'YYYY-MM-DD HH24:MI:SS') START_TIME,
       T.REMARK
  FROM MIL_SAW_RESULT T, MIL_PLAN T1, MIL_SAW_RACK T2
 WHERE T.JUDGE_STOVE_NO = T1.JUDGE_STOVE_NO
   AND T.JUDGE_STOVE_NO = T2.JUDGE_STOVE_NO
   AND T2.COL_SHIFT IS NOT NULL
   AND T2.COL_GROUP IS NOT NULL
]]>
</query>
</queryMap>