<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="接箍切割作业实绩">
	<query id="CoupCutService.CutPlan.GetCutResultByPlanNo" desc="根据计划号查询切割实绩">
        <![CDATA[
  SELECT T.RESULT_NO,
       T.WO_ID,
      NVL(T.QUALIFIED_NUMBER,0) QUALIFIED_NUMBER,
       T.CUT_PIECES,
       T.REJECTED_PCS,
       T.REJECTED_REASON,
       T.PLINE_CODE,
       T.PLINE_NAME,
       T.PRALO_PCS,
       DECODE(T.COL_MODE, '0', '接口采集', '1', '人工录入') COL_MODE,
       TO_CHAR(T.COL_TIME, 'YYYY-MM-DD HH24:MI:SS') COL_TIME,
       T.COL_USER,
       DECODE(T.COL_SHIFT, '1', '早', '2', '中', '3', '夜') COL_SHIFT,
       DECODE(T.COL_GROUP, '1', '甲', '2', '乙', '3', '丙', '4', '丁') COL_GROUP,
       T.MACHINE_NO,
       DECODE(T.IS_REMAINING, '0', '/', '1', '是') IS_REMAINING,
       T.LVALID_LENGTH,
       DECODE(T.IS_EMBOSSED, '0', '/', '1', '是') IS_EMBOSSED,
       T.EMB_CONTENT,
       NVL(T.EMB_COUNT,0) EMB_COUNT,
       NVL(T.ROUGHMACH_COUNT,0) ROUGHMACH_COUNT,
       T.IS_ROUGHMACH,
       DECODE(T.IF_ALL_OUT_WORK, '0', '/', '1', '是') IF_ALL_OUT_WORK,
       TO_CHAR(T.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       T.COL_OPERATOR,
       NVL(T.OFF_NUM,0) OFF_NUM,
       DECODE(T.IF_MONITOR_JG, '0', '/', '1', '是') IF_MONITOR_JG,
       T.PRDCR_NO,
       T.JUDGE_STOVE_NO,
       T.BATCH_NO,
       T.MEMO,
       T.CONFIRM
  FROM COUPLING_CUT_RESULT T
 WHERE T.WO_ID = ?
  ORDER BY T.CREATE_TIME DESC
        ]]>
	</query>
	<query id="CoupCutService.DeletePortJg" desc="删除子管队列">
		<![CDATA[
DELETE FROM port_jg_batch_sample_result  WHERE WO_ID =? AND M_MAT_NO = ?
			]]>
	</query>
	<query id="CoupCutService.QueryCouplingOff" desc="查询委外数据">
		<![CDATA[
SELECT COUNT(*) COUNT FROM COUPLING_OFFLINE_RESULT T WHERE T.WO_ID = ? AND (T.SUBCONTRACT_NUM >0 AND T.SUBCONTRACTCOMPLETE_NUM=0)
			]]>
	</query>
	<query id="CoupCutService.UpdatePortJg" desc="修改子管队列">
		<![CDATA[
UPDATE port_jg_batch_sample_result T SET T.MAT_STATUS=?,T.OP_PROCESS=?, RESULT_NO=?
WHERE T.WO_ID=? AND T.MAT_NO=?
			]]>
	</query>
	<query id="CoupCutService.updateMatStatus" desc="更新材料表状态">
		<![CDATA[
             Update MAT_BC_M SET QCM_STAUS = ? WHERE MAT_NO = ?
			]]>
	</query>
	<query id="CoupCutService.QueryMatGp" desc="查询list表里材料号">
		<![CDATA[
             SELECT t.mat_no, t.act_weight
  FROM mat_bc_backup t, YDM_BC_BUTTRESS T1
 WHERE T.MAT_NO = T1.MAT_NO(+)
   AND T.QCM_STAUS = '00'
   AND T.JUDGE_STOVE_NO = ?
   AND T.BATCH_NO = ?
   AND NVL(T.BATCH_GROUD_NO, '/') = NVL(?, '/')
   AND T.NEXT_PROCESS_CDOE = 'H'
   AND rownum <= ?
   AND T.MAT_NO NOT IN (SELECT M.MAT_NO
                          FROM mat_bc_m M
                         WHERE m.QCM_STAUS = '11'
                           AND M.JUDGE_STOVE_NO = ?
                           AND M.BATCH_NO = ?
                           AND NVL(M.BATCH_GROUD_NO, '/') = NVL(?, '/')
                           AND M.NEXT_PROCESS_CDOE = 'H')
        AND T.MAT_NO NOT IN (SELECT M.MAT_NO
                          FROM mat_bc_backup M
                         WHERE m.mat_no = t.mat_no
                           AND M.Process_Cdoe ='H'
                          )
 ORDER BY T.MAT_NO ASC
			]]>
	</query>
	
	<query id="CoupCutService.queryMaxMatNo" desc="查询最大材料号">
	 <![CDATA[  
select ? ||
       LPAD(SUBSTR(NVL(MAX(T.MAT_NO), '000'), -3, 3) + 1, 3, '0') AS MAT_NO
        from COUPLING_MAT_M t WHERE T.JUDGE_STOVE_NO = ? 
   ]]>
	</query>
	<query id="CoupCutService.getConfirm" desc="确认切管实绩">
	<![CDATA[
 UPDATE COUPLING_CUT_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="CoupCutService.getCancelConfirm" desc="取消确认切管实绩">
	<![CDATA[
 UPDATE COUPLING_CUT_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="CoupCutService.CutPlan.AddCutResult" desc="新增切割实绩">
        <![CDATA[
       INSERT INTO COUPLING_CUT_RESULT
  (RESULT_NO,
   PLINE_CODE,
   WO_ID,
   QUALIFIED_NUMBER,
   CUT_PIECES,
   REJECTED_PCS,
   REJECTED_REASON,
   COL_MODE,
   COL_TIME,
   COL_USER,
   COL_SHIFT,
   COL_GROUP,
   MACHINE_NO,
   IS_REMAINING,
   LVALID_LENGTH,
   IS_EMBOSSED,
   EMB_CONTENT,
   EMB_COUNT,
   ROUGHMACH_COUNT,
   IS_ROUGHMACH,
   IF_ALL_OUT_WORK,
   CREATE_TIME,
   COL_OPERATOR,
   OFF_NUM,
   IF_MONITOR_JG,
   PRDCR_NO,
   PLINE_NAME,
   PRALO_PCS,
   JUDGE_STOVE_NO,
   BATCH_NO,
   MEMO)
VALUES
  ('#RESULT_NO#',
   '#PLINE_CODE#',
   '#WO_ID#',
   '#QUALIFIED_NUMBER#',
   '#CUT_PIECES#',
   '#REJECTED_PCS#',
   '#REJECTED_REASON#',
   '1',
   TO_DATE('#COL_TIME#', 'YYYY-MM-DD HH24:MI:SS'),
   '#COL_USER#',
   '#COL_SHIFT#',
   '#COL_GROUP#',
   '#MACHINE_NO#',
   '#IS_REMAINING#',
   '#LVALID_LENGTH#',
   '#IS_EMBOSSED#',
   '#EMB_CONTENT#',
   '#EMB_COUNT#',
   '#ROUGHMACH_COUNT#',
   '#IS_ROUGHMACH#',
   '#IF_ALL_OUT_WORK#',
   TO_DATE('#CREATE_TIME#', 'YYYY-MM-DD HH24:MI:SS'),
   '#COL_OPERATOR#',
   '#OFF_NUM#',
   '#IF_MONITOR_JG#',
   '#PRDCR_NO#',
   '#PLINE_NAME#',
   '#PRALO_PCS#',
   '#JUDGE_STOVE_NO#',
   '#BATCH_NO#',
   '#MEMO#')

        ]]>
	</query>

	<query id="CoupCutService.AddPortJg" desc="增加子管队列">
		<![CDATA[

INSERT INTO PORT_JG_BATCH_SAMPLE_RESULT
  (
   WO_ID,
   MAT_NO,
   M_MAT_NO,
   M_M_MAT_NO,
   LOT_NO,
   PLINE_CODE,
   PLINE_NAME,
   JUDGE_STOVE_NO,
   BATCH_NO,
   GROUP_NO,
   STOVE_NO,
   FLAG_STOVE_NO,
   SINGLE_CUT_NUN,
   ACT_COUNT,
   ACT_WEIGHT,
   ACT_THEORY_WEIGHT,
   OP_PROCESS,
   MAT_STATUS,
   LEVE_LOG,
   INSTORE_FLAG,
   RETURN_PROCESS,
   PRO_USER,
   PRO_SHIFT,
   PRO_GROUP,
   PRO_TIME,
   REMARK,
   RESULT_NO,
   VALIDFLAG)
  SELECT
  		 WO_ID,
         MAT_NO || LPAD(?,3,'0'),
         ?,
         M_M_MAT_NO,
         LOT_NO,
         PLINE_CODE,
         PLINE_NAME,
         JUDGE_STOVE_NO,
         BATCH_NO,
         GROUP_NO,
         STOVE_NO,
         FLAG_STOVE_NO,
         1,
         ACT_COUNT,
         ACT_WEIGHT/SINGLE_CUT_NUN,
         ACT_THEORY_WEIGHT/SINGLE_CUT_NUN,
         OP_PROCESS,
         MAT_STATUS,
         LEVE_LOG,
         '0',
         '',
         PRO_USER,
         PRO_SHIFT,
         PRO_GROUP,
         PRO_TIME,
         REMARK,
         RESULT_NO,
         '1'
    FROM PORT_JG_BATCH_SAMPLE_RESULT
    WHERE WO_ID = ? AND MAT_NO = ?
			]]>
	</query>
	
	<query id="CoupCutService.MarkPortMch" desc="标记母管">
		<![CDATA[
          UPDATE  PORT_JG_BATCH_SAMPLE_RESULT SET VALIDFLAG = ?
          WHERE WO_ID = ? AND MAT_NO = ?
			]]>
	</query>

<query id="CoupCutService.getCutResult" desc="查询切割支数总和">
        <![CDATA[
   SELECT NVL(SUM(T.CUT_PIECES), 0) PRO_NUM,NVL(SUM(T.QUALIFIED_NUMBER), 0) CUT_NUM FROM COUPLING_CUT_RESULT T
   WHERE T.WO_ID = ?
        ]]>
	</query>
		<query id="CoupCutService.ProcessPlan.updateJgPortResult" desc="修改队列表工艺路径，材料状态，工序状态,离线状态">
		<![CDATA[
UPDATE PORT_JG_BATCH_SAMPLE_RESULT T
    SET   T.MAT_STATUS          = ?,
       T.LEVE_LOG            = ?,
       T.OP_PROCESS          = ?,
       T.RESULT_NO = ?
 WHERE T.WO_ID = ?
   AND T.MAT_NO=?
   AND T.MAT_STATUS = '00'
   AND T.VALIDFLAG = '1'
			]]>
	</query>
		<query id="CoupCutService.QueryCanCut" desc="查找可以分切的队列">
		<![CDATA[
SELECT *
  FROM (SELECT *
          FROM PORT_JG_BATCH_SAMPLE_RESULT
         WHERE  WO_ID = ?
           AND INSTORE_FLAG ='0'
           AND VALIDFLAG = '1'
           AND MAT_STATUS = '00'
           AND SINGLE_CUT_NUN > 1
         ORDER BY MAT_NO ASC)
 WHERE ROWNUM <= ?
			]]>
	</query>
	
			<query id="CoupCutService.QueryPortMaxMatNo" desc="查找可以分切的队列">
		<![CDATA[
SELECT MAX(MAT_NO) MAT_NO
          FROM PORT_JG_BATCH_SAMPLE_RESULT
         WHERE  WO_ID = ?
           AND INSTORE_FLAG ='0'
           AND VALIDFLAG = '1'
           AND MAT_STATUS = '00'
           AND SINGLE_CUT_NUN > 1
           AND ROWNUM <= ?
         ORDER BY MAT_NO ASC
			]]>
	</query>
	<query id="CoupCutService.getCutResultPiece" desc="查询切割个数总和">
        <![CDATA[
   SELECT NVL(SUM(T.QUALIFIED_NUMBER), 0) PRO_NUM FROM COUPLING_CUT_RESULT T
   WHERE T.WO_ID = ?
        ]]>
	</query>
<query id="CoupCutService.doQuerybianhao" desc="查询机床编号">
        <![CDATA[
	SELECT T.MACHINE_NAME FROM COUPLING_MACHINE_USER T
		WHERE T.PLINE_NO=? AND T.PROCESS_NO=? AND T.MACHINE_GROUP=?
        ]]>
	</query>
	<query id="CoupCutService.doQueryZygNo" desc="作业工单查询">
	<![CDATA[
	SELECT T.ZY_PLAN_ID,
       T.BATCH_NO,
       T.JUDGE_STOVE_NO,
       DECODE(T.ZY_PLAN_STATUS,
              '0',
              '计划',
              '1',
              '下发',
              '2',
              '生产中',
              '3',
              '生产完成',
              '4',
              '取消') ZY_PLAN_STATUS,
       T.PLINE_CODE,
       T.PLINE_NAME,
       T.PRO_PLAN_ID,
       DECODE(T.IF_OUT_CUT, '0', '否', '1', '是') IF_OUT_CUT,
       DECODE(T.IF_IMPRESS, '0', '否', '1', '是') IF_IMPRESS,
       DECODE(T.IF_OUT_IMPRESS, '0', '否', '1', '是') IF_OUT_IMPRESS,
       T.CUT_MACH_GRP_NM,
       DECODE(T.CUT_STATUS, '0', '计划', '1', '生产中','2','生产完成') CUT_STATUS, 
       NVL(T.PLAN_CUT_NUM,0) PLAN_CUT_NUM,
       NVL(T.PLAN_IMPRESS_NUM,0) PLAN_IMPRESS_NUM
       FROM PLN_ZY_JG T
 WHERE T.ZY_PLAN_ID || '&' LIKE ('%' || ? || '%')
   AND T.JUDGE_STOVE_NO || '&' LIKE ('%' || ? || '%')
   AND T.BATCH_NO || '&' LIKE ('%' || ? || '%')
   AND T.ZY_PLAN_STATUS IN ('1','2')
  
   ]]>
	</query>
	<query id="CoupCutService.doQueryLoadResult" desc="查询上料实绩">
		SELECT
		LOAD_WEIGHT AS PRO_WT,
		RESULT_NO,
		ZY_PLAN_ID,
		LOAD_WEIGHT AS PRO_NUM,
		DECODE(LOAD_SHIFT, '1', '甲', '2', '乙', '3', '丙', '4', '丁') PRO_SHIFT,
		DECODE(LOAD_GROUP, '0', '常白', '1', '早', '2', '中', '3', '夜') PRO_GROUP,
		LOAD_USER,
		TO_CHAR(LOAD_TIME, 'YYYY-MM-DD HH24:MI:SS') RRO_TIME
		FROM COUPLING_LOADING_RESULT
		WHERE ZY_PLAN_ID = ?
		ORDER BY LOAD_TIME DESC
	</query>
	<query id="CoupCutService.doQueryPrdcr" desc="查询监制信息">
		SELECT DISTINCT
		T.PRDCR_MAN FROM SLM_ORDER_LINE_PRDCR_LST T WHERE T.PRDCR_NO = ?
	</query>
	<query id="CoupCutService.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_CUT_RESULT
   WHERE RESULT_NO LIKE ? || TO_CHAR(SYSDATE, 'yyyyMMDD') || '______'

	</query>
	<query id="CoupCutService.ProcessPlan.lixianThreadingResult"
		desc="离线切割实绩">
        <![CDATA[
   UPDATE COUPLING_CUT_RESULT T SET T.OFF_NUM=TO_NUMBER(NVL(T.OFF_NUM,0))+TO_NUMBER(?)  WHERE T.RESULT_NO=? 
        ]]>
	</query>
	<query id="CoupCutService.ProcessPlan.lixianThreadingResultLoad"
		desc="离线上料实绩">
        <![CDATA[
   UPDATE COUPLING_LOADING_RESULT T SET T.OFF_NUM=TO_NUMBER(NVL(T.OFF_NUM,0))+TO_NUMBER(?)  WHERE T.RESULT_NO=? 
        ]]>
	</query>
	<query id="CoupCutService.ProcessPlan.lixianThreadingResultThread"
		desc="离线车丝实绩">
        <![CDATA[
   UPDATE COUPLING_THREADING_RESULT T SET T.OFF_NUM=TO_NUMBER(NVL(T.OFF_NUM,0))+TO_NUMBER(?)  WHERE T.RESULT_NO=? 
        ]]>
	</query>
	<query id="CoupCutService.ProcessPlan.lixianThreadingResultThinsp"
		desc="离线螺纹检验实绩">
        <![CDATA[
   UPDATE COUPLING_THINSPECT_RESULT T SET T.OFF_NUM=TO_NUMBER(NVL(T.OFF_NUM,0))+TO_NUMBER(?)  WHERE T.RESULT_NO=? 
        ]]>
	</query>
	<query id="CoupCutService.ProcessPlan.lixianThreadingResultSand"
		desc="离线喷砂实绩">
        <![CDATA[
   UPDATE COUPLING_SANDBLAST_RESULT T SET T.OFF_NUM=TO_NUMBER(NVL(T.OFF_NUM,0))+TO_NUMBER(?)  WHERE T.RESULT_NO=? 
        ]]>
	</query>
	<query id="CoupCutService.ProcessPlan.lixianThreadingResultPhosp"
		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="CoupCutService.ProcessPlan.unlixianThreadingResult"
		desc="撤销离线锯切实绩">
        <![CDATA[
      DELETE COUPLING_CUT_RESULT WHERE RESULT_NO = ?
    
        ]]>
	</query>
	<query id="CoupCutService.updatelixianofflineResult"
		desc="修改工单工序的离线状态">
        <![CDATA[
      UPDATE PLN_ZY_JG_WORKBILL
   SET IF_OUT_CUT = '1', IF_OUT_CJG = '1', IF_OUT_IMPRESS = '1'
 WHERE WO_ID = ?
      
        ]]>
	</query>
	
	<query id="CoupCutService.unupdatelixianofflineResult"
		desc="修改工单工序的离线状态">
        <![CDATA[
      UPDATE PLN_ZY_JG_WORKBILL
   SET IF_OUT_CUT = '0', IF_OUT_CJG = '0', IF_OUT_IMPRESS = '0'
 WHERE WO_ID = ?
      
        ]]>
	</query>
	<query id="CoupCutService.unupdatelixianofflineResult2"
		desc="修改工单工序的离线状态">
        <![CDATA[
      UPDATE PLN_ZY_JG_WORKBILL
   SET IF_OUT_CUT = '1', IF_OUT_CJG = '1', IF_OUT_IMPRESS = '1'
 WHERE WO_ID = ?
      
        ]]>
	</query>
	<query id="CoupCutService.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="CoupCutService.unlixianComInfoResult" desc="撤销ComInfo表">
		DELETE COUPLING_COM_INFO WHERE RESULT_NO = ? AND WO_ID=? AND IF_OUT_RPO = '1'
	</query>
	<query
		id="CoupCutService.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,
     MEMO,
     BATCH_GROUD_NO,
     PLINE_NAME)
  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="CoupCutService.queryPortJgPort" desc="查询管号队列合格数据">
		<![CDATA[
	SELECT T1.*
  FROM (SELECT 
               T.MAT_NO,
               T.M_MAT_NO,
               T.M_M_MAT_NO,
               T.LOT_NO,
               T.PLINE_CODE,
               T.PLINE_NAME,
               T.JUDGE_STOVE_NO,
               T.BATCH_NO,
               T.GROUP_NO,
               T.STOVE_NO,
               T.ACT_COUNT,
               T.ACT_WEIGHT,
               T.ACT_THEORY_WEIGHT,
               T.OP_PROCESS,
               T.MAT_STATUS,
               T.LEVE_LOG,
               T.INSTORE_FLAG,
               T.PRO_USER,
               T.PRO_SHIFT,
               T.PRO_GROUP,
               T.PRO_TIME,
               T.REMARK
          FROM PORT_JG_BATCH_SAMPLE_RESULT T
         WHERE T.MAT_STATUS = '00'
           AND T.VALIDFLAG = '1'
           AND T.WO_ID = ?
           AND T.INSTORE_FLAG = '0'
         ORDER BY T.MAT_NO ASC) T1
 WHERE ROWNUM < ?
			]]>
	</query>
	<query id="CoupCutService.queryPortJgBatchHg" desc="查询合格支">
		<![CDATA[
		SELECT NVL(SUM(T.ACT_COUNT),0) ACT_COUNT
  FROM PORT_JG_BATCH_SAMPLE_RESULT T
 WHERE T.MAT_STATUS = '00'
   AND T.WO_ID = ?
   AND T.INSTORE_FLAG = '0'
			]]>
	</query>
	<query
		id="CoupCutService.unlixianofflineResult"
		desc="撤销离线表">
        <![CDATA[
         DELETE COUPLING_OFFLINE_RESULT WHERE RESULT_NO = ? 
        ]]>
	</query>
	<query id="CoupCutService.getMachine" desc="查询机床编号">
		SELECT T.MACHINE_NAME,T.MACHINE_NO FROM Coupling_Machine_Cut_User T WHERE 1=1
	</query>
	<query id="CoupCutService.getCutResultFp" desc="查询废品原因">
		SELECT T.BASENAME FAIL_TYPE_NAME,T.BASECODE FROM COM_BASE_INFO T WHERE T.SORTCODE=? AND T.VALIDFLAG='1' ORDER BY T.BASECODE
	</query>
	<query id="CoupCutService.getMachUser" desc="查询操作工">
		SELECT T.MACHINE_USER1 FROM COUPLING_OPERATION T WHERE 1=1 AND  T.PROCESS_NO='700302'
	</query>
	<query id="CoupCutService.getMatProBz" desc="查询操作工班组">
		SELECT T.PRO_BZ, DECODE(T.PRO_BZ, '1', '甲', '2', '乙', '3', '丙', '4', '丁') PRO_BZ_NAME	FROM COUPLING_OPERATION T WHERE 1=1 AND  T.PROCESS_NO='700302'
	</query>
	<query id="CoupCutService.CutPlan.UpdateCutResult" desc="修改切割实绩">
UPDATE COUPLING_CUT_RESULT
   SET QUALIFIED_NUMBER = ?,
       CUT_PIECES       = ?,
       REJECTED_PCS     = ?,
       REJECTED_REASON  = ?,
       COL_SHIFT        = ?,
       COL_GROUP        = ?,
       MACHINE_NO       = ?,
       LVALID_LENGTH    = ?,
       COL_OPERATOR     = ?,
       EMB_CONTENT      = ?,
       EMB_COUNT        = ?
 WHERE RESULT_NO = ?

	</query>
	<query id="CoupCutService.UpdateComInfoResult" desc="修改comInfo表">
UPDATE COUPLING_COM_INFO
   SET PRO_NUM      = ?,
       PRO_WT       =?,
       FAIL_NUM     = ?,
       FAIL_WT      =?,
       PRO_SHIFT    = ?,
       PRO_GROUP    = ?,
       COL_OPERATOR = ?
 WHERE RESULT_NO = ?
   AND STATION_CODE = ?
   AND WO_ID=?
	</query>
	<query id="CoupCutService.queryCutCou" desc="查询切割实绩对应工单总支数">
SELECT COUNT(1) COUNT,
       SUM(NVL(T.QUALIFIED_NUMBER, 0)) QUALIFIED_NUMBER,
       SUM(NVL(T.REJECTED_PCS, 0)) REJECTED_PCS,
       SUM(NVL(T.EMB_COUNT, 0)) EMB_COUNT
  FROM COUPLING_CUT_RESULT T
 WHERE T.ZY_PLAN_ID = ?
   AND T.WO_ID = ?
	</query>
	
	<query id="CoupCutService.querylixian" desc="查询切割实绩对应是否离线">
SELECT count(1) count
  FROM COUPLING_CUT_RESULT T
 WHERE T.WO_ID = ?
   and t.if_all_out_work='1'
	</query>
	<query id="CoupCutService.deleteCutData" desc="删除切割实绩">
		DELETE COUPLING_CUT_RESULT WHERE RESULT_NO = '#RESULT_NO#'
	</query>
	
	<query id="CoupCutService.deleteComData" desc="删除comInfo表">
		DELETE COUPLING_COM_INFO WHERE RESULT_NO = '#RESULT_NO#' AND WO_ID='#WO_ID#'
	</query>
		<query id="CoupCutService.QueryCanCut2" desc="查找撤销分切的队列">
		<![CDATA[
SELECT *
  FROM (SELECT *
          FROM port_jg_batch_sample_result
         WHERE  WO_ID =?
         	and validflag = '0'
           AND SINGLE_CUT_NUN > 1       
         ORDER BY MAT_NO ASC)
 WHERE ROWNUM <= ?
			]]>
	</query>
	<query id="CoupCutService.QueryCanCutMaxMat" desc="查找撤销分切的队列">
		<![CDATA[
SELECT MAX(MAT_NO) MAT_NO
          FROM port_jg_batch_sample_result
         WHERE  WO_ID =?
         	and validflag = '0'
           AND SINGLE_CUT_NUN > 1  
           AND ROWNUM <= ?     
         ORDER BY MAT_NO ASC
			]]>
	</query>
		<query id="CoupCutService.QueryChildPortJg" desc="查找子管的队列">
		<![CDATA[
SELECT *
          FROM port_jg_batch_sample_result
         WHERE  WO_ID =?
           AND M_MAT_NO = ?
			]]>
	</query>
	<query id="CoupCutService.getCoupLingById" desc="查询工单信息">
		<![CDATA[
SELECT T.WO_ID,
       T.ZY_PLAN_ID,
       T.PLINE_CODE,
       T.JUDGE_STOVE_NO,
       T.BATCH_NO,
       T.GRADENAME,
       T.STEELNAME,
       T.OUTDIAMETER,
       T.WALLTHICK,
       (SELECT SUM(NVL(PRO_NUM, 0))
          FROM COUPLING_COM_INFO T1
         WHERE T1.ZY_PLAN_ID = T.ZY_PLAN_ID
           AND T1.WO_ID = T.WO_ID
           AND T1.STATION_CODE = '700301') S_PRO_NUM,
       (SELECT SUM(NVL(PRO_WT, 0))
          FROM COUPLING_COM_INFO T1
         WHERE T1.ZY_PLAN_ID = T.ZY_PLAN_ID
           AND T1.WO_ID = T.WO_ID
           AND T1.STATION_CODE = '700301') S_PRO_WT,
       (SELECT SUM(NVL(PRO_NUM, 0))
          FROM COUPLING_COM_INFO T1
         WHERE T1.ZY_PLAN_ID = T.ZY_PLAN_ID
           AND T1.WO_ID = T.WO_ID
           AND T1.STATION_CODE = '700302') Q_PRO_NUM,
       (SELECT SUM(NVL(PRO_NUM, 0))
          FROM COUPLING_COM_INFO T1
         WHERE T1.ZY_PLAN_ID = T.ZY_PLAN_ID
           AND T1.WO_ID = T.WO_ID
           AND T1.STATION_CODE = '700304') Y_PRO_NUM,
       (SELECT SUM(NVL(PRO_NUM, 0))
          FROM COUPLING_COM_INFO T1
         WHERE T1.ZY_PLAN_ID = T.ZY_PLAN_ID
           AND T1.WO_ID = T.WO_ID
           AND T1.STATION_CODE = '700303') J_PRO_NUM,
       (SELECT SUM(NVL(PRO_NUM, 0))
          FROM COUPLING_COM_INFO T1
         WHERE T1.ZY_PLAN_ID = T.ZY_PLAN_ID
           AND T1.WO_ID = T.WO_ID
           AND T1.STATION_CODE = '700305') C_PRO_NUM,
       (SELECT SUM(NVL(PRO_NUM, 0))
          FROM COUPLING_COM_INFO T1
         WHERE T1.ZY_PLAN_ID = T.ZY_PLAN_ID
           AND T1.WO_ID = T.WO_ID
           AND T1.STATION_CODE = '700306') L_PRO_NUM,
       (SELECT SUM(NVL(PRO_NUM, 0))
          FROM COUPLING_COM_INFO T1
         WHERE T1.ZY_PLAN_ID = T.ZY_PLAN_ID
           AND T1.WO_ID = T.WO_ID
           AND T1.STATION_CODE = '700307') T_PRO_NUM,
       (SELECT SUM(NVL(PRO_NUM, 0))
          FROM COUPLING_COM_INFO T1
         WHERE T1.ZY_PLAN_ID = T.ZY_PLAN_ID
           AND T1.WO_ID = T.WO_ID
           AND T1.STATION_CODE = '700308') P_PRO_NUM,
       (SELECT SUM(NVL(PRO_NUM, 0))
          FROM COUPLING_COM_INFO T1
         WHERE T1.ZY_PLAN_ID = T.ZY_PLAN_ID
           AND T1.WO_ID = T.WO_ID
           AND T1.STATION_CODE = '700311') B_PRO_NUM,
       (SELECT SUM(NVL(PRO_NUM, 0))
          FROM COUPLING_COM_INFO T1
         WHERE T1.ZY_PLAN_ID = T.ZY_PLAN_ID
           AND T1.WO_ID = T.WO_ID
           AND T1.STATION_CODE = '700313') K_PRO_NUM,
           (SELECT SUM(NVL(PRO_NUM, 0))
          FROM COUPLING_COM_INFO T1
         WHERE T1.ZY_PLAN_ID = T.ZY_PLAN_ID
           AND T1.WO_ID = T.WO_ID
           AND T1.STATION_CODE = '700310') D_PRO_NUM
  FROM COUPLING_COM_INFO T
 WHERE 1 = 1
   AND T.ZY_PLAN_ID = ?
   AND T.PLINE_CODE = ?
 GROUP BY T.WO_ID,
          T.ZY_PLAN_ID,
          T.PLINE_CODE,
          T.JUDGE_STOVE_NO,
          T.BATCH_NO,
          T.GRADENAME,
          T.STEELNAME,
          T.OUTDIAMETER,
          T.WALLTHICK
		]]>
	</query>
	
</queryMap>