<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="DBK公共信息">
	<query id="FrmJGXPerformance.doQuery" desc="查询DBK实绩">		
        <![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,
       T.GRADENAME,
       MAX(T.BAL_YEAR_MONTH) BAL_YEAR_MONTH,
       C.PLAN_INDOUBLE_NUM,
       C.PLAN_INDOUBLE_WT,
       M.ORDER_NO || '/' || M.ORDER_SEQ ORDER_NO,
       M.OUTWL_DESC,
                     M1.SPEC_NAME,
       M1.STD_NAME,
       M1.PRODUCNAME,
       M1.MODEL_DESC,
       M1.STEELNAME,
          NVL((SELECT SUM(V.ACT_COUNT)
             FROM port_mch_batch_sample_result V
            WHERE V.HEAT_PLAN_NO = M.HEAT_PLAN_NO
            AND V.PLINE_CODE = M.PLINE_CODE
            AND V.BATCH_NO = C.BATCH_NO
              AND V.MAT_STATUS = '10'),
           0) FAIL_NUM,
       NVL((SELECT SUM(V.ACT_WEIGHT)
             FROM port_mch_batch_sample_result V
            WHERE V.HEAT_PLAN_NO = M.HEAT_PLAN_NO
            AND V.PLINE_CODE = M.PLINE_CODE
             AND V.BATCH_NO = C.BATCH_NO
              AND V.MAT_STATUS = '10'),
           0) FAIL_WT,
       NVL((SELECT SUM(V.PRO_NUM)
             FROM MCH_COM_INFO V
            WHERE V.HEAT_PLAN_NO = M.HEAT_PLAN_NO
            AND V.PLINE_CODE = M.PLINE_CODE
             AND V.BATCH_NO = C.BATCH_NO
              AND V.STATION_CODE = '701311'),
           0) PRO_NUM,
       NVL((SELECT SUM(V.PRO_WT)
             FROM MCH_COM_INFO V
            WHERE V.HEAT_PLAN_NO = M.HEAT_PLAN_NO
            AND V.PLINE_CODE = M.PLINE_CODE
             AND V.BATCH_NO = C.BATCH_NO
              AND V.STATION_CODE = '701311'),
           0) PRO_WT,
       NVL((SELECT SUM(V.OFFLINE_NUM)
             FROM MCH_OFFLINE_RESULT V
            WHERE V.HEAT_PLAN_NO = M.HEAT_PLAN_NO
             AND V.BATCH_NO = C.BATCH_NO
            AND V.PLINE_CODE = M.PLINE_CODE),
           0) OFFLINE_NUM,
       NVL((SELECT SUM(V.OFFLINE_WT)
             FROM MCH_OFFLINE_RESULT V
            WHERE V.HEAT_PLAN_NO = M.HEAT_PLAN_NO
             AND V.BATCH_NO = C.BATCH_NO
            AND V.PLINE_CODE = M.PLINE_CODE),
           0) OFFLINE_WT,
       NVL((SELECT SUM(V.RE_NUM)
             FROM MCH_OFFLINE_RESULT V
            WHERE V.HEAT_PLAN_NO = M.HEAT_PLAN_NO
             AND V.BATCH_NO = C.BATCH_NO
            AND V.PLINE_CODE = M.PLINE_CODE),
           0) RE_NUM,
       NVL((SELECT SUM(V.RE_WT)
             FROM MCH_OFFLINE_RESULT V
            WHERE V.HEAT_PLAN_NO = M.HEAT_PLAN_NO
             AND V.BATCH_NO = C.BATCH_NO
            AND V.PLINE_CODE = M.PLINE_CODE),
           0) RE_WT,
       NVL((SELECT SUM(V.PRO_NUM)
             FROM MCH_LOADING_RESULT V
            WHERE V.HEAT_PLAN_NO = M.HEAT_PLAN_NO
             AND V.BATCH_NO = C.BATCH_NO
            AND V.PLINE_CODE = M.PLINE_CODE),
           0) LOAD_PRO_NUM,
       NVL((SELECT SUM(V.PRO_WT)
             FROM MCH_LOADING_RESULT V
            WHERE V.HEAT_PLAN_NO = M.HEAT_PLAN_NO
             AND V.BATCH_NO = C.BATCH_NO
            AND V.PLINE_CODE = M.PLINE_CODE),
           0) LOAD_PRO_WT,
   
       NVL((SELECT SUM(V1.TESTING_NUM)
             FROM htt_crack_detection_et V1
            WHERE V1.HEAT_PLAN_NO = M.HEAT_PLAN_NO
            AND V1.BATCH_NO = C.BATCH_NO
            AND V1.PROCESS_CODE = 'G'
            AND V1.PLINE_CODE = M.PLINE_CODE),
           0) MEA_ACC_NUM,        NVL((SELECT SUM(V1.TESTING_WT)
             FROM htt_crack_detection_et V1
            WHERE V1.HEAT_PLAN_NO = M.HEAT_PLAN_NO
             AND V1.PROCESS_CODE = 'G'
            AND V1.BATCH_NO = C.BATCH_NO
            AND V1.PLINE_CODE = M.PLINE_CODE),
           0) MEA_ACC_WT,
       NVL((SELECT SUM(V1.EWASTE_NUM)
             FROM htt_crack_detection_et V1    
            WHERE V1.HEAT_PLAN_NO = M.HEAT_PLAN_NO
             AND V1.PROCESS_CODE = 'G'
            AND V1.BATCH_NO = C.BATCH_NO
            AND V1.PLINE_CODE = M.PLINE_CODE),
           0) MEA_FAIL_NUM,
       NVL((SELECT SUM(V1.PRO_NUM)
             FROM MCH_CUT_RESULT V1
            WHERE V1.HEAT_PLAN_NO = M.HEAT_PLAN_NO
            AND V1.BATCH_NO = C.BATCH_NO
            AND V1.PLINE_CODE = M.PLINE_CODE),
           0) REE_PRO_NUM,        NVL((SELECT SUM(V1.PRO_WT)
             FROM MCH_CUT_RESULT V1
            WHERE V1.HEAT_PLAN_NO = M.HEAT_PLAN_NO
            AND V1.BATCH_NO = C.BATCH_NO
            AND V1.PLINE_CODE = M.PLINE_CODE),
           0) REE_PRO_WT,
       NVL((SELECT SUM(V1.FAIL_NUM)
             FROM MCH_CUT_RESULT V1
            WHERE V1.HEAT_PLAN_NO = M.HEAT_PLAN_NO
            AND V1.BATCH_NO = C.BATCH_NO
            AND V1.PLINE_CODE = M.PLINE_CODE),
           0) REE_FAIL_NUM,
       NVL((SELECT SUM(V1.PRO_NUM)
             FROM MCH_THREADER_RESULT V1
            WHERE V1.HEAT_PLAN_NO = M.HEAT_PLAN_NO
            AND V1.BATCH_NO = C.BATCH_NO
            AND V1.PLINE_CODE = M.PLINE_CODE),
           0) SIZ_PRO_NUM,        NVL((SELECT SUM(V1.PRO_WT)
             FROM MCH_THREADER_RESULT V1
            WHERE V1.HEAT_PLAN_NO = M.HEAT_PLAN_NO
            AND V1.BATCH_NO = C.BATCH_NO
            AND V1.PLINE_CODE = M.PLINE_CODE),
           0) SIZ_PRO_WT,
       NVL((SELECT SUM(V1.FAIL_NUM)
             FROM MCH_THREADER_RESULT V1
            WHERE V1.HEAT_PLAN_NO = M.HEAT_PLAN_NO
            AND V1.BATCH_NO = C.BATCH_NO
            AND V1.PLINE_CODE = M.PLINE_CODE),
           0) SIZ_FAIL_NUM,
       NVL((SELECT SUM(V1.PRO_NUM)
             FROM MCH_HREAD_RESULT V1
            WHERE V1.HEAT_PLAN_NO = M.HEAT_PLAN_NO
            AND V1.BATCH_NO = C.BATCH_NO
            AND V1.PLINE_CODE = M.PLINE_CODE),
           0) ROT_ACC_NUM,        NVL((SELECT SUM(V1.PRO_WT)
             FROM MCH_HREAD_RESULT V1
            WHERE V1.HEAT_PLAN_NO = M.HEAT_PLAN_NO
            AND V1.BATCH_NO = C.BATCH_NO
            AND V1.PLINE_CODE = M.PLINE_CODE),
           0) ROT_ACC_WT,
       NVL((SELECT SUM(V1.FAIL_NUM)
             FROM MCH_HREAD_RESULT V1
            WHERE V1.HEAT_PLAN_NO = M.HEAT_PLAN_NO
            AND V1.BATCH_NO = C.BATCH_NO
            AND V1.PLINE_CODE = M.PLINE_CODE),
           0) ROT_FAIL_NUM,
       NVL((SELECT SUM(V1.PRO_NUM)
             FROM MCH_TWISTINGLY_RESULT V1
            WHERE V1.HEAT_PLAN_NO = M.HEAT_PLAN_NO
            AND V1.BATCH_NO = C.BATCH_NO
            AND V1.PLINE_CODE = M.PLINE_CODE),
           0) JUM_ACC_NUM,        NVL((SELECT SUM(V1.PRO_WT)
             FROM MCH_TWISTINGLY_RESULT V1
            WHERE V1.HEAT_PLAN_NO = M.HEAT_PLAN_NO
            AND V1.BATCH_NO = C.BATCH_NO
            AND V1.PLINE_CODE = M.PLINE_CODE),
           0) JUM_ACC_WT,
       NVL((SELECT SUM(V1.FAIL_NUM)
             FROM MCH_TWISTINGLY_RESULT V1
            WHERE V1.HEAT_PLAN_NO = M.HEAT_PLAN_NO
            AND V1.BATCH_NO = C.BATCH_NO
            AND V1.PLINE_CODE = M.PLINE_CODE),
           0) JUM_FAIL_NUM,
       NVL((SELECT SUM(V1.PRO_NUM)
             FROM MCH_PATH_RESULT V1
            WHERE V1.HEAT_PLAN_NO = M.HEAT_PLAN_NO
            AND V1.BATCH_NO = C.BATCH_NO
            AND V1.PLINE_CODE = M.PLINE_CODE),
           0) HOT_ACC_NUM,        NVL((SELECT SUM(V1.PRO_WT)
             FROM MCH_PATH_RESULT V1
            WHERE V1.HEAT_PLAN_NO = M.HEAT_PLAN_NO
            AND V1.BATCH_NO = C.BATCH_NO
            AND V1.PLINE_CODE = M.PLINE_CODE),
           0) HOT_ACC_WT,
       NVL((SELECT SUM(V1.FAIL_NUM)
             FROM MCH_PATH_RESULT V1
            WHERE V1.HEAT_PLAN_NO = M.HEAT_PLAN_NO
            AND V1.BATCH_NO = C.BATCH_NO
            AND V1.PLINE_CODE = M.PLINE_CODE),
           0) HOT_FAIL_NUM,
       NVL((SELECT SUM(V1.PRO_NUM)
             FROM MCH_WATERGAGE_RESULT V1
            WHERE V1.HEAT_PLAN_NO = M.HEAT_PLAN_NO
            AND V1.BATCH_NO = C.BATCH_NO
            AND V1.PLINE_CODE = M.PLINE_CODE),
           0) HEA_ACC_NUM,        NVL((SELECT SUM(V1.PRO_WT)
             FROM MCH_WATERGAGE_RESULT V1
            WHERE V1.HEAT_PLAN_NO = M.HEAT_PLAN_NO
            AND V1.BATCH_NO = C.BATCH_NO
            AND V1.PLINE_CODE = M.PLINE_CODE),
           0) HEA_ACC_WT,
       NVL((SELECT SUM(V1.FAIL_NUM)
             FROM MCH_WATERGAGE_RESULT V1
            WHERE V1.HEAT_PLAN_NO = M.HEAT_PLAN_NO
            AND V1.BATCH_NO = C.BATCH_NO
            AND V1.PLINE_CODE = M.PLINE_CODE),
           0) HEA_FAIL_NUM,
       NVL((SELECT SUM(V1.PRO_NUM)
             FROM MCH_CHAMFERING_RESULT V1
            WHERE V1.HEAT_PLAN_NO = M.HEAT_PLAN_NO
            AND V1.BATCH_NO = C.BATCH_NO
            AND V1.PLINE_CODE = M.PLINE_CODE),
           0) CHA_ACC_NUM,        NVL((SELECT SUM(V1.PRO_WT)
             FROM MCH_CHAMFERING_RESULT V1
            WHERE V1.HEAT_PLAN_NO = M.HEAT_PLAN_NO
            AND V1.BATCH_NO = C.BATCH_NO
            AND V1.PLINE_CODE = M.PLINE_CODE),
           0) CHA_ACC_WT,
       NVL((SELECT SUM(V1.FAIL_NUM)
             FROM MCH_CHAMFERING_RESULT V1
            WHERE V1.HEAT_PLAN_NO = M.HEAT_PLAN_NO
            AND V1.BATCH_NO = C.BATCH_NO
            AND V1.PLINE_CODE = M.PLINE_CODE),
           0) CHA_FAIL_NUM,
       NVL((SELECT SUM(V1.PRO_NUM)
             FROM MCH_MEASURE_RESULT V1
            WHERE V1.HEAT_PLAN_NO = M.HEAT_PLAN_NO
            AND V1.BATCH_NO = C.BATCH_NO
            AND V1.PLINE_CODE = M.PLINE_CODE),
           0) CLD_ACC_NUM,        NVL((SELECT SUM(V1.PRO_WT)
             FROM MCH_MEASURE_RESULT V1
            WHERE V1.HEAT_PLAN_NO = M.HEAT_PLAN_NO
            AND V1.BATCH_NO = C.BATCH_NO
            AND V1.PLINE_CODE = M.PLINE_CODE),
           0) CLD_ACC_WT,
       NVL((SELECT SUM(V1.FAIL_NUM)
             FROM MCH_MEASURE_RESULT V1
            WHERE V1.HEAT_PLAN_NO = M.HEAT_PLAN_NO
            AND V1.BATCH_NO = C.BATCH_NO
            AND V1.PLINE_CODE = M.PLINE_CODE),
           0) CLD_FAIL_NUM,
           
             NVL((SELECT SUM(MAT.ACT_COUNT)
             FROM QCM_ZG_JUGDE_APPLY MAT
            WHERE MAT.JUDGE_STOVE_NO = M.JUDGE_STOVE_NO
            AND MAT.BATCH_NO = C.BATCH_NO
            AND MAT.PLINE_CODE = M.PLINE_CODE
            AND MAT.HEAT_PLAN_NO = M.HEAT_PLAN_NO
            AND MAT.VALIDFLAG != '50'),
           0) MAT_NUM,      
       NVL((SELECT SUM(MAT.ACT_WEIGHT)
             FROM QCM_ZG_JUGDE_APPLY MAT
            WHERE MAT.JUDGE_STOVE_NO = M.JUDGE_STOVE_NO
            AND MAT.BATCH_NO = C.BATCH_NO
            AND MAT.PLINE_CODE = M.PLINE_CODE
            AND MAT.HEAT_PLAN_NO = M.HEAT_PLAN_NO
            AND MAT.VALIDFLAG != '50'),
           0) MAT_WEIGHT,
            NVL((SELECT SUM(QCM.ACT_THEORY_WEIGHT)
             FROM QCM_ZG_JUGDE_APPLY QCM
            WHERE QCM.JUDGE_STOVE_NO = M.JUDGE_STOVE_NO
            AND QCM.BATCH_NO = C.BATCH_NO
            AND QCM.PLINE_CODE = M.PLINE_CODE
            AND QCM.HEAT_PLAN_NO = M.HEAT_PLAN_NO
            AND QCM.VALIDFLAG != '50'),
           0) QCM_THEORY_WEIGHT,
       NVL((SELECT SUM(QCM.ACT_COUNT)
             FROM QCM_ZG_JUGDE_APPLY QCM
            WHERE QCM.JUDGE_STOVE_NO = M.JUDGE_STOVE_NO
            AND QCM.BATCH_NO = C.BATCH_NO
            AND QCM.PLINE_CODE = M.PLINE_CODE
            AND QCM.HEAT_PLAN_NO = M.HEAT_PLAN_NO
            AND QCM.VALIDFLAG = '20'),
           0) QCM_NUM,      
       NVL((SELECT SUM(QCM.ACT_WEIGHT)
             FROM QCM_ZG_JUGDE_APPLY QCM
            WHERE QCM.JUDGE_STOVE_NO = M.JUDGE_STOVE_NO
            AND QCM.BATCH_NO = C.BATCH_NO
            AND QCM.PLINE_CODE = M.PLINE_CODE
            AND QCM.HEAT_PLAN_NO = M.HEAT_PLAN_NO
            AND QCM.VALIDFLAG = '20'),
           0) QCM_WEIGHT,
        NVL((SELECT SUM(QCM.ACT_THEORY_WEIGHT)
             FROM QCM_ZG_JUGDE_APPLY QCM
            WHERE QCM.JUDGE_STOVE_NO = M.JUDGE_STOVE_NO
            AND QCM.BATCH_NO = C.BATCH_NO
            AND QCM.PLINE_CODE = M.PLINE_CODE
            AND QCM.HEAT_PLAN_NO = M.HEAT_PLAN_NO
            AND QCM.VALIDFLAG = '20'),
           0) THEORY_WEIGHT,  
       MIN(TO_CHAR(T1.LOAD_TIME, 'YYYY-MM-DD HH24:MI:SS')) LOAD_TIME

  FROM MCH_COM_INFO       T,
       PLN_ZY_JGX_M       M,
       (SELECT HEAT_PLAN_NO,BATCH_NO,SUM(PLAN_INDOUBLE_NUM) PLAN_INDOUBLE_NUM,
  SUM(PLAN_INDOUBLE_WT) PLAN_INDOUBLE_WT FROM  PLN_ZY_JGX_C GROUP BY HEAT_PLAN_NO,BATCH_NO)       C,
       PLN_SALEORD        M1,
       MCH_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="FrmJGXPerformance.doQueryPort" desc="查询JGX进程">		
        <![CDATA[
SELECT M.HEAT_PLAN_NO, --炉计划ID
       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, --判定炉号
        CASE
                 WHEN (SELECT COUNT(1)
                         FROM QCM_ZG_JUGDE_APPLY Q
                        WHERE (Q.INSTANCY_FLAG = '1' OR
                              Q.TOL_INSTANCY_FLAG = '1')
                          AND Q.JUDGE_STOVE_NO = M.JUDGE_STOVE_NO
                          AND (Q.JUDGE_RESULT IS NULL OR
                              Q.JUDGE_RESULT = '不合格')) > 0 THEN
                  '是'
                 ELSE
                  '否'
               END IS_FLAG,
       C.BATCH_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, --- 存在未下线合格管标志
       TO_CHAR(C.LOADTIME, 'YYYY-MM-DD HH24:MI:SS') LOAD_TIME, -- 上料时间
       DECODE(M.IF_MATCH_ODD,
              '0',
              '正常计划',
              '1',
              '利库计划',
              '2',
              '组炉计划') IF_MATCH_ODD, -- 计划状态
       M.ORDER_NO || '/' || M.ORDER_SEQ || '/' || M.DELIVERY_NO ORDER_NO, --合同号
       M.OUTWL_DESC, --产出物料描述
       M.SPEC_NAME, --产品规格描述
       M.STD_NAME, --标准名称
       M.PRODUCNAME, --品名描述
       M.MODEL_DESC, --扣型描述
       M.STEELNAME, --钢级名称
       NVL((SELECT SUM(V.OFFLINE_NUM)
             FROM MCH_OFFLINE_RESULT V
            WHERE V.HEAT_PLAN_NO = M.HEAT_PLAN_NO
              AND V.BATCH_NO = C.BATCH_NO),
           0) OFFLINE_NUM, --- 总下线支
       NVL((SELECT SUM(V.OFFLINE_WT)
             FROM MCH_OFFLINE_RESULT V
            WHERE V.HEAT_PLAN_NO = M.HEAT_PLAN_NO
              AND V.BATCH_NO = C.BATCH_NO),
           0) OFFLINE_WT, ---总下线吨
       NVL((SELECT SUM(V.RE_NUM)
             FROM MCH_OFFLINE_RESULT V
            WHERE V.HEAT_PLAN_NO = M.HEAT_PLAN_NO
              AND V.BATCH_NO = C.BATCH_NO),
           0) RE_NUM, -- 总返线支
       NVL((SELECT SUM(V.RE_WT)
             FROM MCH_OFFLINE_RESULT V
            WHERE V.HEAT_PLAN_NO = M.HEAT_PLAN_NO
              AND V.BATCH_NO = C.BATCH_NO),
           0) RE_WT, ---总返线吨

       NVL(C.REAL_INDOUBLE_NUM, 0) LOAD_PRO_NUM, --上料支
       NVL(C.REAL_INDOUBLE_WT, 0) LOAD_PRO_WT, -- 上料吨
       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.BATCH_NO = T.BATCH_NO),
           0) MEA_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.BATCH_NO = T.BATCH_NO), 0) MEA_FAIL_NUM, --探伤废品

 NVL((SELECT SUM(V1.PRO_NUM)
        FROM MCH_CUT_RESULT V1
       WHERE V1.HEAT_PLAN_NO = M.HEAT_PLAN_NO
         AND V1.BATCH_NO = C.BATCH_NO), -- 分切支
 0) REE_PRO_NUM, NVL((SELECT SUM(V1.PRO_WT)
                        FROM MCH_CUT_RESULT V1
                       WHERE V1.HEAT_PLAN_NO = M.HEAT_PLAN_NO
                         AND V1.BATCH_NO = C.BATCH_NO), 0) REE_PRO_WT, --分切吨
 NVL((SELECT SUM(V1.FAIL_NUM)
        FROM MCH_CUT_RESULT V1
       WHERE V1.HEAT_PLAN_NO = M.HEAT_PLAN_NO
         AND V1.BATCH_NO = C.BATCH_NO), 0) REE_FAIL_NUM, -- 分切废品
 NVL((SELECT SUM(V1.PRO_NUM)
        FROM MCH_THREADER_RESULT V1
       WHERE V1.HEAT_PLAN_NO = M.HEAT_PLAN_NO
         AND V1.BATCH_NO = C.BATCH_NO), 0) SIZ_PRO_NUM, ---车丝支
 NVL((SELECT SUM(V1.PRO_WT)
        FROM MCH_THREADER_RESULT V1
       WHERE V1.HEAT_PLAN_NO = M.HEAT_PLAN_NO
         AND V1.BATCH_NO = C.BATCH_NO), --车丝吨
 0) SIZ_PRO_WT, NVL((SELECT SUM(V1.FAIL_NUM)
                       FROM MCH_THREADER_RESULT V1
                      WHERE V1.HEAT_PLAN_NO = M.HEAT_PLAN_NO
                        AND V1.BATCH_NO = C.BATCH_NO), 0) SIZ_FAIL_NUM, --车丝废品
 NVL((SELECT SUM(V1.PRO_NUM)
        FROM MCH_HREAD_RESULT V1
       WHERE V1.HEAT_PLAN_NO = M.HEAT_PLAN_NO
         AND V1.BATCH_NO = C.BATCH_NO), 0) ROT_ACC_NUM, --螺纹检验支
 NVL((SELECT SUM(V1.PRO_WT)
        FROM MCH_HREAD_RESULT V1
       WHERE V1.HEAT_PLAN_NO = M.HEAT_PLAN_NO
         AND V1.BATCH_NO = C.BATCH_NO), 0) ROT_ACC_WT, --螺纹检验吨
 NVL((SELECT SUM(V1.FAIL_NUM)
        FROM MCH_HREAD_RESULT V1
       WHERE V1.HEAT_PLAN_NO = M.HEAT_PLAN_NO
         AND V1.BATCH_NO = C.BATCH_NO), 0) ROT_FAIL_NUM, --螺纹检验废品
 NVL((SELECT SUM(V1.PRO_NUM)
        FROM MCH_TWISTINGLY_RESULT V1
       WHERE V1.HEAT_PLAN_NO = M.HEAT_PLAN_NO
         AND V1.BATCH_NO = C.BATCH_NO), 0) JUM_ACC_NUM, ---拧接支
 NVL((SELECT SUM(V1.PRO_WT)
        FROM MCH_TWISTINGLY_RESULT V1
       WHERE V1.HEAT_PLAN_NO = M.HEAT_PLAN_NO
         AND V1.BATCH_NO = C.BATCH_NO), 0) JUM_ACC_WT, ---拧接吨
 NVL((SELECT SUM(V1.FAIL_NUM)
        FROM MCH_TWISTINGLY_RESULT V1
       WHERE V1.HEAT_PLAN_NO = M.HEAT_PLAN_NO
         AND V1.BATCH_NO = C.BATCH_NO
         AND V1.PLINE_CODE = M.PLINE_CODE), 0) JUM_FAIL_NUM, -- 拧接废品
 NVL((SELECT SUM(V1.PRO_NUM)
        FROM MCH_PATH_RESULT V1
       WHERE V1.HEAT_PLAN_NO = M.HEAT_PLAN_NO
         AND V1.BATCH_NO = C.BATCH_NO), 0) HOT_ACC_NUM, --通经支
 NVL((SELECT SUM(V1.PRO_WT)
        FROM MCH_PATH_RESULT V1
       WHERE V1.HEAT_PLAN_NO = M.HEAT_PLAN_NO
         AND V1.BATCH_NO = C.BATCH_NO), 0) HOT_ACC_WT, --通经吨
 NVL((SELECT SUM(V1.FAIL_NUM)
        FROM MCH_PATH_RESULT V1
       WHERE V1.HEAT_PLAN_NO = M.HEAT_PLAN_NO
         AND V1.BATCH_NO = C.BATCH_NO), 0) HOT_FAIL_NUM, --通经废品
 NVL((SELECT SUM(V1.PRO_NUM)
        FROM MCH_WATERGAGE_RESULT V1
       WHERE V1.HEAT_PLAN_NO = M.HEAT_PLAN_NO
         AND V1.BATCH_NO = C.BATCH_NO
         AND V1.PLINE_CODE = M.PLINE_CODE), 0) HEA_ACC_NUM, --水压支
 NVL((SELECT SUM(V1.PRO_WT)
        FROM MCH_WATERGAGE_RESULT V1
       WHERE V1.HEAT_PLAN_NO = M.HEAT_PLAN_NO
         AND V1.BATCH_NO = C.BATCH_NO), 0) HEA_ACC_WT, --水压吨
 NVL((SELECT SUM(V1.FAIL_NUM)
        FROM MCH_WATERGAGE_RESULT V1
       WHERE V1.HEAT_PLAN_NO = M.HEAT_PLAN_NO
         AND V1.BATCH_NO = C.BATCH_NO), 0) HEA_FAIL_NUM, --水压废品
 NVL((SELECT SUM(V1.PRO_NUM)
        FROM MCH_CHAMFERING_RESULT V1
       WHERE V1.HEAT_PLAN_NO = M.HEAT_PLAN_NO
         AND V1.BATCH_NO = C.BATCH_NO), 0) CHA_ACC_NUM, --倒棱支

 NVL((SELECT SUM(V1.PRO_WT)
        FROM MCH_CHAMFERING_RESULT V1
       WHERE V1.HEAT_PLAN_NO = M.HEAT_PLAN_NO
         AND V1.BATCH_NO = C.BATCH_NO), 0) CHA_ACC_WT, --倒棱吨
 NVL((SELECT SUM(V1.FAIL_NUM)
        FROM MCH_CHAMFERING_RESULT V1
       WHERE V1.HEAT_PLAN_NO = M.HEAT_PLAN_NO
         AND V1.BATCH_NO = C.BATCH_NO), 0) CHA_FAIL_NUM, --倒棱废品
 NVL((SELECT SUM(V1.PRO_NUM)
        FROM MCH_MEASURE_RESULT V1
       WHERE V1.HEAT_PLAN_NO = M.HEAT_PLAN_NO
         AND V1.BATCH_NO = C.BATCH_NO), 0) CLD_ACC_NUM, --测量支
 NVL((SELECT SUM(V1.PRO_WT)
        FROM MCH_MEASURE_RESULT V1
       WHERE V1.HEAT_PLAN_NO = M.HEAT_PLAN_NO
         AND V1.BATCH_NO = C.BATCH_NO), 0) CLD_ACC_WT, --测量吨
 NVL((SELECT SUM(V1.FAIL_NUM)
        FROM MCH_MEASURE_RESULT V1
       WHERE V1.HEAT_PLAN_NO = M.HEAT_PLAN_NO
         AND V1.BATCH_NO = C.BATCH_NO), 0) CLD_FAIL_NUM, --测量废品
         
  NVL((SELECT SUM(V1.PRO_NUM)
        FROM MCH_FINAL_CHECK_RESULT V1
       WHERE V1.HEAT_PLAN_NO = M.HEAT_PLAN_NO
         AND V1.BATCH_NO = C.BATCH_NO), 0) RKJY_ACC_NUM, --入库检验支
 NVL((SELECT SUM(V1.PRO_WT)
        FROM MCH_FINAL_CHECK_RESULT V1
       WHERE V1.HEAT_PLAN_NO = M.HEAT_PLAN_NO
         AND V1.BATCH_NO = C.BATCH_NO), 0) RKJY_ACC_WT, --入库检验吨

(SELECT MAX(MAT.JUDGE_RESULT_TIME)
    FROM QCM_ZG_JUGDE_APPLY MAT
   WHERE MAT.HEAT_PLAN_NO = M.HEAT_PLAN_NO
     AND MAT.BATCH_NO = C.BATCH_NO
     AND MAT.IS_FLAG = '0'
     AND MAT.IS_ALL_SCRAP IN ('0', '2')) JUDGE_RESULT_TIME, -- 工序判定时间
 NVL((SELECT SUM(MAT.ACT_COUNT)
        FROM QCM_ZG_JUGDE_APPLY MAT
       WHERE MAT.HEAT_PLAN_NO = M.HEAT_PLAN_NO
         AND MAT.BATCH_NO = C.BATCH_NO
         AND MAT.IS_FLAG = '0'
         AND MAT.IS_ALL_SCRAP IN ('0', '2')), 0) MAT_NUM, -- 送判支
 NVL((SELECT SUM(MAT.ACT_WEIGHT)
        FROM QCM_ZG_JUGDE_APPLY MAT
       WHERE MAT.HEAT_PLAN_NO = M.HEAT_PLAN_NO
         AND MAT.BATCH_NO = C.BATCH_NO
         AND MAT.IS_FLAG = '0'
         AND MAT.IS_ALL_SCRAP IN ('0', '2')), 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
         AND QCM.BATCH_NO = C.BATCH_NO
         AND QCM.IS_FLAG = '0'
         AND QCM.IS_ALL_SCRAP IN ('0', '2')), 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
         AND QCM.BATCH_NO = C.BATCH_NO
         AND QCM.IS_FLAG = '0'
         AND QCM.IS_ALL_SCRAP IN ('0', '2')
  AND (((QCM.JUDGE_RESULT_CODE = '40740701' OR QCM.JUDGE_RESULT_CODE =
                                                   '40740709' OR
                                       QCM.INSTANCY_FLAG = '1')
               AND QCM.TARGET <> 'A') OR
               (QCM.TARGET = 'A'  AND  (QCM.JUDGE_TOLRESULT_CODE =
                                     '40740701' OR QCM.JUDGE_TOLRESULT_CODE =
                                     '40740709') ))
      ), 0) QCM_NUM, -- 已判支
 NVL((SELECT SUM(QCM.ACT_WEIGHT)
        FROM QCM_ZG_JUGDE_APPLY QCM
       WHERE QCM.HEAT_PLAN_NO = M.HEAT_PLAN_NO
         AND QCM.BATCH_NO = C.BATCH_NO
         AND QCM.IS_FLAG = '0'
         AND QCM.IS_ALL_SCRAP IN ('0', '2')
   AND (((QCM.JUDGE_RESULT_CODE = '40740701' OR QCM.JUDGE_RESULT_CODE =
                                                   '40740709' OR
                                       QCM.INSTANCY_FLAG = '1')
               AND QCM.TARGET <> 'A') OR
               (QCM.TARGET = 'A'  AND  (QCM.JUDGE_TOLRESULT_CODE =
                                     '40740701' OR QCM.JUDGE_TOLRESULT_CODE =
                                     '40740709') ))
      ), 0) QCM_WEIGHT, -- 已判吨
      
             NVL((SELECT SUM(QCM.ACT_LEN)
        FROM QCM_ZG_JUGDE_APPLY QCM
       WHERE QCM.HEAT_PLAN_NO = M.HEAT_PLAN_NO
         AND QCM.BATCH_NO = C.BATCH_NO
         AND QCM.IS_FLAG = '0'
         AND QCM.IS_ALL_SCRAP IN ('0', '2')
  AND (((QCM.JUDGE_RESULT_CODE = '40740701' OR QCM.JUDGE_RESULT_CODE =
                                                   '40740709' OR
                                       QCM.INSTANCY_FLAG = '1')
               AND QCM.TARGET <> 'A') OR
               (QCM.TARGET = 'A'  AND  (QCM.JUDGE_TOLRESULT_CODE =
                                     '40740701' OR QCM.JUDGE_TOLRESULT_CODE =
                                     '40740709') ))
      ), 0) QCM_LEN, -- 已判长度
 NVL((SELECT SUM(QCM.ACT_THEORY_WEIGHT)
        FROM QCM_ZG_JUGDE_APPLY QCM
       WHERE QCM.HEAT_PLAN_NO = M.HEAT_PLAN_NO
         AND QCM.BATCH_NO = C.BATCH_NO
         AND QCM.IS_FLAG = '0'
         AND QCM.IS_ALL_SCRAP IN ('0', '2')
       AND (((QCM.JUDGE_RESULT_CODE = '40740701' OR QCM.JUDGE_RESULT_CODE =
                                                   '40740709' OR
                                       QCM.INSTANCY_FLAG = '1')
               AND QCM.TARGET <> 'A') OR
               (QCM.TARGET = 'A'  AND  (QCM.JUDGE_TOLRESULT_CODE =
                                     '40740701' OR QCM.JUDGE_TOLRESULT_CODE =
                                     '40740709') ))
      ), 0) THEORY_WEIGHT, -- 已判理论吨
       NVL((SELECT SUM(QCM.ACT_COUNT)
        FROM QCM_ZG_JUGDE_APPLY QCM
       WHERE QCM.HEAT_PLAN_NO = M.HEAT_PLAN_NO
         AND QCM.BATCH_NO = C.BATCH_NO
         AND QCM.BATCH_GROUD_NO='001'
         AND QCM.IS_FLAG = '0'
         AND QCM.IS_ALL_SCRAP IN ('0', '2')
 AND (((QCM.JUDGE_RESULT_CODE = '40740701' OR QCM.JUDGE_RESULT_CODE =
                                                   '40740709' OR
                                       QCM.INSTANCY_FLAG = '1')
               AND QCM.TARGET <> 'A') OR
               (QCM.TARGET = 'A'  AND  (QCM.JUDGE_TOLRESULT_CODE =
                                     '40740701' OR QCM.JUDGE_TOLRESULT_CODE =
                                     '40740709') ))
      ), 0) GROUP001, -- 组号001
           NVL((SELECT SUM(QCM.ACT_COUNT)
        FROM QCM_ZG_JUGDE_APPLY QCM
       WHERE QCM.HEAT_PLAN_NO = M.HEAT_PLAN_NO
         AND QCM.BATCH_NO = C.BATCH_NO
         AND QCM.BATCH_GROUD_NO='002'
         AND QCM.IS_FLAG = '0'
         AND QCM.IS_ALL_SCRAP IN ('0', '2')
 AND (((QCM.JUDGE_RESULT_CODE = '40740701' OR QCM.JUDGE_RESULT_CODE =
                                                   '40740709' OR
                                       QCM.INSTANCY_FLAG = '1')
               AND QCM.TARGET <> 'A') OR
               (QCM.TARGET = 'A'  AND  (QCM.JUDGE_TOLRESULT_CODE =
                                     '40740701' OR QCM.JUDGE_TOLRESULT_CODE =
                                     '40740709') ))
      ), 0) GROUP002, -- 组号002
           NVL((SELECT SUM(QCM.ACT_COUNT)
        FROM QCM_ZG_JUGDE_APPLY QCM
       WHERE QCM.HEAT_PLAN_NO = M.HEAT_PLAN_NO
         AND QCM.BATCH_NO = C.BATCH_NO
         AND QCM.BATCH_GROUD_NO='003'
         AND QCM.IS_FLAG = '0'
         AND QCM.IS_ALL_SCRAP IN ('0', '2')
 AND (((QCM.JUDGE_RESULT_CODE = '40740701' OR QCM.JUDGE_RESULT_CODE =
                                                   '40740709' OR
                                       QCM.INSTANCY_FLAG = '1')
               AND QCM.TARGET <> 'A') OR
               (QCM.TARGET = 'A'  AND  (QCM.JUDGE_TOLRESULT_CODE =
                                     '40740701' OR QCM.JUDGE_TOLRESULT_CODE =
                                     '40740709') ))
      ), 0) GROUP003, -- 组号003
           NVL((SELECT SUM(QCM.ACT_COUNT)
        FROM QCM_ZG_JUGDE_APPLY QCM
       WHERE QCM.HEAT_PLAN_NO = M.HEAT_PLAN_NO
         AND QCM.BATCH_NO = C.BATCH_NO
         AND QCM.BATCH_GROUD_NO='004'
         AND QCM.IS_FLAG = '0'
         AND QCM.IS_ALL_SCRAP IN ('0', '2')
 AND (((QCM.JUDGE_RESULT_CODE = '40740701' OR QCM.JUDGE_RESULT_CODE =
                                                   '40740709' OR
                                       QCM.INSTANCY_FLAG = '1')
               AND QCM.TARGET <> 'A') OR
               (QCM.TARGET = 'A'  AND  (QCM.JUDGE_TOLRESULT_CODE =
                                     '40740701' OR QCM.JUDGE_TOLRESULT_CODE =
                                     '40740709') ))
      ), 0) GROUP004, -- 组号004
           NVL((SELECT SUM(QCM.ACT_COUNT)
        FROM QCM_ZG_JUGDE_APPLY QCM
       WHERE QCM.HEAT_PLAN_NO = M.HEAT_PLAN_NO
         AND QCM.BATCH_NO = C.BATCH_NO
         AND QCM.BATCH_GROUD_NO='005'
         AND QCM.IS_FLAG = '0'
         AND QCM.IS_ALL_SCRAP IN ('0', '2')
 AND (((QCM.JUDGE_RESULT_CODE = '40740701' OR QCM.JUDGE_RESULT_CODE =
                                                   '40740709' OR
                                       QCM.INSTANCY_FLAG = '1')
               AND QCM.TARGET <> 'A') OR
               (QCM.TARGET = 'A'  AND  (QCM.JUDGE_TOLRESULT_CODE =
                                     '40740701' OR QCM.JUDGE_TOLRESULT_CODE =
                                     '40740709') ))
      ), 0) GROUP005, -- 组号005
           NVL((SELECT SUM(QCM.ACT_COUNT)
        FROM QCM_ZG_JUGDE_APPLY QCM
       WHERE QCM.HEAT_PLAN_NO = M.HEAT_PLAN_NO
         AND QCM.BATCH_NO = C.BATCH_NO
         AND QCM.BATCH_GROUD_NO='006'
         AND QCM.IS_FLAG = '0'
         AND QCM.IS_ALL_SCRAP IN ('0', '2')
 AND (((QCM.JUDGE_RESULT_CODE = '40740701' OR QCM.JUDGE_RESULT_CODE =
                                                   '40740709' OR
                                       QCM.INSTANCY_FLAG = '1')
               AND QCM.TARGET <> 'A') OR
               (QCM.TARGET = 'A'  AND  (QCM.JUDGE_TOLRESULT_CODE =
                                     '40740701' OR QCM.JUDGE_TOLRESULT_CODE =
                                     '40740709') ))
      ), 0) GROUP006, -- 组号006
           NVL((SELECT SUM(QCM.ACT_COUNT)
        FROM QCM_ZG_JUGDE_APPLY QCM
       WHERE QCM.HEAT_PLAN_NO = M.HEAT_PLAN_NO
         AND QCM.BATCH_NO = C.BATCH_NO
         AND QCM.BATCH_GROUD_NO='007'
         AND QCM.IS_FLAG = '0'
         AND QCM.IS_ALL_SCRAP IN ('0', '2')
 AND (((QCM.JUDGE_RESULT_CODE = '40740701' OR QCM.JUDGE_RESULT_CODE =
                                                   '40740709' OR
                                       QCM.INSTANCY_FLAG = '1')
               AND QCM.TARGET <> 'A') OR
               (QCM.TARGET = 'A'  AND  (QCM.JUDGE_TOLRESULT_CODE =
                                     '40740701' OR QCM.JUDGE_TOLRESULT_CODE =
                                     '40740709') ))
      ), 0) GROUP007, -- 组号007
           NVL((SELECT SUM(QCM.ACT_COUNT)
        FROM QCM_ZG_JUGDE_APPLY QCM
       WHERE QCM.HEAT_PLAN_NO = M.HEAT_PLAN_NO
         AND QCM.BATCH_NO = C.BATCH_NO
         AND QCM.BATCH_GROUD_NO='008'
         AND QCM.IS_FLAG = '0'
         AND QCM.IS_ALL_SCRAP IN ('0', '2')
 AND (((QCM.JUDGE_RESULT_CODE = '40740701' OR QCM.JUDGE_RESULT_CODE =
                                                   '40740709' OR
                                       QCM.INSTANCY_FLAG = '1')
               AND QCM.TARGET <> 'A') OR
               (QCM.TARGET = 'A'  AND  (QCM.JUDGE_TOLRESULT_CODE =
                                     '40740701' OR QCM.JUDGE_TOLRESULT_CODE =
                                     '40740709') ))
      ), 0) GROUP008 -- 组号008
 FROM (SELECT HEAT_PLAN_NO,
              PHY_BATCH_NO BATCH_NO,
              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 --- 存在未缴库
         FROM PORT_MCH_BATCH_SAMPLE_RESULT T
        WHERE T.VALIDFLAG = '1'
        GROUP BY HEAT_PLAN_NO, PHY_BATCH_NO) T, PLN_ZY_JGX_M M, (SELECT HEAT_PLAN_NO,
                                                                        BATCH_NO,
                                                                        LOADTIME,
                                                                        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_JGX_C
                                                                  GROUP BY HEAT_PLAN_NO,
                                                                           BATCH_NO,
                                                                           LOADTIME) C
 WHERE M.HEAT_PLAN_NO = T.HEAT_PLAN_NO
   AND M.HEAT_PLAN_NO = C.HEAT_PLAN_NO
   AND T.BATCH_NO = C.BATCH_NO
        ]]>
	</query>
</queryMap>