<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="管加工操作人员维护">
	<query id="FrmMchPerson.doQuery" desc="维护人员实绩查询">
	 <![CDATA[ 
SELECT T.* FROM MCH_PERSON T WHERE 1 = 1
	  ]]>
	</query>
	
		<query id="FrmMchBugD.doQueryAlarmNum" desc="查询可疑支数">
	 <![CDATA[ 
SELECT T.*
  FROM MCH_BUG_D T
 WHERE 1=1
   AND T.FAIL_TYPE_CODE ='1'
	  ]]>
	</query>
		<query id="FrmMchBugD.deleteFail" desc="删除可疑支数">
	 <![CDATA[ 
DELETE FROM MCH_BUG_D T WHERE T.RESULT_NO =? AND T.FAIL_BILL = ?  AND T.FAIL_BILL_SQE=?
	  ]]>
	</query>
		<query id="FrmMchBugD.deleteFailD" desc="删除废品支数">
	 <![CDATA[ 
DELETE FROM MCH_BUG_D T WHERE T.RESULT_NO =? AND T.FAIL_BILL = ?  AND T.FAIL_BILL_SQE=?
	  ]]>
	</query>
		<query id="FrmMchBugD.updateFail" desc="修改可疑支数">
	 <![CDATA[ 
UPDATE MCH_BUG_D T
   SET T.FAIL_TYPE_NAME = ?, T.FAIL_DIRECT = ?, T.FAIL_NUM = ?
 WHERE T.RESULT_NO = ?
   AND T.FAIL_BILL = ?
   AND T.FAIL_BILL_SQE = ? AND T.FAIL_SORT='00'
	  ]]>
	</query>
		<query id="FrmMchBugD.updateFailD" desc="修改废品支数">
	 <![CDATA[ 
UPDATE MCH_BUG_D T
   SET T.FAIL_TYPE_NAME = ?, T.FAIL_DIRECT = ?, T.FAIL_NUM = ?
 WHERE T.RESULT_NO = ?
   AND T.FAIL_BILL = ?
   AND T.FAIL_BILL_SQE = ? AND T.FAIL_SORT='10'
	  ]]>
	</query>
		<query id="FrmMchBugD.queryGX" desc="查询工序">
	 <![CDATA[ 
SELECT SUBSTR(T.RESULT_NO,5,6) RESULT_NO FROM MCH_BUG_D T WHERE T.HEAT_PLAN_NO=? and t.pline_code= ? GROUP BY RESULT_NO
	  ]]>
	</query>
	
	
		<query id="FrmMchBugD.doQueryScrapNum" desc="查询废品支数">
	 <![CDATA[ 
SELECT T.*
  FROM MCH_BUG_D T
 WHERE 1=1
   AND T.FAIL_TYPE_CODE ='2'
	  ]]>
	</query>
	
	
	<query id="FrmMchBugD.queryExpandMaxRESULT1" 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 T.PLINE_CODE = ?
	  ]]>
	</query>
		<query id="FrmMchBugD.queryExpandMaxRESULT2" desc="查询最大实绩编号">
	 <![CDATA[ 
SELECT ? ||
       LPAD(SUBSTR(NVL(MAX(T.RESULT_NO), '000000'), -6, 6) + 1, 6, '0') AS RESULT_NO
  FROM MCH_UT_RESULT T
 WHERE T.PLINE_CODE = ?
	  ]]>
	</query>
	
		<query id="FrmMchBugD.Updatebugd" desc="修改缺陷表实绩编号">
	 <![CDATA[ 
UPDATE MCH_BUG_D T SET T.RESULT_NO=?
WHERE T.HEAT_PLAN_NO=? AND T.PLINE_CODE=? and SUBSTR(T.RESULT_NO,5,6) =?
	  ]]>
	</query>
	
	
		<query id="FrmMchBugD.queryExpandMaxRESULT3" desc="查询最大实绩编号">
	 <![CDATA[ 
SELECT ? ||
       LPAD(SUBSTR(NVL(MAX(T.RESULT_NO), '000000'), -6, 6) + 1, 6, '0') AS RESULT_NO
  FROM MCH_CUT_RESULT T  
 WHERE T.PLINE_CODE = ?
	  ]]>
	</query>
		<query id="FrmMchBugD.queryExpandMaxRESULT4" desc="查询最大实绩编号">
	 <![CDATA[ 
SELECT ? ||
       LPAD(SUBSTR(NVL(MAX(T.RESULT_NO), '000000'), -6, 6) + 1, 6, '0') AS RESULT_NO
  FROM MCH_THREADER_RESULT T
 WHERE T.PLINE_CODE = ?
	  ]]>
	</query>
		<query id="FrmMchBugD.queryExpandMaxRESULT5" desc="查询最大实绩编号">
	 <![CDATA[ 
SELECT ? ||
       LPAD(SUBSTR(NVL(MAX(T.RESULT_NO), '000000'), -6, 6) + 1, 6, '0') AS RESULT_NO
  FROM MCH_HREAD_RESULT T
 WHERE T.PLINE_CODE = ?
	  ]]>
	</query>
		<query id="FrmMchBugD.queryExpandMaxRESULT6" desc="查询最大实绩编号">
	 <![CDATA[ 
SELECT ? ||
       LPAD(SUBSTR(NVL(MAX(T.RESULT_NO), '000000'), -6, 6) + 1, 6, '0') AS RESULT_NO
  FROM mch_twistingly_result T
 WHERE T.PLINE_CODE = ?
	  ]]>
	</query>
		<query id="FrmMchBugD.queryExpandMaxRESULT7" desc="查询最大实绩编号">
	 <![CDATA[ 
SELECT ? ||
       LPAD(SUBSTR(NVL(MAX(T.RESULT_NO), '000000'), -6, 6) + 1, 6, '0') AS RESULT_NO
  FROM mch_path_result T
 WHERE T.PLINE_CODE = ?
	  ]]>
	</query>
		<query id="FrmMchBugD.queryExpandMaxRESULT8" desc="查询最大实绩编号">
	 <![CDATA[ 
SELECT ? ||
       LPAD(SUBSTR(NVL(MAX(T.RESULT_NO), '000000'), -6, 6) + 1, 6, '0') AS RESULT_NO
  FROM mch_watergage_result T
 WHERE T.PLINE_CODE = ?
	  ]]>
	</query>
		<query id="FrmMchBugD.queryExpandMaxRESULT9" desc="查询最大实绩编号">
	 <![CDATA[ 
SELECT ? ||
       LPAD(SUBSTR(NVL(MAX(T.RESULT_NO), '000000'), -6, 6) + 1, 6, '0') AS RESULT_NO
  FROM mch_chamfering_result T
 WHERE T.PLINE_CODE = ?
	  ]]>
	</query>
		<query id="FrmMchBugD.queryExpandMaxRESULT10" desc="查询最大实绩编号">
	 <![CDATA[ 
SELECT ? ||
       LPAD(SUBSTR(NVL(MAX(T.RESULT_NO), '000000'), -6, 6) + 1, 6, '0') AS RESULT_NO
  FROM mch_measure_result T
 WHERE T.PLINE_CODE = ?
	  ]]>
	</query>
	
	
	<query id="FrmMchBugD.queryMaxfailBill" desc="生成废品缺陷编号">
	 <![CDATA[ 
   SELECT ? ||
       LPAD(SUBSTR(NVL(MAX(T.FAIL_BILL), '000'), -3, 3) + 1, 3, '0') AS FAIL_BILL
  FROM MCH_BUG_D T
 WHERE T.HEAT_PLAN_NO = ? and t.FAIL_SORT = ?
	  ]]>
	</query>

	<query id="FrmMchBugD.queryJumpDRESULT" desc="查询从表最大实绩编号">
		<![CDATA[
SELECT  LPAD(SUBSTR(NVL(MAX(T.FAIL_BILL_SQE), '00000000'), -8, 8) + 1, 8, '0') AS FAIL_BILL_SQE
  FROM MCH_BUG_D T
 WHERE T.HEAT_PLAN_NO = ?
		]]>
	</query>


			<query id="FrmMchBugD.QueryFailData" desc="查询废品详细信息">
	 <![CDATA[ 
SELECT T.FAIL_TYPE_NAME,
       T.FAIL_NUM,
       T.FAIL_DIRECT,
       T.FAIL_BILL,
       T.FAIL_BILL_SQE,
       T.RESULT_NO,
       T.HEAT_PLAN_NO,
       T.PLINE_CODE
  FROM MCH_BUG_D T, MCH_COM_INFO T1
 WHERE T.RESULT_NO = T1.RESULT_NO
 AND T.FAIL_SORT = '10'
	  ]]>
	</query>
			<query id="FrmMchBugD.QueryKeyiFailData" desc="查询可疑详细信息">
	 <![CDATA[ 
SELECT T.FAIL_TYPE_NAME,
       T.FAIL_NUM,
       T.FAIL_DIRECT,
       T.FAIL_BILL,
       T.FAIL_BILL_SQE,
       T.RESULT_NO,
       T.HEAT_PLAN_NO,
       T.PLINE_CODE
  FROM MCH_BUG_D T, MCH_COM_INFO T1
 WHERE T.RESULT_NO = T1.RESULT_NO
 AND T.FAIL_SORT = '00'
	  ]]>
	</query>
		<query id="FrmMchBugD.updatePerson" desc="修改人员">
	 <![CDATA[ 
 UPDATE MCH_PERSON T
   SET T.MAN_NAME = ?,T.PLINE_CODE = ?,T.PRO_BZ = ?
 WHERE T.MAN_NAME = ?
	  ]]>
	</query>



	<query id="FrmMchBugD.AddExpandDResult" desc="新增可疑从表实绩">
		<![CDATA[
	INSERT INTO MCH_BUG_D
    (FAIL_BILL,
   FAIL_BILL_SQE,
   RESULT_NO,
   HEAT_PLAN_NO,
   FAIL_SORT,
   FAIL_TYPE_CODE,
   FAIL_TYPE_NAME,
   FAIL_NUM,
   FAIL_WT,
   PLINE_CODE,
   BATCH_NO)
VALUES
  (?, ?, ?, ?, '00', ?, ?, ?, ?, ?, ?)
		]]>
	</query>

	<query id="FrmMchBugD.AddExpandDResult1" desc="新增废品从表实绩">
		<![CDATA[
	INSERT INTO MCH_BUG_D
  (FAIL_BILL,
   FAIL_BILL_SQE,
   RESULT_NO,
   HEAT_PLAN_NO,
   FAIL_SORT,
   FAIL_TYPE_CODE,
   FAIL_TYPE_NAME,
   FAIL_NUM,
   FAIL_WT,
   PLINE_CODE,
   BATCH_NO)
VALUES
  (?, ?, ?, ?, '10', ?, ?, ?, ?, ?, ?)


		]]>
	</query>


	<query id="FrmMchBugD.AddExpandDResult3" desc="新增废品从表实绩">
		<![CDATA[
INSERT INTO MCH_BUG_D
  (FAIL_BILL,
   FAIL_BILL_SQE,
   RESULT_NO,
   HEAT_PLAN_NO,
   FAIL_SORT,
   FAIL_TYPE_CODE,
   FAIL_TYPE_NAME,
   FAIL_NUM,
   FAIL_WT,
   PLINE_CODE,
   BATCH_NO)
VALUES
  (?, ?, ?, ?, '20', ?, ?, ?, ?, ?, ?)


		]]>
	</query>

	<query id="FrmMchBugD.AddWasteMatNo" desc="">
		<![CDATA[
	INSERT INTO MCH_WASTE_MAT_NO
  (FAIL_BILL,
   FAIL_BILL_SQE,
   MAT_NO)
VALUES
  (?, ?, ?)

		]]>
	</query>



	<query id="FrmMchBugD.queryMaxfailBillNew" desc="生成废品缺陷编号">
		<![CDATA[
  SELECT ? || LPAD(NVL(MAX(TO_NUMBER(SUBSTR(FAIL_BILL,
                                            LENGTH(FAIL_BILL) - 2))),
                       0) + 1,
                   3,
                   '0') FAIL_BILL
    FROM MCH_BUG_D
   WHERE FAIL_BILL LIKE ? || '___'
	  ]]>
	</query>

	<query id="FrmMchBugD.queryJumpDRESULTNEW" desc="查询从表最大实绩编号">
		<![CDATA[
SELECT  LPAD(SUBSTR(NVL(MAX(T.FAIL_BILL_SQE), '00000000'), -8, 8) + 1, 8, '0') AS FAIL_BILL_SQE
  FROM MCH_BUG_D T
 WHERE T.FAIL_BILL = ?
		]]>
	</query>


	<query id="FrmMchBugD.queryPortMchWithKey" desc="查询管号队列里合格的材料号">
		<![CDATA[
              SELECT * FROM PORT_MCH_BATCH_SAMPLE_RESULT  T
               WHERE  T.HEAT_PLAN_NO = ?
              AND T.MAT_NO = ?
			]]>
	</query>

	<query id="FrmMchBugD.updateMatStatus" desc="更新材料表状态">
		<![CDATA[
             Update MAT_BC_M SET QCM_STAUS = ? WHERE MAT_NO = ?
			]]>
	</query>

	<query id="FrmMchBugD.updateMatStatus2" desc="更新材料表状态">
		<![CDATA[
            UPDATE MAT_BC_M
   SET QCM_STAUS = ?
 WHERE MAT_NO IN (SELECT MAT_NO
                    FROM MCH_WASTE_MAT_NO
                   WHERE (FAIL_BILL, FAIL_BILL_SQE) IN
                         (SELECT FAIL_BILL, FAIL_BILL_SQE
                            FROM MCH_BUG_D
                           WHERE RESULT_NO = ?
                             AND FAIL_SORT = '20'))
			]]>
	</query>
	<query id="FrmMchBugD.UpdatePortHttDbk" desc="更改管号队列状态">
		<![CDATA[
UPDATE PORT_VRP_BATCH_SAMPLE_RESULT T SET T.MAT_STATUS=?,T.OP_PROCESS=?, RESULT_NO=?, IS_FAIL_CHECK ='0'
WHERE T.HEAT_PLAN_NO=? AND T.MAT_NO=?
			]]>
	</query>
	<query id="FrmMchBugD.UpdatePortHtt" desc="更改管号队列状态">
		<![CDATA[
UPDATE PORT_MCH_BATCH_SAMPLE_RESULT T SET T.MAT_STATUS=?,T.OP_PROCESS=?, RESULT_NO=?, IS_FAIL_CHECK ='0'
WHERE T.HEAT_PLAN_NO=? AND T.MAT_NO=?
			]]>
	</query>
	
	<query id="FrmMchBugD.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="FrmMchBugD.UpdateMesureDataDbk" desc="">
		<![CDATA[
UPDATE RTD_MEASURE_POSDATA T
   SET T.FLAG = ?
 WHERE (T.JUDGE_STOVE_NO, T.BATCH_NO, MAT_NO, PLINE_CODE) IN
       (SELECT JUDGE_STOVE_NO, PHY_BATCH_NO, MEASURING_SEQ, PLINE_CODE
          FROM PORT_VRP_BATCH_SAMPLE_RESULT
         WHERE HEAT_PLAN_NO = ?
           AND MAT_NO = ?)
			]]>
	</query>
	<query id="FrmMchBugD.UpdateMesureData" desc="">
		<![CDATA[
UPDATE RTD_MEASURE_POSDATA T
   SET T.FLAG = ?
 WHERE (T.JUDGE_STOVE_NO, T.BATCH_NO, MAT_NO, PLINE_CODE) IN
       (SELECT JUDGE_STOVE_NO, PHY_BATCH_NO, MEASURING_SEQ, PLINE_CODE
          FROM PORT_MCH_BATCH_SAMPLE_RESULT
         WHERE HEAT_PLAN_NO = ?
           AND MAT_NO = ?)
			]]>
	</query>

	<query id="FrmMchBugD.UpdateMesureData1" desc="">
		<![CDATA[
UPDATE RTD_MEASURE_POSDATA T
   SET T.FLAG = ?
 WHERE  KEY_ID = ?
			]]>
	</query>

	<query id="FrmMchBugD.QueryFailPortHttDbk" 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=?
             AND (T.RESULT_NO=? OR T.RESULT_NO IS NULL)
         ORDER BY  T.RESULT_NO,T.MAT_NO DESC) T1
 WHERE ROWNUM<?
			]]>
	</query>
	<query id="FrmMchBugD.QueryFailPortHtt" 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=?
             AND (T.RESULT_NO=? OR T.RESULT_NO IS NULL)
         ORDER BY  T.RESULT_NO,T.MAT_NO DESC) T1
 WHERE ROWNUM<?
			]]>
	</query>
	
		<query id="FrmMchBugD.QueryFailPortJg" desc="查询废品材料信息">
		<![CDATA[
	SELECT T1.MAT_NO
  FROM (SELECT T.MAT_NO
          FROM port_jg_batch_sample_result T
         WHERE T.MAT_STATUS = '10'
           AND T.WO_ID = ?
             AND T.OP_PROCESS=?
             AND (T.RESULT_NO=? OR T.RESULT_NO IS NULL)
         ORDER BY  T.RESULT_NO,T.MAT_NO DESC) T1
 WHERE ROWNUM<?
			]]>
	</query>

	<query id="FrmMchBugD.detelefailnum" desc="删除废品缺陷">
		<![CDATA[
DELETE MCH_BUG_D WHERE RESULT_NO = ?
		]]>
	</query>

	<query id="FrmMchBugD.detelefailnum2" desc="删除废品缺陷">
		<![CDATA[
DELETE MCH_WASTE_MAT_NO WHERE (FAIL_BILL,FAIL_BILL_SQE) IN (SELECT FAIL_BILL,FAIL_BILL_SQE FROM MCH_BUG_D WHERE RESULT_NO = ? )
		]]>
	</query>
	
</queryMap>