<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="DBK公共信息">
	<query id="FrmRCLPerformance.doQuery" desc="查询实绩">		
        <![CDATA[
SELECT M.HEAT_PLAN_NO,
       M.PLINE_NAME,
       M.ZY_BATCH_ID,
       M.PRO_PLAN_ID,
       M.GX_PLAN_NO,
       M.CRAFT_FILE_NO,
       M.CRAFT_FILE_MAN,
       M.CRAFT_SEQ,
       M.JUDGE_STOVE_NO JUDGE_STOVE_NO,
       C.BATCH_NO,
       C.BATCH_GROUD_NO,
       M.GRADENAME,
       C.PLAN_INDOUBLE_NUM,
       C.PLAN_INDOUBLE_WT,
       M.ORDER_NO || '/' || M.ORDER_SEQ ORDER_NO,
       M.OUTWL_DESC,
       --M.OUT_NUM,
       --M.OUT_WT,
       M1.SPEC_NAME,
       M1.STD_NAME,
       M1.PRODUCNAME,
       M1.MODEL_DESC,
       M1.STEELNAME,
       NVL((SELECT SUM(V.ACT_COUNT)
             FROM PORT_HTT_BATCH_SAMPLE_RESULT V
            WHERE V.HEAT_PLAN_NO = M.HEAT_PLAN_NO
              AND V.MAT_STATUS IN ('10','40')
              AND V.PLINE_CODE = M.PLINE_CODE),
           0) FAIL_NUM,
       NVL((SELECT SUM(V.ACT_WEIGHT)
             FROM PORT_HTT_BATCH_SAMPLE_RESULT V
            WHERE V.HEAT_PLAN_NO = M.HEAT_PLAN_NO
              AND V.MAT_STATUS IN ('10','40')
               AND V.PLINE_CODE = M.PLINE_CODE),
           0) FAIL_WT,
       NVL((SELECT SUM(V.PRO_NUM)
             FROM HTT_COM_INFO V
            WHERE V.HEAT_PLAN_NO = M.HEAT_PLAN_NO
              AND V.STATION_CODE = '600211'
               AND V.PLINE_CODE = M.PLINE_CODE),
           0) PRO_NUM,
       NVL((SELECT SUM(V.PRO_WT)
             FROM HTT_COM_INFO V
            WHERE V.HEAT_PLAN_NO = M.HEAT_PLAN_NO
              AND V.STATION_CODE = '600211'
               AND V.PLINE_CODE = M.PLINE_CODE),
           0) PRO_WT,
       NVL((SELECT SUM(V.OFFLINE_NUM)
             FROM HTT_OFFLINE_RESULT V
            WHERE V.HEAT_PLAN_NO = M.HEAT_PLAN_NO
             AND V.PLINE_CODE = M.PLINE_CODE),
           0) OFFLINE_NUM,
       NVL((SELECT SUM(V.OFFLINE_WT)
             FROM HTT_OFFLINE_RESULT V
            WHERE V.HEAT_PLAN_NO = M.HEAT_PLAN_NO
             AND V.PLINE_CODE = M.PLINE_CODE),
           0) OFFLINE_WT,
       NVL((SELECT SUM(V.RE_NUM)
             FROM HTT_OFFLINE_RESULT V
            WHERE V.HEAT_PLAN_NO = M.HEAT_PLAN_NO
             AND V.PLINE_CODE = M.PLINE_CODE),
           0) RE_NUM,
       NVL((SELECT SUM(V.RE_WT)
             FROM HTT_OFFLINE_RESULT V
            WHERE V.HEAT_PLAN_NO = M.HEAT_PLAN_NO
             AND V.PLINE_CODE = M.PLINE_CODE),
           0) RE_WT,
       
       NVL((SELECT SUM(V.PRO_NUM)
             FROM HTT_LOADING_RESULT V
            WHERE V.HEAT_PLAN_NO = M.HEAT_PLAN_NO
             AND V.PLINE_CODE = M.PLINE_CODE),
           0) LOAD_PRO_NUM,
       NVL((SELECT SUM(V.PRO_WT)
             FROM HTT_LOADING_RESULT V
            WHERE V.HEAT_PLAN_NO = M.HEAT_PLAN_NO
             AND V.PLINE_CODE = M.PLINE_CODE),
           0) LOAD_PRO_WT,
       NVL((SELECT SUM(V1.PRO_NUM)
             FROM HTT_HHEAT_RESULT V1
            WHERE V1.HEAT_PLAN_NO = M.HEAT_PLAN_NO
             AND V1.PLINE_CODE = M.PLINE_CODE),
           0) EXP_PRO_NUM,
       NVL((SELECT SUM(V1.PRO_WT)
             FROM HTT_HHEAT_RESULT V1
            WHERE V1.HEAT_PLAN_NO = M.HEAT_PLAN_NO
            AND V1.PLINE_CODE = M.PLINE_CODE),
           0) EXP_PRO_WT,
       NVL((SELECT SUM(V1.FAIL_NUM)
             FROM HTT_HHEAT_RESULT V1
            WHERE V1.HEAT_PLAN_NO = M.HEAT_PLAN_NO
            AND V1.PLINE_CODE = M.PLINE_CODE),
           0) EXP_FAIL_NUM,
       NVL((SELECT SUM(V1.PRO_NUM)
             FROM HTT_QUENCHING_RESULT V1
            WHERE V1.HEAT_PLAN_NO = M.HEAT_PLAN_NO
            AND V1.PLINE_CODE = M.PLINE_CODE),
           0) MEA_ACC_NUM,  
       NVL((SELECT SUM(V1.PRO_NUM)
             FROM HTT_LHEAT_RESULT V1
            WHERE V1.HEAT_PLAN_NO = M.HEAT_PLAN_NO
            AND V1.PLINE_CODE = M.PLINE_CODE),
           0) REE_PRO_NUM,
       NVL((SELECT SUM(V1.PRO_WT)
             FROM HTT_LHEAT_RESULT V1
            WHERE V1.HEAT_PLAN_NO = M.HEAT_PLAN_NO
            AND V1.PLINE_CODE = M.PLINE_CODE),
           0) REE_PRO_WT,
       NVL((SELECT SUM(V1.FAIL_NUM)
             FROM HTT_LHEAT_RESULT V1
            WHERE V1.HEAT_PLAN_NO = M.HEAT_PLAN_NO
            AND V1.PLINE_CODE = M.PLINE_CODE),
           0) REE_FAIL_NUM,
       NVL((SELECT SUM(V1.PRO_NUM)
             FROM HTT_SIZING_RESULT V1
            WHERE V1.HEAT_PLAN_NO = M.HEAT_PLAN_NO
            AND V1.PLINE_CODE = M.PLINE_CODE),
           0) SIZ_PRO_NUM,
       NVL((SELECT SUM(V1.PRO_WT)
             FROM HTT_SIZING_RESULT V1
            WHERE V1.HEAT_PLAN_NO = M.HEAT_PLAN_NO
            AND V1.PLINE_CODE = M.PLINE_CODE),
           0) SIZ_PRO_WT,
       NVL((SELECT SUM(V1.FAIL_NUM)
             FROM HTT_SIZING_RESULT V1
            WHERE V1.HEAT_PLAN_NO = M.HEAT_PLAN_NO
            AND V1.PLINE_CODE = M.PLINE_CODE),
           0) SIZ_FAIL_NUM,
       NVL((SELECT SUM(V1.PRO_NUM)
             FROM HTT_HLSTRAIGHTEN_RESULT V1
            WHERE V1.HEAT_PLAN_NO = M.HEAT_PLAN_NO
            AND V1.PLINE_CODE = M.PLINE_CODE),
           0) ROT_ACC_NUM,
       NVL((SELECT SUM(V1.PRO_WT)
             FROM HTT_HLSTRAIGHTEN_RESULT V1
            WHERE V1.HEAT_PLAN_NO = M.HEAT_PLAN_NO
            AND V1.PLINE_CODE = M.PLINE_CODE),
           0) ROT_ACC_WT,
       NVL((SELECT SUM(V1.FAIL_NUM)
             FROM HTT_HLSTRAIGHTEN_RESULT V1
            WHERE V1.HEAT_PLAN_NO = M.HEAT_PLAN_NO
            AND V1.PLINE_CODE = M.PLINE_CODE),
           0) ROT_FAIL_NUM,
       NVL((SELECT SUM(V1.PRO_NUM)
             FROM HTT_CLSTRAIGHTEN_RESULT V1
            WHERE V1.HEAT_PLAN_NO = M.HEAT_PLAN_NO
            AND V1.PLINE_CODE = M.PLINE_CODE),
           0) JUM_ACC_NUM,
       NVL((SELECT SUM(V1.PRO_WT)
             FROM HTT_CLSTRAIGHTEN_RESULT V1
            WHERE V1.HEAT_PLAN_NO = M.HEAT_PLAN_NO
            AND V1.PLINE_CODE = M.PLINE_CODE),
           0) JUM_ACC_WT,
       NVL((SELECT SUM(V1.FAIL_NUM)
             FROM HTT_CLSTRAIGHTEN_RESULT V1
            WHERE V1.HEAT_PLAN_NO = M.HEAT_PLAN_NO
            AND V1.PLINE_CODE = M.PLINE_CODE),
           0) JUM_FAIL_NUM,
       NVL((SELECT SUM(V1.PASS_NUM)
             FROM HTT_APPEARANCECHECK_RESULT V1
            WHERE V1.HEAT_PLAN_NO = M.HEAT_PLAN_NO
            AND V1.PLINE_CODE = M.PLINE_CODE),
           0) HOT_ACC_NUM,
       NVL((SELECT SUM(V1.DUBIOUS_NUM)
             FROM HTT_APPEARANCECHECK_RESULT V1
            WHERE V1.HEAT_PLAN_NO = M.HEAT_PLAN_NO
            AND V1.PLINE_CODE = M.PLINE_CODE),
           0) HOT_ACC_WT,
       NVL((SELECT SUM(V1.WAST_NUM)
             FROM HTT_APPEARANCECHECK_RESULT V1
            WHERE V1.HEAT_PLAN_NO = M.HEAT_PLAN_NO
            AND V1.PLINE_CODE = M.PLINE_CODE),
           0) HOT_FAIL_NUM,
       NVL((SELECT NVL((SUM(V1.TESTING_NUM)-SUM(V1.EWASTE_NUM)),0)
             FROM HTT_CRACK_DETECTION_ET V1
            WHERE V1.HEAT_PLAN_NO = M.HEAT_PLAN_NO
            AND V1.PLINE_CODE = M.PLINE_CODE),
           0) HEA_ACC_NUM,
                  NVL((SELECT SUM(NVL(V1.EWASTE_NUM, 0)) + SUM(NVL（V1.EWASTE_NUM_ET, 0)) +
           SUM(NVL（V1.REJECTED_NUM, 0))
  FROM HTT_CRACK_DETECTION_ET V1
 WHERE V1.HEAT_PLAN_NO = M.HEAT_PLAN_NO   AND V1.PLINE_CODE = M.PLINE_CODE), 0) HEA_FAIL_NUM, --探伤废品
     NVL((SELECT SUM(MAT.ACT_COUNT)
        FROM QCM_ZG_JUGDE_APPLY MAT
       WHERE (MAT.HEAT_PLAN_NO = M.HEAT_PLAN_NO OR
       MAT.HEAT_PLAN_NO = (SELECT HEAT_PLAN_NO FROM pln_zy_rcl_m  WHERE HEAT_PLAN_NO_OLD = M.HEAT_PLAN_NO  AND IF_MATCH_ODD = '6'))
         AND MAT.VALIDFLAG != '50'), 0) MAT_NUM,
 NVL((SELECT SUM(MAT.ACT_WEIGHT)
        FROM QCM_ZG_JUGDE_APPLY MAT
       WHERE (MAT.HEAT_PLAN_NO = M.HEAT_PLAN_NO OR
       MAT.HEAT_PLAN_NO = (SELECT HEAT_PLAN_NO FROM pln_zy_rcl_m  WHERE HEAT_PLAN_NO_OLD = M.HEAT_PLAN_NO  AND IF_MATCH_ODD = '6'))
         AND MAT.VALIDFLAG != '50'), 0) MAT_WEIGHT,
 NVL((SELECT SUM(QCM.ACT_THEORY_WEIGHT)
        FROM QCM_ZG_JUGDE_APPLY QCM
       WHERE (QCM.HEAT_PLAN_NO = M.HEAT_PLAN_NO OR
       QCM.HEAT_PLAN_NO = (SELECT HEAT_PLAN_NO FROM pln_zy_rcl_m  WHERE HEAT_PLAN_NO_OLD = M.HEAT_PLAN_NO  AND IF_MATCH_ODD = '6'))
         AND QCM.VALIDFLAG != '50'), 0) QCM_THEORY_WEIGHT,  NVL((SELECT SUM(QCM.ACT_COUNT)
        FROM QCM_ZG_JUGDE_APPLY QCM
       WHERE  (QCM.HEAT_PLAN_NO = M.HEAT_PLAN_NO OR
       QCM.HEAT_PLAN_NO = (SELECT HEAT_PLAN_NO FROM pln_zy_rcl_m  WHERE HEAT_PLAN_NO_OLD = M.HEAT_PLAN_NO  AND IF_MATCH_ODD = '6'))
         AND    (QCM.JUDGE_RESULT_CODE = '40740701' OR QCM.JUDGE_RESULT_CODE =
                                                   '40740709' OR
                                       EXISTS (
SELECT 1
  FROM QCM_BC_PASS_APPLY
 WHERE JUGDE_APPLY_CODE = QCM.JUGDE_APPLY_CODE
   AND JUDGE_STOVE_NO = QCM.JUDGE_STOVE_NO
   AND BATCH_NO = QCM.BATCH_NO
   AND VALIDFLAG = '1'
   AND TYPE = '1')
)
                                   AND QCM.IS_FLAG = '0'
                                   AND QCM.IS_ALL_SCRAP IN ('0', '2')), 0) QCM_NUM,  NVL((SELECT SUM(QCM.ACT_WEIGHT)
        FROM QCM_ZG_JUGDE_APPLY QCM
       WHERE (QCM.HEAT_PLAN_NO = M.HEAT_PLAN_NO OR
       QCM.HEAT_PLAN_NO = (SELECT HEAT_PLAN_NO FROM pln_zy_rcl_m  WHERE HEAT_PLAN_NO_OLD = M.HEAT_PLAN_NO  AND IF_MATCH_ODD = '6'))
         AND    (QCM.JUDGE_RESULT_CODE = '40740701' OR QCM.JUDGE_RESULT_CODE =
                                                   '40740709' OR
                                       EXISTS (
SELECT 1
  FROM QCM_BC_PASS_APPLY
 WHERE JUGDE_APPLY_CODE = QCM.JUGDE_APPLY_CODE
   AND JUDGE_STOVE_NO = QCM.JUDGE_STOVE_NO
   AND BATCH_NO = QCM.BATCH_NO
   AND VALIDFLAG = '1'
   AND TYPE = '1')
)
                                   AND QCM.IS_FLAG = '0'
                                   AND QCM.IS_ALL_SCRAP IN ('0', '2')), 0) QCM_WEIGHT,  NVL((SELECT SUM(QCM.ACT_THEORY_WEIGHT)
        FROM QCM_ZG_JUGDE_APPLY QCM
       WHERE  (QCM.HEAT_PLAN_NO = M.HEAT_PLAN_NO OR
       QCM.HEAT_PLAN_NO = (SELECT HEAT_PLAN_NO FROM pln_zy_rcl_m  WHERE HEAT_PLAN_NO_OLD = M.HEAT_PLAN_NO  AND IF_MATCH_ODD = '6'))
         AND    (QCM.JUDGE_RESULT_CODE = '40740701' OR QCM.JUDGE_RESULT_CODE =
                                                   '40740709' OR
                                      EXISTS (
SELECT 1
  FROM QCM_BC_PASS_APPLY
 WHERE JUGDE_APPLY_CODE = QCM.JUGDE_APPLY_CODE
   AND JUDGE_STOVE_NO = QCM.JUDGE_STOVE_NO
   AND BATCH_NO = QCM.BATCH_NO
   AND VALIDFLAG = '1'
   AND TYPE = '1')
)
                                   AND QCM.IS_FLAG = '0'
                                   AND QCM.IS_ALL_SCRAP IN ('0', '2')), 0) THEORY_WEIGHT,
       MIN(TO_CHAR(T1.LOAD_TIME, 'YYYY-MM-DD HH24:MI:SS')) LOAD_TIME,
(SELECT MIN(V.BAL_YEAR_MONTH)
          FROM HTT_COM_INFO V
         WHERE V.HEAT_PLAN_NO = M.HEAT_PLAN_NO
         AND V.PLINE_CODE = M.PLINE_CODE
           AND V.STATION_CODE = '600201') BAL_YEAR_MONTH
  FROM HTT_COM_INFO       T,
       PLN_ZY_RCL_M       M,
       PLN_ZY_RCL_C       C,
       PLN_SALEORD        M1,
       HTT_LOADING_RESULT T1
 WHERE M.HEAT_PLAN_NO = T.HEAT_PLAN_NO
 and M.HEAT_PLAN_NO = C.HEAT_PLAN_NO
   AND M.HEAT_PLAN_NO = T1.HEAT_PLAN_NO(+)
   AND M.ORD_LN_DLY_PK = M1.ORD_LN_DLY_PK(+)
        ]]>
	</query>
	<query id="FrmRCLPerformance.doQueryPort" desc="查询进程">		
        <![CDATA[
SELECT M.HEAT_PLAN_NO, --炉计划ID
       T.PLINE_NAME, --产线
       M.ZY_BATCH_ID, -- 生产批号
       M.PRO_PLAN_ID, --热处理订单编号
       M.GX_PLAN_NO, -- 热处理订单排产序号
       M.CRAFT_FILE_NO, --工艺文件号
       M.CRAFT_FILE_MAN, --工艺文件责任人
       M.CRAFT_SEQ, --工艺序号
       M.JUDGE_STOVE_NO, --判定炉号
       M.PROCESS_DESC_C, --二级工序名
       M.GRADENAME, -- 钢种
       T.BAL_YEAR_MONTH, --生产年月
       C.PLAN_INDOUBLE_NUM, --排产支
       C.PLAN_INDOUBLE_WT, ---排产吨
       T.FAIL_NUM, --废品支
       T.FAIL_WT, --废品吨
       T.PRO_NUM, --下线支
       T.PRO_WT, --下线吨
       T.ZL_ACT_COUNT, --已组炉支
       T. ZL_ACT_WEIGHT, --已组炉吨
       T.FLAG, -- 存在待处理标志
       T.FLAG1, --- 存在未下线合格管标志
       NVL((SELECT SUM(V.OFFLINE_NUM)
             FROM HTT_OFFLINE_RESULT V
            WHERE V.HEAT_PLAN_NO = M.HEAT_PLAN_NO
              AND V.PROCESS_SEQ = T.PROCESS_SEQ),
           0) OFFLINE_NUM, --总离线支
       NVL((SELECT SUM(V.OFFLINE_WT)
             FROM HTT_OFFLINE_RESULT V
            WHERE V.HEAT_PLAN_NO = M.HEAT_PLAN_NO
              AND V.PROCESS_SEQ = T.PROCESS_SEQ),
           0) OFFLINE_WT, --总离线吨
       NVL((SELECT SUM(V.RE_NUM)
             FROM HTT_OFFLINE_RESULT V
            WHERE V.HEAT_PLAN_NO = M.HEAT_PLAN_NO
              AND V.PROCESS_SEQ = T.PROCESS_SEQ),
           0) RE_NUM, --总返线支
       NVL((SELECT SUM(V.RE_WT)
             FROM HTT_OFFLINE_RESULT V
            WHERE V.HEAT_PLAN_NO = M.HEAT_PLAN_NO
              AND V.PROCESS_SEQ = T.PROCESS_SEQ),
           0) RE_WT, -- 总返线吨
     DECODE(M.IF_MATCH_ODD,2, NVL(C.REAL_INDOUBLE_NUM,0),  NVL((SELECT SUM(H.PRO_NUM)
             FROM HTT_LOADING_RESULT H
            WHERE H.HEAT_PLAN_NO = M.HEAT_PLAN_NO
              AND H.PROCESS_SEQ = T.PROCESS_SEQ),
           0)) LOAD_PRO_NUM, --上料支
         DECODE(M.IF_MATCH_ODD,2, NVL(C.REAL_INDOUBLE_WT,0),NVL((SELECT SUM(H.PRO_WT)
             FROM HTT_LOADING_RESULT H
            WHERE H.HEAT_PLAN_NO = M.HEAT_PLAN_NO
              AND H.PROCESS_SEQ = T.PROCESS_SEQ),
           0)) LOAD_PRO_WT, -- 上料吨
       NVL((SELECT SUM(V1.PRO_NUM)
             FROM HTT_HHEAT_RESULT V1
            WHERE V1.HEAT_PLAN_NO = M.HEAT_PLAN_NO
              AND V1.PROCESS_SEQ = T.PROCESS_SEQ),
           0) EXP_PRO_NUM, -- 高温炉支
       NVL((SELECT SUM(V1.PRO_WT)
             FROM HTT_HHEAT_RESULT V1
            WHERE V1.HEAT_PLAN_NO = M.HEAT_PLAN_NO
              AND V1.PROCESS_SEQ = T.PROCESS_SEQ),
           0) EXP_PRO_WT, --高温炉吨
       NVL((SELECT SUM(V1.FAIL_NUM)
             FROM HTT_HHEAT_RESULT V1
            WHERE V1.HEAT_PLAN_NO = M.HEAT_PLAN_NO
              AND V1.PROCESS_SEQ = T.PROCESS_SEQ),
           0) EXP_FAIL_NUM, -- 高温炉废品支
       NVL((SELECT SUM(V1.PRO_NUM)
             FROM HTT_QUENCHING_RESULT V1
            WHERE V1.HEAT_PLAN_NO = M.HEAT_PLAN_NO
              AND V1.PROCESS_SEQ = T.PROCESS_SEQ),
           0) MEA_ACC_NUM, -- 淬火支
       NVL((SELECT SUM(V1.PRO_NUM)
             FROM HTT_LHEAT_RESULT V1
            WHERE V1.HEAT_PLAN_NO = M.HEAT_PLAN_NO
              AND V1.PROCESS_SEQ = T.PROCESS_SEQ),
           0) REE_PRO_NUM,
       - -- 低温炉支
       NVL((SELECT SUM(V1.PRO_WT)
             FROM HTT_LHEAT_RESULT V1
            WHERE V1.HEAT_PLAN_NO = M.HEAT_PLAN_NO
              AND V1.PROCESS_SEQ = T.PROCESS_SEQ),
           0) REE_PRO_WT, -- 低温炉吨
       NVL((SELECT SUM(V1.FAIL_NUM)
             FROM HTT_LHEAT_RESULT V1
            WHERE V1.HEAT_PLAN_NO = M.HEAT_PLAN_NO
              AND V1.PROCESS_SEQ = T.PROCESS_SEQ),
           0) REE_FAIL_NUM, -- 低温炉废品
       NVL((SELECT SUM(V1.PRO_NUM)
             FROM HTT_SIZING_RESULT V1
            WHERE V1.HEAT_PLAN_NO = M.HEAT_PLAN_NO
              AND V1.PROCESS_SEQ = T.PROCESS_SEQ),
           0) SIZ_PRO_NUM, -- 定径支
       NVL((SELECT SUM(V1.PRO_WT)
             FROM HTT_SIZING_RESULT V1
            WHERE V1.HEAT_PLAN_NO = M.HEAT_PLAN_NO
              AND V1.PROCESS_SEQ = T.PROCESS_SEQ),
           0) SIZ_PRO_WT, -- 定径吨
       NVL((SELECT SUM(V1.FAIL_NUM)
             FROM HTT_SIZING_RESULT V1
            WHERE V1.HEAT_PLAN_NO = M.HEAT_PLAN_NO
              AND V1.PROCESS_SEQ = T.PROCESS_SEQ),
           0) SIZ_FAIL_NUM, -- 定径废品
       NVL((SELECT SUM(V1.PRO_NUM)
             FROM HTT_HLSTRAIGHTEN_RESULT V1
            WHERE V1.HEAT_PLAN_NO = M.HEAT_PLAN_NO
              AND V1.PROCESS_SEQ = T.PROCESS_SEQ),
           0) ROT_ACC_NUM, -- 热矫支
       NVL((SELECT SUM(V1.PRO_WT)
             FROM HTT_HLSTRAIGHTEN_RESULT V1
            WHERE V1.HEAT_PLAN_NO = M.HEAT_PLAN_NO
              AND V1.PROCESS_SEQ = T.PROCESS_SEQ),
           0) ROT_ACC_WT, --- 热矫吨
       NVL((SELECT SUM(V1.FAIL_NUM)
             FROM HTT_HLSTRAIGHTEN_RESULT V1
            WHERE V1.HEAT_PLAN_NO = M.HEAT_PLAN_NO
              AND V1.PROCESS_SEQ = T.PROCESS_SEQ),
           0) ROT_FAIL_NUM, -- 热矫废品
       NVL((SELECT SUM(V1.PRO_NUM)
             FROM HTT_CLSTRAIGHTEN_RESULT V1
            WHERE V1.HEAT_PLAN_NO = M.HEAT_PLAN_NO
              AND V1.PROCESS_SEQ = T.PROCESS_SEQ),
           0) JUM_ACC_NUM, --冷矫支
       NVL((SELECT SUM(V1.PRO_WT)
             FROM HTT_CLSTRAIGHTEN_RESULT V1
            WHERE V1.HEAT_PLAN_NO = M.HEAT_PLAN_NO
              AND V1.PROCESS_SEQ = T.PROCESS_SEQ),
           0) JUM_ACC_WT, --冷矫吨
       NVL((SELECT SUM(V1.FAIL_NUM)
             FROM HTT_CLSTRAIGHTEN_RESULT V1
            WHERE V1.HEAT_PLAN_NO = M.HEAT_PLAN_NO
              AND V1.PROCESS_SEQ = T.PROCESS_SEQ),
           0) JUM_FAIL_NUM, --冷矫废品，
       NVL((SELECT SUM(V1.PASS_NUM)
             FROM HTT_APPEARANCECHECK_RESULT V1
            WHERE V1.HEAT_PLAN_NO = M.HEAT_PLAN_NO
              AND V1.PROCESS_SEQ = T.PROCESS_SEQ),
           0) HOT_ACC_NUM, --表检支
       NVL((SELECT SUM(V1.DUBIOUS_NUM)
             FROM HTT_APPEARANCECHECK_RESULT V1
            WHERE V1.HEAT_PLAN_NO = M.HEAT_PLAN_NO
              AND V1.PROCESS_SEQ = T.PROCESS_SEQ),
           0) HOT_ACC_WT, --表检吨
       NVL((SELECT SUM(V1.WAST_NUM)
             FROM HTT_APPEARANCECHECK_RESULT V1
            WHERE V1.HEAT_PLAN_NO = M.HEAT_PLAN_NO
              AND V1.PROCESS_SEQ = T.PROCESS_SEQ),
           0) HOT_FAIL_NUM, --表检废品
       NVL((SELECT NVL((SUM(V1.TESTING_NUM) - SUM(V1.EWASTE_NUM)), 0)
             FROM HTT_CRACK_DETECTION_ET V1
            WHERE V1.HEAT_PLAN_NO = M.HEAT_PLAN_NO
              AND V1.PROCESS_SEQ = T.PROCESS_SEQ),
           0) HEA_ACC_NUM, --探伤支
       NVL((SELECT SUM(NVL(V1.EWASTE_NUM, 0)) + SUM(NVL（V1.EWASTE_NUM_ET, 0)) +
           SUM(NVL（V1.REJECTED_NUM, 0))
  FROM HTT_CRACK_DETECTION_ET V1
 WHERE V1.HEAT_PLAN_NO = M.HEAT_PLAN_NO
   AND V1.PROCESS_SEQ = T.PROCESS_SEQ), 0) HEA_FAIL_NUM, --探伤废品

  NVL((SELECT SUM(MAT.ACT_COUNT)
        FROM QCM_ZG_JUGDE_APPLY MAT
       WHERE (MAT.HEAT_PLAN_NO = M.HEAT_PLAN_NO OR
       MAT.HEAT_PLAN_NO = (SELECT HEAT_PLAN_NO FROM pln_zy_rcl_m  WHERE HEAT_PLAN_NO_OLD = M.HEAT_PLAN_NO  AND IF_MATCH_ODD = '6'))
         AND MAT.VALIDFLAG != '50'), 0) MAT_NUM,
 NVL((SELECT SUM(MAT.ACT_WEIGHT)
        FROM QCM_ZG_JUGDE_APPLY MAT
       WHERE (MAT.HEAT_PLAN_NO = M.HEAT_PLAN_NO OR
       MAT.HEAT_PLAN_NO = (SELECT HEAT_PLAN_NO FROM pln_zy_rcl_m  WHERE HEAT_PLAN_NO_OLD = M.HEAT_PLAN_NO  AND IF_MATCH_ODD = '6'))
         AND MAT.VALIDFLAG != '50'), 0) MAT_WEIGHT,
 NVL((SELECT SUM(QCM.ACT_THEORY_WEIGHT)
        FROM QCM_ZG_JUGDE_APPLY QCM
       WHERE (QCM.HEAT_PLAN_NO = M.HEAT_PLAN_NO OR
       QCM.HEAT_PLAN_NO = (SELECT HEAT_PLAN_NO FROM pln_zy_rcl_m  WHERE HEAT_PLAN_NO_OLD = M.HEAT_PLAN_NO  AND IF_MATCH_ODD = '6'))
         AND QCM.VALIDFLAG != '50'), 0) QCM_THEORY_WEIGHT,  NVL((SELECT SUM(QCM.ACT_COUNT)
        FROM QCM_ZG_JUGDE_APPLY QCM
       WHERE  (QCM.HEAT_PLAN_NO = M.HEAT_PLAN_NO OR
       QCM.HEAT_PLAN_NO = (SELECT HEAT_PLAN_NO FROM pln_zy_rcl_m  WHERE HEAT_PLAN_NO_OLD = M.HEAT_PLAN_NO  AND IF_MATCH_ODD = '6'))
         AND    (QCM.JUDGE_RESULT_CODE = '40740701' OR QCM.JUDGE_RESULT_CODE =
                                                   '40740709' OR
                                       EXISTS (
SELECT 1
  FROM QCM_BC_PASS_APPLY
 WHERE JUGDE_APPLY_CODE = QCM.JUGDE_APPLY_CODE
   AND JUDGE_STOVE_NO = QCM.JUDGE_STOVE_NO
   AND BATCH_NO = QCM.BATCH_NO
   AND VALIDFLAG = '1'
   AND TYPE = '1')
)
                                   AND QCM.IS_FLAG = '0'
                                   AND QCM.IS_ALL_SCRAP IN ('0', '2')), 0) QCM_NUM,  NVL((SELECT SUM(QCM.ACT_WEIGHT)
        FROM QCM_ZG_JUGDE_APPLY QCM
       WHERE (QCM.HEAT_PLAN_NO = M.HEAT_PLAN_NO OR
       QCM.HEAT_PLAN_NO = (SELECT HEAT_PLAN_NO FROM pln_zy_rcl_m  WHERE HEAT_PLAN_NO_OLD = M.HEAT_PLAN_NO  AND IF_MATCH_ODD = '6'))
         AND    (QCM.JUDGE_RESULT_CODE = '40740701' OR QCM.JUDGE_RESULT_CODE =
                                                   '40740709' OR
                                       EXISTS (
SELECT 1
  FROM QCM_BC_PASS_APPLY
 WHERE JUGDE_APPLY_CODE = QCM.JUGDE_APPLY_CODE
   AND JUDGE_STOVE_NO = QCM.JUDGE_STOVE_NO
   AND BATCH_NO = QCM.BATCH_NO
   AND VALIDFLAG = '1'
   AND TYPE = '1')
)
                                   AND QCM.IS_FLAG = '0'
                                   AND QCM.IS_ALL_SCRAP IN ('0', '2')), 0) QCM_WEIGHT,  NVL((SELECT SUM(QCM.ACT_THEORY_WEIGHT)
        FROM QCM_ZG_JUGDE_APPLY QCM
       WHERE  (QCM.HEAT_PLAN_NO = M.HEAT_PLAN_NO OR
       QCM.HEAT_PLAN_NO = (SELECT HEAT_PLAN_NO FROM pln_zy_rcl_m  WHERE HEAT_PLAN_NO_OLD = M.HEAT_PLAN_NO  AND IF_MATCH_ODD = '6'))
         AND    (QCM.JUDGE_RESULT_CODE = '40740701' OR QCM.JUDGE_RESULT_CODE =
                                                   '40740709' OR
                                       EXISTS (
SELECT 1
  FROM QCM_BC_PASS_APPLY
 WHERE JUGDE_APPLY_CODE = QCM.JUGDE_APPLY_CODE
   AND JUDGE_STOVE_NO = QCM.JUDGE_STOVE_NO
   AND BATCH_NO = QCM.BATCH_NO
   AND VALIDFLAG = '1'
   AND TYPE = '1')
)
                                   AND QCM.IS_FLAG = '0'
                                   AND QCM.IS_ALL_SCRAP IN ('0', '2')), 0) THEORY_WEIGHT,
                   M.LOADTIME LOAD_TIME, -- 上料时间
 DECODE(M.IF_MATCH_ODD, '0', '正常计划', '1', '利库计划', '2', '组炉计划') IF_MATCH_ODD, -- 计划状态
 M.ORDER_NO || '/' || M.ORDER_SEQ  ORDER_NO, --合同号
 M.OUTWL_DESC, --产出物料描述
 M.SPEC_NAME, --产品规格描述
 M.STD_NAME, --标准名称
 M.PRODUCNAME, --品名描述
 M.MODEL_DESC, --扣型描述
 M.STEELNAME, --钢级名称
 T.PROCESS_SEQ -- 热处理次数
 FROM (SELECT HEAT_PLAN_NO,
              PROCESS_SEQ,
              MIN(BAL_YEAR_MONTH) BAL_YEAR_MONTH,
              SUM(CASE
                    WHEN T.MAT_STATUS = '10' OR T.MAT_STATUS = '40' THEN
                     T.ACT_COUNT
                    ELSE
                     0
                  END) FAIL_NUM, --废品支
              SUM(CASE
                    WHEN T.MAT_STATUS = '10' OR T.MAT_STATUS = '40' THEN
                     T.ACT_WEIGHT
                    ELSE
                     0
                  END) FAIL_WT, --废品吨
              SUM(CASE
                    WHEN T.INSTORE_FLAG = '1' THEN
                     T.ACT_COUNT
                    ELSE
                     0
                  END) PRO_NUM, --下线支
              SUM(CASE
                    WHEN T.INSTORE_FLAG = '1' OR T.MAT_STATUS = '40' THEN
                     T.ACT_WEIGHT
                    ELSE
                     0
                  END) PRO_WT, --下线吨
              SUM(CASE
                    WHEN T.MAT_STATUS = '20' THEN
                     T.ACT_COUNT
                    ELSE
                     0
                  END) OFFLINE_NUM, --离线支
              SUM(CASE
                    WHEN T.MAT_STATUS = '20' THEN
                     T.ACT_WEIGHT
                    ELSE
                     0
                  END) OFFLINE_WT, --离线吨
              SUM(CASE
                    WHEN T.MAT_STATUS = '30' THEN
                     T.ACT_COUNT
                    ELSE
                     0
                  END) ZL_ACT_COUNT, --已组炉支
              SUM(CASE
                    WHEN T.MAT_STATUS = '30' THEN
                     T.ACT_WEIGHT
                    ELSE
                     0
                  END) ZL_ACT_WEIGHT, --已组炉吨
              SUM(CASE
                    WHEN T.MAT_STATUS = '20' THEN
                     1
                    ELSE
                     0
                  END) FLAG, -- 存在待处理标志
              SUM(CASE
                    WHEN T.MAT_STATUS = '00' AND T.INSTORE_FLAG = '0' THEN
                     1
                    ELSE
                     0
                  END) FLAG1, --- 存在未下线合格管标志
                   SUM(CASE
                    WHEN T.MAT_STATUS = '00' AND T.INSTORE_FLAG = '1'  AND JUGDE_APPLY_CODE IS NULL  THEN
                     1
                    ELSE
                     0
                  END) FLAG2, --- 存在下线未送判
                      SUM(CASE
                    WHEN (T.MAT_STATUS = '00' OR T.MAT_STATUS = '20') AND JUGDE_APPLY_CODE IS NULL   THEN
                     1
                    ELSE
                     0
                  END) FLAG3, --- 存在未缴库
                  T.PLINE_NAME, T.PLINE_CODE
         FROM PORT_HTT_BATCH_SAMPLE_RESULT T
        GROUP BY HEAT_PLAN_NO, PROCESS_SEQ,T.PLINE_NAME, T.PLINE_CODE) T, PLN_ZY_RCL_M M, (SELECT HEAT_PLAN_NO,
                                                                       SUM(PLAN_INDOUBLE_NUM) PLAN_INDOUBLE_NUM,
                                                                       SUM(PLAN_INDOUBLE_WT) PLAN_INDOUBLE_WT,
                                                                       SUM(REAL_INDOUBLE_NUM) REAL_INDOUBLE_NUM ,
                                                                              SUM(REAL_INDOUBLE_WT) REAL_INDOUBLE_WT
                                                                  FROM PLN_ZY_RCL_C
                                                                 GROUP BY HEAT_PLAN_NO) C
 WHERE M.HEAT_PLAN_NO = T.HEAT_PLAN_NO
   AND M.HEAT_PLAN_NO = C.HEAT_PLAN_NO

        ]]>
	</query>
</queryMap>