<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="尺寸外观检查实绩">
	<query id="AppearanceService.GetAppearanceResultById" desc="按计划号查询尺寸外观检查实绩">
        <![CDATA[
       SELECT T.RESULT_NO,
       T.ZY_BATCH_ID,
       T.PROD_INDEX,
       T.PRO_PLAN_ID,
       T.GX_PLAN_NO,
       T.ODMAX,
       T.ODMIN,
       T.OUTOFROUNDNESS,
       T.ENDSTRAIGHTNESS,
       T.FULLLENGTHSTRAIGHTNESS,
       T.CHECKPIECES,
       T.PASS_NUM,
       T.DUBIOUS_NUM,
       T.WAST_NUM,
       T.DEF_SERIAL_ITEM,
       TO_CHAR(T.COL_TIME, 'YYYY-MM-DD HH24:MI:SS') COL_TIME,
       T.COL_USER,
       T.COL_SHIFT,
       T.COL_GROUP,
       T.HEAT_PLAN_NO,
       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,
       T.PLINE_CODE,
       T.PLINE_NAME,
       T.PROCESS_SEQ,
       REPORT_PATH,
       DECODE(B.STATION_STATUS, '1', '生产中', '2', '生产完成') STATION_STATUS,
       T.BATCH_NO,
       DECODE(T.RESULT,'0','合格','1','不合格') RESULT
  FROM HTT_APPEARANCECHECK_RESULT T,HTT_COM_INFO B
 WHERE T.RESULT_NO = B.RESULT_NO
   AND T.HEAT_PLAN_NO = B.HEAT_PLAN_NO
 AND T.HEAT_PLAN_NO = ?
 ORDER BY T.COL_TIME DESC
        ]]>
	</query>
		<query id="AppearanceService.AddOffLineD" desc="新增离线实绩从表">
		<![CDATA[
INSERT INTO HTT_OFFLINE_RESULT_D
  (RESULT_NO,
   RESULT_SQE,
   HEAT_PLAN_NO,
   PLINE_CODE,
   PLINE_NAME,
   OFFLINE_NUM,
   GOWHERE_CODE,
   GOWHERE_NAME,
   CREATE_TIME,
   STATION_CODE,
   STATION_DESC)
VALUES
  (?, ?, ?, ?, ? , ? , ? , ?, TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), ?, (SELECT BASENAME FROM COM_BASE_INFO WHERE BASECODE=?))

			]]>
	</query>
	
	<query id="AppearanceService.qureyGxLxCount" desc="查询是否离线">
		<![CDATA[
		SELECT COUNT(1) COUNT
  FROM PORT_HTT_BATCH_SAMPLE_RESULT T
 WHERE T.HEAT_PLAN_NO =?
   AND T.OP_PROCESS = ?
    AND T.MAT_STATUS='20'
   AND T.LEVE_LOG<>'00'
			]]>
	</query>

	<query id="AppearanceService.qureyGxLxCount1" desc="查询是否离线">
		<![CDATA[
		SELECT COUNT(1) COUNT
  FROM PORT_HTT_BATCH_SAMPLE_RESULT T
 WHERE T.HEAT_PLAN_NO =?
   AND (T.OP_PROCESS = ? or T.OP_PROCESS = ? or T.OP_PROCESS = ? )
    AND T.MAT_STATUS='20'
   AND T.LEVE_LOG<>'00'
			]]>
	</query>
		<query id="AppearanceService.getQueryExpandResultStuts" desc="查询相同炉计划ID下尺寸外观状态">
		<![CDATA[
SELECT B.STATION_STATUS 
  FROM htt_appearancecheck_result T INNER JOIN htt_COM_INFO B ON T.RESULT_NO=B.RESULT_NO
 WHERE T.HEAT_PLAN_NO = ? AND T.PLINE_CODE =?
			]]>
	</query>
		<query id="AppearanceService.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="AppearanceService.querymaxsqeNew" desc="查询最大高温炉实绩编号">
		<![CDATA[
  SELECT ? ||
         LPAD(NVL(MAX(TO_NUMBER(SUBSTR(RESULT_SQE, LENGTH(RESULT_SQE) - 1))),
                  0) + 1,
              2,
              '0') RESULT_SQE
    FROM HTT_OFFLINE_RESULT_D
   WHERE RESULT_NO = ?
     AND RESULT_SQE LIKE ? || '__'
			]]>
	</query>

	<query id="AppearanceService.addMatBc" desc="新增材料表">
        <![CDATA[      
INSERT INTO MAT_BC_M
  SELECT *
    FROM MAT_BC_BACKUP T
   WHERE T.Mat_No = ?
     AND T.NEXT_PROCESS_CDOE = 'F'
        ]]>
	</query>
	<query id="AppearanceService.updateMatBc" desc="修改材料表状态12">
        <![CDATA[      
  UPDATE MAT_BC_M T SET T.QCM_STAUS = '22',T.PROCESS_CDOE = ?, T.PROCESS_DESC =  (SELECT BASENAME FROM COM_BASE_INFO  WHERE BASECODE=? )
  where  T.Mat_No = ?
        ]]>
	</query>
	<query id="AppearanceService.updateMatBcOffline" desc="修改材料表状态11">
        <![CDATA[
  UPDATE MAT_BC_M T SET T.QCM_STAUS = '11',T.PROCESS_CDOE = ?, T.PROCESS_DESC =  (SELECT BASENAME FROM COM_BASE_INFO  WHERE BASECODE=? )
  where  T.Mat_No = ?
        ]]>
	</query>

<query id="AppearanceService.AddOffLine" desc="新增离线实绩">
		<![CDATA[
INSERT INTO HTT_OFFLINE_RESULT
  (RESULT_NO,
   PLINE_CODE,
   PLINE_NAME,
   STATION_CODE,
   STATION_DESC,
   HEAT_PLAN_NO,
   ZY_BATCH_ID,
   PROD_INDEX,
   PRO_PLAN_ID,
   GX_PLAN_NO,
   JUDGE_STOVE_NO,
   BATCH_NO,
   BATCH_GROUD_NO,
   PRODUCCODE,
   PRODUCNAME,
   STEELCODE,
   STEELNAME,
   GRADECODE,
   GRADENAME,
   MODEL_CODE,
   MODEL_DESC,
   STD_CODE,
   STD_NAME,
   STD_STYLE,
   STD_STYLE_DESC,
   ACT_DIMATER,
   ACT_HEIGHT,
   ACT_LEN,
   ACT_LEN_MIN,
   ACT_LEN_MAX,
   ORD_LN_DLY_PK,
   ORDER_NO,
   ORDER_SEQ,
   DELIVERY_NO,
   OFFLINE_NUM,
   OFFLINE_WT,
   PRO_USER,
   PRO_SHIFT,
   PRO_GROUP,
   PRO_TIME,
   PROCESS_SEQ,
   FLAG_STOVE_NO,
   MEMO,
   LOAD_JUDGE_STOVE_NO)
VALUES
  (?,
   ?,
   ?,
   ?,
   (SELECT BASENAME FROM COM_BASE_INFO WHERE BASECODE = ?),
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'),
   ?,
   ?,
   ?,
   ?)

			]]>
	</query>
	<query id="AppearanceService.queryMatZc" desc="查询新增物料信息">
		<![CDATA[
SELECT T1.*
  FROM (SELECT T.MAT_NO,
               T.PRODUCT_FLAG,
               T.MAT_STATUS,
               T.JUDGE_STOVE_NO,
               T.BATCH_NO,
               T.BATCH_GROUD_NO,
               T.ORIGIN_MAT_NO,
               T.MATERIAL_NO,
               T.MATERIAL_NAME,
               T.PRODUCCODE,
               T.PRODUCNAME,
               T.STEELCODE,
               T.STEELNAME,
               T.GRADECODE,
               T.GRADENAME,
               T.SPEC_CODE,
               T.SPEC_NAME,
               T.MODEL_CODE,
               T.MODEL_DESC,
               T.STD_CODE,
               T.STD_NAME,
               T.STD_STYLE,
               T.STD_STYLE_DESC,
               T.ORDER_NO,
               T.ORDER_SEQ,
               T.ORDER_SEQ_NO,
               T.PROCESS_CDOE,
               T.PROCESS_DESC,
               T.PLINE_CODE,
               T.PLINE_NAME,
               T.MAT_ORIGIN_CODE,
               T.MAT_ORIGIN_NAME,
               T.ACT_DIMATER,
               T.ACT_HEIGHT,
               T.ACT_LEN,
               T.ACT_LEN_MIN,
               T.ACT_LEN_MAX,
               T.ACT_COUNT,
               T.ACT_WEIGHT,
               T.ACT_THEORY_WEIGHT,
               T.BELONG_CODE,
               T.BELONG_NAME,
               T.LOCK_FLAG,
               T.PRO_BC,
               T.PRO_BZ,
               T.RPO_TIME,
               T.ORD_PK,
               T.ORD_LN_PK,
               SUBSTR(T.ORD_LN_DLY_PK, 0, INSTR(T.ORD_LN_DLY_PK, '-') - 1) ORD_LN_DLY_PK,
               T.BAL_YEAR_MONTH,
               T.JUDGE_STD_NAME,
               T.JUDGE_STD_CODE,
               T.SOURE_CODE,
               T.SOURE_NAME,
               T.MNG_LOCK_FLAG,           
               T.STOVE_NO
          FROM MAT_BC_M T
         WHERE T.PRODUCT_FLAG = '801401'
           AND T.MAT_STATUS = '80150105'
           AND T.JUDGE_STOVE_NO = ?
           AND NVL(T.BATCH_NO, '/') = NVL(?, '/')
           AND NVL(T.BATCH_GROUD_NO, '/') = NVL(?, '/')
         ORDER BY T.MAT_NO ASC) T1
 WHERE ROWNUM < ?
		]]>
	</query>
	<query id="AppearanceService.AddAppearanceResult" desc="新增尺寸外观检查实绩">
        <![CDATA[
        INSERT INTO HTT_APPEARANCECHECK_RESULT (RESULT_NO, ZY_BATCH_ID,  
PRO_PLAN_ID, GX_PLAN_NO, ODMAX, ODMIN, OUTOFROUNDNESS, ENDSTRAIGHTNESS, 
FULLLENGTHSTRAIGHTNESS, CHECKPIECES, PASS_NUM, DUBIOUS_NUM, WAST_NUM, COL_TIME, 
COL_USER, COL_SHIFT, COL_GROUP, HEAT_PLAN_NO, CREATE_TIME, PLINE_CODE, 
PLINE_NAME,PROCESS_SEQ,WAST_WT,BATCH_NO,RESULT) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,
TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), ?, ?, ?, ?, 
TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), ?, ?,?,     (SELECT  NVL(SUM(DEF_FILL_WT),0) FROM HTT_WASTE_RESULT WHERE RESULT_NO = ? ), ?, ?)
        ]]>
	</query>
	
	<query id="AppearanceService.UpdatePathPortVrp" desc="修改队列表工艺路径，材料状态，工序状态,离线状态">
		<![CDATA[
UPDATE PORT_HTT_BATCH_SAMPLE_RESULT T
   SET T.PRC_TECHNOLOGY_PATH = SUBSTR(T.PRC_TECHNOLOGY_PATH, ?, ?) || ? ||
                               SUBSTR(T.PRC_TECHNOLOGY_PATH,
                                      ?,
                                      LENGTH(T.PRC_TECHNOLOGY_PATH)),
       T.MAT_STATUS          = ?,
       T.LEVE_LOG            = ?,
       T.OP_PROCESS          = ?
 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=?
   AND MAT_STATUS = '00'

			]]>
	</query>

	<query id="AppearanceService.UpdatePathPortVrp2" desc="修改队列表工艺路径，材料状态，工序状态,离线状态">
		<![CDATA[
UPDATE PORT_HTT_BATCH_SAMPLE_RESULT T
   SET T.PRC_TECHNOLOGY_PATH = SUBSTR(T.PRC_TECHNOLOGY_PATH, ?, ?) || ? ||
                               SUBSTR(T.PRC_TECHNOLOGY_PATH,
                                      ?,
                                      LENGTH(T.PRC_TECHNOLOGY_PATH)),
       T.MAT_STATUS          = ?,
       T.LEVE_LOG            = ?,
       T.OP_PROCESS          = ?,
       RESULT_NO             = ?
 WHERE T.HEAT_PLAN_NO = ?
   AND PROCESS_SEQ = ?
   AND T.MAT_NO=?
   AND MAT_STATUS = '00'

			]]>
	</query>
	
	<query id="AppearanceService.AddYdmButt" desc="新增位置表">
	<![CDATA[
	INSERT INTO YDM_BC_BUTTRESS
  (MAT_NO,
   JUDGE_STOVE_NO,
   BATCH_NO,
   BATCH_GROUD_NO,
   STORAGE_NO,
   LOCATION_NO,
   LARY_NO,
   LOC_NO,
   STORAGE_ATTR,
   STORAGE_ATTR_NAME,
   STORAGE_TYPE_NO,
   STORAGE_TYPE_NAME,
   MANAGEMENT_NO,
   MANAGEMENT_NAME,
   MEMO,
   CREATE_NAME,
   CREATE_TIME,
   DEPARTMENT_CODE,
   DEPARTMENT_DESC)
  values ( ?,
          ?,
          ?,
          ?,
          ?,
          ?,
          ?,
          ?,
          ?,
          ?,
          ?,
          ?,
          ?,
          ?,
          ?,
          ?,
          TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'),
          ?,
          ?)
    ]]>
	</query>
	
	<query id="AppearanceService.queryPortVrpHg" desc="查询管号队列合格数据">
		<![CDATA[
	SELECT T1.*
  FROM (SELECT T.HEAT_PLAN_NO,
               T.MAT_NO,
               T.M_MAT_NO,
               T.M_M_MAT_NO,
               T.LOT_NO,
               T.LOT_NO_SQE,
               T.PLINE_CODE,
               T.PLINE_NAME,
               T.JUDGE_STOVE_NO,
               T.BATCH_NO,
               T.GROUP_NO,
               T.STOVE_NO,
               T.FLAG_STOVE_NO,
               T.ACT_DIMATER,
               T.ACT_HEIGHT,
               T.ACT_LEN,
               T.ACT_LEN_MIN,
               T.ACT_LEN_MAX,
               T.ACT_COUNT,
               T.ACT_WEIGHT,
               T.ACT_THEORY_WEIGHT,
               T.IS_SAMPLE_PIPE,
               T.SAMPLE_PIPE_LEN,
               T.GET_SAMPLE_SHIFT,
               T.GET_SAMPLE_CLASS,
               T.GET_SAMPLE_NAME,
               T.GET_SAMPLE_TIME,
               T.OLD_JUDGE_STOVE_NO,
               T.GROUP_FLAG,
               T.OP_PROCESS,
               T.MAT_STATUS,
               T.LEVE_LOG,
               T.INSTORE_FLAG,
               T.PRO_USER,
               T.PRO_SHIFT,
               T.PRO_GROUP,
               T.PRO_TIME,
               T.REMARK,
               T.PRC_TECHNOLOGY_PATH,
               T.PROCESS_SEQ
          FROM PORT_HTT_BATCH_SAMPLE_RESULT T
         WHERE  T.MAT_STATUS = '00'
           AND T.IS_SAMPLE_PIPE = '0'
           AND T.HEAT_PLAN_NO = ?
           AND T.GROUP_NO = ?
         ORDER BY T.MAT_NO ASC) T1
 WHERE ROWNUM < ?
			]]>
	</query>

	<query id="AppearanceService.queryPortVrpHgByProcess" desc="查询管号队列合格数据">
		<![CDATA[
	SELECT T1.*
  FROM (SELECT T.*
          FROM PORT_HTT_BATCH_SAMPLE_RESULT T
         WHERE  T.MAT_STATUS = '00'
           AND T.IS_SAMPLE_PIPE = '0'
           AND T.HEAT_PLAN_NO = ?
           AND PROCESS_SEQ = ?
         ORDER BY T.MAT_NO ASC) T1
 WHERE ROWNUM < ?
			]]>
	</query>

	<query id="AppearanceService.queryPortVrpHgByProcess2" desc="查询管号队列合格数据">
		<![CDATA[
SELECT T1.*
  FROM (SELECT T.*
          FROM PORT_HTT_BATCH_SAMPLE_RESULT T
         WHERE  T.MAT_STATUS = '00'
           AND T.INSTORE_FLAG = '0'
           AND T.HEAT_PLAN_NO = ?
           AND PROCESS_SEQ = ?
           AND NVL(PHY_BATCH_NO,'/') = NVL(?,'/')
         ORDER BY T.MAT_NO ASC) T1
 WHERE ROWNUM < ?
			]]>
	</query>

	<query id="AppearanceService.queryPortVrpHgByProcess3" desc="查询管号队列合格数据">
		<![CDATA[
        SELECT T.*
          FROM PORT_HTT_BATCH_SAMPLE_RESULT T
         WHERE  T.MAT_STATUS = '00'
           AND T.INSTORE_FLAG = '0'
           AND T.HEAT_PLAN_NO = ?
           AND PROCESS_SEQ = ?
           AND NVL(PHY_BATCH_NO,'/') = NVL(?,'/')
			]]>
	</query>

	<query id="AppearanceService.queryPortVrpBatchHg" desc="查询合格支">
		<![CDATA[
		SELECT NVL(SUM(T.ACT_COUNT),0) ACT_COUNT
  FROM PORT_HTT_BATCH_SAMPLE_RESULT T
 WHERE T.MAT_STATUS = '00'
   AND T.HEAT_PLAN_NO = ?
   AND T.IS_SAMPLE_PIPE='0'	
			]]>
	</query>
	
	<query id="AppearanceService.queryStorageType" desc="查询库位信息">
	 <![CDATA[ 
SELECT T.STORAGE_ATTR,
       T.STORAGE_ATTR_NAME,
       T.STORAGE_TYPE_NO,
       T.STORAGE_TYPE_NAME,
       T.MANAGEMENT_NO,
       T.MANAGEMENT_NAME,
       T.DEPARTMENT_CODE,
       T.DEPARTMENT_DESC
  FROM YDM_BS_STORAGE T
 WHERE T.STORAGE_NO = ?
 AND T.VALIDFLAG='1'
	  ]]>
	</query>
	
	<query id="AppearanceService.AddYdmInList" desc="新增入库表">
		<![CDATA[
	INSERT INTO YDM_BC_INLIST (INSTOCK_SQE, INSTOCK_DOC, INSTOCK_TYPE_CODE, 
INSTOCK_TYPE_NAME, VEHICLE_NO, MAT_NO, LOT_NO, 
STOVE_NO, JUDGE_STOVE_NO, BATCH_NO, BATCH_GROUD_NO, MATERIAL_NO, MATERIAL_NAME, 
PRODUCCODE, PRODUCNAME, STD_CODE, STD_NAME, GRADECODE, GRADENAME, STEELCODE, 
STEELNAME, STD_STYLE, STD_STYLE_DESC, SPEC_CODE, SPEC_NAME, MODEL_CODE, 
MODEL_DESC, PRO_ORDER_NO, PLINE_CODE, PLINE_NAME, ACT_DIMATER, ACT_HEIGHT, 
ACT_LEN, ACT_LEN_MIN, ACT_LEN_MAX, ACT_COUNT, ACT_WEIGHT, ACT_THEORY_WEIGHT, 
BELONG_CODE, BELONG_NAME, STORAGE_NO, LOCATION_NO, LARY_NO, LOC_NO, 
STORAGE_ATTR, STORAGE_ATTR_NAME, STORAGE_TYPE_NO, STORAGE_TYPE_NAME, 
MANAGEMENT_NO, MANAGEMENT_NAME, RPO_TIME, PRO_BC, PRO_BZ, INSTOCK_TIME, IN_BC, 
IN_BZ, MEMO, CREATE_NAME, CREATE_TIME, ORD_PK, ORD_LN_PK, ORD_LN_DLY_PK, 
DEPARTMENT_CODE, DEPARTMENT_DESC, ORDER_NO, ORDER_SEQ, DELIVERY_NO, 
PRODUCT_FLAG, MAT_STATUS, JUDGE_STD_NAME, JUDGE_STD_CODE, IN_TIME_F, 
LEN_NO, LEN_DESC, LEN_UNIT, PIPMEMO, SOURE_CODE, SOURE_NAME, 
MAT_ORIGIN_CODE, MAT_ORIGIN_NAME, AFFIRM_LOG) 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'),?, ?, ?, 
?, ?, ?, ?, ?, 
?, ?, ?, ?, TO_DATE(?,'YYYY-MM-DD HH24:MI:SS'),  ?, ?, ?, ?,?, ?, 
?, ?, ?)
		]]>
	</query>
	
	<query id="AppearanceService.UpdateMatNo" desc="修改材料表">
		<![CDATA[
UPDATE MAT_BC_BACKUP T SET T.MAT_STATUS = ? WHERE T.MAT_NO = ?
			]]>
	</query>
	<query id="AppearanceService.queryOffMaxRESULT" desc="查询离线最大实绩编号">
		<![CDATA[
SELECT ? ||
       LPAD(MAX(SUBSTR(NVL(T.RESULT_NO, '000000'), -6, 6)) + 1, 6, '0') AS RESULT_NO
  FROM HTT_OFFLINE_RESULT T
 WHERE T.PRO_YEAR_MONTH_DAY = ?
   AND T.PLINE_CODE = ?
		]]>
	</query>


	<query id="AppearanceService.queryOffMaxRESULT1" desc="查询离线最大实绩编号">
	<![CDATA[
                 	SELECT ? ||
	LPAD(NVL(MAX(TO_NUMBER(SUBSTR(RESULT_NO, LENGTH(RESULT_NO) - 5))),
	0) + 1,
	6,
	'0') RESULT_NO
	FROM HTT_OFFLINE_RESULT
	WHERE RESULT_NO LIKE ? || '______'
		]]>
	</query>
	
	<query id="AppearanceService.getInListDoc1" desc="查询入库流水">
	<![CDATA[
	SELECT LPAD(SUBSTR(NVL(MAX(T.INSTOCK_SQE), '0000'), -4, 4) + 1, 4, '0') AS INSTOCK_SQE
  FROM YDM_BC_INLIST T
 WHERE T.INSTOCK_DOC = ?
    ]]>
	</query>
	
	<query id="AppearanceService.getInListDoc" desc="查询入库单号">
	<![CDATA[
		 SELECT ? || ? ||
        LPAD(SUBSTR(NVL(MAX(T.INSTOCK_DOC), '00000'), -5, 5) + 1, 5, '0') AS INSTOCK_DOC
   FROM YDM_BC_INLIST T
  WHERE TRUNC(T.CREATE_TIME) = TO_DATE(?, 'YYYY-MM-DD')
    AND T.INSTOCK_TYPE_CODE = ?
    ]]>
	</query>

	<query id="AppearanceService.UpdateAppearanceResult" desc="修改尺寸外观检查实绩">
		<![CDATA[
UPDATE HTT_APPEARANCECHECK_RESULT
   SET ODMAX                  = ?,
       ODMIN                  = ?,
       OUTOFROUNDNESS         = ?,
       ENDSTRAIGHTNESS        = ?,
       FULLLENGTHSTRAIGHTNESS = ?,
       CHECKPIECES            = ?,
       PASS_NUM               = ?,
       DUBIOUS_NUM            = ?,
       WAST_NUM               = ?,
       COL_TIME               = TO_DATE(?,'YYYY-MM-DD HH24:MI:SS'),
       COL_SHIFT              = ?,
       COL_GROUP              = ?,
       UPDATE_TIME            = TO_DATE(?,'YYYY-MM-DD HH24:MI:SS'),
       UPDATE_NAME            = ?
 WHERE RESULT_NO = ?
		]]>
	</query>

	<query id="AppearanceService.GetAppearanceDById" desc="查询尺寸外观检查结果表">
        <![CDATA[
       SELECT RESULT_NO,
       M_RESULT_NO,
       SEQ_NO,
       PIPE_NO,
       ENDA_STRAIGHTNESS,
       ENDA_AVG_OD,
       ENDA_MAX_OD,
       ENDA_MIN_OD,
       ENDA_OVALITY,
       ENDB_STRAIGHTNESS,
       ENDB_AVG_OD,
       ENDB_MIN_OD,
       ENDB_MAX_OD,
       ENDB_OVALITY,
       HEATNO_LAST,
       TO_CHAR(CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       TO_CHAR(UPDATE_TIME, 'YYYY-MM-DD HH24:MI:SS') UPDATE_TIME,
       UPDATE_NAME,
       CREATE_NAME
  FROM HTT_APPEARANCECHECK_RESULT_D
  WHERE M_RESULT_NO=?
        ]]>
	</query>

	<query id="AppearanceService.AddAppearanceD" desc="新增尺寸外观检查实绩结果表">
        <![CDATA[
        INSERT INTO HTT_APPEARANCECHECK_RESULT_D (RESULT_NO, M_RESULT_NO, SEQ_NO, PIPE_NO, ENDA_STRAIGHTNESS, 
ENDA_AVG_OD, ENDA_MAX_OD, ENDA_MIN_OD, ENDA_OVALITY, ENDB_STRAIGHTNESS, 
ENDB_AVG_OD, ENDB_MIN_OD, ENDB_MAX_OD, ENDB_OVALITY, HEATNO_LAST, CREATE_TIME, 
CREATE_NAME) VALUES ((SELECT LPAD(SUBSTR(NVL(MAX(T.M_RESULT_NO), '000000'), -6, 6) + 1, 6, '0') AS RESULT_NO
  FROM HTT_APPEARANCECHECK_RESULT_D T
 WHERE RESULT_NO = ?),?,  ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 
TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), ?)
        ]]>
	</query>

	<query id="AppearanceService.UpdateAppearanceD" desc="修改尺寸外观检查实绩结果表">
		<![CDATA[
UPDATE HTT_APPEARANCECHECK_RESULT_D
   SET PIPE_NO = ?,
       ENDA_STRAIGHTNESS = ?,
       ENDA_AVG_OD       = ?,
       ENDA_MAX_OD       = ?,
       ENDA_MIN_OD       = ?,
       ENDA_OVALITY      = ?,
       ENDB_STRAIGHTNESS = ?,
       ENDB_AVG_OD       = ?,
       ENDB_MIN_OD       = ?,
       ENDB_MAX_OD       = ?,
       ENDB_OVALITY      = ?,
       UPDATE_TIME       = TO_DATE(?,'YYYY-MM-DD HH24:MI:SS'),
       UPDATE_NAME       = ?
 WHERE RESULT_NO = ?
   AND M_RESULT_NO = ?
		]]>
	</query>
	<query id="AppearanceService.queryLoadRESULT" desc="查询最大实绩编号">
		<![CDATA[
  SELECT ? ||
         LPAD(NVL(MAX(TO_NUMBER(SUBSTR(RESULT_NO, LENGTH(RESULT_NO) - 5))),
                  0) + 1,
              6,
              '0') RESULT_NO
    FROM HTT_APPEARANCECHECK_RESULT
   WHERE RESULT_NO LIKE ? || '______'
   		]]>
	</query>
	<query id="AppearanceService.getQueryExpandResult1" desc="查询外观检验实绩合格支数的和">
        <![CDATA[
   SELECT NVL(SUM(T.CHECKPIECES), 0) CHECKPIECES FROM HTT_APPEARANCECHECK_RESULT T
   WHERE T.HEAT_PLAN_NO = ?
        ]]>
	</query>
	<query id="AppearanceService.deleteHttCrackResult" desc="删除外观检验实绩">
		<![CDATA[	
		DELETE HTT_APPEARANCECHECK_RESULT WHERE RESULT_NO = ?
		]]>
	</query>
	<query id="AppearanceService.deleteHttCrackResultD" desc="删除抽检记录实绩">
		<![CDATA[	
DELETE HTT_APPEARANCECHECK_RESULT_D
 WHERE RESULT_NO = ?
   AND M_RESULT_NO = ?
		]]>
	</query>
	<query id="AppearanceService.deleteHttCrackResultD1" desc="删除抽检记录实绩1">
		<![CDATA[	
DELETE HTT_APPEARANCECHECK_RESULT_D
 WHERE M_RESULT_NO =?
		]]>
	</query>
	<query id="AppearanceService.queryAppearancecheckD" desc="查询是否还有抽检记录">
		<![CDATA[	
		SELECT COUNT(*) COUNT FROM htt_appearancecheck_result_d T WHERE T.M_RESULT_NO=?
			]]>
	</query>
	<query id="AppearanceService.selectComInfo" desc="查询是否有当前工序">
		<![CDATA[
SELECT COUNT(*) COUNT FROM HTT_COM_INFO
WHERE HEAT_PLAN_NO = ?
 AND PLINE_CODE = ?
 AND STATION_CODE = ?
			]]>
	</query>
	<query id="AppearanceService.updatePlnZyRclM" desc="修改热处理计划表">
		<![CDATA[
UPDATE PLN_ZY_RCL_M
   SET PER_STATUS  = ?
 WHERE HEAT_PLAN_NO = ?
			]]>
	</query>
	<query id="AppearanceService.queryExpandFailNUM1" desc="查询工序废品数量">
		<![CDATA[
		SELECT NVL(SUM(T.WAST_NUM),0) WAST_NUM FROM HTT_APPEARANCECHECK_RESULT T
WHERE  T.HEAT_PLAN_NO=? 
			]]>
	</query>
	<query id="AppearanceService.UpdatePath" desc="修改队列表工艺路径">
		<![CDATA[
UPDATE PORT_HTT_BATCH_SAMPLE_RESULT T
   SET T.PRC_TECHNOLOGY_PATH = SUBSTR(T.PRC_TECHNOLOGY_PATH, 1,14) || ? ||
                               SUBSTR(T.PRC_TECHNOLOGY_PATH,16, LENGTH(T.PRC_TECHNOLOGY_PATH))
 WHERE T.HEAT_PLAN_NO = ?
 AND MAT_STATUS='00'
			]]>
	</query>	
	<query id="AppearanceService.qureyGxComInfo" desc="查询是工序结炉状态">
		<![CDATA[
SELECT DISTINCT STATION_STATUS
  FROM HTT_COM_INFO
 WHERE HEAT_PLAN_NO = ?
 AND PROCESS_SEQ = (SELECT real_process_seq FROM pln_zy_rcl_m WHERE heat_plan_no = t.heat_plan_no)
   AND PLINE_CODE = ?
   AND STATION_CODE = ?
			]]>
	</query>
	<query id="AppearanceService.doBeside" desc="修改工序状态结炉">
		<![CDATA[
		UPDATE HTT_COM_INFO
 SET STATION_STATUS = '2'
WHERE HEAT_PLAN_NO = ?
 AND PLINE_CODE = ?
 AND STATION_CODE = ?
			]]>
	</query>
	<query id="AppearanceService.deleteBeside" desc="修改工序状态撤销结炉">
		<![CDATA[
		UPDATE HTT_COM_INFO
 SET STATION_STATUS = '1'
WHERE HEAT_PLAN_NO = ?
 AND PLINE_CODE = ?
 AND STATION_CODE = ?
			]]>
	</query>
	<query id="AppearanceService.updateComInfoResult" desc="修改公共信息">
		<![CDATA[
UPDATE HTT_COM_INFO
   SET 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="AppearanceService.MarkUnCancelFlag" desc="标记无法撤销返线">
		<![CDATA[
UPDATE VRP_OFFLINE_RESULT T
   SET FLAG = '1'
 WHERE T.HEAT_PLAN_NO = ?
   AND JUDGE_STOVE_NO =?
   AND NVL(BATCH_NO,'') = ?
   AND  NVL(BATCH_GROUD_NO,'') = ?
   AND STATION_CODE = ?
   AND (TO_NUMBER(NVL(T.OFFLINE_NUM, 0)) - TO_NUMBER(NVL(T.GROUP_NUM, 0)) -
       TO_NUMBER(NVL(T.RE_NUM, 0)) - TO_NUMBER(NVL(T.SUBCONTRACT_NUM, 0)) +
       TO_NUMBER(NVL(T.SUBCONTRACTCOMPLETE_NUM, 0))) <=  0
			]]>
	</query>

	<query id="AppearanceService.GetAppResult" desc="热处理高温炉实绩查询">
		<![CDATA[
          SELECT *
 FROM HTT_APPEARANCECHECK_RESULT
        ]]>
	</query>

	<query id="AppearanceService.UpdatePortHttBarCode" desc="">
		<![CDATA[
                        UPDATE PORT_HTT_BATCH_SAMPLE_RESULT
           SET BAR_CODE = JUDGE_STOVE_NO || PHY_BATCH_NO || LPAD(?, 4, '0')
         WHERE HEAT_PLAN_NO = ?
           AND MAT_NO = ?

        ]]>
	</query>

	<query id="AppearanceService.UpdateReportUrl" desc="">
		<![CDATA[
                        UPDATE HTT_APPEARANCECHECK_RESULT
           SET REPORT_PATH = ?
         WHERE HEAT_PLAN_NO = ?
        ]]>
	</query>

</queryMap>