<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="热处理废品">
	
		<query id="FrmHttBugD.doQueryAlarmNum" desc="查询可疑支数">
	 <![CDATA[ 
SELECT T.*, (SELECT  WM_CONCAT(MAT_NO) FROM HTT_WASTE_MAT_NO WHERE DEF_SERIAL_ITEM = T.DEF_SERIAL_ITEM AND DEF_SERIAL_NO = T.DEF_SERIAL_NO ) MAT_NO
  FROM HTT_WASTE_RESULT T
 WHERE 1=1
   AND T.DEF_FILL_NO ='1'
	  ]]>
	</query>
	
		<query id="FrmHttBugD.queryGX" desc="查询工序">
	 <![CDATA[ 
SELECT SUBSTR(T.RESULT_NO,5,6) RESULT_NO FROM HTT_WASTE_RESULT T WHERE T.HEAT_PLAN_NO=? and t.pline_code= ? GROUP BY RESULT_NO
	  ]]>
	</query>
	
	
		<query id="FrmHttBugD.doQueryScrapNum" desc="查询废品支数">
	 <![CDATA[
SELECT T.*,(SELECT  WM_CONCAT(MAT_NO) FROM HTT_WASTE_MAT_NO WHERE DEF_SERIAL_ITEM = T.DEF_SERIAL_ITEM AND DEF_SERIAL_NO = T.DEF_SERIAL_NO ) MAT_NO
  FROM HTT_WASTE_RESULT T
 WHERE 1=1
   AND T.DEF_FILL_NO ='2'
	  ]]>
	</query>

	<query id="FrmHttBugD.doQueryScrapLen" desc="查询可疑支数">
		<![CDATA[
SELECT T.*,(SELECT  WM_CONCAT(MAT_NO) FROM HTT_WASTE_MAT_NO WHERE DEF_SERIAL_ITEM = T.DEF_SERIAL_ITEM AND DEF_SERIAL_NO = T.DEF_SERIAL_NO ) MAT_NO
  FROM HTT_WASTE_RESULT T
 WHERE 1=1
   AND T.DEF_FILL_NO ='3'
	  ]]>
	</query>
	
	
	<query id="FrmHttBugD.queryExpandMaxRESULT1" desc="查询最大实绩编号">
	 <![CDATA[ 
SELECT ? ||
       LPAD(SUBSTR(NVL(MAX(T.RESULT_NO), '000000'), -6, 6) + 1, 6, '0') AS RESULT_NO
  FROM HTT_LOADING_RESULT T
 WHERE T.PLINE_CODE = ? AND T.HEAT_PLAN_NO= ?
	  ]]>
	</query>
		<query id="FrmHttBugD.queryExpandMaxRESULT2" desc="查询最大实绩编号">
	 <![CDATA[ 
SELECT ? ||
       LPAD(SUBSTR(NVL(MAX(T.RESULT_NO), '000000'), -6, 6) + 1, 6, '0') AS RESULT_NO
  FROM HTT_HHEAT_RESULT T
 WHERE T.PLINE_CODE = ? AND T.HEAT_PLAN_NO= ?
	  ]]>
	</query>
	
		<query id="FrmHttBugD.Updatebugd" desc="修改缺陷表实绩编号">
	 <![CDATA[ 
UPDATE HTT_WASTE_RESULT T SET T.RESULT_NO=?
WHERE T.HEAT_PLAN_NO=? AND T.PLINE_CODE=? and SUBSTR(T.RESULT_NO,5,6) =?
	  ]]>
	</query>
	
	
		<query id="FrmHttBugD.queryExpandMaxRESULT3" desc="查询最大实绩编号">
	 <![CDATA[ 
SELECT ? ||
       LPAD(SUBSTR(NVL(MAX(T.RESULT_NO), '000000'), -6, 6) + 1, 6, '0') AS RESULT_NO
  FROM HTT_LHEAT_RESULT T  
 WHERE T.PLINE_CODE = ? AND T.HEAT_PLAN_NO= ?
	  ]]>
	</query>
		<query id="FrmHttBugD.queryExpandMaxRESULT4" desc="查询最大实绩编号">
	 <![CDATA[ 
SELECT ? ||
       LPAD(SUBSTR(NVL(MAX(T.RESULT_NO), '000000'), -6, 6) + 1, 6, '0') AS RESULT_NO
  FROM HTT_APPEARANCECHECK_RESULT T
 WHERE T.PLINE_CODE = ? AND T.HEAT_PLAN_NO= ?
	  ]]>
	</query>
		<query id="FrmHttBugD.queryExpandMaxRESULT5" desc="查询最大实绩编号">
	 <![CDATA[ 
SELECT ? ||
       LPAD(SUBSTR(NVL(MAX(T.RESULT_NO), '000000'), -6, 6) + 1, 6, '0') AS RESULT_NO
  FROM HTT_CRACK_DETECTION_ET T
 WHERE T.PLINE_CODE = ? AND T.HEAT_PLAN_NO= ?
	  ]]>
	</query>
	
	
	<query id="FrmHttBugD.queryMaxfailBill" desc="生成废品缺陷编号">
	 <![CDATA[ 
   SELECT ? ||
       LPAD(SUBSTR(NVL(MAX(T.DEF_SERIAL_ITEM), '000'), -3, 3) + 1, 3, '0') AS DEF_SERIAL_ITEM
  FROM HTT_WASTE_RESULT T
 WHERE T.HEAT_PLAN_NO = ? and t.DEF_FILL_NO =?
	  ]]>
	</query>

	<query id="FrmHttBugD.queryMaxfailBillNew" desc="生成废品缺陷编号">
		<![CDATA[
  SELECT ? || LPAD(NVL(MAX(TO_NUMBER(SUBSTR(DEF_SERIAL_ITEM,
                                            LENGTH(DEF_SERIAL_ITEM) - 2))),
                       0) + 1,
                   3,
                   '0') DEF_SERIAL_ITEM
    FROM HTT_WASTE_RESULT
   WHERE DEF_SERIAL_ITEM LIKE ? || '___'
	  ]]>
	</query>
	
	<query id="FrmHttBugD.queryJumpDRESULT" desc="查询从表最大实绩编号">
		<![CDATA[
SELECT  LPAD(SUBSTR(NVL(MAX(T.DEF_SERIAL_NO), '00000000'), -8, 8) + 1, 8, '0') AS DEF_SERIAL_NO
  FROM HTT_WASTE_RESULT T
 WHERE T.HEAT_PLAN_NO = ?
		]]>
	</query>
	
	
	<query id="FrmHttBugD.AddExpandDResult" desc="新增可疑从表实绩">
		<![CDATA[
		INSERT INTO HTT_WASTE_RESULT
  (DEF_SERIAL_ITEM,
   DEF_SERIAL_NO,
   RESULT_NO,
   HEAT_PLAN_NO,
   DEF_FILL_NO,
   DEF_FILL_CODE,
   DEF_FILL_NAME,
   DEF_FILL_NUM,
   DEF_FILL_WT,
   PLINE_CODE,
   BATCH_NO)
VALUES
  (?, ?, ?, ?, '1',?, ?, ?,?,?,?)

		]]>
	</query>
	
		<query id="FrmHttBugD.AddExpandDResult1" desc="新增废品从表实绩">
		<![CDATA[
	INSERT INTO HTT_WASTE_RESULT
  (DEF_SERIAL_ITEM,
   DEF_SERIAL_NO,
   RESULT_NO,
   HEAT_PLAN_NO,
   DEF_FILL_NO,
   DEF_FILL_CODE,
   DEF_FILL_NAME,
   DEF_FILL_NUM,
   DEF_FILL_WT,
   PLINE_CODE,
   BATCH_NO)
VALUES
  (?, ?, ?, ?, '2',?, ?, ?,?,?,?)

		]]>
	</query>


	<query id="FrmHttBugD.AddExpandDResult3" desc="新增废品从表实绩">
		<![CDATA[
	INSERT INTO HTT_WASTE_RESULT
  (DEF_SERIAL_ITEM,
   DEF_SERIAL_NO,
   RESULT_NO,
   HEAT_PLAN_NO,
   DEF_FILL_NO,
   PLINE_CODE,
   BATCH_NO,
   TOTAL_LEN)
VALUES
  (?, ?, ?, ?, '3',?,?,?)

		]]>
	</query>

	<query id="FrmHttBugD.AddWasteMatNo" desc="">
		<![CDATA[
	INSERT INTO HTT_WASTE_MAT_NO
  (DEF_SERIAL_ITEM,
   DEF_SERIAL_NO,
   MAT_NO)
VALUES
  (?, ?, ?)

		]]>
	</query>

		<query id="FrmHttPerson.doQuerypline" desc="查询产线">
	 <![CDATA[ 
SELECT t.PLINE_CODE,t.PLINE_NAME FROM COM_BASE_PLINE t
where t.DEPARTMENT_DESC_P = '管加工部' and t.PROCESS_DESC ='热处理'
	  ]]>
	</query>
		<query id="FrmHttBugD.AddExpandDResult2" desc="查询实绩为1的数量">
	 <![CDATA[ 
 SELECT COUNT(*) COUNT FROM  HTT_WASTE_RESULT WHERE DEF_FILL_NO=? AND DEF_FILL_WT=?
	  ]]>
	</query>
		<query id="FrmHttPerson.updatePerson" desc="修改人员">
	 <![CDATA[ 
 UPDATE MCH_PERSON T
   SET T.NAME = ?,T.PLINE_CODE = ?,T.PRO_BZ = ?
 WHERE T.NAME = ?
	  ]]>
	</query>
	
		<query id="FrmHttPerson.deletePerson" desc="删除人员">
	 <![CDATA[ 
 DELETE FROM MCH_PERSON T WHERE T.NAME= ?
	  ]]>
	</query>


	<query id="FrmHttBugD.queryExpandNUMWithProcessSeq" desc="查询管号队列里合格的材料号">
		<![CDATA[
	SELECT T1.MAT_NO
  FROM (SELECT T.MAT_NO
          FROM PORT_HTT_BATCH_SAMPLE_RESULT T
         WHERE T.MAT_STATUS = '00'
           AND T.IS_SAMPLE_PIPE='0'
           AND T.instore_flag = '0'
           AND T.HEAT_PLAN_NO = ?
           AND T.PROCESS_SEQ = ?
           AND (T.PHY_BATCH_NO =DECODE(?,'',T.PHY_BATCH_NO,?) OR T.PHY_BATCH_NO IS NULL)
         ORDER BY T.MAT_NO ASC) T1
 WHERE ROWNUM<?
			]]>
	</query>

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

	<query id="FrmHttBugD.queryExpandNUMWithProcessSeqAndMatNo" desc="查询管号队列里合格的材料号">
		<![CDATA[
	SELECT T1.MAT_NO
  FROM (SELECT T.MAT_NO
          FROM PORT_HTT_BATCH_SAMPLE_RESULT T
         WHERE T.MAT_STATUS = '00'
           AND T.IS_SAMPLE_PIPE='0'
           AND T.instore_flag = '0'
           AND T.HEAT_PLAN_NO = ?
           AND T.PROCESS_SEQ = ?
           AND (T.PHY_BATCH_NO =DECODE(?,'',T.PHY_BATCH_NO,?) OR T.PHY_BATCH_NO IS NULL)

         ORDER BY T.MAT_NO ASC) T1
 WHERE ROWNUM<?
			]]>
	</query>

	<query id="FrmHttBugD.UpdatePortHtt" desc="更改管号队列状态">
		<![CDATA[
UPDATE PORT_HTT_BATCH_SAMPLE_RESULT T
   SET T.MAT_STATUS   = ?,
       T.OP_PROCESS   = ?,
       RESULT_NO      = ?,
       BAL_YEAR_MONTH_FAIL = DECODE(T.MAT_STATUS,
                               '00',
                                TO_CHAR(SYSDATE + 3 / 24, 'YYYYMM'),
                                '')
 WHERE T.HEAT_PLAN_NO = ?
   AND PROCESS_SEQ = (SELECT REAL_PROCESS_SEQ
                        FROM PLN_ZY_RCL_M
                       WHERE HEAT_PLAN_NO = T.HEAT_PLAN_NO)
   AND T.MAT_NO = ?
			]]>
	</query>

	<query id="HeatTreatmentService.QueryFailPortHtt" desc="查询废品材料信息">
		<![CDATA[
	SELECT T1.MAT_NO
  FROM (SELECT T.MAT_NO
          FROM PORT_HTT_BATCH_SAMPLE_RESULT T
         WHERE T.MAT_STATUS = '10'
           AND T.HEAT_PLAN_NO = ?
             AND T.OP_PROCESS=?
             AND T.PROCESS_SEQ =?
             AND (T.RESULT_NO=? OR T.RESULT_NO IS NULL)
         ORDER BY  T.RESULT_NO,T.MAT_NO DESC) T1
 WHERE ROWNUM<?
			]]>
	</query>

</queryMap>