<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc = "处理整炉废、白条">
<query id = "FrmScrapStoveApplyDescion.doQueryMataE" desc = "查询已经上料了炉计划(整炉废信息)镦拔扩">
<![CDATA[
SELECT T.PRO_PLAN_ID,
       T.GX_PLAN_NO,
       T.ORDER_SEQ,
       T.ORDER_NO || '/' || t.order_seq ORDER_NO,
       T.BAL_YEAR_MONTH,
       T.MODEL_DESC,
       T.SPEC_NAME,
       T.STEELNAME,
       T.GRADENAME,
       T.PRODUCNAME,
       T.STD_STYLE_DESC,
       T.STD_NAME,
       T.STEELNAME,
       T.GRADENAME,
       T.DECISION,
       T.OUTWL_ID,
       T.OUTWL_DESC,
       T.ZY_BATCH_ID,
       S.JUDGE_STOVE_NO,
       S.ACT_COUNT PLN_INSINGLE_NUM,
       S.ACT_WEIGHT PLN_INSINGLE_WT,
       T.PLINE_CODE,
       T.PLINE_NAME,
       S.PHY_BATCH_NO BATCH_NO,
       T.HEAT_PLAN_NO,
       DECODE(t.PLANSTATUS,
              '00',
              '计划',
              '10',
              '下发',
              '20',
              '生产中',
              '30',
              '生产完成',
              '40',
              '关闭') PLANSTATUS
  FROM pln_zy_DBK_m T,
       pln_zy_DBK_c T2,
       (SELECT T1.JUDGE_STOVE_NO,
               T1.PHY_BATCH_NO,
               SUM(T1.ACT_COUNT) ACT_COUNT,
               SUM(T1.act_weight) ACT_WEIGHT
          FROM PORT_VRP_BATCH_SAMPLE_RESULT T1
         WHERE T1.GROUP_FLAG = '0'
           AND REGEXP_REPLACE(T1.JUDGE_STOVE_NO, '-.*', '') || '&' LIKE
               '%' || ? || '%'
           AND T1.BAL_YEAR_MONTH = ?
           AND T1.PLINE_CODE = ?
           AND NOT EXISTS
         (SELECT T3.JUDGE_STOVE_NO
                  FROM PORT_VRP_BATCH_SAMPLE_RESULT T3
                 WHERE T3.JUDGE_STOVE_NO = T1.JUDGE_STOVE_NO
                   AND T3.HEAT_PLAN_NO = T1.HEAT_PLAN_NO
                   AND T3.MAT_STATUS IN ('00', '20', '30'))
         GROUP BY T1.JUDGE_STOVE_NO, T1.PHY_BATCH_NO) S
 WHERE T.If_Match_Odd in ('0', '1')
   AND T.HEAT_PLAN_NO = T2.HEAT_PLAN_NO
   AND T.JUDGE_STOVE_NO = T2.JUDGE_STOVE_NO
   AND T.JUDGE_STOVE_NO = S.JUDGE_STOVE_NO
   AND T.PLANSTATUS = '40'
  ]]>
</query>

<query id = "FrmScrapStoveApplyDescion.doQueryMataF" desc = "查询已经上料了炉计划(整炉废信息)热处理">
<![CDATA[
SELECT T.PRO_PLAN_ID,
       T.GX_PLAN_NO,
       T.ORDER_SEQ,
       T.ORDER_NO || '/' || T.ORDER_SEQ ORDER_NO,
       T.BAL_YEAR_MONTH,
       T.MODEL_DESC,
       T.SPEC_NAME,
       T.STEELNAME,
       T.GRADENAME,
       T.PRODUCNAME,
       T.STD_STYLE_DESC,
       T.STD_NAME,
       T.STEELNAME,
       T.GRADENAME,
       T.DECISION,
       T.OUTWL_ID,
       T.OUTWL_DESC,
       T.ZY_BATCH_ID,
       S.JUDGE_STOVE_NO,
       S.ACT_COUNT PLN_INSINGLE_NUM,
       S.ACT_WEIGHT PLN_INSINGLE_WT,
       T.PLINE_CODE,
       T.PLINE_NAME,
       S.PHY_BATCH_NO BATCH_NO,
       T.HEAT_PLAN_NO,
       DECODE(t.PLANSTATUS,
              '00',
              '计划',
              '10',
              '下发',
              '20',
              '生产中',
              '30',
              '生产完成',
              '40',
              '关闭') PLANSTATUS
  FROM pln_zy_rcl_m T,
       pln_zy_rcl_c T2,
       (SELECT T1.JUDGE_STOVE_NO,
               T1.PHY_BATCH_NO,
               SUM(T1.ACT_COUNT) ACT_COUNT,
               SUM(T1.act_weight) ACT_WEIGHT
          FROM PORT_HTT_BATCH_SAMPLE_RESULT T1
         WHERE T1.GROUP_FLAG = '0'
           AND REGEXP_REPLACE(T1.JUDGE_STOVE_NO, '-.*', '') || '&' LIKE
               '%' || ? || '%'
           AND T1.BAL_YEAR_MONTH = ?
           AND T1.PLINE_CODE = ?
           AND NOT EXISTS
         (SELECT T3.JUDGE_STOVE_NO
                  FROM PORT_HTT_BATCH_SAMPLE_RESULT T3
                 WHERE T3.JUDGE_STOVE_NO = T1.JUDGE_STOVE_NO
                   AND T3.HEAT_PLAN_NO = T1.HEAT_PLAN_NO
                   AND T3.MAT_STATUS IN ('00', '20', '30'))
         GROUP BY T1.JUDGE_STOVE_NO, T1.PHY_BATCH_NO) S
 WHERE T.If_Match_Odd in ('0', '1')
   AND T.HEAT_PLAN_NO = T2.HEAT_PLAN_NO
   AND T.JUDGE_STOVE_NO = T2.JUDGE_STOVE_NO
   AND T.JUDGE_STOVE_NO = S.JUDGE_STOVE_NO
   AND T2.BATCH_NO = S.PHY_BATCH_NO
   AND T.PLANSTATUS = '40'

  ]]>
</query>

<query id = "FrmScrapStoveApplyDescion.doQueryMataG" desc = "查询已经上料了炉计划(整炉废信息)加工线">
<![CDATA[
SELECT T.PRO_PLAN_ID,
       T.GX_PLAN_NO,
       T.ORDER_SEQ,
       T.ORDER_NO || '/' || T.ORDER_SEQ ORDER_NO,
       T.BAL_YEAR_MONTH,
       T.MODEL_DESC,
       T.SPEC_NAME,
       T.STEELNAME,
       T.GRADENAME,
       T.PRODUCNAME,
       T.STD_STYLE_DESC,
       T.STD_NAME,
       T.STEELNAME,
       T.GRADENAME,
       T.DECISION,
       T.OUTWL_ID,
       T.OUTWL_DESC,
       T.ZY_BATCH_ID,
       S.JUDGE_STOVE_NO,
       S.ACT_COUNT PLN_INSINGLE_NUM,
       S.ACT_WEIGHT PLN_INSINGLE_WT,
       T.PLINE_CODE,
       T.PLINE_NAME,
       S.PHY_BATCH_NO BATCH_NO,
       T.HEAT_PLAN_NO,
       DECODE(t.PLANSTATUS,
              '00',
              '计划',
              '10',
              '下发',
              '20',
              '生产中',
              '30',
              '生产完成',
              '40',
              '关闭') PLANSTATUS
  FROM pln_zy_jgx_m T,
       pln_zy_jgx_c T2,
       (SELECT T1.JUDGE_STOVE_NO,
               T1.HEAT_PLAN_NO,
               T1.PHY_BATCH_NO,
               T1.BATCH_NO,
               SUM(T1.ACT_COUNT) ACT_COUNT,
               SUM(T1.act_weight) ACT_WEIGHT
          FROM PORT_MCH_BATCH_SAMPLE_RESULT T1
         WHERE T1.GROUP_FLAG = '0'
           AND REGEXP_REPLACE(T1.JUDGE_STOVE_NO, '-.*', '') || '&' LIKE
               '%' || ? || '%'
           AND T1.BAL_YEAR_MONTH = ?
           AND T1.PLINE_CODE = ?
           AND NOT EXISTS
         (SELECT T3.JUDGE_STOVE_NO
                  FROM PORT_MCH_BATCH_SAMPLE_RESULT T3
                 WHERE T3.JUDGE_STOVE_NO = T1.JUDGE_STOVE_NO
                   AND T3.HEAT_PLAN_NO = T1.HEAT_PLAN_NO
                   AND T3.MAT_STATUS IN ('00', '20', '30'))
         GROUP BY T1.HEAT_PLAN_NO,
                  T1.JUDGE_STOVE_NO,
                  T1.PHY_BATCH_NO,
                  T1.BATCH_NO) S
 WHERE T.If_Match_Odd in ('0', '1')
   AND T.HEAT_PLAN_NO = T2.HEAT_PLAN_NO
   AND T.JUDGE_STOVE_NO = T2.JUDGE_STOVE_NO
   AND T2.BATCH_NO = S.BATCH_NO
   AND T.JUDGE_STOVE_NO = S.JUDGE_STOVE_NO
   AND T.HEAT_PLAN_NO = S.HEAT_PLAN_NO
   AND T.PLANSTATUS = '40';

  ]]>
</query>
<!-- 
AND NOT EXISTS
  (SELECT *
          FROM QCM_ZG_JUGDE_APPLY S1
         WHERE S1.JUDGE_STOVE_NO = SUBSTR(S.JUDGE_STOVE_NO,0,6)
           AND S1.IS_FLAG ='0'
           AND S1.IS_ALL_SCRAP IN('0','1')
 -->
<query id = "FrmScrapStoveApplyDescion.doQueryBTMataE" desc = "查询可以打白条信息">
<![CDATA[
SELECT MAX(F.PRODUCNAME) PRODUCNAME,
       MAX(F.ORDER_NO || '/' || F.ORDER_SEQ) ORDER_NO,
       MAX(F.ORDER_SEQ) ORDER_SEQ,
       MAX(F.BAL_YEAR_MONTH) BAL_YEAR_MONTH,
       MAX(F.MODEL_DESC) MODEL_DESC,
       MAX(F.STEELNAME) STEELNAME,
       MAX(F.STD_NAME) STD_NAME,
       MAX(F.PLINE_NAME) PLINE_NAME,
       MAX(F.SPEC_NAME) SPEC_NAME,
       MAX(F.GRADENAME) GRADENAME,
       MAX(F.OUTWL_ID) OUTWL_ID,
       MAX(F.OUTWL_DESC) OUTWL_DESC,
       MAX(F.HEAT_PLAN_NO) HEAT_PLAN_NO,
       MAX(F.STD_STYLE_DESC) STD_STYLE_DESC,
       MAX(F.PER_STATUS) PER_STATUS,
       DECODE(MAX(F.PLANSTATUS),
              '00',
              '计划',
              '10',
              '下发',
              '20',
              '生产中',
              '30',
              '生产完成',
              '40',
              '关闭') PLANSTATUS,
       MAX(F.PRODUCCODE) PRODUCCODE,
       MAX(F.STEELCODE) STEELCODE,
       MAX(F.GRADECODE) GRADECODE,
       MAX(F.SPEC_CODE) SPEC_CODE,
       MAX(F.MODEL_CODE) MODEL_CODE,
       MAX(F.STD_CODE) STD_CODE,
       MAX(F.STD_STYLE) STD_STYLE,
       MAX(F.DECISION) DECISION,
       MAX(F.PRO_PLAN_ID) PRO_PLAN_ID,
       MAX(F.GX_PLAN_NO) GX_PLAN_NO,
       F.JUDGE_STOVE_NO,
       MAX(F.REAL_INDOUBLE_NUM) PLN_INSINGLE_NUM,
       MAX(F.REAL_INDOUBLE_WT) PLN_INSINGLE_WT,
       SUM(F.PLN_INSINGLE_NUM) PLN_ONSINGLE_NUM,
       SUM(F.PLN_INSINGLE_WT) PLN_ONSINGLE_WT,
       MAX(F.PLINE_CODE) PLINE_CODE,
       MAX(F.ZY_BATCH_ID) ZY_BATCH_ID
  FROM (SELECT T.ORDER_NO,
               T.ORDER_SEQ,
               T.SPEC_NAME,
               T.BAL_YEAR_MONTH,
               T.STD_NAME,
               T.PRODUCNAME,
               T.MODEL_DESC,
               T.STEELNAME,
               T.GRADENAME,
               T.PLINE_NAME,
               T.HEAT_PLAN_NO,
               T.STD_STYLE_DESC,
               T.PER_STATUS,
               T.PLANSTATUS,
               T.PRODUCCODE,
               T.STEELCODE,
               T.GRADECODE,
               T.SPEC_CODE,
               T.MODEL_CODE,
               T.STD_CODE,
               T.STD_STYLE,
               T.DECISION,
               T.PRO_PLAN_ID,
               T.GX_PLAN_NO,
               T.JUDGE_STOVE_NO,
               T.OUTWL_ID,
               T.OUTWL_DESC,
               t1.ACT_COUNT         REAL_INDOUBLE_NUM,
               t1.ACT_THEORY_WEIGHT REAL_INDOUBLE_WT,
               m.pro_num            PLN_INSINGLE_NUM,
               m.pro_wt             PLN_INSINGLE_WT,
               T.PLINE_CODE,
               T.ZY_BATCH_ID
          FROM vrp_loading_result m,
               PLN_ZY_DBK_M T,
               (SELECT T3.JUDGE_STOVE_NO,
                       T3.HEAT_PLAN_NO,
                       SUM(T3.ACT_COUNT) ACT_COUNT,
                       SUM(T3.act_weight) ACT_THEORY_WEIGHT
                  FROM port_VRP_batch_sample_result T3
                 WHERE T3.MAT_STATUS = '00'
                   AND REGEXP_REPLACE(T3.JUDGE_STOVE_NO, '-.*', '') || '&' LIKE
                       '%' || ? || '%'
                   AND T3.BAL_YEAR_MONTH = ?
                 group by t3.judge_stove_no, t3.heat_plan_no) t1
         WHERE T.HEAT_PLAN_NO = T1.HEAT_PLAN_NO
           AND T.JUDGE_STOVE_NO = T1.JUDGE_STOVE_NO
           AND M.HEAT_PLAN_NO = T.HEAT_PLAN_NO
           AND T.PLINE_CODE = ?
           AND T.PLANSTATUS IN ('30', '40')) F
 WHERE NOT EXISTS (SELECT *
          FROM QCM_ZG_JUGDE_APPLY S1
         WHERE F.JUDGE_STOVE_NO = S1.JUDGE_STOVE_NO
           AND S1.PROCESS_CODE = 'E')
 GROUP BY F.JUDGE_STOVE_NO

  ]]>
</query>
<query id = "FrmScrapStoveApplyDescion.doQueryBTMataF" desc = "查询可以打白条信息热处理">
<![CDATA[
SELECT MAX(F.PRODUCNAME) PRODUCNAME,
       MAX(F.ORDER_NO || '/' || F.ORDER_SEQ) ORDER_NO,
       MAX(F.ORDER_SEQ) ORDER_SEQ,
       MAX(F.BAL_YEAR_MONTH) BAL_YEAR_MONTH,
       MAX(F.MODEL_DESC) MODEL_DESC,
       MAX(F.STD_NAME) STD_NAME,
       MAX(F.SPEC_NAME) SPEC_NAME,
       MAX(F.STEELNAME) STEELNAME,
       MAX(F.PLINE_NAME) PLINE_NAME,
       MAX(F.GRADENAME) GRADENAME,
       MAX(F.OUTWL_ID) OUTWL_ID,
       MAX(F.OUTWL_DESC) OUTWL_DESC,
       MAX(F.HEAT_PLAN_NO) HEAT_PLAN_NO,
       MAX(F.STD_STYLE_DESC) STD_STYLE_DESC,
       MAX(F.PER_STATUS) PER_STATUS,
       DECODE(MAX(F.PLANSTATUS),
              '00',
              '计划',
              '10',
              '下发',
              '20',
              '生产中',
              '30',
              '生产完成',
              '40',
              '关闭') PLANSTATUS,
       MAX(F.PRODUCCODE) PRODUCCODE,
       MAX(F.STEELCODE) STEELCODE,
       MAX(F.GRADECODE) GRADECODE,
       MAX(F.SPEC_CODE) SPEC_CODE,
       MAX(F.MODEL_CODE) MODEL_CODE,
       MAX(F.STD_CODE) STD_CODE,
       MAX(F.STD_STYLE) STD_STYLE,
       MAX(F.DECISION) DECISION,
       MAX(F.PRO_PLAN_ID) PRO_PLAN_ID,
       MAX(F.GX_PLAN_NO) GX_PLAN_NO,
       F.JUDGE_STOVE_NO,
       MAX(F.REAL_INDOUBLE_NUM) PLN_INSINGLE_NUM,
       MAX(F.REAL_INDOUBLE_WT) PLN_INSINGLE_WT,
       SUM(F.PLN_INSINGLE_NUM) PLN_ONSINGLE_NUM,
       SUM(F.PLN_INSINGLE_WT) PLN_ONSINGLE_WT,
       MAX(F.PLINE_CODE) PLINE_CODE,
       MAX(F.ZY_BATCH_ID) ZY_BATCH_ID
  FROM (SELECT T.ORDER_NO,
               T.ORDER_SEQ,
               T.BAL_YEAR_MONTH,
               T.SPEC_NAME,
               T.PRODUCNAME,
               T.STD_NAME,
               T.MODEL_DESC,
               T.STEELNAME,
               T.GRADENAME,
               T.PLINE_NAME,
               T.HEAT_PLAN_NO,
               T.STD_STYLE_DESC,
               T.PER_STATUS,
               T.PLANSTATUS,
               T.PRODUCCODE,
               T.STEELCODE,
               T.GRADECODE,
               T.SPEC_CODE,
               T.MODEL_CODE,
               T.STD_CODE,
               T.STD_STYLE,
               T.DECISION,
               T.PRO_PLAN_ID,
               T.GX_PLAN_NO,
               T.JUDGE_STOVE_NO,
               T.OUTWL_ID,
               T.OUTWL_DESC,
               t1.ACT_COUNT         REAL_INDOUBLE_NUM,
               t1.ACT_THEORY_WEIGHT REAL_INDOUBLE_WT,
               m.pro_num            PLN_INSINGLE_NUM,
               m.pro_wt             PLN_INSINGLE_WT,
               T.PLINE_CODE,
               T.ZY_BATCH_ID
          FROM htt_loading_result m,
               PLN_ZY_RCL_M T,
               (SELECT T3.JUDGE_STOVE_NO,
                       T3.HEAT_PLAN_NO,
                       t3.PROCESS_SEQ,
                       SUM(T3.ACT_COUNT) ACT_COUNT,
                       SUM(T3.act_weight) ACT_THEORY_WEIGHT
                  FROM port_htt_batch_sample_result T3
                 WHERE T3.MAT_STATUS = '00'
                   AND REGEXP_REPLACE(T3.JUDGE_STOVE_NO, '-.*', '') || '&' LIKE
                       '%' || ? || '%'
                   AND T3.BAL_YEAR_MONTH = ?
                 group by t3.judge_stove_no, t3.heat_plan_no, t3.PROCESS_SEQ) t1
         WHERE T.HEAT_PLAN_NO = T1.HEAT_PLAN_NO
           AND T.JUDGE_STOVE_NO = T1.JUDGE_STOVE_NO
           AND M.HEAT_PLAN_NO = T.HEAT_PLAN_NO
           AND T.PLINE_CODE = ?
           and t.REAL_PROCESS_SEQ = t1.PROCESS_SEQ
           AND T.PLANSTATUS IN ('30', '40')) F
 WHERE NOT EXISTS (SELECT *
          FROM QCM_ZG_JUGDE_APPLY S1
         WHERE F.JUDGE_STOVE_NO = S1.JUDGE_STOVE_NO
           AND S1.PROCESS_CODE = 'F')
 GROUP BY F.JUDGE_STOVE_NO

  ]]>
</query>
<query id = "FrmScrapStoveApplyDescion.doQueryBTMataG" desc = "查询可以打白条信息加工线">
<![CDATA[
SELECT F.PHY_BATCH_NO BATCH_NO,
       MAX(F.PRODUCNAME) PRODUCNAME,
       MAX(F.MODEL_DESC) MODEL_DESC,
       MAX(F.ORDER_NO || '/' || F.ORDER_SEQ) ORDER_NO,
       MAX(F.ORDER_SEQ) ORDER_SEQ,
       MAX(F.BAL_YEAR_MONTH) BAL_YEAR_MONTH,
       MAX(F.STD_NAME) STD_NAME,
       MAX(F.SPEC_NAME) SPEC_NAME,
       MAX(F.STEELNAME) STEELNAME,
       MAX(F.PLINE_NAME) PLINE_NAME,
       MAX(F.GRADENAME) GRADENAME,
       MAX(F.OUTWL_ID) OUTWL_ID,
       MAX(F.OUTWL_DESC) OUTWL_DESC,
       MAX(F.HEAT_PLAN_NO) HEAT_PLAN_NO,
       MAX(F.STD_STYLE_DESC) STD_STYLE_DESC,
       MAX(F.PER_STATUS) PER_STATUS,
       DECODE(MAX(F.PLANSTATUS),
              '00',
              '计划',
              '10',
              '下发',
              '20',
              '生产中',
              '30',
              '生产完成',
              '40',
              '关闭') PLANSTATUS,
       MAX(F.PRODUCCODE) PRODUCCODE,
       MAX(F.STEELCODE) STEELCODE,
       MAX(F.GRADECODE) GRADECODE,
       MAX(F.SPEC_CODE) SPEC_CODE,
       MAX(F.MODEL_CODE) MODEL_CODE,
       MAX(F.STD_CODE) STD_CODE,
       MAX(F.STD_STYLE) STD_STYLE,
       MAX(F.DECISION) DECISION,
       MAX(F.PRO_PLAN_ID) PRO_PLAN_ID,
       MAX(F.GX_PLAN_NO) GX_PLAN_NO,
       F.JUDGE_STOVE_NO,
       MAX(F.REAL_INDOUBLE_NUM) PLN_INSINGLE_NUM,
       MAX(F.REAL_INDOUBLE_WT) PLN_INSINGLE_WT,
       SUM(F.PLN_INSINGLE_NUM) PLN_ONSINGLE_NUM,
       SUM(F.PLN_INSINGLE_WT) PLN_ONSINGLE_WT,
       MAX(F.PLINE_CODE) PLINE_CODE,
       MAX(F.ZY_BATCH_ID) ZY_BATCH_ID
  FROM (SELECT T1.PHY_BATCH_NO,
               T.ORDER_NO,
               T.ORDER_SEQ,
               T.PRODUCNAME,
               T.MODEL_DESC,
               T.BAL_YEAR_MONTH,
               T.STD_NAME,
               T.SPEC_NAME,
               T.STEELNAME,
               T.PLINE_NAME,
               T.GRADENAME,
               T.HEAT_PLAN_NO,
               T.STD_STYLE_DESC,
               T.PER_STATUS,
               T.PLANSTATUS,
               T.PRODUCCODE,
               T.STEELCODE,
               T.GRADECODE,
               T.SPEC_CODE,
               T.MODEL_CODE,
               T.STD_CODE,
               T.STD_STYLE,
               T.DECISION,
               T.PRO_PLAN_ID,
               T.GX_PLAN_NO,
               T1.JUDGE_STOVE_NO,
               T.OUTWL_ID,
               T.OUTWL_DESC,
               t1.ACT_COUNT         REAL_INDOUBLE_NUM,
               t1.ACT_THEORY_WEIGHT REAL_INDOUBLE_WT,
               m.pro_num            PLN_INSINGLE_NUM,
               m.pro_wt             PLN_INSINGLE_WT,
               T.PLINE_CODE,
               T.ZY_BATCH_ID
          FROM mch_loading_result m,
               PLN_ZY_JGX_M T,
               (SELECT T3.JUDGE_STOVE_NO,
                       T3.HEAT_PLAN_NO,
                       t3.phy_batch_no,
                       SUM(T3.ACT_COUNT) ACT_COUNT,
                       SUM(T3.act_weight) ACT_THEORY_WEIGHT
                  FROM port_MCH_batch_sample_result T3
                 WHERE T3.MAT_STATUS = '00'
                   AND REGEXP_REPLACE(T3.JUDGE_STOVE_NO, '-.*', '') || '&' LIKE
                       '%' || ? || '%'
                   AND T3.BAL_YEAR_MONTH = ?
                 group by t3.judge_stove_no, t3.heat_plan_no, t3.phy_batch_no) t1
         WHERE T1.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO
           AND T.HEAT_PLAN_NO = T1.HEAT_PLAN_NO
           AND M.HEAT_PLAN_NO = T.HEAT_PLAN_NO
           AND M.BATCH_NO = T1.phy_batch_no
           AND T.PLINE_CODE = ?
           AND T.PLANSTATUS IN ('30', '40')) F
 WHERE NOT EXISTS (SELECT *
          FROM QCM_ZG_JUGDE_APPLY S1
         WHERE F.JUDGE_STOVE_NO = S1.JUDGE_STOVE_NO
           AND S1.PROCESS_CODE = 'G'
           and s1.batch_no = F.PHY_BATCH_NO)
 GROUP BY F.JUDGE_STOVE_NO, F.PHY_BATCH_NO

  ]]>
</query>
<query id = "FrmScrapStoveApplyDescion.doQueryQcmMata" desc = "查询整炉废、白条信息">
<![CDATA[
SELECT JUGDE_APPLY_CODE,
       JUDGE_STOVE_NO,
       BATCH_NO,
       BATCH_GROUD_NO,
       PROCESS_CODE,
       PLINE_CODE,
       ACT_COUNT,
       ACT_WEIGHT,
       ACT_THEORY_WEIGHT,
       PRO_ORDER_ID,
       FACE_RESULT_CODE,
       SPEC_RESULT_CODE,
       CHEM_RESULT_CODE,
       PHY_RESULT_CODE,
       DETECT_RESULT_CODE,
       WPRESSURE_RESULT_CODE,
       PROCESS_RESULT_CODE,
       FACE_RESULT_PATH,
       SPEC_RESULT_PATH,
       CHEM_RESULT_PATH,
       PHY_RESULT_PATH,
       DETECT_RESULT_PATH,
       WPRESSURE_RESULT_PATH,
       PROCESS_RESULT_PATH,
       VALIDFLAG,
       APPLY_NAME,
       APPLY_TIME,
       MEMO,
       QUALITY_GROUP,
       MATERIAL_NO,
       MATERIAL_NAME,
       PRODUCCODE,
       PRODUCNAME,
       STEELCODE,
       STEELNAME,
       GRADECODE,
       GRADENAME,
       SPEC_CODE,
       SPEC_NAME,
       MODEL_CODE,
       MODEL_DESC,
       STD_CODE,
       STD_NAME,
       STD_STYLE,
       STD_STYLE_DESC,
       CRAF_NO,
       LOT_NO,
       PLINE_NAME,
       PRO_ORDER_NO,
       TARGET,
       PROCESS_STATUS,
       MAT_GOWHERE_CODE,
       MAT_GOWHERE_NAME,
       ACT_DIMATER,
       ACT_HEIGHT,
       ACT_LEN_MIN,
       ACT_LEN_MAX,
       JUDGE_RESULT_CODE,
       JUDGE_RESULT,
       JUDGE_RESULT_TIME,
       JUDGE_MAKER,
       IF_SET_ZY_PLAN,
       TESTING_GRADE,
       TESTING_TYPE,
       TESTING_GRADE1,
       TESTING_TYPE1,
       DETECT_RESULT_CODE1,
       DETECT_RESULT_PATH1,
       ORD_LN_DLY_PK,
       APPLY_FLAG,
       BACK_JUGDE_MEMO,
       INSTOCK_FLAG,
       BELONG_CODE,
       BELONG_NAME,
       ISENDGX,
       EXIT_TEMP,
       SAMPLE_NEWS,
       ACT_LEN,
       BELONG_CODE_JUGDE,
       BELONG_NAME_JUGDE,
       GX_PLAN_NO,
       INPUT_WEIGHT,
       INPUT_COUNT,
       OUTPUT_WEIGHT,
       OUTPUT_COUNT,
       BAL_YEAR_MONTH,
       IS_FLAG,
       DECODE(IS_ALL_SCRAP, '1', '整炉废', '2', '白条') IS_ALL_SCRAP,
       IS_CARRY_VOER,
       JUGDE_APPLY_SEQUENO
  FROM QCM_ZG_JUGDE_APPLY T
 WHERE REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '') || '&' LIKE
       '%' || ? || '%'
   AND T.BAL_YEAR_MONTH = ?
   AND PLINE_CODE = ?
   AND PROCESS_CODE = ?
   AND IS_ALL_SCRAP IN ('1', '2')

           ]]>
</query>
 <query id = "FrmScrapStoveApplyDescion.selectBelong" desc = "查询产线对应所属权">
   SELECT T.DEPARTMENT_CODE,T.DEPARTMENT_DESC FROM COM_BASE_PLINE T WHERE T.PLINE_CODE = ?
   </query>
	<query id = "FrmScrapStoveApplyDescion.jugdeApplyNo" desc = "申请判定单号">
	SELECT '#PLINE_CODE#'|| '801401' || TO_CHAR(SYSDATE, 'YYYYMMDD') ||
         LPAD(NVL(MAX(SUBSTR(T.JUGDE_APPLY_CODE, 19,5)), 0) + 1, 5, 0)||'1' JUGDE_APPLY_CODE
    FROM QCM_ZG_JUGDE_APPLY T
   WHERE TRUNC(T.APPLY_TIME) = TRUNC(SYSDATE)
   AND T.IS_ALL_SCRAP != '3' AND T.IS_ALL_SCRAP != '4'  AND T.JUGDE_APPLY_CODE LIKE '#PLINE_CODE#'||'801401' || '%'
	</query>
<query id = "FrmScrapStoveApplyDescion.doDecisionScrap" desc = "整炉废插入判定表">
 INSERT INTO QCM_ZG_JUGDE_APPLY
  (JUGDE_APPLY_CODE,
   JUDGE_STOVE_NO,
   BATCH_NO,
   BATCH_GROUD_NO,
   PLINE_CODE,
   ACT_COUNT,
   ACT_WEIGHT,
   ACT_THEORY_WEIGHT,
   PRO_ORDER_ID,
   VALIDFLAG,
   APPLY_NAME,
   APPLY_TIME,
   PRODUCNAME,
   STEELNAME,
   GRADENAME,
   SPEC_NAME,
   MODEL_DESC,
   STD_NAME,
   STD_STYLE_DESC,
   CRAF_NO,
   LOT_NO,
   PLINE_NAME,
   PRO_ORDER_NO,
   TARGET,
   ORD_LN_DLY_PK,
   APPLY_FLAG,
   BELONG_CODE,
   BELONG_NAME,
   BELONG_CODE_JUGDE,
   BELONG_NAME_JUGDE,
   GX_PLAN_NO,
   INPUT_WEIGHT,
   INPUT_COUNT,
   OUTPUT_WEIGHT,
   OUTPUT_COUNT,
   BAL_YEAR_MONTH,
   IS_ALL_SCRAP,
   PROCESS_CODE,
   QUALITY_GROUP,
   MAT_GOWHERE_CODE,
   MAT_GOWHERE_NAME,
   JUDGE_RESULT,
   JUDGE_RESULT_CODE,
   JUGDE_APPLY_SEQUENO,
   JUDGE_TOLRESULT_CODE,
   JUDGE_TOLRESULT,
   JUDGE_TOLRESULT_TIME,
   --JUDGE_TOLMAKER,
   JUDGE_RESULT_TIME,
   JUDGE_MAKER,
   MATERIAL_NO,
   MATERIAL_NAME,
   PRODUCCODE,
   STEELCODE,
   GRADECODE,
   SPEC_CODE,
   MODEL_CODE,
   STD_CODE,
   STD_STYLE,
   HEAT_PLAN_NO,
   SUPPLY_UNIT,
   SUPPLY_UNIT_DESC)
VALUES
  ('#JUGDE_APPLY_CODE#',
   '#JUDGE_STOVE_NO#',
   NVL('#BATCH_NO#', '/'),
   '#BATCH_GROUD_NO#',
   '#PLINE_CODE#',
   '#ACT_COUNT#',
   '#ACT_WEIGHT#',
   '#ACT_THEORY_WEIGHT#',
   '#PRO_ORDER_ID#',
   '#VALIDFLAG#',
   '#APPLY_NAME#',
   SYSDATE,
   '#PRODUCNAME#',
   '#STEELNAME#',
   '#GRADENAME#',
   '#SPEC_NAME#',
   '#MODEL_DESC#',
   '#STD_NAME#',
   '#STD_STYLE_DESC#',
   '#CRAF_NO#',
   '#LOT_NO#',
   '#PLINE_NAME#',
   '#PRO_ORDER_NO#',
   '#TARGET#',
   '#ORD_LN_DLY_PK#',
   '#APPLY_FLAG#',
   '#BELONG_CODE#',
   '#BELONG_NAME#',
   '#BELONG_CODE_JUGDE#',
   '#BELONG_NAME_JUGDE#',
   '#GX_PLAN_NO#',
   '#INPUT_WEIGHT#',
   '#INPUT_COUNT#',
   '#OUTPUT_WEIGHT#',
   '#OUTPUT_COUNT#',
   '#BAL_YEAR_MONTH#',
   '#IS_ALL_SCRAP#',
   '#PROCESS_CODE#',
   '1',
   '1',
   '',
   '合格',
   '40740701',
   '#JUGDE_APPLY_SEQUENO#',
   '#JUDGE_TOLRESULT_CODE#',
   '#JUDGE_TOLRESULT#',
   TO_DATE('#JUDGE_TOLRESULT_TIME#', 'YYYY-MM-DD HH24:mi:ss'),
   --'#JUDGE_TOLMAKER#',
   SYSDATE,
   '#JUDGE_MAKER#',
   '#MATERIAL_NO#',
   '#MATERIAL_NAME#',
   '#PRODUCCODE#',
   '#STEELCODE#',
   '#GRADECODE#',
   '#SPEC_CODE#',
   '#MODEL_CODE#',
   '#STD_CODE#',
   '#STD_STYLE#',
   '#HEAT_PLAN_NO#',
   (SELECT C.SUPPLY_UNIT_CODE
      FROM COM_BASE_PLINE C
     WHERE C.PLINE_CODE = '#PLINE_CODE#'),
   (SELECT C.SUPPLY_UNIT
      FROM COM_BASE_PLINE C
     WHERE C.PLINE_CODE = '#PLINE_CODE#'))
 
</query>

<query id = "FrmScrapStoveApplyDescion.SelectJudegNoSequenNo" desc = "查询申请判定顺序号">
SELECT NVL(MAX(T.JUGDE_APPLY_SEQUENO),0)+1 JUGDE_APPLY_SEQUENO
  FROM QCM_ZG_JUGDE_APPLY T
 WHERE T.JUGDE_APPLY_CODE = ?
</query>

<query id = "FrmScrapStoveApplyDescion.SelectScrapInput" desc = "查询投料量(废)">
<![CDATA[
SELECT COUNT(1)INPUT_COUNT,SUM(INPUT_WEIGHT)INPUT_WEIGHT
  FROM (SELECT S.M_MAT_NO,SUM(S.INPUT_WEIGHT)INPUT_WEIGHT
          FROM PORT_MIL_BATCH_SAMPLE_RESULT S
         WHERE S.JUDGE_STOVE_NO = ? || '-01'
         AND S.TR_FLAG = '0'
         GROUP BY S.M_MAT_NO
         ORDER BY S.M_MAT_NO)
                        ]]>
</query>
<query id = "FrmScrapStoveApplyDescion.SelectScrapInput1" desc = "查询投料量(白条)">
<![CDATA[
SELECT *
                         FROM (SELECT S.M_MAT_NO
                                 FROM PORT_MIL_BATCH_SAMPLE_RESULT S
                                WHERE S.JUDGE_STOVE_NO =
                                      ? || '-01'
                                  AND S.TR_FLAG = '0'
                                  AND S.JUGDE_APPLY_CODE IS NULL
                                GROUP BY S.M_MAT_NO
                                ORDER BY S.M_MAT_NO)
                        WHERE ROWNUM <= ?
                        ]]>
</query>
<query id = "FrmScrapStoveApplyDescion.cancelScrapMata" desc = "撤销整炉送判">
DELETE FROM QCM_ZG_JUGDE_APPLY T WHERE T.JUGDE_APPLY_CODE = '#JUGDE_APPLY_CODE#' AND T.IS_ALL_SCRAP = '#IS_ALL_SCRAP#'
AND T.JUGDE_APPLY_SEQUENO ='#JUGDE_APPLY_SEQUENO#'
</query>
<query id = "insertWhiteBank.selectInstore" desc = "查询下线实绩表">
<![CDATA[
SELECT COUNT(1)ACOUNT FROM MIL_INSTORE_RESULT T WHERE T.JUDGE_STOVE_NO || '&' LIKE '%' || ? || '%'
]]>
</query>
<query id = "FrmScrapStoveApplyDescion.selectMaxBalYearMoth" desc = "查询期初表最大结转年月">
SELECT TO_CHAR(SYSDATE,'YYYYMM') BAL_YEAR_MONTH,to_char(add_months(sysdate,1),'yyyymm') as B_BAL_YEAR_MONTH FROM DUAL T
</query>
<query id = "FrmScrapStoveApplyDescion.selectDostoreE" desc = "查询是否结炉镦拔扩">
<![CDATA[
SELECT  COUNT(*) COUNT FROM pln_zy_dbk_m T WHERE T.JUDGE_STOVE_NO = ? and t.PLANSTATUS IN ('30','40') 
]]>
</query>
<query id = "FrmScrapStoveApplyDescion.selectDostoreF" desc = "查询是否结炉热处理">
<![CDATA[
SELECT  COUNT(*) COUNT FROM PLN_ZY_RCL_M T WHERE T.JUDGE_STOVE_NO = ? and t.PLANSTATUS IN ('30','40') 
]]>
</query>
<query id = "FrmScrapStoveApplyDescion.selectDostoreG" desc = "查询是否结炉加工线">
<![CDATA[
SELECT  COUNT(*) COUNT FROM pln_zy_jgx_m T WHERE T.JUDGE_STOVE_NO = ? and t.PLANSTATUS IN ('30','40') 
]]>
</query>
<query id = "FrmScrapStoveApplyDescion.updatePlanStatusE" desc = "更新炉计划状态镦拔扩">
UPDATE pln_zy_dbk_m T
   SET T.PLANSTATUS = ?
 WHERE t.heat_plan_no = ?
  and t.judge_stove_no = ?
</query>

<query id = "FrmScrapStoveApplyDescion.updatePlanStatusF" desc = "更新炉计划状态热处理">
UPDATE pln_zy_rcl_m T
   SET T.PLANSTATUS = ?
 WHERE t.heat_plan_no = ?
  and t.judge_stove_no = ?
</query>
<query id = "FrmScrapStoveApplyDescion.updatePlanStatusG" desc = "更新炉计划状态加工线">
UPDATE pln_zy_jgx_m T
   SET T.PLANSTATUS = ?
 WHERE t.heat_plan_no = ?
  and t.judge_stove_no = ?
</query>

       <query id = "FrmScrapStoveApplyDescion.updatePortF" desc = "更新管号队列送判单号">
              UPDATE PORT_HTT_BATCH_SAMPLE_RESULT
              SET JUGDE_APPLY_CODE = ?
              WHERE HEAT_PLAN_NO = ?
       </query>


       <query id = "FrmScrapStoveApplyDescion.updatePortG" desc = "更新管号队列送判单号">
              UPDATE PORT_MCH_BATCH_SAMPLE_RESULT
              SET JUGDE_APPLY_CODE = ?
              WHERE HEAT_PLAN_NO = ?
              AND BATCH_NO = ?
       </query>

       <query id = "FrmScrapStoveApplyDescion.updatePortF1" desc = "更新管号队列送判单号">
              UPDATE PORT_HTT_BATCH_SAMPLE_RESULT
              SET JUGDE_APPLY_CODE = ''
              WHERE JUGDE_APPLY_CODE = ?
              AND judge_stove_no = ?
       </query>


       <query id = "FrmScrapStoveApplyDescion.updatePortG1" desc = "更新管号队列送判单号">
              UPDATE PORT_MCH_BATCH_SAMPLE_RESULT
              SET JUGDE_APPLY_CODE = ''
              WHERE  JUGDE_APPLY_CODE = ?
              AND judge_stove_no = ?
       </query>
</queryMap>