<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="加工超声探伤实绩">
	<query id="FrmCrackDetectResult.getQueryExpandResult" desc="查超声探伤实绩">
        <![CDATA[
SELECT T.*,T1.REPORT_PATH  REPORT，T1.MEMO,
       (SELECT WM_CONCAT(D.FAIL_NUM || '支' || D.FAIL_TYPE_NAME)
          FROM MCH_BUG_D D
         WHERE D.RESULT_NO = T.RESULT_NO
           AND D.FAIL_SORT = '00') FTESTING_REASON,
       (SELECT WM_CONCAT(D.FAIL_NUM || '支' || D.FAIL_TYPE_NAME)
          FROM MCH_BUG_D D
         WHERE D.RESULT_NO = T.RESULT_NO
           AND D.FAIL_SORT = '10') EWASTE_REASON
  FROM HTT_CRACK_DETECTION_ET T
  LEFT JOIN HTT_CRACK_DETECTION_PARA T1 ON T.RESULT_NO = T1.RESULT_NO
 WHERE T.HEAT_PLAN_NO = ? AND T.BATCH_NO = ?
        ]]>
	</query>
	<query id="FrmCrackDetectResult.getQueryExpandResultStuts" desc="查询相同炉计划ID下超声探伤实绩状态">
        <![CDATA[
SELECT  B.STATION_STATUS
  FROM MCH_UT_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="FrmCrackDetectResult.getQueryExpandResult1" desc="查询探伤实绩合格支数的和">
        <![CDATA[
   SELECT NVL(SUM(T.PRO_NUM), 0) PRO_NUM FROM MCH_UT_RESULT T
   WHERE T.HEAT_PLAN_NO = ?
        ]]>
	</query>
	<query id="FrmCrackDetectResult.getquerynum" desc="查询实绩里不同分切数的加工支数">
        <![CDATA[
   SELECT NVL(SUM(T.TET_NUM), 0) TET_NUM,NVL(SUM(T.FAIL_NUM), 0) FAIL_NUM FROM MCH_UT_RESULT T
   WHERE T.HEAT_PLAN_NO = ? and t.OUTNUM_CUT = ?
        ]]>
	</query>
			<query id="FrmCrackDetectResult.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="FrmCrackDetectResult.AddExpandResult" desc="新增超声探伤实绩">
		<![CDATA[
		INSERT INTO MCH_UT_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,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,TET_NUM,DUBIOUS_NUM,FTESTING_NUM,FPASS_NUM,TESTING_STANDARD1,
TESTING_GRADE1,TESTING_STANDARD2,TESTING_GRADE2,TESTING_STANDARD3,TESTING_GRADE3,
TESTING_STANDARD4,TESTING_GRADE4,LEXTERNAL_LVL,LINTERNAL_LVL,TEXTERNAL_LVL,TINTERNAL_LVL,
PROBE_RUN_SPEED,PIPE_ROT_SPEED,LONG_EMI_FREQ,LONG_MAG_CUR,TRANS_MAG_CUR,TRANS_EMI_FREQ,UT_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="FrmCrackDetectResult.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=? and t.OUTNUM_CUT = ?
			]]>
	</query>


	<query id="FrmCrackDetectResult.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="FrmCrackDetectResult.getQuerybase" desc="查询探伤标准">
		<![CDATA[
SELECT T.BASECODE,T.BASENAME FROM COM_BASE_INFO T WHERE T.SORTCODE =? and t.VALIDFLAG ='1'

		 ]]>
	</query>
	
	<query id="FrmCrackDetectResult.getQuerydirect" desc="查询离线去向">
		<![CDATA[
SELECT T.PLINE_CODE, T.PLINE_NAME FROM COM_BASE_PLINE T WHERE T.PROCESS_CODE =?  and t.VALIDFLAG ='1'
--UNION ALL
--SELECT T.STORAGE_NO, T.STORAGE_NAME FROM YDM_BS_STORAGE T WHERE T.HL_MANAGEMENT_NO=?

		 ]]>
	</query>
		<query id="FrmCrackDetectResult.getQuerydirectOffline" desc="查询离线去向">
		<![CDATA[
SELECT DISTINCT REGEXP_SUBSTR (OFFLINE_PLACE,'[^;]+',1,LEVEL) as OFFLINE_PLACE
FROM   MCH_COM_SETPLINE where PLINE_CODE = ?
CONNECT BY REGEXP_SUBSTR (OFFLINE_PLACE,'[^;]+',1,LEVEL) IS NOT NULL
order by 1
		 ]]>
	</query>
	
	
	
	<query id="FrmCrackDetectResult.qureyGxComInfo" desc="查询工序是否是结炉状态">
		<![CDATA[
SELECT DISTINCT STATION_STATUS
  FROM MCH_COM_INFO
 WHERE HEAT_PLAN_NO = ?
   AND PLINE_CODE = ?
   AND STATION_CODE = ?
			]]>
	</query>
	<query id="FrmCrackDetectResult.UpdatePln1" desc="撤销修改计划表状态">
		<![CDATA[
 UPDATE PLN_ZY_JGX_M
    SET  PER_STATUS = ?
  WHERE HEAT_PLAN_NO = ?
			]]>
	</query>
	<query id="FrmCrackDetectResult.queryExpandMaxRESULT" 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 TO_CHAR(T.CREATE_TIME, 'YYYY-MM-DD') = ?
   AND T.PLINE_CODE = ?
		]]>
	</query>
	
		<query id="FrmCrackDetectResult.getqueryfailnum" desc="查询废品支数">
		<![CDATA[
delete MCH_BUG_D where RESULT_NO = ? and FAIL_SORT !='20'
		]]>
	</query>
		<query id="FrmCrackDetectResult.detelefailnum" desc="删除废品缺陷">
		<![CDATA[
DELETE MCH_BUG_D WHERE RESULT_NO = ? and HEAT_PLAN_NO = ? and PLINE_CODE = ?	
		]]>
	</query>
	<query id="FrmCrackDetectResult.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 = ?
           AND T.OUTNUM_CUT = ?
         ORDER BY T.MAT_NO ASC) T1
 WHERE ROWNUM<?
			]]>
	</query>
	<query id="FrmCrackDetectResult.deleteComInfoResult" desc="删除公共信息">
		<![CDATA[
		DELETE MCH_COM_INFO WHERE RESULT_NO = ?		
		]]>
	</query>
	<query id="FrmCrackDetectResult.deleteVrpExpandResult" desc="删除超声探伤实绩">
		<![CDATA[
		DELETE MCH_UT_RESULT WHERE RESULT_NO = ?		
		]]>
	</query>

	<query id="FrmCrackDetectResult.UpdatePln" desc="新增修改计划表状态">
		<![CDATA[
 UPDATE PLN_ZY_JGX_M
    SET  PER_STATUS = '10'
  WHERE HEAT_PLAN_NO = ?
			]]>
	</query>
	<query id="FrmCrackDetectResult.queryExpandFailNUM1" desc="查询工序废品数量">
		<![CDATA[
		SELECT NVL(SUM(T.FAIL_NUM),0) FAIL_NUM FROM MCH_UT_RESULT T
WHERE  T.HEAT_PLAN_NO=? 
			]]>
	</query>
	<query id="FrmCrackDetectResult.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="FrmCrackDetectResult.updateVrpExpandResult" desc="修改超声探伤实绩">
		<![CDATA[		
	UPDATE MCH_UT_RESULT
   SET HEAT_PLAN_NO = ?,
       ZY_BATCH_ID =?,
       PROD_INDEX = ?,
       PRO_PLAN_ID = ?,
       GX_PLAN_NO = ?,
       PLINE_CODE = ?,
       PLINE_NAME = ?,
       IF_MONITOR_RCL = ?,
       MONITORDEMAND = ?,
       
       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     = ?,
       UPDATE_TIME    = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'),
       UPDATE_NAME    = ?,
       TET_NUM       = ?,
       DUBIOUS_NUM   = ?,
       FTESTING_NUM  = ?,
       FPASS_NUM     = ?,
       
       TESTING_STANDARD1 = ?,
       TESTING_STANDARD2 = ?,
       TESTING_STANDARD3 = ?,
       TESTING_STANDARD4 = ?,
       TESTING_GRADE1 = ?,
       TESTING_GRADE2 = ?,
       TESTING_GRADE3 = ?,
       TESTING_GRADE4 = ?,
       LEXTERNAL_LVL = ?,
       LINTERNAL_LVL = ?,
       TEXTERNAL_LVL = ?,
       TINTERNAL_LVL = ?,
       PROBE_RUN_SPEED = ?,
       PIPE_ROT_SPEED = ?,
       LONG_EMI_FREQ = ?,
       LONG_MAG_CUR = ?,
       TRANS_MAG_CUR = ?,
       TRANS_EMI_FREQ = ?,
       UT_NOTE = ?,
       UT_MAN = ?,
       UT_MAN_GRADE = ?,
       SIGN_MAN = ?,
       SIGN_MAN_GRADE = ?
             
 WHERE RESULT_NO = ?  
			]]>
	</query>
	<query id="FrmCrackDetectResult.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="FrmCrackDetectResult.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="FrmCrackDetectResult.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>


	<query id="FrmCrackDetectResult.queryResultNo" desc="查询实绩最大实绩编号">
		<![CDATA[
		  SELECT ? || TO_CHAR(SYSDATE, 'yyyyMMDD') ||
         LPAD(NVL(MAX(TO_NUMBER(SUBSTR(RESULT_NO, LENGTH(RESULT_NO) - 5))),
                  0) + 1,
              6,
              '0') RESULT_NO
    FROM  MCH_CRACK_DETECTION
   WHERE RESULT_NO LIKE ? || TO_CHAR(SYSDATE, 'yyyyMMDD') || '______'
			]]>
	</query>

	<query id="FrmCrackDetectResult.AddResult" desc="增加实绩">
		<![CDATA[
INSERT INTO HTT_CRACK_DETECTION_ET
  (RESULT_NO,
   HEAT_PLAN_NO,
   BATCH_NO,
   JUDGE_STOVE_NO,
   PLINE_CODE,
   PLINE_NAME,
   TESTING_GRADE,
   TESTING_TYPE,
   TESTING_NUM,
   TESTING_WT,
   EWASTE_NUM,
   EWASTE_WT,
   QUALIFIED_NUM_AFTER_CUT,
   DUBIOUS_NUM,
   FTESTING_NUM,
   FPASS_NUM,
   COL_SHIFT,
   COL_GROUP,
   COL_USER,
   CREATE_TIME,
   COL_TIME,
   PROCESS_CODE)
VALUES
  ('#RESULT_NO#',
   '#HEAT_PLAN_NO#',
   '#BATCH_NO#',
   '#JUDGE_STOVE_NO#',
   '#PLINE_CODE#',
   '#PLINE_NAME#',
   '#TESTING_GRADE#',
   '#TESTING_TYPE#',
   '#PRO_NUM#',
   '#PRO_WT#',
   '#FAIL_NUM#',
   '#FAIL_WT#',
   '#CUT_NUM#',
   '#DUBIOUS_NUM#',
   '#FTESTING_NUM#',
   '#FPASS_NUM#',
   '#PRO_SHIFT#',
   '#PRO_GROUP#',
   '#PRO_USER#',
   SYSDATE,
   TO_DATE('#PRO_TIME#', 'YYYY-MM-DD HH24:MI:SS'),'G')
			]]>
	</query>


	<query id="FrmCrackDetectResult.DeleteResult" desc="删除实绩">
		<![CDATA[
DELETE FROM HTT_CRACK_DETECTION_ET WHERE RESULT_NO =?

			]]>
	</query>


	<query id="FrmCrackDetectResult.UpdatePath" desc="删除实绩">
		<![CDATA[
UPDATE HTT_CRACK_DETECTION_PARA SET REPORT_PATH = ? WHERE RESULT_NO =?

			]]>
	</query>

	<query id="FrmCrackDetectResult.GetReportCptName" desc="">
		<![CDATA[

SELECT REPORT_CPT,REPORT_TYPE FROM HTT_REPORT WHERE PLINE_CODE=? AND REPORT_TYPE = ?  AND MACHINE_NO =?
			]]>
	</query>
	<query id="FrmCrackDetectResult.CheckCraftRCL0" desc="">
		<![CDATA[
SELECT D.POSITION_CODE  COUNT
          FROM HTT_CRACK_HEADINFO       T,
               CRAFT_ORD_DESIGN         C,
               pln_zy_rcl_m             m,
               HTT_CRACK_DETECTION_ET   et,
                CRAFT_ORD_DESIGN_STD_DIC D
         WHERE T.RESULT_NO=?
           and c.craft_no = m.Craft_File_No
           and C.VALIDFLAG = '1'
           and t.result_no = et.result_no
           and et.heat_plan_no = m.heat_plan_no
           and d.phy_code IN ('P0032' ,'P0769')
           and  D.desgin_key = C.desgin_key
           and d.process_code='F'
			]]>
	</query>
	<query id="FrmCrackDetectResult.CheckCraftRCL1" desc="">
		<![CDATA[
SELECT D.STD_DESC COUNT
  FROM HTT_CRACK_HEADINFO       T,
       CRAFT_ORD_DESIGN         C,
       pln_zy_rcl_m             m,
       HTT_CRACK_DETECTION_ET   et,
       CRAFT_ORD_DESIGN_STD_DIC D
 WHERE T.RESULT_NO = ?
   and c.craft_no = m.Craft_File_No
   and C.VALIDFLAG = '1'
   and t.result_no = et.result_no
   and et.heat_plan_no = m.heat_plan_no
   and (d.phy_code in ('P0107', 'P0469', 'P0040', 'P0149') or
       (d.position_desc = '全长' and
       d.phy_code in ('P0105', 'P0104', 'P0032')))
   and D.desgin_key = C.desgin_key
   and d.process_code = 'F'
			]]>
	</query>
	<query id="FrmCrackDetectResult.CheckCraftRCL15" desc="">
		<![CDATA[
SELECt d.std_desc count
  FROM HTT_CRACK_HEADINFO       T,
       CRAFT_ORD_DESIGN         C,
       pln_zy_rcl_m             m,
       HTT_CRACK_DETECTION_ET   et,
       CRAFT_ORD_DESIGN_STD_DIC D
 WHERE T.RESULT_NO = ?
   and c.craft_no = m.Craft_File_No
   and C.VALIDFLAG = '1'
   and t.result_no = et.result_no
   and et.heat_plan_no = m.heat_plan_no
   and (d.phy_code in ('P0107', 'P0469', 'P0040', 'P0149') or
       (d.position_desc = '全长' and
       d.phy_code in ('P0105', 'P0104', 'P0032')))
   and D.desgin_key = C.desgin_key


			]]>
	</query>
	<query id="FrmCrackDetectResult.CheckCraftJGX1" desc="">
		<![CDATA[
SELECT  D.STD_DESC COUNT
  FROM HTT_CRACK_HEADINFO T,
     CRAFT_ORD_DESIGN C,
      pln_zy_jgx_m            m,
      CRAFT_ORD_DESIGN_STD_DIC D,
     HTT_CRACK_DETECTION_ET   et
 WHERE T.RESULT_NO = ?
   and c.craft_no = m.Craft_File_No
   and C.VALIDFLAG = '1'
   and t.result_no = et.result_no
   and et.heat_plan_no = m.heat_plan_no
   and  d.phy_code in ('P0107', 'P0469', 'P0040', 'P0149')
   and D.desgin_key = C.desgin_key
    and d.process_code='G'


			]]>
	</query>
	<query id="FrmCrackDetectResult.CheckCraftJGX10" desc="">
		<![CDATA[
SELECT  D.POSITION_CODE  COUNT
          FROM HTT_CRACK_HEADINFO       T,
               CRAFT_ORD_DESIGN         C,
               CRAFT_ORD_DESIGN_STD_DIC D,
               pln_zy_jgx_m           m,
               HTT_CRACK_DETECTION_ET   et
         WHERE T.RESULT_NO = ?
           and c.craft_no = m.Craft_File_No
           and C.VALIDFLAG = '1'
           and t.result_no = et.result_no
           and et.heat_plan_no = m.heat_plan_no
          and  d.phy_code in ('P0107', 'P0469', 'P0040', 'P0149')
          and D.desgin_key = C.desgin_key
            and d.process_code='G'

			]]>
	</query>



</queryMap>