<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="镦拔扩测量实绩">

	<query id="FrmVrpMeasuring.AddVrpMeasuring" desc="新增测量实绩">
        <![CDATA[
INSERT INTO VRP_MEASURING_RESULT
  (RESULT_NO,
   HEAT_PLAN_NO,
   ZY_BATCH_ID,
   PRO_PLAN_ID,
   GX_PLAN_NO,
   PLINE_CODE,
   PLINE_NAME,
   PRO_NUM,
   PRO_WT,
   FAIL_NUM,
   FAIL_WT,
   OFFLINE_NUM,
   OFFLINE_WT,
   RE_NUM,
   RE_WT,   
   MONITORDEMAND,
   IF_MONITOR_DBK,
   PRODUCER,
   PRDCR_NO,
   PRODUCER_TIME,
   LOAD_TIME,
   LOAD_SHIFT,
   LOAD_GROUP,
   LOAD_USER,
   COL_MODE,
   CREATE_TIME,
   ACC_NUM,
   ACC_WT,
   FAIL_REASON)
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="FrmVrpMeasuring.GetQueryMeasuring" 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.PRO_NUM,
       T.PRO_WT,
       T.ACC_NUM,
       T.ACC_WT,
       T.FAIL_NUM,
       T.FAIL_WT,
       T.FAIL_REASON,
       T.OFFLINE_NUM,
       T.OFFLINE_WT,
       T.RE_NUM,
       T.RE_WT,
       T.MONITORDEMAND,
       DECODE(T.IF_MONITOR_DBK,'0','否','1','是') IF_MONITOR_DBK,
       T.PRODUCER,
       T.PRDCR_NO,
       TO_CHAR(T.PRODUCER_TIME, 'YYYY-MM-DD HH24:MI:SS') PRODUCER_TIME,
       TO_CHAR(T.LOAD_TIME, 'YYYY-MM-DD HH24:MI:SS') LOAD_TIME,
       T.LOAD_SHIFT,
       T.LOAD_GROUP,
       T.LOAD_USER,
       T.COL_MODE,
       TO_CHAR(T.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       TO_CHAR(T.UPDATE_TIME, 'YYYY-MM-DD HH24:MI:SS') UPDATE_TIME,
       T.UPDATE_NAME,
       DECODE(B.STATION_STATUS, '1', '生产中', '2', '生产完成') STATION_STATUS
  FROM VRP_MEASURING_RESULT T INNER JOIN VRP_COM_INFO B ON T.RESULT_NO=B.RESULT_NO
	WHERE T.HEAT_PLAN_NO = ?
        ]]>
	</query>
	<query id="FrmVrpMeasuring.GetQueryMeasuring1" desc="根据计划号查询镦拔扩测量实绩合格支数的和">
        <![CDATA[
SELECT NVL(SUM(T.ACC_NUM), 0) ACC_NUM FROM VRP_MEASURING_RESULT T
   WHERE T.HEAT_PLAN_NO = ?
        ]]>
	</query>
	<query id="FrmVrpMeasuring.ReturnVrpMeasuringResult" desc="撤销测量实绩">
		<![CDATA[
		DELETE VRP_MEASURING_RESULT WHERE RESULT_NO = ?
		]]>
	</query>

	<query id="FrmVrpMeasuring.UpdatePath" desc="修改队列表工艺路径">
		<![CDATA[
		UPDATE PORT_VRP_BATCH_SAMPLE_RESULT T
   SET T.PRC_TECHNOLOGY_PATH = SUBSTR(T.PRC_TECHNOLOGY_PATH, 1,2) || ? ||
                               SUBSTR(T.PRC_TECHNOLOGY_PATH,4, LENGTH(T.PRC_TECHNOLOGY_PATH))
 WHERE T.HEAT_PLAN_NO = ? AND T.MAT_STATUS = '00'
		]]>
	</query>

	<query id="FrmVrpMeasuring.updateVrpMeasuringResult" desc="修改测量实绩">
		<![CDATA[
UPDATE VRP_MEASURING_RESULT
   SET PRO_NUM     = ?,
       PRO_WT      = ?,
       LOAD_SHIFT  = ?,
       LOAD_GROUP  = ?,
       ACC_NUM     = ?,
       ACC_WT      = ?,
       LOAD_USER   = ?,
       FAIL_NUM    = ?,
       FAIL_WT     = ?,
       FAIL_REASON = ?,
       UPDATE_TIME=TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'),
       PRODUCER    = ?,
       PRODUCER_TIME = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS')    
 WHERE RESULT_NO = ?
		]]>
	</query>
	<query id="FrmVrpMeasuring.queryMeasuringKEY" desc="查询最大实绩编号">
        <![CDATA[
	SELECT ? ||
	LPAD(SUBSTR(NVL(MAX(T.RESULT_NO),'000000'),-6,6) + 1, 6, '0') AS RESULT_NO
	FROM VRP_MEASURING_RESULT T
	WHERE TO_CHAR(T.CREATE_TIME,'YYYY-MM-DD') = ?
	AND T.PLINE_CODE= ?
        ]]>
	</query>

	<query id="FrmVrpMeasuring.queryCountMeasuring" desc="查询计划下剩余上料支、吨">
		<![CDATA[
SELECT COUNT(*) COUNT,NVL(SUM(T.PRO_NUM),0) PRO_NUM,NVL(SUM(T.PRO_WT),0) PRO_WT  FROM VRP_MEASURING_RESULT T  WHERE HEAT_PLAN_NO=?
		]]>
	</query>

	<query id="FrmVrpMeasuring.AddComInfoResult1" desc="修改材料状态和工序编码">
		<![CDATA[
UPDATE PORT_VRP_BATCH_SAMPLE_RESULT T SET T.MAT_STATUS=?,T.OP_PROCESS=?
WHERE T.HEAT_PLAN_NO=? AND T.MAT_NO=?
			]]>
	</query>

	<query id="FrmVrpMeasuring.queryExpandNUM" desc="查询管号队列表里合格的材料号">
		<![CDATA[
	SELECT T1.MAT_NO
  FROM (SELECT T.MAT_NO
          FROM PORT_VRP_BATCH_SAMPLE_RESULT T
         WHERE T.MAT_STATUS = '00'
         AND T.IS_SAMPLE_PIPE != '1'
           AND T.HEAT_PLAN_NO = ?
           AND T.INSTORE_FLAG = '0'
         ORDER BY T.MAT_NO ASC) T1
 WHERE ROWNUM<?
			]]>
	</query>

	<query id="FrmVrpMeasuring.queryExpandFailNUM" desc="查询管号队列废品数量">
		<![CDATA[
		SELECT NVL(SUM(T.ACT_COUNT),0) ACT_COUNT
  FROM PORT_VRP_BATCH_SAMPLE_RESULT T
 WHERE T.MAT_STATUS = '10'
   AND T.HEAT_PLAN_NO = ?
   AND T.OP_PROCESS = ?	
			]]>
	</query>

	<query id="FrmVrpMeasuring.queryExpandFailNUM1" desc="查询工序废品数量">
		<![CDATA[
		SELECT NVL(SUM(T.FAIL_NUM),0) FAIL_NUM FROM VRP_MEASURING_RESULT T
WHERE  T.HEAT_PLAN_NO=? 
			]]>
	</query>

	<query id="FrmVrpMeasuring.queryExpandNUM2" desc="查询废品材料信息">
		<![CDATA[
	SELECT T1.MAT_NO
  FROM (SELECT T.MAT_NO
          FROM PORT_VRP_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="FrmVrpMeasuring.UPDATEDbkPlan" desc="修改计划表工序点开始状态">
		<![CDATA[
		UPDATE PLN_ZY_DBK_M SET PER_STATUS = ? WHERE HEAT_PLAN_NO = ?
			]]>
	</query>
	<query id="FrmVrpMeasuring.UPDATEDbkBesideStatrs" desc="修改计划表工序点结炉状态">
		<![CDATA[
		UPDATE PLN_ZY_DBK_M SET BESIDE_STATUS = ? WHERE HEAT_PLAN_NO = ?
			]]>
	</query>
	<query id="FrmVrpMeasuring.qureyGxLxCount" desc="查询是否离线">
		<![CDATA[
		SELECT COUNT(1) COUNT
  FROM PORT_VRP_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>