<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="接箍磷化检测实绩">
	<query id="PhosphateResultService.ProcessPlan.CoupProcessItem"
		desc="检测项配置表查询">
        <![CDATA[
         select T.PROCEDUR_NO,T.TEST_ITEMS,T.SPAN,T.SETTING_TEMPERATURE,T.ITEM_NO,T.PLINE_CODE 
			from COUPLING_PHOSPHATE_ITEM T
        ]]>
	</query>
	<query id="PhosphateResultService.getphosInResult"
		desc="查询查询入库实绩">
        <![CDATA[
  SELECT MAX(T.ZY_PLAN_ID) ZY_PLAN_ID,
       T.WO_ID,
       T.JUDGE_STOVE_NO,
       T.BATCH_NO,
       MAX(T.STEELNAME) STEELNAME,
       MAX(T.GRADENAME) GRADENAME,
       MAX(T.SPEC_JG_DESC) SPEC_JG_DESC,
       MAX(T.STD_NAME) STD_NAME,
       MAX(T.STD_STYLE_DESC) STD_STYLE_DESC,
       MAX(T.PRODUCCODE_JG_DESC) PRODUCCODE_JG_DESC,
       MAX(T.MODEL_DESC) MODEL_DESC,
       MAX(T.CODE_JG) CODE_JG,
       MAX(T.CODE_JG_BL) CODE_JG_BL,
       MAX(T.MIN_D) MIN_D,
       MAX(T.MIN_H) MIN_H,
       NVL(MAX(T.COL_COUNT), 0) LH_NUM,
       MAX(T.PLINE_CODE) PLINE_CODE,
       MAX(T.PLINE_NAME) PLINE_NAME,
       MAX(T.STYLE_JG) STYLE_JG,
       T.CREATE_TIME,
       T.CREATE_NAME,
       MAX(T.ORDER_NO) ORDER_NO,
       MAX(T.ORDER_SEQ) ORDER_SEQ,
       MAX(T.ORDER_SEQ_NO) ORDER_SEQ_NO,
       MAX(T.DEMAND_DETECTION) DEMAND_DETECTION,
       MAX(T.DEMAND_BLAST) DEMAND_BLAST,
       MAX(T.DEMAND_BONDERIZING) DEMAND_BONDERIZING,
       MAX(T.DEMAND_COPPER) DEMAND_COPPER,
       DECODE(T.MATCONFIRM, '1', '确认', '未确认') MATCONFIRM,
       DECODE(T.COL_SHIFT, '1', '早班', '2', '中班', '3', '晚班') COL_SHIFT,
       MAX(T.COL_OPERATOR) COL_OPERATOR,
       MAX(T.CONFIRM_TIME) CONFIRM_TIME,
       MAX(T.CONFIRM_NAME) CONFIRM_NAME,
       MAX(T.MATCONFIRM_TIME) MATCONFIRM_TIME,
       MAX(T.MATCONFIRM_NAME) MATCONFIRM_NAME,
       MAX(T.MEMO) MEMO
  FROM (SELECT T1.HEAT_PLAN_NO ZY_PLAN_ID,
               T1.WO_ID,
               T1.JUDGE_STOVE_NO,
               T1.BATCH_NO,
               T1.BATCH_GROUD_NO,
               T1.STEELNAME,
               T1.GRADENAME,
               T1.SPEC_JG_DESC,
               T1.STD_NAME,
               T1.STD_STYLE_DESC,
               T1.PRODUCCODE_JG_DESC,
               T1.MODEL_DESC,
               T1.CODE_JG,
               T1.CODE_JG_BL,
               T1.MIN_D,
               T1.MIN_H,
               T1.PLINE_CODE,
               T1.PLINE_NAME,
               T1.STYLE_JG,
               (SELECT B.BASENAME
                  FROM COM_BASE_INFO B
                 WHERE B.BASECODE = T1.DEMAND_DETECTION) DEMAND_DETECTION,
               (SELECT B.BASENAME
                  FROM COM_BASE_INFO B
                 WHERE B.BASECODE = T1.DEMAND_BLAST) DEMAND_BLAST,
               (SELECT B.BASENAME
                  FROM COM_BASE_INFO B
                 WHERE B.BASECODE = T1.DEMAND_BONDERIZING) DEMAND_BONDERIZING,
               (SELECT B.BASENAME
                  FROM COM_BASE_INFO B
                 WHERE B.BASECODE = T1.DEMAND_COPPER) DEMAND_COPPER,
               T3.CREATE_TIME,
               T3.CREATE_NAME,
               T3.COL_COUNT,
               T2.ORDER_NO,
               T2.ORDER_SEQ,
               T2.ORDER_SEQ_NO,
               T3.MATCONFIRM,
               T3.COL_SHIFT,
               T3.COL_OPERATOR,
               T3.CONFIRM_TIME,
               T3.CONFIRM_NAME,
               T3.MATCONFIRM_NAME,
               T3.MATCONFIRM_TIME,
               T3.MEMO
          FROM PLN_ZY_JG_WORKBILL        T1,
               PLN_ZY_JG_MIDDLE          T2,
               COUPLING_PHOSPHATE_RESULT T3
         WHERE T1.WO_ID = T2.WO_ID
           AND T1.JUDGE_STOVE_NO = T2.JUDGE_STOVE_NO
           AND T1.WO_ID = T3.WO_ID
           AND T2.STATUS = (SELECT MIN(M.STATUS)
                              FROM PLN_ZY_JG_MIDDLE M
                             WHERE M.WO_ID = T2.WO_ID) #SOMETHING#) T
 GROUP BY T.WO_ID,
          T.JUDGE_STOVE_NO,
          T.BATCH_NO,
          T.MATCONFIRM,
          T.COL_SHIFT,
          T.CREATE_TIME,
          T.CREATE_NAME
        ]]>
	</query>
		<query id="PhosphateResultService.getphosphResult" desc="查询磷化支数总和">
        <![CDATA[
   SELECT NVL(SUM(T.COL_COUNT), 0) PRO_NUM FROM COUPLING_PHOSPHATE_RESULT T
   WHERE T.WO_ID = ?
        ]]>
	</query>
	
		<query id="PhosphateResultService.QuerySingleWt" desc="查询单重">
        <![CDATA[
    SELECT T.WEIGHT_JG FROM COM_MSC_JG T WHERE T.CODE_JG = ?
        ]]>
	</query>
	<query id="PhosphateResultService.queryColUser" desc="查询磷化操作工">
        <![CDATA[
   select t.Basecode,T.BASENAME from COM_BASE_INFO t WHERE T.SORTCODE=?
        ]]>
	</query>
	
	<query id="PhosphateResultService.queryMemo" desc="查询备注">
        <![CDATA[
   select t.MEMO from COM_BASE_INFO t WHERE T.SORTCODE='7030' and t.basecode = ?
        ]]>
	</query>
	<query id="PhosphateResultService.ProcessPlan.CoupProcessRD"
		desc="接箍磷化检验结果表查询">
        <![CDATA[
 SELECT T.DETAIL_NO,
       T.RESULT_NO,
       T.ITEM_NO,
       T.TEST_RESULT_F,
       T.TEST_RESULT_T,
       T.DOSAGE,
       T.TEMPERATURE,
       T.SEQ_NO,
       T.ZY_PLAN_ID,
       T1.PROCEDUR_NO,
       T1.SPAN,
       T1.SETTING_TEMPERATURE,
       T.WO_ID
  FROM COUPLING_PHOSPHATE_RESULT_D T, COUPLING_PHOSPHATE_ITEM T1
 WHERE T.ITEM_NO = T1.ITEM_NO
   AND T.RESULT_NO = ?
   AND T.WO_ID=?
        ]]>
	</query>
	
	<query id="PhosphateResultService.getConfirm" desc="确认磷化实绩">
	<![CDATA[
 UPDATE COUPLING_PHOSPHATE_RESULT T SET T.CONFIRM = '1',T.CONFIRM_NAME =?,T.CONFIRM_TIME = TO_DATE(?,'YYYY-MM-DD HH24:MI:SS')
  WHERE T.RESULT_NO = ?
	]]>
	</query>
	
	<query id="PhosphateResultService.getCancelConfirm" desc="取消确认磷化实绩">
	<![CDATA[
 UPDATE COUPLING_PHOSPHATE_RESULT T SET T.CONFIRM = '0',T.CONFIRM_NAME =?,T.CONFIRM_TIME = TO_DATE(?,'YYYY-MM-DD HH24:MI:SS')
  WHERE T.RESULT_NO = ?
	]]>
	</query>
	
	<query id="PhosphateResultService.getMatConfirm" desc="确认接箍入库">
	<![CDATA[
 UPDATE COUPLING_PHOSPHATE_RESULT T SET T.MATCONFIRM = '1',T.MATCONFIRM_NAME = ?,T.MATCONFIRM_TIME = TO_DATE(?,'YYYY-MM-DD HH24:MI:SS') WHERE T.WO_ID = ? and t.COL_SHIFT = ?
 AND T.JUDGE_STOVE_NO = ? AND T.BATCH_NO = ? AND T.MATCONFIRM = ? AND T.CREATE_TIME = TO_DATE(?,'YYYY-MM-DD HH24:MI:SS')
	]]>
	</query>
	
	<query id="PhosphateResultService.getCancelMatConfirm" desc="取消确认接箍入库">
	<![CDATA[
 UPDATE COUPLING_PHOSPHATE_RESULT T SET T.MATCONFIRM = '0',T.MATCONFIRM_NAME = ?,T.MATCONFIRM_TIME = ? WHERE T.WO_ID = ? and t.COL_SHIFT = ?
 AND T.JUDGE_STOVE_NO = ? AND T.BATCH_NO = ? AND T.MATCONFIRM = ? AND T.CREATE_TIME = TO_DATE(?,'YYYY-MM-DD HH24:MI:SS')
	]]>
	</query>

	<query id="PhosphateResultService.ProcessPlan.AddCoupProcessRD"
		desc="新增接箍磷化检验结果">
        <![CDATA[
         INSERT INTO COUPLING_PHOSPHATE_RESULT_D
                    (ITEM_NO,
                    TEST_RESULT_F,
                    TEST_RESULT_T,
                    DOSAGE,
                    TEMPERATURE,
                    RESULT_NO,
                    DETAIL_NO)
            VALUES
                   (?,
                    ?,
                    ?,
                    ?,
                    ?,
                    ?,
                    ?)
        ]]>
	</query>

	<query id="PhosphateResultService.ProcessPlan.UpdateCoupProcessRD"
		desc="修改接箍磷化检验结果">
		<![CDATA[
			 UPDATE COUPLING_PHOSPHATE_RESULT_D set
							ITEM_NO=?, 
							TEST_RESULT_F=?,
							TEST_RESULT_T=?,
							DOSAGE=?,
							TEMPERATURE=?
							WHERE RESULT_NO =? and DETAIL_NO=?
		]]>
	</query>
	
	<query id="PhosphateResultService.ProcessPlan.unlixianThreadingResult"
		desc="撤销离线磷化镀铜实绩">
        <![CDATA[
      DELETE COUPLING_PHOSPHATE_RESULT WHERE RESULT_NO = ?
    
        ]]>
	</query>
	
	
	<query id="PhosphateResultService.unlixianComInfoResult" desc="撤销ComInfo表">
		DELETE COUPLING_COM_INFO WHERE RESULT_NO = ? AND WO_ID=? AND IF_OUT_RPO = '1'
	</query>
	
	
	<query
		id="PhosphateResultService.unlixianofflineResult"
		desc="撤销离线表">
        <![CDATA[
         DELETE COUPLING_OFFLINE_RESULT WHERE RESULT_NO = ? 
        ]]>
	</query>
	
	
	<query id="PhosphateResultService.unupdatelixianofflineResult"
		desc="修改工单工序的离线状态">
        <![CDATA[
      UPDATE PLN_ZY_JG_WORKBILL
   SET IF_OUT_COAT='0'
 WHERE WO_ID = ?
      
        ]]>
	</query>
	
	
	<query id="PhosphateResultService.unupdatelixianofflineResult2"
		desc="修改工单工序的离线状态">
        <![CDATA[
      UPDATE PLN_ZY_JG_WORKBILL
   SET IF_OUT_COAT='1'
 WHERE WO_ID = ?
      
        ]]>
	</query>
	
	<query id="PhosphateResultService.queryLodResult2" desc="查询磷化镀铜实绩对应是否撤销离线">
SELECT count(1) count
  FROM COUPLING_PHOSPHATE_RESULT T
 WHERE T.WO_ID = ?
   and t.if_all_out_work='1'
	</query>
	
	
	<query id="PhosphateResultService.ProcessPlan.GetPhosphateResult"
		desc="根据计划号查询磷化检测实绩">
        <![CDATA[
  SELECT C.RESULT_NO,
       C.PLINE_CODE,
       C.ZY_PLAN_ID,
       C.MEMBRANCE_THICK,
       DECODE(C.ADHESION, '1', '不合格','合格') ADHESION,
       C.ANTI_CORROSION,
       C.REACTION_TIME,
       DECODE(C.SURFACE_CONDITION, '1', '不合格','合格') SURFACE_CONDITION,
       C.REMARK,
       C.COL_USER,
       DECODE(C.COL_SHIFT, '1', '早', '2', '中', '3', '夜') COL_SHIFT,
       DECODE(C.COL_GROUP, '1', '甲', '2', '乙', '3', '丙', '4', '丁') COL_GROUP,
       TO_CHAR(C.COL_TIME, 'YYYY-MM-DD') COL_TIME,
       C.CREATE_NAME,
       TO_CHAR(C.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       C.UPDATE_NAME,
       TO_CHAR(C.UPDATE_TIME, 'YYYY-MM-DD HH24:MI:SS') UPDATE_TIME,
       C.PRODUCER,
       TO_CHAR(C.PRODUCER_TIME, 'YYYY-MM-DD HH24:MI:SS') PRODUCER_TIME,
       C.COL_COUNT,
       C.COL_OPERATOR,
       DECODE(C.IS_SPRAY, '0', '/', '1', '是') IS_SPRAY,
       C.SPRAY_CONTENT,
       C.SPRAY_COUNT,
       C.WO_ID,
       C.OFF_NUM,
       DECODE(C.IF_ALL_OUT_WORK, '0', '/', '1', '是') IF_ALL_OUT_WORK,
       C.PLINE_NAME,
       C.JUDGE_STOVE_NO,
       C.BATCH_NO,
       C.CONFIRM,
       C.MATCONFIRM_NAME
  FROM COUPLING_PHOSPHATE_RESULT C
 WHERE C.WO_ID = ?
 ORDER BY C.CREATE_TIME DESC
        ]]>
	</query>

<query id="PhosphateResultService.ProcessPlan.lixianThreadingResult"
		desc="离线磷化镀铜实绩">
        <![CDATA[
   UPDATE COUPLING_PHOSPHATE_RESULT T SET T.OFF_NUM=TO_NUMBER(NVL(T.OFF_NUM,0))+TO_NUMBER(?)  WHERE T.RESULT_NO=? 
    
        ]]>
	</query>
	
	<query id="PhosphateResultService.updatelixianofflineResult"
		desc="修改工单工序的离线状态">
        <![CDATA[
      UPDATE PLN_ZY_JG_WORKBILL
   SET IF_OUT_COAT='1'
 WHERE WO_ID = ?
            ]]>
	</query>
	<query id="PhosphateResultService.lixianComInfoResult" desc="插入ComInfo表">
		DECLARE
		BEGIN
		FOR MYROW IN (SELECT T.* FROM PLN_ZY_JG T WHERE T.HEAT_PLAN_NO = ?) LOOP
		INSERT INTO COUPLING_COM_INFO
		(STEELCODE,
		STEELNAME,
		MODEL_CODE,
		MODEL_DESC,
		OUTDIAMETER,
		WALLTHICK,
		SPEC_JG,
		SPEC_JG_DESC,
		STYLE_JG,
		DIAMETER,
		CHECK_J_VAL,
		AIMLENGTH,
		SINGLEWEIGHT,
		MONITORDEMAND,
		IF_MONITOR_JG,
		PRDCR_NO,
		PRODUCER,
		PRODUCER_TIME,
		MACH_NO,
		MACH_NM,
		PRO_NUM,
		PRO_WT,
		FAIL_NUM,
		FAIL_WT,
		OFFLINE_NUM,
		OFFLINE_WT,
		STATION_STATUS,
		RRO_TIME,
		RRO_TIME_NU,
		PRO_USER,
		PRO_SHIFT,
		PRO_GROUP,
		RESULT_NO,
		PRO_PLAN_ID,
		CODE_JG_BL,
		JG_GROUP_ID,
		IF_OUT_RPO,
		PLINE_CODE,
		PLINE_NAME,
		STATION_CODE,
		STATION_DESC,
		JUDGE_STOVE_NO,
		BATCH_NO,
		BL_WL_ID,
		BL_WL_DESC,
		MIN_D,
		MIN_H,
		AIMLENGTH_BL,
		AIM_CUT_LEN,
		LENGTH_MIN,
		LENGTH_MAX,
		TAPER,
		CODE_JG,
		GRADECODE,
		GRADENAME,CREATE_TIME,COL_OPERATOR,WO_ID)
		VALUES
		(MYROW.STEELCODE,
		MYROW.STEELNAME,
		MYROW.MODEL_CODE,
		MYROW.MODEL_DESC,
		MYROW.OUTDIAMETER,
		MYROW.WALLTHICK,
		MYROW.SPEC_JG,
		MYROW.SPEC_JG_DESC,
		MYROW.STYLE_JG,
		MYROW.DIAMETER,
		MYROW.CHECK_J_VAL,
		MYROW.AIMLENGTH,
		MYROW.SINGLEWEIGHT,
		MYROW.MONITORDEMAND,
		MYROW.IF_MONITOR_JG,
		MYROW.PRDCR_NO,
		?,
		TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'),
		?,
		'',
		?,
		?,
		?,
		?,
		?,
		'',
		'1',
		TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'),
		'',
		?,
		?,
		?,
		?,
		MYROW.PRO_PLAN_ID,
		MYROW.CODE_JG_BL,
		MYROW.JG_GROUP_ID,
		?,
		MYROW.PLINE_CODE,
		MYROW.PLINE_NAME,
		?,
		'磷化',
		MYROW.JUDGE_STOVE_NO,
		MYROW.BATCH_NO,
		MYROW.BL_WL_ID,
		MYROW.BL_WL_DESC,
		MYROW.MIN_D,
		MYROW.MIN_H,
		MYROW.AIMLENGTH_BL,
		MYROW.AIM_CUT_LEN,
		MYROW.LENGTH_MIN,
		MYROW.LENGTH_MAX,
		MYROW.TAPER,
		MYROW.CODE_JG,
		MYROW.GRADECODE,
		MYROW.GRADENAME,TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'),?,?);
		END LOOP;
		END;
	</query>
	<query
		id="PhosphateResultService.lixianofflineResult"
		desc="新增离线表">
        <![CDATA[
         INSERT INTO COUPLING_OFFLINE_RESULT
    (RESULT_NO,
     PLINE_CODE,
     WO_ID,
     STATION_CODE,
     STATION_DESC,
     JUDGE_STOVE_NO,
     BATCH_NO,
     OFFLINE_NUM,
     OFFLINE_WT,
     IF_ALL_OUT_WORK,
     HARSH_TYPE,
     COATING_TYPE,
     COL_TIME,
     COL_USER,
     COL_SHIFT,
     COL_GROUP,
     CREATE_TIME)
  VALUES
    (?,
     ?,
     ?,
     ?,
     ?,
     ?,
     ?,
     ?,
     ?,
     ?,
     ?,
     ?,
     TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'),
     ?,
     ?,
     ?,
     TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'))
        ]]>
	</query>
	<query id="PhosphateResultService.queryLoadRESULT" desc="生成实绩编号">
		  SELECT ? || ? || TO_CHAR(SYSDATE, 'yyyyMMDD') ||
         LPAD(NVL(MAX(TO_NUMBER(SUBSTR(RESULT_NO, LENGTH(RESULT_NO) - 5))),
                  0) + 1,
              6,
              '0') RESULT_NO
    FROM  COUPLING_PHOSPHATE_RESULT
   WHERE RESULT_NO LIKE ? || TO_CHAR(SYSDATE, 'yyyyMMDD') || '______'
	</query>	
	<query id="PhosphateResultService.ProcessPlan.AddPhosphateResult"
		desc="新增磷化检测实绩">
        <![CDATA[
         INSERT INTO COUPLING_PHOSPHATE_RESULT (RESULT_NO, MEMBRANCE_THICK, ADHESION, 
ANTI_CORROSION, REACTION_TIME, SURFACE_CONDITION, PRODUCER, PRODUCER_TIME, 
COL_SHIFT, COL_GROUP, COL_USER, COL_TIME, PLINE_CODE, ZY_PLAN_ID, REMARK, 
CREATE_NAME, CREATE_TIME,COL_COUNT,COL_OPERATOR,IS_SPRAY,SPRAY_CONTENT,SPRAY_COUNT,IF_ALL_OUT_WORK,WO_ID,PLINE_NAME,JUDGE_STOVE_NO,BATCH_NO) VALUES (?, ?, ?, ?, ?, 
?, ?, TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), ?, ?, ?, 
TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), ?, ?, ?, ?, TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'),?,?,?,?,?,?,?,?,?,?)   
        ]]>
	</query>
	<query id="PhosphateResultService.queryPhosResD" desc="获取最大磷化检验结果序号 ">
	<![CDATA[
SELECT ? || ? ||
       LPAD(SUBSTR(NVL(MAX(T.DETAIL_NO), '000'), -3, 3) + 1, 3, '0') AS DETAIL_NO
  FROM COUPLING_PHOSPHATE_RESULT_D T
 WHERE T.RESULT_NO = ?
	]]>
	</query>
	<query id="PhosphateResultService.DeletephorestD" desc="删除磷化检验结果表 ">
	<![CDATA[
   DELETE COUPLING_PHOSPHATE_RESULT_D WHERE RESULT_NO=?
	]]>
	</query>
	<query id="PhosphateResultService.AddphorestD" desc="新增磷化检验结果表 ">
	<![CDATA[
INSERT INTO COUPLING_PHOSPHATE_RESULT_D
  (DETAIL_NO,
   RESULT_NO,
   ITEM_NO,
   TEST_RESULT_F,
   TEST_RESULT_T,
   DOSAGE,
   TEMPERATURE,
   SEQ_NO,ZY_PLAN_ID,WO_ID)
VALUES
  (?, ?, ?, ?, ?, ?, ?, ?,?,?)
	]]>
	</query>
	<query id="PhosphateResultService.deletePlnInfo" desc="删除接箍公共信息">
		<![CDATA[
	DELETE COUPLING_COM_INFO T
 WHERE T.RESULT_NO = ?
   AND T.WO_ID = ?
			]]>
	</query>
	<query id="PhosphateResultService.queryPlanJg" desc="查询工单表状态">
		<![CDATA[
SELECT T.ZY_BILL_STATUS,
	   T.CUT_STATUS,
       T.CJG_STATUS,
       T.IMPRESS_STATUS,
       T.LATHE_STATUS,
       T.THREAD_CHK_STATUS,
       T.DETECT_STATUS,
       T.BLAST_STATUS,
       T.SPOT_CHK_STATUS,
       T.PLT_CU_STATUS,
       T.PHOS_STATUS,
       T.COPPER_STATUS,
       T.INSTORE_STATUS,
       NVL(T.PLAN_JG_NUM,0) PLAN_JG_NUM,
       NVL(T.CUT_PLN_NUMB,0) CUT_PLN_NUMB,
       NVL(T.CUT_OK_NUM,0) CUT_OK_NUM,
       NVL(T.CJG_PLN_NUM,0) CJG_PLN_NUM,
       NVL(T.CJG_OK_NUM,0) CJG_OK_NUM,
       NVL(T.IMPRESS_PLN_NUM,0) IMPRESS_PLN_NUM,
       NVL(T.IMPRESS_OK_NUM,0) IMPRESS_OK_NUM,
       NVL(T.LATHE_PLN_NUM,0) LATHE_PLN_NUM,
       NVL(T.LATHE_OK_NUM,0) LATHE_OK_NUM,
       NVL(T.THREAD_PLN_NUM,0) THREAD_PLN_NUM,
       NVL(T.THREAD_CHK_OK_NUM,0) THREAD_CHK_OK_NUM,
       NVL(T.DETECT_PLN_NUM,0) DETECT_PLN_NUM,
       NVL(T.DETECT_OK_NUM,0) DETECT_OK_NUM,
       NVL(T.BLAST_PLN_NUM,0) BLAST_PLN_NUM,
       NVL(T.BLAST_OK_NUM,0) BLAST_OK_NUM,
       NVL(T.PLT_PLN_NUM,0) PLT_PLN_NUM,
       NVL(T.PLT_CU_OK_NUM,0) PLT_CU_OK_NUM,
       NVL(T.PHOS_PLN_NUM,0) PHOS_PLN_NUM,
       NVL(T.PHOS_OK_NUM,0) PHOS_OK_NUM,
       NVL(T.COPPER_PLN_NUM,0) COPPER_PLN_NUM,
       NVL(T.COPPER_OK_NUM,0) COPPER_OK_NUM      
  FROM pln_zy_jg_workbill T
 WHERE T.WO_ID = ?
			]]>
	</query>
	<query id="PhosphateResultService.deletePhosphateResult" desc="删除磷化实绩">
		<![CDATA[
		DELETE COUPLING_PHOSPHATE_RESULT WHERE RESULT_NO = ?
			]]>
	</query>
	<query id="PhosphateResultService.queryLodResult1" desc="根据工单号查询是否还有磷化">
		<![CDATA[
      SELECT COUNT(1)  COUNT FROM COUPLING_PHOSPHATE_RESULT T WHERE T.ZY_PLAN_ID=? AND T.WO_ID=?
		]]>
	</query>
	
	<query id="PhosphateResultService.queryLodResult" desc="查询磷化实绩回退是否同一班次班组">
		<![CDATA[
     SELECT COL_SHIFT||'/'||COL_GROUP  LOAD_SHIFT FROM COUPLING_PHOSPHATE_RESULT T WHERE T.RESULT_NO=?
		]]>
	</query>
	<query id="PhosphateResultService.updatePltStatus" desc="结炉修改工单表镀铜状态">
		<![CDATA[
    DECLARE
BEGIN
  UPDATE PLN_ZY_JG_WORKBILL SET PLT_CU_STATUS = '2' WHERE ZY_PLAN_ID = ?  AND WO_ID = ?;
  UPDATE PLN_ZY_JG_WORKBILL SET COPPER_STATUS = ? WHERE ZY_PLAN_ID = ?  AND WO_ID = ?;
  UPDATE COUPLING_COM_INFO
     SET STATION_STATUS = '2'
   WHERE ZY_PLAN_ID = ?
     AND STATION_CODE = ?  AND WO_ID = ?;
  UPDATE COUPLING_COM_INFO
     SET STATION_STATUS = '2'
   WHERE ZY_PLAN_ID = ?
     AND STATION_CODE = ?  AND WO_ID = ?;
END;
		]]>
	</query>
	<query id="PhosphateResultService.updatePltStatus1" desc="撤销结炉修改工单表镀铜状态">
		<![CDATA[
     DECLARE
BEGIN
  UPDATE PLN_ZY_JG_WORKBILL SET PLT_CU_STATUS = '1' WHERE ZY_PLAN_ID = ?  AND WO_ID = ?;
  UPDATE PLN_ZY_JG_WORKBILL SET COPPER_STATUS = ? WHERE ZY_PLAN_ID = ?  AND WO_ID = ?;
  UPDATE COUPLING_COM_INFO
     SET STATION_STATUS = '1'
   WHERE ZY_PLAN_ID = ?
     AND STATION_CODE = ?  AND WO_ID = ?;
  UPDATE COUPLING_COM_INFO
     SET STATION_STATUS = '1'
   WHERE ZY_PLAN_ID = ?
     AND STATION_CODE = ?  AND WO_ID = ?;
END;
		]]>
	</query>
	<query id="PhosphateResultService.updatePhosStatus" desc="结炉修改工单表磷化状态">
		<![CDATA[
DECLARE
BEGIN
  UPDATE PLN_ZY_JG_WORKBILL
     SET PHOS_STATUS = '2'
   WHERE WO_ID = ?;
  UPDATE PLN_ZY_JG_WORKBILL
     SET COPPER_STATUS = ?
   WHERE WO_ID = ?;
  UPDATE COUPLING_COM_INFO
     SET STATION_STATUS = '2'
   WHERE STATION_CODE = ?
     AND WO_ID = ?;
  UPDATE COUPLING_COM_INFO
     SET STATION_STATUS = '2'
   WHERE STATION_CODE = ?
     AND WO_ID = ?;
END;
		]]>
	</query>
	<query id="PhosphateResultService.updatePhosStatus1" desc="撤销结炉修改工单表磷化状态">
		<![CDATA[
 DECLARE
BEGIN
  UPDATE PLN_ZY_JG_WORKBILL
     SET PHOS_STATUS = '1'
   WHERE ZY_PLAN_ID = ?
     AND WO_ID = ?;
  UPDATE PLN_ZY_JG_WORKBILL
     SET COPPER_STATUS = ?
   WHERE ZY_PLAN_ID = ?
     AND WO_ID = ?;
  UPDATE COUPLING_COM_INFO
     SET STATION_STATUS = '1'
   WHERE ZY_PLAN_ID = ?
     AND STATION_CODE = ?
     AND WO_ID = ?;
  UPDATE COUPLING_COM_INFO
     SET STATION_STATUS = '1'
   WHERE ZY_PLAN_ID = ?
     AND STATION_CODE = ?
     AND WO_ID = ?;
END;
		]]>
	</query>
	<query id="PhosphateResultService.queryPhosphateItem" desc="查询磷化检测项目">
		<![CDATA[
     SELECT T.ITEM_NO, T.TEST_ITEMS
  FROM COUPLING_PHOSPHATE_ITEM T
 WHERE T.PLINE_CODE = ?
		]]>
	</query>
	<query id="PhosphateResultService.queryPhosphateItem1" desc="查询磷化检测项目">
		<![CDATA[
      SELECT ITEM_NO,
        PLINE_CODE,
        PROCEDUR_NO,
        TEST_ITEMS,
        SPAN,
        SETTING_TEMPERATURE
   FROM COUPLING_PHOSPHATE_ITEM
  WHERE ITEM_NO = ?
		]]>
	</query>
	<query id="PhosphateResultService.UpdatePlnInfo" desc="修改接箍公共信息">
		<![CDATA[
  UPDATE COUPLING_COM_INFO
     SET PRO_NUM = ?,
         PRO_WT=?,
         OFFLINE_NUM  = ?,
         PRO_SHIFT=?,
         PRO_GROUP=?,
         COL_OPERATOR=?,
         PRODUCER=?,
         PRODUCER_TIME=TO_DATE(?,'YYYY-MM-DD HH24:MI:SS')
   WHERE RESULT_NO = ?
     AND STATION_CODE= ?
     AND WO_ID=?
			]]>
	</query>
	<query id="PhosphateResultService.updatePhosphateResult" desc="修改镀铜实绩">
		<![CDATA[
UPDATE COUPLING_PHOSPHATE_RESULT
   SET MEMBRANCE_THICK   = ?,
       ADHESION          = ?,
       ANTI_CORROSION    = ?,
       REACTION_TIME     = ?,
       SURFACE_CONDITION = ?,
       REMARK            = ?,
       COL_SHIFT         = ?,
       COL_GROUP         = ?,
       UPDATE_NAME       = ?,
       UPDATE_TIME       = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'),
       PRODUCER          = ?,
       PRODUCER_TIME     = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'),
       COL_COUNT         = ?,
       COL_OPERATOR      = ?,
       SPRAY_CONTENT     = ?,
       SPRAY_COUNT       = ?
 WHERE RESULT_NO = ?
			]]>
	</query>
	<query id="PhosphateResultService.queryRests" desc="根据工单号查询实绩支数">
		<![CDATA[
	  SELECT COUNT(1) COUNT,SUM(NVL(T.COL_COUNT, 0)) COL_COUNT,
         SUM(NVL(T.SPRAY_COUNT, 0)) SPRAY_COUNT
    FROM COUPLING_PHOSPHATE_RESULT T
   WHERE T.ZY_PLAN_ID = ?
   AND T.WO_ID=?
		]]>
	</query>
	<query id="PhosphateResultService.UpdatePhosphateResultD" desc="修改检验记录">
		<![CDATA[
UPDATE COUPLING_PHOSPHATE_RESULT_D
   SET ITEM_NO       = ?,
       TEST_RESULT_F = ?,
       TEST_RESULT_T = ?,
       DOSAGE        = ?,
       TEMPERATURE   = ?
 WHERE DETAIL_NO = ?
   AND RESULT_NO = ?
   AND ZY_PLAN_ID = ?
   AND SEQ_NO = ?
		]]>
	</query>
	<query id="PhosphateResultService.DeletePhosphateResultD" desc="删除检验记录">
		<![CDATA[
delete coupling_phosphate_result_d 
 WHERE DETAIL_NO = ?
		]]>
	</query>
	<query id="PhosphateResultService.QueryInsResultD" desc="检验记录是否有数据">
		<![CDATA[
select count(1) count from coupling_phosphate_result_d 
 WHERE RESULT_NO = ?
		]]>
	</query>
	<query id="PhosphateResultService.QueryInsResult" desc="查询实绩是否有数据">
		<![CDATA[
select count(1) count from coupling_phosphate_result 
 WHERE RESULT_NO = ?
		]]>
	</query>
	<query id="PhosphateResultService.AddMatM"
		desc="新增接箍材料表">
        <![CDATA[
         DECLARE
  V_WO_ID       PLN_ZY_JG_WORKBILL.WO_ID%type := ?;
  V_MAT_NO      COUPLING_MAT_M.MAT_NO%type := ?;
  V_RESULT_NO   COUPLING_MAT_M.RESULT_NO%type := ?;
  V_PRO_NUM     COUPLING_MAT_M.PRO_NUM%type := ?;
  V_PRO_WT      COUPLING_MAT_M.PRO_WT%type := ?;
  V_RRO_TIME    COUPLING_MAT_M.MAT_NO%type := ?;
  V_PRO_SHIFT   COUPLING_MAT_M.PRO_SHIFT%type := ?;
  V_PRO_GROUP   COUPLING_MAT_M.PRO_GROUP%type := ?;
  V_CREATE_NAME COUPLING_MAT_M.CREATE_NAME%type := ?;
  V_CREATE_TIME COUPLING_MAT_M.MAT_NO%type := ?;
  V_BELONG_CODE COUPLING_MAT_M.BELONG_CODE%type := ?;
  V_BELONG_NAME COUPLING_MAT_M.BELONG_NAME%type := ?;
  V_QCM_STAUS   COUPLING_MAT_M.QCM_STAUS%type := ?;

BEGIN
  FOR MYROW IN (SELECT T.WO_ID,
                       T.HEAT_PLAN_NO,
                       T.JUDGE_STOVE_NO,
                       T.BATCH_NO,
                       T.BATCH_GROUD_NO,
                       T.PLINE_CODE,
                       T.PLINE_NAME,
                       T.IF_ALL_OUT_WORK,
                       T.IF_OUT_CUT,
                       T.IF_OUT_CJG,
                       T.IF_OUT_IMPRESS,
                       T.IF_OUT_LATHE,
                       T.IF_OUT_DETECT,
                       T.IF_OUT_BLAST,
                       T.IF_OUT_COAT,
                       T.COAT_TYPE,
                       T.IFSPLIT,
                       NVL(T.PLAN_JG_NUM, 0) PLAN_JG_NUM,
                       NVL(T.CS_JG_NUM, 0) CS_JG_NUM,
                       NVL(T.XQ_JG_NUM, 0) XQ_JG_NUM,
                       T.DEMAND_COPPER,
                       T.LATHE_GRP_NO,
                       T.LATHE_GRP_NM,
                       T.DEMAND_DETECTION,
                       T.DEMAND_BLAST,
                       T.DEMAND_BONDERIZING,
                       T.ZY_BILL_STATUS,
                       T.MEMO,
                       T.CREATE_NAME,
                       TO_CHAR(T.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
                       T.UPDATE_NAME,
                       TO_CHAR(T.UPDATE_TIME, 'YYYY-MM-DD HH24:MI:SS') UPDATE_TIME,
                       T.IF_OUT_COPPER,
                       TO_CHAR(T.CLOSE_TIME, 'YYYY-MM-DD HH24:MI:SS') CLOSE_TIME,
                       NVL(T.PLAN_BL_NUM, 0) PLAN_BL_NUM,
                       NVL(T.PLAN_BL_WT, 0) PLAN_BL_WT,
                       T.IF_OUT_THREAD,
                       NVL(T.REAL_BL_NUM, 0) REAL_BL_NUM,
                       NVL(T.REAL_BL_WT, 0) REAL_BL_WT,
                       T.STOVE_NO,
                       T.FLAG_STOVE_NO,
                       T.OUT_NUM,
                       T.OUT_WT,
                       T.STEELCODE,
                       T.STEELNAME,
                       T.GRADECODE,
                       T.GRADENAME,
                       T.SPEC_JG_DESC,
                       T.SPEC_JG,
                       T.STYLE_JG,
                       T.STD_CODE,
                       T.STD_NAME,
                       T.STD_STYLE,
                       T.STD_STYLE_DESC,
                       T.PRODUCCODE_JG,
                       T.PRODUCCODE_JG_DESC,
                       T.CODE_JG,
                       T.CODE_JG_BL,
                       T.CODE_BL_ALL,
                       T.MODEL_CODE,
                       T.MODEL_DESC,
                       T.IF_MONITOR_JG,
                       T.PRDCR_NO,
                       T.HEAT_PLAN_SQE,
                       T.KEY,
                       T.BL_WL_ID,
                       T.BL_WL_DESC,
                       T.OUTWL_ID,
                       T.OUTWL_DESC,
                       T.AIMLENGTH_BL,
                       T.AIM_CUT_LEN,
                       T.SINGLE_CUT_NUN,
                       T.SINGLEWEIGHT,
                       T.PER_STATUS,
                       T.BESIDE_STATUS,
                       T1.MIN_D,
                       T1.MIN_H,
                       T1.LENGTH_MAX,
                       T1.LENGTH_MIN,
                       T1.TAPER,
                       T1.DIAMETER_JG,
                       T1.HEIGHT_JG,
                       T1.DIAMETER,
                       T1.CHECK_J_VAL,
                       T1.LENGTH_JG,
                       T1.WEIGHT_JG,
                       T.JG_ORDERNO_ALL,
                       T.CRAFT_PATH,
                       T.CRAFT_NO_JG2,
                       T.CRAFT_SEQ2,
                       T.ORD_LN_DLY_PK,
                       T.LATHE_CUT_NM,
                       T.DELIVERY_NO,
                       T.ORDER_NO,
                       T.ORDER_SEQ,
                       T.IS_LOAD_FLAG,
                       T.ORDER_NO || '/' || T.ORDER_SEQ ORDER_NO_SEQ,
                       T.CRAFT_SEQ,
                       T.CRAFT_FILE_NO,
                       T.BUYER_NAME,
                       T2.produccode PRODUCCODE_BL,
                       T2.producname PRODUCNAME_BL,
                       T2.std_code STD_CODE_BL,
                       T2.std_name std_name_BL,
                       T2.steelcode steelcode_BL,
                       T2.steelname steelname_BL,
                       T2.std_style std_style_BL,
                       T2.std_style_desc std_style_desc_BL,
                       T2.model_code model_code_BL,
                       T2.model_desc model_desc_BL,
                       T2.MIN_D MIN_D_BL,
                       T2.MIN_H MIN_H_BL
                  FROM PLN_ZY_JG_WORKBILL T, COM_MSC_JG T1, COM_MSC_BL T2
                 WHERE T.CODE_JG = T1.CODE_JG(+)
                   AND T.CODE_JG_BL = T2.PSC_BL(+)
                   AND T.WO_ID = V_WO_ID) LOOP
  
    INSERT INTO COUPLING_MAT_M
      (MAT_NO,
       RESULT_NO,
       ZY_PLAN_ID,
       WO_ID,
       PLINE_CODE,
       PLINE_NAME,
       JUDGE_STOVE_NO,
       BATCH_NO,
       BL_WL_ID,
       BL_WL_DESC,
       MIN_D,
       MIN_H,
       CODE_JG,
       GRADECODE,
       GRADENAME,
       STEELCODE,
       STEELNAME,
       MODEL_CODE,
       MODEL_DESC,
       OUTDIAMETER,
       WALLTHICK,
       SPEC_JG,
       SPEC_JG_DESC,
       STYLE_JG,
       DIAMETER,
       CHECK_J_VAL,
       AIMLENGTH,
       SINGLEWEIGHT,
       MONITORDEMAND,
       IF_MONITOR_JG,
       PRDCR_NO,
       PRODUCER,
       PRO_NUM,
       PRO_WT,
       RRO_TIME,
       PRO_SHIFT,
       PRO_GROUP,
       COL_OPERATOR,
       CREATE_NAME,
       CREATE_TIME,
       F_IN_TIME,
       BELONG_CODE,
       BELONG_NAME,
       QCM_STAUS,
       CRAFT_SEQ,
       CODE_JG_BL,
       STOVE_NO,
       FLAG_STOVE_NO,
       PRODUCCODE_JG,
       PRODUCCODE_JG_DESC,
       PRODUCCODE_BL,
       PRODUCNAME_BL,
       STD_CODE_BL,
       STD_NAME_BL,
       STEELCODE_BL,
       STEELNAME_BL,
       STD_STYLE_BL,
       STD_STYLE_DESC_BL,
       MODEL_CODE_BL,
       MODEL_DESC_BL,
       MIN_D_BL,
       MIN_H_BL,
       DEMAND_DETECTION,
       DEMAND_BLAST,
       DEMAND_BONDERIZING,
       DEMAND_COPPER,
       COAT_TYPE,
       ORDER_NO,
       ORDER_SEQ,
       DELIVERY_NO,
       ORD_LN_DLY_PK,
       JG_ORDERNO_ALL)
    VALUES
      (V_MAT_NO,
       V_RESULT_NO,
       '',
       V_WO_ID,
       MYROW.PLINE_CODE,
       MYROW.PLINE_NAME,
       MYROW.JUDGE_STOVE_NO,
       MYROW.BATCH_NO,
       MYROW.OUTWL_ID,
       MYROW.OUTWL_DESC,
       MYROW.MIN_D,
       MYROW.MIN_H,
       MYROW.CODE_JG,
       MYROW.GRADECODE,
       MYROW.GRADENAME,
       MYROW.STEELCODE,
       MYROW.STEELNAME,
       MYROW.MODEL_CODE,
       MYROW.MODEL_DESC,
       MYROW.DIAMETER_JG,
       MYROW.HEIGHT_JG,
       MYROW.SPEC_JG,
       MYROW.SPEC_JG_DESC,
       MYROW.STYLE_JG,
       MYROW.DIAMETER,
       MYROW.CHECK_J_VAL,
       MYROW.LENGTH_JG,
       MYROW.SINGLEWEIGHT,
       '',
       MYROW.IF_MONITOR_JG,
       MYROW.PRDCR_NO,
       '',
       V_PRO_NUM,
       V_PRO_WT,
       TO_DATE(V_RRO_TIME, 'YYYY-MM-DD HH24:MI:SS'),
       V_PRO_SHIFT,
       V_PRO_GROUP,
       '',
       V_CREATE_NAME,
       TO_DATE(V_CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS'),
       TO_DATE(V_CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS'),
       V_BELONG_CODE,
       V_BELONG_NAME,
       V_QCM_STAUS,
       MYROW.CRAFT_SEQ,
       MYROW.CODE_JG_BL,
       MYROW.STOVE_NO,
       MYROW.FLAG_STOVE_NO,
       MYROW.PRODUCCODE_JG,
       MYROW.PRODUCCODE_JG_DESC,
       MYROW.PRODUCCODE_BL,
       MYROW.PRODUCNAME_BL,
       MYROW.STD_CODE_BL,
       MYROW.STD_NAME_BL,
       MYROW.STEELCODE_BL,
       MYROW.STEELNAME_BL,
       MYROW.STD_STYLE_BL,
       MYROW.STD_STYLE_DESC_BL,
       MYROW.MODEL_CODE_BL,
       MYROW.MODEL_DESC_BL,
       MYROW.MIN_D_BL,
       MYROW.MIN_H_BL,
       MYROW.DEMAND_DETECTION,
       MYROW.DEMAND_BLAST,
       MYROW.DEMAND_BONDERIZING,
       MYROW.DEMAND_COPPER,
       MYROW.COAT_TYPE,
       MYROW.ORDER_NO,
       MYROW.ORDER_SEQ,
       MYROW.DELIVERY_NO,
       MYROW.ORD_LN_DLY_PK,
       MYROW.JG_ORDERNO_ALL);
  
  END LOOP;
END;
        ]]>
	</query>
	
	<query id="PhosphateResultService.QueryPhosphateResult" desc="查询返线交库数据">
		<![CDATA[
select count(1) count
  from coupling_phosphate_result T
 WHERE T.REMARK = '返线交库'
   AND T.WO_ID = ?
		]]>
	</query>
</queryMap>