<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="接箍切割作业实绩">
	<query id="FrmOutSourPerfor.doQueryLoadResult" desc="查询接箍公共信息">		
        <![CDATA[
  SELECT RESULT_NO,
       ZY_PLAN_ID,
       PRO_PLAN_ID,
       CODE_JG_BL,
       JG_GROUP_ID, 
       DECODE(IF_OUT_RPO,'1', '是', '0', '否') 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,
       STEELCODE,
       STEELNAME,
       MODEL_CODE,
       MODEL_DESC,
       OUTDIAMETER,
       WALLTHICK,
       SPEC_JG,
       SPEC_JG_DESC,
       STYLE_JG,
       DIAMETER,
       CHECK_J_VAL,
       AIMLENGTH,
       SINGLEWEIGHT,
       MONITORDEMAND,
       DECODE(IF_MONITOR_JG, '1', '是', '0', '否') IF_MONITOR_JG,
       PRDCR_NO,
       PRODUCER,
       TO_CHAR(PRODUCER_TIME, 'YYYY-MM-DD HH24:MI:SS') PRODUCER_TIME,
       MACH_NO,
       MACH_NM,
       NVL(PRO_NUM,0) PRO_NUM,
       NVL(PRO_WT,0) PRO_WT,
       NVL(FAIL_NUM,0) FAIL_NUM,
       NVL(FAIL_WT,0) FAIL_WT,
       NVL(OFFLINE_NUM,0) OFFLINE_NUM,
       NVL(OFFLINE_WT,0) OFFLINE_WT,
       DECODE(STATION_STATUS, '1', '生产中', '2', '生产完成') STATION_STATUS,
       TO_CHAR(CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       TO_CHAR(RRO_TIME, 'YYYY-MM-DD') RRO_TIME,
       COL_OPERATOR,
       RRO_TIME_NU,
       PRO_USER,
       DECODE(PRO_SHIFT, '1', '早', '2', '中', '3', '夜') PRO_SHIFT,
       DECODE(PRO_GROUP, '1', '甲', '2', '乙', '3', '丙', '4', '丁') PRO_GROUP,
       DECODE(IF_ALL_OUT_WORK, '1', '是', '0', '否') IF_ALL_OUT_WORK,
       WO_ID
  FROM COUPLING_COM_INFO
  WHERE ZY_PLAN_ID =?
  AND WO_ID=?
  AND IF_OUT_RPO>'0'
  ORDER BY CREATE_TIME DESC
        ]]>
	</query>
	<query id="FrmOutSourPerfor.queryLoadRESULT" desc="生成实绩编号">
		SELECT ? || ?
		|| ? ||
		LPAD(SUBSTR(NVL(MAX(T.RESULT_NO), '00000'), -5, 5) + 1, 5, '0')
		AS RESULT_NO
		FROM COUPLING_COM_INFO T
		WHERE TO_CHAR(T.CREATE_TIME,
		'YYYY-MM-DD') = ?
		AND T.PLINE_CODE = ?
		AND T.ZY_PLAN_ID = ?
		AND
		T.STATION_CODE = ?
		AND T.WO_ID = ?
	</query>
	<query id="FrmOutSourPerfor.updatePln" desc="修改锯切计划表">
	   <![CDATA[
	  UPDATE PLN_ZY_JG_WORKBILL
   SET CUT_OK_NUM = TO_NUMBER(?),
       CUT_STATUS = ?
 WHERE WO_ID = ?
	      ]]>
	</query>
	<query id="FrmOutSourPerfor.UpdateComInfoResult" desc="修改comInfo表">
		UPDATE
		COUPLING_COM_INFO
		SET PRO_NUM = ?, PRO_SHIFT = ?, PRO_GROUP = ?
		WHERE
		RESULT_NO = ?
		AND ZY_PLAN_ID = ?
		AND STATION_CODE = ?
		AND WO_ID = ?
	</query>
	<query id="FrmOutSourPerfor.queryCutCou" desc="查询是否存在离线记录">
		SELECT COUNT(*)
		COUNT,RESULT_NO
		FROM COUPLING_COM_INFO T
		WHERE T.ZY_PLAN_ID = ?
		AND
		T.STATION_CODE = ?
		AND T.WO_ID=?
		AND T.IF_OUT_RPO='1'
	</query>
	<query id="FrmOutSourPerfor.DeleteComInfoResult" desc="删除comInfo表">
		DELETE
		COUPLING_COM_INFO
		WHERE RESULT_NO = ?
		AND ZY_PLAN_ID = ?
		AND
		STATION_CODE=?
		AND WO_ID=?
	</query>
	<query id="FrmOutSourPerfor.queryCutCou1" desc="查询实绩对应工单重支数">
		SELECT Count(*)
		count, NVL(SUM(T.PRO_NUM), 0) PRO_NUM
		FROM COUPLING_COM_INFO T
		WHERE
		T.ZY_PLAN_ID = ?
		AND T.STATION_CODE = ?
		AND T.WO_ID=?
	</query>
	<query id="FrmOutSourPerfor.selectComInfo" desc="查询是否已存在该单号的实绩">
		SELECT
		T.PRO_NUM
		FROM COUPLING_COM_INFO T WHERE T.ZY_PLAN_ID = ?
		AND T.STATION_CODE = ?
	</query>
	<query id="FrmOutSourPerfor.doBeside" desc="锯切结炉">
		DECLARE
		BEGIN
		UPDATE
		COUPLING_COM_INFO T
		SET T.STATION_STATUS = ?
		WHERE T.ZY_PLAN_ID = ?
		AND
		T.STATION_CODE = ?
		AND T.WO_ID = ?;
		UPDATE
		PLN_ZY_JG_WORKBILL T
		SET
		T.CUT_STATUS = ?
		WHERE T.ZY_PLAN_ID = ?
		AND
		T.WO_ID = ?;
		END;
	</query>
	<query id="FrmOutSourPerfor.doBesideCJG" desc="粗加工结炉">
		DECLARE
		BEGIN
		UPDATE
		COUPLING_COM_INFO T
		SET T.STATION_STATUS = ?
		WHERE T.ZY_PLAN_ID = ?
		AND
		T.STATION_CODE = ?
		AND T.WO_ID = ?;
		UPDATE
		PLN_ZY_JG_WORKBILL T
		SET
		T.CJG_STATUS = ?
		WHERE T.ZY_PLAN_ID = ?
		AND
		T.WO_ID = ?;
		END;

	</query>
	<query id="FrmOutSourPerfor.doBesideYY" desc="压印结炉">
		DECLARE
		BEGIN
		UPDATE
		COUPLING_COM_INFO T
		SET T.STATION_STATUS = ?
		WHERE T.ZY_PLAN_ID = ?
		AND
		T.STATION_CODE = ?
		AND T.WO_ID = ?;
		UPDATE
		PLN_ZY_JG_WORKBILL T
		SET
		T.IMPRESS_STATUS = ?
		WHERE T.ZY_PLAN_ID = ?
		AND
		T.WO_ID = ?;
		END;
	</query>
	<query id="FrmOutSourPerfor.doBesideDT" desc="镀铜结炉">
		DECLARE
		BEGIN
		UPDATE
		COUPLING_COM_INFO T
		SET T.STATION_STATUS = ?
		WHERE T.ZY_PLAN_ID = ?
		AND
		T.STATION_CODE = ?
		AND T.WO_ID = ?;
		UPDATE
		PLN_ZY_JG_WORKBILL T
		SET
		T.PLT_CU_STATUS = ?
		WHERE T.ZY_PLAN_ID = ?
		AND
		T.WO_ID = ?;
		END;

	</query>
	<query id="FrmOutSourPerfor.doBesideTS" desc="探伤结炉">
		DECLARE
		BEGIN
		UPDATE
		COUPLING_COM_INFO T
		SET T.STATION_STATUS = ?
		WHERE T.ZY_PLAN_ID = ?
		AND
		T.STATION_CODE = ?
		AND T.WO_ID = ?;
		UPDATE
		PLN_ZY_JG_WORKBILL T
		SET
		T.DETECT_STATUS = ?
		WHERE T.ZY_PLAN_ID = ?
		AND
		T.WO_ID = ?;
		END;

	</query>
	<query id="FrmOutSourPerfor.doBesidePS" desc="喷砂结炉">
		DECLARE
		BEGIN
		UPDATE
		COUPLING_COM_INFO T
		SET T.STATION_STATUS = ?
		WHERE T.ZY_PLAN_ID = ?
		AND
		T.STATION_CODE = ?
		AND T.WO_ID = ?;
		UPDATE
		PLN_ZY_JG_WORKBILL T
		SET
		T.BLAST_STATUS = ?
		WHERE T.ZY_PLAN_ID = ?
		AND
		T.WO_ID = ?;
		END;

	</query>
	<query id="FrmOutSourPerfor.doBesideCS" desc="车丝结炉">
		DECLARE
		BEGIN
		UPDATE
		COUPLING_COM_INFO T
		SET T.STATION_STATUS = ?
		WHERE T.ZY_PLAN_ID = ?
		AND
		T.STATION_CODE = ?
		AND T.WO_ID = ?;
		UPDATE
		PLN_ZY_JG_WORKBILL T
		SET
		T.LATHE_STATUS = ?
		WHERE T.ZY_PLAN_ID = ?
		AND
		T.WO_ID = ?;
		END;
	</query>
	<query id="FrmOutSourPerfor.doBesideLH" desc="磷化结炉">
		DECLARE
		BEGIN
		UPDATE
		COUPLING_COM_INFO T
		SET T.STATION_STATUS = ?
		WHERE T.ZY_PLAN_ID = ?
		AND
		T.STATION_CODE = ?
		AND T.WO_ID = ?;
		UPDATE
		PLN_ZY_JG_WORKBILL T
		SET
		T.PHOS_STATUS = ?
		WHERE T.ZY_PLAN_ID = ?
		AND
		T.WO_ID = ?;
		END;

	</query>

	<query id="FrmOutSourPerfor.doBesideLW" desc="螺纹结炉">
		DECLARE
		BEGIN
		UPDATE
		COUPLING_COM_INFO T
		SET T.STATION_STATUS = ?
		WHERE T.ZY_PLAN_ID = ?
		AND
		T.STATION_CODE = ?
		AND T.WO_ID = ?;
		UPDATE
		PLN_ZY_JG_WORKBILL T
		SET
		T.THREAD_CHK_STATUS = ?
		WHERE T.ZY_PLAN_ID = ?
		AND T.WO_ID = ?;
		END;

	</query>

	<query id="FrmOutSourPerfor.doBesidePB" desc="喷标结炉">
		DECLARE
		BEGIN
		UPDATE
		COUPLING_COM_INFO T
		SET T.STATION_STATUS = ?
		WHERE T.ZY_PLAN_ID = ?
		AND
		T.STATION_CODE = ?
		AND T.WO_ID = ?;
		UPDATE
		PLN_ZY_JG_WORKBILL T
		SET
		T.COPPER_STATUS = ?
		WHERE T.ZY_PLAN_ID = ?
		AND
		T.WO_ID = ?;
		END;

	</query>
</queryMap>