<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc = "申请判定管理">
<query id = "FrmCouplingApplPh.doQueryMat" desc = "查询炉信息">
<![CDATA[
SELECT T.WO_ID,           
       T.JUDGE_STOVE_NO,
       t.DETER_NO,
       t.BATCH_NO,
       --DECODE(MAX(T.LOCK_LIKU),'0','正常','1','利库') LOCK_LIKU,
       --MAX(T.JUDGE_STD_NAME) JUDGE_STD_NAME,
       --MAX(T.SOURE_CODE) SOURE_CODE,
       --MAX(T.SOURE_NAME) SOURE_NAME,
       --MAX(T.MAT_ORIGIN_CODE) MAT_ORIGIN_CODE,
       --MAX(T.MAT_ORIGIN_NAME) MAT_ORIGIN_NAME,
       MAX(T3.BUYER_NAME) FINAL_USER_DESC,
       DECODE(MAX(t3.ZY_BILL_STATUS),'2','生产中','3','生产完成','关闭') ZY_BILL_STATUS,
       decode(MAX(t.DETER_STATUS),'0','未判定','1','申请判定','2','已判定') DETER_STATUS,
       MI.ORDER_NO,
       MI.ORDER_SEQ,
       MI.ORDER_SEQ_NO,
       MI.CRAFT_SEQ_ORD CRAFT_SEQ,
       MI.CRAFT_FILE_NO_ORD CRAFT_FILE_NO,
       MAX(T3.CODE_JG_BL) CODE_JG_BL,
       MAX(T3.STOVE_NO) STOVE_NO,
       MAX(T3.FLAG_STOVE_NO) FLAG_STOVE_NO,
       MAX(T3.STD_NAME) STD_NAME,
       MAX(T3.STD_STYLE_DESC) STD_STYLE_DESC,
       MAX(T3.PRODUCCODE_JG_DESC) PRODUCCODE_JG_DESC,
       DECODE(MAX(T3.COAT_TYPE),'0','无','1','镀铜','2','磷化','3','镀铜及磷化') COAT_TYPE,
       MAX(T3.DEMAND_COPPER) DEMAND_COPPER,
       MAX(T3.DEMAND_BONDERIZING) DEMAND_BONDERIZING,
       MAX(T3.DEMAND_BLAST) DEMAND_BLAST,
       MAX(T3.DEMAND_DETECTION) DEMAND_DETECTION,
       MAX(T.MEMO) MEMO,
       (SELECT SUM(M.REJECTED_PCS) FROM COUPLING_THREADING_RESULT M WHERE T.WO_ID = M.WO_ID) REJECTED_PCS,
       ROUND(MAX(JG.WEIGHT_JG/1000)*(SELECT SUM(M.REJECTED_PCS) FROM COUPLING_THREADING_RESULT M WHERE T.WO_ID = M.WO_ID),3) REJECTED_WT,
       MAX(T3.BL_WL_DESC) BL_WL_DESC,
       MIN(T.CREATE_TIME) F_IN_TIME,
       MAX(T.UPDATE_NAME) UPDATE_NAME,
       MAX(T.UPDATE_TIME) UPDATE_TIME,
       MAX(T.CREATE_TIME) CREATE_TIME,
       MAX(T.COL_OPERATOR) CREATE_NAME,
       MAX(T.DETER_NO) DETER_NO,
       MAX(T.DETER_NO_SEQ) DETER_NO_SEQ,
       DECODE(MAX(T.COL_GROUP),'1','甲','2','乙','3','丙','4','丁') PRO_GROUP,
       DECODE(MAX(T.COL_SHIFT),'1','早班','2','中班','3','晚班') PRO_SHIFT,
       MAX(T.COL_TIME) RRO_TIME,
       MAX(T.COL_OPERATOR) COL_OPERATOR,
       SUM(T.COL_COUNT) PRO_NUM,
       ROUND((SUM(T.COL_COUNT))/1000*MAX(JG.WEIGHT_JG),3) PRO_WT,
       MAX(T.PRODUCER) PRODUCER,
       MAX(T3.PRDCR_NO) PRDCR_NO,
       DECODE(MAX(T3.IF_MONITOR_JG),'0','否','是') IF_MONITOR_JG,
       MAX(T3.MONITORDEMAND) MONITORDEMAND,
       MAX(T3.SINGLEWEIGHT) SINGLEWEIGHT,
       MAX(JG.LENGTH_JG) AIMLENGTH,
       MAX(JG.CHECK_J_VAL) CHECK_J_VAL,
       MAX(JG.DIAMETER) DIAMETER,
       MAX(T3.STYLE_JG) STYLE_JG,
       MAX(T3.SPEC_JG_DESC) SPEC_JG_DESC,
       MAX(T3.SPEC_JG) SPEC_JG,
       MAX(JG.DIAMETER_JG) OUTDIAMETER,
       MAX(JG.HEIGHT_JG) WALLTHICK,
       MAX(T3.CODE_JG) CODE_JG,
       MAX(T3.BL_WL_ID) BL_WL_ID,
       MAX(T3.MIN_D) MIN_D, 
       MAX(T3.STEELCODE) STEELCODE,
       MAX(T3.STEELNAME) STEELNAME,
       MAX(T3.GRADECODE) GRADECODE,
       MAX(T3.GRADENAME) GRADENAME,
       MAX(T3.MODEL_CODE) MODEL_CODE,
       MAX(T3.MODEL_DESC) MODEL_DESC,
       MAX(T3.PLINE_CODE) PLINE_CODE,
       MAX(T3.PLINE_NAME) PLINE_NAME,
       MAX(T3.BELONG_CODE) BELONG_CODE,
       MAX(T3.BELONG_NAME) BELONG_NAME,
       MAX(T2.JUDGE_RESULT_CODE),
       DECODE(MAX(T1.JUDGE_RESULT_CODE),
              NULL,
              '未判',
              DECODE(MAX(T2.JUDGE_RESULT_CODE), '1', '部分已判', '已判')) JUDGE_FLAG,
       MAX(T1.HTT_TYPE) HTT_TYPE,
       MAX(T1.MIN_TEMP) MIN_TEMP,
       MAX(T1.HTT_TECHNOLOGY) HTT_TECHNOLOGY,
       MAX(T1.NOTCH_INFO) NOTCH_INFO,
       MAX(T1.NOTCH_LENGTH) NOTCH_LENGTH,
       MAX(T1.NOTCH_WIDTH) NOTCH_WIDTH,
       MAX(T1.NOTCH_DEPTH) NOTCH_DEPTH,
       MAX(T1.TEST_PRESSURE) TEST_PRESSURE,
       MAX(T1.HOLDTIME_TIME) HOLDTIME_TIME,
       MAX(T1.TEST_PRESSURE_Y) TEST_PRESSURE_Y,
       MAX(T1.MCH_WATERGAGE_RESULT) MCH_WATERGAGE_RESULT,
       MAX(T1.MCH_PATH_RESULT) MCH_PATH_RESULT,
       MAX(T1.MCH_CHAMFERING_RESULT) MCH_CHAMFERING_RESULT,
       MAX(T1.MCH_TWISTINGLY_RESULT) MCH_TWISTINGLY_RESULT,
       MAX(T1.MCH_DIMENSIONS_RESULT) MCH_DIMENSIONS_RESULT,
       MAX(T1.MCH_VISUAL_RESULT) MCH_VISUAL_RESULT,
       MAX(T1.MCH_THREAD_INSPECTION_RESULT) MCH_THREAD_INSPECTION_RESULT,
       MAX(T1.MCH_REMANENCE_RESULT) MCH_REMANENCE_RESULT,
       MAX(T1.MCH_RADIOACTIVITY_RESULT) MCH_RADIOACTIVITY_RESULT,
       MAX(T1.MCH_BEVEL_RESULT) MCH_BEVEL_RESULT,
       MAX(T1.ANGLE_VAL) ANGLE_VAL,
       MAX(T1.EDGE_VAL) EDGE_VAL,
       MAX(T1.DRIFT_MODEL_MIN) DRIFT_MODEL_MIN,
       MAX(T1.MEASURED_END_PART) MEASURED_END_PART,
       MAX(T1.MEASURED_MIDDLE_PART) MEASURED_MIDDLE_PART,
       MAX(T1.MEASURED_TAIL_PART) MEASURED_TAIL_PART,
       MAX(T1.DETECT_RESULT_CODE) DETECT_RESULT_CODE,
       MAX(T1.TESTING_STANDAR) TESTING_STANDAR,
       MAX(T1.TESTING_GRADE) TESTING_GRADE,
       MAX(T1.TESTING_TYPE) TESTING_TYPE,
       MAX(T1.APPLY_TIME) APPLY_TIME,
       MAX(T3.PLAN_BL_NUM) PLAN_BL_NUM,
       MAX(T3.PLAN_BL_WT) PLAN_BL_WT,
       MAX(T3.REAL_BL_NUM) REAL_BL_NUM,
       MAX(T3.REAL_BL_WT) REAL_BL_WT,
       to_char(ROUND((SUM(T.COL_COUNT))/1000*MAX(JG.WEIGHT_JG)/MAX(T3.REAL_BL_WT),4)  *100, 'FM99999990.99') ||'%' MATER
  FROM PLN_ZY_JG_MIDDLE_SP MI
   LEFT JOIN COUPLING_MAT_M MM
  ON MM.MAT_NO = MI.MAT_NO AND MM.WO_ID = MI.WO_ID
  LEFT JOIN COUPLING_MAT_BACKUP BA
  ON BA.MAT_NO = MI.MAT_NO AND BA.WO_ID = MI.WO_ID,
  PLN_ZY_JG_WORKBILL t3,COM_MSC_JG JG,COUPLING_PHOSPHATE_RESULT T
  LEFT JOIN (SELECT MAX(JUDGE_RESULT_CODE) JUDGE_RESULT_CODE,
                    MAX(T1.HTT_TYPE) HTT_TYPE,
                    MAX(T1.MIN_TEMP) MIN_TEMP,
                    MAX(T1.HTT_TECHNOLOGY) HTT_TECHNOLOGY,
                    MAX(T1.NOTCH_INFO) NOTCH_INFO,
                    MAX(T1.NOTCH_LENGTH) NOTCH_LENGTH,
                    MAX(T1.NOTCH_WIDTH) NOTCH_WIDTH,
                    MAX(T1.NOTCH_DEPTH) NOTCH_DEPTH,
                    MAX(T1.TEST_PRESSURE) TEST_PRESSURE,
                    MAX(T1.HOLDTIME_TIME) HOLDTIME_TIME,
                    MAX(T1.TEST_PRESSURE_Y) TEST_PRESSURE_Y,
                    MAX(T1.MCH_WATERGAGE_RESULT) MCH_WATERGAGE_RESULT,
                    MAX(T1.MCH_PATH_RESULT) MCH_PATH_RESULT,
                    MAX(T1.MCH_CHAMFERING_RESULT) MCH_CHAMFERING_RESULT,
                    MAX(T1.MCH_TWISTINGLY_RESULT) MCH_TWISTINGLY_RESULT,
                    MAX(T1.MCH_DIMENSIONS_RESULT) MCH_DIMENSIONS_RESULT,
                    MAX(T1.MCH_VISUAL_RESULT) MCH_VISUAL_RESULT,
                    MAX(T1.MCH_THREAD_INSPECTION_RESULT) MCH_THREAD_INSPECTION_RESULT,
                    MAX(T1.MCH_REMANENCE_RESULT) MCH_REMANENCE_RESULT,
                    MAX(T1.MCH_RADIOACTIVITY_RESULT) MCH_RADIOACTIVITY_RESULT,
                    MAX(T1.MCH_BEVEL_RESULT) MCH_BEVEL_RESULT,
                    MAX(T1.ANGLE_VAL) ANGLE_VAL,
                    MAX(T1.EDGE_VAL) EDGE_VAL,
                    MAX(T1.DRIFT_MODEL_MIN) DRIFT_MODEL_MIN,
                    MAX(T1.MEASURED_END_PART) MEASURED_END_PART,
                    MAX(T1.MEASURED_MIDDLE_PART) MEASURED_MIDDLE_PART,
                    MAX(T1.MEASURED_TAIL_PART) MEASURED_TAIL_PART,
                    MAX(T1.TESTING_GRADE) TESTING_GRADE,
                    MAX(T1.TESTING_TYPE) TESTING_TYPE,
                    MAX(T1.APPLY_TIME) APPLY_TIME,
                    MAX(T1.TESTING_STANDAR) TESTING_STANDAR,
                    MAX(DECODE(T1.DETECT_RESULT_CODE,
                               '40740401',
                               '合格',
                               '40740402',
                               '不合格')) DETECT_RESULT_CODE,
                    JUGDE_APPLY_CODE
               FROM QCM_ZG_JUGDE_APPLY T1
              GROUP BY JUGDE_APPLY_CODE) t1
    ON T.DETER_NO = T1.JUGDE_APPLY_CODE
  LEFT JOIN (SELECT MIN(nvl(JUDGE_RESULT_CODE, '1')) JUDGE_RESULT_CODE,
                    JUGDE_APPLY_CODE
               FROM QCM_ZG_JUGDE_APPLY T1
              GROUP BY JUGDE_APPLY_CODE) t2
    ON T.DETER_NO = T2.JUGDE_APPLY_CODE
 WHERE 1 = 1 and t.WO_ID = t3.WO_ID AND T3.CODE_JG = JG.CODE_JG and MI.WO_ID = T.WO_ID 
 AND MI.CREATE_TIME =
       (SELECT MIN(E.CREATE_TIME)
          FROM PLN_ZY_JG_MIDDLE_SP E
          LEFT JOIN COUPLING_MAT_M MM
            ON MM.MAT_NO = E.MAT_NO
           AND MM.WO_ID = E.WO_ID
          LEFT JOIN COUPLING_MAT_BACKUP MB
            ON MB.MAT_NO = E.MAT_NO
           AND MB.WO_ID = E.WO_ID
         where e.WO_ID = T.WO_ID
           AND E.PLINE_CODE = T.PLINE_CODE)
 AND ((MM.MAT_NO IS NOT NULL AND MM.QCM_STAUS IN ('00','10')) OR (BA.MAT_NO IS NOT NULL AND BA.QCM_STAUS IN ('00','10')))
 #WO_ID# 
#INSTOCK_TIME#
 #JUDGE_STOVE_NO# 
 #JUGDE_APPLY_CODE#
 #JUDGE_RESULT_CODE# 
 #BELONG_CODE# 
 #GROUP_BY#  
 ]]>
</query>
<query id = "FrmCouplingApplPh.QueryQcmAddAsk" desc = "查询合同附加要求信息 （QCM_ADD_ASK）">
<![CDATA[
select t.* from QCM_ADD_ASK t WHERE T.JUGDE_APPLY_CODE = ? AND T.JUDGE_STOVE_NO = ?
  ]]>
</query>
<query id = "FrmCouplingApplPh.doQueryJgWt" desc = "查询接箍单个重（COM_MSC_JG）">
<![CDATA[
select t.* from COM_MSC_JG t WHERE T.CODE_JG = ? 
  ]]>
</query>



<query id = "FrmCouplingApplPh.QueryQcmAddAsk2" desc = "查询合同附加要求信息 (CRAFT_ORD_DESIGN_ADD_ASK)">
<![CDATA[
select t.DESGIN_KEY,
       T.ASK_ITME,
       T.ASK_ITME_DESC,
       T.ASK_SUB_ITME,
       T.ASK_SUB_ITME_DESC,
       T.ASK_SUB_ITME_VAL,
       T.ASK_SUB_ITME_VAL_DESC
  from CRAFT_ORD_DESIGN_ADD_ASK t
 WHERE T.DESGIN_KEY =
       (SELECT C.DESGIN_KEY
          FROM SLM_ORDER_HEAD A, SLM_ORDER_LINE B, CRAFT_ORD_DESIGN C
         WHERE A.ORD_PK = B.ORD_PK
           AND C.ORD_LN_PK = B.ORD_LN_PK
           AND C.VALIDFLAG = '1'
           AND A.ORDER_NO || '/' || B.ORDER_SEQ = ?)
  ]]>
</query>
<query id = "FrmCouplingApplPh.QueryZgJugdeApply" desc = "查询送判数据">
<![CDATA[
select t.*
  from QCM_ZG_JUGDE_APPLY t
 WHERE 1=1
 AND T.PROCESS_CODE = 'H'
  ]]>
</query>
<query id = "FrmCouplingApplPh.insertQcmAddAsk" desc = "新增合同附加要求信息 （QCM_ADD_ASK）">
<![CDATA[
 INSERT INTO QCM_ADD_ASK(
        JUGDE_APPLY_CODE,
        JUDGE_STOVE_NO,
        DESGIN_KEY,
        ASK_ITME,
        ASK_ITME_DESC,
        ASK_SUB_ITME,
        ASK_SUB_ITME_DESC,
        ASK_SUB_ITME_VAL,
        ASK_SUB_ITME_VAL_DESC,
        ASK_IS_COMFRIM,
        ASK_VAL_DESC,
        COMFRIM_NAME,
        COMFRIM_TIME)
 VALUES( 
        '#JUGDE_APPLY_CODE#',
        '#JUDGE_STOVE_NO#',
        '#DESGIN_KEY#',
        '#ASK_ITME#',
        '#ASK_ITME_DESC#',
        '#ASK_SUB_ITME#',
        '#ASK_SUB_ITME_DESC#',
        '#ASK_SUB_ITME_VAL#',
        '#ASK_SUB_ITME_VAL_DESC#',
        '#ASK_IS_COMFRIM#',
        '#ASK_VAL_DESC#',
        '#COMFRIM_NAME#',
        SYSDATE)
  ]]>
</query>

<query id = "FrmCouplingApplPh.doUpdateJgWt" desc = "修改单重 （COM_MSC_JG）">
<![CDATA[
UPDATE COM_MSC_JG T
   SET T.WEIGHT_JG = '#WEIGHT_JG#'
 WHERE T.CODE_JG = '#CODE_JG#'
  ]]>
</query>

<query id = "FrmCouplingApplPh.doUpdateJgCouplingWt" desc = "修改单重 （COM_MSC_JG）">
<![CDATA[
UPDATE COUPLING_MAT_M T
   SET T.SINGLEWEIGHT = '#WEIGHT_JG#',
   T.PRO_WT = TO_NUMBER(T.PRO_NUM)*TO_NUMBER('#WEIGHT_JG#')/1000
 WHERE T.CODE_JG = '#CODE_JG#' AND T.DETER_NO IS NULL
  ]]>
</query>
<query id = "FrmCouplingApplPh.doQueryJudgeBath" desc = "查询详细炉批信息">
SELECT 
       T.WO_ID,           
       T.JUDGE_STOVE_NO,
       t.DETER_NO,
       T.BATCH_NO,
       T1.ORDER_NO,
       T1.ORDER_SEQ,
       T1.ORDER_SEQ_NO,
       T1.CRAFT_SEQ_ORD CRAFT_SEQ,
       T1.CRAFT_FILE_NO_ORD CRAFT_FILE_NO,
       DECODE(MAX(T.LOCK_LIKU),'0','正常','1','利库') LOCK_LIKU,
       MAX(T.JUDGE_STD_NAME) JUDGE_STD_NAME,
       MAX(T.SOURE_CODE) SOURE_CODE,
       MAX(T.SOURE_NAME) SOURE_NAME,
       MAX(T.MAT_ORIGIN_CODE) MAT_ORIGIN_CODE,
       MAX(T.MAT_ORIGIN_NAME) MAT_ORIGIN_NAME,
       MAX(T.FINAL_USER_DESC) FINAL_USER_DESC,
       max(T.DETER_RESULTS) DETER_RESULTS,
       decode(MAX(t.DETER_STATUS),'0','未判定','1','申请判定','2','已判定') DETER_STATUS,
       DECODE(MAX(T.MNG_LOCK_FLAG),'0','未封锁','1','管理封锁') MNG_LOCK_FLAG,
       DECODE(MAX(T.LOCK_FLAG),'0','未封锁','1','质量封锁') LOCK_FLAG,
       MAX(T.CODE_JG_BL) CODE_JG_BL,
       DECODE(MAX(T.COAT_TYPE),'0','无','1','镀铜','2','磷化','3','镀铜及磷化') COAT_TYPE,
       MAX(T.DEMAND_COPPER) DEMAND_COPPER,
       MAX(T.DEMAND_BONDERIZING) DEMAND_BONDERIZING,
       MAX(T.DEMAND_BLAST) DEMAND_BLAST,
       MAX(T.DEMAND_DETECTION) DEMAND_DETECTION,
       MAX(T.MEMO) MEMO,
       MAX(T.BL_WL_DESC) BL_WL_DESC,
       MAX(T.F_IN_TIME) F_IN_TIME,
       MAX(T.UPDATE_NAME) UPDATE_NAME,
       MAX(T.UPDATE_TIME) UPDATE_TIME,
       MAX(T.CREATE_TIME) CREATE_TIME,
       MAX(T.CREATE_NAME) CREATE_NAME,
       DECODE(MAX(T.PRO_GROUP),'1','甲','2','乙','3','丙','4','丁') PRO_GROUP,
       DECODE(MAX(T.PRO_SHIFT),'1','早班','2','中班','3','晚班') PRO_SHIFT,
       MAX(T.RRO_TIME) RRO_TIME,
       MAX(T.COL_OPERATOR) COL_OPERATOR,
       SUM(T.PRO_NUM) PRO_NUM,
       ROUND(SUM(T.PRO_WT),3) PRO_WT,
       MAX(T.PRODUCER) PRODUCER,
       MAX(T.PRDCR_NO) PRDCR_NO,
       DECODE(MAX(T.IF_MONITOR_JG),'0','否','是') IF_MONITOR_JG,
       MAX(T.MONITORDEMAND) MONITORDEMAND,
       MAX(T.SINGLEWEIGHT) SINGLEWEIGHT,
       MAX(T.AIMLENGTH) AIMLENGTH,
       MAX(T.CHECK_J_VAL) CHECK_J_VAL,
       MAX(T.DIAMETER) DIAMETER,
       MAX(T.STYLE_JG) STYLE_JG,
       MAX(T.SPEC_JG_DESC) SPEC_JG_DESC,
       MAX(T.SPEC_JG) SPEC_JG,
       MAX(T.OUTDIAMETER) OUTDIAMETER,
       MAX(T.WALLTHICK) WALLTHICK,
       MAX(T.CODE_JG) CODE_JG,
       MAX(T.BL_WL_ID) BL_WL_ID,
       MAX(T.MIN_D) MIN_D, 
       MAX(T.STEELCODE) STEELCODE,
       MAX(T.STEELNAME) STEELNAME,
       MAX(T.GRADECODE) GRADECODE,
       MAX(T.GRADENAME) GRADENAME,
       MAX(T.MODEL_CODE) MODEL_CODE,
       MAX(T.MODEL_DESC) MODEL_DESC,
       MAX(T.PLINE_CODE) PLINE_CODE,
       MAX(T.PLINE_NAME) PLINE_NAME,
       MAX(T.BELONG_CODE) BELONG_CODE,
       MAX(T.BELONG_NAME) BELONG_NAME,
       T.DETER_NO_SEQ,
       MAX(T.MAT_NO) MAT_NO
 FROM COUPLING_MAT_M T,PLN_ZY_JG_MIDDLE T1
 WHERE 1=1 AND T.WO_ID = T1.WO_ID AND T.MAT_NO = T1.MAT_NO AND T.QCM_STAUS = '00'
 #WO_ID#
 #JUDGE_STOVE_NO#
 #JUGDE_APPLY_CODE#
 #JUGDE_APPLY_CODE2#
 #GROUP_BY#
</query>
<query id = "FrmCouplingApplPh.doQueryHttData" desc = "查询热处理槽长槽宽槽深">
SELECT MAX(T.NOTCH_LENGTH) NOTCH_LENGTH, MAX(T.NOTCH_WIDTH) NOTCH_WIDTH, MAX(T.NOTCH_DEPTH) NOTCH_DEPTH
  FROM HTT_CRACK_DETECTION_ET T
 WHERE 1 = 1
</query>
<query id = "FrmCouplingApplPh.updateProWgt" desc = "回报过磅量">
UPDATE COUPLING_MAT_M T SET T.PRO_WT = ? WHERE T.MAT_NO = ? AND T.JUDGE_STOVE_NO = ? AND T.BELONG_CODE = ? AND T.BATCH_NO = ?
</query>
<query id = "FrmCouplingApplPh.selectCount" desc = "查询该炉总支数">
	SELECT COUNT(*) ACOUNT
  FROM COUPLING_MAT_M T
 WHERE T.JUDGE_STOVE_NO = ?
   AND T.BELONG_CODE = ?
   AND T.BATCH_NO = ?
	</query>
	
	<query id = "FrmCouplingApplPh.doQueryJudgeBathCount" desc = "查询详细炉批信息">
 SELECT 
  COUNT(*) COUNT
 FROM COUPLING_MAT_M T
 WHERE T.WO_ID = ?
 AND T.JUDGE_STOVE_NO = ?
</query>
	<query id = "FrmCouplingApplPh.doQueryWt" desc = "查询回磅重量">
	SELECT NVL(SUM(T.PONDER_GROSS_WT),0) PONDER_GROSS_WT FROM MAT_BC_M T WHERE 1 = 1 AND T.QCM_STAUS = '00' AND T.JUGDE_APPLY_CODE IS NULL
	</query>
	<query id = "FrmCouplingApplPh.doQueryQcmApply" desc = "查询判定表热处理状态">
	SELECT T.HTT_TYPE, T.MIN_TEMP, T.HTT_TECHNOLOGY,T.NOTCH_INFO,T.NOTCH_LENGTH,T.NOTCH_WIDTH,T.NOTCH_DEPTH FROM QCM_ZG_JUGDE_APPLY T WHERE 1 = 1
	</query>
		<query id = "FrmCouplingApplPh.doQueryProcess" desc = "查询镦拔扩二级工序">		
SELECT T.PROCESS_CODE_C
  FROM PLN_ZY_DBK_M T
 WHERE 1=1
	</query>
	<query id = "FrmCouplingApplPh.getQueryProcessRcl" desc = "查询热处理二级工序">		
SELECT T.PROCESS_CODE_C
  FROM PLN_ZY_RCL_M T
 WHERE 1=1
	</query>
	<query id = "FrmCouplingApplPh.getQueryProcessJgx" desc = "查询加工线二级工序">		
SELECT T.PROCESS_CODE_C
  FROM PLN_ZY_JGX_M T
 WHERE 1=1
	</query>
		<query id = "FrmCouplingApplPh.doQueryProcessDesc" desc = "查询镦拔扩二级工序">		
SELECT T.PROCESS_CODE_C
  FROM PLN_ZY_DBK_M T
 WHERE 1=1 
	</query>
		<query id = "FrmCouplingApplPh.doQueryProcessRclDesc" desc = "查询热处理二级工序">		
SELECT T.PROCESS_CODE_C
  FROM PLN_ZY_RCL_M T
 WHERE 1=1 
	</query>
	<query id = "FrmCouplingApplPh.selectMatNo" desc = "查询所有材料号">
	SELECT T.MAT_NO
  FROM COUPLING_MAT_M T
 WHERE T.JUDGE_STOVE_NO = ?
   AND T.BELONG_CODE = ?
   AND T.BATCH_NO = ?
	</query>
		<query id = "FrmCouplingApplPh.doQueryStorage" desc = "查询存储位置">
	SELECT T1.STORAGE_NAME
  FROM YDM_BC_BUTTRESS T,YDM_BS_STORAGE T1
 WHERE 1 = 1  AND T.STORAGE_NO = T1.STORAGE_NO
	</query>
		<query id = "FrmCouplingApplPh.doQueryBsStorage" desc = "查询存储">
	SELECT T.STORAGE_NAME
  FROM YDM_BS_STORAGE T
 WHERE 1 = 1  
	</query>
	
	<query id = "FrmCouplingApplPh.doQueryTestingGrade" desc = "根据快速检索码查基础信息">
	SELECT T.BASENAME,T.BASECODE  FROM COM_BASE_INFO T WHERE T.SORTCODE = ?
	</query>
	<query id = "FrmCouplingApplPh.jugdeApplyNo" desc = "申请判定单号">
	SELECT '#PLINE_CODE#'||'801401' || TO_CHAR(SYSDATE, 'YYYYMMDD') ||
         LPAD(NVL(MAX(SUBSTR(T.JUGDE_APPLY_CODE, 19,5)), 0) + 1, 5, 0)||'1' JUGDE_APPLY_CODE
    FROM QCM_ZG_JUGDE_APPLY T
   WHERE TRUNC(T.APPLY_TIME) = TRUNC(SYSDATE)
   AND T.IS_ALL_SCRAP != '3' AND T.IS_ALL_SCRAP != '4' AND T.JUGDE_APPLY_CODE LIKE '#PLINE_CODE#'||'801401' || '%'
	</query>
		<query id = "FrmCouplingApplPh.getQueryPlnRclM" desc = "查询热处理是否下发">
	SELECT NVL(COUNT(*),0) COUNT FROM PLN_ZY_RCL_M WHERE PLANSTATUS NOT IN ('00','10')
	</query>
		<query id = "FrmCouplingApplPh.getQueryPlnJgx" desc = "查询加工线是否下发">
	SELECT NVL(COUNT(*),0) COUNT FROM PLN_ZY_JGX_M WHERE PLANSTATUS NOT IN ('00','10')
	</query>
	<query id = "FrmCouplingApplPh.getQueryPlnJg" desc = "查询接箍是否下发">
	SELECT NVL(COUNT(*),0) COUNT FROM PLN_ZY_JG_M WHERE PLANSTATUS NOT IN ('00','10')
	</query>
	<query id = "FrmCouplingApplPh.SelectJudegNo" desc = "查询最大序号">
SELECT T.JUGDE_APPLY_CODE
  FROM QCM_ZG_JUGDE_APPLY T
 WHERE T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
   AND T.PROCESS_CODE = 'H'
   AND T.IS_FLAG = '0'
   AND T.IS_ALL_SCRAP = '0'
   GROUP BY T.JUGDE_APPLY_CODE
</query>
<query id = "FrmCouplingApplPh.SelectJudegNoSequenNo" desc = "查询申请判定顺序号">
SELECT NVL(MAX(T.JUGDE_APPLY_SEQUENO),0)+1 JUGDE_APPLY_SEQUENO
  FROM QCM_ZG_JUGDE_APPLY T
 WHERE T.JUGDE_APPLY_CODE = ?
</query>
<query id = "FrmCouplingApplPh.SelectFaceResultPath" desc = "查询表检报告路径">
SELECT S.FACE_RESULT_PATH,S.HEAT_PLAN_NO
  FROM VRP_COM_INFO S
 WHERE S.HEAT_PLAN_NO = '#HEAT_PLAN_NO#'
   AND S.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
   AND S.PLINE_CODE = '#PLINE_CODE#'
   AND S.STATION_CODE IN('650106','650404','650504','650604','650704')
</query>
<query id = "FrmCouplingApplPh.SelectDeteceResultPath" desc = "查询探伤报告路径">
SELECT MIN(T.REPORT_PATH) REPORT_PATH
  FROM HTT_CRACK_DETECTION_PARA T
 WHERE T.HEAT_PLAN_NO = '#HEAT_PLAN_NO#'
 AND T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
 AND T.batch_no = TRIM('#BATCH_NO#')
   AND T.REPORT_PATH IS NOT NULL
</query>
<query id = "FrmCouplingApplPh.QueryCode" desc = "查询申请判定数据刷新">
SELECT SUM(COUNT) COUNT FROM
(SELECT SUM(T.COL_COUNT) COUNT
                  FROM coupling_phosphate_result T
                 WHERE T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
                   AND T.WO_ID = '#WO_ID#'
                   AND T.BATCH_NO = '#BATCH_NO#'
                   AND T.PLINE_CODE = '#PLINE_CODE#'
                   AND T.DETER_NO IS NULL
                 )
</query>
<query id = "FrmCouplingApplPh.QueryDeterNo" desc = "查询申请判定数据刷新">
<![CDATA[
SELECT COUNT(*) DETER FROM QCM_ZG_JUGDE_APPLY T WHERE T.IS_ALL_SCRAP <> '6' AND T.PRO_ORDER_ID = '#WO_ID#'
 ]]>
</query>
<query id = "FrmCouplingApplPh.SelectLiku" desc = "查询利库标志">
SELECT T.LOCK_LIKU FROM COUPLING_MAT_M T WHERE T.WO_ID = '#WO_ID#'
UNION ALL
SELECT T.LOCK_LIKU FROM COUPLING_MAT_BACKUP T WHERE T.WO_ID = '#WO_ID#'
</query>
<query id = "FrmCouplingApplPh.SelectNodeFlagVrp" desc = "查询结炉状态">
SELECT T.*
  FROM PLN_ZY_JG_WORKBILL T
 WHERE T.WO_ID = '#WO_ID#'
   AND T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
   AND T.BATCH_NO = '#BATCH_NO#'
</query>
<query id = "FrmCouplingApplPh.SelectNodePortEntity" desc = "查询管号队列检验编号">
SELECT T.CHECK_NO
  FROM PORT_htt_BATCH_SAMPLE_RESULT T
 WHERE T.HEAT_PLAN_NO = '#HEAT_PLAN_NO#'
   AND T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
   AND T.PHY_BATCH_NO = '#BATCH_NO#'
   AND T.IS_SAMPLE_PIPE = '1'
   GROUP BY T.CHECK_NO
</query>
<query id = "FrmCouplingApplPh.QueryVrpPortFailPiece" desc = "查询各实绩废品和">
select NVL(SUM(T.ACT_COUNT), 0) ACT_COUNT
  from PORT_HTT_BATCH_SAMPLE_RESULT t
 WHERE T.HEAT_PLAN_NO = ?
   AND T.JUDGE_STOVE_NO = ?
   AND T.PROCESS_SEQ = ?
   AND T.MAT_STATUS = '10'
</query>
<query id = "FrmCouplingApplPh.insertJugdeApply" desc = "插入申请判定表">
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_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,
   MAT_GOWHERE_CODE,
   MAT_GOWHERE_NAME,
   ACT_DIMATER,
   ACT_HEIGHT,
   ACT_LEN_MIN,
   ACT_LEN_MAX,
   ORD_LN_DLY_PK,
   APPLY_FLAG,
   INSTOCK_FLAG,
   BELONG_CODE,
   BELONG_NAME,
   ISENDGX,
   ACT_LEN,
   BELONG_CODE_JUGDE,
   BELONG_NAME_JUGDE,
   GX_PLAN_NO,
   BAL_YEAR_MONTH,
   STOVE_NO,
   STEEL_STANDRAD,
   PRO_PLAN_ID_NEXT,
   GX_PLAN_NO_NEXT,
   LK_FLAG,
   JUGDE_APPLY_SEQUENO,
   TARGET,
   CRAFT_SEQ,
   INDEX_SEQ,
   CIC,
   PIC,
   SIC,
   DIC,
   WIC,
   GIC,
   FACE_RESULT_CODE,
   SPEC_RESULT_CODE,
   CHEM_RESULT_CODE,
   PHY_RESULT_CODE,
   DETECT_RESULT_CODE,
   WPRESSURE_RESULT_CODE,
   PROCESS_RESULT_CODE,
   CHECK_NO,
   HEAT_PLAN_NO_NEXT,
   HEAT_PLAN_NO,
   NEXT_PROCESS_CDOE,
   DELIVERY_STATE_CODE,
   DELIVERY_STATE_NAME,
   LOAD_JUDGE_STOVE_NO,
   ZP_M_LH,
   ZP_COLL,
   HTT_TYPE,
   MIN_TEMP,
   HTT_TECHNOLOGY,
   NOTCH_INFO,
   NOTCH_LENGTH,
   NOTCH_WIDTH,
   NOTCH_DEPTH,
   LOT_NO_GROUP,
   TESTING_GRADE,
   TESTING_TYPE,
   TEST_PRESSURE,
   HOLDTIME_TIME,
   TEST_PRESSURE_Y,
   MCH_WATERGAGE_RESULT,
   MCH_PATH_RESULT,
   MCH_CHAMFERING_RESULT,
   MCH_TWISTINGLY_RESULT,
   MCH_DIMENSIONS_RESULT,
   MCH_VISUAL_RESULT,
   MCH_THREAD_INSPECTION_RESULT,
   MCH_REMANENCE_RESULT,
   MCH_RADIOACTIVITY_RESULT,
   MCH_BEVEL_RESULT,
   ANGLE_VAL,
   EDGE_VAL,
   INPUT_WEIGHT,
   INPUT_COUNT,
   OUTPUT_WEIGHT,
   OUTPUT_COUNT,
   TESTING_STANDAR,
   DRIFT_MODEL_MIN,
   MEASURED_END_PART,
   MEASURED_MIDDLE_PART,
   MEASURED_TAIL_PART,
   INSTANCY_FLAG,
   SUPPLY_UNIT,
   SUPPLY_UNIT_DESC)
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_PATH#',
   '#SPEC_RESULT_PATH#',
   '#CHEM_RESULT_PATH#',
   '#PHY_RESULT_PATH#',
   '#DETECT_RESULT_PATH#',
   '#WPRESSURE_RESULT_PATH#',
   '#PROCESS_RESULT_PATH#',
   '#VALIDFLAG#',
   '#APPLY_NAME#',
   TO_DATE('#APPLY_TIME#', 'YYYY-MM-DD HH24:MI:SS'),
   '#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#',
   NVL('#CRAF_NO#', '\'),
   '#LOT_NO#',
   '#PLINE_NAME#',
   '#PRO_ORDER_NO#',
   NVL('#MAT_GOWHERE_CODE#', '\'),
   NVL('#MAT_GOWHERE_NAME#', '\'),
   '#ACT_DIMATER#',
   '#ACT_HEIGHT#',
   '#ACT_LEN_MIN#',
   '#ACT_LEN_MAX#',
   '#ORD_LN_DLY_PK#',
   '#APPLY_FLAG#',
   '#INSTOCK_FLAG#',
   '#BELONG_CODE#',
   '#BELONG_NAME#',
   '#ISENDGX#',
   '#ACT_LEN#',
   '#BELONG_CODE_JUGDE#',
   '#BELONG_NAME_JUGDE#',
   '#GX_PLAN_NO#',
   '',
   NVL('#STOVE_NO#', ''),
   '#STEEL_STANDRAD#',
   '#PRO_PLAN_ID_NEXT#',
   '#GX_PLAN_NO_NEXT#',
   '#LK_FLAG#',
   '#JUGDE_APPLY_SEQUENO#',
   '#TARGET#',
   '#CRAFT_SEQ#',
   '#INDEX_SEQ#',
   '#CIC#',
   '#PIC#',
   '#SIC#',
   '#DIC#',
   '#WIC#',
   '#GIC#',
   '#FACE_RESULT_CODE#',
   '#SPEC_RESULT_CODE#',
   '#CHEM_RESULT_CODE#',
   '#PHY_RESULT_CODE#',
   '#DETECT_RESULT_CODE#',
   '#WPRESSURE_RESULT_CODE#',
   '#PROCESS_RESULT_CODE#',
   '#CHECK_NO#',
   '#HEAT_PLAN_NO_NEXT#',
   '#HEAT_PLAN_NO#',
   '#NEXT_PROCESS_CDOE#',
   '#DELIVERY_STATE_CODE#',
   '#DELIVERY_STATE_NAME#',
   '#LOAD_JUDGE_STOVE_NO#',
   '#ZP_M_LH#',
   '#ZP_COLL#',
   '#HTT_TYPE#',
   '#MIN_TEMP#',
   '#HTT_TECHNOLOGY#',
   '#NOTCH_INFO#',
   '#NOTCH_LENGTH#',
   '#NOTCH_WIDTH#',
   '#NOTCH_DEPTH#',
   '#LOT_NO_GROUP#',
   '#TESTING_GRADE#',
   '#TESTING_TYPE#',
   '#TEST_PRESSURE#',
   '#HOLDTIME_TIME#',
   '#TEST_PRESSURE_Y#',
   '#MCH_WATERGAGE_RESULT#',
   '#MCH_PATH_RESULT#',
   '#MCH_CHAMFERING_RESULT#',
   '#MCH_TWISTINGLY_RESULT#',
   '#MCH_DIMENSIONS_RESULT#',
   '#MCH_VISUAL_RESULT#',
   '#MCH_THREAD_INSPECTION_RESULT#',
   '#MCH_REMANENCE_RESULT#',
   '#MCH_RADIOACTIVITY_RESULT#',
   '#MCH_BEVEL_RESULT#',
   '#ANGLE_VAL#',
   '#EDGE_VAL#',
   '#INPUT_WEIGHT#',
   '#INPUT_COUNT#',
   '#OUTPUT_WEIGHT#',
   '#OUTPUT_COUNT#',
   '#TESTING_STANDAR#',
   '#DRIFT_MODEL_MIN#',
   '#MEASURED_END_PART#',
   '#MEASURED_MIDDLE_PART#',
   '#MEASURED_TAIL_PART#',
   '1',
   '120501',
   '天津钢管制造有限公司')
</query>

<query id = "FrmCouplingApplPh.updateMatBcJugdeApplyCode" desc = "修改库存申请判定单号">
DECLARE
BEGIN
  FOR MYROW IN (SELECT T.MAT_NO, T.PLINE_CODE,t.wo_id
                  FROM COUPLING_MAT_M T
                 WHERE T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
                   AND T.BATCH_NO = '#BATCH_NO#'
                   AND T.PLINE_CODE = '#PLINE_CODE#'
                   AND T.WO_ID = '#PRO_ORDER_ID#'
                   --AND T.PRO_ORDER_ID = '#PRO_ORDER_ID#'
                   --AND T.GX_PLAN_NO = '#GX_PLAN_NO#'
                   --AND T.QCM_STAUS = '00'
                   AND T.DETER_NO IS NULL
                    UNION ALL
      SELECT T.MAT_NO, T.PLINE_CODE,t.wo_id
                  FROM COUPLING_MAT_BACKUP T
                 WHERE T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
                   AND T.BATCH_NO = '#BATCH_NO#'
                   AND T.PLINE_CODE = '#PLINE_CODE#'
                   AND T.WO_ID = '#PRO_ORDER_ID#'
                   AND T.DETER_NO IS NULL
                 ORDER BY MAT_NO ASC) LOOP
    UPDATE COUPLING_MAT_M T
       SET T.DETER_NO    = '#JUGDE_APPLY_CODE#',
           T.DETER_NO_SEQ = '#JUGDE_APPLY_SEQUENO#',
           T.INSTANCY_FLAG = '1',
           T.DETER_STATUS = '1'
          -- T.JUGDE_APPLY_TIME    = TO_DATE('#APPLY_TIME#','YYYY-MM-DD HH24:MI:SS')
     WHERE T.MAT_NO = MYROW.MAT_NO
     AND T.QCM_STAUS = '00'
       AND T.PLINE_CODE = MYROW.PLINE_CODE; 
       UPDATE COUPLING_MAT_BACKUP T
       SET T.DETER_NO    = '#JUGDE_APPLY_CODE#',
           T.DETER_NO_SEQ = '#JUGDE_APPLY_SEQUENO#',
           T.INSTANCY_FLAG = '1',
           T.DETER_STATUS = '1'
          -- T.JUGDE_APPLY_TIME    = TO_DATE('#APPLY_TIME#','YYYY-MM-DD HH24:MI:SS')
     WHERE T.MAT_NO = MYROW.MAT_NO
     AND T.QCM_STAUS = '00'
       AND T.PLINE_CODE = MYROW.PLINE_CODE; 
    UPDATE coupling_phosphate_result T
       SET T.DETER_NO    = '#JUGDE_APPLY_CODE#',
           T.DETER_NO_SEQ = '#JUGDE_APPLY_SEQUENO#',
           T.DETER_STATUS = '1'
     WHERE T.Wo_Id = '#PRO_ORDER_ID#'
       AND T.PLINE_CODE = MYROW.PLINE_CODE; 
  END LOOP;
END;

</query>
<query id = "FrmCouplingApplPh.SelectPlineBelong" desc = "获取现有产线所属权">
SELECT S.DEPARTMENT_CODE FROM COM_BASE_PLINE S WHERE S.PLINE_CODE = '#PLINE_CODE#'
</query>

<query id = "FrmCouplingApplPh.SelectOrderInfo" desc = "查询midd合同信息">
SELECT T.ORDER_NO || '/' || T.ORDER_SEQ PRO_ORDER_NO,T.ORD_LN_DLY_PK FROM PLN_ZY_JG_MIDDLE_SP T WHERE T.WO_ID='#WO_ID#' 
AND  T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#' AND T.BATCH_NO = '#BATCH_NO#'
</query>

<query id = "FrmCouplingApplPh.updateMatBcButter" desc = "修改储存库位">   
   UPDATE YDM_BC_BUTTRESS T
      SET T.STORAGE_NO = (SELECT T1.STORAGE_NO FROM YDM_BS_STORAGE T1 WHERE T1.STORAGE_NAME = '#STORAGE_NAME#')
    WHERE T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
      AND T.BATCH_NO = '#BATCH_NO#'
</query>

<query id = "FrmCouplingApplPh.updatePlnZyJgMiddleWork" desc = "修改计划工单状态">   
   UPDATE PLN_ZY_JG_WORKBILL T SET T.ZY_BILL_STATUS = '3' WHERE T.WO_ID = '#WO_ID#'
</query>

<query id = "FrmCouplingApplPh.updatePlnZyJgMiddleCancel" desc = "修改计划工单状态">   
   UPDATE PLN_ZY_JG_WORKBILL T SET T.ZY_BILL_STATUS = '2' WHERE T.WO_ID = '#WO_ID#'
</query>
<query id = "FrmCouplingApplPh.doQueryHttType" desc = "获取热处理类型">
select T.SORT_CODE
  from COM_BASE_PROCESS_C t
 WHERE T.PROCESS_CDOE_C = (select T1.PROCESS_CODE_C
                             from PLN_ZY_RCL_M T1
                            where 1 =1                          
</query>
<query id = "FrmCouplingApplPh.doQueryHttTemp" desc = "获取热处理温度工艺制度">
SELECT 
case
  when t.LOW_TEMP is null
    then ''
      else MAX(T.LOW_TEMP) || '℃' end LHEAT_EXIT_TEMP,
case 
  when T.LHEAT_EXIT_TEMP is null and t1.HHEAT_EXIT_TEMP is not null
    then T1.HHEAT_EXIT_TEMP || '℃' || '×' || T1.TOTAL_TIME || 'min' 
      when T1.HHEAT_EXIT_TEMP is null and t.LHEAT_EXIT_TEMP is not null
        then T.LHEAT_EXIT_TEMP || '℃' || '×' || T.TOTAL_TIME || 'min'
          when T.LHEAT_EXIT_TEMP is null and T1.HHEAT_EXIT_TEMP is null
            then ''
              else T1.HHEAT_EXIT_TEMP || '℃' || '×' || T1.TOTAL_TIME || 'min' || '+' ||T.LHEAT_EXIT_TEMP || '℃' || '×' || T.TOTAL_TIME || 'min' end HEAT_EXIT_TEMP,
MAX(T.CREATE_TIME),MAX(T1.CREATE_TIME)
  FROM HTT_LHEAT_RESULT T,HTT_HHEAT_RESULT T1
 WHERE T.HEAT_PLAN_NO = T1.HEAT_PLAN_NO
   AND T.PLINE_CODE = T1.PLINE_CODE
   AND T1.CREATE_TIME = (SELECT MAX(T2.CREATE_TIME) FROM HTT_HHEAT_RESULT T2 WHERE #HEAT_PLAN_NO# and #PLINE_CODE#)
   AND #LHEAT_PLAN_NO#
   and #LPLINE_CODE#
 GROUP BY T.LHEAT_EXIT_TEMP,t1.total_time,t.total_time,t.LOW_TEMP,
  T1.HHEAT_EXIT_TEMP
</query>
<query id = "FrmCouplingApplPh.doQueryHttTempTech" desc = "获取热处理温度工艺制度">
SELECT T.MIN_TEMP,T.HTT_TECHNOLOGY FROM qcm_zg_jugde_apply T WHERE 1 =1 AND #LHEAT_PLAN_NO# AND #LPLINE_CODE#
</query>
<query id = "FrmCouplingApplPh.SelectZgJudgeNoE" desc = "查询组炉号">
SELECT T.GROUP_ID,
CASE 
  WHEN T.ZP_BATCH_NO IS NULL
    THEN T.ZP_JUDGE_STOVE_NO
      ELSE T.ZP_JUDGE_STOVE_NO || '+' || T.ZP_BATCH_NO END ZP_M_LH
FROM VRP_OFFLINE_RESULT T WHERE T.HEAT_PLAN_NO = '#HEAT_PLAN_NO#' AND T.GROUP_LOG = '1'
</query>
<query id = "FrmCouplingApplPh.SelectJudgeNoE" desc = "查询组炉前炉号">
SELECT 
      LISTAGG(DECODE(T.BATCH_NO,
                     '',T.JUDGE_STOVE_NO,T.JUDGE_STOVE_NO || '+' || T.BATCH_NO), ',') WITHIN GROUP(ORDER BY T.BATCH_NO) ZP_COLL
              FROM VRP_GROUP_RESULT T WHERE T.GROUP_ID = ?
</query>
<query id = "FrmCouplingApplPh.SelectZgJudgeNoF" desc = "查询组炉号">
SELECT T.GROUP_ID,
CASE 
  WHEN T.ZP_BATCH_NO IS NULL
    THEN T.ZP_JUDGE_STOVE_NO
      ELSE T.ZP_JUDGE_STOVE_NO || '+' || T.ZP_BATCH_NO END ZP_M_LH
FROM HTT_OFFLINE_RESULT T WHERE T.HEAT_PLAN_NO = '#HEAT_PLAN_NO#' AND T.GROUP_LOG = '1'
</query>
<query id = "FrmCouplingApplPh.SelectJudgeNoF" desc = "查询组炉前炉号">
SELECT 
      LISTAGG(DECODE(T.BATCH_NO,
                     '',T.JUDGE_STOVE_NO,T.JUDGE_STOVE_NO || '+' || T.BATCH_NO), ',') WITHIN GROUP(ORDER BY T.BATCH_NO) ZP_COLL
              FROM HTT_GROUP_RESULT T WHERE T.GROUP_ID = ?
</query>
<query id = "FrmCouplingApplPh.SelectZgJudgeNoG" desc = "查询组炉号">
SELECT T.GROUP_ID,
CASE 
  WHEN T.ZP_BATCH_NO IS NULL
    THEN T.ZP_JUDGE_STOVE_NO
      ELSE T.ZP_JUDGE_STOVE_NO || '+' || T.ZP_BATCH_NO END ZP_M_LH
FROM MCH_OFFLINE_RESULT T WHERE T.HEAT_PLAN_NO = '#HEAT_PLAN_NO#' AND T.GROUP_LOG = '1'
</query>
<query id = "FrmCouplingApplPh.SelectJudgeNoG" desc = "查询组炉前炉号">
SELECT 
      LISTAGG(DECODE(T.BATCH_NO,
                     '',T.JUDGE_STOVE_NO,T.JUDGE_STOVE_NO || '+' || T.BATCH_NO), ',') WITHIN GROUP(ORDER BY T.BATCH_NO) ZP_COLL
              FROM MCH_GROUP_RESULT T WHERE T.GROUP_ID = ?
</query>
<query id = "FrmCouplingApplPh.SelectGroupResultE" desc = "查询组炉号">
 SELECT 
CASE 
  WHEN T.ZP_BATCH_NO IS NULL
    THEN T.ZP_JUDGE_STOVE_NO
       ELSE T.ZP_JUDGE_STOVE_NO || '+' || T.ZP_BATCH_NO END ZP_M_LH,
         CASE 
           WHEN T.BATCH_NO IS NULL
             THEN LISTAGG(T.JUDGE_STOVE_NO, ',') WITHIN GROUP(ORDER BY T.JUDGE_STOVE_NO || T.BATCH_NO) 
               ELSE LISTAGG(T.JUDGE_STOVE_NO || '+' || T.BATCH_NO, ',') WITHIN GROUP(ORDER BY T.JUDGE_STOVE_NO || T.BATCH_NO) END ZP_COLL
  FROM VRP_GROUP_RESULT T
 WHERE T.ZP_JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
 GROUP BY T.ZP_JUDGE_STOVE_NO, T.ZP_BATCH_NO,T.BATCH_NO
</query>
<query id = "FrmCouplingApplPh.SelectGroupResultF" desc = "查询组炉号">
 SELECT 
CASE 
  WHEN T.ZP_BATCH_NO IS NULL
    THEN T.ZP_JUDGE_STOVE_NO
       ELSE T.ZP_JUDGE_STOVE_NO || '+' || T.ZP_BATCH_NO END ZP_M_LH,
         CASE 
           WHEN T.BATCH_NO IS NULL
             THEN LISTAGG(T.JUDGE_STOVE_NO, ',') WITHIN GROUP(ORDER BY T.JUDGE_STOVE_NO || T.BATCH_NO) 
               ELSE LISTAGG(T.JUDGE_STOVE_NO || '+' || T.BATCH_NO, ',') WITHIN GROUP(ORDER BY T.JUDGE_STOVE_NO || T.BATCH_NO) END ZP_COLL
  FROM HTT_GROUP_RESULT T
 WHERE T.ZP_JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
 GROUP BY T.ZP_JUDGE_STOVE_NO, T.ZP_BATCH_NO,T.BATCH_NO
</query>
<query id = "FrmCouplingApplPh.SelectGroupResultG" desc = "查询组炉号">
 SELECT 
CASE 
  WHEN T.ZP_BATCH_NO IS NULL
    THEN T.ZP_JUDGE_STOVE_NO
       ELSE T.ZP_JUDGE_STOVE_NO || '+' || T.ZP_BATCH_NO END ZP_M_LH,
         CASE 
           WHEN T.BATCH_NO IS NULL
             THEN LISTAGG(T.JUDGE_STOVE_NO, ',') WITHIN GROUP(ORDER BY T.JUDGE_STOVE_NO || T.BATCH_NO) 
               ELSE LISTAGG(T.JUDGE_STOVE_NO || '+' || T.BATCH_NO, ',') WITHIN GROUP(ORDER BY T.JUDGE_STOVE_NO || T.BATCH_NO) END ZP_COLL
  FROM MCH_GROUP_RESULT T
 WHERE T.ZP_JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
 GROUP BY T.ZP_JUDGE_STOVE_NO, T.ZP_BATCH_NO,T.BATCH_NO
</query>
<query id = "FrmCouplingApplPh.SelectCraftNo" desc = "查找工艺文件号">
SELECT T.CRAFT_SEQ, T.CRAFT_FILE_NO,T.INDEX_SEQ
  FROM PLN_ZY_JG_WORKBILL T
 WHERE  T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
   AND T.WO_ID = '#WO_ID#'
</query>
<query id = "FrmCouplingApplPh.SelectDemand" desc = "查找要求">
SELECT T.DEMAND_COPPER,T.DEMAND_DETECTION,T.DEMAND_BLAST,T.DEMAND_BONDERIZING FROM PLN_ZY_JG_WORKBILL T 
WHERE T.WO_ID = ?
</query>
<query id = "FrmCouplingApplPh.SelectDemandYayin" desc = "查找压印喷标">
SELECT NVL(T.EMB_COUNT,0) EMB_COUNT  FROM coupling_cut_result T  WHERE T.WO_ID = ?
</query>
<query id = "FrmCouplingApplPh.SelectDemandPen" desc = "查找喷标">
SELECT NVL(T.COL_COUNT,0) COL_COUNT,NVL(T.SPRAY_COUNT, 0) SPRAY_COUNT
  FROM COUPLING_PHOSPHATE_RESULT T
 WHERE T.WO_ID = ?
</query>
<query id = "FrmCouplingApplPh.SelectDemandTan" desc = "查找探伤">
SELECT NVL(T.INSPECT_PIECES, 0) INSPECT_PIECES
   FROM COUPLING_INSPECTION_RESULT T
  WHERE T.WO_ID = ?
</query>
<query id = "FrmCouplingApplPh.SelectDemandSha" desc = "查找喷砂">
  SELECT NVL(T.SPRAY_COUNT, 0) SPRAY_COUNT
    FROM COUPLING_SANDBLAST_RESULT T
   WHERE T.WO_ID = ?
</query>
<query id = "FrmCouplingApplPh.SelectCraftNoRcl" desc = "查找工艺文件号">
SELECT T.CRAFT_SEQ, T.CRAFT_FILE_NO,T.INDEX_SEQ
  FROM PLN_ZY_RCL_M T
 WHERE T.HEAT_PLAN_NO = '#HEAT_PLAN_NO#'
   AND T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
</query>

    <query id = "FrmCouplingApplPh.SelectCrackType" desc = "查找探伤类型">
        SELECT REPLACE(DBMS_LOB.SUBSTR(WMSYS.WM_CONCAT(DISTINCT DECODE(REPORT_NO,
        '4',
        'ET',
        'UT')),
        400),
        ',',
        '+') TESTING_TYPE
        FROM HTT_CRACK_DETECTION_PARA
        WHERE HEAT_PLAN_NO = '#HEAT_PLAN_NO#'
        AND BATCH_NO = '#BATCH_NO#'

    </query>

    <query id = "FrmCouplingApplPh.SelectCrackGade" desc = "查找探伤类型">
        SELECT REPLACE(DBMS_LOB.SUBSTR(WMSYS.WM_CONCAT(DISTINCT TESTING_GRAGE),
        400),
        ',',
        '+') TESTING_GRAGE
        FROM (SELECT LONGITUDINAL_EXTERNAL TESTING_GRAGE
        FROM HTT_CRACK_DETECTION_PARA
        WHERE HEAT_PLAN_NO = '#HEAT_PLAN_NO#'
        AND BATCH_NO = '#BATCH_NO#'
        AND LONGITUDINAL_EXTERNAL IS NOT NULL
        AND LONGITUDINAL_EXTERNAL != '/'
        UNION
        SELECT ACCPETANCE_LEVEL TESTING_GRAGE
        FROM HTT_CRACK_DETECTION_PARA
        WHERE HEAT_PLAN_NO = '#HEAT_PLAN_NO#'
        AND BATCH_NO = '#BATCH_NO#'
        AND ACCPETANCE_LEVEL IS NOT NULL
        AND ACCPETANCE_LEVEL  != '/')
    </query>
    
     <query id = "FrmCouplingApplPh.SelectQcmZcCheck" desc = "查找是否有重新热处理">
       SELECT COUNT(*) COUNT
  FROM QCM_ZC_CHECKCONSIGN T
 WHERE T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
   AND T.BATCH_NO = '#BATCH_NO#'
   AND T.PROCESS_CODE = 'F'
   AND T.CYCLES_FLAG = '1'
    </query>

<query id = "FrmCouplingApplPh.SelectCraftNoJgx" desc = "查找工艺文件号">
SELECT T.CRAFT_SEQ, T.CRAFT_FILE_NO,T.INDEX_SEQ
  FROM PLN_ZY_JGX_M T
 WHERE T.HEAT_PLAN_NO = '#HEAT_PLAN_NO#'
   AND T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
</query>
<query id = "FrmCouplingApplPh.SelectDesignKey" desc = "查找designKey">
SELECT T.DESGIN_KEY
  FROM CRAFT_ORD_DESIGN T
 WHERE T.CRAFT_NO = ?
   AND T.CRAFT_SEQ = ?
</query>

<query id = "FrmCouplingApplPh.SelectBaseCodeState" desc = "查找交货状态">
SELECT T.DELIVERY_STATE_CODE BASECODE, T.DELIVERY_STATE_NAME BASENAME
  FROM QCM_ZG_JUGDE_APPLY T
 WHERE T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
   AND T.BATCH_NO = '#BATCH_NO#'
   AND T.PROCESS_CODE = (SELECT MAX(A.PROCESS_CODE)
                           FROM QCM_ZG_JUGDE_APPLY A
                          WHERE A.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
                            AND A.BATCH_NO = '#BATCH_NO#')
</query>

<query id = "FrmCouplingApplPh.QueryVrpPortPiece" desc = "查询各实绩废品和">
select NVL(SUM(T.ACT_COUNT), 0) ACT_COUNT
  from PORT_HTT_BATCH_SAMPLE_RESULT t
 WHERE T.HEAT_PLAN_NO = '#HEAT_PLAN_NO#'
   AND T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
   AND ((T.MAT_STATUS = '00' and t.instore_flag='0')
   or t.mat_status = '20')
</query>
<query id = "FrmCouplingApplPh.SelectBaseCode" desc = "查找交货状态">
SELECT T.BASECODE, T.BASENAME
  FROM COM_BASE_INFO T
 WHERE T.BASECODE = (SELECT GET_DELIVERY_STATE(?,
                                               ?) SORTCODE
                       FROM DUAL)
                       AND T.SORTCODE='4100'
</query>
<query id = "FrmCouplingApplPh.SelectBaseCode1" desc = "查找交货状态">
SELECT T.BASECODE, T.BASENAME
  FROM COM_BASE_INFO T
 WHERE T.BASECODE = (SELECT GET_SHIPPED_STATE(?,?,?) SORTCODE
                       FROM DUAL)
                       AND T.SORTCODE='4100'
</query>
<query id = "FrmCouplingApplPh.SelectOrderSlaOrg" desc= "查询合同所属部门">
SELECT S.SALE_ORG, S.SALE_ORG_DESC
  FROM SLM_ORDER_HEAD S,SLM_ORDER_LINE S1,pln_zy_jg_middle T1
 WHERE S.ORD_PK = S1.ORD_PK
   AND S.ORDER_NO ||'/'||S1.ORDER_SEQ = t1.ORDER_NO || '/' || t1.order_seq
   AND T1.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
   AND T1.PLINE_CODE = '#PLINE_CODE#'
   AND ROWNUM = 1
</query>
<query id = "FrmCouplingApplPh.SelectNextPlineBelong" desc = "查询下工序产线部门">
SELECT P.DEPARTMENT_CODE,P.DEPARTMENT_DESC
  FROM (SELECT S.ORD_LN_DLY_PK, S.PLN_DIVIDE_ID
          FROM PLN_ZY_DBK_M T, PLN_ORDER_DBK_S S
         WHERE T.PRO_PLAN_ID = S.PRO_PLAN_ID
           AND T.GX_PLAN_NO = S.GX_PLAN_NO
           AND T.HEAT_PLAN_NO = '#HEAT_PLAN_NO#'
           AND T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#') E,
       #PLAN# F,
       COM_BASE_PLINE P
 WHERE E.ORD_LN_DLY_PK = F.ORD_LN_DLY_PK
   AND E.PLN_DIVIDE_ID = F.PLN_DIVIDE_ID
   AND F.PLINE_CODE = P.PLINE_CODE
   AND ROWNUM = 1
</query>
<query id = "FrmCouplingApplPh.SelectValueFlag" desc = "查询判定状态">
SELECT T.VALIDFLAG,T.INSTOCK_FLAG
  FROM QCM_ZG_JUGDE_APPLY T
 WHERE T.JUGDE_APPLY_CODE = '#JUGDE_APPLY_CODE#'
   AND T.JUGDE_APPLY_SEQUENO = '#JUGDE_APPLY_SEQUENO#'
   AND T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
   AND T.BATCH_NO = '#BATCH_NO#'
   AND T.BATCH_GROUD_NO = '#BATCH_GROUD_NO#'
   AND T.PLINE_CODE = '#PLINE_CODE#'
   AND T.IS_ALL_SCRAP = '0'
</query>
<query id = "FrmCouplingApplPh.SelectValueFlagData" desc = "查询判定状态">
SELECT T.VALIDFLAG,T.INSTOCK_FLAG
  FROM QCM_ZG_JUGDE_APPLY T
 WHERE T.IS_ALL_SCRAP = '0'
</query>
<query id = "FrmCouplingApplPh.deleteQcmJudgeApply" desc = "撤销申请判定">
DECLARE
  V_APPLY_FLAG QCM_ZG_JUGDE_APPLY.APPLY_FLAG%TYPE := NULL;
BEGIN
  SELECT T.APPLY_FLAG
    INTO V_APPLY_FLAG
    FROM QCM_ZG_JUGDE_APPLY T
   WHERE T.JUGDE_APPLY_CODE = '#DETER_NO#'
     AND T.JUGDE_APPLY_SEQUENO = '#DETER_NO_SEQ#'
     AND T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
     AND T.BATCH_NO = '#BATCH_NO#'
     AND T.BATCH_GROUD_NO = '001'
     AND T.PLINE_CODE = '#PLINE_CODE#'
     AND T.IS_ALL_SCRAP = '0';
  FOR MYROW IN (SELECT *
                  FROM COUPLING_MAT_M T
                 WHERE T.DETER_NO = '#DETER_NO#'
                   AND T.DETER_NO_SEQ = '#DETER_NO_SEQ#'
                   AND T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
                   AND T.BATCH_NO = '#BATCH_NO#'
                   AND T.PLINE_CODE = '#PLINE_CODE#'
                UNION
                SELECT *
                  FROM COUPLING_MAT_BACKUP T
                 WHERE T.DETER_NO = '#DETER_NO#'
                   AND T.DETER_NO_SEQ = '#DETER_NO_SEQ#'
                   AND T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
                   AND T.BATCH_NO = '#BATCH_NO#'
                   AND T.PLINE_CODE = '#PLINE_CODE#') LOOP
    UPDATE COUPLING_MAT_M S
       SET S.DETER_NO = '', S.DETER_NO_SEQ = '', S.DETER_STATUS = '0'
     WHERE S.MAT_NO = MYROW.MAT_NO
       AND S.PLINE_CODE = MYROW.PLINE_CODE;
    UPDATE COUPLING_MAT_BACKUP S
       SET S.DETER_NO = '', S.DETER_NO_SEQ = '', S.DETER_STATUS = '0'
     WHERE S.MAT_NO = MYROW.MAT_NO
       AND S.PLINE_CODE = MYROW.PLINE_CODE;
    UPDATE coupling_phosphate_result S
       SET S.DETER_NO = '', S.DETER_NO_SEQ = '', S.DETER_STATUS = '0'
     WHERE S.WO_ID = '#WO_ID#'
       AND S.PLINE_CODE = MYROW.PLINE_CODE;
    DELETE FROM MAT_BC_QCMTRACK S
     WHERE S.MAT_NO = MYROW.MAT_NO
       AND S.PROCESS_CDOE = 'H';
  
  END LOOP;
  IF (V_APPLY_FLAG = '1') THEN
    UPDATE QCM_ZG_JUGDE_APPLY T
       SET T.IS_FLAG = '1'
     WHERE T.JUGDE_APPLY_CODE = '#DETER_NO#'
       AND T.JUGDE_APPLY_SEQUENO = '#DETER_NO_SEQ#'
       AND T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
       AND T.BATCH_NO = '#BATCH_NO#'
       AND T.BATCH_GROUD_NO = '001'
       AND T.PLINE_CODE = '#PLINE_CODE#';
  ELSE
    DELETE FROM QCM_ZG_JUGDE_APPLY S
     WHERE S.JUGDE_APPLY_CODE = '#DETER_NO#'
       AND S.JUGDE_APPLY_SEQUENO = '#DETER_NO_SEQ#'
       AND S.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
       AND S.BATCH_NO = '#BATCH_NO#'
       AND S.BATCH_GROUD_NO = '001'
       AND S.PLINE_CODE = '#PLINE_CODE#';
  END IF;
END;

</query>
<query id = "FrmCouplingApplPh.insertMatQcmBack" desc = "插入质量跟踪表">
DECLARE
BEGIN
  FOR MYROW IN (SELECT *
                  FROM COUPLING_MAT_M T
                 WHERE T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
                   AND T.BATCH_NO = '#BATCH_NO#'
                   AND T.PLINE_CODE = '#PLINE_CODE#'
                   AND T.DETER_NO = '#JUGDE_APPLY_CODE#' 
                   AND T.DETER_NO_SEQ = '#JUGDE_APPLY_SEQUENO#'
                 ) LOOP
    INSERT INTO MAT_BC_QCMTRACK
      (MAT_NO,
       PROCESS_CDOE,
       STOVE_NO,
       JUDGE_STOVE_NO,
       BATCH_NO,
       GRADECODE,
       GRADENAME,
       MATERIAL_NO,
       MATERIAL_NAME,
       JUGDE_APPLY_CODE,
       JUGDE_APPLY_TIME,
       JUGDE_APPLY_MAKER)
    VALUES
      (MYROW.MAT_NO,
       'H',
       '',
       MYROW.JUDGE_STOVE_NO,
       MYROW.BATCH_NO,
       MYROW.GRADECODE,
       MYROW.GRADENAME,
       MYROW.BL_WL_ID,
       MYROW.BL_WL_DESC,
       '#JUGDE_APPLY_CODE#',
       TO_DATE('#APPLY_TIME#','YYYY-MM-DD HH24:MI:SS'),
       '#APPLY_NAME#');
  END LOOP;
END;
</query>

<query id = "FrmCouplingApplPh.SelectIsWic" desc = "查询是否有水压要求">
SELECT COUNT(1) ACOUNT
  FROM CRAFT_ORD_DESIGN_MSC_PL_PRC T, CRAFT_ORD_DESIGN_STD_WIC W
 WHERE T.DESGIN_KEY = W.DESGIN_KEY
   AND T.MSC_PLINE = W.MSC_PLINE
   and t.PROCESS_CODE = W.PROCESS_CODE
   AND W.SPECL_FL = '2'
   AND T.PROCESS_CODE = ?
   AND T.DESGIN_KEY = ?
</query>

<query id = "FrmCouplingApplPh.doQueryWicValue" desc = "查询水压">
select t.*
  from MCH_WATERGAGE_RESULT t
 WHERE T.HEAT_PLAN_NO = ?
   AND T.JUDGE_STOVE_NO = ?
</query>

<query id = "FrmCouplingApplPh.doQueryMchPathResult" desc = "查询加工通径结果">
select MAX(T.DRIFT_MODEL_MIN) DRIFT_MODEL_MIN,
       MIN(T2.MEASURED_END_PART) MEASURED_END_PART,
       MIN(T2.MEASURED_MIDDLE_PART) MEASURED_MIDDLE_PART,
       MIN(T2.MEASURED_TAIL_PART) MEASURED_TAIL_PART
  from MCH_PATH_RESULT t, MCH_PATH_RESULT_D T2
 WHERE T.HEAT_PLAN_NO = T2.HEAT_PLAN_NO(+)
   AND T.HEAT_PLAN_NO = ?
   AND T.JUDGE_STOVE_NO = ?
</query>

<query id = "FrmCouplingApplPh.doQueryMchChamferingResult" desc = "查询加工倒棱结果">
select t.*
  from MCH_CHAMFERING_RESULT t
 WHERE T.HEAT_PLAN_NO = ?
   AND T.JUDGE_STOVE_NO = ?
</query>

<query id = "FrmCouplingApplPh.doQueryMchTwistinglyResult" desc = "查询加工拧接结果">
select t.*
  from MCH_TWISTINGLY_RESULT t
 WHERE T.HEAT_PLAN_NO = ?
   AND T.JUDGE_STOVE_NO = ?
</query>

<query id = "FrmCouplingApplPh.doQueryHttCrackDetectionEt" desc = "查询探伤结果">
<![CDATA[
SELECT listagg(TESTING_GRADE, ',') within GROUP(order by TESTING_GRADE) over(partition by '') TESTING_GRADE,
       listagg(TESTING_TYPE, ',') within GROUP(order by TESTING_GRADE) over(partition by '') TESTING_TYPE
  FROM (select DISTINCT T.TESTING_GRADE, T.TESTING_TYPE
          from HTT_CRACK_DETECTION_ET t
         WHERE T.HEAT_PLAN_NO = ?
           AND T.JUDGE_STOVE_NO = ?
           AND T.PROCESS_CODE = ?)
 ]]>
</query>

<query id = "FrmCouplingApplPh.SelectQcmZgData" desc = "查询送判表支数">
SELECT SUM(T.ACT_COUNT) ACT_COUNT
  FROM QCM_ZG_JUGDE_APPLY T
 WHERE T.JUDGE_STOVE_NO = ?
   AND T.PLINE_CODE = ?
   AND T.PROCESS_CODE = 'F'
</query>

<query id = "FrmCouplingApplPh.SelectTestingStandar" desc = "查询探伤标准">
<![CDATA[
SELECT WMSYS.WM_CONCAT(DISTINCT T2.STANDARD_NAME) TESTING_STANDAR
  FROM HTT_CRACK_DETECTION_PARA T1, HTT_CRACK_DETECTION_STANDARD T2
 WHERE T1.STANDARD_ID = T2.STANDARD_ID
   AND T1.HEAT_PLAN_NO = '#HEAT_PLAN_NO#'
 ]]>
</query>

<query id = "FrmCouplingApplPh.SelectInputCountVrp" desc = "查询镦拔扩投料量">
<![CDATA[
select SUM(T.ACT_COUNT) ACT_COUNT,
       SUM(NVL(T.ACT_THEORY_WEIGHT, T.ACT_WEIGHT)) ACT_WEIGHT
  from PORT_VRP_BATCH_SAMPLE_RESULT t
 WHERE T.HEAT_PLAN_NO = '#HEAT_PLAN_NO#'
 ]]>
</query>

<query id = "FrmCouplingApplPh.SelectInputCountHtt" desc = "查询热处理投料量">
<![CDATA[
select SUM(T.ACT_COUNT) ACT_COUNT,
       SUM(NVL(T.ACT_THEORY_WEIGHT, T.ACT_WEIGHT)) ACT_WEIGHT
  from PORT_HTT_BATCH_SAMPLE_RESULT t
 WHERE T.HEAT_PLAN_NO = '#HEAT_PLAN_NO#'
 ]]>
</query>

<query id = "FrmCouplingApplPh.SelectInputCountMch" desc = "查询加工投料量">
<![CDATA[
select SUM(T.ACT_COUNT) ACT_COUNT,
       SUM(NVL(T.ACT_THEORY_WEIGHT, T.ACT_WEIGHT)) ACT_WEIGHT
  from PORT_MCH_BATCH_SAMPLE_RESULT t
 WHERE T.HEAT_PLAN_NO = '#HEAT_PLAN_NO#'
 ]]>
</query>

<query id = "FrmCouplingApplPh.doQueryQcmZgApplyData" desc = "查询加工线前紧急放行数据">
<![CDATA[
SELECT  T.*
  FROM QCM_ZG_JUGDE_APPLY T
 WHERE T.INSTANCY_FLAG = '1'
   AND (T.JUDGE_RESULT is null OR T.JUDGE_RESULT = '不合格' OR T.JUDGE_RESULT_CODE = '40740709')
 ]]>
</query>
<query id = "FrmCouplingApplPh.SelectJudegApplyCount" desc = "查询是否已送判定过">
SELECT COUNT(1) ACOUNT
  FROM QCM_ZG_JUGDE_APPLY T
 WHERE T.JUDGE_STOVE_NO = ?
   AND T.PROCESS_CODE = ?
   AND T.IS_FLAG = '0'
   AND T.IS_ALL_SCRAP IN ('0', '1')
</query>

	<query id="FrmCouplingApplPh.SelectJgStuts" desc="查询公共表结炉状态">
	 <![CDATA[ 
   SELECT T.STATION_STATUS, T.STATION_DESC
     FROM COUPLING_COM_INFO T
    WHERE T.WO_ID = ?
      AND T.STATION_CODE = '700310'
   
	  ]]>
	</query>
<query id = "FrmCouplingApplPh.SelectIsGroupE" desc = "查询炉计划标识">
SELECT T.IF_MATCH_ODD FROM PLN_ZY_DBK_M T WHERE T.HEAT_PLAN_NO = ? AND T.JUDGE_STOVE_NO = ?
</query>
<query id = "FrmCouplingApplPh.SelectIsGroupF" desc = "查询炉计划标识">
SELECT T.IF_MATCH_ODD FROM PLN_ZY_RCL_M T WHERE T.HEAT_PLAN_NO = ? AND T.JUDGE_STOVE_NO = ?
</query>
<query id = "FrmCouplingApplPh.SelectIsGroupG" desc = "查询炉计划标识">
SELECT T.IF_MATCH_ODD FROM PLN_ZY_JGX_M T WHERE T.HEAT_PLAN_NO = ? AND T.JUDGE_STOVE_NO = ?
</query>

<query id = "FrmVrpApplyNew.SelectApplyNo" desc = "查询库存支数与送判支数是否一致">
 <![CDATA[ 
SELECT (NVL((SELECT SUM(T.ACT_COUNT)
              FROM QCM_ZG_JUGDE_APPLY T
             WHERE T.JUGDE_APPLY_CODE = ?),
            0) - NVL((SELECT SUM(T1.PRO_NUM)
                        FROM COUPLING_MAT_M T1
                       WHERE T1.DETER_NO = ?),
                      0)) ACOUNT
  FROM DUAL
  ]]>
</query>
</queryMap>