<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="加工湿磁粉探伤实绩">
	<query id="FrmDetectResult.getQueryExpandResult" desc="查湿磁粉探伤实绩">
        <![CDATA[
    SELECT T.RESULT_NO,
       T.HEAT_PLAN_NO,
       T.ZY_BATCH_ID,
       T.PRO_PLAN_ID,
       T.GX_PLAN_NO,
       T.PLINE_CODE,
       T.PLINE_NAME,
       T.TET_NUM,
       T.CUT_NUM,
       T.DUBIOUS_NUM,
       T.FTESTING_NUM,
       T.FPASS_NUM,  
       T.PRO_NUM,
       T.PRO_WT,
       T.FAIL_NUM,
       T.FAIL_WT,
       T.OFFLINE_NUM,
       T.OFFLINE_WT,
       T.RE_NUM,
       T.RE_WT,
       T.MONITORDEMAND,
       T.SHIM_MAG_INDIC,
       T.SHIM_MAG_TYPE,
       T.MT_TYPE,
       T.MAG_SUSP_LIQ_CON,
       T.COIL_CUR_INT,
       T.CTR_STI_CUR_INT,
       T.DEMAG_VOL,
       T.MT_NOTE,
       T.UT_MAN,
       T.UT_MAN_GRADE,
       T.SIGN_MAN,
       T.SIGN_MAN_GRADE,
       T.TESTING_STANDARD1,
       T.TESTING_STANDARD2,
       T.TESTING_STANDARD3,
       T.TESTING_STANDARD4,
       T.TESTING_GRADE1,
       T.TESTING_GRADE2,
       T.TESTING_GRADE3,
       T.TESTING_GRADE4,
       DECODE(T.IF_MONITOR_RCL,'1','是','0','否') IF_MONITOR_RCL,
       T.PRODUCER,
       T.PRDCR_NO,
       TO_CHAR(T.PRODUCER_TIME, 'YYYY-MM-DD HH24:MI:SS') PRODUCER_TIME,
       TO_CHAR(T.RRO_TIME, 'YYYY-MM-DD HH24:MI:SS') RRO_TIME,
       T.PRO_SHIFT,
       T.PRO_GROUP,
       T.COL_MODE,
       TO_CHAR(T.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       T.CREATE_USER,
       TO_CHAR(T.UPDATE_TIME, 'YYYY-MM-DD HH24:MI:SS') UPDATE_TIME,
       T.UPDATE_NAME,
       T.OUTNUM_CUT,
       T.LENGTH_IN,
       T.LENGTHMIN_IN,
       T.LENGTHMAX_IN,
       DECODE(B.STATION_STATUS, '1', '生产中', '2', '生产完成') STATION_STATUS
  FROM MCH_MT_RESULT T INNER JOIN MCH_COM_INFO B ON T.RESULT_NO=B.RESULT_NO
 WHERE T.HEAT_PLAN_NO = ?
        ]]>
	</query>
	<query id="FrmDetectResult.getQueryExpandResultStuts" desc="查询相同炉计划ID下湿磁粉探伤实绩状态">
        <![CDATA[
    SELECT B.STATION_STATUS
  FROM MCH_MT_RESULT T INNER JOIN MCH_COM_INFO B ON T.RESULT_NO=B.RESULT_NO
 WHERE T.HEAT_PLAN_NO = ? AND T.PLINE_CODE = ?
        ]]>
	</query>
	<query id="FrmDetectResult.getQueryExpandResult1" desc="查询探伤实绩合格支数的和">
        <![CDATA[
   SELECT NVL(SUM(T.PRO_NUM), 0) PRO_NUM FROM MCH_MT_RESULT T
   WHERE T.HEAT_PLAN_NO = ?
        ]]>
	</query>
		<query id="FrmDetectResult.detelefailnum" desc="删除废品缺陷">
		<![CDATA[
DELETE MCH_BUG_D WHERE RESULT_NO = ? and HEAT_PLAN_NO = ? and PLINE_CODE = ?	
		]]>
	</query>
			<query id="FrmDetectResult.querymaxsqe" desc="查询最大的离线序号">
	 <![CDATA[ 
SELECT ? ||
       LPAD(SUBSTR(NVL(MAX(T.RESULT_SQE), '00'), -2, 2) + 1, 2, '0') AS RESULT_SQE
  FROM MCH_OFFLINE_RESULT_D T
 WHERE  T.HEAT_PLAN_NO = ? and t.PLINE_CODE =?
	  ]]>
	</query>
		<query id="FrmDetectResult.queryGxPosition" desc="查询产线下工序的位置">
		<![CDATA[
SELECT LENGTH(SUBSTR(T.STATION_NAMES, 0, INSTR(STATION_NAMES, '探伤 '))) -
       LENGTH(REPLACE(SUBSTR(T.STATION_NAMES,0,INSTR(STATION_NAMES, '探伤')), ';', '')) + 1  CNUM
  FROM MCH_COM_SETPLINE T
 WHERE T.PLINE_CODE = ?
			]]>
	</query>
		<query id="FrmDetectResult.getquerynum" desc="查询实绩里不同分切数的加工支数">
        <![CDATA[
   SELECT NVL(SUM(T.TET_NUM), 0) TET_NUM,NVL(SUM(T.FAIL_NUM), 0) FAIL_NUM FROM MCH_MT_RESULT T
   WHERE T.HEAT_PLAN_NO = ? and t.OUTNUM_CUT = ?
        ]]>
	</query>
	
	<query id="FrmDetectResult.AddExpandResult" desc="新增湿磁粉探伤实绩">
		<![CDATA[
			INSERT INTO MCH_MT_RESULT (RESULT_NO, HEAT_PLAN_NO, ZY_BATCH_ID, 
PRO_PLAN_ID, GX_PLAN_NO, PLINE_CODE, PLINE_NAME,TET_NUM,CUT_NUM,DUBIOUS_NUM,FTESTING_NUM,FPASS_NUM,  
 PRO_NUM, PRO_WT, FAIL_NUM, FAIL_WT,FAIL_BILL, 
 OFFLINE_NUM, OFFLINE_WT, RE_NUM, RE_WT, MONITORDEMAND, 
IF_MONITOR_RCL, PRODUCER, PRDCR_NO, PRODUCER_TIME, RRO_TIME, PRO_SHIFT, 
PRO_GROUP, COL_MODE, CREATE_TIME,TESTING_STANDARD1,TESTING_STANDARD2,
TESTING_STANDARD3,TESTING_STANDARD4,TESTING_GRADE1,TESTING_GRADE2,
TESTING_GRADE3,TESTING_GRADE4,SHIM_MAG_INDIC,SHIM_MAG_TYPE,MT_TYPE,MAG_SUSP_LIQ_CON,
COIL_CUR_INT,CTR_STI_CUR_INT,DEMAG_VOL,MT_NOTE,UT_MAN,UT_MAN_GRADE,SIGN_MAN,SIGN_MAN_GRADE,CREATE_USER,
OUTNUM_CUT,LENGTH_IN,LENGTHMAX_IN,LENGTHMIN_IN) 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="FrmDetectResult.AddComInfoResult1" desc="修改材料状态和工序编码">
		<![CDATA[
UPDATE PORT_MCH_BATCH_SAMPLE_RESULT T SET T.MAT_STATUS=?,T.OP_PROCESS=?
WHERE T.HEAT_PLAN_NO=? AND T.MAT_NO=?
			]]>
	</query>
	<query id="FrmDetectResult.UpdatePath" desc="修改队列表工艺路径">
		<![CDATA[
UPDATE PORT_MCH_BATCH_SAMPLE_RESULT T
   SET T.PRC_TECHNOLOGY_PATH = SUBSTR(T.PRC_TECHNOLOGY_PATH, 1,?) || ? ||
                               SUBSTR(T.PRC_TECHNOLOGY_PATH,?, LENGTH(T.PRC_TECHNOLOGY_PATH))
 WHERE T.HEAT_PLAN_NO = ?
 AND MAT_STATUS='00' AND ROWNUM<=?
			]]>
	</query>
	<query id="FrmDetectResult.qureyGxComInfo" desc="查询工序是否是结炉状态">
		<![CDATA[
SELECT DISTINCT STATION_STATUS
  FROM MCH_COM_INFO
 WHERE HEAT_PLAN_NO = ?
   AND PLINE_CODE = ?
   AND STATION_CODE = ?
			]]>
	</query>
	<query id="FrmDetectResult.UpdatePln1" desc="撤销修改计划表状态">
		<![CDATA[
 UPDATE PLN_ZY_JGX_M
    SET  PER_STATUS = ?
  WHERE HEAT_PLAN_NO = ?
			]]>
	</query>
	<query id="FrmDetectResult.queryExpandMaxRESULT" desc="查询最大实绩编号">
		<![CDATA[
SELECT ? ||
       LPAD(SUBSTR(NVL(MAX(T.RESULT_NO), '000000'), -6, 6) + 1, 6, '0') AS RESULT_NO
  FROM MCH_LOADING_RESULT T
 WHERE TO_CHAR(T.CREATE_TIME, 'YYYY-MM-DD') = ?
   AND T.PLINE_CODE = ?
		]]>
	</query>
	<query id="FrmDetectResult.queryExpandNUM" desc="查询管号队列里合格的材料号">
		<![CDATA[
	SELECT T1.MAT_NO
  FROM (SELECT T.MAT_NO
          FROM PORT_MCH_BATCH_SAMPLE_RESULT T
         WHERE T.MAT_STATUS = '00'
           AND T.IS_SAMPLE_PIPE='0'
           AND T.HEAT_PLAN_NO = ?
         ORDER BY T.MAT_NO ASC) T1
 WHERE ROWNUM<?
			]]>
	</query>
	<query id="FrmDetectResult.deleteComInfoResult" desc="删除公共信息">
		<![CDATA[
		DELETE MCH_COM_INFO WHERE RESULT_NO = ?		
		]]>
	</query>
	<query id="FrmDetectResult.deleteVrpExpandResult" desc="删除湿磁粉探伤实绩">
		<![CDATA[
		DELETE MCH_MT_RESULT WHERE RESULT_NO = ?		
		]]>
	</query>

	<query id="FrmDetectResult.UpdatePln" desc="新增修改计划表状态">
		<![CDATA[
 UPDATE PLN_ZY_JGX_M
    SET  PER_STATUS = '10'
  WHERE HEAT_PLAN_NO = ?
			]]>
	</query>
	<query id="FrmDetectResult.queryExpandFailNUM1" desc="查询工序废品数量">
		<![CDATA[
		SELECT NVL(SUM(T.FAIL_NUM),0) FAIL_NUM FROM MCH_MT_RESULT T
WHERE  T.HEAT_PLAN_NO=? 
			]]>
	</query>
	<query id="FrmDetectResult.queryExpandNUM2" desc="查询废品材料信息">
		<![CDATA[
	SELECT T1.MAT_NO
  FROM (SELECT T.MAT_NO
          FROM PORT_MCH_BATCH_SAMPLE_RESULT T
         WHERE T.MAT_STATUS = '10'
           AND T.HEAT_PLAN_NO = ?
             AND T.OP_PROCESS=?
         ORDER BY T.MAT_NO ASC) T1
 WHERE ROWNUM<?
			]]>
	</query>
	<query id="FrmDetectResult.updateVrpExpandResult" desc="修改湿磁粉探伤实绩">
		<![CDATA[		
	UPDATE MCH_MT_RESULT
   SET TET_NUM       = ?,
   	   CUT_NUM		=?,
   	   DUBIOUS_NUM   =?,
   	   FTESTING_NUM   =?,
   	   FPASS_NUM     =?,
   	   PRO_NUM        = ?,
       PRO_WT         = ?,
       FAIL_NUM       = ?,
       FAIL_WT        = ?,
       FAIL_BILL    = ?,
       PRODUCER       = ?,
       PRODUCER_TIME  = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'),
       RRO_TIME      = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'),
       PRO_SHIFT     = ?,
       PRO_GROUP     = ?,
       TESTING_STANDARD1 =?,
       TESTING_STANDARD2 =?,
       TESTING_STANDARD3 =?,
       TESTING_STANDARD4 =?,
       TESTING_GRADE1 =?,
       TESTING_GRADE2 =?,
       TESTING_GRADE3 =?,
       TESTING_GRADE4 =?,
       SHIM_MAG_INDIC =?,
       SHIM_MAG_TYPE =?,
       MT_TYPE =?,
       MAG_SUSP_LIQ_CON = ?,
       COIL_CUR_INT =?,
       CTR_STI_CUR_INT =?,
       DEMAG_VOL =?,
       MT_NOTE =?,
       UT_MAN =?,
       UT_MAN_GRADE =?,
       SIGN_MAN =?,
       SIGN_MAN_GRADE =?,
       UPDATE_TIME    = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'),
       UPDATE_NAME    = ?
 WHERE RESULT_NO = ?  
			]]>
	</query>
	<query id="FrmDetectResult.queryExpandFailNUM" desc="查询管号队列废品数量">
		<![CDATA[
		SELECT NVL(SUM(T.ACT_COUNT),0) ACT_COUNT
  FROM PORT_MCH_BATCH_SAMPLE_RESULT T
 WHERE T.MAT_STATUS = '10'
   AND T.HEAT_PLAN_NO = ?
   AND T.OP_PROCESS = ?
		
			]]>
	</query>
	<query id="FrmDetectResult.updateComInfoResult" desc="修改公共信息">
		<![CDATA[
UPDATE MCH_COM_INFO
   SET PRODUCER      = ?,
       PRODUCER_TIME = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'),
       PRO_NUM       = ?,
       PRO_WT        = ?,
       FAIL_NUM      = ?,
       FAIL_WT       = ?,
       RRO_TIME      = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'),
       PRO_SHIFT     = ?,
       PRO_GROUP     = ?
 WHERE RESULT_NO = ?
		]]>
	</query>
	<query id="FrmDetectResult.qureyGxLxCount" desc="查询是否离线">
		<![CDATA[
		SELECT COUNT(1) COUNT
  FROM PORT_MCH_BATCH_SAMPLE_RESULT T
 WHERE T.HEAT_PLAN_NO =?
   AND T.PLINE_CODE =?
   AND T.OP_PROCESS = ?
    AND T.MAT_STATUS='20'
   AND T.LEVE_LOG<>'00'
			]]>
	</query>
</queryMap>