<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="QCM_ZG_JUGDE_APPLY （生成工具：代码生成工具4.0   访问地址：http://172.16.2.128/tool/）">
    <query id="QcmZgJugdeApplyDAL.Query" desc="查询">
        <![CDATA[
 SELECT 
       T.JUGDE_APPLY_CODE,
       T.JUDGE_STOVE_NO,
       T.BATCH_NO,
       T.BATCH_GROUD_NO,
       T.PROCESS_CODE,
       T.PLINE_CODE,
       T.ACT_COUNT,
       T.ACT_WEIGHT,
       T.ACT_THEORY_WEIGHT, 
       T.PRO_ORDER_ID,
       T.FACE_RESULT_CODE,
       T.SPEC_RESULT_CODE,
       T.CHEM_RESULT_CODE,
       T.PHY_RESULT_CODE,
       T.DETECT_RESULT_CODE,
       T.WPRESSURE_RESULT_CODE,
       T.PROCESS_RESULT_CODE,
       T.FACE_RESULT_PATH,
       T.SPEC_RESULT_PATH,
       T.CHEM_RESULT_PATH,
       T.PHY_RESULT_PATH,
       T.DETECT_RESULT_PATH,
       T.WPRESSURE_RESULT_PATH,
       T.PROCESS_RESULT_PATH,
       T.VALIDFLAG,
       T.APPLY_NAME,
       TO_CHAR(T.APPLY_TIME, 'YYYY-MM-DD HH24:MI:SS') APPLY_TIME,
       T.MEMO,
       T.QUALITY_GROUP,
       T.MATERIAL_NO,
       T.MATERIAL_NAME,
       T.PRODUCCODE,
       T.PRODUCNAME,
       T.STEELCODE,
       T.STEELNAME,
       T.GRADECODE,
       T.GRADENAME,
       T.SPEC_CODE,
       T.SPEC_NAME,
       T.MODEL_CODE,
       T.MODEL_DESC,
       T.STD_CODE,
       T.STD_NAME,
       T.STD_STYLE,
       T.STD_STYLE_DESC,
       T.CRAF_NO,
       T.LOT_NO,
       T.PLINE_NAME,
       T.PRO_ORDER_NO,
       T.TARGET,
       T.PROCESS_STATUS,
       T.MAT_GOWHERE_CODE,
       T.MAT_GOWHERE_NAME,
       T.ACT_DIMATER,
       T.ACT_HEIGHT,
       T.ACT_LEN_MIN,
       T.ACT_LEN_MAX,
       T.JUDGE_RESULT_CODE,
       T.JUDGE_RESULT,
       TO_CHAR(T.JUDGE_RESULT_TIME, 'YYYY-MM-DD HH24:MI:SS') JUDGE_RESULT_TIME,
       T.JUDGE_MAKER,
       T.IF_SET_ZY_PLAN,
       T.TESTING_GRADE,
       T.TESTING_TYPE,
       T.TESTING_GRADE1,
       T.TESTING_TYPE1,
       T.DETECT_RESULT_CODE1,
       T.DETECT_RESULT_PATH1,
       T.ORD_LN_DLY_PK,
       T.APPLY_FLAG,
       T.BACK_JUGDE_MEMO,
       T.INSTOCK_FLAG,
       T.BELONG_CODE,
       T.BELONG_NAME,
       T.ISENDGX,
       T.EXIT_TEMP,
       T.SAMPLE_NEWS,
       T.ACT_LEN,
       T.BELONG_CODE_JUGDE,
       T.BELONG_NAME_JUGDE,
       T.GX_PLAN_NO,
       T.INPUT_WEIGHT,
       T.INPUT_COUNT,
       T.OUTPUT_WEIGHT,
       T.OUTPUT_COUNT,
       T.BAL_YEAR_MONTH,
       T.IS_FLAG,
       T.IS_ALL_SCRAP,
       T.IS_CARRY_VOER
 FROM QCM_ZG_JUGDE_APPLY T
 WHERE
       T.JUGDE_APPLY_CODE = '#JUGDE_APPLY_CODE#'
       AND T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
       AND T.BATCH_NO = '#BATCH_NO#'
       AND T.BATCH_GROUD_NO = '#BATCH_GROUD_NO#'
       AND T.QUALITY_GROUP = '#QUALITY_GROUP#'
       AND T.MAT_GOWHERE_CODE = '#MAT_GOWHERE_CODE#'
        ]]>
    </query>
    
    <query id="QcmZgJugdeApplyDAL.QueryBcChem" desc="查询轧管成分">
        <![CDATA[
SELECT T.STOVE_NO,
       T.JUDGE_STOVE_NO,
       T.BATCH_NO,
       MIN(T.GRADENAME) GRADENAME,
       MIN(T.ACT_DIMATER) ACT_DIMATER,
       MIN(T.ACT_HEIGHT) ACT_HEIGHT,
       MAX(T.CHEM_RESULT_CODE) CHEM_RESULT_CODE,
       MIN(T2.BASENAME) CHEM_RESULT_NAME,
       MAX(T.PLINE_CODE) PLINE_CODE,
       MAX(T.PLINE_NAME) PLINE_NAME,
       TO_CHAR(MAX(T.APPLY_TIME), 'YYYY-MM-DD HH24:MI:SS') APPLY_TIME,
       MIN(T.JUGDE_APPLY_CODE) JUGDE_APPLY_CODE,
       TO_CHAR(MAX(A.CREATE_TIME), 'YYYY-MM-DD HH24:MI:SS') JUDGE_TIME,
       MIN(A.CREATE_NAME) JUDGE_NAME,
       MAX(A.MEMO) MEMO,
       '正常' LK_FLAG,
       MIN(T.STEEL_STANDRAD) STEEL_STANDRAD,
       DECODE(MIN(B.SAMPLE_TYPE), '1', '初样', '2', '复样', NULL) CHEM_TYPE,
       NULL OLD_GRADENAME,
       NULL OLD_CIC
  FROM QCM_ZG_JUGDE_APPLY T
  LEFT JOIN COM_BASE_INFO T2
    ON T2.BASECODE = T.CHEM_RESULT_CODE
  LEFT JOIN (SELECT MIN(AA.JUDGE_STOVE_NO) JUDGE_STOVE_NO,
                    MIN(AA.CREATE_TIME) CREATE_TIME,
                    MIN(AA.MEMO) MEMO,
                    MIN(AA.VALIDFLAG) VALIDFLAG,
                    MIN(AA.PROCESS_CDOE) PROCESS_CDOE,
                    MIN(AA.CREATE_NAME) CREATE_NAME,
                    MIN(AA.BATCH_NO) BATCH_NO
               FROM QCM_BC_CHEMJUDGE AA
              GROUP BY AA.CHEM_JUDGE_ID) A
    ON T.JUDGE_STOVE_NO = A.JUDGE_STOVE_NO
   AND T.BATCH_NO = A.BATCH_NO
   AND A.PROCESS_CDOE = {9}
   AND A.VALIDFLAG = '1'
  LEFT JOIN QCM_BC_CHEMJUDGE B
    ON B.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO
   AND B.BATCH_NO = T.BATCH_NO
   AND B.PROCESS_CDOE = {9}
   AND B.VALIDFLAG = '1'
 WHERE ({0} IS NULL OR T.BATCH_NO LIKE '%' || {0} || '%')
   AND ({1} IS NULL OR T.JUDGE_STOVE_NO LIKE '%' || {1} || '%')
   AND ({2} = '0' AND T.CHEM_RESULT_CODE IS NULL OR
       {2} = '1' AND T.CHEM_RESULT_CODE IS NOT NULL OR
       {2} NOT IN ('0', '1') AND T.CHEM_RESULT_CODE = {2} OR {2} IS NULL)
   AND ({3} IS NULL OR
       T.APPLY_TIME >= TO_DATE({3}, 'YYYY-MM-DD HH24:MI:SS'))
   AND ({4} IS NULL OR
       T.APPLY_TIME <= TO_DATE({4}, 'YYYY-MM-DD HH24:MI:SS'))
   AND ({5} = '0' OR T.PLINE_CODE IN {6})
   AND ({7} IS NULL OR B.SAMPLE_TYPE = {7})
   AND ({8} IS NULL OR {8} = '1' AND T.PLINE_CODE NOT IN ('C065', 'C066') OR
       {8} = '2' AND T.PLINE_CODE IN ('C065', 'C066'))
   AND T.PROCESS_CODE = {9}
   AND T.IS_FLAG = '0'
   AND T.IS_ALL_SCRAP IN ('0', '4', '5')
 GROUP BY T.BATCH_NO, T.JUDGE_STOVE_NO, T.STOVE_NO
 ORDER BY T.STOVE_NO
        ]]>
    </query>
    
    <query id="QcmZgJugdeApplyDAL.QueryBcPhy" desc="查询">
        <![CDATA[
SELECT T.STOVE_NO,
       T.JUDGE_STOVE_NO,
       T.BATCH_NO,
       MIN(T.GRADENAME) GRADENAME,
       MIN(T.ACT_DIMATER) ACT_DIMATER,
       MIN(T.ACT_HEIGHT) ACT_HEIGHT,
       MAX(T.PHY_RESULT_CODE) PHY_RESULT_CODE,
       MIN(T2.BASENAME) PHY_RESULT_NAME,
       MAX(T.PLINE_CODE) PLINE_CODE,
       MAX(T.PLINE_NAME) PLINE_NAME,
       TO_CHAR(MAX(T.APPLY_TIME), 'YYYY-MM-DD HH24:MI:SS') APPLY_TIME,
       MIN(T.JUGDE_APPLY_CODE) JUGDE_APPLY_CODE,
       TO_CHAR(MAX(A.CREATE_TIME), 'YYYY-MM-DD HH24:MI:SS') JUDGE_TIME,
       MIN(A.CREATE_NAME) JUDGE_NAME,
       MAX(A.MEMO) MEMO,
       '正常' LK_FLAG,
       MIN(T.STEEL_STANDRAD) STEEL_STANDRAD,
       DECODE(MIN(B.SAMPLE_TYPE), '1', '初验', '2', '复验', NULL) SAMPLE_TYPE,
       NULL OLD_GRADENAME,
       NULL OLD_CIC
  FROM QCM_ZG_JUGDE_APPLY T
  LEFT JOIN COM_BASE_INFO T2
    ON T2.BASECODE = T.PHY_RESULT_CODE
  LEFT JOIN (SELECT MIN(AA.JUDGE_STOVE_NO) JUDGE_STOVE_NO,
                    MIN(AA.CREATE_TIME) CREATE_TIME,
                    MIN(AA.MEMO) MEMO,
                    MIN(AA.VALIDFLAG) VALIDFLAG,
                    MIN(AA.PROCESS_CDOE) PROCESS_CDOE,
                    MIN(AA.CREATE_NAME) CREATE_NAME,
                    MIN(AA.BATCH_NO) BATCH_NO
               FROM QCM_BC_PHYJUDGE AA
              GROUP BY AA.PHY_JUDGE_ID) A
    ON T.JUDGE_STOVE_NO = A.JUDGE_STOVE_NO
   AND T.BATCH_NO = A.BATCH_NO
   AND A.PROCESS_CDOE = {9}
   AND A.VALIDFLAG = '1'
  LEFT JOIN QCM_BC_PHYJUDGE B
    ON B.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO
   AND B.BATCH_NO = T.BATCH_NO
   AND B.PROCESS_CDOE = {9}
   AND B.VALIDFLAG = '1'
 WHERE ({0} IS NULL OR T.BATCH_NO LIKE '%' || {0} || '%')
   AND ({1} IS NULL OR T.JUDGE_STOVE_NO LIKE '%' || {1} || '%')
   AND ({2} = '0' AND T.PHY_RESULT_CODE IS NULL OR
       {2} = '1' AND T.PHY_RESULT_CODE IS NOT NULL OR
       {2} NOT IN ('0', '1') AND T.PHY_RESULT_CODE = {2} OR {2} IS NULL)
   AND ({3} IS NULL OR
       T.APPLY_TIME >= TO_DATE({3}, 'YYYY-MM-DD HH24:MI:SS'))
   AND ({4} IS NULL OR
       T.APPLY_TIME <= TO_DATE({4}, 'YYYY-MM-DD HH24:MI:SS'))
   AND ({5} = '0' OR T.PLINE_CODE IN {6})
   AND ({7} IS NULL OR B.SAMPLE_TYPE = {7})
   AND ({8} IS NULL OR {8} = '1' AND T.PLINE_CODE NOT IN ('C065', 'C066') OR
       {8} = '2' AND T.PLINE_CODE IN ('C065', 'C066'))
   AND T.PROCESS_CODE = {9}
   AND T.IS_FLAG = '0'
   AND T.IS_ALL_SCRAP IN ('0', '4', '5')
 GROUP BY T.BATCH_NO, T.JUDGE_STOVE_NO, T.STOVE_NO
 ORDER BY T.STOVE_NO
        ]]>
    </query>
    
    <query id="QcmZgJugdeApplyDAL.QueryBcColligate" desc="半成品综合查询">
        <![CDATA[
SELECT *
  FROM (SELECT TT.STOVE_NO,
               TT.LOT_NO,
               MIN(TT.LOT_NO_GROUP) LOT_NO_GROUP,
               MIN(TT.JUDGE_STOVE_NO) JUDGE_STOVE_NO,
               MIN(TT.BATCH_NO) BATCH_NO,
               MIN(TT.ZP_M_LH) ZP_M_LH,
               MIN(TT.ZP_COLL) ZP_COLL,
               MIN(TT.LOAD_JUDGE_STOVE_NO) LOAD_JUDGE_STOVE_NO,
               MIN(TT.LOAD_BATCH_NO) LOAD_BATCH_NO,
               MIN(TT.GRADENAME) GRADENAME,
               MIN(TT.STEELNAME) STEELNAME,
               MIN(TT.ACT_DIMATER) ACT_DIMATER,
               MIN(TT.ACT_HEIGHT) ACT_HEIGHT,
               MIN(TT.PHY_RESULT_CODE) PHY_RESULT_CODE,
               MIN(TT.PHY_RESULT_NAME) PHY_RESULT_NAME,
               MIN(TT.CHEM_RESULT_CODE) CHEM_RESULT_CODE,
               MIN(TT.CHEM_RESULT_NAME) CHEM_RESULT_NAME,
               MIN(TT.PLINE_CODE) PLINE_CODE,
               MIN(TT.PLINE_NAME) PLINE_NAME,
               MIN(TT.APPLY_TIME) APPLY_TIME,
               MIN(TT.JUDGE_TIME) JUDGE_TIME,
               MIN(TT.JUDGE_NAME) JUDGE_NAME,
               MIN(TT.MEMO) MEMO,
               MIN(TT.JUDGE_MEMO) JUDGE_MEMO,
               MIN(TT.LK_FLAG) LK_FLAG,
               MIN(TT.STEEL_STANDRAD) STEEL_STANDRAD,
               MIN(TT.PHY_TYPE) PHY_TYPE,
               MIN(TT.OLD_GRADENAME) OLD_GRADENAME,
               MIN(TT.OLD_CIC) OLD_CIC,
               MIN(TT.PASS_APPLY_NO) PASS_APPLY_NO,
               MIN(TT.AUDIT_RESULT) AUDIT_RESULT,
               MIN(TT.URGENT_PASS_NO) URGENT_PASS_NO,
               MIN(TT.URGENT_AUDIT_RESULT) URGENT_AUDIT_RESULT,
               MIN(TT.RESULT_NAME) RESULT_NAME,
               MIN(TT.RESULT_CODE) RESULT_CODE,
               MIN(TT.SPEC_RESULT_NAME) SPEC_RESULT_NAME,
               MIN(TT.FACE_RESULT_NAME) FACE_RESULT_NAME,
               MIN(TT.DETECT_RESULT_NAME) DETECT_RESULT_NAME,
               MIN(TT.WATER_RESULT_NAME) WATER_RESULT_NAME,
               MIN(TT.PROCESS_RESULT_NAME) PROCESS_RESULT_NAME,
               MIN(TT.JUGDE_APPLY_CODE) JUGDE_APPLY_CODE,
               MIN(TT.TARGET) TARGET,
               MIN(TT.ORDER_NO) ORDER_NO,
               MIN(TT.BUYER_NAME) BUYER_NAME,
               MIN(TT.PRODUCNAME) PRODUCNAME,
               MIN(TT.STD_STYLE_DESC) STD_STYLE_DESC,
               MIN(TT.MODEL_DESC) MODEL_DESC,
               MIN(TT.SPEC_NAME) SPEC_NAME,
               MIN(TT.DELIVERY_STATE_NAME) DELIVERY_STATE_NAME,
               MIN(TT.STD_NAME) STD_NAME,
               MIN(TT.APPLY_MEMO) APPLY_MEMO,
               MIN(TT.HTT_TYPE) HTT_TYPE,
               MIN(TT.MIN_TEMP) MIN_TEMP,
               MIN(TT.HTT_TECHNOLOGY) HTT_TECHNOLOGY,
               MIN(TT.NOTCH_INFO) NOTCH_INFO,
               MIN(TT.NOTCH_LENGTH) NOTCH_LENGTH,
               MIN(TT.NOTCH_WIDTH) NOTCH_WIDTH,
               MIN(TT.NOTCH_DEPTH) NOTCH_DEPTH,
               MIN(TT.TESTING_GRADE) TESTING_GRADE,
               MIN(TT.TESTING_TYPE) TESTING_TYPE,
               MIN(TT.TESTING_GRADE1) TESTING_GRADE1,
               MIN(TT.TESTING_TYPE1) TESTING_TYPE1,
               MIN(TT.JUDGE_CONDITION) JUDGE_CONDITION,
               SUM(TT.ACT_COUNT) ACT_COUNT,
               SUM(TT.ACT_THEORY_WEIGHT) ACT_THEORY_WEIGHT,
               MIN(TT.CHECK_NO) CHECK_NO,
               MIN(TT.TEST_PRESSURE) TEST_PRESSURE,
               MIN(TT.HOLDTIME_TIME) HOLDTIME_TIME,
               MIN(TT.TEST_PRESSURE_Y) TEST_PRESSURE_Y,
               MIN(TT.PRODUCE_TIME) PRODUCE_TIME,
               MIN(TT.IF_OUT_DETECT) IF_OUT_DETECT,
               MIN(TT.IF_OUT_COAT) IF_OUT_COAT,
               MIN(TT.IF_OUT_IMPRESS) IF_OUT_IMPRESS,
               MIN(TT.IF_OUT_BLAST) IF_OUT_BLAST,
               MIN(TT.WO_ID) WO_ID,
               MIN(TT.EXIT_TEMP) EXIT_TEMP,
               MAX(TT.ZBS_LOCK_FLAG) ZBS_LOCK_FLAG,
               MIN(TT.AUTO_JUDGE) AUTO_JUDGE,
               MIN(TT.CIC) CIC,
               MIN(TT.PIC) PIC,
               TT.IN_MOLD
          FROM (SELECT MIN(T.STOVE_NO) STOVE_NO,
                       MIN(T.LOT_NO) LOT_NO,
                       MIN(T.LOT_NO_GROUP) LOT_NO_GROUP,
                       T.JUDGE_STOVE_NO,
                       T.BATCH_NO,
                       MIN(T.ZP_M_LH) ZP_M_LH,
                       MIN(T.ZP_COLL) ZP_COLL,
                       MIN(T.LOAD_JUDGE_STOVE_NO) LOAD_JUDGE_STOVE_NO,
                       MIN(T.LOAD_BATCH_NO) LOAD_BATCH_NO,
                       MIN(T.GRADENAME) GRADENAME,
                       MIN(T.STEELNAME) STEELNAME,
                       MIN(T.ACT_DIMATER) ACT_DIMATER,
                       MIN(T.ACT_HEIGHT) ACT_HEIGHT,
                       MAX(E.PHY_RESULT_CODE) PHY_RESULT_CODE,
                       MIN(T2.BASENAME) PHY_RESULT_NAME,
                       MIN(E.CHEM_RESULT_CODE) CHEM_RESULT_CODE,
                       MIN(T3.BASENAME) CHEM_RESULT_NAME,
                       MAX(T.PLINE_CODE) PLINE_CODE,
                       MAX(T.PLINE_NAME) PLINE_NAME,
                       TO_CHAR(MAX(T.APPLY_TIME), 'YYYY-MM-DD HH24:MI:SS') APPLY_TIME,
                       TO_CHAR(MAX(T.JUDGE_RESULT_TIME),
                               'YYYY-MM-DD HH24:MI:SS') JUDGE_TIME,
                       MIN(A.CREATE_NAME) JUDGE_NAME,
                       MIN(T.JUDGE_FILE_MEMO) MEMO,
                       MIN(T.JUDGE_MEMO) JUDGE_MEMO,
                       MIN(T.LK_FLAG) LK_FLAG,
                       MIN(T.STEEL_STANDRAD) STEEL_STANDRAD,
                       CASE
                         WHEN MIN(B.SAMPLE_TYPE) = '2' THEN
                          '复验'
                         ELSE
                          '初验'
                       END CHEM_TYPE,
                       CASE
                         WHEN MIN(C.SAMPLE_TYPE) = '2' THEN
                          '复验'
                         ELSE
                          '初验'
                       END PHY_TYPE,
                       NULL OLD_GRADENAME,
                       NULL OLD_CIC,
                       MIN(D.PASS_APPLY_NO) PASS_APPLY_NO,
                       MIN(D2.BASENAME) AUDIT_RESULT,
                       MIN(D3.PASS_APPLY_NO) URGENT_PASS_NO,
                       DECODE(MIN(D3.AUDIT_RESULT),
                              '0',
                              '审核不通过',
                              '1',
                              '审核通过',
                              NULL) URGENT_AUDIT_RESULT,
                       MIN(T.JUDGE_RESULT) RESULT_NAME,
                       MIN(T.JUDGE_RESULT_CODE) RESULT_CODE,
                       MIN(T4.BASENAME) SPEC_RESULT_NAME,
                       MIN(T5.BASENAME) FACE_RESULT_NAME,
                       MIN(T6.BASENAME) DETECT_RESULT_NAME,
                       MIN(T7.BASENAME) WATER_RESULT_NAME,
                       MIN(T8.BASENAME) PROCESS_RESULT_NAME,
                       T.JUGDE_APPLY_CODE JUGDE_APPLY_CODE,
                       MIN(T.TARGET) TARGET,
                       MIN(F.ORDER_NO) || '/' || MIN(F.ORDER_SEQ) ORDER_NO,
                       MIN(F.BUYER_NAME) BUYER_NAME,
                       MIN(T.PRODUCNAME) PRODUCNAME,
                       MIN(T.STD_STYLE_DESC) STD_STYLE_DESC,
                       MIN(T.MODEL_DESC) MODEL_DESC,
                       MIN(T.SPEC_NAME) SPEC_NAME,
                       MIN(T.DELIVERY_STATE_NAME) DELIVERY_STATE_NAME,
                       MIN(T.STD_NAME) STD_NAME,
                       MIN(T.MEMO) APPLY_MEMO,
                       MIN(T.HTT_TYPE) HTT_TYPE,
                       MIN(T.MIN_TEMP) MIN_TEMP,
                       MIN(T.HTT_TECHNOLOGY) HTT_TECHNOLOGY,
                       MIN(T.NOTCH_INFO) NOTCH_INFO,
                       MIN(T.NOTCH_LENGTH) NOTCH_LENGTH,
                       MIN(T.NOTCH_WIDTH) NOTCH_WIDTH,
                       MIN(T.NOTCH_DEPTH) NOTCH_DEPTH,
                       MIN(T.TESTING_GRADE) TESTING_GRADE,
                       MIN(T.TESTING_TYPE) TESTING_TYPE,
                       MIN(T.TESTING_GRADE1) TESTING_GRADE1,
                       MIN(T.TESTING_TYPE1) TESTING_TYPE1,
                       DECODE(MIN(E.JUDGE_RESULT_CODE),
                              NULL,
                              '不符合',
                              '40740704','不符合',
                              '符合') JUDGE_CONDITION,
                       MIN(T.ACT_COUNT) ACT_COUNT,
                       MIN(T.ACT_WEIGHT) ACT_THEORY_WEIGHT,
                       MIN(T.CHECK_NO) CHECK_NO,
                       MIN(T.TEST_PRESSURE) TEST_PRESSURE,
                       MIN(T.HOLDTIME_TIME) HOLDTIME_TIME,
                       MIN(T.TEST_PRESSURE_Y) TEST_PRESSURE_Y,
                       CASE
                         WHEN MIN(T.PROCESS_CODE) = 'D' THEN
                          TO_CHAR(MIN(G.FEED_TIME), 'YYYY-MM-DD HH24:MI:SS')
                         WHEN MIN(T.PROCESS_CODE) = 'E' THEN
                          TO_CHAR(MIN(G2.LOAD_TIME), 'YYYY-MM-DD HH24:MI:SS')
                         WHEN MIN(T.PROCESS_CODE) = 'F' THEN
                          TO_CHAR(MIN(G3.LOADTIME), 'YYYY-MM-DD HH24:MI:SS')
                         WHEN MIN(T.PROCESS_CODE) = 'G' THEN
                          TO_CHAR(MIN(G4.LOADTIME), 'YYYY-MM-DD HH24:MI:SS')
                         WHEN MIN(T.PROCESS_CODE) = 'H' THEN
                          TO_CHAR(MIN(G5.LOAD_TIME), 'YYYY-MM-DD HH24:MI:SS')
                         ELSE
                          NULL
                       END PRODUCE_TIME,
                       MIN(H2.BASENAME) IF_OUT_DETECT,
                       MIN(H3.BASENAME) IF_OUT_COAT,
                       MIN(H4.BASENAME) IF_OUT_IMPRESS,
                       MIN(H5.BASENAME) IF_OUT_BLAST,
                       MIN(H.WO_ID) WO_ID,
                       MIN(T.EXIT_TEMP) EXIT_TEMP,
                       MAX(T.ZBS_LOCK_FLAG) ZBS_LOCK_FLAG,
                       MIN(T.AUTO_JUDGE) AUTO_JUDGE,
                       MIN(T.CIC) CIC,
                       MIN(T.PIC) PIC,
                       (SELECT BASENAME FROM COM_BASE_INFO WHERE BASECODE = T.IN_MOLD) IN_MOLD
                  FROM QCM_ZG_JUGDE_APPLY T
                  LEFT JOIN COM_BASE_INFO T4
                    ON T4.BASECODE = T.SPEC_RESULT_CODE
                   AND T.SPEC_RESULT_CODE IS NOT NULL
                  LEFT JOIN COM_BASE_INFO T5
                    ON T5.BASECODE = T.FACE_RESULT_CODE
                   AND T.FACE_RESULT_CODE IS NOT NULL
                  LEFT JOIN COM_BASE_INFO T6
                    ON T6.BASECODE = T.DETECT_RESULT_CODE
                   AND T.DETECT_RESULT_CODE IS NOT NULL
                  LEFT JOIN COM_BASE_INFO T7
                    ON T7.BASECODE = T.WPRESSURE_RESULT_CODE
                   AND T.WPRESSURE_RESULT_CODE IS NOT NULL
                  LEFT JOIN COM_BASE_INFO T8
                    ON T8.BASECODE = T.PROCESS_RESULT_CODE
                   AND T.PROCESS_RESULT_CODE IS NOT NULL
                  LEFT JOIN QCM_BC_JUDGE A
                    ON A.JUDGE_ID = T.JUGDE_CONVICTED
                   AND T.JUGDE_CONVICTED IS NOT NULL
                  LEFT JOIN QCM_BC_CHEMJUDGE B
                    ON B.CHEM_JUDGE_ID = A.CHEM_JUDGE_ID
                   AND B.JUDGE_SEQ = 1
                   AND A.CHEM_JUDGE_ID IS NOT NULL
                  LEFT JOIN QCM_BC_PHYJUDGE C
                    ON C.PHY_JUDGE_ID = A.PHY_RESULT_ID
                   AND C.JUDGE_SEQ = 1
                   AND A.PHY_RESULT_ID IS NOT NULL
                  LEFT JOIN QCM_BC_PASS_APPLY D
                    ON D.JUGDE_APPLY_CODE = T.JUGDE_APPLY_CODE
                   AND D.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO
                   AND D.BATCH_NO = T.BATCH_NO
                   AND D.PROCESS_CODE = T.PROCESS_CODE
                   AND D.VALIDFLAG = '1'
                   AND D.PASS_APPLY_SEQ = '001'
                   AND D.TYPE = '0'
                   AND T.JUGDE_APPLY_CODE IS NOT NULL
                   AND T.JUDGE_STOVE_NO IS NOT NULL
                   AND T.BATCH_NO IS NOT NULL
                  LEFT JOIN COM_BASE_INFO D2
                    ON D2.BASECODE = D.AUDIT_RESULT
                   AND D.AUDIT_RESULT IS NOT NULL
                  LEFT JOIN QCM_BC_PASS_APPLY D3
                    ON D3.JUGDE_APPLY_CODE = T.JUGDE_APPLY_CODE
                   AND D3.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO
                   AND D3.BATCH_NO = T.BATCH_NO
                   AND D3.PROCESS_CODE = T.PROCESS_CODE
                   AND D3.VALIDFLAG = '1'
                   AND D3.PASS_APPLY_SEQ = '001'
                   AND D3.TYPE = '1'
                   AND T.JUGDE_APPLY_CODE IS NOT NULL
                   AND T.JUDGE_STOVE_NO IS NOT NULL
                   AND T.BATCH_NO IS NOT NULL
                  LEFT JOIN QCM_BC_PASS_APPLY D4
                    ON D4.JUGDE_APPLY_CODE = T.JUGDE_APPLY_CODE
                   AND D4.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO
                   AND D4.BATCH_NO = T.BATCH_NO
                   AND D4.PROCESS_CODE = T.PROCESS_CODE
                   AND D4.TYPE = '0'
                   AND D4.AUDIT_RESULT IN ('407502', '407503')
                   AND D4.VALIDFLAG = '1'
                   AND T.JUGDE_APPLY_CODE IS NOT NULL
                   AND T.JUDGE_STOVE_NO IS NOT NULL
                   AND T.BATCH_NO IS NOT NULL
                   AND T.PROCESS_CODE IS NOT NULL
                  LEFT JOIN QCM_BC_BATCH_RESULT E
                    ON E.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO
                   AND E.BATCH_NO = T.BATCH_NO
                   AND E.PROCESS_CODE = T.PROCESS_CODE
                   AND E.CRAFT_SOURCE = '0'
                   AND E.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK
                   --AND T.ORD_LN_DLY_PK IS NOT NULL
                   AND T.JUDGE_STOVE_NO IS NOT NULL
                   AND T.BATCH_NO IS NOT NULL
                   AND T.PROCESS_CODE IS NOT NULL
                  LEFT JOIN COM_BASE_INFO T3
                    ON T3.BASECODE = E.CHEM_RESULT_CODE
                   AND E.CHEM_RESULT_CODE IS NOT NULL
                  LEFT JOIN COM_BASE_INFO T2
                    ON T2.BASECODE = E.PHY_RESULT_CODE
                   AND E.PHY_RESULT_CODE IS NOT NULL
                  LEFT JOIN MIL_PLAN G
                    ON G.ID = T.HEAT_PLAN_NO
                   AND T.PROCESS_CODE = 'D'
                   AND T.HEAT_PLAN_NO IS NOT NULL
                  LEFT JOIN VRP_LOADING_RESULT G2
                    ON G2.HEAT_PLAN_NO = T.HEAT_PLAN_NO
                  LEFT JOIN PLN_ZY_RCL_C G3
                    ON G3.HEAT_PLAN_NO = T.HEAT_PLAN_NO
                   AND T.PROCESS_CODE = 'F'
                   AND T.HEAT_PLAN_NO IS NOT NULL
                  LEFT JOIN PLN_ZY_JGX_C G4
                    ON G4.HEAT_PLAN_NO = T.HEAT_PLAN_NO
                   AND T.PROCESS_CODE = 'G'
                   AND T.HEAT_PLAN_NO IS NOT NULL
                  LEFT JOIN COUPLING_LOADING_RESULT G5
                    ON G5.WO_ID = T.PRO_ORDER_ID
                   AND T.PROCESS_CODE = 'H'
                  LEFT JOIN PLN_ZY_JG_WORKBILL H
                    ON H.WO_ID = T.PRO_ORDER_ID
                   AND T.PRO_ORDER_ID IS NOT NULL
                  LEFT JOIN COM_BASE_INFO H2
                    ON H2.BASECODE = H.demand_detection
                   AND H.demand_detection IS NOT NULL
                  LEFT JOIN COM_BASE_INFO H3
                    ON H3.BASECODE = H.demand_bonderizing
                   AND H.demand_bonderizing IS NOT NULL
                  LEFT JOIN COM_BASE_INFO H4
                    ON H4.BASECODE = H.demand_copper
                   AND H.demand_copper IS NOT NULL
                  LEFT JOIN COM_BASE_INFO H5
                    ON H5.BASECODE = H.demand_blast
                   AND H.demand_blast IS NOT NULL
				  LEFT JOIN  PLN_SALEORD F
                  ON F.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK
                 WHERE ({0} IS NULL OR T.LOT_NO LIKE '%' || {0} || '%')
                   AND ({1} IS NULL OR
                       T.JUDGE_STOVE_NO LIKE '%' || {1} || '%')
                   AND ({2} = '0' OR
                       ('0' IN {3} AND (T.JUDGE_RESULT_CODE IS NULL OR
                       T.JUDGE_RESULT_CODE = '40740709' OR
                       T.JUDGE_RESULT_CODE = '40740704' AND
                       D4.PASS_APPLY_NO IS NOT NULL) OR
                       '1' IN {3} AND T.JUDGE_RESULT_CODE IS NOT NULL AND
                       T.JUDGE_RESULT_CODE <> '40740709') OR
                       T.JUDGE_RESULT_CODE IN {3})
                   AND ({12} = '1' AND
                       ({4} IS NULL OR T.APPLY_TIME >=
                       TO_DATE({4}, 'YYYY-MM-DD HH24:MI:SS')) AND
                       ({5} IS NULL OR T.APPLY_TIME <=
                       TO_DATE({5}, 'YYYY-MM-DD HH24:MI:SS')) OR
                       {12} = '2' AND
                       ({4} IS NULL OR T.JUDGE_RESULT_TIME >=
                       TO_DATE({4}, 'YYYY-MM-DD HH24:MI:SS')) AND
                       ({5} IS NULL OR T.JUDGE_RESULT_TIME <=
                       TO_DATE({5}, 'YYYY-MM-DD HH24:MI:SS')))
                   AND ({6} = '0' OR T.PLINE_CODE IN {7})
                   AND T.PROCESS_CODE = {8}
                   AND T.IS_FLAG = '0'
                   AND T.IS_ALL_SCRAP IN ('0', '4', '5')
                   AND (T.STEEL_STANDRAD LIKE '%CIC%' OR
                       T.STEEL_STANDRAD LIKE '%PIC%' OR
                       T.ORD_LN_DLY_PK IS NULL)
                   AND T.APPLY_TIME >= TO_DATE('2018-07-30', 'YYYY-MM-DD')
                   AND ({9} IS NULL OR
                       {9} = '0' AND E.JUDGE_RESULT_CODE IS NULL OR
                       {9} = '1' AND E.JUDGE_RESULT_CODE IS NOT NULL)
                   AND ({10} IS NULL OR
                       F.ORDER_NO LIKE '%' || UPPER({10}) || '%')
                   AND ({11} IS NULL OR F.ORDER_SEQ = {11})
                   AND ({13} IS NULL OR T.SUPPLY_UNIT = {13})
                   AND ((T.XS_FLAG != '1' AND T.IN_MOLD != '801701') OR T.IN_MOLD IS NULL OR T.XS_FLAG = '1' OR T.SUPPLY_UNIT = '120504' OR T.TARGET != 'A')
                 GROUP BY T.JUGDE_APPLY_CODE,
                          T.JUGDE_APPLY_SEQUENO,
                          T.JUDGE_STOVE_NO,
                          T.BATCH_NO,
                          T.BATCH_GROUD_NO,T.IN_MOLD) TT
         GROUP BY TT.JUGDE_APPLY_CODE,
                  TT.LOT_NO,
                  TT.BATCH_NO,
                  TT.JUDGE_STOVE_NO,
                  TT.STOVE_NO,TT.IN_MOLD
        UNION ALL
        SELECT TT.STOVE_NO,
               TT.LOT_NO,
               MIN(TT.LOT_NO_GROUP) LOT_NO_GROUP,
               MIN(TT.JUDGE_STOVE_NO) JUDGE_STOVE_NO,
               MIN(TT.BATCH_NO) BATCH_NO,
               MIN(TT.ZP_M_LH) ZP_M_LH,
               MIN(TT.ZP_COLL) ZP_COLL,
               MIN(TT.LOAD_JUDGE_STOVE_NO) LOAD_JUDGE_STOVE_NO,
               MIN(TT.LOAD_BATCH_NO) LOAD_BATCH_NO,
               MIN(TT.GRADENAME) GRADENAME,
               MIN(TT.STEELNAME) STEELNAME,
               MIN(TT.ACT_DIMATER) ACT_DIMATER,
               MIN(TT.ACT_HEIGHT) ACT_HEIGHT,
               MIN(TT.PHY_RESULT_CODE) PHY_RESULT_CODE,
               MIN(TT.PHY_RESULT_NAME) PHY_RESULT_NAME,
               MIN(TT.CHEM_RESULT_CODE) CHEM_RESULT_CODE,
               MIN(TT.CHEM_RESULT_NAME) CHEM_RESULT_NAME,
               MIN(TT.PLINE_CODE) PLINE_CODE,
               MIN(TT.PLINE_NAME) PLINE_NAME,
               MIN(TT.APPLY_TIME) APPLY_TIME,
               MIN(TT.JUDGE_TIME) JUDGE_TIME,
               MIN(TT.JUDGE_NAME) JUDGE_NAME,
               MIN(TT.MEMO) MEMO,
               MIN(TT.JUDGE_MEMO) JUDGE_MEMO,
               MIN(TT.LK_FLAG) LK_FLAG,
               MIN(TT.STEEL_STANDRAD) STEEL_STANDRAD,
               MIN(TT.PHY_TYPE) PHY_TYPE,
               MIN(TT.OLD_GRADENAME) OLD_GRADENAME,
               MIN(TT.OLD_CIC) OLD_CIC,
               MIN(TT.PASS_APPLY_NO) PASS_APPLY_NO,
               MIN(TT.AUDIT_RESULT) AUDIT_RESULT,
               MIN(TT.URGENT_PASS_NO) URGENT_PASS_NO,
               MIN(TT.URGENT_AUDIT_RESULT) URGENT_AUDIT_RESULT,
               MIN(TT.RESULT_NAME) RESULT_NAME,
               MIN(TT.RESULT_CODE) RESULT_CODE,
               MIN(TT.SPEC_RESULT_NAME) SPEC_RESULT_NAME,
               MIN(TT.FACE_RESULT_NAME) FACE_RESULT_NAME,
               MIN(TT.DETECT_RESULT_NAME) DETECT_RESULT_NAME,
               MIN(TT.WATER_RESULT_NAME) WATER_RESULT_NAME,
               MIN(TT.PROCESS_RESULT_NAME) PROCESS_RESULT_NAME,
               MIN(TT.JUGDE_APPLY_CODE) JUGDE_APPLY_CODE,
               MIN(TT.TARGET) TARGET,
               MIN(TT.ORDER_NO) ORDER_NO,
               MIN(TT.BUYER_NAME) BUYER_NAME,
               MIN(TT.PRODUCNAME) PRODUCNAME,
               MIN(TT.STD_STYLE_DESC) STD_STYLE_DESC,
               MIN(TT.MODEL_DESC) MODEL_DESC,
               MIN(TT.SPEC_NAME) SPEC_NAME,
               MIN(TT.DELIVERY_STATE_NAME) DELIVERY_STATE_NAME,
               MIN(TT.STD_NAME) STD_NAME,
               MIN(TT.APPLY_MEMO) APPLY_MEMO,
               MIN(TT.HTT_TYPE) HTT_TYPE,
               MIN(TT.MIN_TEMP) MIN_TEMP,
               MIN(TT.HTT_TECHNOLOGY) HTT_TECHNOLOGY,
               MIN(TT.NOTCH_INFO) NOTCH_INFO,
               MIN(TT.NOTCH_LENGTH) NOTCH_LENGTH,
               MIN(TT.NOTCH_WIDTH) NOTCH_WIDTH,
               MIN(TT.NOTCH_DEPTH) NOTCH_DEPTH,
               MIN(TT.TESTING_GRADE) TESTING_GRADE,
               MIN(TT.TESTING_TYPE) TESTING_TYPE,
               MIN(TT.TESTING_GRADE1) TESTING_GRADE1,
               MIN(TT.TESTING_TYPE1) TESTING_TYPE1,
               MIN(TT.JUDGE_CONDITION) JUDGE_CONDITION,
               SUM(TT.ACT_COUNT) ACT_COUNT,
               SUM(TT.ACT_THEORY_WEIGHT) ACT_THEORY_WEIGHT,
               MIN(TT.CHECK_NO) CHECK_NO,
               MIN(TT.TEST_PRESSURE) TEST_PRESSURE,
               MIN(TT.HOLDTIME_TIME) HOLDTIME_TIME,
               MIN(TT.TEST_PRESSURE_Y) TEST_PRESSURE_Y,
               MIN(TT.PRODUCE_TIME) PRODUCE_TIME,
               MIN(TT.IF_OUT_DETECT) IF_OUT_DETECT,
               MIN(TT.IF_OUT_COAT) IF_OUT_COAT,
               MIN(TT.IF_OUT_IMPRESS) IF_OUT_IMPRESS,
               MIN(TT.IF_OUT_BLAST) IF_OUT_BLAST,
               MIN(TT.WO_ID) WO_ID,
               MIN(TT.EXIT_TEMP) EXIT_TEMP,
               MAX(TT.ZBS_LOCK_FLAG) ZBS_LOCK_FLAG,
               MIN(TT.AUTO_JUDGE) AUTO_JUDGE,
               MIN(TT.CIC) CIC,
               MIN(TT.PIC) PIC,TT.IN_MOLD
          FROM (SELECT MIN(T.STOVE_NO) STOVE_NO,
                       MIN(T.LOT_NO) LOT_NO,
                       MIN(T.LOT_NO_GROUP) LOT_NO_GROUP,
                       T.JUDGE_STOVE_NO,
                       T.BATCH_NO,
                       MIN(T.ZP_M_LH) ZP_M_LH,
                       MIN(T.ZP_COLL) ZP_COLL,
                       MIN(T.LOAD_JUDGE_STOVE_NO) LOAD_JUDGE_STOVE_NO,
                       MIN(T.LOAD_BATCH_NO) LOAD_BATCH_NO,
                       MIN(T.GRADENAME) GRADENAME,
                       MIN(T.STEELNAME) STEELNAME,
                       MIN(T.ACT_DIMATER) ACT_DIMATER,
                       MIN(T.ACT_HEIGHT) ACT_HEIGHT,
                       NULL PHY_RESULT_CODE,
                       NULL PHY_RESULT_NAME,
                       NULL CHEM_RESULT_CODE,
                       NULL CHEM_RESULT_NAME,
                       MAX(T.PLINE_CODE) PLINE_CODE,
                       MAX(T.PLINE_NAME) PLINE_NAME,
                       TO_CHAR(MAX(T.APPLY_TIME), 'YYYY-MM-DD HH24:MI:SS') APPLY_TIME,
                       TO_CHAR(MAX(T.JUDGE_RESULT_TIME),
                               'YYYY-MM-DD HH24:MI:SS') JUDGE_TIME,
                       MIN(A.CREATE_NAME) JUDGE_NAME,
                       MIN(T.JUDGE_FILE_MEMO) MEMO,
                       MIN(T.JUDGE_MEMO) JUDGE_MEMO,
                       MIN(T.LK_FLAG) LK_FLAG,
                       MIN(T.STEEL_STANDRAD) STEEL_STANDRAD,
                       CASE
                         WHEN MIN(B.SAMPLE_TYPE) = '2' THEN
                          '复验'
                         ELSE
                          '初验'
                       END CHEM_TYPE,
                       CASE
                         WHEN MIN(C.SAMPLE_TYPE) = '2' THEN
                          '复验'
                         ELSE
                          '初验'
                       END PHY_TYPE,
                       NULL OLD_GRADENAME,
                       NULL OLD_CIC,
                       MIN(D.PASS_APPLY_NO) PASS_APPLY_NO,
                       MIN(D2.BASENAME) AUDIT_RESULT,
                       MIN(D3.PASS_APPLY_NO) URGENT_PASS_NO,
                       DECODE(MIN(D3.AUDIT_RESULT),
                              '0',
                              '审核不通过',
                              '1',
                              '审核通过',
                              NULL) URGENT_AUDIT_RESULT,
                       MIN(T.JUDGE_RESULT) RESULT_NAME,
                       MIN(T.JUDGE_RESULT_CODE) RESULT_CODE,
                       MIN(T4.BASENAME) SPEC_RESULT_NAME,
                       MIN(T5.BASENAME) FACE_RESULT_NAME,
                       MIN(T6.BASENAME) DETECT_RESULT_NAME,
                       MIN(T7.BASENAME) WATER_RESULT_NAME,
                       MIN(T8.BASENAME) PROCESS_RESULT_NAME,
                       T.JUGDE_APPLY_CODE JUGDE_APPLY_CODE,
                       MIN(T.TARGET) TARGET,
                       MIN(F.ORDER_NO) || '/' || MIN(F.ORDER_SEQ) ORDER_NO,
                       MIN(F.BUYER_NAME) BUYER_NAME,
                       MIN(T.PRODUCNAME) PRODUCNAME,
                       MIN(T.STD_STYLE_DESC) STD_STYLE_DESC,
                       MIN(T.MODEL_DESC) MODEL_DESC,
                       MIN(T.SPEC_NAME) SPEC_NAME,
                       MIN(T.DELIVERY_STATE_NAME) DELIVERY_STATE_NAME,
                       MIN(T.STD_NAME) STD_NAME,
                       MIN(T.MEMO) APPLY_MEMO,
                       MIN(T.HTT_TYPE) HTT_TYPE,
                       MIN(T.MIN_TEMP) MIN_TEMP,
                       MIN(T.HTT_TECHNOLOGY) HTT_TECHNOLOGY,
                       MIN(T.NOTCH_INFO) NOTCH_INFO,
                       MIN(T.NOTCH_LENGTH) NOTCH_LENGTH,
                       MIN(T.NOTCH_WIDTH) NOTCH_WIDTH,
                       MIN(T.NOTCH_DEPTH) NOTCH_DEPTH,
                       MIN(T.TESTING_GRADE) TESTING_GRADE,
                       MIN(T.TESTING_TYPE) TESTING_TYPE,
                       MIN(T.TESTING_GRADE1) TESTING_GRADE1,
                       MIN(T.TESTING_TYPE1) TESTING_TYPE1,
                       '符合' JUDGE_CONDITION,
                       MIN(T.ACT_COUNT) ACT_COUNT,
                       MIN(T.ACT_WEIGHT) ACT_THEORY_WEIGHT,
                       MIN(T.CHECK_NO) CHECK_NO,
                       MIN(T.TEST_PRESSURE) TEST_PRESSURE,
                       MIN(T.HOLDTIME_TIME) HOLDTIME_TIME,
                       MIN(T.TEST_PRESSURE_Y) TEST_PRESSURE_Y,
                       CASE
                         WHEN MIN(T.PROCESS_CODE) = 'D' THEN
                          TO_CHAR(MIN(G.FEED_TIME), 'YYYY-MM-DD HH24:MI:SS')
                         WHEN MIN(T.PROCESS_CODE) = 'E' THEN
                          TO_CHAR(MIN(G2.LOAD_TIME), 'YYYY-MM-DD HH24:MI:SS')
                         WHEN MIN(T.PROCESS_CODE) = 'F' THEN
                          TO_CHAR(MIN(G3.LOADTIME), 'YYYY-MM-DD HH24:MI:SS')
                         WHEN MIN(T.PROCESS_CODE) = 'G' THEN
                          TO_CHAR(MIN(G4.LOADTIME), 'YYYY-MM-DD HH24:MI:SS')
                         WHEN MIN(T.PROCESS_CODE) = 'H' THEN
                          TO_CHAR(MIN(G5.LOAD_TIME), 'YYYY-MM-DD HH24:MI:SS')
                         ELSE
                          NULL
                       END PRODUCE_TIME,
                       MIN(H2.BASENAME) IF_OUT_DETECT,
                       MIN(H3.BASENAME) IF_OUT_COAT,
                       MIN(H4.BASENAME) IF_OUT_IMPRESS,
                       MIN(H5.BASENAME) IF_OUT_BLAST,
                       MIN(H.WO_ID) WO_ID,
                       MIN(T.EXIT_TEMP) EXIT_TEMP,
                       MAX(T.ZBS_LOCK_FLAG) ZBS_LOCK_FLAG,
                       MIN(T.AUTO_JUDGE) AUTO_JUDGE,
                       MIN(T.CIC) CIC,
                       MIN(T.PIC) PIC,
                       (SELECT BASENAME FROM COM_BASE_INFO WHERE BASECODE = T.IN_MOLD) IN_MOLD
                  FROM QCM_ZG_JUGDE_APPLY T
                  LEFT JOIN COM_BASE_INFO T4
                    ON T4.BASECODE = T.SPEC_RESULT_CODE
                   AND T.SPEC_RESULT_CODE IS NOT NULL
                  LEFT JOIN COM_BASE_INFO T5
                    ON T5.BASECODE = T.FACE_RESULT_CODE
                   AND T.FACE_RESULT_CODE IS NOT NULL
                  LEFT JOIN COM_BASE_INFO T6
                    ON T6.BASECODE = T.DETECT_RESULT_CODE
                   AND T.DETECT_RESULT_CODE IS NOT NULL
                  LEFT JOIN COM_BASE_INFO T7
                    ON T7.BASECODE = T.WPRESSURE_RESULT_CODE
                   AND T.WPRESSURE_RESULT_CODE IS NOT NULL
                  LEFT JOIN COM_BASE_INFO T8
                    ON T8.BASECODE = T.PROCESS_RESULT_CODE
                   AND T.PROCESS_RESULT_CODE IS NOT NULL
                  LEFT JOIN QCM_BC_JUDGE A
                    ON A.JUDGE_ID = T.JUGDE_CONVICTED
                  LEFT JOIN QCM_BC_CHEMJUDGE B
                    ON B.CHEM_JUDGE_ID = A.CHEM_JUDGE_ID
                   AND B.JUDGE_SEQ = 1
                  LEFT JOIN QCM_BC_PHYJUDGE C
                    ON C.PHY_JUDGE_ID = A.PHY_RESULT_ID
                   AND C.JUDGE_SEQ = 1
                  LEFT JOIN QCM_BC_PASS_APPLY D
                    ON T.JUGDE_APPLY_CODE IS NOT NULL
                   AND T.JUDGE_STOVE_NO IS NOT NULL
                   AND T.BATCH_NO IS NOT NULL
                   AND D.JUGDE_APPLY_CODE = T.JUGDE_APPLY_CODE
                   AND D.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO
                   AND D.BATCH_NO = T.BATCH_NO
                   AND D.PROCESS_CODE = T.PROCESS_CODE
                   AND D.VALIDFLAG = '1'
                   AND D.PASS_APPLY_SEQ = '001'
                   AND D.TYPE = '0'
                  LEFT JOIN COM_BASE_INFO D2
                    ON D2.BASECODE = D.AUDIT_RESULT
                   AND D.AUDIT_RESULT IS NOT NULL
                  LEFT JOIN QCM_BC_PASS_APPLY D3
                    ON T.JUGDE_APPLY_CODE IS NOT NULL
                   AND T.JUDGE_STOVE_NO IS NOT NULL
                   AND T.BATCH_NO IS NOT NULL
                   AND D3.JUGDE_APPLY_CODE = T.JUGDE_APPLY_CODE
                   AND D3.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO
                   AND D3.BATCH_NO = T.BATCH_NO
                   AND D3.PROCESS_CODE = T.PROCESS_CODE
                   AND D3.VALIDFLAG = '1'
                   AND D3.PASS_APPLY_SEQ = '001'
                   AND D3.TYPE = '1'
                  LEFT JOIN QCM_BC_PASS_APPLY D4
                    ON D4.JUGDE_APPLY_CODE = T.JUGDE_APPLY_CODE
                   AND D4.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO
                   AND D4.BATCH_NO = T.BATCH_NO
                   AND D4.PROCESS_CODE = T.PROCESS_CODE
                   AND D4.TYPE = '0'
                   AND D4.AUDIT_RESULT IN ('407502', '407503')
                   AND D4.VALIDFLAG = '1'
                   AND T.JUGDE_APPLY_CODE IS NOT NULL
                   AND T.JUDGE_STOVE_NO IS NOT NULL
                   AND T.BATCH_NO IS NOT NULL
                   AND T.PROCESS_CODE IS NOT NULL
                  LEFT JOIN MIL_PLAN G
                    ON G.ID = T.HEAT_PLAN_NO
                   AND T.PROCESS_CODE = 'D'
                   AND T.HEAT_PLAN_NO IS NOT NULL
                  LEFT JOIN VRP_LOADING_RESULT G2
                    ON G2.HEAT_PLAN_NO = T.HEAT_PLAN_NO
                  LEFT JOIN PLN_ZY_RCL_C G3
                    ON G3.HEAT_PLAN_NO = T.HEAT_PLAN_NO
                   AND T.PROCESS_CODE = 'F'
                   AND T.HEAT_PLAN_NO IS NOT NULL
                  LEFT JOIN PLN_ZY_JGX_C G4
                    ON G4.HEAT_PLAN_NO = T.HEAT_PLAN_NO
                   AND T.PROCESS_CODE = 'G'
                   AND T.HEAT_PLAN_NO IS NOT NULL
                  LEFT JOIN COUPLING_LOADING_RESULT G5
                    ON G5.WO_ID = T.PRO_ORDER_ID
                   AND T.PROCESS_CODE = 'H'
                  LEFT JOIN PLN_ZY_JG_WORKBILL H
                    ON H.WO_ID = T.PRO_ORDER_ID
                   AND T.PRO_ORDER_ID IS NOT NULL
                  LEFT JOIN COM_BASE_INFO H2
                    ON H2.BASECODE = H.demand_detection
                   AND H.demand_detection IS NOT NULL
                  LEFT JOIN COM_BASE_INFO H3
                    ON H3.BASECODE = H.demand_bonderizing
                   AND H.demand_bonderizing IS NOT NULL
                  LEFT JOIN COM_BASE_INFO H4
                    ON H4.BASECODE = H.demand_copper
                   AND H.demand_copper IS NOT NULL
                  LEFT JOIN COM_BASE_INFO H5
                    ON H5.BASECODE = H.demand_blast
                   AND H.demand_blast IS NOT NULL
                  LEFT JOIN  PLN_SALEORD F
                  ON F.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK
                 WHERE ({0} IS NULL OR T.BATCH_NO LIKE '%' || {0} || '%')
                   AND ({1} IS NULL OR
                       T.JUDGE_STOVE_NO LIKE '%' || {1} || '%')
                   AND ({2} = '0' OR
                       ('0' IN {3} AND (T.JUDGE_RESULT_CODE IS NULL OR
                       T.JUDGE_RESULT_CODE = '40740709' OR
                       T.JUDGE_RESULT_CODE = '40740704' AND
                       D4.PASS_APPLY_NO IS NOT NULL) OR
                       '1' IN {3} AND T.JUDGE_RESULT_CODE IS NOT NULL AND
                       T.JUDGE_RESULT_CODE <> '40740709') OR
                       T.JUDGE_RESULT_CODE IN {3})
                   AND ({12} = '1' AND
                       ({4} IS NULL OR T.APPLY_TIME >=
                       TO_DATE({4}, 'YYYY-MM-DD HH24:MI:SS')) AND
                       ({5} IS NULL OR T.APPLY_TIME <=
                       TO_DATE({5}, 'YYYY-MM-DD HH24:MI:SS')) OR
                       {12} = '2' AND
                       ({4} IS NULL OR T.JUDGE_RESULT_TIME >=
                       TO_DATE({4}, 'YYYY-MM-DD HH24:MI:SS')) AND
                       ({5} IS NULL OR T.JUDGE_RESULT_TIME <=
                       TO_DATE({5}, 'YYYY-MM-DD HH24:MI:SS')))
                   AND ({6} = '0' OR T.PLINE_CODE IN {7})
                   AND T.PROCESS_CODE = {8}
                   AND T.IS_FLAG = '0'
                   AND T.IS_ALL_SCRAP IN ('0', '4', '5')
                   AND T.ORD_LN_DLY_PK IS NOT NULL
                   AND (T.STEEL_STANDRAD NOT LIKE '%CIC%' AND
                       T.STEEL_STANDRAD NOT LIKE '%PIC%' OR
                       T.STEEL_STANDRAD IS NULL OR
                       T.PRODUCCODE IN ('S000103', 'S000125'))
                   AND T.APPLY_TIME >= TO_DATE('2018-07-30', 'YYYY-MM-DD')
                   AND ({9} IS NULL OR {9} = '1')
                   AND ({10} IS NULL OR
                       F.ORDER_NO LIKE '%' || UPPER({10}) || '%')
                   AND ({11} IS NULL OR F.ORDER_SEQ = {11})
                   AND ({13} IS NULL OR T.SUPPLY_UNIT = {13})
                   AND ((T.XS_FLAG != '1' AND T.IN_MOLD != '801701') OR T.IN_MOLD IS NULL OR T.XS_FLAG = '1' OR T.SUPPLY_UNIT = '120504' OR T.TARGET != 'A')
                 GROUP BY T.JUGDE_APPLY_CODE,
                          T.JUGDE_APPLY_SEQUENO,
                          T.JUDGE_STOVE_NO,
                          T.BATCH_NO,
                          T.BATCH_GROUD_NO,T.IN_MOLD) TT
         GROUP BY TT.JUGDE_APPLY_CODE,
                  TT.LOT_NO,
                  TT.BATCH_NO,
                  TT.JUDGE_STOVE_NO,
                  TT.STOVE_NO,TT.IN_MOLD) TT
 ORDER BY TT.JUDGE_STOVE_NO, TT.BATCH_NO, TT.JUGDE_APPLY_CODE
        ]]>
    </query>
    
    <query id="QcmZgJugdeApplyDAL.QueryBcQuality" desc="半成品质量放行查询">
        <![CDATA[
SELECT TT.STOVE_NO,
       TT.LOT_NO,
       MIN(TT.LOT_NO_GROUP) LOT_NO_GROUP,
       MIN(TT.JUDGE_STOVE_NO) JUDGE_STOVE_NO,
       MIN(TT.BATCH_NO) BATCH_NO,
       MIN(TT.ZP_M_LH) ZP_M_LH,
       MIN(TT.ZP_COLL) ZP_COLL,
       MIN(TT.LOAD_JUDGE_STOVE_NO) LOAD_JUDGE_STOVE_NO,
       MIN(TT.LOAD_BATCH_NO) LOAD_BATCH_NO,
       MIN(TT.GRADENAME) GRADENAME,
       MIN(TT.STEELNAME) STEELNAME,
       MIN(TT.ACT_DIMATER) ACT_DIMATER,
       MIN(TT.ACT_HEIGHT) ACT_HEIGHT,
       MIN(TT.PHY_RESULT_CODE) PHY_RESULT_CODE,
       MIN(TT.PHY_RESULT_NAME) PHY_RESULT_NAME,
       MIN(TT.CHEM_RESULT_CODE) CHEM_RESULT_CODE,
       MIN(TT.CHEM_RESULT_NAME) CHEM_RESULT_NAME,
       MIN(TT.PLINE_CODE) PLINE_CODE,
       MIN(TT.PLINE_NAME) PLINE_NAME,
       MIN(TT.APPLY_TIME) APPLY_TIME,
       MIN(TT.JUDGE_TIME) JUDGE_TIME,
       MIN(TT.JUDGE_NAME) JUDGE_NAME,
       MIN(TT.MEMO) MEMO,
       MIN(TT.JUDGE_MEMO) JUDGE_MEMO,
       MIN(TT.LK_FLAG) LK_FLAG,
       MIN(TT.STEEL_STANDRAD) STEEL_STANDRAD,
       MIN(TT.PHY_TYPE) PHY_TYPE,
       MIN(TT.OLD_GRADENAME) OLD_GRADENAME,
       MIN(TT.OLD_CIC) OLD_CIC,
       MIN(TT.PASS_APPLY_NO) PASS_APPLY_NO,
       MIN(TT.AUDIT_RESULT) AUDIT_RESULT,
       MIN(TT.URGENT_PASS_NO) URGENT_PASS_NO,
       MIN(TT.URGENT_AUDIT_RESULT) URGENT_AUDIT_RESULT,
       MIN(TT.RESULT_NAME) RESULT_NAME,
       MIN(TT.RESULT_CODE) RESULT_CODE,
       MIN(TT.SPEC_RESULT_NAME) SPEC_RESULT_NAME,
       MIN(TT.FACE_RESULT_NAME) FACE_RESULT_NAME,
       MIN(TT.DETECT_RESULT_NAME) DETECT_RESULT_NAME,
       MIN(TT.WATER_RESULT_NAME) WATER_RESULT_NAME,
       MIN(TT.PROCESS_RESULT_NAME) PROCESS_RESULT_NAME,
       MIN(TT.JUGDE_APPLY_CODE) JUGDE_APPLY_CODE,
       MIN(TT.TARGET) TARGET,
       MIN(TT.ORDER_NO) ORDER_NO,
       MIN(TT.BUYER_NAME) BUYER_NAME,
       MIN(TT.PRODUCNAME) PRODUCNAME,
       MIN(TT.STD_STYLE_DESC) STD_STYLE_DESC,
       MIN(TT.MODEL_DESC) MODEL_DESC,
       MIN(TT.SPEC_NAME) SPEC_NAME,
       MIN(TT.DELIVERY_STATE_NAME) DELIVERY_STATE_NAME,
       MIN(TT.STD_NAME) STD_NAME,
       MIN(TT.APPLY_MEMO) APPLY_MEMO,
       MIN(TT.HTT_TYPE) HTT_TYPE,
       MIN(TT.MIN_TEMP) MIN_TEMP,
       MIN(TT.HTT_TECHNOLOGY) HTT_TECHNOLOGY,
       MIN(TT.NOTCH_INFO) NOTCH_INFO,
       MIN(TT.NOTCH_LENGTH) NOTCH_LENGTH,
       MIN(TT.NOTCH_WIDTH) NOTCH_WIDTH,
       MIN(TT.NOTCH_DEPTH) NOTCH_DEPTH,
       MIN(TT.TESTING_GRADE) TESTING_GRADE,
       MIN(TT.TESTING_TYPE) TESTING_TYPE,
       MIN(TT.TESTING_GRADE1) TESTING_GRADE1,
       MIN(TT.TESTING_TYPE1) TESTING_TYPE1,
       MIN(TT.JUDGE_CONDITION) JUDGE_CONDITION,
       SUM(TT.ACT_COUNT) ACT_COUNT,
       SUM(TT.ACT_THEORY_WEIGHT) ACT_THEORY_WEIGHT,
       MIN(TT.CHECK_NO) CHECK_NO,
       MIN(TT.TEST_PRESSURE) TEST_PRESSURE,
       MIN(TT.HOLDTIME_TIME) HOLDTIME_TIME,
       MIN(TT.TEST_PRESSURE_Y) TEST_PRESSURE_Y,
       MIN(TT.PRODUCE_TIME) PRODUCE_TIME,
       MIN(TT.IF_OUT_DETECT) IF_OUT_DETECT,
       MIN(TT.IF_OUT_COAT) IF_OUT_COAT,
       MIN(TT.IF_OUT_IMPRESS) IF_OUT_IMPRESS,
       MIN(TT.IF_OUT_BLAST) IF_OUT_BLAST,
       MIN(TT.WO_ID) WO_ID,
       MAX(TT.ZBS_LOCK_FLAG) ZBS_LOCK_FLAG,
       MIN(TT.EXIT_TEMP) EXIT_TEMP
  FROM (SELECT MIN(T.STOVE_NO) STOVE_NO,
               MIN(T.LOT_NO) LOT_NO,
               MIN(T.LOT_NO_GROUP) LOT_NO_GROUP,
               T.JUDGE_STOVE_NO,
               T.BATCH_NO,
               MIN(T.ZP_M_LH) ZP_M_LH,
               MIN(T.ZP_COLL) ZP_COLL,
               MIN(T.LOAD_JUDGE_STOVE_NO) LOAD_JUDGE_STOVE_NO,
               MIN(T.LOAD_BATCH_NO) LOAD_BATCH_NO,
               MIN(T.GRADENAME) GRADENAME,
               MIN(T.STEELNAME) STEELNAME,
               MIN(T.ACT_DIMATER) ACT_DIMATER,
               MIN(T.ACT_HEIGHT) ACT_HEIGHT,
               MAX(E.PHY_RESULT_CODE) PHY_RESULT_CODE,
               MIN(T2.BASENAME) PHY_RESULT_NAME,
               MIN(E.CHEM_RESULT_CODE) CHEM_RESULT_CODE,
               MIN(T3.BASENAME) CHEM_RESULT_NAME,
               MAX(T.PLINE_CODE) PLINE_CODE,
               MAX(T.PLINE_NAME) PLINE_NAME,
               TO_CHAR(MAX(T.APPLY_TIME), 'YYYY-MM-DD HH24:MI:SS') APPLY_TIME,
               TO_CHAR(MAX(T.JUDGE_RESULT_TIME), 'YYYY-MM-DD HH24:MI:SS') JUDGE_TIME,
               MIN(A.CREATE_NAME) JUDGE_NAME,
               MIN(T.JUDGE_FILE_MEMO) MEMO,
               MIN(T.JUDGE_MEMO) JUDGE_MEMO,
               MIN(T.LK_FLAG) LK_FLAG,
               MIN(T.STEEL_STANDRAD) STEEL_STANDRAD,
               CASE
                 WHEN MIN(B.SAMPLE_TYPE) = '2' THEN
                  '复验'
                 ELSE
                  '初验'
               END CHEM_TYPE,
               CASE
                 WHEN MIN(C.SAMPLE_TYPE) = '2' THEN
                  '复验'
                 ELSE
                  '初验'
               END PHY_TYPE,
               NULL OLD_GRADENAME,
               NULL OLD_CIC,
               MIN(D.PASS_APPLY_NO) PASS_APPLY_NO,
               MIN(D2.BASENAME) AUDIT_RESULT,
               MIN(D3.PASS_APPLY_NO) URGENT_PASS_NO,
               DECODE(MIN(D3.AUDIT_RESULT),
                      '0',
                      '审核不通过',
                      '1',
                      '审核通过',
                      NULL) URGENT_AUDIT_RESULT,
               MIN(T.JUDGE_RESULT) RESULT_NAME,
               MIN(T.JUDGE_RESULT_CODE) RESULT_CODE,
               MIN(T4.BASENAME) SPEC_RESULT_NAME,
               MIN(T5.BASENAME) FACE_RESULT_NAME,
               MIN(T6.BASENAME) DETECT_RESULT_NAME,
               MIN(T7.BASENAME) WATER_RESULT_NAME,
               MIN(T8.BASENAME) PROCESS_RESULT_NAME,
               T.JUGDE_APPLY_CODE JUGDE_APPLY_CODE,
               MIN(T.TARGET) TARGET,
               MIN(F.ORDER_NO) || '/' || MIN(F.ORDER_SEQ) ORDER_NO,
               MIN(F.BUYER_NAME) BUYER_NAME,
               MIN(T.PRODUCNAME) PRODUCNAME,
               MIN(T.STD_STYLE_DESC) STD_STYLE_DESC,
               MIN(T.MODEL_DESC) MODEL_DESC,
               MIN(T.SPEC_NAME) SPEC_NAME,
               MIN(T.DELIVERY_STATE_NAME) DELIVERY_STATE_NAME,
               MIN(T.STD_NAME) STD_NAME,
               MIN(T.MEMO) APPLY_MEMO,
               MIN(T.HTT_TYPE) HTT_TYPE,
               MIN(T.MIN_TEMP) MIN_TEMP,
               MIN(T.HTT_TECHNOLOGY) HTT_TECHNOLOGY,
               MIN(T.NOTCH_INFO) NOTCH_INFO,
               MIN(T.NOTCH_LENGTH) NOTCH_LENGTH,
               MIN(T.NOTCH_WIDTH) NOTCH_WIDTH,
               MIN(T.NOTCH_DEPTH) NOTCH_DEPTH,
               MIN(T.TESTING_GRADE) TESTING_GRADE,
               MIN(T.TESTING_TYPE) TESTING_TYPE,
               MIN(T.TESTING_GRADE1) TESTING_GRADE1,
               MIN(T.TESTING_TYPE1) TESTING_TYPE1,
               DECODE(MIN(E.JUDGE_RESULT_CODE), NULL, '不符合','40740704','不符合', '符合') JUDGE_CONDITION,
               MIN(T.ACT_COUNT) ACT_COUNT,
               MIN(T.ACT_WEIGHT) ACT_THEORY_WEIGHT,
               MIN(T.CHECK_NO) CHECK_NO,
               MIN(T.TEST_PRESSURE) TEST_PRESSURE,
               MIN(T.HOLDTIME_TIME) HOLDTIME_TIME,
               MIN(T.TEST_PRESSURE_Y) TEST_PRESSURE_Y,
               CASE
                 WHEN MIN(T.PROCESS_CODE) = 'D' THEN
                  TO_CHAR(MIN(G.FEED_TIME), 'YYYY-MM-DD HH24:MI:SS')
                 WHEN MIN(T.PROCESS_CODE) = 'E' THEN
                  TO_CHAR(MIN(G2.LOAD_TIME), 'YYYY-MM-DD HH24:MI:SS')
                 WHEN MIN(T.PROCESS_CODE) = 'F' THEN
                  TO_CHAR(MIN(G3.LOADTIME), 'YYYY-MM-DD HH24:MI:SS')
                 WHEN MIN(T.PROCESS_CODE) = 'G' THEN
                  TO_CHAR(MIN(G4.LOADTIME), 'YYYY-MM-DD HH24:MI:SS')
                 WHEN MIN(T.PROCESS_CODE) = 'H' THEN
                  TO_CHAR(MIN(G5.LOAD_TIME), 'YYYY-MM-DD HH24:MI:SS')
                 ELSE
                  NULL
               END PRODUCE_TIME,
               MIN(H2.BASENAME) IF_OUT_DETECT,
               MIN(H3.BASENAME) IF_OUT_COAT,
               MIN(H4.BASENAME) IF_OUT_IMPRESS,
               MIN(H5.BASENAME) IF_OUT_BLAST,
               MIN(H.WO_ID) WO_ID,
               MAX(T.ZBS_LOCK_FLAG) ZBS_LOCK_FLAG,
               MIN(T.EXIT_TEMP) EXIT_TEMP
          FROM QCM_ZG_JUGDE_APPLY T
          LEFT JOIN COM_BASE_INFO T4
            ON T4.BASECODE = T.SPEC_RESULT_CODE
           AND T.SPEC_RESULT_CODE IS NOT NULL
          LEFT JOIN COM_BASE_INFO T5
            ON T5.BASECODE = T.FACE_RESULT_CODE
           AND T.FACE_RESULT_CODE IS NOT NULL
          LEFT JOIN COM_BASE_INFO T6
            ON T6.BASECODE = T.DETECT_RESULT_CODE
           AND T.DETECT_RESULT_CODE IS NOT NULL
          LEFT JOIN COM_BASE_INFO T7
            ON T7.BASECODE = T.WPRESSURE_RESULT_CODE
           AND T.WPRESSURE_RESULT_CODE IS NOT NULL
          LEFT JOIN COM_BASE_INFO T8
            ON T8.BASECODE = T.PROCESS_RESULT_CODE
           AND T.PROCESS_RESULT_CODE IS NOT NULL
          LEFT JOIN QCM_BC_JUDGE A
            ON A.JUDGE_ID = T.JUGDE_CONVICTED
           AND T.JUGDE_CONVICTED IS NOT NULL
          LEFT JOIN QCM_BC_CHEMJUDGE B
            ON B.CHEM_JUDGE_ID = A.CHEM_JUDGE_ID
           AND B.JUDGE_SEQ = 1
           AND A.CHEM_JUDGE_ID IS NOT NULL
          LEFT JOIN QCM_BC_PHYJUDGE C
            ON C.PHY_JUDGE_ID = A.PHY_RESULT_ID
           AND C.JUDGE_SEQ = 1
           AND A.PHY_RESULT_ID IS NOT NULL
          LEFT JOIN QCM_BC_PASS_APPLY D
            ON D.JUGDE_APPLY_CODE = T.JUGDE_APPLY_CODE
           AND D.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO
           AND D.BATCH_NO = T.BATCH_NO
           AND D.PROCESS_CODE = T.PROCESS_CODE
           AND D.VALIDFLAG = '1'
           AND D.PASS_APPLY_SEQ = '001'
           AND D.TYPE = '0'
           AND T.JUGDE_APPLY_CODE IS NOT NULL
           AND T.JUDGE_STOVE_NO IS NOT NULL
           AND T.BATCH_NO IS NOT NULL
          LEFT JOIN COM_BASE_INFO D2
            ON D2.BASECODE = D.AUDIT_RESULT
           AND D.AUDIT_RESULT IS NOT NULL
          LEFT JOIN QCM_BC_PASS_APPLY D3
            ON D3.JUGDE_APPLY_CODE = T.JUGDE_APPLY_CODE
           AND D3.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO
           AND D3.BATCH_NO = T.BATCH_NO
           AND D3.PROCESS_CODE = T.PROCESS_CODE
           AND D3.VALIDFLAG = '1'
           AND D3.PASS_APPLY_SEQ = '001'
           AND D3.TYPE = '1'
           AND T.JUGDE_APPLY_CODE IS NOT NULL
           AND T.JUDGE_STOVE_NO IS NOT NULL
           AND T.BATCH_NO IS NOT NULL
          LEFT JOIN QCM_BC_PASS_APPLY D4
            ON D4.JUGDE_APPLY_CODE = T.JUGDE_APPLY_CODE
           AND D4.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO
           AND D4.BATCH_NO = T.BATCH_NO
           AND D4.PROCESS_CODE = T.PROCESS_CODE
           AND D4.TYPE = '0'
           AND D4.AUDIT_RESULT IN ('407502', '407503')
           AND D4.VALIDFLAG = '1'
           AND T.JUGDE_APPLY_CODE IS NOT NULL
           AND T.JUDGE_STOVE_NO IS NOT NULL
           AND T.BATCH_NO IS NOT NULL
           AND T.PROCESS_CODE IS NOT NULL
          LEFT JOIN QCM_BC_BATCH_RESULT E
            ON E.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO
           AND E.BATCH_NO = T.BATCH_NO
           AND E.PROCESS_CODE = T.PROCESS_CODE
           AND E.CRAFT_SOURCE = '0'
           AND E.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK
           AND T.ORD_LN_DLY_PK IS NOT NULL
           AND T.JUDGE_STOVE_NO IS NOT NULL
           AND T.BATCH_NO IS NOT NULL
           AND T.PROCESS_CODE IS NOT NULL
          LEFT JOIN COM_BASE_INFO T3
            ON T3.BASECODE = E.CHEM_RESULT_CODE
           AND E.CHEM_RESULT_CODE IS NOT NULL
          LEFT JOIN COM_BASE_INFO T2
            ON T2.BASECODE = E.PHY_RESULT_CODE
           AND E.PHY_RESULT_CODE IS NOT NULL
          LEFT JOIN MIL_PLAN G
            ON G.ID = T.HEAT_PLAN_NO
           AND T.PROCESS_CODE = 'D'
           AND T.HEAT_PLAN_NO IS NOT NULL
          LEFT JOIN VRP_LOADING_RESULT G2
            ON G2.HEAT_PLAN_NO = T.HEAT_PLAN_NO
          LEFT JOIN PLN_ZY_RCL_C G3
            ON G3.HEAT_PLAN_NO = T.HEAT_PLAN_NO
           AND T.PROCESS_CODE = 'F'
           AND T.HEAT_PLAN_NO IS NOT NULL
          LEFT JOIN PLN_ZY_JGX_C G4
            ON G4.HEAT_PLAN_NO = T.HEAT_PLAN_NO
           AND T.PROCESS_CODE = 'G'
           AND T.HEAT_PLAN_NO IS NOT NULL
          LEFT JOIN COUPLING_LOADING_RESULT G5
            ON G5.WO_ID = T.PRO_ORDER_ID
           AND T.PROCESS_CODE = 'H'
          LEFT JOIN PLN_ZY_JG_WORKBILL H
            ON H.WO_ID = T.PRO_ORDER_ID
           AND T.PRO_ORDER_ID IS NOT NULL
          LEFT JOIN COM_BASE_INFO H2
            ON H2.BASECODE = H.demand_detection
           AND H.demand_detection IS NOT NULL
          LEFT JOIN COM_BASE_INFO H3
            ON H3.BASECODE = H.demand_bonderizing
           AND H.demand_bonderizing IS NOT NULL
          LEFT JOIN COM_BASE_INFO H4
            ON H4.BASECODE = H.demand_copper
           AND H.demand_copper IS NOT NULL
          LEFT JOIN COM_BASE_INFO H5
            ON H5.BASECODE = H.demand_blast
           AND H.demand_blast IS NOT NULL, PLN_SALEORD F
         WHERE ({0} IS NULL OR T.LOT_NO LIKE '%' || {0} || '%')
           AND ({1} IS NULL OR T.JUDGE_STOVE_NO LIKE '%' || {1} || '%')
           AND ({2} = '0' OR
               ('0' IN {3} AND (T.JUDGE_RESULT_CODE IS NULL OR
               T.JUDGE_RESULT_CODE = '40740709' OR
               T.JUDGE_RESULT_CODE = '40740704' AND
               D4.PASS_APPLY_NO IS NOT NULL) OR
               '1' IN {3} AND T.JUDGE_RESULT_CODE IS NOT NULL AND
               T.JUDGE_RESULT_CODE <> '40740709') OR
               T.JUDGE_RESULT_CODE IN {3})
           AND ({12} = '1' AND
               ({4} IS NULL OR
               T.APPLY_TIME >= TO_DATE({4}, 'YYYY-MM-DD HH24:MI:SS')) AND
               ({5} IS NULL OR
               T.APPLY_TIME <= TO_DATE({5}, 'YYYY-MM-DD HH24:MI:SS')) OR
               {12} = '2' AND
               ({4} IS NULL OR T.JUDGE_RESULT_TIME >=
               TO_DATE({4}, 'YYYY-MM-DD HH24:MI:SS')) AND
               ({5} IS NULL OR T.JUDGE_RESULT_TIME <=
               TO_DATE({5}, 'YYYY-MM-DD HH24:MI:SS')))
           AND ({6} = '0' OR T.PLINE_CODE IN {7})
           AND T.PROCESS_CODE = {8}
           AND T.IS_FLAG = '0'
           AND T.IS_ALL_SCRAP IN ('0', '4', '5')
           AND F.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK
           AND T.APPLY_TIME >= TO_DATE('2018-07-30', 'YYYY-MM-DD')
           AND ({9} IS NULL OR {9} = '0' AND E.JUDGE_RESULT_CODE IS NULL OR
               {9} = '1' AND E.JUDGE_RESULT_CODE IS NOT NULL)
           AND ({10} IS NULL OR F.ORDER_NO LIKE '%' || UPPER({10}) || '%')
           AND ({11} IS NULL OR F.ORDER_SEQ = {11})
         GROUP BY T.JUGDE_APPLY_CODE,
                  T.JUGDE_APPLY_SEQUENO,
                  T.JUDGE_STOVE_NO,
                  T.BATCH_NO,
                  T.BATCH_GROUD_NO) TT
 GROUP BY TT.JUGDE_APPLY_CODE,
          TT.LOT_NO,
          TT.BATCH_NO,
          TT.JUDGE_STOVE_NO,
          TT.STOVE_NO
 ORDER BY TT.JUDGE_STOVE_NO, TT.BATCH_NO, TT.JUGDE_APPLY_CODE
        ]]>
    </query>
    
    <query id="QcmZgJugdeApplyDAL.QueryBcUrgent" desc="半成品紧急放行查询">
        <![CDATA[
SELECT TT.STOVE_NO,
       TT.LOT_NO,
       MIN(TT.LOT_NO_GROUP) LOT_NO_GROUP,
       MIN(TT.JUDGE_STOVE_NO) JUDGE_STOVE_NO,
       MIN(TT.BATCH_NO) BATCH_NO,
       MIN(TT.ZP_M_LH) ZP_M_LH,
       MIN(TT.ZP_COLL) ZP_COLL,
       MIN(TT.LOAD_JUDGE_STOVE_NO) LOAD_JUDGE_STOVE_NO,
       MIN(TT.LOAD_BATCH_NO) LOAD_BATCH_NO,
       MIN(TT.GRADENAME) GRADENAME,
       MIN(TT.STEELNAME) STEELNAME,
       MIN(TT.ACT_DIMATER) ACT_DIMATER,
       MIN(TT.ACT_HEIGHT) ACT_HEIGHT,
       MIN(TT.PHY_RESULT_CODE) PHY_RESULT_CODE,
       MIN(TT.PHY_RESULT_NAME) PHY_RESULT_NAME,
       MIN(TT.CHEM_RESULT_CODE) CHEM_RESULT_CODE,
       MIN(TT.CHEM_RESULT_NAME) CHEM_RESULT_NAME,
       MIN(TT.PLINE_CODE) PLINE_CODE,
       MIN(TT.PLINE_NAME) PLINE_NAME,
       MIN(TT.APPLY_TIME) APPLY_TIME,
       MIN(TT.JUDGE_TIME) JUDGE_TIME,
       MIN(TT.JUDGE_NAME) JUDGE_NAME,
       MIN(TT.MEMO) MEMO,
       MIN(TT.JUDGE_MEMO) JUDGE_MEMO,
       MIN(TT.LK_FLAG) LK_FLAG,
       MIN(TT.STEEL_STANDRAD) STEEL_STANDRAD,
       MIN(TT.PHY_TYPE) PHY_TYPE,
       MIN(TT.OLD_GRADENAME) OLD_GRADENAME,
       MIN(TT.OLD_CIC) OLD_CIC,
       MIN(TT.PASS_APPLY_NO) PASS_APPLY_NO,
       MIN(TT.AUDIT_RESULT) AUDIT_RESULT,
       MIN(TT.URGENT_PASS_NO) URGENT_PASS_NO,
       MIN(TT.URGENT_AUDIT_RESULT) URGENT_AUDIT_RESULT,
       MIN(TT.RESULT_NAME) RESULT_NAME,
       MIN(TT.RESULT_CODE) RESULT_CODE,
       MIN(TT.SPEC_RESULT_NAME) SPEC_RESULT_NAME,
       MIN(TT.FACE_RESULT_NAME) FACE_RESULT_NAME,
       MIN(TT.DETECT_RESULT_NAME) DETECT_RESULT_NAME,
       MIN(TT.WATER_RESULT_NAME) WATER_RESULT_NAME,
       MIN(TT.PROCESS_RESULT_NAME) PROCESS_RESULT_NAME,
       MIN(TT.JUGDE_APPLY_CODE) JUGDE_APPLY_CODE,
       MIN(TT.TARGET) TARGET,
       MIN(TT.ORDER_NO) ORDER_NO,
       MIN(TT.BUYER_NAME) BUYER_NAME,
       MIN(TT.PRODUCNAME) PRODUCNAME,
       MIN(TT.STD_STYLE_DESC) STD_STYLE_DESC,
       MIN(TT.MODEL_DESC) MODEL_DESC,
       MIN(TT.SPEC_NAME) SPEC_NAME,
       MIN(TT.DELIVERY_STATE_NAME) DELIVERY_STATE_NAME,
       MIN(TT.STD_NAME) STD_NAME,
       MIN(TT.APPLY_MEMO) APPLY_MEMO,
       MIN(TT.HTT_TYPE) HTT_TYPE,
       MIN(TT.MIN_TEMP) MIN_TEMP,
       MIN(TT.HTT_TECHNOLOGY) HTT_TECHNOLOGY,
       MIN(TT.NOTCH_INFO) NOTCH_INFO,
       MIN(TT.NOTCH_LENGTH) NOTCH_LENGTH,
       MIN(TT.NOTCH_WIDTH) NOTCH_WIDTH,
       MIN(TT.NOTCH_DEPTH) NOTCH_DEPTH,
       MIN(TT.TESTING_GRADE) TESTING_GRADE,
       MIN(TT.TESTING_TYPE) TESTING_TYPE,
       MIN(TT.TESTING_GRADE1) TESTING_GRADE1,
       MIN(TT.TESTING_TYPE1) TESTING_TYPE1,
       MIN(TT.JUDGE_CONDITION) JUDGE_CONDITION,
       SUM(TT.ACT_COUNT) ACT_COUNT,
       SUM(TT.ACT_THEORY_WEIGHT) ACT_THEORY_WEIGHT,
       MIN(TT.CHECK_NO) CHECK_NO,
       MIN(TT.TEST_PRESSURE) TEST_PRESSURE,
       MIN(TT.HOLDTIME_TIME) HOLDTIME_TIME,
       MIN(TT.TEST_PRESSURE_Y) TEST_PRESSURE_Y,
       MIN(TT.PRODUCE_TIME) PRODUCE_TIME,
       MIN(TT.IF_OUT_DETECT) IF_OUT_DETECT,
       MIN(TT.IF_OUT_COAT) IF_OUT_COAT,
       MIN(TT.IF_OUT_IMPRESS) IF_OUT_IMPRESS,
       MIN(TT.IF_OUT_BLAST) IF_OUT_BLAST,
       MIN(TT.WO_ID) WO_ID,
       MAX(TT.ZBS_LOCK_FLAG) ZBS_LOCK_FLAG,
       MIN(TT.EXIT_TEMP) EXIT_TEMP
  FROM (SELECT MIN(T.STOVE_NO) STOVE_NO,
               MIN(T.LOT_NO) LOT_NO,
               MIN(T.LOT_NO_GROUP) LOT_NO_GROUP,
               T.JUDGE_STOVE_NO,
               T.BATCH_NO,
               MIN(T.ZP_M_LH) ZP_M_LH,
               MIN(T.ZP_COLL) ZP_COLL,
               MIN(T.LOAD_JUDGE_STOVE_NO) LOAD_JUDGE_STOVE_NO,
               MIN(T.LOAD_BATCH_NO) LOAD_BATCH_NO,
               MIN(T.GRADENAME) GRADENAME,
               MIN(T.STEELNAME) STEELNAME,
               MIN(T.ACT_DIMATER) ACT_DIMATER,
               MIN(T.ACT_HEIGHT) ACT_HEIGHT,
               MAX(T.PHY_RESULT_CODE) PHY_RESULT_CODE,
               MIN(T2.BASENAME) PHY_RESULT_NAME,
               MIN(T.CHEM_RESULT_CODE) CHEM_RESULT_CODE,
               MIN(T3.BASENAME) CHEM_RESULT_NAME,
               MAX(T.PLINE_CODE) PLINE_CODE,
               MAX(T.PLINE_NAME) PLINE_NAME,
               TO_CHAR(MAX(T.APPLY_TIME), 'YYYY-MM-DD HH24:MI:SS') APPLY_TIME,
               TO_CHAR(MAX(T.JUDGE_RESULT_TIME), 'YYYY-MM-DD HH24:MI:SS') JUDGE_TIME,
               MIN(A.CREATE_NAME) JUDGE_NAME,
               MIN(T.JUDGE_FILE_MEMO) MEMO,
               MIN(T.JUDGE_MEMO) JUDGE_MEMO,
               MIN(T.LK_FLAG) LK_FLAG,
               MIN(T.STEEL_STANDRAD) STEEL_STANDRAD,
               CASE
                 WHEN MIN(B.SAMPLE_TYPE) = '2' THEN
                  '复验'
                 ELSE
                  '初验'
               END CHEM_TYPE,
               CASE
                 WHEN MIN(C.SAMPLE_TYPE) = '2' THEN
                  '复验'
                 ELSE
                  '初验'
               END PHY_TYPE,
               NULL OLD_GRADENAME,
               NULL OLD_CIC,
               MIN(D.PASS_APPLY_NO) PASS_APPLY_NO,
               MIN(D2.BASENAME) AUDIT_RESULT,
               MIN(D3.PASS_APPLY_NO) URGENT_PASS_NO,
               DECODE(MIN(D3.AUDIT_RESULT),
                      '0',
                      '审核不通过',
                      '1',
                      '审核通过',
                      NULL) URGENT_AUDIT_RESULT,
               MIN(T.JUDGE_RESULT) RESULT_NAME,
               MIN(T.JUDGE_RESULT_CODE) RESULT_CODE,
               MIN(T4.BASENAME) SPEC_RESULT_NAME,
               MIN(T5.BASENAME) FACE_RESULT_NAME,
               MIN(T6.BASENAME) DETECT_RESULT_NAME,
               MIN(T7.BASENAME) WATER_RESULT_NAME,
               MIN(T8.BASENAME) PROCESS_RESULT_NAME,
               T.JUGDE_APPLY_CODE JUGDE_APPLY_CODE,
               MIN(T.TARGET) TARGET,
               MIN(F.ORDER_NO) || '/' || MIN(F.ORDER_SEQ) ORDER_NO,
               MIN(F.BUYER_NAME) BUYER_NAME,
               MIN(T.PRODUCNAME) PRODUCNAME,
               MIN(T.STD_STYLE_DESC) STD_STYLE_DESC,
               MIN(T.MODEL_DESC) MODEL_DESC,
               MIN(T.SPEC_NAME) SPEC_NAME,
               MIN(T.DELIVERY_STATE_NAME) DELIVERY_STATE_NAME,
               MIN(T.STD_NAME) STD_NAME,
               MIN(T.MEMO) APPLY_MEMO,
               MIN(T.HTT_TYPE) HTT_TYPE,
               MIN(T.MIN_TEMP) MIN_TEMP,
               MIN(T.HTT_TECHNOLOGY) HTT_TECHNOLOGY,
               MIN(T.NOTCH_INFO) NOTCH_INFO,
               MIN(T.NOTCH_LENGTH) NOTCH_LENGTH,
               MIN(T.NOTCH_WIDTH) NOTCH_WIDTH,
               MIN(T.NOTCH_DEPTH) NOTCH_DEPTH,
               MIN(T.TESTING_GRADE) TESTING_GRADE,
               MIN(T.TESTING_TYPE) TESTING_TYPE,
               MIN(T.TESTING_GRADE1) TESTING_GRADE1,
               MIN(T.TESTING_TYPE1) TESTING_TYPE1,
               DECODE(MIN(E.JUDGE_RESULT_CODE), NULL, '不符合','40740704','不符合', '符合') JUDGE_CONDITION,
               MIN(T.ACT_COUNT) ACT_COUNT,
               MIN(T.ACT_WEIGHT) ACT_THEORY_WEIGHT,
               MIN(T.CHECK_NO) CHECK_NO,
               MIN(T.TEST_PRESSURE) TEST_PRESSURE,
               MIN(T.HOLDTIME_TIME) HOLDTIME_TIME,
               MIN(T.TEST_PRESSURE_Y) TEST_PRESSURE_Y,
               CASE
                 WHEN MIN(T.PROCESS_CODE) = 'D' THEN
                  TO_CHAR(MIN(G.FEED_TIME), 'YYYY-MM-DD HH24:MI:SS')
                 WHEN MIN(T.PROCESS_CODE) = 'E' THEN
                  TO_CHAR(MIN(G2.LOAD_TIME), 'YYYY-MM-DD HH24:MI:SS')
                 WHEN MIN(T.PROCESS_CODE) = 'F' THEN
                  TO_CHAR(MIN(G3.LOADTIME), 'YYYY-MM-DD HH24:MI:SS')
                 WHEN MIN(T.PROCESS_CODE) = 'G' THEN
                  TO_CHAR(MIN(G4.LOADTIME), 'YYYY-MM-DD HH24:MI:SS')
                 WHEN MIN(T.PROCESS_CODE) = 'H' THEN
                  TO_CHAR(MIN(G5.LOAD_TIME), 'YYYY-MM-DD HH24:MI:SS')
                 ELSE
                  NULL
               END PRODUCE_TIME,
               MIN(H2.BASENAME) IF_OUT_DETECT,
               MIN(H3.BASENAME) IF_OUT_COAT,
               MIN(H4.BASENAME) IF_OUT_IMPRESS,
               MIN(H5.BASENAME) IF_OUT_BLAST,
               MIN(H.WO_ID) WO_ID,
               MAX(T.ZBS_LOCK_FLAG) ZBS_LOCK_FLAG,
               MIN(T.EXIT_TEMP) EXIT_TEMP
          FROM QCM_ZG_JUGDE_APPLY T
          LEFT JOIN COM_BASE_INFO T4
            ON T4.BASECODE = T.SPEC_RESULT_CODE
           AND T.SPEC_RESULT_CODE IS NOT NULL
          LEFT JOIN COM_BASE_INFO T5
            ON T5.BASECODE = T.FACE_RESULT_CODE
           AND T.FACE_RESULT_CODE IS NOT NULL
          LEFT JOIN COM_BASE_INFO T6
            ON T6.BASECODE = T.DETECT_RESULT_CODE
           AND T.DETECT_RESULT_CODE IS NOT NULL
          LEFT JOIN COM_BASE_INFO T7
            ON T7.BASECODE = T.WPRESSURE_RESULT_CODE
           AND T.WPRESSURE_RESULT_CODE IS NOT NULL
          LEFT JOIN COM_BASE_INFO T8
            ON T8.BASECODE = T.PROCESS_RESULT_CODE
           AND T.PROCESS_RESULT_CODE IS NOT NULL
          LEFT JOIN QCM_BC_JUDGE A
            ON A.JUDGE_ID = T.JUGDE_CONVICTED
           AND T.JUGDE_CONVICTED IS NOT NULL
          LEFT JOIN QCM_BC_CHEMJUDGE B
            ON B.CHEM_JUDGE_ID = A.CHEM_JUDGE_ID
           AND B.JUDGE_SEQ = 1
           AND A.CHEM_JUDGE_ID IS NOT NULL
          LEFT JOIN QCM_BC_PHYJUDGE C
            ON C.PHY_JUDGE_ID = A.PHY_RESULT_ID
           AND C.JUDGE_SEQ = 1
           AND A.PHY_RESULT_ID IS NOT NULL
          LEFT JOIN QCM_BC_PASS_APPLY D
            ON D.JUGDE_APPLY_CODE = T.JUGDE_APPLY_CODE
           AND D.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO
           AND D.BATCH_NO = T.BATCH_NO
           AND D.PROCESS_CODE = T.PROCESS_CODE
           AND D.VALIDFLAG = '1'
           AND D.PASS_APPLY_SEQ = '001'
           AND D.TYPE = '0'
           AND T.JUGDE_APPLY_CODE IS NOT NULL
           AND T.JUDGE_STOVE_NO IS NOT NULL
           AND T.BATCH_NO IS NOT NULL
          LEFT JOIN COM_BASE_INFO D2
            ON D2.BASECODE = D.AUDIT_RESULT
           AND D.AUDIT_RESULT IS NOT NULL
          LEFT JOIN QCM_BC_PASS_APPLY D3
            ON D3.JUGDE_APPLY_CODE = T.JUGDE_APPLY_CODE
           AND D3.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO
           AND D3.BATCH_NO = T.BATCH_NO
           AND D3.PROCESS_CODE = T.PROCESS_CODE
           AND D3.VALIDFLAG = '1'
           AND D3.PASS_APPLY_SEQ = '001'
           AND D3.TYPE = '1'
           AND T.JUGDE_APPLY_CODE IS NOT NULL
           AND T.JUDGE_STOVE_NO IS NOT NULL
           AND T.BATCH_NO IS NOT NULL
          LEFT JOIN QCM_BC_PASS_APPLY D4
            ON D4.JUGDE_APPLY_CODE = T.JUGDE_APPLY_CODE
           AND D4.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO
           AND D4.BATCH_NO = T.BATCH_NO
           AND D4.PROCESS_CODE = T.PROCESS_CODE
           AND D4.TYPE = '0'
           AND D4.AUDIT_RESULT IN ('407502', '407503')
           AND D4.VALIDFLAG = '1'
           AND T.JUGDE_APPLY_CODE IS NOT NULL
           AND T.JUDGE_STOVE_NO IS NOT NULL
           AND T.BATCH_NO IS NOT NULL
           AND T.PROCESS_CODE IS NOT NULL
          LEFT JOIN QCM_BC_BATCH_RESULT E
            ON E.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO
           AND E.BATCH_NO = T.BATCH_NO
           AND E.PROCESS_CODE = T.PROCESS_CODE
           AND E.CRAFT_SOURCE = '0'
           AND E.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK
           AND T.ORD_LN_DLY_PK IS NOT NULL
           AND T.JUDGE_STOVE_NO IS NOT NULL
           AND T.BATCH_NO IS NOT NULL
           AND T.PROCESS_CODE IS NOT NULL
          LEFT JOIN COM_BASE_INFO T3
            ON T3.BASECODE = E.CHEM_RESULT_CODE
           AND E.CHEM_RESULT_CODE IS NOT NULL
          LEFT JOIN COM_BASE_INFO T2
            ON T2.BASECODE = E.PHY_RESULT_CODE
           AND E.PHY_RESULT_CODE IS NOT NULL
          LEFT JOIN MIL_PLAN G
            ON G.ID = T.HEAT_PLAN_NO
           AND T.PROCESS_CODE = 'D'
           AND T.HEAT_PLAN_NO IS NOT NULL
          LEFT JOIN VRP_LOADING_RESULT G2
            ON G2.HEAT_PLAN_NO = T.HEAT_PLAN_NO
          LEFT JOIN PLN_ZY_RCL_C G3
            ON G3.HEAT_PLAN_NO = T.HEAT_PLAN_NO
           AND T.PROCESS_CODE = 'F'
           AND T.HEAT_PLAN_NO IS NOT NULL
          LEFT JOIN PLN_ZY_JGX_C G4
            ON G4.HEAT_PLAN_NO = T.HEAT_PLAN_NO
           AND T.PROCESS_CODE = 'G'
           AND T.HEAT_PLAN_NO IS NOT NULL
          LEFT JOIN COUPLING_LOADING_RESULT G5
            ON G5.WO_ID = T.PRO_ORDER_ID
           AND T.PROCESS_CODE = 'H'
          LEFT JOIN PLN_ZY_JG_WORKBILL H
            ON H.WO_ID = T.PRO_ORDER_ID
           AND T.PRO_ORDER_ID IS NOT NULL
          LEFT JOIN COM_BASE_INFO H2
            ON H2.BASECODE = H.demand_detection
           AND H.demand_detection IS NOT NULL
          LEFT JOIN COM_BASE_INFO H3
            ON H3.BASECODE = H.demand_bonderizing
           AND H.demand_bonderizing IS NOT NULL
          LEFT JOIN COM_BASE_INFO H4
            ON H4.BASECODE = H.demand_copper
           AND H.demand_copper IS NOT NULL
          LEFT JOIN COM_BASE_INFO H5
            ON H5.BASECODE = H.demand_blast
           AND H.demand_blast IS NOT NULL, PLN_SALEORD F
         WHERE ({0} IS NULL OR T.LOT_NO LIKE '%' || {0} || '%')
           AND ({1} IS NULL OR T.JUDGE_STOVE_NO LIKE '%' || {1} || '%')
           AND ({2} IS NULL OR
               ({2} = '0' AND (T.JUDGE_RESULT_CODE IS NULL OR
               T.JUDGE_RESULT_CODE = '40740709') OR
               {2} = '1' AND T.JUDGE_RESULT_CODE IS NOT NULL AND
               T.JUDGE_RESULT_CODE <> '40740709'))
           AND ({11} = '1' AND
               ({3} IS NULL OR
               T.APPLY_TIME >= TO_DATE({3}, 'YYYY-MM-DD HH24:MI:SS')) AND
               ({4} IS NULL OR
               T.APPLY_TIME <= TO_DATE({4}, 'YYYY-MM-DD HH24:MI:SS')) OR
               {11} = '2' AND
               ({3} IS NULL OR T.JUDGE_RESULT_TIME >=
               TO_DATE({3}, 'YYYY-MM-DD HH24:MI:SS')) AND
               ({4} IS NULL OR T.JUDGE_RESULT_TIME <=
               TO_DATE({4}, 'YYYY-MM-DD HH24:MI:SS')))
           AND ({5} = '0' OR T.PLINE_CODE IN {6})
           AND T.PROCESS_CODE = {7}
           AND T.IS_FLAG = '0'
           AND T.IS_ALL_SCRAP IN ('0', '4', '5')
           AND F.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK
           AND T.APPLY_TIME >= TO_DATE('2018-07-30', 'YYYY-MM-DD')
           AND ({8} IS NULL OR {8} = '0' AND E.JUDGE_RESULT_CODE IS NULL OR
               {8} = '1' AND E.JUDGE_RESULT_CODE IS NOT NULL)
           AND ({9} IS NULL OR F.ORDER_NO LIKE '%' || UPPER({9}) || '%')
           AND ({10} IS NULL OR F.ORDER_SEQ = {10})
         GROUP BY T.JUGDE_APPLY_CODE,
                  T.JUGDE_APPLY_SEQUENO,
                  T.JUDGE_STOVE_NO,
                  T.BATCH_NO,
                  T.BATCH_GROUD_NO) TT
 GROUP BY TT.JUGDE_APPLY_CODE,
          TT.LOT_NO,
          TT.BATCH_NO,
          TT.JUDGE_STOVE_NO,
          TT.STOVE_NO
 ORDER BY TT.JUDGE_STOVE_NO, TT.BATCH_NO, TT.JUGDE_APPLY_CODE
        ]]>
    </query>
    
    <query id="QcmZgJugdeApplyDAL.QueryZcColligate" desc="成品综合查询">
        <![CDATA[
SELECT MIN(TT.LOT_NO) LOT_NO,
       MIN(TT.LOT_NO_GROUP) LOT_NO_GROUP,
       MIN(TT.STOVE_NO) STOVE_NO,
       TT.JUDGE_STOVE_NO,
       TT.BATCH_NO,
       MIN(TT.ZP_M_LH) ZP_M_LH,
       MIN(TT.ZP_COLL) ZP_COLL,
       MIN(TT.LOAD_JUDGE_STOVE_NO) LOAD_JUDGE_STOVE_NO,
       MIN(TT.LOAD_BATCH_NO) LOAD_BATCH_NO,
       TT.JUGDE_APPLY_CODE,
       MIN(TT.GRADENAME) GRADENAME,
       MIN(TT.ACT_DIMATER) ACT_DIMATER,
       MIN(TT.ACT_HEIGHT) ACT_HEIGHT,
       MIN(TT.PLINE_CODE) PLINE_CODE,
       MIN(TT.PLINE_NAME) PLINE_NAME,
       MIN(TT.APPLY_NAME) APPLY_NAME,
       MIN(TT.APPLY_TIME) APPLY_TIME,
       MIN(TT.JUDGE_TIME) JUDGE_TIME,
       MIN(TT.JUDGE_NAME) JUDGE_NAME,
       MIN(TT.MEMO) MEMO,
       MIN(TT.JUDGE_MEMO) JUDGE_MEMO,
       MIN(TT.LK_FLAG) LK_FLAG,
       MIN(TT.STEEL_STANDRAD) STEEL_STANDRAD,
       MIN(TT.PHY_TYPE) PHY_TYPE,
       MIN(TT.OLD_GRADENAME) OLD_GRADENAME,
       MIN(TT.OLD_CIC) OLD_CIC,
       MIN(TT.PASS_APPLY_NO) PASS_APPLY_NO,
       MIN(TT.AUDIT_RESULT) AUDIT_RESULT,
       MIN(TT.RESULT_NAME) RESULT_NAME,
       MIN(TT.RESULT_CODE) RESULT_CODE,
       MIN(TT.PROCESS_CODE) PROCESS_CODE,
       MIN(TT.PROCESS_DESC) PROCESS_DESC,
       MIN(TT.STEELNAME) STEELNAME,
       MIN(TT.TARGET) TARGET,
       MIN(TT.ORDER_NO) ORDER_NO,
       MIN(TT.BUYER_NAME) BUYER_NAME,
       MIN(TT.PRODUCNAME) PRODUCNAME,
       MIN(TT.STD_STYLE_DESC) STD_STYLE_DESC,
       MIN(TT.MODEL_DESC) MODEL_DESC,
       MIN(TT.SPEC_NAME) SPEC_NAME,
       MIN(TT.DELIVERY_STATE_NAME) DELIVERY_STATE_NAME,
       MIN(TT.STD_NAME) STD_NAME,
       MIN(TT.APPLY_MEMO) APPLY_MEMO,
       MIN(TT.HTT_TYPE) HTT_TYPE,
       MIN(TT.MIN_TEMP) MIN_TEMP,
       MIN(TT.HTT_TECHNOLOGY) HTT_TECHNOLOGY,
       MIN(TT.NOTCH_INFO) NOTCH_INFO,
       MIN(TT.NOTCH_LENGTH) NOTCH_LENGTH,
       MIN(TT.NOTCH_WIDTH) NOTCH_WIDTH,
       MIN(TT.NOTCH_DEPTH) NOTCH_DEPTH,
       MIN(TT.TESTING_GRADE) TESTING_GRADE,
       MIN(TT.TESTING_TYPE) TESTING_TYPE,
       MIN(TT.TESTING_GRADE1) TESTING_GRADE1,
       MIN(TT.TESTING_TYPE1) TESTING_TYPE1,
       SUM(TT.ACT_COUNT) ACT_COUNT,
       SUM(TT.ACT_LEN) ACT_LEN,
       SUM(TT.ACT_THEORY_WEIGHT) ACT_THEORY_WEIGHT,
       MIN(TT.CHECK_NO) CHECK_NO,
       MIN(TT.TEST_PRESSURE) TEST_PRESSURE,
       MIN(TT.HOLDTIME_TIME) HOLDTIME_TIME,
       MIN(TT.TEST_PRESSURE_Y) TEST_PRESSURE_Y,
       MIN(TT.ZBS_FLAG) ZBS_FLAG,
       MIN(TT.ZC_JUDGE_CONDITION) ZC_JUDGE_CONDITION,
       MIN(TT.PRODUCE_TIME) PRODUCE_TIME,
       MIN(TT.SALE_ORG_DESC) SALE_ORG_DESC,
       MIN(TT.SALE_AREA_DESC) SALE_AREA_DESC,
       MIN(TT.SALE_CREATE_NAME) SALE_CREATE_NAME,
       MIN(TT.IF_OUT_DETECT) IF_OUT_DETECT,
       MIN(TT.IF_OUT_COAT) IF_OUT_COAT,
       MIN(TT.IF_OUT_IMPRESS) IF_OUT_IMPRESS,
       MIN(TT.IF_OUT_BLAST) IF_OUT_BLAST,
       MIN(TT.WO_ID) WO_ID,
       MAX(TT.ZBS_LOCK_FLAG) ZBS_LOCK_FLAG,
       MAX( TT.IS_ALL_SCRAP ) IS_ALL_SCRAP,
       MIN(TT.EXIT_TEMP) EXIT_TEMP,
       MIN(TT.CIC) CIC,
       MIN(TT.PIC) PIC,
       DECODE(MAX(TT.LENGTH_TYPE),'0','正尺','1','长尺','2','短尺') LENGTH_TYPE
  FROM (SELECT MIN(T.LOT_NO) LOT_NO,
               MIN(T.LOT_NO_GROUP) LOT_NO_GROUP,
               MIN(T.STOVE_NO) STOVE_NO,
               T.JUDGE_STOVE_NO,
               T.BATCH_NO,
               MIN(T.ZP_M_LH) ZP_M_LH,
               MIN(T.ZP_COLL) ZP_COLL,
               MIN(T.LOAD_JUDGE_STOVE_NO) LOAD_JUDGE_STOVE_NO,
               MIN(T.LOAD_BATCH_NO) LOAD_BATCH_NO,
               T.JUGDE_APPLY_CODE,
               MIN(T.GRADENAME) GRADENAME,
               MIN(T.ACT_DIMATER) ACT_DIMATER,
               MIN(T.ACT_HEIGHT) ACT_HEIGHT,
               MAX(T.PLINE_CODE) PLINE_CODE,
               MAX(T.PLINE_NAME) PLINE_NAME,
               MAX(T.APPLY_NAME) APPLY_NAME,
               TO_CHAR(MAX(T.APPLY_TIME), 'YYYY-MM-DD HH24:MI:SS') APPLY_TIME,
               TO_CHAR(MAX(T.JUDGE_TOLRESULT_TIME), 'YYYY-MM-DD HH24:MI:SS') JUDGE_TIME,
               MIN(A.CREATE_NAME) JUDGE_NAME,
               MIN(T.JUDGE_FILE_TOLMEMO) MEMO,
               MIN(T.JUDGE_TOLMEMO) JUDGE_MEMO,
               MIN(T.LK_FLAG) LK_FLAG,
               MIN(T.STEEL_STANDRAD) STEEL_STANDRAD,
               CASE
                 WHEN MIN(B.SAMPLE_TYPE) = '2' THEN
                  '复验'
                 ELSE
                  '初验'
               END CHEM_TYPE,
               CASE
                 WHEN MIN(C.SAMPLE_TYPE) = '2' THEN
                  '复验'
                 ELSE
                  '初验'
               END PHY_TYPE,
               NULL OLD_GRADENAME,
               NULL OLD_CIC,
               MIN(D.PASS_APPLY_NO) PASS_APPLY_NO,
               DECODE(MIN(D.AUDIT_RESULT),
                      '0',
                      '审核不通过',
                      '1',
                      '审核通过',
                      MIN(D2.BASENAME)) AUDIT_RESULT,
               MIN(T.JUDGE_TOLRESULT) RESULT_NAME,
               MIN(T.JUDGE_TOLRESULT_CODE) RESULT_CODE,
               MIN(T.PROCESS_CODE) PROCESS_CODE,
               MIN(T4.PROCESS_DESC) PROCESS_DESC,
               MIN(T.STEELNAME) STEELNAME,
               MIN(T.TARGET) TARGET,
               MIN(F3.ORDER_NO) || '/' || MIN(F2.ORDER_SEQ) ORDER_NO,
               MIN(F4.ABRVITION) BUYER_NAME,
               MIN(T.PRODUCNAME) PRODUCNAME,
               MIN(T.STD_STYLE_DESC) STD_STYLE_DESC,
               MIN(T.MODEL_DESC) MODEL_DESC,
               MIN(T.SPEC_NAME) SPEC_NAME,
               MIN(T.DELIVERY_STATE_NAME) DELIVERY_STATE_NAME,
               MIN(T.STD_NAME) STD_NAME,
               MIN(T.MEMO) APPLY_MEMO,
               MIN(T.HTT_TYPE) HTT_TYPE,
               MIN(T.MIN_TEMP) MIN_TEMP,
               MIN(T.HTT_TECHNOLOGY) HTT_TECHNOLOGY,
               MIN(T.NOTCH_INFO) NOTCH_INFO,
               MIN(T.NOTCH_LENGTH) NOTCH_LENGTH,
               MIN(T.NOTCH_WIDTH) NOTCH_WIDTH,
               MIN(T.NOTCH_DEPTH) NOTCH_DEPTH,
               MIN(T.TESTING_GRADE) TESTING_GRADE,
               MIN(T.TESTING_TYPE) TESTING_TYPE,
               MIN(T.TESTING_GRADE1) TESTING_GRADE1,
               MIN(T.TESTING_TYPE1) TESTING_TYPE1,
               MIN(T.ACT_COUNT) ACT_COUNT,
               MIN(T.ACT_LEN) ACT_LEN,
               MIN(T.ACT_WEIGHT) ACT_THEORY_WEIGHT,
               MIN(T.CHECK_NO) CHECK_NO,
               MIN(T.TEST_PRESSURE) TEST_PRESSURE,
               MIN(T.HOLDTIME_TIME) HOLDTIME_TIME,
               MIN(T.TEST_PRESSURE_Y) TEST_PRESSURE_Y,
               DECODE(MIN(T.ZBS_FLAG), '1', '产销', '2', '老系统', '/') ZBS_FLAG,
               DECODE(MIN(T.ZC_JUDGE_CONDITION),
                      '1',
                      '符合',
                      '0',
                      '不符合',
                      '/') ZC_JUDGE_CONDITION,
               CASE
                 WHEN MIN(T.PROCESS_CODE) = 'D' THEN
                  TO_CHAR(MIN(G.FEED_TIME), 'YYYY-MM-DD HH24:MI:SS')
                 WHEN MIN(T.PROCESS_CODE) = 'E' THEN
                  TO_CHAR(MIN(G2.LOAD_TIME), 'YYYY-MM-DD HH24:MI:SS')
                 WHEN MIN(T.PROCESS_CODE) = 'F' THEN
                  TO_CHAR(MIN(G3.LOADTIME), 'YYYY-MM-DD HH24:MI:SS')
                 WHEN MIN(T.PROCESS_CODE) = 'G' THEN
                  TO_CHAR(MIN(G4.LOADTIME), 'YYYY-MM-DD HH24:MI:SS')
                 WHEN MIN(T.PROCESS_CODE) = 'H' THEN
                  TO_CHAR(MIN(G5.LOAD_TIME), 'YYYY-MM-DD HH24:MI:SS')
                 ELSE
                  NULL
               END PRODUCE_TIME,
               MIN(F3.SALE_ORG_DESC) SALE_ORG_DESC,
               MIN(F3.SALE_AREA_DESC) SALE_AREA_DESC,
               MIN(F3.CREATE_NAME) SALE_CREATE_NAME,
               MIN(H2.BASENAME) IF_OUT_DETECT,
               MIN(H3.BASENAME) IF_OUT_COAT,
               MIN(H4.BASENAME) IF_OUT_IMPRESS,
               MIN(H5.BASENAME) IF_OUT_BLAST,
               MIN(H.WO_ID) WO_ID,
               MAX(T.ZBS_LOCK_FLAG) ZBS_LOCK_FLAG,
               DECODE(MAX(T.IS_ALL_SCRAP),'0','正常','1','整炉废','2','白条','3','红冲','4','成品利库','5','短节备料利库','6','半成品转成品','7','离线转压库','8','余材转压库') IS_ALL_SCRAP,
               MIN(T.EXIT_TEMP) EXIT_TEMP,
               MIN(T.CIC) CIC,
               MIN(T.PIC) PIC,
               MAX(T.LENGTH_TYPE) LENGTH_TYPE
          FROM QCM_ZG_JUGDE_APPLY T
          LEFT JOIN COM_BASE_PROCESS T4
            ON T4.PROCESS_CODE = T.PROCESS_CODE
           AND T.PROCESS_CODE IS NOT NULL
          LEFT JOIN QCM_ZC_JUDGE A
            ON A.JUDGE_ID = T.JUGDE_TOLCONVICTED
           AND T.JUGDE_TOLCONVICTED IS NOT NULL
          LEFT JOIN COM_BASE_INFO T6
            ON T6.BASECODE = A.JUDGE_RESULT
           AND A.JUDGE_RESULT IS NOT NULL
          LEFT JOIN QCM_BC_CHEMJUDGE B
            ON B.CHEM_JUDGE_ID = A.CHEM_JUDGE_ID
           AND B.JUDGE_SEQ = 1
           AND A.CHEM_JUDGE_ID IS NOT NULL
          LEFT JOIN QCM_BC_PHYJUDGE C
            ON C.PHY_JUDGE_ID = A.PHY_RESULT_ID
           AND C.JUDGE_SEQ = 1
           AND A.PHY_RESULT_ID IS NOT NULL
          LEFT JOIN QCM_ZC_PASS_APPLY D
            ON D.JUGDE_APPLY_CODE = T.JUGDE_APPLY_CODE
           AND D.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO
           AND D.BATCH_NO = T.BATCH_NO
           AND D.PROCESS_CODE = T.PROCESS_CODE
           AND D.VALIDFLAG = '1'
           AND D.PASS_APPLY_SEQ = '001'
           AND T.JUGDE_APPLY_CODE IS NOT NULL
           AND T.JUDGE_STOVE_NO IS NOT NULL
           AND T.BATCH_NO IS NOT NULL
          LEFT JOIN COM_BASE_INFO D2
            ON D2.BASECODE = D.AUDIT_RESULT
           AND D.AUDIT_RESULT IS NOT NULL
          LEFT JOIN QCM_ZC_PASS_APPLY D3
            ON D3.JUGDE_APPLY_CODE = T.JUGDE_APPLY_CODE
           AND D3.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO
           AND D3.BATCH_NO = T.BATCH_NO
           AND D3.PROCESS_CODE = T.PROCESS_CODE
           AND D3.VALIDFLAG = '1'
           AND D3.PASS_APPLY_SEQ = '001'
           AND D3.TYPE = '0'
           AND T.JUGDE_APPLY_CODE IS NOT NULL
           AND T.JUDGE_STOVE_NO IS NOT NULL
           AND T.BATCH_NO IS NOT NULL
          LEFT JOIN MIL_PLAN G
            ON G.ID = T.HEAT_PLAN_NO
           AND T.PROCESS_CODE = 'D'
           AND T.HEAT_PLAN_NO IS NOT NULL
          LEFT JOIN VRP_LOADING_RESULT G2
            ON G2.HEAT_PLAN_NO = T.HEAT_PLAN_NO
          LEFT JOIN PLN_ZY_RCL_C G3
            ON G3.HEAT_PLAN_NO = T.HEAT_PLAN_NO
           AND T.PROCESS_CODE = 'F'
           AND T.HEAT_PLAN_NO IS NOT NULL
          LEFT JOIN PLN_ZY_JGX_C G4
            ON G4.HEAT_PLAN_NO = T.HEAT_PLAN_NO
           AND T.PROCESS_CODE = 'G'
           AND T.HEAT_PLAN_NO IS NOT NULL
          LEFT JOIN COUPLING_LOADING_RESULT G5
            ON G5.WO_ID = T.PRO_ORDER_ID
           AND T.PROCESS_CODE = 'H'
          LEFT JOIN PLN_ZY_JG_WORKBILL H
            ON H.WO_ID = T.PRO_ORDER_ID
           AND T.PRO_ORDER_ID IS NOT NULL
          LEFT JOIN COM_BASE_INFO H2
            ON H2.BASECODE = H.demand_detection
           AND H.demand_detection IS NOT NULL
          LEFT JOIN COM_BASE_INFO H3
            ON H3.BASECODE = H.demand_bonderizing
           AND H.demand_bonderizing IS NOT NULL
          LEFT JOIN COM_BASE_INFO H4
            ON H4.BASECODE = H.demand_copper
           AND H.demand_copper IS NOT NULL
          LEFT JOIN COM_BASE_INFO H5
            ON H5.BASECODE = H.demand_blast
           AND H.demand_blast IS NOT NULL
          LEFT JOIN QCM_BC_JUDGE H6
            ON H6.JUDGE_ID = T.JUGDE_CONVICTED
           AND T.JUGDE_CONVICTED IS NOT NULL
		  LEFT JOIN SLM_ORDER_LINE_DELIVERY F
		  	ON F.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK
		  LEFT JOIN SLM_ORDER_LINE F2
		  	ON F2.ORD_LN_PK = F.ORD_LN_PK
		  LEFT JOIN SLM_ORDER_HEAD F3
		  	ON F3.ORD_PK = F2.ORD_PK
		  LEFT JOIN SLM_BASE_CUSTOMER F4
		  	ON F4.CUSTOMER_NO = F3.CUSTOMER_NO
         WHERE ({0} IS NULL OR T.LOT_NO LIKE '%' || {0} || '%')
           AND ({1} IS NULL OR T.JUDGE_STOVE_NO LIKE '%' || {1} || '%')
           AND ({2} = '0' OR
               (T.JUDGE_TOLRESULT_CODE IN {3} OR
               '0' IN {3} AND (T.JUDGE_TOLRESULT_CODE IS NULL OR
               T.JUDGE_TOLRESULT_CODE = '40740709' OR
               T.JUDGE_TOLRESULT_CODE = '40740704' AND
               D3.PASS_APPLY_NO IS NOT NULL) OR
               '1' IN {3} AND T.JUDGE_TOLRESULT_CODE IS NOT NULL AND
               T.JUDGE_TOLRESULT_CODE <> '40740709'))
           AND ({10} = '1' AND
               ({4} IS NULL OR
               T.APPLY_TIME >= TO_DATE({4}, 'YYYY-MM-DD HH24:MI:SS')) AND
               ({4} IS NULL OR
               T.APPLY_TIME <= TO_DATE({5}, 'YYYY-MM-DD HH24:MI:SS')) OR
               {10} = '2' AND
               ({4} IS NULL OR T.JUDGE_TOLRESULT_TIME >=
               TO_DATE({4}, 'YYYY-MM-DD HH24:MI:SS')) AND
               ({4} IS NULL OR T.JUDGE_TOLRESULT_TIME <=
               TO_DATE({5}, 'YYYY-MM-DD HH24:MI:SS')))
           AND ({6} = '0' OR T.PLINE_CODE IN {7})
           AND T.TARGET = 'A'
           AND T.IS_FLAG = '0'
          -- AND T.IS_ALL_SCRAP IN ('0', '4', '5', '6', '7', '8')
           AND (T.IS_ALL_SCRAP = '4' OR T.JUDGE_RESULT_CODE = '40740701' OR
               T.JUDGE_RESULT_CODE = '40740709')
           AND (F.ORD_LN_PK IS NOT NULL OR T.ORD_LN_DLY_PK IS NULL)
           --AND F.ORD_LN_PK IS NOT NULL
           --AND F2.ORD_PK IS NOT NULL
           --AND F3.CUSTOMER_NO IS NOT NULL
           AND (T.IS_ALL_SCRAP IN ('4', '6') OR H6.JUDGE_ID IS NOT NULL OR T.ORD_LN_DLY_PK IS NULL)
           AND ({8} IS NULL OR F3.ORDER_NO LIKE '%' || UPPER({8}) || '%')
           AND ({9} IS NULL OR F2.ORDER_SEQ = {9})
           AND ({11} IS NULL OR T.ZC_JUDGE_CONDITION = {11})
           AND T.IS_ALL_SCRAP in {12}
           AND T.APPLY_TIME >= TO_DATE('2018-07-30', 'YYYY-MM-DD')
         GROUP BY T.JUGDE_APPLY_CODE,
                  T.JUGDE_APPLY_SEQUENO,
                  T.JUDGE_STOVE_NO,
                  T.BATCH_NO,
                  T.BATCH_GROUD_NO) TT
 GROUP BY TT.JUGDE_APPLY_CODE,
          TT.LOT_NO,
          TT.BATCH_NO,
          TT.JUDGE_STOVE_NO,
          TT.STOVE_NO
 ORDER BY TT.JUDGE_STOVE_NO, TT.BATCH_NO, TT.JUGDE_APPLY_CODE
        ]]>
    </query>
    
    <query id="QcmZgJugdeApplyDAL.QueryByPk" desc="通过主键查询">
        <![CDATA[
 SELECT 
       T.JUGDE_APPLY_CODE,
       T.JUDGE_STOVE_NO,
       T.BATCH_NO,
       T.BATCH_GROUD_NO,
       T.PROCESS_CODE,
       T.PLINE_CODE,
       T.ACT_COUNT,
       T.ACT_WEIGHT,
       T.ACT_THEORY_WEIGHT,
       T.PRO_ORDER_ID,
       T.FACE_RESULT_CODE,
       T.SPEC_RESULT_CODE,
       T.CHEM_RESULT_CODE,
       T.PHY_RESULT_CODE,
       T.DETECT_RESULT_CODE,
       T.WPRESSURE_RESULT_CODE,
       T.PROCESS_RESULT_CODE,
       T.FACE_RESULT_PATH,
       T.SPEC_RESULT_PATH,
       T.CHEM_RESULT_PATH,
       T.PHY_RESULT_PATH,
       T.DETECT_RESULT_PATH,
       T.WPRESSURE_RESULT_PATH,
       T.PROCESS_RESULT_PATH,
       T.VALIDFLAG,
       T.APPLY_NAME,
       TO_CHAR(T.APPLY_TIME, 'YYYY-MM-DD HH24:MI:SS') APPLY_TIME,
       T.MEMO,
       T.QUALITY_GROUP,
       T.MATERIAL_NO,
       T.MATERIAL_NAME,
       T.PRODUCCODE,
       T.PRODUCNAME,
       T.STEELCODE,
       T.STEELNAME,
       T.GRADECODE,
       T.GRADENAME,
       T.SPEC_CODE,
       T.SPEC_NAME,
       T.MODEL_CODE,
       T.MODEL_DESC,
       T.STD_CODE,
       T.STD_NAME,
       T.STD_STYLE,
       T.STD_STYLE_DESC,
       T.CRAF_NO,
       T.LOT_NO,
       T.PLINE_NAME,
       T.PRO_ORDER_NO,
       T.TARGET,
       T.PROCESS_STATUS,
       T.MAT_GOWHERE_CODE,
       T.MAT_GOWHERE_NAME,
       T.ACT_DIMATER,
       T.ACT_HEIGHT,
       T.ACT_LEN_MIN,
       T.ACT_LEN_MAX,
       T.JUDGE_RESULT_CODE,
       T.JUDGE_RESULT,
       TO_CHAR(T.JUDGE_RESULT_TIME, 'YYYY-MM-DD HH24:MI:SS') JUDGE_RESULT_TIME,
       T.JUDGE_MAKER,
       T.IF_SET_ZY_PLAN,
       T.TESTING_GRADE,
       T.TESTING_TYPE,
       T.TESTING_GRADE1,
       T.TESTING_TYPE1,
       T.DETECT_RESULT_CODE1,
       T.DETECT_RESULT_PATH1,
       T.ORD_LN_DLY_PK,
       T.APPLY_FLAG,
       T.BACK_JUGDE_MEMO,
       T.INSTOCK_FLAG,
       T.BELONG_CODE,
       T.BELONG_NAME,
       T.ISENDGX,
       T.EXIT_TEMP,
       T.SAMPLE_NEWS,
       T.ACT_LEN,
       T.BELONG_CODE_JUGDE,
       T.BELONG_NAME_JUGDE,
       T.GX_PLAN_NO,
       T.INPUT_WEIGHT,
       T.INPUT_COUNT,
       T.OUTPUT_WEIGHT,
       T.OUTPUT_COUNT,
       T.BAL_YEAR_MONTH,
       T.IS_FLAG,
       T.IS_ALL_SCRAP,
       T.IS_CARRY_VOER
 FROM QCM_ZG_JUGDE_APPLY T
 WHERE
       T.JUGDE_APPLY_CODE = '#JUGDE_APPLY_CODE#'
       AND T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
       AND T.BATCH_NO = '#BATCH_NO#'
       AND T.BATCH_GROUD_NO = '#BATCH_GROUD_NO#'
       AND T.QUALITY_GROUP = '#QUALITY_GROUP#'
       AND T.MAT_GOWHERE_CODE = '#MAT_GOWHERE_CODE#'
        ]]>
    </query>
    <query id="QcmZgJugdeApplyDAL.QueryByBatchNo" desc="通过批号查询">
        <![CDATA[
SELECT T.*,
       T.ORD_LN_DLY_PK PRO_ORD_LN_DLY_PK, T2.PROCESS_DESC
  FROM QCM_ZG_JUGDE_APPLY T
  LEFT JOIN PLN_ZY_DBK_M B
    ON B.HEAT_PLAN_NO = T.HEAT_PLAN_NO
  LEFT JOIN PLN_ZY_RCL_M C
    ON C.HEAT_PLAN_NO = T.HEAT_PLAN_NO
  LEFT JOIN PLN_ZY_JGX_M D
    ON D.HEAT_PLAN_NO = T.HEAT_PLAN_NO
  LEFT JOIN PLN_ZY_JG_M E
    ON E.HEAT_PLAN_NO = T.HEAT_PLAN_NO
  LEFT JOIN COM_BASE_PROCESS T2
    ON T2.PROCESS_CODE = T.PROCESS_CODE
 WHERE T.JUGDE_APPLY_CODE = {0}
   AND T.JUDGE_STOVE_NO = {1}
   AND T.BATCH_NO = {2}
   AND T.IS_FLAG = '0'
   AND T.IS_ALL_SCRAP IN ('0', '4', '5', '6', '7', '8')
        ]]>
    </query>
    
    <query id="QcmZgJugdeApplyDAL.QueryByBatchNoAddResult" desc="查询轧管数据新增判定特殊处理">
        <![CDATA[
SELECT D.PASS_APPLY_NO PASS_APPLY_NO,
       D2.BASENAME AUDIT_RESULT,
       D3.PASS_APPLY_NO URGENT_PASS_NO,
       DECODE(D3.AUDIT_RESULT, '0', '审核不通过', '1', '审核通过', NULL) URGENT_AUDIT_RESULT,
       T.ORD_LN_DLY_PK PRO_ORD_LN_DLY_PK,
       T2.PROCESS_DESC
  FROM QCM_ZG_JUGDE_APPLY T
  LEFT JOIN PLN_ZY_DBK_M B
    ON B.HEAT_PLAN_NO = T.HEAT_PLAN_NO
  LEFT JOIN PLN_ZY_RCL_M C
    ON C.HEAT_PLAN_NO = T.HEAT_PLAN_NO
  LEFT JOIN PLN_ZY_JGX_M D
    ON D.HEAT_PLAN_NO = T.HEAT_PLAN_NO
  LEFT JOIN PLN_ZY_JG_M E
    ON E.HEAT_PLAN_NO = T.HEAT_PLAN_NO
  LEFT JOIN COM_BASE_PROCESS T2
    ON T2.PROCESS_CODE = T.PROCESS_CODE
  LEFT JOIN QCM_BC_PASS_APPLY D
    ON D.JUGDE_APPLY_CODE = T.JUGDE_APPLY_CODE
   AND D.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO
   AND D.BATCH_NO = T.BATCH_NO
   AND D.PROCESS_CODE = T.PROCESS_CODE
   AND D.VALIDFLAG = '1'
   AND D.PASS_APPLY_SEQ = '001'
   AND D.TYPE = '0'
   AND T.JUGDE_APPLY_CODE IS NOT NULL
   AND T.JUDGE_STOVE_NO IS NOT NULL
   AND T.BATCH_NO IS NOT NULL
  LEFT JOIN COM_BASE_INFO D2
    ON D2.BASECODE = D.AUDIT_RESULT
   AND D.AUDIT_RESULT IS NOT NULL
  LEFT JOIN QCM_BC_PASS_APPLY D3
    ON D3.JUGDE_APPLY_CODE = T.JUGDE_APPLY_CODE
   AND D3.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO
   AND D3.BATCH_NO = T.BATCH_NO
   AND D3.PROCESS_CODE = T.PROCESS_CODE
   AND D3.VALIDFLAG = '1'
   AND D3.PASS_APPLY_SEQ = '001'
   AND D3.TYPE = '1'
   AND T.JUGDE_APPLY_CODE IS NOT NULL
   AND T.JUDGE_STOVE_NO IS NOT NULL
   AND T.BATCH_NO IS NOT NULL
 WHERE T.JUGDE_APPLY_CODE = ?
   AND T.JUDGE_STOVE_NO = ?
   AND T.BATCH_NO = ?
   AND T.IS_FLAG = '0'
   AND T.IS_ALL_SCRAP IN ('0', '4', '5', '6', '7', '8')
        ]]>
    </query>
    
    <query id="QcmZgJugdeApplyDAL.QueryNoBatchNo" desc="通过批号查询">
        <![CDATA[
SELECT T.*,
       T.ORD_LN_DLY_PK PRO_ORD_LN_DLY_PK, T2.PROCESS_DESC
  FROM QCM_ZG_JUGDE_APPLY T
  LEFT JOIN PLN_ZY_DBK_M B
    ON B.HEAT_PLAN_NO = T.HEAT_PLAN_NO
  LEFT JOIN PLN_ZY_RCL_M C
    ON C.HEAT_PLAN_NO = T.HEAT_PLAN_NO
  LEFT JOIN PLN_ZY_JGX_M D
    ON D.HEAT_PLAN_NO = T.HEAT_PLAN_NO
  LEFT JOIN PLN_ZY_JG_M E
    ON E.HEAT_PLAN_NO = T.HEAT_PLAN_NO
  LEFT JOIN COM_BASE_PROCESS T2
    ON T2.PROCESS_CODE = T.PROCESS_CODE
 WHERE T.JUGDE_APPLY_CODE = {0}
   AND T.JUDGE_STOVE_NO = {1}
   AND T.IS_FLAG = '0'
   AND T.IS_ALL_SCRAP IN ('0', '4', '5', '6', '7', '8')
        ]]>
    </query>
    
     <query id="QcmZgJugdeApplyDAL.QueryGroupInfoByBatchNo" desc="通过批号查询">
        <![CDATA[
SELECT SUM(T.ACT_COUNT) ACT_COUNT,
       SUM(T.ACT_WEIGHT) ACT_WEIGHT,
       SUM(T.ACT_THEORY_WEIGHT) ACT_THEORY_WEIGHT
  FROM QCM_ZG_JUGDE_APPLY T
 WHERE T.JUGDE_APPLY_CODE = {0}
   AND T.JUDGE_STOVE_NO = {1}
   AND T.BATCH_NO = {2}
   AND T.IS_FLAG = '0'
   AND T.IS_ALL_SCRAP IN ('0', '4', '5', '6', '7', '8')
 GROUP BY T.JUGDE_APPLY_CODE, T.JUDGE_STOVE_NO, T.BATCH_NO
        ]]>
    </query>
    <query id="QcmZgJugdeApplyDAL.QueryByBatchNo2" desc="通过批号查询2">
        <![CDATA[
SELECT T.*, T.ORD_LN_DLY_PK PRO_ORD_LN_DLY_PK, T2.PROCESS_DESC
  FROM QCM_ZG_JUGDE_APPLY T
  LEFT JOIN PLN_ZY_DBK_M B
    ON B.HEAT_PLAN_NO = T.HEAT_PLAN_NO
  LEFT JOIN PLN_ZY_RCL_M C
    ON C.HEAT_PLAN_NO = T.HEAT_PLAN_NO
  LEFT JOIN PLN_ZY_JGX_M D
    ON D.HEAT_PLAN_NO = T.HEAT_PLAN_NO
  LEFT JOIN PLN_ZY_JG_M E
    ON E.HEAT_PLAN_NO = T.HEAT_PLAN_NO
  LEFT JOIN COM_BASE_PROCESS T2
    ON T2.PROCESS_CODE = T.PROCESS_CODE
 WHERE T.JUDGE_STOVE_NO = {0}
   AND T.BATCH_NO = {1}
   AND T.PROCESS_CODE = {2}
   AND ({3} IS NULL OR T.HEAT_PLAN_NO = {3})
   AND T.IS_FLAG = '0'
   AND T.IS_ALL_SCRAP IN ('0', '4', '5', '6', '7', '8')
   	 ORDER BY T.JUDGE_RESULT_TIME
        ]]>
    </query>
    
    <query id="QcmZgJugdeApplyDAL.QueryNoBatchNo2" desc="通过批号查询2">
        <![CDATA[
SELECT T.*, T.ORD_LN_DLY_PK PRO_ORD_LN_DLY_PK, T2.PROCESS_DESC
  FROM QCM_ZG_JUGDE_APPLY T
  LEFT JOIN PLN_ZY_DBK_M B
    ON B.HEAT_PLAN_NO = T.HEAT_PLAN_NO
  LEFT JOIN PLN_ZY_RCL_M C
    ON C.HEAT_PLAN_NO = T.HEAT_PLAN_NO
  LEFT JOIN PLN_ZY_JGX_M D
    ON D.HEAT_PLAN_NO = T.HEAT_PLAN_NO
  LEFT JOIN PLN_ZY_JG_M E
    ON E.HEAT_PLAN_NO = T.HEAT_PLAN_NO
  LEFT JOIN COM_BASE_PROCESS T2
    ON T2.PROCESS_CODE = T.PROCESS_CODE
 WHERE T.JUDGE_STOVE_NO = {0}
   AND T.PROCESS_CODE = {1}
   AND ({2} IS NULL OR T.HEAT_PLAN_NO = {2})
   AND T.IS_FLAG = '0'
   AND T.IS_ALL_SCRAP IN ('0', '4', '5', '6', '7', '8')
        ]]>
    </query>
    
    <query id="QcmZgJugdeApplyDAL.QueryByBatchNoNoLiku" desc="通过批号查询 排除成品利库">
        <![CDATA[
SELECT T.*,
       CASE
         WHEN B.HEAT_PLAN_NO IS NOT NULL THEN
          B.UPPER_HEATPLAN_ID
         WHEN C.HEAT_PLAN_NO IS NOT NULL THEN
          C.UPPER_HEATPLAN_ID
         WHEN D.HEAT_PLAN_NO IS NOT NULL THEN
          D.UPPER_HEATPLAN_ID
         WHEN E.HEAT_PLAN_NO IS NOT NULL THEN
          E.UPPER_HEATPLAN_ID
       END UPPER_HEATPLAN_ID
  FROM QCM_ZG_JUGDE_APPLY T
  LEFT JOIN PLN_ZY_DBK_M B
    ON B.HEAT_PLAN_NO = T.HEAT_PLAN_NO
  LEFT JOIN PLN_ZY_RCL_M C
    ON C.HEAT_PLAN_NO = T.HEAT_PLAN_NO
  LEFT JOIN PLN_ZY_JGX_M D
    ON D.HEAT_PLAN_NO = T.HEAT_PLAN_NO
  LEFT JOIN PLN_ZY_JG_M E
    ON E.HEAT_PLAN_NO = T.HEAT_PLAN_NO
 WHERE T.JUDGE_STOVE_NO = {0}
   AND T.BATCH_NO = {1}
   AND PROCESS_CODE = {2}
   AND T.IS_FLAG = '0'
   AND T.IS_ALL_SCRAP IN ('0', '5', '6')
        ]]>
    </query>
    <query id="QcmZgJugdeApplyDAL.QueryBLByBatchNo" desc="通过批号查询备料">
        <![CDATA[
SELECT T.*, T.ORD_LN_DLY_PK PRO_ORD_LN_DLY_PK,
       CASE
         WHEN B.HEAT_PLAN_NO IS NOT NULL THEN
          B.UPPER_HEATPLAN_ID
         WHEN C.HEAT_PLAN_NO IS NOT NULL THEN
          C.UPPER_HEATPLAN_ID
         WHEN D.HEAT_PLAN_NO IS NOT NULL THEN
          D.UPPER_HEATPLAN_ID
         WHEN E.HEAT_PLAN_NO IS NOT NULL THEN
          E.UPPER_HEATPLAN_ID
       END UPPER_HEATPLAN_ID
   FROM QCM_ZG_JUGDE_APPLY T
   LEFT JOIN PLN_ZY_DBK_M B
    ON B.HEAT_PLAN_NO = T.HEAT_PLAN_NO
  LEFT JOIN PLN_ZY_RCL_M C
    ON C.HEAT_PLAN_NO = T.HEAT_PLAN_NO
  LEFT JOIN PLN_ZY_JGX_M D
    ON D.HEAT_PLAN_NO = T.HEAT_PLAN_NO
  LEFT JOIN PLN_ZY_JG_M E
    ON E.HEAT_PLAN_NO = T.HEAT_PLAN_NO
  WHERE T.JUDGE_STOVE_NO = {0}
    AND T.BATCH_NO = {1}
    AND T.IS_FLAG = '0'
    AND T.IS_ALL_SCRAP IN ('0', '5', '6')
    AND T.ORD_LN_DLY_PK LIKE 'ZZB%'
    AND T.PROCESS_CODE =
        (SELECT MAX(A.PROCESS_CODE)
           FROM QCM_ZG_JUGDE_APPLY A
          WHERE A.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO
            AND A.BATCH_NO = T.BATCH_NO
            AND A.IS_FLAG = T.IS_FLAG
            AND A.IS_ALL_SCRAP = T.IS_ALL_SCRAP
            AND A.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK)
        ]]>
    </query>
    <query id="QcmZgJugdeApplyDAL.QueryByJudgeStoveNoFirstRow" desc="通过判定炉号查询">
        <![CDATA[
SELECT T.*,
       CASE
         WHEN B.HEAT_PLAN_NO IS NOT NULL THEN
          B.UPPER_HEATPLAN_ID
         WHEN C.HEAT_PLAN_NO IS NOT NULL THEN
          C.UPPER_HEATPLAN_ID
         WHEN D.HEAT_PLAN_NO IS NOT NULL THEN
          D.UPPER_HEATPLAN_ID
         WHEN E.HEAT_PLAN_NO IS NOT NULL THEN
          E.UPPER_HEATPLAN_ID
       END UPPER_HEATPLAN_ID
  FROM QCM_ZG_JUGDE_APPLY T
  LEFT JOIN PLN_ZY_DBK_M B
    ON B.HEAT_PLAN_NO = T.HEAT_PLAN_NO
  LEFT JOIN PLN_ZY_RCL_M C
    ON C.HEAT_PLAN_NO = T.HEAT_PLAN_NO
  LEFT JOIN PLN_ZY_JGX_M D
    ON D.HEAT_PLAN_NO = T.HEAT_PLAN_NO
  LEFT JOIN PLN_ZY_JG_M E
    ON E.HEAT_PLAN_NO = T.HEAT_PLAN_NO
 WHERE T.JUDGE_STOVE_NO = {0}
   AND T.PROCESS_CODE = {1}
   AND T.IS_FLAG = '0'
   AND T.IS_ALL_SCRAP IN ('0', '4', '5', '6', '7', '8')
   AND ROWNUM <= 1
        ]]>
    </query>
    <query id="QcmZgJugdeApplyDAL.Insert" desc="新增">
        <![CDATA[
 INSERT INTO QCM_ZG_JUGDE_APPLY(
        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,
        IS_ALL_SCRAP,
        IS_CARRY_VOER)
 VALUES( 
        '#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#',
        SYSDATE,
        '#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#',
        SYSDATE,
        '#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#',
        '#IS_ALL_SCRAP#',
        '#IS_CARRY_VOER#')
        ]]>
    </query>
    <query id="QcmZgJugdeApplyDAL.Update" desc="修改">
        <![CDATA[
 UPDATE QCM_ZG_JUGDE_APPLY T
   SET 
        T.JUGDE_APPLY_CODE = '#JUGDE_APPLY_CODE#',
        T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#',
        T.BATCH_NO = '#BATCH_NO#',
        T.BATCH_GROUD_NO = '#BATCH_GROUD_NO#',
        T.PROCESS_CODE = '#PROCESS_CODE#',
        T.PLINE_CODE = '#PLINE_CODE#',
        T.ACT_COUNT = '#ACT_COUNT#',
        T.ACT_WEIGHT = '#ACT_WEIGHT#',
        T.ACT_THEORY_WEIGHT = '#ACT_THEORY_WEIGHT#',
        T.PRO_ORDER_ID = '#PRO_ORDER_ID#',
        T.FACE_RESULT_CODE = '#FACE_RESULT_CODE#',
        T.SPEC_RESULT_CODE = '#SPEC_RESULT_CODE#',
        T.CHEM_RESULT_CODE = '#CHEM_RESULT_CODE#',
        T.PHY_RESULT_CODE = '#PHY_RESULT_CODE#',
        T.DETECT_RESULT_CODE = '#DETECT_RESULT_CODE#',
        T.WPRESSURE_RESULT_CODE = '#WPRESSURE_RESULT_CODE#',
        T.PROCESS_RESULT_CODE = '#PROCESS_RESULT_CODE#',
        T.FACE_RESULT_PATH = '#FACE_RESULT_PATH#',
        T.SPEC_RESULT_PATH = '#SPEC_RESULT_PATH#',
        T.CHEM_RESULT_PATH = '#CHEM_RESULT_PATH#',
        T.PHY_RESULT_PATH = '#PHY_RESULT_PATH#',
        T.DETECT_RESULT_PATH = '#DETECT_RESULT_PATH#',
        T.WPRESSURE_RESULT_PATH = '#WPRESSURE_RESULT_PATH#',
        T.PROCESS_RESULT_PATH = '#PROCESS_RESULT_PATH#',
        T.VALIDFLAG = '#VALIDFLAG#',
        T.APPLY_NAME = '#APPLY_NAME#',
        T.APPLY_TIME = SYSDATE,
        T.MEMO = '#MEMO#',
        T.QUALITY_GROUP = '#QUALITY_GROUP#',
        T.MATERIAL_NO = '#MATERIAL_NO#',
        T.MATERIAL_NAME = '#MATERIAL_NAME#',
        T.PRODUCCODE = '#PRODUCCODE#',
        T.PRODUCNAME = '#PRODUCNAME#',
        T.STEELCODE = '#STEELCODE#',
        T.STEELNAME = '#STEELNAME#',
        T.GRADECODE = '#GRADECODE#',
        T.GRADENAME = '#GRADENAME#',
        T.SPEC_CODE = '#SPEC_CODE#',
        T.SPEC_NAME = '#SPEC_NAME#',
        T.MODEL_CODE = '#MODEL_CODE#',
        T.MODEL_DESC = '#MODEL_DESC#',
        T.STD_CODE = '#STD_CODE#',
        T.STD_NAME = '#STD_NAME#',
        T.STD_STYLE = '#STD_STYLE#',
        T.STD_STYLE_DESC = '#STD_STYLE_DESC#',
        T.CRAF_NO = '#CRAF_NO#',
        T.LOT_NO = '#LOT_NO#',
        T.PLINE_NAME = '#PLINE_NAME#',
        T.PRO_ORDER_NO = '#PRO_ORDER_NO#',
        T.TARGET = '#TARGET#',
        T.PROCESS_STATUS = '#PROCESS_STATUS#',
        T.MAT_GOWHERE_CODE = '#MAT_GOWHERE_CODE#',
        T.MAT_GOWHERE_NAME = '#MAT_GOWHERE_NAME#',
        T.ACT_DIMATER = '#ACT_DIMATER#',
        T.ACT_HEIGHT = '#ACT_HEIGHT#',
        T.ACT_LEN_MIN = '#ACT_LEN_MIN#',
        T.ACT_LEN_MAX = '#ACT_LEN_MAX#',
        T.JUDGE_RESULT_CODE = '#JUDGE_RESULT_CODE#',
        T.JUDGE_RESULT = '#JUDGE_RESULT#',
        T.JUDGE_RESULT_TIME = SYSDATE,
        T.JUDGE_MAKER = '#JUDGE_MAKER#',
        T.IF_SET_ZY_PLAN = '#IF_SET_ZY_PLAN#',
        T.TESTING_GRADE = '#TESTING_GRADE#',
        T.TESTING_TYPE = '#TESTING_TYPE#',
        T.TESTING_GRADE1 = '#TESTING_GRADE1#',
        T.TESTING_TYPE1 = '#TESTING_TYPE1#',
        T.DETECT_RESULT_CODE1 = '#DETECT_RESULT_CODE1#',
        T.DETECT_RESULT_PATH1 = '#DETECT_RESULT_PATH1#',
        T.ORD_LN_DLY_PK = '#ORD_LN_DLY_PK#',
        T.APPLY_FLAG = '#APPLY_FLAG#',
        T.BACK_JUGDE_MEMO = '#BACK_JUGDE_MEMO#',
        T.INSTOCK_FLAG = '#INSTOCK_FLAG#',
        T.BELONG_CODE = '#BELONG_CODE#',
        T.BELONG_NAME = '#BELONG_NAME#',
        T.ISENDGX = '#ISENDGX#',
        T.EXIT_TEMP = '#EXIT_TEMP#',
        T.SAMPLE_NEWS = '#SAMPLE_NEWS#',
        T.ACT_LEN = '#ACT_LEN#',
        T.BELONG_CODE_JUGDE = '#BELONG_CODE_JUGDE#',
        T.BELONG_NAME_JUGDE = '#BELONG_NAME_JUGDE#',
        T.GX_PLAN_NO = '#GX_PLAN_NO#',
        T.INPUT_WEIGHT = '#INPUT_WEIGHT#',
        T.INPUT_COUNT = '#INPUT_COUNT#',
        T.OUTPUT_WEIGHT = '#OUTPUT_WEIGHT#',
        T.OUTPUT_COUNT = '#OUTPUT_COUNT#',
        T.BAL_YEAR_MONTH = '#BAL_YEAR_MONTH#',
        T.IS_FLAG = '#IS_FLAG#',
        T.IS_ALL_SCRAP = '#IS_ALL_SCRAP#',
        T.IS_CARRY_VOER = '#IS_CARRY_VOER#'
 WHERE
       T.JUGDE_APPLY_CODE = '#JUGDE_APPLY_CODE#'
       AND T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
       AND T.BATCH_NO = '#BATCH_NO#'
       AND T.BATCH_GROUD_NO = '#BATCH_GROUD_NO#'
       AND T.QUALITY_GROUP = '#QUALITY_GROUP#'
       AND T.MAT_GOWHERE_CODE = '#MAT_GOWHERE_CODE#'
        ]]>
    </query>
    <query id="QcmZgJugdeApplyDAL.GetMaxPk" desc="获取最大主键">
        <![CDATA[
SELECT NVL(MAX(JUGDE_APPLY_CODE), 0) + 1 MAX_VALUE FROM QCM_ZG_JUGDE_APPLY T
        ]]>
    </query>
    <query id="QcmZgJugdeApplyDAL.Delete" desc="作废">
        <![CDATA[
UPDATE QCM_ZG_JUGDE_APPLY T
   SET
       T.VALIDFLAG = '0',
       T.DELETE_NAME = '#DELETE_NAME#',
       T.DELETE_TIME = SYSDATE
WHERE
       T.JUGDE_APPLY_CODE = '#JUGDE_APPLY_CODE#'
       AND T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
       AND T.BATCH_NO = '#BATCH_NO#'
       AND T.BATCH_GROUD_NO = '#BATCH_GROUD_NO#'
       AND T.QUALITY_GROUP = '#QUALITY_GROUP#'
       AND T.MAT_GOWHERE_CODE = '#MAT_GOWHERE_CODE#'
        ]]>
    </query>
    <query id="QcmZgJugdeApplyDAL.Resume" desc="恢复">
        <![CDATA[
UPDATE QCM_ZG_JUGDE_APPLY T
   SET
       T.VALIDFLAG = '1',
       T.DELETE_NAME = NULL,
       T.DELETE_TIME = NULL,
       T.UPDATE_NAME = '#UPDATE_NAME#',
       T.UPDATE_TIME = SYSDATE
WHERE
       T.JUGDE_APPLY_CODE = '#JUGDE_APPLY_CODE#'
       AND T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
       AND T.BATCH_NO = '#BATCH_NO#'
       AND T.BATCH_GROUD_NO = '#BATCH_GROUD_NO#'
       AND T.QUALITY_GROUP = '#QUALITY_GROUP#'
       AND T.MAT_GOWHERE_CODE = '#MAT_GOWHERE_CODE#'
        ]]>
    </query>
    <query id="QcmZgJugdeApplyDAL.updatePhyResult" desc="修改理化结果">
        <![CDATA[
UPDATE QCM_ZG_JUGDE_APPLY T
   SET T.PHY_RESULT_CODE = {4}
 WHERE T.JUGDE_APPLY_CODE = {0}
   AND T.JUDGE_STOVE_NO = {1}
   AND T.BATCH_NO = {2}
   AND T.PROCESS_CODE = {3}
   AND T.IS_FLAG = '0'
   AND T.IS_ALL_SCRAP IN ('0', '4', '5', '6', '7', '8')
        ]]>
    </query>
    
    <query id="QcmZgJugdeApplyDAL.updateJudgeResult" desc="修改综合判定结果">
        <![CDATA[
UPDATE QCM_ZG_JUGDE_APPLY T
   SET T.CHEM_RESULT_CODE   = {3},
       T.PHY_RESULT_CODE    = {4},
       T.DETECT_RESULT_CODE = {5},
       T.DETECT_RESULT_PATH = {6},
       T.FACE_RESULT_CODE   = {7},
       T.FACE_RESULT_PATH   = {8},
       T.JUDGE_RESULT_CODE  = {9},
       T.JUDGE_RESULT       = {10},
       T.JUDGE_RESULT_TIME  = SYSDATE,
       T.JUDGE_MAKER        = {11}
 WHERE T.JUGDE_APPLY_CODE = {0}
   AND T.JUDGE_STOVE_NO = {1}
   AND T.BATCH_NO = {2}
   AND T.IS_FLAG = '0'
   AND T.IS_ALL_SCRAP IN ('0', '4', '5', '6', '7', '8')
        ]]>
    </query>
    
    <query id="QcmZgJugdeApplyDAL.getChemFile" desc="获取成分文件路径">
        <![CDATA[
SELECT T.CHEM_RESULT_PATH, T.CHEM_RESULT_PATH CHEM_FILE, '合格' QUALIFIED
  FROM QCM_ZG_JUGDE_APPLY T
 WHERE T.JUGDE_APPLY_CODE = {0}
   AND T.JUDGE_STOVE_NO = {1}
   AND T.BATCH_NO = {2}
   AND T.IS_FLAG = '0'
   AND T.IS_ALL_SCRAP IN ('0', '4', '5', '6', '7', '8')
   AND T.CHEM_RESULT_PATH IS NOT NULL
        ]]>
    </query>
    
    <query id="QcmZgJugdeApplyDAL.getFaceFile" desc="获取表检文件路径">
        <![CDATA[
SELECT T.FACE_RESULT_PATH, T.FACE_RESULT_PATH FACE_FILE, '合格' QUALIFIED
  FROM QCM_ZG_JUGDE_APPLY T
 WHERE T.JUGDE_APPLY_CODE = {0}
   AND T.JUDGE_STOVE_NO = {1}
   AND T.BATCH_NO = {2}
   AND T.IS_FLAG = '0'
   AND T.IS_ALL_SCRAP IN ('0', '4', '5', '6', '7', '8')
        ]]>
    </query>
    
    <query id="QcmZgJugdeApplyDAL.getDetectFile" desc="获取探伤文件路径">
        <![CDATA[
SELECT T.DETECT_RESULT_PATH, T.DETECT_RESULT_PATH DETECT_FILE, '合格' QUALIFIED
  FROM QCM_ZG_JUGDE_APPLY T
 WHERE T.JUGDE_APPLY_CODE = {0}
   AND T.JUDGE_STOVE_NO = {1}
   AND T.BATCH_NO = {2}
   AND T.IS_FLAG = '0'
   AND T.IS_ALL_SCRAP IN ('0', '4', '5', '6', '7', '8')
        ]]>
    </query>
    
    <query id="QcmZgJugdeApplyDAL.getSpecFile" desc="获取公差文件路径">
        <![CDATA[
SELECT DISTINCT T.SPEC_RESULT_PATH, T.SPEC_RESULT_PATH SPEC_FILE, '合格' QUALIFIED
  FROM QCM_ZG_JUGDE_APPLY T
 WHERE T.JUDGE_STOVE_NO = {0}
   AND T.BATCH_NO = {1}
   AND T.PROCESS_CODE = {2}
   AND T.IS_FLAG = '0'
   AND T.IS_ALL_SCRAP IN ('0', '4', '5', '6', '7', '8')
        ]]>
    </query>
    
    <query id="QcmZgJugdeApplyDAL.getWaterFile" desc="获取水压文件路径">
        <![CDATA[
SELECT T.WPRESSURE_RESULT_PATH WATER_RESULT_PATH, T.WPRESSURE_RESULT_PATH WATER_FILE, '合格' QUALIFIED
  FROM QCM_ZG_JUGDE_APPLY T
 WHERE T.JUGDE_APPLY_CODE = {0}
   AND T.JUDGE_STOVE_NO = {1}
   AND T.BATCH_NO = {2}
   AND T.IS_FLAG = '0'
   AND T.IS_ALL_SCRAP IN ('0', '4', '5', '6', '7', '8')
        ]]>
    </query>
    
    <query id="QcmZgJugdeApplyDAL.getProcessFile" desc="获取加工文件路径">
        <![CDATA[
SELECT T.PROCESS_RESULT_PATH, T.PROCESS_RESULT_PATH PROCESS_FILE, '合格' QUALIFIED
  FROM QCM_ZG_JUGDE_APPLY T
 WHERE T.JUGDE_APPLY_CODE = {0}
   AND T.JUDGE_STOVE_NO = {1}
   AND T.BATCH_NO = {2}
   AND T.IS_FLAG = '0'
   AND T.IS_ALL_SCRAP IN ('0', '4', '5', '6', '7', '8')
        ]]>
    </query>
    
    <query id="QcmZgJugdeApplyDAL.getChemFileZc" desc="获取表检文件路径">
        <![CDATA[
SELECT T2.PROCESS_DESC,
       MIN(T.CHEM_RESULT_PATH) CHEM_RESULT_PATH,
       MIN(T.CHEM_RESULT_PATH) CHEM_FILE, '合格' QUALIFIED
  FROM QCM_ZG_JUGDE_APPLY T
  LEFT JOIN COM_BASE_PROCESS T2
    ON T2.PROCESS_CODE = T.PROCESS_CODE, MAT_BC_QCMTRACK A
 WHERE T.CHEM_RESULT_PATH IS NOT NULL
   AND A.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO
   AND A.BATCH_NO = T.BATCH_NO
   AND T.IS_FLAG = '0'
   AND T.IS_ALL_SCRAP IN ('0', '4', '5', '6', '7', '8')
   AND EXISTS (SELECT 1
          FROM MAT_BC_QCMTRACK B
         WHERE B.JUDGE_STOVE_NO = {0}
           AND B.BATCH_NO = {1}
           AND SUBSTR(B.MAT_NO, 1, 13) = A.MAT_NO)
 GROUP BY T.PROCESS_CODE, T2.PROCESS_DESC
        ]]>
    </query>
    
    <query id="QcmZgJugdeApplyDAL.getFaceFileZc" desc="获取表检文件路径">
        <![CDATA[
SELECT T2.PROCESS_DESC,
       MIN(T.FACE_RESULT_PATH) FACE_RESULT_PATH,
       MIN(T.FACE_RESULT_PATH) FACE_FILE, '合格' QUALIFIED
  FROM QCM_ZG_JUGDE_APPLY T
  LEFT JOIN COM_BASE_PROCESS T2
    ON T2.PROCESS_CODE = T.PROCESS_CODE, MAT_BC_QCMTRACK A
 WHERE T.FACE_RESULT_PATH IS NOT NULL
   AND A.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO
   AND A.BATCH_NO = T.BATCH_NO
   AND T.IS_FLAG = '0'
   AND T.IS_ALL_SCRAP IN ('0', '4', '5', '6', '7', '8')
   AND EXISTS (SELECT 1
          FROM MAT_BC_QCMTRACK B
         WHERE B.JUDGE_STOVE_NO = {0}
           AND B.BATCH_NO = {1}
           AND SUBSTR(B.MAT_NO, 1, 13) = A.MAT_NO)
 GROUP BY T.PROCESS_CODE, T2.PROCESS_DESC
        ]]>
    </query>
    
    <query id="QcmZgJugdeApplyDAL.getSpecFileZc" desc="获取公差文件路径">
        <![CDATA[
SELECT T2.PROCESS_DESC,
       MIN(T.SPEC_RESULT_PATH) SPEC_RESULT_PATH,
       MIN(T.SPEC_RESULT_PATH) SPEC_FILE, '合格' QUALIFIED
  FROM QCM_ZG_JUGDE_APPLY T
  LEFT JOIN COM_BASE_PROCESS T2
    ON T2.PROCESS_CODE = T.PROCESS_CODE, MAT_BC_QCMTRACK A
 WHERE T.SPEC_RESULT_PATH IS NOT NULL
   AND A.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO
   AND A.BATCH_NO = T.BATCH_NO
   AND T.IS_FLAG = '0'
   AND T.IS_ALL_SCRAP IN ('0', '4', '5', '6', '7', '8')
   AND EXISTS (SELECT 1
          FROM MAT_BC_QCMTRACK B
         WHERE B.JUDGE_STOVE_NO = {0}
           AND B.BATCH_NO = {1}
           AND SUBSTR(B.MAT_NO, 1, 13) = A.MAT_NO)
 GROUP BY T.PROCESS_CODE, T2.PROCESS_DESC
        ]]>
    </query>
    
    <query id="QcmZgJugdeApplyDAL.getDetectFileZc" desc="获取探伤文件路径">
        <![CDATA[
SELECT T2.PROCESS_DESC,
       MIN(T.DETECT_RESULT_PATH) DETECT_RESULT_PATH,
       MIN(T.DETECT_RESULT_PATH) DETECT_FILE,
       MIN(T.DETECT_RESULT_PATH1) DETECT_RESULT_PATH2,
       MIN(T.DETECT_RESULT_PATH1) DETECT_FILE2,
        '合格' QUALIFIED
  FROM QCM_ZG_JUGDE_APPLY T
  LEFT JOIN COM_BASE_PROCESS T2
    ON T2.PROCESS_CODE = T.PROCESS_CODE, MAT_BC_QCMTRACK A
 WHERE T.DETECT_RESULT_PATH IS NOT NULL
   AND A.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO
   AND A.BATCH_NO = T.BATCH_NO
   AND T.IS_FLAG = '0'
   AND T.IS_ALL_SCRAP IN ('0', '4', '5', '6', '7', '8')
   AND EXISTS (SELECT 1
          FROM MAT_BC_QCMTRACK B
         WHERE B.JUDGE_STOVE_NO = {0}
           AND B.BATCH_NO = {1}
           AND SUBSTR(B.MAT_NO, 1, 13) = A.MAT_NO)
 GROUP BY T.PROCESS_CODE, T2.PROCESS_DESC
        ]]>
    </query>
    
    <query id="QcmZgJugdeApplyDAL.getWaterFileZc" desc="获取水压文件路径">
        <![CDATA[
SELECT T2.PROCESS_DESC,
       MIN(T.WPRESSURE_RESULT_PATH) WATER_RESULT_PATH,
       MIN(T.WPRESSURE_RESULT_PATH) WATER_FILE, '合格' QUALIFIED
  FROM QCM_ZG_JUGDE_APPLY T
  LEFT JOIN COM_BASE_PROCESS T2
    ON T2.PROCESS_CODE = T.PROCESS_CODE, MAT_BC_QCMTRACK A
 WHERE T.WPRESSURE_RESULT_PATH IS NOT NULL
   AND A.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO
   AND A.BATCH_NO = T.BATCH_NO
   AND T.IS_FLAG = '0'
   AND T.IS_ALL_SCRAP IN ('0', '4', '5', '6', '7', '8')
   AND EXISTS (SELECT 1
          FROM MAT_BC_QCMTRACK B
         WHERE B.JUDGE_STOVE_NO = {0}
           AND B.BATCH_NO = {1}
           AND SUBSTR(B.MAT_NO, 1, 13) = A.MAT_NO)
 GROUP BY T.PROCESS_CODE, T2.PROCESS_DESC
        ]]>
    </query>
    
    <query id="QcmZgJugdeApplyDAL.getProcessFileZc" desc="获取水压文件路径">
        <![CDATA[
SELECT T2.PROCESS_DESC,
       MIN(T.PROCESS_RESULT_PATH) PROCESS_RESULT_PATH,
       MIN(T.PROCESS_RESULT_PATH) PROCESS_FILE, '合格' QUALIFIED
  FROM QCM_ZG_JUGDE_APPLY T
  LEFT JOIN COM_BASE_PROCESS T2
    ON T2.PROCESS_CODE = T.PROCESS_CODE, MAT_BC_QCMTRACK A
 WHERE T.PROCESS_RESULT_PATH IS NOT NULL
   AND A.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO
   AND A.BATCH_NO = T.BATCH_NO
   AND T.IS_FLAG = '0'
   AND T.IS_ALL_SCRAP IN ('0', '4', '5', '6', '7', '8')
   AND EXISTS (SELECT 1
          FROM MAT_BC_QCMTRACK B
         WHERE B.JUDGE_STOVE_NO = {0}
           AND B.BATCH_NO = {1}
           AND SUBSTR(B.MAT_NO, 1, 13) = A.MAT_NO)
 GROUP BY T.PROCESS_CODE, T2.PROCESS_DESC
        ]]>
    </query>
    
    <query id="QcmZgJugdeApplyDAL.querDtlByJudgeStoveNoApplyNo" desc="查询计划轧管表">
		<![CDATA[
SELECT T.ACT_DIMATER,
       T.ACT_HEIGHT,
       T.ACT_LEN,
       T.BATCH_NO,
       T.ACT_COUNT,
       T.ACT_WEIGHT ACT_THEORY_WEIGHT,
       T.GRADENAME,
       T.STEELNAME,
       T.ORD_LN_DLY_PK,
       T.CRAFT_SEQ,
       T.ACT_LEN_MIN || ' - ' || T.ACT_LEN_MAX LENGTH_GROUP,
       /* CASE
         WHEN T.IS_ALL_SCRAP = '4' OR T.PROCESS_CODE <> 'G' THEN
         	T.ACT_LEN_MIN || ' - ' || T.ACT_LEN_MAX
         WHEN B.GROUP_MIN IS NULL THEN
           NULL
         ELSE
           TO_CHAR(B.GROUP_MIN, 'FM99990.000') || ' - ' || TO_CHAR(B.GROUP_MAX, 'FM99990.000')
       END LENGTH_GROUP, */
       T.PROCESS_CODE,
       T.MODEL_DESC,
       T.SPEC_NAME
  FROM QCM_ZG_JUGDE_APPLY T
  LEFT JOIN PLN_SALEORD A
    ON A.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK
   /* LEFT JOIN MCH_GROUPNO B
   ON B.ORDER_NO = A.ORDER_NO || '/' || A.ORDER_SEQ
   AND B.GROUP_NO = T.BATCH_GROUD_NO */
 WHERE T.JUGDE_APPLY_CODE = {0}
   AND T.JUDGE_STOVE_NO = {1}
   AND T.BATCH_NO = {2}
   AND T.IS_FLAG = '0'
   AND T.IS_ALL_SCRAP IN ('0', '4', '5', '6', '7', '8')
   AND ((T.XS_FLAG != '1' AND T.IN_MOLD != '801701') OR T.IN_MOLD IS NULL OR T.XS_FLAG = '1' OR T.SUPPLY_UNIT = '120504' OR T.TARGET != 'A')
 ORDER BY T.BATCH_GROUD_NO
		]]>
	</query>
	
	<query id="QcmZgJugdeApplyDAL.udpateChemResult" desc="修改轧管申请判定表中的成分结果">
		<![CDATA[
UPDATE QCM_ZG_JUGDE_APPLY T
   SET T.CHEM_RESULT_CODE = {4}
 WHERE T.JUGDE_APPLY_CODE = {0}
   AND T.JUDGE_STOVE_NO = {1}
   AND T.BATCH_NO = {2}
   AND T.IS_FLAG = '0'
   AND T.IS_ALL_SCRAP IN ('0', '4', '5', '6', '7', '8')
   AND T.PROCESS_CODE = {3}
		]]>
	</query>
	
	<query id="QcmZgJugdeApplyDAL.udpatePhyResult" desc="修改轧管申请判定表中的理化结果">
		<![CDATA[
UPDATE QCM_ZG_JUGDE_APPLY T
   SET T.PHY_RESULT_CODE = {4}
 WHERE T.JUGDE_APPLY_CODE = {0}
   AND T.JUDGE_STOVE_NO = {1}
   AND T.BATCH_NO = {2}
   AND T.IS_FLAG = '0'
   AND T.IS_ALL_SCRAP IN ('0', '4', '5', '6', '7', '8')
   AND T.PROCESS_CODE = {3}
		]]>
	</query>
	
	<query id="QcmZgJugdeApplyDAL.existJudgeQualified" desc="是否已判合格">
		<![CDATA[
SELECT JUDGE_RESULT_CODE, JUDGE_RESULT,ORD_LN_DLY_PK
  FROM QCM_ZG_JUGDE_APPLY T
 WHERE T.JUGDE_APPLY_CODE = {0}
   AND T.JUDGE_STOVE_NO = {1}
   AND T.BATCH_NO = {2}
   AND T.PROCESS_CODE = {3}
   AND T.IS_FLAG = '0'
   AND T.IS_ALL_SCRAP IN ('0', '4', '5', '6', '7', '8')
		]]>
	</query>
	
	<query id="QcmZgJugdeApplyDAL.existJudgeQualifiedZc" desc="是否已判合格">
		<![CDATA[
SELECT JUDGE_TOLRESULT_CODE, JUDGE_TOLRESULT, LENGTH_TYPE
  FROM QCM_ZG_JUGDE_APPLY T
 WHERE T.JUGDE_APPLY_CODE = {0}
   AND T.JUDGE_STOVE_NO = {1}
   AND T.BATCH_NO = {2}
   AND T.PROCESS_CODE = {3}
   AND T.IS_FLAG = '0'
   AND T.IS_ALL_SCRAP IN ('0', '4', '5', '6', '7', '8')
		]]>
	</query>

	<query id="QcmZgJugdeApplyDAL.setJudgeResult" desc="回写综合判定记录">
		<![CDATA[
UPDATE QCM_ZG_JUGDE_APPLY T
   SET T.JUDGE_RESULT_CODE     = {4},
       T.JUDGE_RESULT         =
       (SELECT BASENAME FROM COM_BASE_INFO A WHERE A.BASECODE = {4}),
       T.JUDGE_MAKER           = {5},
       T.JUDGE_ORDER           = {6},
       T.JUDGE_GROUP           = {7},
       T.FACE_RESULT_CODE      = NVL({8}, T.FACE_RESULT_CODE),
       T.DETECT_RESULT_CODE    = NVL({9}, T.DETECT_RESULT_CODE),
       T.SPEC_RESULT_CODE      = {10},
       T.WPRESSURE_RESULT_CODE = {11},
       T.PROCESS_RESULT_CODE   = {12},
       T.VALIDFLAG             = {13},
       T.JUDGE_MEMO            = {14},
       T.JUGDE_CONVICTED = {15},
       T.CHEM_RESULT_CODE = {16},
       T.PHY_RESULT_CODE = {17},
       T.JUDGE_FILE_MEMO = {18}
 WHERE T.JUGDE_APPLY_CODE = {0}
   AND T.JUDGE_STOVE_NO = {1}
   AND T.BATCH_NO = {2}
   AND T.PROCESS_CODE = {3}
   AND T.IS_FLAG = '0'
   AND T.IS_ALL_SCRAP IN ('0', '4', '5', '6', '7', '8')
		]]>
	</query>
	
	<query id="QcmZgJugdeApplyDAL.setJudgeTime" desc="回写综合判定时间">
		<![CDATA[
UPDATE QCM_ZG_JUGDE_APPLY T
   SET T.JUDGE_RESULT_TIME = TO_DATE(DECODE({4}, NULL, NULL, TO_CHAR(SYSDATE, 'YYYY-MM-DD HH24:MI:SS')), 'YYYY-MM-DD HH24:MI:SS')
 WHERE T.JUGDE_APPLY_CODE = {0}
   AND T.JUDGE_STOVE_NO = {1}
   AND T.BATCH_NO = {2}
   AND T.PROCESS_CODE = {3}
   AND T.IS_FLAG = '0'
   AND T.IS_ALL_SCRAP IN ('0', '4', '5', '6', '7', '8')
		]]>
	</query>
	
	<query id="QcmZgJugdeApplyDAL.setInstancyFlag" desc="修改紧急放行标志">
		<![CDATA[
UPDATE QCM_ZG_JUGDE_APPLY T
   SET T.INSTANCY_FLAG = {4}
 WHERE T.JUGDE_APPLY_CODE = {0}
   AND T.JUDGE_STOVE_NO = {1}
   AND T.BATCH_NO = {2}
   AND T.PROCESS_CODE = {3}
   AND T.IS_FLAG = '0'
   AND T.IS_ALL_SCRAP IN ('0', '4', '5', '6', '7', '8')
		]]>
	</query>
	
	<query id="QcmZgJugdeApplyDAL.setTolInstancyFlag" desc="修改紧急放行标志">
		<![CDATA[
UPDATE QCM_ZG_JUGDE_APPLY T
   SET T.TOL_INSTANCY_FLAG = {4}
 WHERE T.JUGDE_APPLY_CODE = {0}
   AND T.JUDGE_STOVE_NO = {1}
   AND T.BATCH_NO = {2}
   AND T.PROCESS_CODE = {3}
   AND T.IS_FLAG = '0'
   AND T.IS_ALL_SCRAP IN ('0', '4', '5', '6', '7', '8')
		]]>
	</query>
	
	<query id="QcmZgJugdeApplyDAL.setBalYearMonth" desc="修改结转年月">
		<![CDATA[
UPDATE QCM_ZG_JUGDE_APPLY T
   SET T.BAL_YEAR_MONTH = DECODE( T.INSTOCK_FLAG, '1', T.BAL_YEAR_MONTH, {4} )
 WHERE T.JUGDE_APPLY_CODE = {0}
   AND T.JUDGE_STOVE_NO = {1}
   AND T.BATCH_NO = {2}
   AND T.PROCESS_CODE = {3}
   AND T.IS_FLAG = '0'
   AND T.IS_ALL_SCRAP IN ('0', '4', '5', '6', '7', '8')
		]]>
	</query>
	
	<query id="QcmZgJugdeApplyDAL.setAuditResult" desc="修改放行处置方式">
		<![CDATA[
UPDATE QCM_ZG_JUGDE_APPLY T
   SET T.AUDIT_RESULT = {4}, T.AUDIT_MEMO = {5}, T.INSTANCY_FLAG = {6}
 WHERE T.JUGDE_APPLY_CODE = {0}
   AND T.JUDGE_STOVE_NO = {1}
   AND T.BATCH_NO = {2}
   AND T.PROCESS_CODE = {3}
   AND T.IS_FLAG = '0'
   AND T.IS_ALL_SCRAP IN ('0', '4', '5', '6', '7', '8')
		]]>
	</query>
	
	<query id="QcmZgJugdeApplyDAL.setValidflag" desc="修改申请表状态">
		<![CDATA[
UPDATE QCM_ZG_JUGDE_APPLY T
   SET T.VALIDFLAG = {4},
       T.JUDGE_RESULT_CODE = NULL,
       T.JUDGE_RESULT = NULL
 WHERE T.JUGDE_APPLY_CODE = {0}
   AND T.JUDGE_STOVE_NO = {1}
   AND T.BATCH_NO = {2}
   AND T.PROCESS_CODE = {3}
   AND T.IS_FLAG = '0'
   AND T.IS_ALL_SCRAP IN ('0', '4', '5', '6', '7', '8')
		]]>
	</query>

    <query id="QcmZgJugdeApplyDAL.setValidflagZc" desc="修改申请表状态">
        <![CDATA[
UPDATE QCM_ZG_JUGDE_APPLY T
   SET T.VALIDFLAG = {4},
       T.JUDGE_TOLRESULT_CODE = NULL,
       T.JUDGE_TOLRESULT = NULL
 WHERE T.JUGDE_APPLY_CODE = {0}
   AND T.JUDGE_STOVE_NO = {1}
   AND T.BATCH_NO = {2}
   AND T.PROCESS_CODE = {3}
   AND T.IS_FLAG = '0'
   AND T.IS_ALL_SCRAP IN ('0', '4', '5', '6', '7', '8')
		]]>
    </query>
	
	<query id="QcmZgJugdeApplyDAL.udpateJudgeMemo" desc="修改判定备注">
		<![CDATA[
UPDATE QCM_ZG_JUGDE_APPLY T
   SET T.JUDGE_FILE_MEMO = {4},
       T.JUDGE_MEMO = {5}
 WHERE T.JUGDE_APPLY_CODE = {0}
   AND T.JUDGE_STOVE_NO = {1}
   AND T.BATCH_NO = {2}
   AND T.PROCESS_CODE = {3}
   AND T.IS_FLAG = '0'
   AND T.IS_ALL_SCRAP IN ('0', '4', '5', '6', '7', '8')
		]]>
	</query>
	
	<query id="QcmZgJugdeApplyDAL.udpateJudgeTolMemo" desc="修改判定备注">
		<![CDATA[
UPDATE QCM_ZG_JUGDE_APPLY T
   SET T.JUDGE_FILE_TOLMEMO = {4},
       T.JUDGE_TOLMEMO = {5}
 WHERE T.JUGDE_APPLY_CODE = {0}
   AND T.JUDGE_STOVE_NO = {1}
   AND T.BATCH_NO = {2}
   AND T.PROCESS_CODE = {3}
   AND T.IS_FLAG = '0'
   AND T.IS_ALL_SCRAP IN ('0', '4', '5', '6', '7', '8')
		]]>
	</query>
	
	<query id="QcmZgJugdeApplyDAL.setAuditResultZc" desc="修改放行处置方式">
		<![CDATA[
UPDATE QCM_ZG_JUGDE_APPLY T
   SET T.AUDIT_TOLRESULT = {4}, T.AUDIT_TOLMEMO = {5}, T.TOL_INSTANCY_FLAG = {6}
 WHERE T.JUGDE_APPLY_CODE = {0}
   AND T.JUDGE_STOVE_NO = {1}
   AND T.BATCH_NO = {2}
   AND T.PROCESS_CODE = {3}
   AND T.IS_FLAG = '0'
   AND T.IS_ALL_SCRAP IN ('0', '4', '5', '6', '7', '8')
		]]>
	</query>

    <query id="QcmZgJugdeApplyDAL.getLengthType" desc="长短尺重量">
        <![CDATA[
SELECT
	Z.LENGTH_TYPE,
	SUM( ACT_WEIGHT ) ACT_WEIGHT,
	MAX( LEN_MIN ) LEN_MIN,
	MAX( LEN_MAX ) LEN_MAX,
	MAX( PRDCT_WGT ) PRDCT_WGT,
	MAX( SHRT_LEN_WEIGHT ) SHRT_LEN_WEIGHT,
	MAX( LONG_LEN_WEIGHT ) LONG_LEN_WEIGHT
FROM
	(
	SELECT
		'正尺' LENGTH_TYPE,
		A.ACT_LEN_MIN,
		CASE t1.LEN_UNIT
			WHEN '英尺' THEN
				round(T1.LEN_MIN * 0.3048,3)
			ELSE
				T1.LEN_MIN
		END LEN_MIN,
		A.ACT_LEN_MAX,
		CASE t1.LEN_UNIT
			WHEN '英尺' THEN
				round(T1.LEN_MAX * 0.3048,3)
			ELSE
				T1.LEN_MAX
		END LEN_MAX,
		A.ACT_WEIGHT,
		T1.DELVRY_RANGE_MAX / 100 * T1.PRDCT_WGT + T1.PRDCT_WGT PRDCT_WGT,
		NVL(T1.SHRT_LEN_RATO / 100 * T1.PRDCT_WGT * T1.DELVRY_RANGE_MAX,0) SHRT_LEN_WEIGHT,
		NVL(T1.LONG_LEN_RATO / 100 * T1.PRDCT_WGT * T1.DELVRY_RANGE_MAX,0)  LONG_LEN_WEIGHT
	FROM
		QCM_ZG_JUGDE_APPLY A
		LEFT JOIN SLM_ORDER_LINE_DELIVERY T ON A.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK
		LEFT JOIN SLM_ORDER_LINE T1 ON T.ORD_LN_PK = T1.ORD_LN_PK
	WHERE
		T.VALIDFLAG = '1'
		AND T1.VALIDFLAG = '1'
		AND A.TARGET = 'A'
		AND A.JUDGE_TOLRESULT_CODE IS NOT NULL
		AND (A.ACT_LEN_MIN >= T1.LEN_MAX  OR (t1.LEN_UNIT = '英尺' AND A.ACT_LEN_MIN >= round(T1.LEN_MAX * 0.3048,3)))
		AND (A.ACT_LEN_MAX <= T1.LEN_MIN OR (t1.LEN_UNIT = '英尺' AND A.ACT_LEN_MAX <= 	round(T1.LEN_MIN * 0.3048,3)))
		AND T1.ORD_LN_PK = {0} UNION ALL
	SELECT
		'短尺' LENGTH_TYPE,
		A.ACT_LEN_MIN,
		CASE t1.LEN_UNIT
			WHEN '英尺' THEN
				round(T1.LEN_MIN * 0.3048,3)
			ELSE
				T1.LEN_MIN
		END LEN_MIN,
		A.ACT_LEN_MAX,
		CASE t1.LEN_UNIT
			WHEN '英尺' THEN
				round(T1.LEN_MAX * 0.3048,3)
			ELSE
				T1.LEN_MAX
		END LEN_MAX,
		A.ACT_WEIGHT,
		T1.DELVRY_RANGE_MAX / 100 * T1.PRDCT_WGT + T1.PRDCT_WGT PRDCT_WGT,
		NVL(T1.SHRT_LEN_RATO / 100 * T1.PRDCT_WGT * T1.DELVRY_RANGE_MAX,0) SHRT_LEN_WEIGHT,
		NVL(T1.LONG_LEN_RATO / 100 * T1.PRDCT_WGT * T1.DELVRY_RANGE_MAX,0)  LONG_LEN_WEIGHT
	FROM
		QCM_ZG_JUGDE_APPLY A
		LEFT JOIN SLM_ORDER_LINE_DELIVERY T ON A.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK
		LEFT JOIN SLM_ORDER_LINE T1 ON T.ORD_LN_PK = T1.ORD_LN_PK
	WHERE
		T.VALIDFLAG = '1'
		AND T1.VALIDFLAG = '1'
		AND A.TARGET = 'A'
		AND A.JUDGE_TOLRESULT_CODE IS NOT NULL
		AND (A.ACT_LEN_MAX <= T1.LEN_MIN OR (t1.LEN_UNIT = '英尺' AND A.ACT_LEN_MAX <= 	round(T1.LEN_MIN * 0.3048,3)))
		AND T1.ORD_LN_PK = {0} UNION ALL
	SELECT
		'长尺' LENGTH_TYPE,
		A.ACT_LEN_MIN,
		CASE t1.LEN_UNIT
			WHEN '英尺' THEN
				round(T1.LEN_MIN * 0.3048,3)
			ELSE
				T1.LEN_MIN
		END LEN_MIN,
		A.ACT_LEN_MAX,
		CASE t1.LEN_UNIT
			WHEN '英尺' THEN
				round(T1.LEN_MAX * 0.3048,3)
			ELSE
				T1.LEN_MAX
		END LEN_MAX,
		A.ACT_WEIGHT,
		T1.DELVRY_RANGE_MAX / 100 * T1.PRDCT_WGT + T1.PRDCT_WGT PRDCT_WGT,
		NVL(T1.SHRT_LEN_RATO / 100 * T1.PRDCT_WGT * T1.DELVRY_RANGE_MAX,0) SHRT_LEN_WEIGHT,
		NVL(T1.LONG_LEN_RATO / 100 * T1.PRDCT_WGT * T1.DELVRY_RANGE_MAX,0)  LONG_LEN_WEIGHT
	FROM
		QCM_ZG_JUGDE_APPLY A
		LEFT JOIN SLM_ORDER_LINE_DELIVERY T ON A.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK
		LEFT JOIN SLM_ORDER_LINE T1 ON T.ORD_LN_PK = T1.ORD_LN_PK
	WHERE
		T.VALIDFLAG = '1'
		AND T1.VALIDFLAG = '1'
		AND A.TARGET = 'A'
		AND A.JUDGE_TOLRESULT_CODE IS NOT NULL
		AND (A.ACT_LEN_MIN >= T1.LEN_MAX  OR (t1.LEN_UNIT = '英尺' AND A.ACT_LEN_MIN >= round(T1.LEN_MAX * 0.3048,3)))
		AND T1.ORD_LN_PK = {0}
	) Z
GROUP BY
	Z.LENGTH_TYPE
		]]>
    </query>

    <query id="QcmZgJugdeApplyDAL.getLengthType1" desc="长短尺">
        <![CDATA[
SELECT
	Z.LENGTH_TYPE,
	'0' ACT_WEIGHT,
	MAX( LEN_MIN ) LEN_MIN,
	MAX( LEN_MAX ) LEN_MAX,
	MAX( PRDCT_WGT ) PRDCT_WGT,
	MAX( SHRT_LEN_WEIGHT ) SHRT_LEN_WEIGHT,
	MAX( LONG_LEN_WEIGHT ) LONG_LEN_WEIGHT
FROM
	(
	SELECT
		'正尺' LENGTH_TYPE,
		A.ACT_LEN_MIN,
		CASE t1.LEN_UNIT
			WHEN '英尺' THEN
				round(T1.LEN_MIN * 0.3048,3)
			ELSE
				T1.LEN_MIN
		END LEN_MIN,
		A.ACT_LEN_MAX,
		CASE t1.LEN_UNIT
			WHEN '英尺' THEN
				round(T1.LEN_MAX * 0.3048,3)
			ELSE
				T1.LEN_MAX
		END LEN_MAX,
		A.ACT_WEIGHT,
		T1.DELVRY_RANGE_MAX / 100 * T1.PRDCT_WGT + T1.PRDCT_WGT PRDCT_WGT,
		NVL(T1.SHRT_LEN_RATO / 100 * T1.PRDCT_WGT * T1.DELVRY_RANGE_MAX,0) SHRT_LEN_WEIGHT,
		NVL(T1.LONG_LEN_RATO / 100 * T1.PRDCT_WGT * T1.DELVRY_RANGE_MAX,0)  LONG_LEN_WEIGHT
	FROM
		QCM_ZG_JUGDE_APPLY A
		LEFT JOIN SLM_ORDER_LINE_DELIVERY T ON A.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK
		LEFT JOIN SLM_ORDER_LINE T1 ON T.ORD_LN_PK = T1.ORD_LN_PK
	WHERE
		T.VALIDFLAG = '1'
		AND T1.VALIDFLAG = '1'
		AND A.TARGET = 'A'
		--AND A.JUDGE_TOLRESULT_CODE IS NOT NULL
		AND (A.ACT_LEN_MIN >= T1.LEN_MAX  OR (t1.LEN_UNIT = '英尺' AND A.ACT_LEN_MIN >= round(T1.LEN_MAX * 0.3048,3)))
		AND (A.ACT_LEN_MAX <= T1.LEN_MIN OR (t1.LEN_UNIT = '英尺' AND A.ACT_LEN_MAX <= 	round(T1.LEN_MIN * 0.3048,3)))
		AND T1.ORD_LN_PK = {0} UNION ALL
	SELECT
		'短尺' LENGTH_TYPE,
		A.ACT_LEN_MIN,
		CASE t1.LEN_UNIT
			WHEN '英尺' THEN
				round(T1.LEN_MIN * 0.3048,3)
			ELSE
				T1.LEN_MIN
		END LEN_MIN,
		A.ACT_LEN_MAX,
		CASE t1.LEN_UNIT
			WHEN '英尺' THEN
				round(T1.LEN_MAX * 0.3048,3)
			ELSE
				T1.LEN_MAX
		END LEN_MAX,
		A.ACT_WEIGHT,
		T1.DELVRY_RANGE_MAX / 100 * T1.PRDCT_WGT + T1.PRDCT_WGT PRDCT_WGT,
		NVL(T1.SHRT_LEN_RATO / 100 * T1.PRDCT_WGT * T1.DELVRY_RANGE_MAX,0) SHRT_LEN_WEIGHT,
		NVL(T1.LONG_LEN_RATO / 100 * T1.PRDCT_WGT * T1.DELVRY_RANGE_MAX,0)  LONG_LEN_WEIGHT
	FROM
		QCM_ZG_JUGDE_APPLY A
		LEFT JOIN SLM_ORDER_LINE_DELIVERY T ON A.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK
		LEFT JOIN SLM_ORDER_LINE T1 ON T.ORD_LN_PK = T1.ORD_LN_PK
	WHERE
		T.VALIDFLAG = '1'
		AND T1.VALIDFLAG = '1'
		AND A.TARGET = 'A'
		--AND A.JUDGE_TOLRESULT_CODE IS NOT NULL
		AND (A.ACT_LEN_MAX <= T1.LEN_MIN OR (t1.LEN_UNIT = '英尺' AND A.ACT_LEN_MAX <= 	round(T1.LEN_MIN * 0.3048,3)))
		AND T1.ORD_LN_PK = {0} UNION ALL
	SELECT
		'长尺' LENGTH_TYPE,
		A.ACT_LEN_MIN,
		CASE t1.LEN_UNIT
			WHEN '英尺' THEN
				round(T1.LEN_MIN * 0.3048,3)
			ELSE
				T1.LEN_MIN
		END LEN_MIN,
		A.ACT_LEN_MAX,
		CASE t1.LEN_UNIT
			WHEN '英尺' THEN
				round(T1.LEN_MAX * 0.3048,3)
			ELSE
				T1.LEN_MAX
		END LEN_MAX,
		A.ACT_WEIGHT,
		T1.DELVRY_RANGE_MAX / 100 * T1.PRDCT_WGT + T1.PRDCT_WGT PRDCT_WGT,
		NVL(T1.SHRT_LEN_RATO / 100 * T1.PRDCT_WGT * T1.DELVRY_RANGE_MAX,0) SHRT_LEN_WEIGHT,
		NVL(T1.LONG_LEN_RATO / 100 * T1.PRDCT_WGT * T1.DELVRY_RANGE_MAX,0)  LONG_LEN_WEIGHT
	FROM
		QCM_ZG_JUGDE_APPLY A
		LEFT JOIN SLM_ORDER_LINE_DELIVERY T ON A.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK
		LEFT JOIN SLM_ORDER_LINE T1 ON T.ORD_LN_PK = T1.ORD_LN_PK
	WHERE
		T.VALIDFLAG = '1'
		AND T1.VALIDFLAG = '1'
		AND A.TARGET = 'A'
		--AND A.JUDGE_TOLRESULT_CODE IS NOT NULL
		AND (A.ACT_LEN_MIN >= T1.LEN_MAX  OR (t1.LEN_UNIT = '英尺' AND A.ACT_LEN_MIN >= round(T1.LEN_MAX * 0.3048,3)))
		AND T1.ORD_LN_PK = {0}
	) Z
GROUP BY
	Z.LENGTH_TYPE
		]]>
    </query>

	<query id="QcmZgJugdeApplyDAL.setJudgeResultZc" desc="回写综合判定记录">
		<![CDATA[
UPDATE QCM_ZG_JUGDE_APPLY T
   SET T.JUDGE_TOLRESULT_CODE = {4},
       T.JUDGE_TOLRESULT     =
       (SELECT BASENAME FROM COM_BASE_INFO A WHERE A.BASECODE = {4}),
       T.JUDGE_TOLMAKER       = {5},
       T.JUDGE_TOLORDER       = {6},
       T.JUDGE_TOLGROUP       = {7},
       T.JUDGE_TOLMEMO        = {8},
       T.JUGDE_TOLCONVICTED = {9},
       T.JUDGE_FILE_TOLMEMO = {10},
       T.ZC_JUDGE_CONDITION = {11}
 WHERE T.JUGDE_APPLY_CODE = {0}
   AND T.JUDGE_STOVE_NO = {1}
   AND T.BATCH_NO = {2}
   AND T.PROCESS_CODE = {3}
   AND T.IS_FLAG = '0'
   AND T.IS_ALL_SCRAP IN ('0', '4', '5', '6', '7', '8')
		]]>
	</query>

    <query id="QcmZgJugdeApplyDAL.setInStorageZc" desc="回写综合判定记录">
        <![CDATA[
UPDATE QCM_ZG_JUGDE_APPLY T
   SET T.IN_STORAGE_TYPE = {5},
       T.IN_STORAGE_WEIGHT = {6},
       T.IN_LENGTH_TYPE = {7},
       T.IN_STORAGE_FLAG = {8},
       T.IN_STORAGE_CONFIRM = DECODE({8},'1','SYSTEM',''),
       T.IN_STORAGE_TIME = SYSDATE
 WHERE T.JUGDE_APPLY_CODE = {0}
   AND T.JUDGE_STOVE_NO = {1}
   AND T.BATCH_NO = {2}
   AND T.PROCESS_CODE = {3}
   AND T.JUGDE_APPLY_SEQUENO = {4}
   AND T.IS_FLAG = '0'
   AND T.IS_ALL_SCRAP IN ('0', '4', '5', '6', '7', '8')
		]]>
    </query>
	
	<query id="QcmZgJugdeApplyDAL.setJudgeTimeZc" desc="回写综合判定时间">
		<![CDATA[
UPDATE QCM_ZG_JUGDE_APPLY T
   SET T.JUDGE_TOLRESULT_TIME = TO_DATE(DECODE({4}, NULL, NULL, TO_CHAR(SYSDATE, 'YYYY-MM-DD HH24:MI:SS')), 'YYYY-MM-DD HH24:MI:SS')
 WHERE T.JUGDE_APPLY_CODE = {0}
   AND T.JUDGE_STOVE_NO = {1}
   AND T.BATCH_NO = {2}
   AND T.PROCESS_CODE = {3}
   AND T.IS_FLAG = '0'
   AND T.IS_ALL_SCRAP IN ('0', '4', '5', '6', '7', '8')
		]]>
	</query>
	
	<query id="QcmZgJugdeApplyDAL.PhyFailQuery1" desc="理化不合查询">
		<![CDATA[
SELECT DECODE(MIN(A.AUDIT_RESULT),
              '',
              '复验合格',
              '407501',
              '复验合格',
              MIN(A1.BASENAME)) 处理结果,
       MIN(A.JUDGE_STOVE_NO) 判定炉号,
       MIN(A.BATCH_NO) 性能批号,
       MIN(A.PLINE_NAME) 产线,
       MIN(A.STEELNAME) 钢级,
       MIN(A.GRADENAME) 钢种,
       MIN(A.PRODUCNAME) 品名,
       MIN(A.STD_NAME) 标准类别,
       MIN(A.ACT_DIMATER) 外径,
       MIN(A.ACT_HEIGHT) 壁厚,
       SUM(A.ACT_COUNT) 判定支,
       DECODE(SUM(A.ACT_WEIGHT),
              '',
              SUM(A.ACT_THEORY_WEIGHT),
              SUM(A.ACT_WEIGHT)) 判定吨,
       MIN(C.ORDER_NO || '/' || C.ORDER_SEQ) 合同号,
       MIN(A.CRAF_NO) 标准,
       MIN(TO_CHAR(A.JUDGE_RESULT_TIME, 'YYYY-MM-DD HH24:MI:SS')) 判定日期,
       (SELECT DECODE(MIN(CYCLES_FLAG),'0','否','是') FROM QCM_ZC_CHECKCONSIGN WHERE JUDGE_STOVE_NO = A.JUDGE_STOVE_NO
            and BATCH_NO = a.BATCH_NO) 是否重新热处理,
       MIN(A.BAL_YEAR_MONTH) 结转年月
  FROM QCM_ZG_JUGDE_APPLY A
  LEFT JOIN COM_BASE_INFO A1
    ON A1.BASECODE = A.AUDIT_RESULT, QCM_BC_BATCH_RESULT B, PLN_SALEORD C
 WHERE A.IS_FLAG = '0'
   AND (A.VALIDFLAG = '20' OR
       (A.VALIDFLAG = '00' AND A.INSTANCY_FLAG = '1'))
   AND A.JUDGE_STOVE_NO = B.JUDGE_STOVE_NO
   AND A.BATCH_NO = B.BATCH_NO
   AND A.PROCESS_CODE = B.PROCESS_CODE
   AND B.CRAFT_SOURCE = '0'
   AND (-- A.JUDGE_RESULT_CODE = '40740701' AND
        A.AUDIT_RESULT <> '407501' OR
       -- A.JUDGE_RESULT_CODE = '40740701' AND
       EXISTS(SELECT 1 FROM QCM_ZC_CHECKCONSIGN C
       WHERE C.JUDGE_STOVE_NO = B.JUDGE_STOVE_NO
       AND C.BATCH_NO = B.BATCH_NO
       AND C.PROCESS_CODE = B.PROCESS_CODE
       AND C.CHECK_NO LIKE 'F%'))
   AND ({0} = '0' OR A.PLINE_CODE IN {1})
   AND A.BAL_YEAR_MONTH >= {2}
   AND A.BAL_YEAR_MONTH <= {3}
   AND A.IS_FLAG = '0'
   AND A.IS_ALL_SCRAP IN ('0', '4', '5', '6', '7', '8')
   AND C.ORD_LN_DLY_PK = A.ORD_LN_DLY_PK
 GROUP BY A.JUDGE_STOVE_NO, A.BATCH_NO
		]]>
	</query>
	
	<query id="QcmZgJugdeApplyDAL.PhyFailQuery2" desc="理化不合查询2">
		<![CDATA[
SELECT A2.JUDGE_STOVE_NO 判定炉号,
       A2.BATCH_NO 性能批号,
       LISTAGG(E.CHEM_NAME, '、') WITHIN GROUP(ORDER BY E.CHEM_NAME) "成分不合格项（初验）",
       LISTAGG(E.CHEM_VALUE, '、') WITHIN GROUP(ORDER BY E.CHEM_VALUE) "成分数值（初验）",
       LISTAGG(DECODE(E.NK_MIN,
                      '',
                      '无要求',
                      REPLACE(REPLACE(E.NK_MIN, '>', ''), '=', '')) || '-' ||
               DECODE(E.NK_MAX,
                      '',
                      '无要求',
                      REPLACE(REPLACE(E.NK_MAX, '<', ''), '=', '')),
               '、') WITHIN GROUP(ORDER BY E.NK_MIN, E.NK_MAX) "成分标准范围（初验）"
  FROM (SELECT A.JUDGE_STOVE_NO,
               A.BATCH_NO,
               MIN(A.PROCESS_CODE) PROCESS_CODE
          FROM QCM_ZG_JUGDE_APPLY A
          LEFT JOIN COM_BASE_INFO A1
            ON A1.BASECODE = A.AUDIT_RESULT, QCM_BC_BATCH_RESULT B
         WHERE A.IS_FLAG = '0'
           AND A.IS_ALL_SCRAP IN ('0', '4', '5', '6', '7', '8')
           AND (A.VALIDFLAG = '20' OR
               (A.VALIDFLAG = '00' AND A.INSTANCY_FLAG = '1'))
           AND A.JUDGE_STOVE_NO = B.JUDGE_STOVE_NO
           AND A.BATCH_NO = B.BATCH_NO
           AND A.PROCESS_CODE = B.PROCESS_CODE
           AND B.CRAFT_SOURCE = '0'
           AND (-- A.JUDGE_RESULT_CODE = '40740701' AND
               A.AUDIT_RESULT <> '407501' OR
               -- A.JUDGE_RESULT_CODE = '40740701' AND
               EXISTS(SELECT 1 FROM QCM_ZC_CHECKCONSIGN C
       WHERE C.JUDGE_STOVE_NO = B.JUDGE_STOVE_NO
       AND C.BATCH_NO = B.BATCH_NO
       AND C.PROCESS_CODE = B.PROCESS_CODE
       AND C.CHECK_NO LIKE 'F%'))
           AND ({0} = '0' OR A.PLINE_CODE IN {1})
           AND A.BAL_YEAR_MONTH >= {2}
           AND A.BAL_YEAR_MONTH <= {3}
         GROUP BY A.JUDGE_STOVE_NO, A.BATCH_NO) A2,
       QCM_BC_CHEMJUDGE D,
       QCM_BC_CHEM_RESULT E
 WHERE D.JUDGE_STOVE_NO = A2.JUDGE_STOVE_NO
   AND D.BATCH_NO = A2.BATCH_NO
   AND D.PROCESS_CDOE = A2.PROCESS_CODE
   AND D.VALIDFLAG = '1'
   AND D.SAMPLE_TYPE = '1'
   AND D.CRAFT_SOURCE = '0'
   AND E.CHEM_JUDGE_ID = D.CHEM_JUDGE_ID
   AND E.JUDGE_SEQ = D.JUDGE_SEQ
   AND E.NK_QUALIFIED IN ('0', '2', '3')
 GROUP BY A2.JUDGE_STOVE_NO, A2.BATCH_NO
		]]>
	</query>
	
	<query id="QcmZgJugdeApplyDAL.PhyFailQuery3" desc="理化不合查询2">
		<![CDATA[
SELECT A2.JUDGE_STOVE_NO 判定炉号,
        A2.BATCH_NO 性能批号,
        LISTAGG(E.CHEM_NAME, '、') WITHIN GROUP(ORDER BY E.CHEM_NAME) "成分不合格项（复验）",
        LISTAGG(E.CHEM_VALUE, '、') WITHIN GROUP(ORDER BY E.CHEM_VALUE) "成分数值（复验）",
        LISTAGG(DECODE(E.NK_MIN,
                       '',
                       '无要求',
                       REPLACE(REPLACE(E.NK_MIN, '>', ''), '=', '')) || '-' ||
                DECODE(E.NK_MAX,
                       '',
                       '无要求',
                       REPLACE(REPLACE(E.NK_MAX, '<', ''), '=', '')),
                '、') WITHIN GROUP(ORDER BY E.NK_MIN, E.NK_MAX) "成分标准范围（复验）"
   FROM (SELECT A.JUDGE_STOVE_NO,
                A.BATCH_NO,
                MIN(A.PROCESS_CODE) PROCESS_CODE
           FROM QCM_ZG_JUGDE_APPLY A
           LEFT JOIN COM_BASE_INFO A1
             ON A1.BASECODE = A.AUDIT_RESULT, QCM_BC_BATCH_RESULT B
          WHERE A.IS_FLAG = '0'
            AND A.IS_ALL_SCRAP IN ('0', '4', '5', '6', '7', '8')
            AND (A.VALIDFLAG = '20' OR
                (A.VALIDFLAG = '00' AND A.INSTANCY_FLAG = '1'))
            AND A.JUDGE_STOVE_NO = B.JUDGE_STOVE_NO
            AND A.BATCH_NO = B.BATCH_NO
            AND A.PROCESS_CODE = B.PROCESS_CODE
            AND B.CRAFT_SOURCE = '0'
            AND (-- A.JUDGE_RESULT_CODE = '40740701' AND
                A.AUDIT_RESULT <> '407501' OR
                -- A.JUDGE_RESULT_CODE = '40740701' AND
                EXISTS
                 (SELECT 1
                    FROM QCM_ZC_CHECKCONSIGN C
                   WHERE C.JUDGE_STOVE_NO = B.JUDGE_STOVE_NO
                     AND C.BATCH_NO = B.BATCH_NO
                     AND C.PROCESS_CODE = B.PROCESS_CODE
                     AND C.CHECK_NO LIKE 'F%'))
            AND ({0} = '0' OR A.PLINE_CODE IN {1})
            AND A.BAL_YEAR_MONTH >= {2}
            AND A.BAL_YEAR_MONTH <= {3}
          GROUP BY A.JUDGE_STOVE_NO, A.BATCH_NO) A2,
        QCM_BC_CHEMJUDGE D,
        QCM_BC_CHEM_RESULT E
  WHERE D.JUDGE_STOVE_NO = A2.JUDGE_STOVE_NO
    AND D.BATCH_NO = A2.BATCH_NO
    AND D.PROCESS_CDOE = A2.PROCESS_CODE
    AND D.VALIDFLAG = '1'
    AND D.SAMPLE_TYPE = '2'
    AND D.CRAFT_SOURCE = '0'
    AND E.CHEM_JUDGE_ID = D.CHEM_JUDGE_ID
    AND E.JUDGE_SEQ = D.JUDGE_SEQ
    AND EXISTS (SELECT 1
           FROM Qcm_Bc_Chemjudge D2, Qcm_Bc_Chem_Result E2
          WHERE D2.JUDGE_STOVE_NO = D.JUDGE_STOVE_NO
            AND D2.BATCH_NO = D.BATCH_NO
            AND D2.PROCESS_CDOE = D.PROCESS_CDOE
            AND D2.VALIDFLAG = '1'
            AND D2.SAMPLE_TYPE = '1'
            AND D2.CRAFT_SOURCE = '0'
            AND E2.CHEM_JUDGE_ID = D2.CHEM_JUDGE_ID
            AND E2.JUDGE_SEQ = D2.JUDGE_SEQ
            AND E2.NK_QUALIFIED IN ('0', '2', '3')
            AND E2.CHEM_NAME = E.CHEM_NAME)
  GROUP BY A2.JUDGE_STOVE_NO, A2.BATCH_NO
		]]>
	</query>
	
	<query id="QcmZgJugdeApplyDAL.PhyFailQuery4" desc="理化不合查询4">
		<![CDATA[
SELECT A2.JUDGE_STOVE_NO 判定炉号,
       A2.BATCH_NO 性能批号,
       LISTAGG(E.PHY_NAME, '、') WITHIN GROUP(ORDER BY E.Phy_Code, E.PHY_RESULT_SEQ) "性能不合格项（初验）",
       LISTAGG(E.VALUE1, '、') WITHIN GROUP(ORDER BY E.Phy_Code, E.PHY_RESULT_SEQ) "性能数值1（初验）",
       LISTAGG(E.VALUE2, '、') WITHIN GROUP(ORDER BY E.Phy_Code, E.PHY_RESULT_SEQ) "性能数值2（初验）",
       LISTAGG(E.VALUE3, '、') WITHIN GROUP(ORDER BY E.Phy_Code, E.PHY_RESULT_SEQ) "性能数值3（初验）",
       LISTAGG(E.VALUE4, '、') WITHIN GROUP(ORDER BY E.Phy_Code, E.PHY_RESULT_SEQ) "性能数值4（初验）",
       LISTAGG(E.VALUE5, '、') WITHIN GROUP(ORDER BY E.Phy_Code, E.PHY_RESULT_SEQ) "性能数值5（初验）",
       LISTAGG(E.VALUE6, '、') WITHIN GROUP(ORDER BY E.Phy_Code, E.PHY_RESULT_SEQ) "性能数值6（初验）",
       LISTAGG(E.VALUE7, '、') WITHIN GROUP(ORDER BY E.Phy_Code, E.PHY_RESULT_SEQ) "性能数值7（初验）",
       LISTAGG(E.VALUE8, '、') WITHIN GROUP(ORDER BY E.Phy_Code, E.PHY_RESULT_SEQ) "性能数值8（初验）",
       LISTAGG(E.VALUE9, '、') WITHIN GROUP(ORDER BY E.Phy_Code, E.PHY_RESULT_SEQ) "性能数值9（初验）",
       LISTAGG(E.VALUE10, '、') WITHIN GROUP(ORDER BY E.Phy_Code, E.PHY_RESULT_SEQ) "性能数值10（初验）",
       LISTAGG(E.VALUE11, '、') WITHIN GROUP(ORDER BY E.Phy_Code, E.PHY_RESULT_SEQ) "性能数值11（初验）",
       LISTAGG(E.VALUE12, '、') WITHIN GROUP(ORDER BY E.Phy_Code, E.PHY_RESULT_SEQ) "性能数值12（初验）",
       LISTAGG(E.VALUE13, '、') WITHIN GROUP(ORDER BY E.Phy_Code, E.PHY_RESULT_SEQ) "性能数值13（初验）",
       LISTAGG(E.VALUE14, '、') WITHIN GROUP(ORDER BY E.Phy_Code, E.PHY_RESULT_SEQ) "性能数值14（初验）",
       LISTAGG(E.VALUE15, '、') WITHIN GROUP(ORDER BY E.Phy_Code, E.PHY_RESULT_SEQ) "性能数值15（初验）",
       LISTAGG(DECODE(E.IS_GOOD, '0', '完好'， '1', '缺陷'), '、') WITHIN GROUP(ORDER BY E.Phy_Code, E.PHY_RESULT_SEQ) "是否完好（初验）",
       LISTAGG(DECODE(E.IS_DEFECT, '0', ''), '、') WITHIN GROUP(ORDER BY E.Phy_Code, E.PHY_RESULT_SEQ) "有无缺陷（初验）",
       LISTAGG(DECODE(E.NK_MIN,
                      '',
                      '无要求',
                      REPLACE(REPLACE(E.NK_MIN, '>', ''), '=', '')) || '-' ||
               DECODE(E.NK_MAX,
                      '',
                      '无要求',
                      REPLACE(REPLACE(E.NK_MAX, '<', ''), '=', '')),
               '、') WITHIN GROUP(ORDER BY E.NK_MIN, E.NK_MAX) "性能标准范围（初验）"
  FROM (SELECT A.JUDGE_STOVE_NO,
               A.BATCH_NO,
               MIN(A.PROCESS_CODE) PROCESS_CODE
          FROM QCM_ZG_JUGDE_APPLY A
          LEFT JOIN COM_BASE_INFO A1
            ON A1.BASECODE = A.AUDIT_RESULT, QCM_BC_BATCH_RESULT B
         WHERE A.IS_FLAG = '0'
           AND A.IS_ALL_SCRAP IN ('0', '4', '5', '6', '7', '8')
           AND (A.VALIDFLAG = '20' OR
               (A.VALIDFLAG = '00' AND A.INSTANCY_FLAG = '1'))
           AND A.JUDGE_STOVE_NO = B.JUDGE_STOVE_NO
           AND A.BATCH_NO = B.BATCH_NO
           AND A.PROCESS_CODE = B.PROCESS_CODE
           AND B.CRAFT_SOURCE = '0'
           AND (-- A.JUDGE_RESULT_CODE = '40740701' AND
               A.AUDIT_RESULT <> '407501' OR
              -- A.JUDGE_RESULT_CODE = '40740701' AND
               EXISTS(SELECT 1 FROM QCM_ZC_CHECKCONSIGN C
       WHERE C.JUDGE_STOVE_NO = B.JUDGE_STOVE_NO
       AND C.BATCH_NO = B.BATCH_NO
       AND C.PROCESS_CODE = B.PROCESS_CODE
       AND C.CHECK_NO LIKE 'F%'))
           AND ({0} = '0' OR A.PLINE_CODE IN {1})
           AND A.BAL_YEAR_MONTH >= {2}
           AND A.BAL_YEAR_MONTH <= {3}
         GROUP BY A.JUDGE_STOVE_NO, A.BATCH_NO) A2,
       Qcm_Bc_Phyjudge D,
       Qcm_Bc_Phyresult E
 WHERE D.JUDGE_STOVE_NO = A2.JUDGE_STOVE_NO
   AND D.BATCH_NO = A2.BATCH_NO
   AND D.PROCESS_CDOE = A2.PROCESS_CODE
   AND D.VALIDFLAG = '1'
   AND D.SAMPLE_TYPE = '1'
   AND D.CRAFT_SOURCE = '0'
   AND E.Phy_Result_Id = D.Phy_Judge_Id
   AND E.Phy_Result_Seq = D.Judge_Seq
   AND E.NK_TOL_QUALIFIED IN ('0', '2', '3')
 GROUP BY A2.JUDGE_STOVE_NO, A2.BATCH_NO
		]]>
	</query>
	
	<query id="QcmZgJugdeApplyDAL.PhyFailQuery5" desc="理化不合查询5">
		<![CDATA[
SELECT A2.JUDGE_STOVE_NO 判定炉号,
       A2.BATCH_NO 性能批号,
       LISTAGG(E.PHY_NAME, '、') WITHIN GROUP(ORDER BY E.Phy_Code, E.PHY_RESULT_SEQ) "性能不合格项（复验）",
       LISTAGG(E.VALUE1, '、') WITHIN GROUP(ORDER BY E.Phy_Code, E.PHY_RESULT_SEQ) "性能数值1（复验）",
       LISTAGG(E.VALUE2, '、') WITHIN GROUP(ORDER BY E.Phy_Code, E.PHY_RESULT_SEQ) "性能数值2（复验）",
       LISTAGG(E.VALUE3, '、') WITHIN GROUP(ORDER BY E.Phy_Code, E.PHY_RESULT_SEQ) "性能数值3（复验）",
       LISTAGG(E.VALUE4, '、') WITHIN GROUP(ORDER BY E.Phy_Code, E.PHY_RESULT_SEQ) "性能数值4（复验）",
       LISTAGG(E.VALUE5, '、') WITHIN GROUP(ORDER BY E.Phy_Code, E.PHY_RESULT_SEQ) "性能数值5（复验）",
       LISTAGG(E.VALUE6, '、') WITHIN GROUP(ORDER BY E.Phy_Code, E.PHY_RESULT_SEQ) "性能数值6（复验）",
       LISTAGG(E.VALUE7, '、') WITHIN GROUP(ORDER BY E.Phy_Code, E.PHY_RESULT_SEQ) "性能数值7（复验）",
       LISTAGG(E.VALUE8, '、') WITHIN GROUP(ORDER BY E.Phy_Code, E.PHY_RESULT_SEQ) "性能数值8（复验）",
       LISTAGG(E.VALUE9, '、') WITHIN GROUP(ORDER BY E.Phy_Code, E.PHY_RESULT_SEQ) "性能数值9（复验）",
       LISTAGG(E.VALUE10, '、') WITHIN GROUP(ORDER BY E.Phy_Code, E.PHY_RESULT_SEQ) "性能数值10（复验）",
       LISTAGG(E.VALUE11, '、') WITHIN GROUP(ORDER BY E.Phy_Code, E.PHY_RESULT_SEQ) "性能数值11（复验）",
       LISTAGG(E.VALUE12, '、') WITHIN GROUP(ORDER BY E.Phy_Code, E.PHY_RESULT_SEQ) "性能数值12（复验）",
       LISTAGG(E.VALUE13, '、') WITHIN GROUP(ORDER BY E.Phy_Code, E.PHY_RESULT_SEQ) "性能数值13（复验）",
       LISTAGG(E.VALUE14, '、') WITHIN GROUP(ORDER BY E.Phy_Code, E.PHY_RESULT_SEQ) "性能数值14（复验）",
       LISTAGG(E.VALUE15, '、') WITHIN GROUP(ORDER BY E.Phy_Code, E.PHY_RESULT_SEQ) "性能数值15（复验）",
       LISTAGG(E.IS_GOOD, '、') WITHIN GROUP(ORDER BY E.Phy_Code, E.PHY_RESULT_SEQ) "是否完好（复验）",
       LISTAGG(E.IS_DEFECT, '、') WITHIN GROUP(ORDER BY E.Phy_Code, E.PHY_RESULT_SEQ) "有无缺陷（复验）",
       LISTAGG(DECODE(E.NK_MIN,
                      '',
                      '无要求',
                      REPLACE(REPLACE(E.NK_MIN, '>', ''), '=', '')) || '-' ||
               DECODE(E.NK_MAX,
                      '',
                      '无要求',
                      REPLACE(REPLACE(E.NK_MAX, '<', ''), '=', '')),
               '、') WITHIN GROUP(ORDER BY E.NK_MIN, E.NK_MAX) "性能标准范围（复验）"
  FROM (SELECT A.JUDGE_STOVE_NO,
               A.BATCH_NO,
               MIN(A.PROCESS_CODE) PROCESS_CODE
          FROM QCM_ZG_JUGDE_APPLY A
          LEFT JOIN COM_BASE_INFO A1
            ON A1.BASECODE = A.AUDIT_RESULT, QCM_BC_BATCH_RESULT B
         WHERE A.IS_FLAG = '0'
           AND A.IS_ALL_SCRAP IN ('0', '4', '5', '6', '7', '8')
           AND (A.VALIDFLAG = '20' OR
               (A.VALIDFLAG = '00' AND A.INSTANCY_FLAG = '1'))
           AND A.JUDGE_STOVE_NO = B.JUDGE_STOVE_NO
           AND A.BATCH_NO = B.BATCH_NO
           AND A.PROCESS_CODE = B.PROCESS_CODE
           AND B.CRAFT_SOURCE = '0'
           AND (-- A.JUDGE_RESULT_CODE = '40740701' AND
               A.AUDIT_RESULT <> '407501' OR
               -- A.JUDGE_RESULT_CODE = '40740701' AND
               EXISTS
                (SELECT 1
                   FROM QCM_ZC_CHECKCONSIGN C
                  WHERE C.JUDGE_STOVE_NO = B.JUDGE_STOVE_NO
                    AND C.BATCH_NO = B.BATCH_NO
                    AND C.PROCESS_CODE = B.PROCESS_CODE
                    AND C.CHECK_NO LIKE 'F%'))
           AND ({0} = '0' OR A.PLINE_CODE IN {1})
           AND A.BAL_YEAR_MONTH >= {2}
           AND A.BAL_YEAR_MONTH <= {3}
         GROUP BY A.JUDGE_STOVE_NO, A.BATCH_NO) A2,
       Qcm_Bc_Phyjudge D,
       Qcm_Bc_Phyresult E
 WHERE D.JUDGE_STOVE_NO = A2.JUDGE_STOVE_NO
   AND D.BATCH_NO = A2.BATCH_NO
   AND D.PROCESS_CDOE = A2.PROCESS_CODE
   AND D.VALIDFLAG = '1'
   AND D.SAMPLE_TYPE = '2'
   AND D.CRAFT_SOURCE = '0'
   AND E.Phy_Result_Id = D.Phy_Judge_Id
   AND E.Phy_Result_Seq = D.Judge_Seq
   AND EXISTS (SELECT 1
          FROM Qcm_Bc_Phyjudge D2, Qcm_Bc_Phyresult E2
         WHERE D2.JUDGE_STOVE_NO = D.JUDGE_STOVE_NO
           AND D2.BATCH_NO = D.BATCH_NO
           AND D2.PROCESS_CDOE = D.PROCESS_CDOE
           AND D2.VALIDFLAG = '1'
           AND D2.SAMPLE_TYPE = '1'
           AND D2.CRAFT_SOURCE = '0'
           AND E2.PHY_RESULT_ID = D2.PHY_JUDGE_ID
           AND E2.PHY_RESULT_SEQ = D2.JUDGE_SEQ
           AND E2.NK_TOL_QUALIFIED IN ('0', '2', '3')
           AND E2.PHY_CODE = E.PHY_CODE)
 GROUP BY A2.JUDGE_STOVE_NO, A2.BATCH_NO
		]]>
	</query>
	
	<query id="QcmZgJugdeApplyDAL.GetByJudgeStoveNo" desc="通过判定炉号查询">
        <![CDATA[
SELECT T.*,
       CASE
         WHEN B.HEAT_PLAN_NO IS NOT NULL THEN
          B.UPPER_HEATPLAN_ID
         WHEN C.HEAT_PLAN_NO IS NOT NULL THEN
          C.UPPER_HEATPLAN_ID
         WHEN D.HEAT_PLAN_NO IS NOT NULL THEN
          D.UPPER_HEATPLAN_ID
         WHEN E.HEAT_PLAN_NO IS NOT NULL THEN
          E.UPPER_HEATPLAN_ID
       END UPPER_HEATPLAN_ID
  FROM QCM_ZG_JUGDE_APPLY T
  LEFT JOIN PLN_ZY_DBK_M B
    ON B.HEAT_PLAN_NO = T.HEAT_PLAN_NO
  LEFT JOIN PLN_ZY_RCL_M C
    ON C.HEAT_PLAN_NO = T.HEAT_PLAN_NO
  LEFT JOIN PLN_ZY_JGX_M D
    ON D.HEAT_PLAN_NO = T.HEAT_PLAN_NO
  LEFT JOIN PLN_ZY_JG_M E
    ON E.HEAT_PLAN_NO = T.HEAT_PLAN_NO
 WHERE T.JUDGE_STOVE_NO = {0}
   AND T.PROCESS_CODE = {1}
   AND ({2} IS NULL OR T.HEAT_PLAN_NO = {2})
   AND T.IS_FLAG = '0'
   AND T.IS_ALL_SCRAP IN ('0', '4', '5', '6', '7', '8')
        ]]>
    </query>

    <query id="QcmZgJugdeApplyDAL.PhyFailQueryLg" desc="炼钢理化不合查询">
        <![CDATA[
SELECT
	A3.处理结果,
	A3.判定炉号,
	A3.冶炼炉号,
	A3.钢种,
	A3.规格,
	A3.生产合同号,
	A3.合同号,
	A3.工艺文件号,
	A3.标准名称,
	A3.机组,
	A3.判定日期,
	A3.判定支,
	A3.判定吨,
	NVL( A3.JUDGE_STOVE_NO, A4.JUDGE_STOVE_NO ) JUDGE_STOVE_NO,
	A3."不合格项（初验）",
	A3."数值（初验）",
	NVL( A3.标准范围, A4.STD_RANGE ) 标准范围,
	NVL( A3.交付范围, A4.STD_RANGE_JF ) 交付范围,
	A4."不合格项（复验）",
	A4."数值（复验）",
	'熔炼成分' 不合类别,
	nvl(A3.计入一次合格率,'Y') 计入一次不合,
	A3.原因分析
FROM
	(
	SELECT
		MIN( A2.处理结果 ) 处理结果,
		MIN( A2.判定炉号 ) 判定炉号,
		MIN( A2.冶炼炉号 ) 冶炼炉号,
		MIN( A2.钢种 ) 钢种,
		MIN( A2.规格 ) 规格,
		MIN( A2.生产合同号 ) 生产合同号,
		MIN( A2.合同号 ) 合同号,
		MIN( A2.工艺文件号 ) 工艺文件号,
		MIN( A2.标准名称 ) 标准名称,
		MIN( A2.机组 ) 机组,
		MIN( A2.判定日期 ) 判定日期,
		MIN( A2.判定支 ) 判定支,
		MIN( A2.判定吨 ) 判定吨,
        MIN( A2.计入一次合格率 ) 计入一次合格率,
        MIN( A2.原因分析 ) 原因分析,
		MIN( A2.JUDGE_STOVE_NO ) JUDGE_STOVE_NO,
		LISTAGG ( E.CHEM_NAME, '、' ) WITHIN GROUP ( ORDER BY E.CHEM_NAME ) "不合格项（初验）",
		LISTAGG ( E.CHEM_VALUE, '、' ) WITHIN GROUP ( ORDER BY E.CHEM_VALUE ) "数值（初验）",
		LISTAGG (
			DECODE( E.NK_MIN, '', '无要求', REPLACE ( REPLACE ( E.NK_MIN, '>', '' ), '=', '' ) ) || '-' || DECODE( E.NK_MAX, '', '无要求', REPLACE ( REPLACE ( E.NK_MAX, '<', '' ), '=', '' ) ),
			'、'
		) WITHIN GROUP ( ORDER BY E.NK_MIN, E.NK_MAX ) 标准范围,
		LISTAGG (
			DECODE( E.JF_MIN, '', '无要求', REPLACE ( REPLACE ( E.JF_MIN, '>', '' ), '=', '' ) ) || '-' || DECODE( E.JF_MAX, '', '无要求', REPLACE ( REPLACE ( E.JF_MAX, '<', '' ), '=', '' ) ),
			'、'
		) WITHIN GROUP ( ORDER BY E.JF_MIN, E.JF_MAX ) 交付范围
	FROM
		(
		SELECT
			A.JUDGE_STOVE_NO,
			DECODE( MIN( A.AUDIT_RESULT2 ), '', '复验合格', '407501', '复验合格', MIN( A1.BASENAME ) ) 处理结果,
			MIN( A.JUDGE_STOVE_NO ) 判定炉号,
			MIN( A.STOVE_NO ) 冶炼炉号,
			MIN( A.GRADENAME ) 钢种,
			MIN( A.ACT_DIMATER ) 规格,
			MIN( A.PRO_ORDER_NO ) 生产合同号,
			MIN( SUBSTR( A.PRO_ORDER_NO, 1, 17 ) ) 合同号,
			MIN( A.CRAFT_NO ) 工艺文件号,
			MIN( A.STD_NAME ) 标准名称,
			MIN( B.EF_PLINE_NAME ) 机组,
			MIN( A.JUDGE_RESULT_TIME ) 判定日期,
			SUM( A.ACT_COUNT ) 判定支,
			MIN( A.PASSRATE_FIRST_FLAG ) 计入一次合格率,
			MIN( A.PASSRATE_FIRST_REASON ) 原因分析,
			DECODE( SUM( A.ACT_WEIGHT ), '', SUM( A.ACT_THEORY_WEIGHT ), SUM( A.ACT_WEIGHT ) ) 判定吨
		FROM
			QCM_GP_JUDGE_APPLY A
			LEFT JOIN COM_BASE_INFO A1 ON A1.BASECODE = A.AUDIT_RESULT2,
			PLN_STEELFOR_ORD B
		WHERE
			A.IS_FLAG = '0'
			AND ( A.VALIDFLAG = '20' OR ( A.VALIDFLAG = '00' AND A.INSTANCY_FLAG = '1' ) )
			AND A.PLINE_CODE NOT IN ( 'C063', 'C064' )
			AND (
				A.CHEM_RESULT_CODE = '40740102'
				AND A.AUDIT_RESULT2 <> '407501'
				OR A.CHEM_RESULT_CODE = '40740101'
				AND EXISTS ( SELECT 1 FROM QCM_LG_CHEMJUDGE D WHERE D.JUDGE_STOVE_NO = A.JUDGE_STOVE_NO AND D.SAMPLE_TYPE = '2' )
				AND EXISTS (
				SELECT
					1
				FROM
					QCM_LG_CHEMJUDGE D
				WHERE
					D.JUDGE_STOVE_NO = A.JUDGE_STOVE_NO
					AND D.CHEM_JUDGE_ID = ( SELECT MAX( D2.CHEM_JUDGE_ID ) FROM QCM_LG_CHEMJUDGE D2 WHERE D2.JUDGE_STOVE_NO = D.JUDGE_STOVE_NO AND D2.SAMPLE_TYPE = '1' )
					AND D.MERGE_CHEM_RESULT = '40740102'
				)
			)
			AND B.FURNACENO = A.FURNACENO
			AND B.SEQUENCENO = A.SEQUENCENO
			AND A.CHEM_DB_RPT_FLAG = '0'
			AND ({0} = '0' OR B.EF_PLINE_CODE IN {1})
			AND A.BAL_YEAR_MONTH >= {2}
			AND A.BAL_YEAR_MONTH <= {3}
		GROUP BY
			A.JUDGE_STOVE_NO
		) A2,
		QCM_LG_CHEMJUDGE D,
		QCM_LG_CHEM_RESULT E
	WHERE
		D.JUDGE_STOVE_NO = A2.JUDGE_STOVE_NO
		AND D.CHEM_JUDGE_ID = (
		SELECT
			MAX( D2.CHEM_JUDGE_ID )
		FROM
			QCM_LG_CHEMJUDGE D2
		WHERE
			D2.JUDGE_STOVE_NO = D.JUDGE_STOVE_NO
			AND D2.PROCESS_CDOE = 'B'
			AND D2.SAMPLE_TYPE = '1'
		)
		AND E.CHEM_JUDGE_ID = D.CHEM_JUDGE_ID
		AND E.JUDGE_SEQ = D.JUDGE_SEQ
		AND E.QUALIFIED IN ( '0', '2' )
	GROUP BY
		A2.JUDGE_STOVE_NO
	) A3
	FULL JOIN (
	SELECT
		MIN( 处理结果 ) 处理结果,
		MIN( 判定炉号 ) 判定炉号,
		MIN( 冶炼炉号 ) 冶炼炉号,
		MIN( 钢种 ) 钢种,
		MIN( 规格 ) 规格,
		MIN( 生产合同号 ) 生产合同号,
		MIN( 合同号 ) 合同号,
		MIN( 工艺文件号 ) 工艺文件号,
		MIN( 标准名称 ) 标准名称,
		MIN( 机组 ) 机组,
		MIN( 判定日期 ) 判定日期,
		MIN( 判定支 ) 判定支,
		MIN( 判定吨 ) 判定吨,
        MIN( 计入一次合格率 ) 计入一次合格率,
        MIN( 原因分析 ) 原因分析,
		JUDGE_STOVE_NO,
		NVL( ( LISTAGG ( CHEM_NAME, '、' ) WITHIN GROUP ( ORDER BY CHEM_NAME ) ), '/' ) "不合格项（复验）",
		NVL( ( LISTAGG ( CHEM_VALUE, '、' ) WITHIN GROUP ( ORDER BY CHEM_VALUE ) ), '/' ) "数值（复验）",
		LISTAGG (
			DECODE( NK_MIN, '', '无要求', REPLACE ( REPLACE ( NK_MIN, '>', '' ), '=', '' ) ) || '-' || DECODE( NK_MAX, '', '无要求', REPLACE ( REPLACE ( NK_MAX, '<', '' ), '=', '' ) ),
			'、'
		) WITHIN GROUP ( ORDER BY NK_MIN, NK_MAX ) STD_RANGE,
		LISTAGG (
			DECODE( JF_MIN, '', '无要求', REPLACE ( REPLACE ( JF_MIN, '>', '' ), '=', '' ) ) || '-' || DECODE( JF_MAX, '', '无要求', REPLACE ( REPLACE ( JF_MAX, '<', '' ), '=', '' ) ),
			'、'
		) WITHIN GROUP ( ORDER BY JF_MIN, JF_MAX ) STD_RANGE_JF
	FROM
		(
		SELECT
            MIN( A2.处理结果 ) 处理结果,
            MIN( A2.判定炉号 ) 判定炉号,
            MIN( A2.冶炼炉号 ) 冶炼炉号,
            MIN( A2.钢种 ) 钢种,
            MIN( A2.规格 ) 规格,
            MIN( A2.生产合同号 ) 生产合同号,
            MIN( A2.合同号 ) 合同号,
            MIN( A2.工艺文件号 ) 工艺文件号,
            MIN( A2.标准名称 ) 标准名称,
            MIN( A2.机组 ) 机组,
            MIN( A2.判定日期 ) 判定日期,
            MIN( A2.判定支 ) 判定支,
            MIN( A2.判定吨 ) 判定吨,
            MIN( A2.计入一次合格率 ) 计入一次合格率,
			MIN( A2.原因分析 ) 原因分析,
			A2.JUDGE_STOVE_NO,
			E.CHEM_NAME,
			E.CHEM_VALUE,
			MIN( E.NK_MIN ) NK_MIN,
			MIN( E.NK_MAX ) NK_MAX,
			MIN( E.JF_MIN ) JF_MIN,
			MIN( E.JF_MAX ) JF_MAX
		FROM
			(
			SELECT
				A.JUDGE_STOVE_NO,
				DECODE( MIN( A.AUDIT_RESULT2 ), '', '复验合格', '407501', '复验合格', MIN( A1.BASENAME ) ) 处理结果,
				MIN( A.JUDGE_STOVE_NO ) 判定炉号,
				MIN( A.STOVE_NO ) 冶炼炉号,
				MIN( A.GRADENAME ) 钢种,
				MIN( A.ACT_DIMATER ) 规格,
				MIN( A.PRO_ORDER_NO ) 生产合同号,
				MIN( SUBSTR( A.PRO_ORDER_NO, 1, 17 ) ) 合同号,
				MIN( A.CRAFT_NO ) 工艺文件号,
				MIN( A.STD_NAME ) 标准名称,
				MIN( B.EF_PLINE_NAME ) 机组,
				MIN( A.JUDGE_RESULT_TIME ) 判定日期,
				SUM( A.ACT_COUNT ) 判定支,
                MIN( A.PASSRATE_FIRST_FLAG ) 计入一次合格率,
			    MIN( A.PASSRATE_FIRST_REASON ) 原因分析,
				DECODE( SUM( A.ACT_WEIGHT ), '', SUM( A.ACT_THEORY_WEIGHT ), SUM( A.ACT_WEIGHT ) ) 判定吨
			FROM
				QCM_GP_JUDGE_APPLY A
				LEFT JOIN COM_BASE_INFO A1 ON A1.BASECODE = A.AUDIT_RESULT2,
				PLN_STEELFOR_ORD B
			WHERE
				A.IS_FLAG = '0'
				AND ( A.VALIDFLAG = '20' OR ( A.VALIDFLAG = '00' AND A.INSTANCY_FLAG = '1' ) )
				AND A.PLINE_CODE NOT IN ( 'C063', 'C064' )
				AND (
					A.CHEM_RESULT_CODE = '40740102'
					AND A.AUDIT_RESULT2 <> '407501'
					OR A.CHEM_RESULT_CODE = '40740101'
					AND EXISTS ( SELECT 1 FROM QCM_LG_CHEMJUDGE D WHERE D.JUDGE_STOVE_NO = A.JUDGE_STOVE_NO AND D.SAMPLE_TYPE = '2' )
					AND EXISTS (
					SELECT
						1
					FROM
						QCM_LG_CHEMJUDGE D
					WHERE
						D.JUDGE_STOVE_NO = A.JUDGE_STOVE_NO
						AND D.CHEM_JUDGE_ID = ( SELECT MAX( D2.CHEM_JUDGE_ID ) FROM QCM_LG_CHEMJUDGE D2 WHERE D2.JUDGE_STOVE_NO = D.JUDGE_STOVE_NO AND D2.SAMPLE_TYPE = '1' )
						AND D.MERGE_CHEM_RESULT = '40740102'
					)
				)
				AND B.FURNACENO = A.FURNACENO
				AND B.SEQUENCENO = A.SEQUENCENO
				AND A.CHEM_DB_RPT_FLAG = '0'
				AND ({0} = '0' OR B.EF_PLINE_CODE IN {1})
                AND A.BAL_YEAR_MONTH >= {2}
                AND A.BAL_YEAR_MONTH <= {3}
			GROUP BY
				A.JUDGE_STOVE_NO
			) A2,
			QCM_LG_CHEMJUDGE D,
			QCM_LG_CHEM_RESULT E
		WHERE
			D.JUDGE_STOVE_NO = A2.JUDGE_STOVE_NO
			AND D.CHEM_JUDGE_ID = (
			SELECT
				MAX( D2.CHEM_JUDGE_ID )
			FROM
				QCM_LG_CHEMJUDGE D2
			WHERE
				D2.JUDGE_STOVE_NO = D.JUDGE_STOVE_NO
				AND D2.PROCESS_CDOE = 'B'
				AND D2.SAMPLE_TYPE = '2'
			)
			AND E.CHEM_JUDGE_ID = D.CHEM_JUDGE_ID
			AND E.JUDGE_SEQ = D.JUDGE_SEQ
			AND (
				E.QUALIFIED IN ( '0', '2' )
				AND NOT EXISTS (
				SELECT
					1
				FROM
					QCM_LG_CHEMJUDGE D2,
					QCM_LG_CHEM_RESULT E2
				WHERE
					D2.JUDGE_STOVE_NO = D.JUDGE_STOVE_NO
					AND D2.CHEM_JUDGE_ID = (
					SELECT
						MAX( D3.CHEM_JUDGE_ID )
					FROM
						QCM_LG_CHEMJUDGE D3
					WHERE
						D3.JUDGE_STOVE_NO = D2.JUDGE_STOVE_NO
						AND D3.PROCESS_CDOE = 'B'
						AND D3.SAMPLE_TYPE = '1'
					)
					AND D2.CHEM_JUDGE_ID = E2.CHEM_JUDGE_ID
					AND E2.JUDGE_SEQ = D2.JUDGE_SEQ
					AND E2.QUALIFIED IN ( '0', '2' )
					AND E2.CHEM_NAME = E.CHEM_NAME
				)
				OR EXISTS (
				SELECT
					1
				FROM
					QCM_LG_CHEMJUDGE D2,
					QCM_LG_CHEM_RESULT E2
				WHERE
					D2.JUDGE_STOVE_NO = D.JUDGE_STOVE_NO
					AND D2.CHEM_JUDGE_ID = (
					SELECT
						MAX( D3.CHEM_JUDGE_ID )
					FROM
						QCM_LG_CHEMJUDGE D3
					WHERE
						D3.JUDGE_STOVE_NO = D2.JUDGE_STOVE_NO
						AND D3.PROCESS_CDOE = 'B'
						AND D3.SAMPLE_TYPE = '1'
					)
					AND D2.CHEM_JUDGE_ID = E2.CHEM_JUDGE_ID
					AND E2.JUDGE_SEQ = D2.JUDGE_SEQ
					AND E2.QUALIFIED IN ( '0', '2' )
					AND E2.CHEM_NAME = E.CHEM_NAME
				)
			)
		GROUP BY
			A2.JUDGE_STOVE_NO,
			E.CHEM_NAME,
			E.CHEM_VALUE
		)
	GROUP BY
		JUDGE_STOVE_NO
	) A4 ON A3.JUDGE_STOVE_NO = A4.JUDGE_STOVE_NO UNION ALL
SELECT
	MIN( A2.处理结果 ) 处理结果,
	MIN( A2.判定炉号 ) 判定炉号,
	MIN( A2.冶炼炉号 ) 冶炼炉号,
	MIN( A2.钢种 ) 钢种,
	MIN( A2.规格 ) 规格,
	MIN( A2.生产合同号 ) 生产合同号,
	MIN( A2.合同号 ) 合同号,
	MIN( A2.工艺文件号 ) 工艺文件号,
	MIN( A2.标准名称 ) 标准名称,
	MIN( A2.机组 ) 机组,
	MIN( A2.判定日期 ) 判定日期,
	MIN( A2.判定支 ) 判定支,
	MIN( A2.判定吨 ) 判定吨,
    MIN( A2.计入一次合格率 ) 计入一次合格率,
    MIN( A2.原因分析 ) 原因分析,
	MIN( A2.JUDGE_STOVE_NO ) JUDGE_STOVE_NO,
	LISTAGG ( E.PHY_NAME, '、' ) WITHIN GROUP ( ORDER BY E.PHY_NAME ) "不合格项（初验）",
	LISTAGG ( E.VALUE1, '、' ) WITHIN GROUP ( ORDER BY E.VALUE1 ) "数值（初验）",
	LISTAGG ( E.NK_RANGE || '级', '、' ) WITHIN GROUP ( ORDER BY E.NK_RANGE ) 标准范围,
	'/',
	'/',
	'/',
	'低倍组织' 不合类别
FROM
	(
	SELECT
		A.JUDGE_STOVE_NO,
		DECODE( MIN( A.AUDIT_RESULT2 ), '', '复验合格', '407501', '复验合格', MIN( A1.BASENAME ) ) 处理结果,
		MIN( A.JUDGE_STOVE_NO ) 判定炉号,
		MIN( A.STOVE_NO ) 冶炼炉号,
		MIN( A.GRADENAME ) 钢种,
		MIN( A.ACT_DIMATER ) 规格,
		MIN( A.PRO_ORDER_NO ) 生产合同号,
		MIN( SUBSTR( A.PRO_ORDER_NO, 1, 17 ) ) 合同号,
		MIN( A.CRAFT_NO ) 工艺文件号,
		MIN( A.STD_NAME ) 标准名称,
		MIN( B.EF_PLINE_NAME ) 机组,
		MIN( A.JUDGE_RESULT_TIME ) 判定日期,
		SUM( A.ACT_COUNT ) 判定支,
        MIN( A.PASSRATE_FIRST_FLAG ) 计入一次合格率,
        MIN( A.PASSRATE_FIRST_REASON ) 原因分析,
		DECODE( SUM( A.ACT_WEIGHT ), '', SUM( A.ACT_THEORY_WEIGHT ), SUM( A.ACT_WEIGHT ) ) 判定吨
	FROM
		QCM_GP_JUDGE_APPLY A
		LEFT JOIN COM_BASE_INFO A1 ON A1.BASECODE = A.AUDIT_RESULT2,
		PLN_STEELFOR_ORD B
	WHERE
		A.IS_FLAG = '0'
		AND ( A.VALIDFLAG = '20' OR ( A.VALIDFLAG = '00' AND A.INSTANCY_FLAG = '1' ) )
		AND A.PLINE_CODE NOT IN ( 'C063', 'C064' )
		AND (
			A.CHEM_RESULT_CODE = '40740102'
			AND A.AUDIT_RESULT2 <> '407501'
			OR A.CHEM_RESULT_CODE = '40740101'
			AND EXISTS ( SELECT 1 FROM QCM_LG_CHEMJUDGE D WHERE D.JUDGE_STOVE_NO = A.JUDGE_STOVE_NO AND D.SAMPLE_TYPE = '2' )
			AND EXISTS (
			SELECT
				1
			FROM
				QCM_LG_CHEMJUDGE D
			WHERE
				D.JUDGE_STOVE_NO = A.JUDGE_STOVE_NO
				AND D.CHEM_JUDGE_ID = ( SELECT MAX( D2.CHEM_JUDGE_ID ) FROM QCM_LG_CHEMJUDGE D2 WHERE D2.JUDGE_STOVE_NO = D.JUDGE_STOVE_NO AND D2.SAMPLE_TYPE = '1' )
				AND D.MERGE_CHEM_RESULT = '40740102'
			)
		)
		AND B.FURNACENO = A.FURNACENO
		AND B.SEQUENCENO = A.SEQUENCENO
		AND A.CHEM_DB_RPT_FLAG = '0'
		AND ({0} = '0' OR B.EF_PLINE_CODE IN {1})
        AND A.BAL_YEAR_MONTH >= {2}
        AND A.BAL_YEAR_MONTH <= {3}
	GROUP BY
		A.JUDGE_STOVE_NO
	) A2,
	QCM_LG_PHYJUDGE D,
	QCM_LG_PHYRESULT E
WHERE
	D.JUDGE_STOVE_NO = A2.JUDGE_STOVE_NO
	AND D.PROCESS_CDOE = 'B'
	AND D.VALIDFLAG = '1'
	AND D.JUDGE_SEQ = 1
	AND E.PHY_RESULT_ID = D.PHY_RESULT_ID
	AND E.PHY_RESULT_SEQ = D.JUDGE_SEQ
	AND E.QUALIFIED = '0'
GROUP BY
	A2.JUDGE_STOVE_NO
		]]>
    </query>

    <query id="QcmZgJugdeApplyDAL.doUpdatePassrate" desc="修改">
        update QCM_GP_JUDGE_APPLY set PASSRATE_FIRST_FLAG = ?,PASSRATE_FIRST_REASON = ? where JUDGE_STOVE_NO = ?
    </query>
    <query id="QcmZgJugdeApplyDAL.GetByJudgeStoveNoNoLiku" desc="通过判定炉号查询 排除利库">
        <![CDATA[
 SELECT * FROM QCM_ZG_JUGDE_APPLY T WHERE T.JUDGE_STOVE_NO = {0}
 AND T.PROCESS_CODE = {1} AND T.IS_FLAG = '0' AND T.IS_ALL_SCRAP IN ('0', '5', '6')
        ]]>
    </query>
    
    <query id="QcmZgJugdeApplyDAL.GetLoadJudgeStoveNoByStoveNo" desc="通过熔炼炉号查询上料炉号">
        <![CDATA[
SELECT T.*
   FROM QCM_ZG_JUGDE_APPLY T
  WHERE T.STOVE_NO = {0}
    AND T.PROCESS_CODE = 'D'
    AND T.IS_FLAG = '0'
    AND T.IS_ALL_SCRAP IN ('0', '4', '5', '6', '7', '8')
        ]]>
    </query>
    
    <query id="QcmZgJugdeApplyDAL.getZbsFlagByJudgeStoveNo" desc="查询质保书标志等于2的">
        <![CDATA[
SELECT T.ZBS_FLAG FROM QCM_ZG_JUGDE_APPLY T
WHERE T.JUDGE_STOVE_NO = {0}
AND T.PROCESS_CODE = {1}
AND T.ZBS_FLAG = '2'
AND T.IS_FLAG = '0'
AND T.IS_ALL_SCRAP IN ('0', '4', '5', '6', '7', '8')
        ]]>
    </query>
    
    <query id="QcmZgJugdeApplyDAL.setZbsFlagByJudgeStoveNo" desc="修改质保书标志">
        <![CDATA[
UPDATE QCM_ZG_JUGDE_APPLY T
    SET T.ZBS_FLAG = {2}
    WHERE T.JUDGE_STOVE_NO = {0}
      AND T.PROCESS_CODE = {1}
      AND T.IS_FLAG = '0'
      AND T.IS_ALL_SCRAP IN ('0', '4', '5', '6', '7', '8')
        ]]>
    </query>
    
    <query id="QcmZgJugdeApplyDAL.getByBatchNoZbsInfoC" desc="质保书查询">
        <![CDATA[
SELECT T.JUGDE_APPLY_CODE,
       T.ORD_LN_DLY_PK,
       SUM(T.ACT_COUNT) ACT_COUNT,
       SUM(T.ACT_WEIGHT) ACT_WEIGHT,
       SUM(T.ACT_THEORY_WEIGHT) ACT_THEORY_WEIGHT,
       MIN(T.CRAFT_SEQ) CRAFT_SEQ,
       MIN(T.JUDGE_TOLRESULT_CODE) JUDGE_TOLRESULT_CODE
  FROM QCM_ZG_JUGDE_APPLY T
 WHERE T.JUDGE_STOVE_NO = {0}
   AND T.BATCH_NO = {1}
   AND PROCESS_CODE = {2}
   AND T.IS_FLAG = '0'
   AND T.IS_ALL_SCRAP IN ('0', '4', '5', '6', '7', '8')
 GROUP BY T.JUGDE_APPLY_CODE, T.ORD_LN_DLY_PK
        ]]>
    </query>
    
    <query id="QcmZgJugdeApplyDAL.getDetectInfo" desc="获取探伤信息">
        <![CDATA[
SELECT T.PROCESS_CODE,
       T2.PROCESS_DESC,
       T.NOTCH_LENGTH,
       T.NOTCH_WIDTH,
       T.NOTCH_DEPTH,
       T.TESTING_GRADE,
       T.TESTING_TYPE,
       T.TESTING_GRADE1,
       T.TESTING_TYPE1,
       T3.BASENAME DETECT_RESULT,
       T.DETECT_RESULT_CODE,
       T.DETECT_RESULT_CODE1,
       T4.BASENAME DETECT_RESULT1,
       T.DETECT_RESULT_PATH
  FROM QCM_ZG_JUGDE_APPLY T
  LEFT JOIN COM_BASE_PROCESS T2
    ON T2.PROCESS_CODE = T.PROCESS_CODE
  LEFT JOIN COM_BASE_INFO T3
    ON T3.BASECODE = T.DETECT_RESULT_CODE
  LEFT JOIN COM_BASE_INFO T4
    ON T4.BASECODE = T.DETECT_RESULT_CODE1
 WHERE T.JUGDE_APPLY_CODE = {0}
   AND T.JUDGE_STOVE_NO = {1}
   AND T.BATCH_NO = {2}
   AND T.IS_FLAG = '0'
   AND T.IS_ALL_SCRAP IN ('0', '4', '5', '6', '7', '8')
   AND ROWNUM <= 1
        ]]>
    </query>
    
    <query id="QcmZgJugdeApplyDAL.getWaterInfo" desc="获取水压信息">
        <![CDATA[
SELECT T.PROCESS_CODE,
       T2.PROCESS_DESC,
       T.TEST_PRESSURE,
       T.HOLDTIME_TIME,
       T.TEST_PRESSURE_Y,
       T.WPRESSURE_RESULT_CODE WATER_RESULT_CODE,
       T3.BASENAME             WATER_RESULT,
       T.WPRESSURE_RESULT_PATH WATER_RESULT_PATH
  FROM QCM_ZG_JUGDE_APPLY T
  LEFT JOIN COM_BASE_PROCESS T2
    ON T2.PROCESS_CODE = T.PROCESS_CODE
  LEFT JOIN COM_BASE_INFO T3
    ON T3.BASECODE = T.WPRESSURE_RESULT_CODE
 WHERE T.JUGDE_APPLY_CODE = {0}
   AND T.JUDGE_STOVE_NO = {1}
   AND T.BATCH_NO = {2}
   AND T.IS_FLAG = '0'
   AND T.IS_ALL_SCRAP IN ('0', '4', '5', '6', '7', '8')
   AND ROWNUM <= 1
        ]]>
    </query>
    
    <query id="QcmZgJugdeApplyDAL.getProcessInfo" desc="获取加工信息">
        <![CDATA[
SELECT T.MCH_PATH_RESULT,
       T.MCH_CHAMFERING_RESULT,
       T.MCH_TWISTINGLY_RESULT,
       T.MCH_THREAD_INSPECTION_RESULT,
       T.MCH_REMANENCE_RESULT,
       T.MCH_RADIOACTIVITY_RESULT,
       T.MCH_BEVEL_RESULT,
       T.ANGLE_VAL,
       T.EDGE_VAL,
       T.PROCESS_RESULT_PATH,
       T3.BASENAME                    DETECT_RESULT,
       T4.BASENAME                    WATER_RESULT,
       T5.BASENAME                    SPEC_RESULT,
       T6.BASENAME                    FACE_RESULT,
       T.TESTING_GRADE,
       T.TESTING_TYPE,
       T.TESTING_GRADE1,
       T.TESTING_TYPE1,
       T.NOTCH_LENGTH,
       T.NOTCH_WIDTH,
       T.NOTCH_DEPTH,
       T.TEST_PRESSURE,
       T.HOLDTIME_TIME,
       T.TEST_PRESSURE_Y,
       T.DRIFT_MODEL_MIN,
       T.MEASURED_END_PART,
       T.MEASURED_MIDDLE_PART,
       T.MEASURED_TAIL_PART
  FROM QCM_ZG_JUGDE_APPLY T
  LEFT JOIN COM_BASE_PROCESS T2
    ON T2.PROCESS_CODE = T.PROCESS_CODE
  LEFT JOIN COM_BASE_INFO T3
    ON T3.BASECODE = T.DETECT_RESULT_CODE
  LEFT JOIN COM_BASE_INFO T4
    ON T4.BASECODE = T.WPRESSURE_RESULT_CODE
  LEFT JOIN COM_BASE_INFO T5
    ON T5.BASECODE = T.SPEC_RESULT_CODE
  LEFT JOIN COM_BASE_INFO T6
    ON T6.BASECODE = T.FACE_RESULT_CODE
 WHERE T.JUGDE_APPLY_CODE = {0}
   AND T.JUDGE_STOVE_NO = {1}
   AND T.BATCH_NO = {2}
   AND T.IS_FLAG = '0'
   AND T.IS_ALL_SCRAP IN ('0', '4', '5', '6', '7', '8')
   AND ROWNUM <= 1
        ]]>
    </query>
    
    <query id="QcmZgJugdeApplyDAL.getPassInfo" desc="获取放行信息">
        <![CDATA[
SELECT MIN(T.JUDGE_RESULT) JUDGE_RESULT,
       MIN(T2.BASENAME) AUDIT_RESULT,
       DECODE(MIN(T4.AUDIT_RESULT), '0', '审核不通过', '1', '审核通过', NULL) URGENT_AUDIT_RESULT,
       MIN(T.JUDGE_MAKER) JUDGE_MAKER,
       MIN(T.JUDGE_MEMO) JUDGE_MEMO,
       TO_CHAR(MIN(T.JUDGE_RESULT_TIME), 'YYYY-MM-DD HH24:MI:SS') JUDGE_RESULT_TIME,
       MIN(T.AUDIT_MEMO) AUDIT_MEMO,
       MIN(T3.AUDIT_NAME) AUDIT_NAME,
       TO_CHAR(MIN(T3.AUDIT_TIME), 'YYYY-MM-DD HH24:MI:SS') AUDIT_TIME,
       T.JUGDE_APPLY_CODE,
       DECODE(MIN(T.INSTANCY_FLAG), '1', '紧急放行', '质量放行') INSTANCY_FLAG,
       MIN(T.PLINE_NAME) PLINE_NAME,
       MIN(T.JUDGE_STOVE_NO) JUDGE_STOVE_NO
  FROM QCM_ZG_JUGDE_APPLY T
  LEFT JOIN QCM_BC_PASS_APPLY T3
    ON T3.JUGDE_APPLY_CODE = T.JUGDE_APPLY_CODE
   AND T3.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO
   AND T3.BATCH_NO = T.BATCH_NO
   AND T3.VALIDFLAG = '1'
   AND T3.TYPE = '0'
  LEFT JOIN COM_BASE_INFO T2
    ON T2.BASECODE = T3.AUDIT_RESULT
  LEFT JOIN QCM_BC_PASS_APPLY T4
    ON T4.JUGDE_APPLY_CODE = T.JUGDE_APPLY_CODE
   AND T4.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO
   AND T4.BATCH_NO = T.BATCH_NO
   AND T4.VALIDFLAG = '1'
   AND T4.TYPE = '1'
 WHERE T.JUDGE_STOVE_NO = {0}
   AND T.BATCH_NO = {1}
   AND T.PROCESS_CODE = {2}
   AND T.IS_FLAG = '0'
   AND T.IS_ALL_SCRAP IN ('0', '4', '5', '6', '7', '8')
 GROUP BY T.JUGDE_APPLY_CODE
        ]]>
    </query>
    
    <query id="QcmZgJugdeApplyDAL.setZbsFlag" desc="修改质保书标志">
        <![CDATA[
UPDATE QCM_ZG_JUGDE_APPLY T
    SET T.ZBS_FLAG = {3}
  WHERE T.JUGDE_APPLY_CODE = {0}
    AND T.JUDGE_STOVE_NO = {1}
    AND T.BATCH_NO = {2}
        ]]>
    </query>
    
    <query id="QcmZgJugdeApplyDAL.temp" desc="修改质保书标志">
        <![CDATA[
SELECT T.* FROM QCM_ZG_JUGDE_APPLY T, QCM_ZBS_INFO A
 WHERE T.ZBS_FLAG IN ('1', '2') AND T.JUDGE_TOLRESULT IS NOT NULL
 AND T.JUDGE_TOLRESULT <> '合同内合格'
 AND A.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO
 AND A.BATCH_NO = T.BATCH_NO
 AND A.PROCESS_CODE = T.PROCESS_CODE
 AND A.FLAG = '0'
 AND T.JUDGE_STOVE_NO NOT IN ('585693')
        ]]>
    </query>
    
    <query id="QcmZgJugdeApplyDAL.GetTEMP" desc="修改质保书标志">
        <![CDATA[
SELECT A.*, ROWID
  FROM QCM_ZC_CHECKCONSIGN A
 WHERE A.CHECK_NO = '178837242'
        ]]>
    </query>
    
    <query id="QcmZgJugdeApplyDAL.setCraftSeq" desc="修改工艺版本">
        <![CDATA[
UPDATE QCM_ZG_JUGDE_APPLY T
   SET T.CRAF_NO        = {4},
       T.CRAFT_SEQ      = {5},
       T.CIC            = {6},
       T.PIC            = {7},
       T.SIC            = {8},
       T.DIC            = {9},
       T.WIC            = {10},
       T.GIC            = {11},
       T.STEEL_STANDRAD = {12}
 WHERE T.JUDGE_STOVE_NO = {0}
   AND T.BATCH_NO = {1}
   AND T.PROCESS_CODE = {2}
   AND T.ORD_LN_DLY_PK = {3}
   AND T.IS_FLAG = '0'
   AND T.IS_ALL_SCRAP IN ('0', '4', '5', '6', '7', '8')
        ]]>
    </query>
    
    <query id="QcmZgJugdeApplyDAL.getJudgeBatchNoByLoadStoveNo" desc="通过上料炉号查询">
        <![CDATA[
SELECT T.JUGDE_APPLY_CODE, T.JUDGE_STOVE_NO, T.BATCH_NO, T.TARGET
  FROM QCM_ZG_JUGDE_APPLY T
 WHERE T.LOAD_JUDGE_STOVE_NO = {0}
  AND T.PROCESS_CODE = {1}
  AND T.IS_FLAG = '0'
  AND T.IS_ALL_SCRAP IN ('0', '4', '5', '6', '7', '8')
 GROUP BY T.JUGDE_APPLY_CODE, T.JUDGE_STOVE_NO, T.BATCH_NO, T.TARGET
        ]]>
    </query>
    
     <query id="QcmZgJugdeApplyDAL.getJudgeBatchNoByLoadStoveNoBatchNo" desc="通过上料炉号+性能批号查询">
        <![CDATA[
SELECT T.JUGDE_APPLY_CODE, T.JUDGE_STOVE_NO, T.BATCH_NO, T.TARGET
  FROM QCM_ZG_JUGDE_APPLY T
 WHERE T.LOAD_JUDGE_STOVE_NO = {0}
 AND T.BATCH_NO = {1}
 AND T.PROCESS_CODE = {2}
 AND T.IS_FLAG = '0'
 AND T.IS_ALL_SCRAP IN ('0', '4', '5', '6', '7', '8')
 GROUP BY T.JUGDE_APPLY_CODE, T.JUDGE_STOVE_NO, T.BATCH_NO, T.TARGET
        ]]>
    </query>
    
    <query id="QcmZgJugdeApplyDAL.setZcJudgeCondition" desc="修改成品判定条件">
        <![CDATA[
UPDATE QCM_ZG_JUGDE_APPLY T
   SET T.ZC_JUDGE_CONDITION = {3}
 WHERE T.JUGDE_APPLY_CODE = {0}
   AND T.JUDGE_STOVE_NO = {1}
   AND T.BATCH_NO = {2}
   AND T.IS_FLAG = '0'
   AND T.IS_ALL_SCRAP IN ('0', '4', '5', '6', '7', '8')
        ]]>
    </query>
    
    <query id="QcmZgJugdeApplyDAL.getByBatchNoGroupByApplyCode" desc="通过炉批查询，送判单分组">
        <![CDATA[
SELECT T.JUGDE_APPLY_CODE, T.JUDGE_STOVE_NO, T.BATCH_NO, MIN(T.JUDGE_RESULT_CODE) JUDGE_RESULT_CODE
  FROM QCM_ZG_JUGDE_APPLY T
 WHERE T.JUDGE_STOVE_NO = {0}
   AND T.BATCH_NO = {1}
   AND PROCESS_CODE = {2}
   AND T.IS_FLAG = '0'
   AND T.IS_ALL_SCRAP IN ('0', '4', '5', '6', '7', '8')
 GROUP BY T.JUGDE_APPLY_CODE, T.JUDGE_STOVE_NO, T.BATCH_NO
        ]]>
    </query>

    <query id="QcmZgJugdeApplyDAL.updateCraftSeq" desc="更新工艺版本">
        <![CDATA[
UPDATE QCM_ZG_JUGDE_APPLY T
   SET T.CRAFT_SEQ =
       (SELECT B.CRAFT_SEQ
          FROM SLM_ORDER_LINE_DELIVERY A, CRAFT_ORD_DESIGN B
         WHERE A.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK
           AND A.ORD_LN_PK = B.ORD_LN_PK
           AND B.VALIDFLAG = '1'),
       T.CRAF_NO  =
       (SELECT B.CRAFT_NO
          FROM SLM_ORDER_LINE_DELIVERY A, CRAFT_ORD_DESIGN B
         WHERE A.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK
           AND A.ORD_LN_PK = B.ORD_LN_PK
           AND B.VALIDFLAG = '1'),
       T.PIC      =
       (SELECT MIN(C.PIC)
          FROM SLM_ORDER_LINE_DELIVERY A, CRAFT_ORD_DESIGN B, CRAFT_ORD_DESIGN_STD_PIC C
         WHERE A.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK
           AND A.ORD_LN_PK = B.ORD_LN_PK
           AND B.VALIDFLAG = '1'
           AND C.DESGIN_KEY = B.DESGIN_KEY
           AND C.MSC_PLINE = T.INDEX_SEQ
           AND C.PROCESS_CODE = T.PROCESS_CODE
           AND C.SPECL_FL = '2'
           AND C.CRAFT_SOURCE = '0')
 WHERE T.JUGDE_APPLY_CODE = {0}
   AND T.JUDGE_STOVE_NO = {1}
   AND T.BATCH_NO = {2}
   AND T.IS_FLAG = '0'
        ]]>
    </query>

    <query id="QcmZgJugdeApplyDAL.updateCraftSeqBL" desc="更新工艺版本">
        <![CDATA[
UPDATE QCM_ZG_JUGDE_APPLY T
   SET T.CRAFT_SEQ =
       (SELECT B.CRAFT_SEQ
          FROM PLN_SALEORD A, CRAFT_ORD_DESIGN B
         WHERE A.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK
           AND A.ORD_LN_PK = B.ORD_LN_PK
           AND B.VALIDFLAG = '1'),
       T.CRAF_NO  =
       (SELECT B.CRAFT_NO
          FROM PLN_SALEORD A, CRAFT_ORD_DESIGN B
         WHERE A.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK
           AND A.ORD_LN_PK = B.ORD_LN_PK
           AND B.VALIDFLAG = '1'),
       T.PIC      =
       (SELECT MIN(C.PIC)
          FROM PLN_SALEORD A, CRAFT_ORD_DESIGN B, CRAFT_ORD_DESIGN_STD_PIC C
         WHERE A.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK
           AND A.ORD_LN_PK = B.ORD_LN_PK
           AND B.VALIDFLAG = '1'
           AND C.DESGIN_KEY = B.DESGIN_KEY
           AND C.MSC_PLINE = T.INDEX_SEQ
           AND C.PROCESS_CODE = T.PROCESS_CODE
           AND C.SPECL_FL = '2'
           AND C.CRAFT_SOURCE = '0')
 WHERE T.JUGDE_APPLY_CODE = {0}
   AND T.JUDGE_STOVE_NO = {1}
   AND T.BATCH_NO = {2}
   AND T.IS_FLAG = '0'
        ]]>
    </query>

    <query id="QcmZgJugdeApplyDAL.setAutoJudge" desc="自动判定标识">
        <![CDATA[
UPDATE QCM_ZG_JUGDE_APPLY T
   SET T.AUTO_JUDGE = '1'
 WHERE T.JUGDE_APPLY_CODE = {0}
   AND T.JUDGE_STOVE_NO = {1}
   AND T.BATCH_NO = {2}
        ]]>
    </query>

    <query id="QcmZgJugdeApply.querySupplyUnit" desc="查询制造商">
        <![CDATA[
        SELECT SUPPLY_UNIT FROM QCM_ZG_JUGDE_APPLY T
        WHERE T.JUGDE_APPLY_CODE = {0}
        ]]>
    </query>
    
        <query id="QcmZgJugdeApplyDAL.insertMilProcess" desc="通过批号查询">
        <![CDATA[
   DECLARE
  V_JUDGE_STOVE_NO MIL_PROCESSES.JUDGE_STOVE_NO%TYPE := ?;
  V_LOT_NO         MIL_PROCESSES.LOT_NO%TYPE := ?;
  V_PLINE_CODE     MIL_PROCESSES.PLINE_CODE%TYPE := ?;
  V_PRO_PLAN_ID    MIL_PROCESSES.PRO_PLAN_ID%TYPE := ?;
  V_GX_PLAN_NO     MIL_PROCESSES.GX_PLAN_NO%TYPE := ?;
  V_COUNT          MIL_PROCESSES.YJZ%TYPE := NULL;

BEGIN
  SELECT COUNT(1)
    INTO V_COUNT
    FROM MIL_PROCESSES T
   WHERE T.JUDGE_STOVE_NO = REGEXP_REPLACE(V_JUDGE_STOVE_NO, '-.*', '')
     AND T.LOT_NO = V_LOT_NO
     AND T.PLINE_CODE = V_PLINE_CODE
     AND NVL(T.PRO_PLAN_ID, '/') = NVL(V_PRO_PLAN_ID, '/')
     AND NVL(T.GX_PLAN_NO, '/') = NVL(V_GX_PLAN_NO, '/');

  FOR MYROW IN (SELECT AA.*,
                       CASE
                         WHEN AA.NODE_STATUS < 20 THEN
                          0
                         ELSE
                          AA.HGZ1 - AA.FPZ2
                       END HGZ2,
                       CASE
                         WHEN AA.NODE_STATUS < 20 THEN
                          0
                         ELSE
                          AA.HGD1 - AA.FPD2
                       END HGD2,
                       
                       CASE
                         WHEN AA.NODE_STATUS < 30 THEN
                          0
                         ELSE
                          AA.HGZ1 - AA.FPZ2 - AA.FPZ3
                       END HGZ3,
                       CASE
                         WHEN AA.NODE_STATUS < 30 THEN
                          0
                         ELSE
                          AA.HGD1 - AA.FPD2 - AA.FPD3
                       END HGD3,
                       
                       CASE
                         WHEN AA.NODE_STATUS < 40 THEN
                          0
                         ELSE
                          AA.HGZ1 - AA.FPZ2 - AA.FPZ3 - AA.FPZ4
                       END HGZ4,
                       CASE
                         WHEN AA.NODE_STATUS < 40 THEN
                          0
                         ELSE
                          AA.HGD1 - AA.FPD2 - AA.FPD3 - AA.FPD4
                       END HGD4,
                       
                       CASE
                         WHEN AA.NODE_STATUS < 50 THEN
                          0
                         ELSE
                          AA.HGZ1 - AA.FPZ2 - AA.FPZ3 - AA.FPZ4 - AA.FPZ5
                       END HGZ5,
                       CASE
                         WHEN AA.NODE_STATUS < 50 THEN
                          0
                         ELSE
                          AA.HGD1 - AA.FPD2 - AA.FPD3 - AA.FPD4 - AA.FPD5
                       END HGD5,
                       
                       CASE
                         WHEN AA.NODE_STATUS < 60 THEN
                          0
                         ELSE
                          AA.HGZ1 - AA.FPZ2 - AA.FPZ3 - AA.FPZ4 - AA.FPZ5 -
                          AA.FPZ6
                       END HGZ6,
                       CASE
                         WHEN AA.NODE_STATUS < 60 THEN
                          0
                         ELSE
                          AA.HGD1 - AA.FPD2 - AA.FPD3 - AA.FPD4 - AA.FPD5 -
                          AA.FPD6
                       END HGD6,
                       
                       CASE
                         WHEN AA.NODE_STATUS < 80 THEN
                          0
                         ELSE
                          AA.HGZ7 - AA.FPZ9 - AA.XXZ9 - AA.ZLZ9
                       END HGZ9,
                       CASE
                         WHEN AA.NODE_STATUS < 80 THEN
                          0
                         ELSE
                          AA.HGD7 - AA.FPD9 - AA.XXD9 - AA.ZLD9
                       END HGD9,
                       
                       CASE
                         WHEN AA.NODE_STATUS < 90 THEN
                          0
                         ELSE
                          AA.HGZ7 - AA.FPZ9 - AA.XXZ9 - AA.FPZ10 - AA.XXZ10 -
                          AA.ZLZ10
                       END HGZ10,
                       CASE
                         WHEN AA.NODE_STATUS < 90 THEN
                          0
                         ELSE
                          AA.HGD7 - AA.FPD9 - AA.XXD9 - AA.FPD10 - AA.XXD10 -
                          AA.ZLD10
                       END HGD10,
                       
                       CASE
                         WHEN AA.NODE_STATUS < 96 THEN
                          0
                         ELSE
                          AA.HGZ7 - AA.FPZ9 - AA.XXZ9 - AA.FPZ10 - AA.XXZ10 -
                          AA.FPZ11 - AA.XXZ11 - AA.ZLZ11
                       END HGZ11,
                       CASE
                         WHEN AA.NODE_STATUS < 96 THEN
                          0
                         ELSE
                          AA.HGD7 - AA.FPD9 - AA.XXD9 - AA.FPD10 - AA.XXD10 -
                          AA.FPD11 - AA.XXD11 - AA.ZLD11
                       END HGD11,
                       CASE AA.NODE_STATUS
                         WHEN '10' THEN
                          '锯切完成'
                         WHEN '20' THEN
                          '出炉'
                         WHEN '30' THEN
                          '穿孔完成'
                         WHEN '40' THEN
                          '连轧完成'
                         WHEN '50' THEN
                          '出再加热炉'
                         WHEN '60' THEN
                          '出定径'
                         WHEN '70' THEN
                          '分切完成'
                         WHEN '80' THEN
                          '矫直完成'
                         WHEN '90' THEN
                          '探伤完成'
                         WHEN '96' THEN
                          '质检完成'
                         WHEN '99' THEN
                          '下线'
                       END NODE_STATUS1
                
                  FROM (select REGEXP_REPLACE(T1.JUDGE_STOVE_NO, '-.*', '') JUDGE_STOVE_NO,
                               T1.ID,
                               T1.LOT_NO,
                               T1.PLINE_CODE,
                               (SELECT A.PLINE_NAME
                                  FROM COM_BASE_PLINE A
                                 WHERE A.PLINE_CODE = T1.PLINE_CODE) PLINE_CODE1,
                               T1.CONTRACT_NO,
                               MAX(T1.TARGET) TARGET,
                               MAX(T1.VARIETIES) VARIETIES,
                               MAX(T1.VARIETIES_CODE) VARIETIES_CODE,
                               MAX(T1.STEELNAME) STEELNAME,
                               MAX(T1.STEELCODE) STEELCODE,
                               MAX(T1.GRADENAME) GRADENAME,
                               MAX(T1.GRADECODE) GRADECODE,
                               REPLACE(MAX(T1.PIPE_SIZE), '*', 'x') PIPE_SIZE,
                               MAX(T1.PIPE_SIZE_CODE) PIPE_SIZE_CODE,
                               MAX(T1.BUCKLE_TYPE) BUCKLE_TYPE,
                               MAX(T1.BUCKLE_TYPE_CODE) BUCKLE_TYPE_CODE,
                               MAX(T1.LENGTH_RANGE) LENGTH_RANGE,
                               MAX(T1.ROLL_STANDRAD) ROLL_STANDRAD,
                               MIN(T1.FEED_TIME) FEED_TIME,
                               
                               --MAX(T1.NODE_STATUS) NODE_STATUS,
                               MAX(T1.PRO_PLAN_ID) PRO_PLAN_ID,
                               MAX(T1.GX_PLAN_NO) GX_PLAN_NO,
                               
                               (SELECT MAX(NODE_STATUS)
                                  FROM MIL_PLAN
                                 WHERE ID = T1.ID) NODE_STATUS,
                               
                               (SELECT count(1)
                                  from (SELECT B.JUDGE_STOVE_NO,
                                               B.m_mat_no,
                                               SUM(B.ACT_THEORY_WEIGHT) ACT_THEORY_WEIGHT
                                          FROM PORT_MIL_BATCH_SAMPLE_RESULT B
                                         WHERE B.IS_VALID = '1'
                                           AND (TRIM(B.Op_Process) != '0' OR
                                               B.Op_Process IS NULL)
                                         group by B.m_mat_no, B.JUDGE_STOVE_NO) A
                                 WHERE A.JUDGE_STOVE_NO = T1.JUDGE_STOVE_NO
                                 GROUP BY A.JUDGE_STOVE_NO) HGZ1,
                               
                               (SELECT SUM(A.ACT_THEORY_WEIGHT)
                                  from (SELECT B.JUDGE_STOVE_NO,
                                               B.m_mat_no,
                                               SUM(B.ACT_THEORY_WEIGHT) ACT_THEORY_WEIGHT
                                          FROM PORT_MIL_BATCH_SAMPLE_RESULT B
                                         WHERE B.IS_VALID = '1'
                                           AND (TRIM(B.Op_Process) != '0' OR
                                               B.Op_Process IS NULL)
                                         group by B.m_mat_no, B.JUDGE_STOVE_NO) A
                                 WHERE A.JUDGE_STOVE_NO = T1.JUDGE_STOVE_NO
                                 GROUP BY A.JUDGE_STOVE_NO) HGD1,
                               
                               (select COUNT(1)
                                  from (select B.JUDGE_STOVE_NO,
                                               TRIM(B.OP_PROCESS) OP_PROCESS,
                                               B.m_mat_no,
                                               SUM(B.ACT_THEORY_WEIGHT) ACT_THEORY_WEIGHT
                                          from PORT_MIL_BATCH_SAMPLE_RESULT B
                                         WHERE B.IS_VALID = '1'
                                           AND B.STATUS = '1'
                                         group by B.JUDGE_STOVE_NO,
                                                  B.m_mat_no,
                                                  B.op_process) A
                                 WHERE A.JUDGE_STOVE_NO = T1.JUDGE_STOVE_NO
                                   AND A.OP_PROCESS = '0') FPZ1,
                               
                               NVL((select SUM(A.ACT_THEORY_WEIGHT)
                                     from (select B.JUDGE_STOVE_NO,
                                                  TRIM(B.OP_PROCESS) OP_PROCESS,
                                                  B.m_mat_no,
                                                  SUM(B.ACT_THEORY_WEIGHT) ACT_THEORY_WEIGHT
                                             from PORT_MIL_BATCH_SAMPLE_RESULT B
                                            WHERE B.IS_VALID = '1'
                                              AND B.STATUS = '1'
                                            group by B.JUDGE_STOVE_NO,
                                                     B.m_mat_no,
                                                     B.op_process) A
                                    WHERE A.JUDGE_STOVE_NO =
                                          T1.JUDGE_STOVE_NO
                                      AND A.OP_PROCESS = '0'),
                                   0) FPD1,
                               
                               (select COUNT(1)
                                  from (select B.JUDGE_STOVE_NO,
                                               TRIM(B.OP_PROCESS) OP_PROCESS,
                                               B.m_mat_no,
                                               SUM(B.ACT_THEORY_WEIGHT) ACT_THEORY_WEIGHT
                                          from PORT_MIL_BATCH_SAMPLE_RESULT B
                                         WHERE B.IS_VALID = '1'
                                           AND B.STATUS = '1'
                                         group by B.JUDGE_STOVE_NO,
                                                  B.m_mat_no,
                                                  B.op_process) A
                                 WHERE A.JUDGE_STOVE_NO = T1.JUDGE_STOVE_NO
                                   AND A.OP_PROCESS = '2') FPZ2,
                               
                               NVL((select SUM(A.ACT_THEORY_WEIGHT)
                                     from (select B.JUDGE_STOVE_NO,
                                                  TRIM(B.OP_PROCESS) OP_PROCESS,
                                                  B.m_mat_no,
                                                  SUM(B.ACT_THEORY_WEIGHT) ACT_THEORY_WEIGHT
                                             from PORT_MIL_BATCH_SAMPLE_RESULT B
                                            WHERE B.IS_VALID = '1'
                                              AND B.STATUS = '1'
                                            group by B.JUDGE_STOVE_NO,
                                                     B.m_mat_no,
                                                     B.op_process) A
                                    WHERE A.JUDGE_STOVE_NO =
                                          T1.JUDGE_STOVE_NO
                                      AND A.OP_PROCESS = '2'),
                                   0) FPD2,
                               
                               (select COUNT(1)
                                  from (select B.JUDGE_STOVE_NO,
                                               TRIM(B.OP_PROCESS) OP_PROCESS,
                                               B.m_mat_no,
                                               SUM(B.ACT_THEORY_WEIGHT) ACT_THEORY_WEIGHT
                                          from PORT_MIL_BATCH_SAMPLE_RESULT B
                                         WHERE B.IS_VALID = '1'
                                           AND B.STATUS = '1'
                                         group by B.JUDGE_STOVE_NO,
                                                  B.m_mat_no,
                                                  B.op_process) A
                                 WHERE A.JUDGE_STOVE_NO = T1.JUDGE_STOVE_NO
                                   AND A.OP_PROCESS = '3') FPZ3,
                               
                               NVL((select SUM(A.ACT_THEORY_WEIGHT)
                                     from (select B.JUDGE_STOVE_NO,
                                                  TRIM(B.OP_PROCESS) OP_PROCESS,
                                                  B.m_mat_no,
                                                  SUM(B.ACT_THEORY_WEIGHT) ACT_THEORY_WEIGHT
                                             from PORT_MIL_BATCH_SAMPLE_RESULT B
                                            WHERE B.IS_VALID = '1'
                                              AND B.STATUS = '1'
                                            group by B.JUDGE_STOVE_NO,
                                                     B.m_mat_no,
                                                     B.op_process) A
                                    WHERE A.JUDGE_STOVE_NO =
                                          T1.JUDGE_STOVE_NO
                                      AND A.OP_PROCESS = '3'),
                                   0) FPD3,
                               
                               (select COUNT(1)
                                  from (select B.JUDGE_STOVE_NO,
                                               TRIM(B.OP_PROCESS) OP_PROCESS,
                                               B.m_mat_no,
                                               SUM(B.ACT_THEORY_WEIGHT) ACT_THEORY_WEIGHT
                                          from PORT_MIL_BATCH_SAMPLE_RESULT B
                                         WHERE B.IS_VALID = '1'
                                           AND B.STATUS = '1'
                                         group by B.JUDGE_STOVE_NO,
                                                  B.m_mat_no,
                                                  B.op_process) A
                                 WHERE A.JUDGE_STOVE_NO = T1.JUDGE_STOVE_NO
                                   AND A.OP_PROCESS = '4') FPZ4,
                               
                               NVL((select SUM(A.ACT_THEORY_WEIGHT)
                                     from (select B.JUDGE_STOVE_NO,
                                                  TRIM(B.OP_PROCESS) OP_PROCESS,
                                                  B.m_mat_no,
                                                  SUM(B.ACT_THEORY_WEIGHT) ACT_THEORY_WEIGHT
                                             from PORT_MIL_BATCH_SAMPLE_RESULT B
                                            WHERE B.IS_VALID = '1'
                                              AND B.STATUS = '1'
                                            group by B.JUDGE_STOVE_NO,
                                                     B.m_mat_no,
                                                     B.op_process) A
                                    WHERE A.JUDGE_STOVE_NO =
                                          T1.JUDGE_STOVE_NO
                                      AND A.OP_PROCESS = '4'),
                                   0) FPD4,
                               
                               (select COUNT(1)
                                  from (select B.JUDGE_STOVE_NO,
                                               TRIM(B.OP_PROCESS) OP_PROCESS,
                                               B.m_mat_no,
                                               SUM(B.ACT_THEORY_WEIGHT) ACT_THEORY_WEIGHT
                                          from PORT_MIL_BATCH_SAMPLE_RESULT B
                                         WHERE 1 = 1
                                           AND B.IS_VALID = '1'
                                           AND B.STATUS = '1'
                                         group by B.JUDGE_STOVE_NO,
                                                  B.m_mat_no,
                                                  B.op_process) A
                                 WHERE A.JUDGE_STOVE_NO = T1.JUDGE_STOVE_NO
                                   AND A.OP_PROCESS = '5') FPZ5,
                               
                               NVL((select SUM(A.ACT_THEORY_WEIGHT)
                                     from (select B.JUDGE_STOVE_NO,
                                                  TRIM(B.OP_PROCESS) OP_PROCESS,
                                                  B.m_mat_no,
                                                  SUM(B.ACT_THEORY_WEIGHT) ACT_THEORY_WEIGHT
                                             from PORT_MIL_BATCH_SAMPLE_RESULT B
                                            WHERE B.IS_VALID = '1'
                                              AND B.STATUS = '1'
                                            group by B.JUDGE_STOVE_NO,
                                                     B.m_mat_no,
                                                     B.op_process) A
                                    WHERE A.JUDGE_STOVE_NO =
                                          T1.JUDGE_STOVE_NO
                                      AND A.OP_PROCESS = '5'),
                                   0) FPD5,
                               
                               (select COUNT(1)
                                  from (select B.JUDGE_STOVE_NO,
                                               TRIM(B.OP_PROCESS) OP_PROCESS,
                                               B.m_mat_no,
                                               SUM(B.ACT_THEORY_WEIGHT) ACT_THEORY_WEIGHT
                                          from PORT_MIL_BATCH_SAMPLE_RESULT B
                                         WHERE B.IS_VALID = '1'
                                           AND B.STATUS = '1'
                                         group by B.JUDGE_STOVE_NO,
                                                  B.m_mat_no,
                                                  B.op_process) A
                                 WHERE A.JUDGE_STOVE_NO = T1.JUDGE_STOVE_NO
                                   AND A.OP_PROCESS = '6') FPZ6,
                               
                               NVL((select SUM(A.ACT_THEORY_WEIGHT)
                                     from (select B.JUDGE_STOVE_NO,
                                                  TRIM(B.OP_PROCESS) OP_PROCESS,
                                                  B.m_mat_no,
                                                  SUM(B.ACT_THEORY_WEIGHT) ACT_THEORY_WEIGHT
                                             from PORT_MIL_BATCH_SAMPLE_RESULT B
                                            WHERE B.IS_VALID = '1'
                                              AND B.STATUS = '1'
                                            group by B.JUDGE_STOVE_NO,
                                                     B.m_mat_no,
                                                     B.op_process) A
                                    WHERE A.JUDGE_STOVE_NO =
                                          T1.JUDGE_STOVE_NO
                                      AND A.OP_PROCESS = '6'),
                                   0) FPD6,
                               
                               (SELECT sum(A.act_count)
                                  FROM PORT_MIL_BATCH_SAMPLE_RESULT A
                                 WHERE A.IS_VALID = '1'
                                   AND A.STATUS <> '1'
                                   AND (TRIM(A.OP_PROCESS) <> '7' OR
                                       A.OP_PROCESS IS NULL)
                                   AND SUBSTR(A.JUDGE_STOVE_NO, -2) = '01'
                                   AND A.JUDGE_STOVE_NO = T1.JUDGE_STOVE_NO) HGZ7,
                               
                               (SELECT SUM(A.ACT_THEORY_WEIGHT)
                                  FROM PORT_MIL_BATCH_SAMPLE_RESULT A
                                 WHERE A.IS_VALID = '1'
                                   AND A.STATUS <> '1'
                                   AND (TRIM(A.OP_PROCESS) <> '7' OR
                                       A.OP_PROCESS IS NULL)
                                   AND SUBSTR(A.JUDGE_STOVE_NO, -2) = '01'
                                   AND A.JUDGE_STOVE_NO = T1.JUDGE_STOVE_NO) HGD7,
                               
                               NVL((select sum(A.act_count)
                                     from PORT_MIL_BATCH_SAMPLE_RESULT A
                                    WHERE A.IS_VALID = '1'
                                      AND A.STATUS = '2'
                                      AND TRIM(A.OP_PROCESS) = '7'
                                      AND A.JUDGE_STOVE_NO =
                                          T1.JUDGE_STOVE_NO),
                                   0) FPZ7,
                               
                               NVL((select SUM(A.ACT_THEORY_WEIGHT)
                                     from PORT_MIL_BATCH_SAMPLE_RESULT A
                                    WHERE A.IS_VALID = '1'
                                      AND A.STATUS = '2'
                                      AND TRIM(A.OP_PROCESS) = '7'
                                      AND A.JUDGE_STOVE_NO =
                                          T1.JUDGE_STOVE_NO),
                                   0) FPD7,
                               
                               NVL((select sum(1)
                                     from PORT_MIL_BATCH_SAMPLE_RESULT A
                                    WHERE A.IS_VALID = '1'
                                      AND A.STATUS = '2'
                                      AND TRIM(A.OP_PROCESS) = '9'
                                      AND A.PLAN_ID = T1.ID
                                      AND REGEXP_REPLACE(A.JUDGE_STOVE_NO, '-.*', '') =
                                          REGEXP_REPLACE(T1.JUDGE_STOVE_NO, '-.*', '')),
                                   0) FPZ9,
                               
                               NVL((select sum(A.act_count)
                                     from PORT_MIL_BATCH_SAMPLE_RESULT A
                                    WHERE A.IS_VALID = '1'
                                      AND A.STATUS = '2'
                                      AND TRIM(A.OP_PROCESS) = '9'
                                      AND A.PLAN_ID = T1.ID
                                      AND REGEXP_REPLACE(A.JUDGE_STOVE_NO, '-.*', '') =
                                          REGEXP_REPLACE(T1.JUDGE_STOVE_NO, '-.*', '')),
                                   0) FPD9,
                               
                               NVL((select sum(A.act_count)
                                     from PORT_MIL_BATCH_SAMPLE_RESULT A
                                    WHERE A.IS_VALID = '1'
                                      AND A.STATUS = '3'
                                      AND TRIM(A.OP_PROCESS) = '9'
                                      AND A.PLAN_ID = T1.ID
                                      AND REGEXP_REPLACE(A.JUDGE_STOVE_NO, '-.*', '') =
                                          REGEXP_REPLACE(T1.JUDGE_STOVE_NO, '-.*', '')),
                                   0) XXZ9,
                               
                               NVL((select SUM(A.ACT_THEORY_WEIGHT)
                                     from PORT_MIL_BATCH_SAMPLE_RESULT A
                                    WHERE A.IS_VALID = '1'
                                      AND A.STATUS = '3'
                                      AND TRIM(A.OP_PROCESS) = '9'
                                      AND A.PLAN_ID = T1.ID
                                      AND REGEXP_REPLACE(A.JUDGE_STOVE_NO, '-.*', '') =
                                          REGEXP_REPLACE(T1.JUDGE_STOVE_NO, '-.*', '')),
                                   0) XXD9,
                               
                               NVL((select sum(A.act_count)
                                     from PORT_MIL_BATCH_SAMPLE_RESULT A
                                    WHERE A.IS_VALID = '1'
                                      AND A.STATUS IN ('2', '5')
                                      AND TRIM(A.OP_PROCESS) = '10'
                                      AND A.PLAN_ID = T1.ID
                                      AND REGEXP_REPLACE(A.JUDGE_STOVE_NO, '-.*', '') =
                                          REGEXP_REPLACE(T1.JUDGE_STOVE_NO, '-.*', '')),
                                   0) FPZ10,
                               
                               NVL((select SUM(A.ACT_THEORY_WEIGHT)
                                     from PORT_MIL_BATCH_SAMPLE_RESULT A
                                    WHERE A.IS_VALID = '1'
                                      AND A.STATUS IN ('2', '5')
                                      AND TRIM(A.OP_PROCESS) = '10'
                                      AND A.PLAN_ID = T1.ID
                                      AND REGEXP_REPLACE(A.JUDGE_STOVE_NO, '-.*', '') =
                                          REGEXP_REPLACE(T1.JUDGE_STOVE_NO, '-.*', '')),
                                   0) FPD10,
                               
                               NVL((select sum(A.act_count)
                                     from PORT_MIL_BATCH_SAMPLE_RESULT A
                                    WHERE A.IS_VALID = '1'
                                      AND A.STATUS = '3'
                                      AND TRIM(A.OP_PROCESS) = '10'
                                      AND A.PLAN_ID = T1.ID
                                      AND REGEXP_REPLACE(A.JUDGE_STOVE_NO, '-.*', '') =
                                          REGEXP_REPLACE(T1.JUDGE_STOVE_NO, '-.*', '')),
                                   0) XXZ10,
                               
                               NVL((select SUM(A.ACT_THEORY_WEIGHT)
                                     from PORT_MIL_BATCH_SAMPLE_RESULT A
                                    WHERE A.IS_VALID = '1'
                                      AND A.STATUS = '3'
                                      AND TRIM(A.OP_PROCESS) = '10'
                                      AND A.PLAN_ID = T1.ID
                                      AND REGEXP_REPLACE(A.JUDGE_STOVE_NO, '-.*', '') =
                                          REGEXP_REPLACE(T1.JUDGE_STOVE_NO, '-.*', '')),
                                   0) XXD10,
                               
                               NVL((select sum(A.act_count)
                                     from PORT_MIL_BATCH_SAMPLE_RESULT A
                                    WHERE A.IS_VALID = '1'
                                      AND A.STATUS = '2'
                                      AND TRIM(A.OP_PROCESS) = '11'
                                      AND A.PLAN_ID = T1.ID
                                      AND REGEXP_REPLACE(A.JUDGE_STOVE_NO, '-.*', '') =
                                          REGEXP_REPLACE(T1.JUDGE_STOVE_NO, '-.*', '')),
                                   0) FPZ11,
                               
                               NVL((select SUM(A.ACT_THEORY_WEIGHT)
                                     from PORT_MIL_BATCH_SAMPLE_RESULT A
                                    WHERE A.IS_VALID = '1'
                                      AND A.STATUS = '2'
                                      AND TRIM(A.OP_PROCESS) = '11'
                                      AND A.PLAN_ID = T1.ID
                                      AND REGEXP_REPLACE(A.JUDGE_STOVE_NO, '-.*', '') =
                                          REGEXP_REPLACE(T1.JUDGE_STOVE_NO, '-.*', '')),
                                   0) FPD11,
                               
                               NVL((select sum(A.act_count)
                                     from PORT_MIL_BATCH_SAMPLE_RESULT A
                                    WHERE A.IS_VALID = '1'
                                      AND A.STATUS = '3'
                                      AND TRIM(A.OP_PROCESS) = '11'
                                      AND A.PLAN_ID = T1.ID
                                      AND REGEXP_REPLACE(A.JUDGE_STOVE_NO, '-.*', '') =
                                          REGEXP_REPLACE(T1.JUDGE_STOVE_NO, '-.*', '')),
                                   0) XXZ11,
                               
                               NVL((select SUM(A.ACT_THEORY_WEIGHT)
                                     from PORT_MIL_BATCH_SAMPLE_RESULT A
                                    WHERE A.IS_VALID = '1'
                                      AND A.STATUS = '3'
                                      AND TRIM(A.OP_PROCESS) = '11'
                                      AND A.PLAN_ID = T1.ID
                                      AND REGEXP_REPLACE(A.JUDGE_STOVE_NO, '-.*', '') =
                                          REGEXP_REPLACE(T1.JUDGE_STOVE_NO, '-.*', '')),
                                   0) XXD11,
                               
                               NVL((select sum(1)
                                     from PORT_MIL_BATCH_SAMPLE_RESULT A
                                    WHERE A.IS_VALID = '1'
                                      AND A.GROUP_FLAG = '1'
                                      AND TRIM(A.OP_PROCESS) = '9'
                                      AND A.PLAN_ID = T1.ID
                                      AND REGEXP_REPLACE(A.JUDGE_STOVE_NO, '-.*', '') =
                                          REGEXP_REPLACE(T1.JUDGE_STOVE_NO, '-.*', '')),
                                   0) ZLZ9,
                               
                               NVL((select sum(A.ACT_THEORY_WEIGHT)
                                     from PORT_MIL_BATCH_SAMPLE_RESULT A
                                    WHERE A.IS_VALID = '1'
                                      AND A.GROUP_FLAG = '1'
                                      AND TRIM(A.OP_PROCESS) = '9'
                                      AND A.PLAN_ID = T1.ID
                                      AND REGEXP_REPLACE(A.JUDGE_STOVE_NO, '-.*', '') =
                                          REGEXP_REPLACE(T1.JUDGE_STOVE_NO, '-.*', '')),
                                   0) ZLD9,
                               
                               NVL((select sum(1)
                                     from PORT_MIL_BATCH_SAMPLE_RESULT A
                                    WHERE A.IS_VALID = '1'
                                      AND A.GROUP_FLAG = '1'
                                      AND TRIM(A.OP_PROCESS) = '10'
                                      AND A.PLAN_ID = T1.ID
                                      AND REGEXP_REPLACE(A.JUDGE_STOVE_NO, '-.*', '') =
                                          REGEXP_REPLACE(T1.JUDGE_STOVE_NO, '-.*', '')),
                                   0) ZLZ10,
                               
                               NVL((select sum(A.ACT_THEORY_WEIGHT)
                                     from PORT_MIL_BATCH_SAMPLE_RESULT A
                                    WHERE A.IS_VALID = '1'
                                      AND A.GROUP_FLAG = '1'
                                      AND TRIM(A.OP_PROCESS) = '10'
                                      AND A.PLAN_ID = T1.ID
                                      AND REGEXP_REPLACE(A.JUDGE_STOVE_NO, '-.*', '') =
                                          REGEXP_REPLACE(T1.JUDGE_STOVE_NO, '-.*', '')),
                                   0) ZLD10,
                               
                               NVL((select sum(1)
                                     from PORT_MIL_BATCH_SAMPLE_RESULT A
                                    WHERE A.IS_VALID = '1'
                                      AND A.GROUP_FLAG = '1'
                                      AND TRIM(A.OP_PROCESS) = '11'
                                      AND A.PLAN_ID = T1.ID
                                      AND REGEXP_REPLACE(A.JUDGE_STOVE_NO, '-.*', '') =
                                          REGEXP_REPLACE(T1.JUDGE_STOVE_NO, '-.*', '')),
                                   0) ZLZ11,
                               
                               NVL((select sum(A.ACT_THEORY_WEIGHT)
                                     from PORT_MIL_BATCH_SAMPLE_RESULT A
                                    WHERE A.IS_VALID = '1'
                                      AND A.GROUP_FLAG = '1'
                                      AND TRIM(A.OP_PROCESS) = '11'
                                      AND A.PLAN_ID = T1.ID
                                      AND REGEXP_REPLACE(A.JUDGE_STOVE_NO, '-.*', '') =
                                          REGEXP_REPLACE(T1.JUDGE_STOVE_NO, '-.*', '')),
                                   0) ZLD11,
                               
                               (SELECT DECODE(B.DIRECTOR_QUANTITY,
                                              0,
                                              '',
                                              TO_CHAR(NVL(B.QUALIFIED_BRANCH, 0) * 100 /
                                                      B.DIRECTOR_QUANTITY,
                                                      'FM990.00') || '%')
                                  FROM mil_surface_result B
                                 WHERE B.JUDGE_STOVE_NO = T1.JUDGE_STOVE_NO) qualifiedRate,
                               
                               SUM(B.FEED_NUM_PLAN) SLZ,
                               SUM(B.MAT_TOTAL_HEIGHT -
                                   B.FEED_NUM * DECODE(B.CUT_TARGET,
                                          '返废',
                                          B.CUT_WEIGHT,
                                         /*  '回库',
                                          NVL(round(B.CUT_WEIGHT / B.FEED_NUM,
                                                    3),
                                              0),*/
                                          0)) SLD,
                               SUM(B.FEED_NUM_PLAN * B.DB_NUM) *
                               MAX(T1.SAW_NUM) YJZ,
                               
                               NVL((select sum(A.act_count)
                                     from PORT_MIL_BATCH_SAMPLE_RESULT A
                                    WHERE A.IS_VALID = '1'
                                      AND A.STATUS = '1'
                                      AND A.PLAN_ID = T1.ID
                                      AND REGEXP_REPLACE(A.JUDGE_STOVE_NO, '-.*', '') =
                                          REGEXP_REPLACE(T1.JUDGE_STOVE_NO, '-.*', '')),
                                   0) undeterminedNum,
                               
                               NVL((select sum(A.INPUT_WEIGHT)
                                     from PORT_MIL_BATCH_SAMPLE_RESULT A
                                    WHERE A.IS_VALID = '1'
                                      AND A.STATUS = '1'
                                      AND A.PLAN_ID = T1.ID
                                      AND REGEXP_REPLACE(A.JUDGE_STOVE_NO, '-.*', '') =
                                          REGEXP_REPLACE(T1.JUDGE_STOVE_NO, '-.*', '')),
                                   0) undeterminedD,
                               
                               NVL((select sum(A.act_count)
                                     from PORT_MIL_BATCH_SAMPLE_RESULT A
                                    WHERE A.IS_VALID = '1'
                                      AND A.STATUS IN ('2', '5')
                                      AND A.OP_PROCESS <> '14'
                                      AND A.PLAN_ID = T1.ID
                                      AND REGEXP_REPLACE(A.JUDGE_STOVE_NO, '-.*', '') =
                                          REGEXP_REPLACE(T1.JUDGE_STOVE_NO, '-.*', '')),
                                   0) ScrapNum,
                               
                               NVL((select sum(A.ACT_THEORY_WEIGHT)
                                     from PORT_MIL_BATCH_SAMPLE_RESULT A
                                    WHERE A.IS_VALID = '1'
                                      AND A.STATUS IN ('2', '5')
                                      AND A.OP_PROCESS <> '14'
                                      AND A.PLAN_ID = T1.ID
                                      AND REGEXP_REPLACE(A.JUDGE_STOVE_NO, '-.*', '') =
                                          REGEXP_REPLACE(T1.JUDGE_STOVE_NO, '-.*', '')),
                                   0) ScrapD,
                               
                               NVL((select sum(A.act_count)
                                     from PORT_MIL_BATCH_SAMPLE_RESULT A
                                    WHERE A.IS_VALID = '1'
                                      AND A.STATUS = '2'
                                      AND A.OP_PROCESS = '14'
                                      AND A.PLAN_ID = T1.ID
                                      AND REGEXP_REPLACE(A.JUDGE_STOVE_NO, '-.*', '') =
                                          REGEXP_REPLACE(T1.JUDGE_STOVE_NO, '-.*', '')),
                                   0) FQY,
                               
                               NVL((select sum(A.act_count)
                                     from PORT_MIL_BATCH_SAMPLE_RESULT A
                                    WHERE A.IS_VALID = '1'
                                      AND A.STATUS = '6'
                                      AND A.PLAN_ID = T1.ID
                                      AND REGEXP_REPLACE(A.JUDGE_STOVE_NO, '-.*', '') =
                                          REGEXP_REPLACE(T1.JUDGE_STOVE_NO, '-.*', '')),
                                   0) WWFPZ,
                               
                               NVL((SELECT NVL(SUM(T12.QUALIFIED_NUM), 0)
                                     FROM MIL_INSTORE_RESULT T12
                                    WHERE T12.RESULT_NO = T1.ID
                                      AND REGEXP_REPLACE(T12.JUDGE_STOVE_NO, '-.*', '') =
                                          REGEXP_REPLACE(T1.JUDGE_STOVE_NO, '-.*', '')
                                      AND T12.NODE_FUR_FLAG = '1'),
                                   0) XXZ,
                               
                               NVL((SELECT NVL(SUM(T12.QUALIFIED_TONS), 0)
                                     FROM MIL_INSTORE_RESULT T12
                                    WHERE T12.RESULT_NO = T1.ID
                                      AND REGEXP_REPLACE(T12.JUDGE_STOVE_NO, '-.*', '') =
                                          REGEXP_REPLACE(T1.JUDGE_STOVE_NO, '-.*', '')
                                      AND T12.NODE_FUR_FLAG = '1'),
                                   0) XXD,
                               
                               NVL((SELECT NVL(SUM(T12.QUALIFIED_NUM), 0)
                                     FROM MIL_INSTORE_RESULT T12
                                    WHERE T12.RESULT_NO = T1.ID
                                      AND REGEXP_REPLACE(T12.JUDGE_STOVE_NO, '-.*', '') =
                                          REGEXP_REPLACE(T1.JUDGE_STOVE_NO, '-.*', '')),
                                   0) HGZ12,
                               
                               NVL((SELECT NVL(SUM(T12.QUALIFIED_TONS), 0)
                                     FROM MIL_INSTORE_RESULT T12
                                    WHERE T12.RESULT_NO = T1.ID
                                      AND REGEXP_REPLACE(T12.JUDGE_STOVE_NO, '-.*', '') =
                                          REGEXP_REPLACE(T1.JUDGE_STOVE_NO, '-.*', '')),
                                   0) HGD12,
                               
                               0 HGM12,
                               
                               NVL((select SUM(Q.ACT_COUNT)
                                     from QCM_ZG_JUGDE_APPLY Q
                                    WHERE Q.VALIDFLAG = '20'
                                      AND Q.APPLY_FLAG = '0'
                                      AND Q.JUDGE_STOVE_NO =
                                          REGEXP_REPLACE(T1.JUDGE_STOVE_NO, '-.*', '')),
                                   0) PDZ,
                               
                               NVL((select DECODE(NVL(SUM(Q.ACT_WEIGHT), 0),
                                                 0,
                                                 SUM(Q.ACT_THEORY_WEIGHT),
                                                 SUM(Q.ACT_WEIGHT))
                                     from QCM_ZG_JUGDE_APPLY Q
                                    WHERE Q.VALIDFLAG = '20'
                                      AND Q.APPLY_FLAG = '0'
                                      AND Q.JUDGE_STOVE_NO =
                                          REGEXP_REPLACE(T1.JUDGE_STOVE_NO, '-.*', '')),
                                   0) PDD,
                               
                               NVL((select SUM(Q.ACT_LEN)
                                     from QCM_ZG_JUGDE_APPLY Q
                                    WHERE 1 = 1
                                      AND Q.VALIDFLAG = '20'
                                      AND Q.APPLY_FLAG = '0'
                                      AND Q.JUDGE_STOVE_NO =
                                          REGEXP_REPLACE(T1.JUDGE_STOVE_NO, '-.*', '')),
                                   0) PDM,
                               
                               NVL((select SUM(Q.ACT_COUNT)
                                     from QCM_ZG_JUGDE_APPLY Q
                                    WHERE Q.APPLY_FLAG = '0'
                                      AND Q.JUDGE_STOVE_NO =
                                          REGEXP_REPLACE(T1.JUDGE_STOVE_NO, '-.*', '')),
                                   0) SPZ,
                               
                               NVL((select DECODE(NVL(SUM(Q.ACT_WEIGHT), 0),
                                                 0,
                                                 SUM(Q.ACT_THEORY_WEIGHT),
                                                 SUM(Q.ACT_WEIGHT))
                                     from QCM_ZG_JUGDE_APPLY Q
                                    WHERE Q.APPLY_FLAG = '0'
                                      AND Q.JUDGE_STOVE_NO =
                                          REGEXP_REPLACE(T1.JUDGE_STOVE_NO, '-.*', '')),
                                   0) SPD,
                               
                               NVL((select SUM(Q.ACT_LEN)
                                     from QCM_ZG_JUGDE_APPLY Q
                                    WHERE Q.APPLY_FLAG = '0'
                                      AND Q.JUDGE_STOVE_NO =
                                          REGEXP_REPLACE(T1.JUDGE_STOVE_NO, '-.*', '')),
                                   0) SPM,
                               
                               (NVL((select sum(A.act_count)
                                      from PORT_MIL_BATCH_SAMPLE_RESULT A
                                     WHERE A.IS_VALID = '1'
                                       AND A.STATUS IN ('3', '4')
                                       AND A.OP_PROCESS <> '12'
                                       AND A.PLAN_ID = T1.ID),
                                    0) +
                               NVL((SELECT NVL(SUM(T12.OFFLINE_NUM), 0)
                                      FROM MIL_INSTORE_RESULT T12
                                     WHERE T12.RESULT_NO = T1.ID
                                       AND REGEXP_REPLACE(T12.JUDGE_STOVE_NO, '-.*', '') =
                                           REGEXP_REPLACE(T1.JUDGE_STOVE_NO, '-.*', '')),
                                    0)) LXZ,
                               
                               NVL((select sum(A.act_count)
                                     from PORT_MIL_BATCH_SAMPLE_RESULT A
                                    WHERE A.IS_VALID = '1'
                                      AND A.STATUS = '4'
                                      AND A.GROUP_FLAG = '0'
                                      AND A.PLAN_ID = T1.ID
                                      AND REGEXP_REPLACE(A.JUDGE_STOVE_NO, '-.*', '') =
                                          REGEXP_REPLACE(T1.JUDGE_STOVE_NO, '-.*', '')),
                                   0) FXZ,
                               
                               NVL((select sum(A.act_count)
                                     from PORT_MIL_BATCH_SAMPLE_RESULT A
                                    WHERE A.IS_VALID = '1'
                                      AND A.GROUP_FLAG = '1'
                                      AND TRIM(A.OP_PROCESS) > 6
                                      AND A.PLAN_ID = T1.ID
                                      AND REGEXP_REPLACE(A.JUDGE_STOVE_NO, '-.*', '') =
                                          REGEXP_REPLACE(T1.JUDGE_STOVE_NO, '-.*', '')),
                                   0) ZLZ,
                               
                               NVL((select sum(A.ACT_THEORY_WEIGHT)
                                     from PORT_MIL_BATCH_SAMPLE_RESULT A
                                    WHERE A.IS_VALID = '1'
                                      AND A.GROUP_FLAG = '1'
                                      AND TRIM(A.OP_PROCESS) > 6
                                      AND A.PLAN_ID = T1.ID
                                      AND REGEXP_REPLACE(A.JUDGE_STOVE_NO, '-.*', '') =
                                          REGEXP_REPLACE(T1.JUDGE_STOVE_NO, '-.*', '')),
                                   0) ZLD,
                               
                               (select MAX(A.BAL_YEAR_MONTH)
                                  from PORT_MIL_BATCH_SAMPLE_RESULT A
                                 WHERE A.PLAN_ID = T1.ID) BAL_YEAR_MONTH,
                               
                               TO_CHAR(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.STATUS <> '3'
                                              AND A.STATUS <> '6'
                                              AND A.JUDGE_STOVE_NO =
                                                  T1.JUDGE_STOVE_NO),
                                           0) / SUM(B.MAT_TOTAL_HEIGHT) * 100,
                                       'FM990.00') || '%' RATE,
                               
                               SUM(B.MAT_TOTAL_HEIGHT) *
                               (1 - NVL((select R.BURNNING_RATE
                                           from MIL_FUR_RESULT R
                                          WHERE R.JUDGE_STOVE_NO =
                                                T1.JUDGE_STOVE_NO) / 100,
                                        0)) -
                               DECODE(MAX(T1.CONTROL_THICKP),
                                      0,
                                      0,
                                      (MAX(T1.CUT_HEAD_LENGTHP) +
                                      MAX(T1.CUT_TRAIL_LENGTHP)) / 1000 *
                                      (0.02466 * MAX(T1.CONTROL_THICKP) / 1000 * 1.02 *
                                      ((SUBSTR(MAX(T1.PIPE_SIZE),
                                                1,
                                                INSTR(MAX(T1.PIPE_SIZE), '*') - 1)) *
                                      (CASE
                                        WHEN INSTR(MAX(T1.VARIETIES), '套管') > 0 THEN
                                         1.005
                                        WHEN INSTR(MAX(T1.VARIETIES), '油管') > 0 THEN
                                         1.005
                                        ELSE
                                         1
                                      END) -
                                      (MAX(T1.CONTROL_THICKP) / 1000 * 1.02)) *
                                      SUM(B.FEED_NUM_PLAN * B.DB_NUM))) YJD,
                               
                               TO_CHAR(NVL((select DECODE(NVL(SUM(Q.ACT_WEIGHT),
                                                             0),
                                                         0,
                                                         SUM(Q.ACT_THEORY_WEIGHT),
                                                         SUM(Q.ACT_WEIGHT))
                                             from QCM_ZG_JUGDE_APPLY Q
                                            WHERE Q.VALIDFLAG = '20'
                                              AND Q.APPLY_FLAG = '0'
                                              AND Q.JUDGE_STOVE_NO =
                                                  REGEXP_REPLACE(T1.JUDGE_STOVE_NO,
                                                                 '-.*',
                                                                 '')),
                                           0) * 100 / SUM(B.MAT_TOTAL_HEIGHT),
                                       'FM990.00') || '%' RATE2
                        
                          from MIL_PLAN T1, MIL_FEED_PLAN B
                         WHERE T1.JUDGE_STOVE_NO = B.JUDGE_STOVE_NO
                           AND T1.PRO_PLAN_ID = B.PRO_PLAN_ID
                           AND T1.BACK_SLAB_FLAG <> '2'
                           AND T1.JUDGE_STOVE_NO =
                               REGEXP_REPLACE(V_JUDGE_STOVE_NO, '-.*', '') || '-01'
                           AND T1.LOT_NO = V_LOT_NO
                           AND T1.PLINE_CODE = V_PLINE_CODE
                           AND NVL(T1.PRO_PLAN_ID, '/') =
                               NVL(V_PRO_PLAN_ID, '/')
                           AND NVL(T1.GX_PLAN_NO, '/') =
                               NVL(V_GX_PLAN_NO, '/')
                         GROUP BY T1.JUDGE_STOVE_NO,
                                  T1.LOT_NO,
                                  T1.PLINE_CODE,
                                  T1.JUDGE_STOVE_NO,
                                  T1.ID,
                                  T1.PRO_PLAN_ID,
                                  t1.gx_plan_no,
                                  T1.ID,
                                  T1.CONTRACT_NO) AA
                 ORDER BY AA.FEED_TIME ASC) LOOP
    IF (V_COUNT > 0) THEN
      UPDATE MIL_PROCESSES T
         SET T.YJZ             = MYROW.YJZ,
             T.YJD             = MYROW.YJD,
             T.SLZ             = MYROW.SLZ,
             T.SLD             = MYROW.SLD,
             T.ZZL            =
           (SELECT SUM(TR.QUALIFIED_WT)
              FROM MIL_CONTROL_LOG TR
             WHERE TR.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO || '-01'),
           T.ZZZ            =
           (SELECT SUM(TR.QUALIFIED_NUM)
              FROM MIL_CONTROL_LOG TR
             WHERE TR.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO || '-01'),
             T.UNDETERMINEDNUM = MYROW.UNDETERMINEDNUM,
             T.UNDETERMINEDD   = MYROW.UNDETERMINEDD,
             T.SCRAPNUM        = MYROW.SCRAPNUM,
             T.SCRAPD          = MYROW.SCRAPD,
             T.WWFPZ           = MYROW.WWFPZ,
             T.FQY             = MYROW.FQY,
             T.LXZ             = MYROW.LXZ,
             T.FXZ             = MYROW.FXZ,
             T.ZLZ             = MYROW.ZLZ,
             T.ZLD             = MYROW.ZLD,
             T.SPZ             = MYROW.SPZ,
             T.SPD             = MYROW.SPD,
             T.SPM             = MYROW.SPM,
             T.PDZ             = MYROW.PDZ,
             T.PDD             = MYROW.PDD,
             T.PDM             = MYROW.PDM,
             T.HGZ1            = MYROW.HGZ1,
             T.HGD1            = MYROW.HGD1,
             T.FPZ1            = MYROW.FPZ1,
             T.FPD1            = MYROW.FPD1,
             T.HGZ2            = MYROW.HGZ2,
             T.HGD2            = MYROW.HGD2,
             T.FPZ2            = MYROW.FPZ2,
             T.FPD2            = MYROW.FPD2,
             T.HGZ3            = MYROW.HGZ3,
             T.HGD3            = MYROW.HGD3,
             T.FPZ3            = MYROW.FPZ3,
             T.FPD3            = MYROW.FPD3,
             T.HGZ4            = MYROW.HGZ4,
             T.HGD4            = MYROW.HGD4,
             T.FPZ4            = MYROW.FPZ4,
             T.FPD4            = MYROW.FPD4,
             T.HGZ5            = MYROW.HGZ5,
             T.HGD5            = MYROW.HGD5,
             T.FPZ5            = MYROW.FPZ5,
             T.FPD5            = MYROW.FPD5,
             T.HGZ6            = MYROW.HGZ6,
             T.HGD6            = MYROW.HGD6,
             T.FPZ6            = MYROW.FPZ6,
             T.FPD6            = MYROW.FPD6,
             T.HGZ7            = MYROW.HGZ7,
             T.HGD7            = MYROW.HGD7,
             T.FPZ7            = MYROW.FPZ7,
             T.FPD7            = MYROW.FPD7,
             T.HGZ9            = MYROW.HGZ9,
             T.HGD9            = MYROW.HGD9,
             T.FPZ9            = MYROW.FPZ9,
             T.FPD9            = MYROW.FPD9,
             T.HGZ10           = MYROW.HGZ10,
             T.HGD10           = MYROW.HGD10,
             T.FPZ10           = MYROW.FPZ10,
             T.FPD10           = MYROW.FPD10,
             T.HGZ11           = MYROW.HGZ11,
             T.HGD11           = MYROW.HGD11,
             T.FPZ11           = MYROW.FPZ11,
             T.FPD11           = MYROW.FPD11,
             T.HGZ12           = MYROW.HGZ12,
             T.HGD12           = MYROW.HGD12,
             T.RATE            = MYROW.RATE,
             T.QUALIFIEDRATE   = MYROW.QUALIFIEDRATE,
             T.RATE2           = MYROW.RATE2,
             T.NODE_STATUS1    = MYROW.NODE_STATUS1
       WHERE T.JUDGE_STOVE_NO = MYROW.JUDGE_STOVE_NO
         AND T.LOT_NO = V_LOT_NO
         AND T.PLINE_CODE = V_PLINE_CODE
         AND NVL(T.PRO_PLAN_ID, '/') = NVL(V_PRO_PLAN_ID, '/')
         AND NVL(T.GX_PLAN_NO, '/') = NVL(V_GX_PLAN_NO, '/');
    
     ELSIF (V_COUNT = 0) THEN
      INSERT INTO MIL_PROCESSES
        (ID,
         JUDGE_STOVE_NO,
         LOT_NO,
         PRO_PLAN_ID,
         GX_PLAN_NO,
         PLINE_CODE,
         TARGET,
         VARIETIES,
         VARIETIES_CODE,
         STEELCODE,
         STEELNAME,
         GRADECODE,
         GRADENAME,
         PIPE_SIZE,
         PIPE_SIZE_CODE,
         BUCKLE_TYPE,
         BUCKLE_TYPE_CODE,
         FEED_TIME,
         SLZ,
         SLD,
         YJZ,
         YJD,
         UNDETERMINEDNUM,
         UNDETERMINEDD,
         SCRAPNUM,
         SCRAPD,
         WWFPZ,
         FQY,
         LXZ,
         FXZ,
         ZLZ,
         ZLD,
         SPZ,
         SPD,
         SPM,
         PDZ,
         PDD,
         PDM,
         HGZ1,
         HGD1,
         FPZ1,
         FPD1,
         HGZ2,
         HGD2,
         FPZ2,
         FPD2,
         HGZ3,
         HGD3,
         FPZ3,
         FPD3,
         HGZ4,
         HGD4,
         FPZ4,
         FPD4,
         HGZ5,
         HGD5,
         FPZ5,
         FPD5,
         HGZ6,
         HGD6,
         FPZ6,
         FPD6,
         HGZ7,
         HGD7,
         FPZ7,
         FPD7,
         HGZ9,
         HGD9,
         FPZ9,
         FPD9,
         HGZ10,
         HGD10,
         FPZ10,
         FPD10,
         HGZ11,
         HGD11,
         FPZ11,
         FPD11,
         HGZ12,
         HGD12,
         RATE,
         QUALIFIEDRATE,
         RATE2,
         --ZLC,
         --ISCLOSE,
         CONTRACT_NO,
         BAL_YEAR_MONTH,
         NODE_STATUS1)
      VALUES
        (MYROW.ID,
         MYROW.JUDGE_STOVE_NO,
         MYROW.LOT_NO,
         MYROW.PRO_PLAN_ID,
         MYROW.GX_PLAN_NO,
         MYROW.PLINE_CODE,
         MYROW.TARGET,
         MYROW.VARIETIES,
         MYROW.VARIETIES_CODE,
         MYROW.STEELCODE,
         MYROW.STEELNAME,
         MYROW.GRADECODE,
         MYROW.GRADENAME,
         MYROW.PIPE_SIZE,
         MYROW.PIPE_SIZE_CODE,
         MYROW.BUCKLE_TYPE,
         MYROW.BUCKLE_TYPE_CODE,
         MYROW.FEED_TIME,
         MYROW.SLZ,
         MYROW.SLD,
         MYROW.YJZ,
         MYROW.YJD,
         MYROW.UNDETERMINEDNUM,
         MYROW.UNDETERMINEDD,
         MYROW.SCRAPNUM,
         MYROW.SCRAPD,
         MYROW.WWFPZ,
         MYROW.FQY,
         MYROW.LXZ,
         MYROW.FXZ,
         MYROW.ZLZ,
         MYROW.ZLD,
         MYROW.SPZ,
         MYROW.SPD,
         MYROW.SPM,
         MYROW.PDZ,
         MYROW.PDD,
         MYROW.PDM,
         MYROW.HGZ1,
         MYROW.HGD1,
         MYROW.FPZ1,
         MYROW.FPD1,
         MYROW.HGZ2,
         MYROW.HGD2,
         MYROW.FPZ2,
         MYROW.FPD2,
         MYROW.HGZ3,
         MYROW.HGD3,
         MYROW.FPZ3,
         MYROW.FPD3,
         MYROW.HGZ4,
         MYROW.HGD4,
         MYROW.FPZ4,
         MYROW.FPD4,
         MYROW.HGZ5,
         MYROW.HGD5,
         MYROW.FPZ5,
         MYROW.FPD5,
         MYROW.HGZ6,
         MYROW.HGD6,
         MYROW.FPZ6,
         MYROW.FPD6,
         MYROW.HGZ7,
         MYROW.HGD7,
         MYROW.FPZ7,
         MYROW.FPD7,
         MYROW.HGZ9,
         MYROW.HGD9,
         MYROW.FPZ9,
         MYROW.FPD9,
         MYROW.HGZ10,
         MYROW.HGD10,
         MYROW.FPZ10,
         MYROW.FPD10,
         MYROW.HGZ11,
         MYROW.HGD11,
         MYROW.FPZ11,
         MYROW.FPD11,
         MYROW.HGZ12,
         MYROW.HGD12,
         MYROW.RATE,
         MYROW.QUALIFIEDRATE,
         MYROW.RATE2,
         --MYROW.ZLC,
         -- MYROW.ISCLOSE,
         MYROW.CONTRACT_NO,
         MYROW.BAL_YEAR_MONTH,
         MYROW.NODE_STATUS1);
    
    END IF;
  
    IF (MYROW.YJD > MYROW.HGD12) THEN
      UPDATE MIL_PROCESSES T
         SET T.ZLC = NVL(MYROW.YJD, 0) - NVL(MYROW.HGD12, 0)
       WHERE T.JUDGE_STOVE_NO = MYROW.JUDGE_STOVE_NO
         AND T.LOT_NO = V_LOT_NO
         AND T.PLINE_CODE = V_PLINE_CODE
         AND NVL(T.PRO_PLAN_ID, '/') = NVL(V_PRO_PLAN_ID, '/')
         AND NVL(T.GX_PLAN_NO, '/') = NVL(V_GX_PLAN_NO, '/');
    ELSE
      UPDATE MIL_PROCESSES T
         SET T.ZLC = 0
       WHERE T.JUDGE_STOVE_NO = MYROW.JUDGE_STOVE_NO
         AND T.LOT_NO = V_LOT_NO
         AND T.PLINE_CODE = V_PLINE_CODE
         AND NVL(T.PRO_PLAN_ID, '/') = NVL(V_PRO_PLAN_ID, '/')
         AND NVL(T.GX_PLAN_NO, '/') = NVL(V_GX_PLAN_NO, '/');
    END IF;
  END LOOP;

END;
        ]]>
    </query>

    <query id="QcmZgJugdeApplyDAL.UpdateZbsLock" desc="修改质保书锁定状态">
        <![CDATA[
        UPDATE QCM_ZG_JUGDE_APPLY SET
            ZBS_LOCK_FLAG = {3}
        WHERE
            IS_FLAG = '0'
            AND JUGDE_APPLY_CODE = {0}
            AND JUDGE_STOVE_NO = {1}
            AND BATCH_NO = {2}
        ]]>
    </query>

    <query id="QcmZgJugdeApplyDAL.getReportPath" desc="报表路径">
        <![CDATA[
        SELECT DISTINCT
            *
        FROM
            (
            SELECT
                DECODE( T.DETECT_RESULT_PATH, NULL, NULL, T.DETECT_RESULT_PATH || T.REPORT_NO || '.pdf' ) REPORT_PATH
            FROM
                MIL_MT_RESULT A
                LEFT JOIN QCM_INSPECTION_REPORT T ON REGEXP_REPLACE( A.JUDGE_STOVE_NO, '-.*', '' ) = T.JUDGE_STOVE_NO
            WHERE
                REGEXP_REPLACE( A.JUDGE_STOVE_NO, '-.*', '' ) = {0} UNION ALL
            SELECT
                T.DETECT_RESULT_PATH REPORT_PATH
            FROM
                MIL_ET_RESULT A
                LEFT JOIN QCM_INSPECTION_REPORT T ON REGEXP_REPLACE( A.JUDGE_STOVE_NO, '-.*', '' ) = T.JUDGE_STOVE_NO
            WHERE
                REGEXP_REPLACE( A.JUDGE_STOVE_NO, '-.*', '' ) = {0} UNION ALL
            SELECT
                T.DETECT_RESULT_PATH REPORT_PATH
            FROM
                MIL_ENTRUSTED_BILL A
                LEFT JOIN QCM_INSPECTION_REPORT T ON REGEXP_REPLACE( A.JUDGE_STOVE_NO, '-.*', '' ) = T.JUDGE_STOVE_NO
            WHERE
                REGEXP_REPLACE( A.JUDGE_STOVE_NO, '-.*', '' ) = {0} UNION ALL
            SELECT
                T2.DETECT_RESULT_PATH REPORT_PATH
            FROM
                QCM_ZG_JUGDE_APPLY T2
            WHERE
                T2.JUDGE_STOVE_NO = {0}
                AND T2.PROCESS_CODE = 'D'
                AND T2.PLINE_CODE IN ( 'C065', 'C066' ) UNION ALL
            SELECT
                B.REPORT_PATH
            FROM
                HTT_CRACK_DETECTION_ET A
                LEFT JOIN COM_BASE_PROCESS A2 ON A2.PROCESS_CODE = A.PROCESS_CODE,
                HTT_CRACK_DETECTION_PARA B
            WHERE
                A.JUDGE_STOVE_NO = {0}
                AND A.BATCH_NO = {1}
                AND A.RESULT_NO = B.RESULT_NO UNION ALL
            SELECT DISTINCT
                T.SPEC_RESULT_PATH REPORT_PATH
            FROM
                QCM_ZG_JUGDE_APPLY T
            WHERE
                T.JUDGE_STOVE_NO = {0}
                AND T.BATCH_NO = {1}
                AND T.IS_FLAG = '0'
                AND T.IS_ALL_SCRAP IN ( '0', '4', '5', '6', '7', '8' ) UNION ALL
            SELECT
                T.FACE_RESULT_PATH REPORT_PATH
            FROM
                STL_LG_SURFACE_M T
            WHERE
                EXISTS (
                SELECT
                    1
                FROM
                    QCM_GP_JUDGE_APPLY A
                WHERE
                    A.JUDGE_STOVE_NO = {0}
                    AND T.JUDGE_STOVE_NO = A.JUDGE_STOVE_NO
                    AND T.PRO_PLAN_ID = T.PRO_PLAN_ID
                    AND T.GX_PLAN_NO = T.GX_PLAN_NO
                )
                AND ROWNUM <= 1 UNION ALL
            SELECT
                ( SELECT MAX( T2.FACE_RESULT_PATH ) FROM QCM_SURFACE_REPORT T2 WHERE T2.JUDGE_STOVE_NO = REGEXP_REPLACE( T.JUDGE_STOVE_NO, '-.*', '' ) ) REPORT_PATH
            FROM
                MIL_SURFACE_RESULT T
            WHERE
                REGEXP_REPLACE( T.JUDGE_STOVE_NO, '-.*', '' ) = {0} UNION ALL
            SELECT DISTINCT
                *
            FROM
                (
                SELECT
                    A.REPORT_PATH
                FROM
                    HTT_APPEARANCECHECK_RESULT A,
                    PLN_ZY_DBK_M B
                WHERE
                    B.HEAT_PLAN_NO = A.HEAT_PLAN_NO
                    AND B.JUDGE_STOVE_NO = {0} UNION ALL
                SELECT
                    A.REPORT_PATH
                FROM
                    HTT_APPEARANCECHECK_RESULT A,
                    PLN_ZY_RCL_M B
                WHERE
                    B.HEAT_PLAN_NO = A.HEAT_PLAN_NO
                    AND B.JUDGE_STOVE_NO = {0} UNION ALL
                SELECT
                    A.REPORT_PATH
                FROM
                    HTT_APPEARANCECHECK_RESULT A,
                    PLN_ZY_JGX_M B
                WHERE
                    B.HEAT_PLAN_NO = A.HEAT_PLAN_NO
                    AND B.JUDGE_STOVE_NO = {0} UNION ALL
                SELECT
                    A.REPORT_PATH
                FROM
                    HTT_APPEARANCECHECK_RESULT A,
                    PLN_ZY_JG_M B
                WHERE
                    B.HEAT_PLAN_NO = A.HEAT_PLAN_NO
                    AND B.JUDGE_STOVE_NO = {0}
                ) UNION ALL
            SELECT
                T.REPORT_PATH
            FROM
                MCH_WATERGAGE_RESULT T
            WHERE
                T.JUDGE_STOVE_NO = {0}
                AND T.BATCH_NO = {1}UNION ALL
            SELECT
                T.WPRESSURE_RESULT_PATH REPORT_PATH
            FROM
                QCM_ZG_JUGDE_APPLY T
            WHERE
                T.JUDGE_STOVE_NO = {0}
                AND T.BATCH_NO = {1}
                AND T.IS_FLAG = '0'
                AND T.IS_ALL_SCRAP = '0' UNION ALL-- 通径
            SELECT
                A.REPORT_PATH
            FROM
                MCH_PATH_RESULT A
            WHERE
                A.JUDGE_STOVE_NO = {0}
                AND A.BATCH_NO = {1} UNION ALL--倒棱
            SELECT
                A.REPORT_PATH
            FROM
                MCH_REMANENCE_RESULT A
            WHERE
                A.JUDGE_STOVE_NO = {0}
                AND A.BATCH_NO = {1} UNION ALL--剩磁
            SELECT
                T.REPORT_PATH
            FROM
                MCH_CHAMFERING_RESULT T
            WHERE
                T.JUDGE_STOVE_NO = {0}
                AND T.BATCH_NO = {1} UNION ALL--拧接
            SELECT
                T.FILE_PATH REPORT_PATH
            FROM PLN_ZY_JGX_M T
            WHERE T.JUDGE_STOVE_NO = {0} UNION ALL
            SELECT
                T.REPORT_PATH
            FROM
                MCH_TWISTINGLY_RESULT T
            WHERE
                T.JUDGE_STOVE_NO = {0}
                AND T.BATCH_NO = {1} UNION ALL
            SELECT
                *
            FROM
                (
                SELECT
                    T.CAILI_PATH FILE_PATH
                FROM
                    QCM_JHY_PIPE_CHECKCONSIGN T
                WHERE
                    T.CHECK_NO IN ( SELECT CHECK_NO FROM QCM_ZC_CHECKCONSIGN WHERE JUDGE_STOVE_NO = {0} AND BATCH_NO = {1}) UNION ALL
                SELECT
                    T.FUSHI_PATH
                FROM
                    QCM_JHY_PIPE_CHECKCONSIGN T
                WHERE
                    T.CHECK_NO IN ( SELECT CHECK_NO FROM QCM_ZC_CHECKCONSIGN WHERE JUDGE_STOVE_NO = {0} AND BATCH_NO = {1}) UNION ALL
                SELECT
                    T.JINWU_PATH
                FROM
                    QCM_JHY_PIPE_CHECKCONSIGN T
                WHERE
                    T.CHECK_NO IN ( SELECT CHECK_NO FROM QCM_ZC_CHECKCONSIGN WHERE JUDGE_STOVE_NO = {0} AND BATCH_NO = {1}) UNION ALL
                SELECT
                    T.GONGCHENG_PATH
                FROM
                    QCM_JHY_PIPE_CHECKCONSIGN T
                WHERE
                    T.CHECK_NO IN ( SELECT CHECK_NO FROM QCM_ZC_CHECKCONSIGN WHERE JUDGE_STOVE_NO = {0} AND BATCH_NO = {1}) UNION ALL
                SELECT
                    T.DIBEI_PATH
                FROM
                    QCM_JHY_PIPE_CHECKCONSIGN T
                WHERE
                    T.CHECK_NO IN ( SELECT CHECK_NO FROM QCM_ZC_CHECKCONSIGN WHERE JUDGE_STOVE_NO = {0} AND BATCH_NO = {1}) UNION ALL
                SELECT
                    T.HUAXUE_PATH
                FROM
                    QCM_JHY_PIPE_CHECKCONSIGN T
                WHERE
                    T.CHECK_NO IN ( SELECT CHECK_NO FROM QCM_ZC_CHECKCONSIGN WHERE JUDGE_STOVE_NO = {0} AND BATCH_NO = {1})
                )
            ) T
        WHERE
            T.REPORT_PATH IS NOT NULL
            ORDER BY T.REPORT_PATH
          ]]>
    </query>

    <query id="QcmZgJugdeApplyDAL.getProblem" desc="查询数据">
        <![CDATA[
            SELECT
                JUDGE_STOVE_NO,
                '' BATCH_NO,
                '' BATCH_GROUD_NO,
                PROCESS_CODE,
                PLINE_CODE,
                PLINE_NAME,
                PRO_ORDER_NO,
                '' ORD_LN_DLY_PK
            FROM
                QCM_GP_JUDGE_APPLY T
            WHERE
                ({0} IS NULL OR T.JUDGE_STOVE_NO LIKE '%' || {0} || '%')
                AND ({2} IS NULL OR JUDGE_RESULT_TIME >= TO_DATE( {2}, 'YYYY-MM-DD HH24:MI:SS' ))
                AND ({3} IS NULL OR JUDGE_RESULT_TIME <= TO_DATE( {3}, 'YYYY-MM-DD HH24:MI:SS' ))
                AND T.PLINE_CODE IN {1}
            UNION ALL
            SELECT
                JUDGE_STOVE_NO,
                BATCH_NO,
                BATCH_GROUD_NO,
                PROCESS_CODE,
                PLINE_CODE,
                PLINE_NAME,
                PRO_ORDER_NO,
                ORD_LN_DLY_PK
            FROM
                QCM_ZG_JUGDE_APPLY T
            WHERE
                 ({0} IS NULL OR T.JUDGE_STOVE_NO LIKE '%' || {0} || '%')
                AND ({2} IS NULL OR JUDGE_RESULT_TIME >= TO_DATE( {2}, 'YYYY-MM-DD HH24:MI:SS' ))
                AND ({3} IS NULL OR JUDGE_RESULT_TIME <= TO_DATE( {3}, 'YYYY-MM-DD HH24:MI:SS' ))
                AND T.PLINE_CODE IN {1}
            ORDER BY
                PROCESS_CODE
        ]]>
    </query>
</queryMap>