<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="接箍探伤作业实绩">
	<query id="FrmInspection.getCoupSandBlast" desc="查询探伤实绩">
        <![CDATA[
SELECT T.RESULT_NO,
       T.PLINE_CODE,
       T.ZY_PLAN_ID,
       T.QUALIRIED_PCS,
       T.REJECTED_PCS,
       T.INSPECT_PIECES,
       T.COL_USER,
       DECODE(T.COL_SHIFT, '1', '早', '2', '中', '3', '夜','0','常白') COL_SHIFT,
       DECODE(T.COL_GROUP, '1', '甲', '2', '乙', '3', '丙', '4', '丁') COL_GROUP,
       T.INSP_STANDARD,
       T.SPECIMEN_TYPE,
       T.SPECIMEN_MAGNETIC,
       T.MAGNETIC_POWDER,
       T.CONCENTRATION,
       T.COIL_INTENSITY,
       T.CENTER_INTENSITY,
       T.VOLTAGE,
       T.MEMO,
       TO_CHAR(T.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       T.COL_OPERATOR,
       T.UNQUALIRIED_REASON,
       T.UNQUALIRIED_PCS,
       T.AMOUNT_PCS,
       T.FINAL_QUALIFIED,
       T.REJECTED_REASON,
       TO_CHAR(T.COL_TIME, 'YYYY-MM-DD') COL_TIME,
       T.WO_ID,
       T.OFF_NUM,
       DECODE(T.IF_ALL_OUT_WORK,'0','否','1','是') IF_ALL_OUT_WORK,
       T.PLINE_NAME,
       T.JUDGE_STOVE_NO,
       T.BATCH_NO,
       T.POSITION,
       T.REPORT_PATH REPORT,
       T.MAGTIMES,
       T.ISSUED,
       T.CONFIRM,
       (SELECT LISTAGG(T1.FAIL_TYPE_NAME || ';') WITHIN GROUP(ORDER BY FAIL_TYPE_NAME)
                  FROM (SELECT T2.FAIL_TYPE_NAME || '(' || T2.FAIL_NUM || ')' FAIL_TYPE_NAME,
                               T2.WO_ID,
                               T2.RESULT_NO,
                               T2.VALIDFLAG
                          FROM COUPLING_BUG_REASION T2) T1
                 WHERE T1.WO_ID = T.WO_ID
                   AND T1.RESULT_NO = T.RESULT_NO AND T1.VALIDFLAG ='1') FAIL_NAME,
                          (SELECT LISTAGG(T1.FAIL_TYPE_NAME || ';') WITHIN GROUP(ORDER BY FAIL_TYPE_NAME)
                  FROM (SELECT T2.FAIL_TYPE_NAME || '(' || T2.FAIL_NUM || ')' FAIL_TYPE_NAME,
                               T2.WO_ID,
                               T2.RESULT_NO,
                               T2.VALIDFLAG
                          FROM COUPLING_BUG_REASION T2) T1
                 WHERE T1.WO_ID = T.WO_ID
                   AND T1.RESULT_NO = T.RESULT_NO AND T1.VALIDFLAG ='2') FAILBUG_NAME
  FROM COUPLING_INSPECTION_RESULT T 
 WHERE  T.WO_ID=?
 ORDER BY T.CREATE_TIME DESC
        ]]>
	</query>	
		<query id="FrmInspection.getInspectResult" desc="查询探伤支数总和">
        <![CDATA[
   SELECT NVL(SUM(T.INSPECT_PIECES), 0) PRO_NUM FROM COUPLING_INSPECTION_RESULT T
   WHERE T.WO_ID = ?
        ]]>
	</query>
	<query id="FrmInspection.getComBaseInfo" desc="根据班组带出操作工">
        <![CDATA[
   SELECT T.BASECODE,T.BASENAME FROM COM_BASE_INFO T WHERE T.SORTCODE = ? AND T.MEMO = ?
        ]]>
	</query>
	<query id="FrmInspection.UpdateReportUrl" desc="修改探伤路径">
        <![CDATA[
   UPDATE  COUPLING_INSPECTION_RESULT SET REPORT_PATH = ? WHERE RESULT_NO = ?    
        ]]>
	</query>
	
	<query id="FrmInspection.getConfirm" desc="确认探伤实绩">
	<![CDATA[
 UPDATE COUPLING_INSPECTION_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="FrmInspection.getCancelConfirm" desc="取消确认探伤实绩">
	<![CDATA[
 UPDATE COUPLING_INSPECTION_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="FrmInspection.AddSandResult" desc="新增探伤实绩">
        <![CDATA[
INSERT INTO COUPLING_INSPECTION_RESULT (RESULT_NO, PLINE_CODE, ZY_PLAN_ID, 
QUALIRIED_PCS, REJECTED_PCS, INSPECT_PIECES, COL_MODE, COL_TIME, COL_USER, 
COL_SHIFT, COL_GROUP, INSP_STANDARD, SPECIMEN_TYPE, SPECIMEN_MAGNETIC, 
MAGNETIC_POWDER, CONCENTRATION, COIL_INTENSITY, CENTER_INTENSITY, VOLTAGE, MEMO, 
CREATE_TIME, COL_OPERATOR, UNQUALIRIED_REASON, UNQUALIRIED_PCS, AMOUNT_PCS, 
FINAL_QUALIFIED, REJECTED_REASON, IF_ALL_OUT_WORK,WO_ID,PLINE_NAME,JUDGE_STOVE_NO,BATCH_NO,POSITION,MAGTIMES,ISSUED) VALUES (?, ?, ?, ?, ?, ?, ?, 
TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 
TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), ?, ?, ?, ?, ?, ?, ?,?,?,?,?,?,?,?)
        ]]>
	</query>
	<query id="FrmInspection.ProcessPlan.lixianThreadingResult"
		desc="离线车丝实绩">
        <![CDATA[
 UPDATE COUPLING_INSPECTION_RESULT T SET T.OFF_NUM=TO_NUMBER(NVL(T.OFF_NUM,0))+TO_NUMBER(?)  WHERE T.RESULT_NO=?   
        ]]>
	</query>
	
	
	<query id="FrmInspection.ProcessPlan.unlixianThreadingResult"
		desc="撤销离线探伤实绩">
        <![CDATA[
      DELETE COUPLING_INSPECTION_RESULT WHERE RESULT_NO = ?
    
        ]]>
	</query>
	
		<query id="FrmInspection.ProcessPlan.AddFailComInfo"
		desc="新增螺纹检验废品数据">
        <![CDATA[
    INSERT INTO COUPLING_BUG_REASION 
(RESULT_NO,
WO_ID,
FAIL_TYPE_CODE,
FAIL_TYPE_NAME,
FAIL_NUM,
FAIL_WT,
VALIDFLAG
) VALUES(
?,
?,
?,
?,
?,
?,
?)
        ]]>
	</query>
	
		<query id="FrmInspection.DeleteFail"
		desc="删除探伤废品">
        <![CDATA[
      DELETE FROM COUPLING_BUG_REASION T
 WHERE T.RESULT_NO = ?
   AND T.WO_ID = ?
        ]]>
	</query>
	
	<query id="FrmInspection.unlixianComInfoResult" desc="撤销ComInfo表">
		DELETE COUPLING_COM_INFO WHERE RESULT_NO = ? AND WO_ID=? AND IF_OUT_RPO = '1'
	</query>
	
	<query
		id="FrmInspection.unlixianofflineResult"
		desc="撤销离线表">
        <![CDATA[
         DELETE COUPLING_OFFLINE_RESULT WHERE RESULT_NO = ? 
        ]]>
	</query>
	
	<query id="FrmInspection.unupdatelixianofflineResult"
		desc="修改工单工序的离线状态">
        <![CDATA[
      UPDATE PLN_ZY_JG_WORKBILL
   SET IF_OUT_DETECT='0'
 WHERE WO_ID = ?
      
        ]]>
	</query>
	
	<query id="FrmInspection.unupdatelixianofflineResult2"
		desc="修改工单工序的离线状态">
        <![CDATA[
      UPDATE PLN_ZY_JG_WORKBILL
   SET IF_OUT_DETECT='1'
 WHERE WO_ID = ?
      
        ]]>
	</query>
	
	<query id="FrmInspection.querylixian" desc="查询探伤实绩对应是否离线">
SELECT count(1) count
  FROM COUPLING_INSPECTION_RESULT T
 WHERE T.WO_ID = ?
   and t.if_all_out_work='1'
	</query>
	<query id="FrmInspection.updatelixianofflineResult"
		desc="修改工单工序的离线状态">
        <![CDATA[
      UPDATE PLN_ZY_JG_WORKBILL
   SET IF_OUT_DETECT='1'
 WHERE WO_ID = ?
    
        ]]>
	</query>
	<query id="FrmInspection.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="FrmInspection.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,OFF_XH)
  VALUES
    (?,
     ?,
     ?,
     ?,
     '探伤',
     ?,
     ?,
     ?,
     ?,
     ?,
     ?,
     ?,
     TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'),
     ?,
     ?,
     ?,
     TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'),
     (SELECT LPAD(SUBSTR(NVL(MAX(T.OFF_XH), '000'), -3, 3) + 1, 3, '0') AS OFF_XH
   FROM COUPLING_OFFLINE_RESULT T
  WHERE RESULT_NO = ?))
        ]]>
	</query>
		
		<query id="FrmInspection.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_INSPECTION_RESULT
   WHERE RESULT_NO LIKE ? || TO_CHAR(SYSDATE, 'yyyyMMDD') || '______'
	</query>	
	<query id="FrmInspection.UpdateSandResult" desc="修改探伤实绩">
        <![CDATA[
UPDATE COUPLING_INSPECTION_RESULT
   SET QUALIRIED_PCS      = ?,
       REJECTED_PCS       = ?,
       INSPECT_PIECES     = ?,
       COL_SHIFT          = ?,
       COL_GROUP          = ?,
       INSP_STANDARD      = ?,
       SPECIMEN_TYPE      = ?,
       SPECIMEN_MAGNETIC  = ?,
       MAGNETIC_POWDER    = ?,
       CONCENTRATION      = ?,
       COIL_INTENSITY     = ?,
       CENTER_INTENSITY   = ?,
       VOLTAGE            = ?,
       MEMO               = ?,
       COL_OPERATOR       = ?,
       UPDATE_NAME        = ?,
       UPDATE_DATE        = TO_DATE(?,'YYYY-MM-DD HH24:MI:SS'),
       UNQUALIRIED_REASON = ?,
       UNQUALIRIED_PCS    = ?,
       AMOUNT_PCS         = ?,
       FINAL_QUALIFIED    = ?,
       REJECTED_REASON    = ?,
       MAGTIMES = ?,
       ISSUED = ?
 WHERE RESULT_NO = ?

        ]]>
	</query>
		<query id="FrmInspection.UpdateComInfoResult" desc="修改信息">
        <![CDATA[
 DECLARE
BEGIN
  UPDATE COUPLING_COM_INFO T
     SET T.PRO_NUM      = ?,
         T.PRO_WT       =?,
         T.FAIL_NUM     = ?,
         T.FAIL_WT      =?,
         T.PRO_SHIFT    = ?,
         T.PRO_GROUP    = ?,
         T.COL_OPERATOR = ?
   WHERE T.STATION_CODE = ?
     AND T.RESULT_NO = ?
     AND T.WO_ID = ?;
END;
        ]]>
	</query>
	<query id="FrmInspection.queryCutCou" desc="查询探伤实绩对应工单重支数">
  SELECT COUNT(1) COUNT,
       SUM(NVL(T.FINAL_QUALIFIED, 0)) FINAL_QUALIFIED,
       SUM(NVL(T.INSPECT_PIECES, 0)) INSPECT_PIECES,
       SUM(NVL(T.REJECTED_PCS, 0)) REJECTED_PCS
  FROM COUPLING_INSPECTION_RESULT T
 WHERE T.ZY_PLAN_ID = ?
 AND T.WO_ID=?
	</query>
	<query id="FrmInspection.DeleteSandResult" desc="删除探伤实绩">
DELETE COUPLING_INSPECTION_RESULT WHERE RESULT_NO = ?
	</query>
	<query id="FrmInspection.DeleteComInfoResult" desc="删除comInfo表">
		DELETE
		COUPLING_COM_INFO WHERE RESULT_NO = ? AND STATION_CODE=? AND WO_ID=?
	</query>
	<query id="FrmInspection.doBeside" desc="结炉">
DECLARE
BEGIN
  UPDATE COUPLING_COM_INFO T
     SET T.STATION_STATUS = '2'
   WHERE T.ZY_PLAN_ID = ?
     AND T.STATION_CODE = ?
     AND T.WO_ID=?;
  UPDATE PLN_ZY_JG_WORKBILL T SET T.DETECT_STATUS='2' WHERE T.ZY_PLAN_ID = ? AND T.WO_ID=?;
END;
	</query>
	<query id="FrmInspection.unDoBeside" desc="撤销结炉">
		DECLARE
BEGIN
  UPDATE COUPLING_COM_INFO T
     SET T.STATION_STATUS = '1'
   WHERE T.ZY_PLAN_ID = ?
     AND T.STATION_CODE = ?
     AND T.WO_ID=?;
  UPDATE PLN_ZY_JG_WORKBILL T SET T.DETECT_STATUS = '1' WHERE T.ZY_PLAN_ID = ? AND T.WO_ID=?;
END;
	</query>
</queryMap>