<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="接箍切割作业实绩">
	<query id="FrmPerformanceResult.GetCutResultByPlanNo" desc="根据计划号查询切割实绩">
        <![CDATA[
  SELECT TO_CHAR(CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
        COL_OPERATOR,
        RESULT_NO,
        PLINE_CODE,
        ZY_PLAN_ID,
        QUALIFIED_NUMBER,
        CUT_PIECES,
        REJECTED_PCS,
        REJECTED_REASON,
        COL_MODE,
        TO_CHAR(COL_TIME, 'YYYY-MM-DD') COL_TIME,
        COL_USER,
        DECODE(COL_SHIFT, '1', '早', '2', '中', '3', '夜') COL_SHIFT,
        DECODE(COL_GROUP, '1', '甲', '2', '乙', '3', '丙', '4', '丁') COL_GROUP,
        MACHINE_NO,
        IS_REMAINING,
        LVALID_LENGTH,
        PRODUCER,
        TO_CHAR(PRODUCER_TIME, 'YYYY-MM-DD HH24:MI:SS') PRODUCER_TIME,
        DECODE(IS_EMBOSSED, '0', '否', '1', '是') IS_EMBOSSED,
        EMB_CONTENT,
        EMB_COUNT,
        ROUGHMACH_COUNT,
        WO_ID,
        OFF_NUM,
        DECODE(IF_ALL_OUT_WORK,'0','否','1','是') IF_ALL_OUT_WORK
   FROM COUPLING_CUT_RESULT
 WHERE ZY_PLAN_ID = ? 
       AND WO_ID=?
       ORDER BY CREATE_TIME DESC
        ]]>
	</query>
	<query id="FrmPerformanceResult.getCoupSandBlast" desc="查询喷砂实绩">
        <![CDATA[
       SELECT RESULT_NO,
       PLINE_CODE,
       ZY_PLAN_ID,
       SPRAY_MATERIAL,
       SPRAY_THICK,
       SPRAY_EQUIPMENT,
       SPRAY_PRESSURE,
       SPRAY_COUNT,
       REJECTED_PCS,
       REJECTED_REASON,
       COL_USER,
       DECODE(COL_SHIFT, '1', '早', '2', '中', '3', '夜') COL_SHIFT,
       DECODE(COL_GROUP, '1', '甲', '2', '乙', '3', '丙', '4', '丁') COL_GROUP,
       COL_OPERATOR,
       QUALIRIED_PCS,
       MEMO,
       TO_CHAR(CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       UPDATE_NAME,
       TO_CHAR(UPDATE_TIME, 'YYYY-MM-DD HH24:MI:SS') UPDATE_TIME,
       TO_CHAR(COL_TIME, 'YYYY-MM-DD HH24:MI:SS') COL_TIME,
       WO_ID,
       OFF_NUM,
       DECODE(IF_ALL_OUT_WORK,'0','否','1','是') IF_ALL_OUT_WORK
  FROM COUPLING_SANDBLAST_RESULT
 WHERE ZY_PLAN_ID = ?
 AND WO_ID=?
 ORDER BY CREATE_TIME DESC
        ]]>
	</query>
	<query id="FrmPerformanceResult.getThreadingResult" desc="根据计划号查询车丝实绩">
        <![CDATA[
       SELECT 
       COL_OPERATOR1,
       COL_OPERATOR2,
       RESULT_NO,
       PLINE_CODE,
       ZY_PLAN_ID,
       PRODUCED_PCS,
       QUALIRIED_PCS,
       REJECTED_PCS,
       REJECTED_REASON,
       COL_MODE,
       TO_CHAR(COL_TIME, 'YYYY-MM-DD HH24:MI:SS') COL_TIME,
       COL_USER,
       DECODE(COL_SHIFT, '1', '早', '2', '中', '3', '夜') COL_SHIFT,
       DECODE(COL_GROUP, '1', '甲', '2', '乙', '3', '丙', '4', '丁') COL_GROUP,
       MACHINE_NO,
       PRODUCER,
       TO_CHAR(PRODUCER_TIME, 'YYYY-MM-DD HH24:MI:SS') PRODUCER_TIME,
       TO_CHAR(CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       WO_ID,
       OFF_NUM,
       DECODE(IF_ALL_OUT_WORK,'0','否','1','是') IF_ALL_OUT_WORK
 FROM COUPLING_THREADING_RESULT
 WHERE ZY_PLAN_ID=?	    
 AND WO_ID=?
 ORDER BY CREATE_TIME DESC
        ]]>
	</query>
	<query id="FrmPerformanceResult.queryLoadRESULT" desc="生成实绩编号">
		SELECT ? ||'B'||
		? ||
		LPAD(SUBSTR(NVL(MAX(T.RESULT_NO), '00000'), -5, 5) + 1, 5, '0') AS
		RESULT_NO
		FROM COUPLING_CUT_RESULT T
		WHERE T.PLINE_CODE = ?

	</query>
	<query id="FrmPerformanceResult.ProcessPlan.lixianThreadingResult"
		desc="离线车丝实绩">
        <![CDATA[
      INSERT INTO COUPLING_CUT_RESULT
  (RESULT_NO,
   PLINE_CODE,
   ZY_PLAN_ID,
   WO_ID,
   COL_USER,
   COL_SHIFT,
   COL_GROUP,
   CREATE_TIME,
   IF_ALL_OUT_WORK,
   OFF_NUM)
VALUES
  (?, ?, ?, ?, ?, ?, ?,TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), ?, ?)
    
        ]]>
	</query>
	<query id="FrmPerformanceResult.lixianComInfoResult" desc="插入ComInfo表">
		DECLARE
		BEGIN
		FOR MYROW IN (SELECT T.* FROM PLN_ZY_JG T WHERE T.ZY_PLAN_ID = ?) 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,
		ZY_PLAN_ID,
		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.ZY_PLAN_ID,
		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;
		UPDATE PLN_ZY_JG_WORKBILL T SET 
	   T.LATHE_OK_NUM   = TO_NUMBER(NVL(T.LATHE_OK_NUM, 0)) + TO_NUMBER(?),
       T.LATHE_FAIL_NUM = TO_NUMBER(NVL(T.LATHE_FAIL_NUM, 0)) + TO_NUMBER(?),
       T.LATHE_STATUS   = '1'
 WHERE T.ZY_PLAN_ID = ?
   AND T.WO_ID = ?;
		END;
	</query>
</queryMap>