<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="热处理上料实绩">
	
	<query id="HttLoadingService.GetHttPlanByID" desc="作业计划查询">
        <![CDATA[
         select T.PLINE_CODE,T.PLINE_NAME,T.HEATNO,T.ROLLBATCH_ID,T.PLAN_TIME,
				T.PLAN_USETIME,T.INWL_ID,T.IN_NUM,T.IN_WEIGHT,T.LENGTHMAX,T.LENGTHMIN
			from PLN_ZY_RCL_M T
			where T.RCLBATCH_ID=?
        ]]>
	</query>
		<query id="HttLoadingService.getQueryLoadingResult" desc="查询相同炉计划ID下实绩状态">
        <![CDATA[
select b.station_status  FROM HTT_LOADING_RESULT T,HTT_COM_INFO B
   WHERE T.RESULT_NO = B.RESULT_NO
   AND T.HEAT_PLAN_NO = ? and t.pline_code= ?
        ]]>
	</query>
		<query id="HttLoadingService.queryYdmOutlist" desc="查询出库信息产出出库">
	<![CDATA[
SELECT OUTSTOCK_SQE,
       OUTSTOCK_PLAN_NO,
       OUTSTOCK_DOC,
       OUTSTOCK_TYPE_CODE,
       OUTSTOCK_TYPE_NAME,
       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,
       DEPARTMENT_CODE,
       DEPARTMENT_DESC,
       ACT_WEIGHT,
       BAL_YEAR_MONTH
  FROM (SELECT *
          FROM YDM_BC_OUTLIST
         WHERE OUTSTOCK_TYPE_CODE = '800809'
           AND JUDGE_STOVE_NO = ?
           AND NVL(BATCH_NO,'/') = NVL(?,'/')
           AND OUTSTOCK_PLAN_NO = ?
         ORDER BY MAT_NO ASC)
 WHERE ROWNUM < ? 
	]]>
	</query>
		<query id="HttLoadingService.DeleteOutListQuan" desc="删除出库记录产权出库">
		<![CDATA[
        DELETE YDM_BC_OUTLIST WHERE MAT_NO = ?  AND OUTSTOCK_TYPE_CODE = '800809' AND  OUTSTOCK_PLAN_NO = ?
		]]>
	</query>
		<query id="HttLoadingService.queryStationName" desc="查询工序点配置表里工序名称">
        <![CDATA[
   
select length(t.station_names)-length(replace(t.station_names,';'))+1  NUM from MCH_COM_SETPLINE t where t.pline_code=?
        ]]>
	</query>
	<query id="HttLoadingService.getquerymaternum" desc="查询相同炉计划ID下待上料支数总和">
        <![CDATA[
SELECT SUM(PLAN_INDOUBLE_NUM) - SUM(REAL_INDOUBLE_NUM) NUM,
	   SUM(PLAN_INDOUBLE_wt) - SUM(REAL_INDOUBLE_wt) WT
  FROM PLN_ZY_RCL_C
 WHERE HEAT_PLAN_NO = ?

        ]]>
	</query>
		<query id="HttLoadingService.querypronum" desc="查询计划从表上料 支数和">
		<![CDATA[
SELECT NVL(SUM(T.ACT_COUNT), 0) PRO_NUM
  FROM PORT_HTT_BATCH_SAMPLE_RESULT T
 WHERE HEAT_PLAN_NO = ?
 AND PROCESS_SEQ =?
		]]>
	</query>
	
		<query id="HttLoadingService.CopyBcMat" desc="复制物料主表到MAT_BC_BACKUP表">
		<![CDATA[
INSERT INTO  MAT_BC_BACKUP SELECT * FROM MAT_BC_M T WHERE T.Mat_No= ?
		]]>
	</query>

	<query id="HttLoadingService.CopyBcMat2" desc="复制物料主表到MAT_BC_BACKUP表">
		<![CDATA[
INSERT INTO MAT_BC_BACKUP_PROCESS
  (MAT_NO,
   PRODUCT_FLAG,
   MAT_STATUS,
   LOT_NO,
   STOVE_NO,
   JUDGE_STOVE_NO,
   BATCH_NO,
   BATCH_GROUD_NO,
   SAMPLE_FLAG,
   MATERIAL_NO,
   MATERIAL_NAME,
   INPUT_MATERIAL_NAME,
   INPUT_MATERIAL_NO,
   PRODUCCODE,
   PRODUCNAME,
   STEELCODE,
   STEELNAME,
   GRADECODE,
   GRADENAME,
   SPEC_CODE,
   SPEC_NAME,
   MODEL_CODE,
   MODEL_DESC,
   STD_CODE,
   STD_NAME,
   STD_STYLE,
   STD_STYLE_DESC,
   PRO_ORDER_NO,
   PRO_ORDER_ID,
   ORDER_NO,
   ORDER_SEQ,
   ORDER_SEQ_NO,
   CRAF_NO,
   PROCESS_CDOE,
   PROCESS_DESC,
   NEXT_PROCESS_CDOE,
   NEXT_PROCESS_DESC,
   PLINE_CODE,
   PLINE_NAME,
   MAT_ORIGIN_CODE,
   MAT_ORIGIN_NAME,
   ACT_DIMATER,
   ACT_HEIGHT,
   ACT_LEN,
   ACT_LEN_MIN,
   ACT_LEN_MAX,
   ACT_COUNT,
   ACT_WEIGHT,
   ACT_THEORY_WEIGHT,
   MEASURE_FLAG,
   BELONG_CODE,
   BELONG_NAME,
   PACK_FLAG,
   MAT_GOWHERE_CODE,
   MAT_GOWHERE_NAME,
   MAT_RETURN_FLAG,
   LOCK_FLAG,
   MNG_LOCK_FLAG,
   JUGDE_APPLY_FLAG,
   JUGDE_APPLY_CODE,
   JUGDE_APPLY_TIME,
   FACE_RESULT_CODE,
   FACE_RESULT_TIME,
   FACE_MAKER,
   SPEC_RESULT_CODE,
   SPEC_RESULT_TIME,
   SPEC_MAKER,
   CHEM_RESULT_CODE,
   CHEM_RESULT_TIME,
   CHEM_MAKER,
   PHY_RESULT_CODE,
   PHY_RESULT_TIME,
   PHY_MAKER,
   DETECT_RESULT_CODE,
   WPRESSURE_RESULT_CODE,
   JUDGE_RESULT_CODE,
   JUDGE_RESULT,
   JUDGE_RESULT_TIME,
   JUDGE_MAKER,
   INSTOCK_FLAG,
   INSTOCK_TIME,
   BAR_CODE,
   MEMO,
   CREATE_NAME,
   CREATE_TIME,
   UPDATE_NAME,
   UPDATE_TIME,
   ORD_PK,
   ORD_LN_PK,
   ORD_LN_DLY_PK,
   BAL_YEAR_MONTH,
   JUDGE_STD_NAME,
   PIPMEMO,
   SOURE_CODE,
   SOURE_NAME,
   PONDER_NO,
   PONDER_GROSS_WT,
   JUDGE_ID,
   LOCK_LIKU,
   QCM_STAUS,
   OUTSTOCK_DOC,
   HEAT_PLAN_NO,
   ZG_STOVE_SQE,
   GX_PLAN_NO,
   ZG_MAT_NO,
   TARGET,
   PROCESS_STATUS,
   JUGDE_CONVICTED,
   FIXTYPE_CODE,
   QUALITY_GROUP_ZG,
   FLAG_STOVE_NO_ZG,
   DETECT_RESULT_CODE1,
   TESTING_GRADE,
   TESTING_TYPE,
   TESTING_GRADE1,
   TESTING_TYPE1,
   JUDGE_STOVE_NO_UP,
   CRAFT_SEQ,
   PRO_PLAN_ID_NEXT,
   GX_PLAN_NO_NEXT,
   HANGING_FLAG,
   CUT_NUM,
   JUDGE_TOLRESULT_CODE,
   JUDGE_TOLRESULT,
   JUDGE_TOLRESULT_TIME,
   JUDGE_TOLMAKER,
   INSTANCY_FLAG,
   JUGDE_TOLCONVICTED,
   JUDGE_STD_DES,
   MNG_LOCK_REMARK,
   LOCK_REMARK,
   JUGDE_APPLY_SEQUENO,
   HEAT_PLAN_NO_NEXT,
   CODE_JG_BL,
   CIC,
   SCRAP_REASON,
   BELONG_CODE_RESPONSE,
   BELONG_NAME_RESPONSE,
   PROCESS_SEQ)
  SELECT MAT_NO,
         PRODUCT_FLAG,
         MAT_STATUS,
         LOT_NO,
         STOVE_NO,
         JUDGE_STOVE_NO,
         BATCH_NO,
         BATCH_GROUD_NO,
         SAMPLE_FLAG,
         MATERIAL_NO,
         MATERIAL_NAME,
         INPUT_MATERIAL_NAME,
         INPUT_MATERIAL_NO,
         PRODUCCODE,
         PRODUCNAME,
         STEELCODE,
         STEELNAME,
         GRADECODE,
         GRADENAME,
         SPEC_CODE,
         SPEC_NAME,
         MODEL_CODE,
         MODEL_DESC,
         STD_CODE,
         STD_NAME,
         STD_STYLE,
         STD_STYLE_DESC,
         PRO_ORDER_NO,
         PRO_ORDER_ID,
         ORDER_NO,
         ORDER_SEQ,
         ORDER_SEQ_NO,
         CRAF_NO,
         PROCESS_CDOE,
         PROCESS_DESC,
         NEXT_PROCESS_CDOE,
         NEXT_PROCESS_DESC,
         PLINE_CODE,
         PLINE_NAME,
         MAT_ORIGIN_CODE,
         MAT_ORIGIN_NAME,
         ACT_DIMATER,
         ACT_HEIGHT,
         ACT_LEN,
         ACT_LEN_MIN,
         ACT_LEN_MAX,
         ACT_COUNT,
         ACT_WEIGHT,
         ACT_THEORY_WEIGHT,
         MEASURE_FLAG,
         BELONG_CODE,
         BELONG_NAME,
         PACK_FLAG,
         MAT_GOWHERE_CODE,
         MAT_GOWHERE_NAME,
         MAT_RETURN_FLAG,
         LOCK_FLAG,
         MNG_LOCK_FLAG,
         JUGDE_APPLY_FLAG,
         JUGDE_APPLY_CODE,
         JUGDE_APPLY_TIME,
         FACE_RESULT_CODE,
         FACE_RESULT_TIME,
         FACE_MAKER,
         SPEC_RESULT_CODE,
         SPEC_RESULT_TIME,
         SPEC_MAKER,
         CHEM_RESULT_CODE,
         CHEM_RESULT_TIME,
         CHEM_MAKER,
         PHY_RESULT_CODE,
         PHY_RESULT_TIME,
         PHY_MAKER,
         DETECT_RESULT_CODE,
         WPRESSURE_RESULT_CODE,
         JUDGE_RESULT_CODE,
         JUDGE_RESULT,
         JUDGE_RESULT_TIME,
         JUDGE_MAKER,
         INSTOCK_FLAG,
         INSTOCK_TIME,
         BAR_CODE,
         MEMO,
         CREATE_NAME,
         CREATE_TIME,
         UPDATE_NAME,
         UPDATE_TIME,
         ORD_PK,
         ORD_LN_PK,
         ORD_LN_DLY_PK,
         BAL_YEAR_MONTH,
         JUDGE_STD_NAME,
         PIPMEMO,
         SOURE_CODE,
         SOURE_NAME,
         PONDER_NO,
         PONDER_GROSS_WT,
         JUDGE_ID,
         LOCK_LIKU,
         QCM_STAUS,
         OUTSTOCK_DOC,
         HEAT_PLAN_NO,
         ZG_STOVE_SQE,
         GX_PLAN_NO,
         ZG_MAT_NO,
         TARGET,
         PROCESS_STATUS,
         JUGDE_CONVICTED,
         FIXTYPE_CODE,
         QUALITY_GROUP_ZG,
         FLAG_STOVE_NO_ZG,
         DETECT_RESULT_CODE1,
         TESTING_GRADE,
         TESTING_TYPE,
         TESTING_GRADE1,
         TESTING_TYPE1,
         JUDGE_STOVE_NO_UP,
         CRAFT_SEQ,
         PRO_PLAN_ID_NEXT,
         GX_PLAN_NO_NEXT,
         HANGING_FLAG,
         CUT_NUM,
         JUDGE_TOLRESULT_CODE,
         JUDGE_TOLRESULT,
         JUDGE_TOLRESULT_TIME,
         JUDGE_TOLMAKER,
         INSTANCY_FLAG,
         JUGDE_TOLCONVICTED,
         JUDGE_STD_DES,
         MNG_LOCK_REMARK,
         LOCK_REMARK,
         JUGDE_APPLY_SEQUENO,
         HEAT_PLAN_NO_NEXT,
         CODE_JG_BL,
         CIC,
         SCRAP_REASON,
         BELONG_CODE_RESPONSE,
         BELONG_NAME_RESPONSE,
         ?
    FROM MAT_BC_M
 T WHERE T.Mat_No= ?
		]]>
	</query>

	<query id="HttLoadingService.DeteleBcMat" desc="删除物料主表">
		<![CDATA[
DELETE MAT_BC_M WHERE Mat_No= ?
		]]>
	</query>
	
	<query id="HttLoadingService.CopyBackup" desc="复制MAT_BC_BACKUP表到物料主表">
		<![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="HttLoadingService.CopyBackup2" desc="复制MAT_BC_BACKUP表到物料主表">
		<![CDATA[
INSERT INTO MAT_BC_M
  (MAT_NO,
   PRODUCT_FLAG,
   MAT_STATUS,
   LOT_NO,
   STOVE_NO,
   JUDGE_STOVE_NO,
   BATCH_NO,
   BATCH_GROUD_NO,
   SAMPLE_FLAG,
   MATERIAL_NO,
   MATERIAL_NAME,
   INPUT_MATERIAL_NAME,
   INPUT_MATERIAL_NO,
   PRODUCCODE,
   PRODUCNAME,
   STEELCODE,
   STEELNAME,
   GRADECODE,
   GRADENAME,
   SPEC_CODE,
   SPEC_NAME,
   MODEL_CODE,
   MODEL_DESC,
   STD_CODE,
   STD_NAME,
   STD_STYLE,
   STD_STYLE_DESC,
   PRO_ORDER_NO,
   PRO_ORDER_ID,
   ORDER_NO,
   ORDER_SEQ,
   ORDER_SEQ_NO,
   CRAF_NO,
   PROCESS_CDOE,
   PROCESS_DESC,
   NEXT_PROCESS_CDOE,
   NEXT_PROCESS_DESC,
   PLINE_CODE,
   PLINE_NAME,
   MAT_ORIGIN_CODE,
   MAT_ORIGIN_NAME,
   ACT_DIMATER,
   ACT_HEIGHT,
   ACT_LEN,
   ACT_LEN_MIN,
   ACT_LEN_MAX,
   ACT_COUNT,
   ACT_WEIGHT,
   ACT_THEORY_WEIGHT,
   MEASURE_FLAG,
   BELONG_CODE,
   BELONG_NAME,
   PACK_FLAG,
   MAT_GOWHERE_CODE,
   MAT_GOWHERE_NAME,
   MAT_RETURN_FLAG,
   LOCK_FLAG,
   MNG_LOCK_FLAG,
   JUGDE_APPLY_FLAG,
   JUGDE_APPLY_CODE,
   JUGDE_APPLY_TIME,
   FACE_RESULT_CODE,
   FACE_RESULT_TIME,
   FACE_MAKER,
   SPEC_RESULT_CODE,
   SPEC_RESULT_TIME,
   SPEC_MAKER,
   CHEM_RESULT_CODE,
   CHEM_RESULT_TIME,
   CHEM_MAKER,
   PHY_RESULT_CODE,
   PHY_RESULT_TIME,
   PHY_MAKER,
   DETECT_RESULT_CODE,
   WPRESSURE_RESULT_CODE,
   JUDGE_RESULT_CODE,
   JUDGE_RESULT,
   JUDGE_RESULT_TIME,
   JUDGE_MAKER,
   INSTOCK_FLAG,
   INSTOCK_TIME,
   BAR_CODE,
   MEMO,
   CREATE_NAME,
   CREATE_TIME,
   UPDATE_NAME,
   UPDATE_TIME,
   ORD_PK,
   ORD_LN_PK,
   ORD_LN_DLY_PK,
   BAL_YEAR_MONTH,
   JUDGE_STD_NAME,
   PIPMEMO,
   SOURE_CODE,
   SOURE_NAME,
   PONDER_NO,
   PONDER_GROSS_WT,
   JUDGE_ID,
   LOCK_LIKU,
   QCM_STAUS,
   OUTSTOCK_DOC,
   HEAT_PLAN_NO,
   ZG_STOVE_SQE,
   GX_PLAN_NO,
   ZG_MAT_NO,
   TARGET,
   PROCESS_STATUS,
   JUGDE_CONVICTED,
   FIXTYPE_CODE,
   QUALITY_GROUP_ZG,
   FLAG_STOVE_NO_ZG,
   DETECT_RESULT_CODE1,
   TESTING_GRADE,
   TESTING_TYPE,
   TESTING_GRADE1,
   TESTING_TYPE1,
   JUDGE_STOVE_NO_UP,
   CRAFT_SEQ,
   PRO_PLAN_ID_NEXT,
   GX_PLAN_NO_NEXT,
   HANGING_FLAG,
   CUT_NUM,
   JUDGE_TOLRESULT_CODE,
   JUDGE_TOLRESULT,
   JUDGE_TOLRESULT_TIME,
   JUDGE_TOLMAKER,
   INSTANCY_FLAG,
   JUGDE_TOLCONVICTED,
   JUDGE_STD_DES,
   MNG_LOCK_REMARK,
   LOCK_REMARK,
   JUGDE_APPLY_SEQUENO,
   HEAT_PLAN_NO_NEXT)
  SELECT MAT_NO,
         PRODUCT_FLAG,
         MAT_STATUS,
         LOT_NO,
         STOVE_NO,
         JUDGE_STOVE_NO,
         BATCH_NO,
         BATCH_GROUD_NO,
         SAMPLE_FLAG,
         MATERIAL_NO,
         MATERIAL_NAME,
         INPUT_MATERIAL_NAME,
         INPUT_MATERIAL_NO,
         PRODUCCODE,
         PRODUCNAME,
         STEELCODE,
         STEELNAME,
         GRADECODE,
         GRADENAME,
         SPEC_CODE,
         SPEC_NAME,
         MODEL_CODE,
         MODEL_DESC,
         STD_CODE,
         STD_NAME,
         STD_STYLE,
         STD_STYLE_DESC,
         PRO_ORDER_NO,
         PRO_ORDER_ID,
         ORDER_NO,
         ORDER_SEQ,
         ORDER_SEQ_NO,
         CRAF_NO,
         PROCESS_CDOE,
         PROCESS_DESC,
         NEXT_PROCESS_CDOE,
         NEXT_PROCESS_DESC,
         PLINE_CODE,
         PLINE_NAME,
         MAT_ORIGIN_CODE,
         MAT_ORIGIN_NAME,
         ACT_DIMATER,
         ACT_HEIGHT,
         ACT_LEN,
         ACT_LEN_MIN,
         ACT_LEN_MAX,
         ACT_COUNT,
         ACT_WEIGHT,
         ACT_THEORY_WEIGHT,
         MEASURE_FLAG,
         BELONG_CODE,
         BELONG_NAME,
         PACK_FLAG,
         MAT_GOWHERE_CODE,
         MAT_GOWHERE_NAME,
         MAT_RETURN_FLAG,
         LOCK_FLAG,
         MNG_LOCK_FLAG,
         JUGDE_APPLY_FLAG,
         JUGDE_APPLY_CODE,
         JUGDE_APPLY_TIME,
         FACE_RESULT_CODE,
         FACE_RESULT_TIME,
         FACE_MAKER,
         SPEC_RESULT_CODE,
         SPEC_RESULT_TIME,
         SPEC_MAKER,
         CHEM_RESULT_CODE,
         CHEM_RESULT_TIME,
         CHEM_MAKER,
         PHY_RESULT_CODE,
         PHY_RESULT_TIME,
         PHY_MAKER,
         DETECT_RESULT_CODE,
         WPRESSURE_RESULT_CODE,
         JUDGE_RESULT_CODE,
         JUDGE_RESULT,
         JUDGE_RESULT_TIME,
         JUDGE_MAKER,
         INSTOCK_FLAG,
         INSTOCK_TIME,
         BAR_CODE,
         MEMO,
         CREATE_NAME,
         CREATE_TIME,
         UPDATE_NAME,
         UPDATE_TIME,
         ORD_PK,
         ORD_LN_PK,
         ORD_LN_DLY_PK,
         BAL_YEAR_MONTH,
         JUDGE_STD_NAME,
         PIPMEMO,
         SOURE_CODE,
         SOURE_NAME,
         PONDER_NO,
         PONDER_GROSS_WT,
         JUDGE_ID,
         LOCK_LIKU,
         QCM_STAUS,
         OUTSTOCK_DOC,
         HEAT_PLAN_NO,
         ZG_STOVE_SQE,
         GX_PLAN_NO,
         ZG_MAT_NO,
         TARGET,
         PROCESS_STATUS,
         JUGDE_CONVICTED,
         FIXTYPE_CODE,
         QUALITY_GROUP_ZG,
         FLAG_STOVE_NO_ZG,
         DETECT_RESULT_CODE1,
         TESTING_GRADE,
         TESTING_TYPE,
         TESTING_GRADE1,
         TESTING_TYPE1,
         JUDGE_STOVE_NO_UP,
         CRAFT_SEQ,
         PRO_PLAN_ID_NEXT,
         GX_PLAN_NO_NEXT,
         HANGING_FLAG,
         CUT_NUM,
         JUDGE_TOLRESULT_CODE,
         JUDGE_TOLRESULT,
         JUDGE_TOLRESULT_TIME,
         JUDGE_TOLMAKER,
         INSTANCY_FLAG,
         JUGDE_TOLCONVICTED,
         JUDGE_STD_DES,
         MNG_LOCK_REMARK,
         LOCK_REMARK,
         JUGDE_APPLY_SEQUENO,
         HEAT_PLAN_NO_NEXT
    FROM MAT_BC_BACKUP_PROCESS T
   WHERE T.MAT_NO = ?
     AND PROCESS_SEQ = ?
		]]>
	</query>
	
	<query id="HttLoadingService.DeteleBackup" desc="删除MAT_BC_BACKUP表">
		<![CDATA[
DELETE MAT_BC_BACKUP WHERE Mat_No= ? AND NEXT_PROCESS_CDOE = 'F'
		]]>
	</query>

	<query id="HttLoadingService.DeteleBackup2" desc="删除MAT_BC_BACKUP表">
		<![CDATA[
DELETE MAT_BC_BACKUP_PROCESS WHERE Mat_No= ? AND PROCESS_SEQ =?
		]]>
	</query>
	
	<query id="HttLoadingService.GetLoadResultByID" desc="上料实绩查询">
        <![CDATA[
       SELECT T.*,
       DECODE(B.STATION_STATUS, '1', '生产中', '2', '生产完成') STATION_STATUS
  FROM HTT_LOADING_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 = ? 
   AND T.HEAT_PLAN_SQE = ?
 ORDER BY T.LOAD_TIME DESC     
        ]]>
	</query>
	
	<query id="HttLoadingService.GetLoadResultByIDPD" desc="判断是否有过上料实绩">
        <![CDATA[
         SELECT * FROM HTT_LOADING_RESULT  WHERE  RCLBATCH_ID=?
        ]]>
	</query>
	
	<query id="HttLoadingService.getQueryWeight" desc="根据上料支数查询重量">
	<![CDATA[
	SELECT  NVL(SUM(T1.ACT_WEIGHT),0) ACT_WEIGHT
  FROM (       SELECT T.MAT_NO,
              T.ACT_LEN,
              NVL(T.PONDER_GROSS_WT, T.ACT_WEIGHT) ACT_WEIGHT,
              '合格' MAT_STATUS,
              '未入库' INSTORE_FLAG
         FROM MAT_BC_M T, YDM_BC_BUTTRESS B
        WHERE T.MAT_NO = B.MAT_NO
          AND T.PRODUCT_FLAG = '801401'
          AND T.MAT_STATUS = '80150103'
          AND T.NEXT_PROCESS_CDOE = 'F'
          AND (T.JUDGE_STOVE_NO, NVL(T.BATCH_NO, '/'),
               NVL(T.BATCH_GROUD_NO, '/')) IN
              (SELECT DECODE(M.REAL_PROCESS_SEQ,
                             1,
                             M.FEED_HEAT_NO,
                             M.JUDGE_STOVE_NO),
                      DECODE(M.REAL_PROCESS_SEQ,
                             1,
                             NVL(?, '/'),
                             (SELECT NVL(CHECK_NO_SHORT, '')
                                FROM COM_BASE_PLINE
                               WHERE PLINE_CODE = M.PLINE_CODE) || '000'),
                      DECODE(M.REAL_PROCESS_SEQ,
                             1,
                             ?,
                             NVL(T.BATCH_GROUD_NO, '/'))
                 FROM PLN_ZY_RCL_M M
                WHERE HEAT_PLAN_NO = ?)
        ORDER BY T.MAT_NO ASC) T1
 WHERE ROWNUM < ?

			]]>
	</query>

	<query id="HttLoadingService.AddLoadResultNew" desc="新增上料实绩">
		<![CDATA[
INSERT INTO HTT_LOADING_RESULT
  (RESULT_NO,
   HEAT_PLAN_NO,
   ZY_BATCH_ID,
   PROD_INDEX,
   PRO_PLAN_ID,
   GX_PLAN_NO,
   PLINE_CODE,
   PLINE_NAME,
   IF_MONITOR_RCL,
   MONITORDEMAND,
   PRDCR_NO,
   PRODUCER,
   PRODUCER_TIME,
   PRO_NUM,
   PRO_WT,
   FAIL_NUM,
   FAIL_WT,
   OFFLINE_NUM,
   OFFLINE_WT,
   RE_NUM,
   RE_WT,
   LOAD_TIME,
   LOAD_SHIFT,
   LOAD_GROUP,
   LOAD_USER,
   CREATE_TIME,
   UPDATE_TIME,
   UPDATE_NAME,
   COL_MODE,
   PROCESS_SEQ,HEAT_PLAN_SQE,MAT_SOURCE,BAL_YEAR_MONTH)
VALUES
  ('#RESULT_NO#',
   '#HEAT_PLAN_NO#',
   '#ZY_BATCH_ID#',
   '#PROD_INDEX#',
   '#PRO_PLAN_ID#',
   '#GX_PLAN_NO#',
   '#PLINE_CODE#',
   '#PLINE_NAME#',
   '#IF_MONITOR_RCL#',
   '#MONITORDEMAND#',
   '#PRDCR_NO#',
   '#PRODUCER#',
   TO_DATE('#PRODUCER_TIME#', 'YYYY-MM-DD HH24:MI:SS'),
   '#PRO_NUM#',
   '#PRO_WT#',
   '#FAIL_NUM#',
    (SELECT  SUM(DEF_FILL_WT) FROM HTT_WASTE_RESULT WHERE RESULT_NO = '#RESULT_NO#' ),
   '#OFFLINE_NUM#',
   '#OFFLINE_WT#',
   '#RE_NUM#',
   '#RE_WT#',
   TO_DATE('#LOAD_TIME#', 'YYYY-MM-DD HH24:MI:SS'),
   '#LOAD_SHIFT#',
   '#LOAD_GROUP#',
   '#LOAD_USER#',
   TO_DATE('#CREATE_TIME#', 'YYYY-MM-DD HH24:MI:SS'),
   TO_DATE('#UPDATE_TIME#', 'YYYY-MM-DD HH24:MI:SS'),
   '#UPDATE_NAME#',
   '#COL_MODE#',
   '#PROCESS_SEQ#','#HEAT_PLAN_SQE#','#MAT_SOURCE#','#BAL_YEAR_MONTH#')
        ]]>
	</query>

	<query id="HttLoadingService.AddLoadResult" desc="新增上料实绩">
        <![CDATA[
   INSERT INTO HTT_LOADING_RESULT (RESULT_NO, ZY_BATCH_ID,  
PRO_PLAN_ID, GX_PLAN_NO, PRO_NUM, PRO_WT, FAIL_NUM, FAIL_WT, OFFLINE_NUM, 
OFFLINE_WT, RE_NUM, RE_WT, LOAD_TIME, LOAD_SHIFT, LOAD_GROUP, LOAD_USER, 
COL_MODE, PLINE_CODE, PLINE_NAME, HEAT_PLAN_NO,CREATE_TIME,PRODUCER,PRODUCER_TIME) 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="HttLoadingService.AddComInfoResult" desc=" 新增公共信息">
        <![CDATA[ 
  INSERT INTO HTT_COM_INFO
    (RESULT_NO,
     ZY_BATCH_ID,
     PRO_PLAN_ID,
     GX_PLAN_NO,
     ORDER_SOURCE,
     ORDER_NO,
     ORDER_SEQ,
     REQ_BL_ID,
     PLINE_CODE,
     PLINE_NAME,
     STATION_CODE,
     STATION_DESC,
     GRADECODE,
     GRADENAME,
     STEELCODE,
     STEELNAME,
     DIMATER,
     HEIGHT,
     ACT_DIMATER,
     ACT_SPEC_CODE,
     ACT_SPEC_NAME,
     LEN,
     ACT_LEN_MIN,
     ACT_LEN_MAX,
     LEN_CUT_HEAD,
     LEN_CUT_END,
     ACT_MATERIAL_NO,
     ACT_MATERIAL_NAME,
     INWL_ID,
     INWL_DESC,
     MONITOR_POINT,
     IF_MONITOR_RCL,
     PRDCR_NO,
     PRODUCER,
     PRODUCER_TIME,
     STATION_ROAD,
     CRAFT_FILE_NO,
     CRAFT_FILE_MAN,
     CRAFT_SEQ,
     PRO_NUM,
     PRO_WT,
     FAIL_NUM,
     FAIL_WT,
     OFFLINE_NUM,
     OFFLINE_WT,
     RE_NUM,
     RE_WT,
     STATION_STATUS,
     RRO_TIME,
     RRO_TIME_NU,
     PRO_USER,
     PRO_SHIFT,
     PRO_GROUP,
     VALIDFLAG,
     CREATE_TIME,
     COL_OPERATOR,
     HEAT_PLAN_NO,
     JUDGE_STOVE_NO,
     BATCH_NO,
     BATCH_GROUD_NO,
     PRODUCCODE,
     PRODUCNAME,
     SPEC_CODE,
     SPEC_NAME,
     PROCESS_SEQ)
  VALUES
    (?,
     ?,
     ?,
     ?,
     ?,
     ?,
     ?,
     ?,
     ?,
     ?,
     ?,
     ?,
     ?,
     ?,
     ?,
     ?,
     ?,
     ?,
     ?,
     ?,
     ?,
     ?,
     ?,
     ?,
     ?,
     ?,
     ?,
     ?,
     ?,
     ?,
     ?,
     ?,
     ?,
     ?,
     TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'),
     ?,
     ?,
     ?,
     ?,
     ?,
     ?,
     ?,
     (SELECT  NVL(SUM(DEF_FILL_WT),0) FROM HTT_WASTE_RESULT WHERE RESULT_NO = ? ),
     ?,
     ?,
     ?,
     ?,
     ?,
     TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'),
     ?,
     ?,
     ?,
     ?,
     ?,
     TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'),
     ?,
     ?,
     ?,
     ?,
     ?,
     ?,
     ?,
     ?,
     ?,
     ?)
        ]]>
	</query>
	<query id="HttLoadingService.updateHttLoadingResult" desc="修改上料实绩">
		<![CDATA[
UPDATE HTT_LOADING_RESULT
   SET PRO_NUM     = ?,
       PRO_WT      = ?,
       LOAD_TIME   = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'),
       LOAD_SHIFT  = ?,
       LOAD_GROUP  = ?,
       UPDATE_NAME = ?,
       UPDATE_TIME = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS')    
 WHERE RESULT_NO = ?
		]]>
	</query>
	<query id="HttLoadingService.updateComInfoResult" desc="修改接箍公共信息">
		<![CDATA[
UPDATE HTT_COM_INFO
   SET PRO_NUM     = ?,
       PRO_WT      = ?,
       RRO_TIME   = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'),
       PRO_SHIFT  = ?,
       PRO_GROUP  = ?
 WHERE RESULT_NO = ?
		]]>
	</query>
	<query id="HttLoadingService.ReturnHttLoadingResult" desc="撤销上料实绩">
		<![CDATA[
		DELETE HTT_LOADING_RESULT WHERE RESULT_NO = ?
		]]>
	</query>
	
	<query id="HttLoadingService.getQueryInfoPlan" desc="查询是否存在上料之后的数据">
	<![CDATA[
	SELECT T.STATION_CODE, T.STATION_DESC
  FROM HTT_COM_INFO T, PLN_ZY_RCL_M M
 WHERE  T.HEAT_PLAN_NO = M.HEAT_PLAN_NO
 AND T.PROCESS_SEQ = M.REAL_PROCESS_SEQ
AND T.STATION_CODE !=?
 AND T.HEAT_PLAN_NO = ?
	]]>
	</query>
	
	<query id="HttLoadingService.DeletePortVrp" desc="删除管号队列记录">
	<![CDATA[
DELETE PORT_HTT_BATCH_SAMPLE_RESULT
 WHERE HEAT_PLAN_NO = ?
   AND MAT_NO = ?
   AND PROCESS_SEQ =?
		]]>
</query>

	<query id="HttLoadingService.DeleteOffline" desc="">
		<![CDATA[
DELETE HTT_OFFLINE_RESULT T
 WHERE HEAT_PLAN_NO = ?
   AND NOT EXISTS (SELECT 1
          FROM PORT_HTT_BATCH_SAMPLE_RESULT
         WHERE HEAT_PLAN_NO = T.HEAT_PLAN_NO AND RESULT_NO= T.RESULT_NO)

		]]>
	</query>

	<query id="HttLoadingService.deleteButter" desc="删除位置表">
	<![CDATA[
 DELETE YDM_BC_BUTTRESS WHERE MAT_NO = ?
	]]>
	</query>
	<query id="HttLoadingService.AddOutList" desc="新增出库记录">
	<![CDATA[
INSERT INTO YDM_BC_OUTLIST
  (OUTSTOCK_SQE,
   OUTSTOCK_PLAN_NO,
   OUTSTOCK_DOC,
   OUTSTOCK_TYPE_CODE,
   OUTSTOCK_TYPE_NAME,
   MAT_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,
   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,
   OUTSTOCK_TIME,
   OUT_BC,
   OUT_BZ,
   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_CODE,
   JUDGE_STD_NAME,
   LOT_NO,
   STOVE_NO,
   LOAD_PLINE_CODE,
   LOAD_PLINE_NAME,
   PRO_ORDER_NO,
   BAL_YEAR_MONTH,
   PROCESS_CDOE,
   PROCESS_DESC)
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'),
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   (SELECT PLINE_NAME FROM COM_BASE_PLINE WHERE PLINE_CODE = ?),
   ?,
   ?,
   ?,
   ?)

	]]>
	</query>
	
	<query id="HttLoadingService.AddOutListQuan" desc="新增产权出库">
	<![CDATA[
INSERT INTO YDM_BC_OUTLIST
  (OUTSTOCK_SQE,
   OUTSTOCK_PLAN_NO,
   OUTSTOCK_DOC,
   OUTSTOCK_TYPE_CODE,
   OUTSTOCK_TYPE_NAME,
   MAT_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,
   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,
   OUTSTOCK_TIME,
   OUT_BC,
   OUT_BZ,
   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_CODE,
   JUDGE_STD_NAME,
   LOT_NO,
   STOVE_NO,
   LOAD_PLINE_CODE,
   LOAD_PLINE_NAME,
   PRO_ORDER_NO,
   BAL_YEAR_MONTH,
   PROCESS_CDOE,
   PROCESS_DESC)
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'),
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   (SELECT PLINE_NAME FROM COM_BASE_PLINE WHERE PLINE_CODE = ?),
   ?,
   ?,
   ?,
   ?)

	]]>
	</query>
	<query id="HttLoadingService.DeleteOutList" desc="删除出库记录">
		<![CDATA[
      DELETE YDM_BC_OUTLIST WHERE OUTSTOCK_SQE = ?  AND OUTSTOCK_TYPE_CODE = '800801'
		]]>
	</query>
	<query id="HttLoadingService.updateMatZcPlan" desc="修改库存状态">
	<![CDATA[
   UPDATE MAT_BC_M T SET T.MAT_STATUS = ? WHERE T.MAT_NO = ?
	]]>
	</query>	
	<query id="HttLoadingService.updateMatZcPlanStuts" desc="修改库存状态">
	<![CDATA[
   UPDATE MAT_BC_BACKUP T SET T.MAT_STATUS = ? WHERE T.MAT_NO = ?
	]]>
	</query>	
	<query id="HttLoadingService.queryYdmOut" desc="查询出库信息">
	<![CDATA[
SELECT OUTSTOCK_SQE,
       OUTSTOCK_PLAN_NO,
       OUTSTOCK_DOC,
       OUTSTOCK_TYPE_CODE,
       OUTSTOCK_TYPE_NAME,
       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,
       DEPARTMENT_CODE,
       DEPARTMENT_DESC,
       ACT_WEIGHT,
       BAL_YEAR_MONTH
  FROM (SELECT *
          FROM YDM_BC_OUTLIST
         WHERE OUTSTOCK_TYPE_CODE = '800801'
           AND JUDGE_STOVE_NO = ?
           AND NVL(BATCH_NO,'/') = NVL(?,'/')
           AND OUTSTOCK_PLAN_NO = ?
         ORDER BY MAT_NO DESC)
 WHERE ROWNUM < ? 
	]]>
	</query>
	
	<query id="HttLoadingService.addButter" 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, create_name, 
create_time, department_code, department_desc) values(?, ?, ?, ?, ?, ?, ?, ?, ?, 
?, ?, ?, ?, ?, ?, to_date(?, 'YYYY-MM-DD HH24:MI:SS'), ?, ?)
		]]>
	</query>
	<query id="HttLoadingService.deleteComInfoResult" desc="撤销上料公共实绩">
		<![CDATA[
		DELETE HTT_COM_INFO WHERE RESULT_NO = ?
		]]>
	</query>
	<query id="HttLoadingService.queryLoadRESULT" 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 TO_CHAR(T.CREATE_TIME, 'YYYY-MM-DD') = ?
   AND T.PLINE_CODE = ?
		]]>
	</query>
		<query id="HttLoadingService.updatePlnZyRclc" desc="新增时修改热处理计划表从表">
		<![CDATA[
UPDATE PLN_ZY_RCL_C C
   SET REAL_INDOUBLE_NUM = TO_NUMBER(NVL(REAL_INDOUBLE_NUM, 0)) + TO_NUMBER(?),
       REAL_INDOUBLE_WT  = TO_NUMBER(NVL(REAL_INDOUBLE_WT, 0)) + TO_NUMBER(?),
         Loadtime = (SELECT MIN(LOAD_TIME) FROM HTT_LOADING_RESULT WHERE HEAT_PLAN_NO = C.HEAT_PLAN_NO AND HEAT_PLAN_SQE = C.HEAT_PLAN_SQE)
WHERE HEAT_PLAN_NO =? AND HEAT_PLAN_SQE =?
		]]>
	</query>
	<query id="HttLoadingService.updatePlnZyRclM" desc="新增时修改热处理计划表">
		<![CDATA[
UPDATE PLN_ZY_RCL_M M
   SET PLANSTATUS  = ?,
       PER_STATUS  = ?,
       IS_BATCH = ?,
         Loadtime = (SELECT MIN(LOAD_TIME) FROM HTT_LOADING_RESULT WHERE HEAT_PLAN_NO = M.HEAT_PLAN_NO)
 WHERE HEAT_PLAN_NO = ?
		]]>
	</query>
		<query id="HttLoadingService.updatePlnZyRclM1" desc="修改时修改热处理计划表">
		<![CDATA[
UPDATE PLN_ZY_RCL_M
   SET REAL_INDOUBLE_NUM = ?,
       REAL_INDOUBLE_WT  = ?
 WHERE HEAT_PLAN_NO = ?
		]]>
	</query>
		<query id="HttLoadingService.deletePlnZyRclc" desc="删除时修改热处理计划表从表">
		<![CDATA[
UPDATE PLN_ZY_RCL_C C
   SET REAL_INDOUBLE_NUM = ?,
       REAL_INDOUBLE_WT  = ?,
         Loadtime = (SELECT MIN(LOAD_TIME) FROM HTT_LOADING_RESULT WHERE HEAT_PLAN_NO = C.HEAT_PLAN_NO AND HEAT_PLAN_SQE = C.HEAT_PLAN_SQE)
WHERE HEAT_PLAN_NO = ? AND HEAT_PLAN_SQE =?
		]]>
	</query>
	<query id="HttLoadingService.deletePlnZyRclM" desc="删除时修改热处理计划表">
		<![CDATA[
UPDATE pln_zy_rcl_m M
   SET PLANSTATUS  = ?,
       PER_STATUS='',
       Loadtime = (SELECT MIN(LOAD_TIME) FROM HTT_LOADING_RESULT WHERE HEAT_PLAN_NO = M.HEAT_PLAN_NO)
 WHERE HEAT_PLAN_NO = ?
		]]>
	</query>
	
	<query id="HttLoadingService.doBeside" desc="修改工序状态为结炉">
		<![CDATA[
		UPDATE HTT_COM_INFO
 SET STATION_STATUS = '2'
WHERE HEAT_PLAN_NO = ?
 AND STATION_CODE = ?
 AND PROCESS_SEQ =?
			]]>
	</query>


	<query id="HttLoadingService.doCancelBeside2" desc="修改工序状态为结炉">
		<![CDATA[
		UPDATE HTT_COM_INFO
 SET STATION_STATUS = '1'
WHERE HEAT_PLAN_NO = ?
 AND PROCESS_SEQ =?
 AND STATION_CODE<> '600201'
			]]>
	</query>

	<query id="HttLoadingService.getQueryOrderRCLS" desc="查询是否上料行">
	<![CDATA[
	SELECT MIN(NVL(T2.GX_PRO_SEQ,0)) GX_PRO_SEQ
  FROM (SELECT TO_NUMBER(T1.GX_PRO_SEQ) GX_PRO_SEQ
          FROM PLN_ORDER_RCL_S T1
         WHERE T1.PLINE_CODE = ?
           AND T1.EXE_STATUS = '0'
           AND T1.IF_STOVE_ISSUED = '1'
           AND TO_NUMBER(T1.GX_PRO_SEQ) >
               (SELECT MAX(TO_NUMBER(T.GX_PRO_SEQ)) GX_PRO_SEQ
                  FROM PLN_ORDER_RCL_S T
                 WHERE T.EXE_STATUS = '1'
                   AND T.PLINE_CODE = ?
                   AND T.IF_STOVE_ISSUED = '1')) T2
	]]>
	</query>
	
	<query id="HttLoadingService.GetQuery1" desc="查询上料支数总和">
        <![CDATA[
   SELECT NVL(SUM(T.PRO_NUM), 0) PRO_NUM FROM HTT_LOADING_RESULT T
   WHERE T.HEAT_PLAN_NO = ?
        ]]>
	</query>

	<query id="HttLoadingService.GetQuery2" desc="查询上料支数总和">
		<![CDATA[
   SELECT NVL(SUM(T.PRO_NUM), 0) PRO_NUM FROM HTT_LOADING_RESULT T
   WHERE T.HEAT_PLAN_NO = ? AND T.PROCESS_SEQ  = ?
        ]]>
	</query>

	<query id="HttLoadingService.qureyGxComInfo" desc="查询工序是否是结炉状态">
		<![CDATA[
SELECT DISTINCT STATION_STATUS
  FROM HTT_COM_INFO
 WHERE HEAT_PLAN_NO = ?
   AND STATION_CODE = ?
   AND (PROCESS_SEQ = ? OR PROCESS_SEQ IS NULL)
			]]>
	</query>
	
	<query id="HttLoadingService.deleteBeside" desc="修改工序状态撤销结炉">
		<![CDATA[
		UPDATE HTT_COM_INFO
 SET STATION_STATUS = '1'
WHERE HEAT_PLAN_NO = ?
 AND STATION_CODE = ?
 AND PROCESS_SEQ =?
			]]>
	</query>
	<query id="HttLoadingService.AddPortVrp" desc="新增管号队列">
		<![CDATA[
		INSERT INTO PORT_HTT_BATCH_SAMPLE_RESULT
  (HEAT_PLAN_NO,
   MAT_NO,
   M_MAT_NO,
   M_M_MAT_NO,
   LOT_NO,
   LOT_NO_SQE,
   PLINE_CODE,
   PLINE_NAME,
   JUDGE_STOVE_NO,
   BATCH_NO,
   GROUP_NO,
   STOVE_NO,
   FLAG_STOVE_NO,
   ACT_DIMATER,
   ACT_HEIGHT,
   ACT_LEN,
   ACT_LEN_MIN,
   ACT_LEN_MAX,
   ACT_COUNT,
   ACT_WEIGHT,
   ACT_THEORY_WEIGHT,  
   OP_PROCESS,
   LEVE_LOG, 
   PRC_TECHNOLOGY_PATH,
   PRO_USER,
   PRO_SHIFT,
   PRO_GROUP,
   PRO_TIME,
   PHY_BATCH_NO,
   HEAT_PLAN_SQE,
   FEED_HEAT_NO,
   PROCESS_SEQ,
   PRO_YEAR_MONTH_DAY,
   BAL_YEAR_MONTH)
VALUES
  (?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,   
   ?,
   ?, 
   ?,  
   ?,
   ?,
   ?,
   TO_DATE(?,'YYYY-MM-DD HH24:MI:SS'),?,?,?,?,?,?)
			]]>
	</query>

	<query id="HttLoadingService.UpdatePortValidflag" desc="查询管号队列里的材料号">
		<![CDATA[
 UPDATE port_htt_batch_sample_result t SET  t.validflag = '0' WHERE t.mat_no = ? AND t.process_seq < ?
	]]>
	</query>

	<query id="HttLoadingService.UpdatePortValidflag2" desc="查询管号队列里的材料号">
		<![CDATA[
 UPDATE port_htt_batch_sample_result t SET  t.validflag = '1' WHERE t.mat_no = ? AND t.process_seq = ?
	]]>
	</query>

	<query id="HttLoadingService.UpdatePortBalYearMonth" desc="查询管号队列里的材料号">
		<![CDATA[
UPDATE PORT_HTT_BATCH_SAMPLE_RESULT T
   SET T.BAL_YEAR_MONTH =
       (SELECT O.BAL_YEAR_MONTH
          FROM PORT_HTT_BATCH_SAMPLE_RESULT O
         WHERE O.HEAT_PLAN_NO = T.HEAT_PLAN_NO
           AND O.MAT_NO = T.MAT_NO
           AND O.PROCESS_SEQ = 1)
 WHERE T.HEAT_PLAN_NO = ?
   AND T.MAT_NO = ?
   AND T.PROCESS_SEQ = ?

	]]>
	</query>

		<query id="HttLoadingService.qureymatno" desc="查询管号队列里的材料号">
	<![CDATA[
   SELECT count(1) count
  FROM PORT_VRP_BATCH_SAMPLE_RESULT
 WHERE  MAT_NO = ?
 AND PROCESS_SEQ =?
	]]>
	</query>
	
	<query id="HttLoadingService.queryOutList" desc="查询出库单号">
	<![CDATA[
SELECT (SELECT S.MEMO FROM COM_BASE_INFO S WHERE S.BASECODE = ?) ||
       OUTSTOCK_DOC OUTSTOCK_DOC
  FROM (SELECT TO_CHAR(SYSDATE, 'YYMMDD') ||
               LPAD(NVL(MAX(SUBSTR(T.OUTSTOCK_DOC, 9)), 0) + 1, 5, 0) OUTSTOCK_DOC
          FROM YDM_BC_OUTLIST T
         WHERE OUTSTOCK_SQE LIKE
               (SELECT S.MEMO FROM COM_BASE_INFO S WHERE S.BASECODE = ?) ||
               TO_CHAR(SYSDATE, 'YYMMDD') || '%')
	]]>
	</query>


	<query id="HttLoadingService.queryZcOutList" desc="查询出库单号">
		<![CDATA[
SELECT (SELECT S.MEMO FROM COM_BASE_INFO S WHERE S.BASECODE = ?) ||
       OUTSTOCK_DOC OUTSTOCK_DOC
  FROM (SELECT TO_CHAR(SYSDATE, 'YYMMDD') ||
               LPAD(NVL(MAX(SUBSTR(T.OUTSTOCK_DOC, 9)), 0) + 1, 5, 0) OUTSTOCK_DOC
          FROM YDM_ZC_OUTLIST T
         WHERE OUTSTOCK_SQE LIKE
               (SELECT S.MEMO FROM COM_BASE_INFO S WHERE S.BASECODE = ?) ||
               TO_CHAR(SYSDATE, 'YYMMDD') || '%')
	]]>
	</query>

	<query id="HttLoadingService.queryInList" desc="查询入库单号">
		<![CDATA[
SELECT (SELECT S.MEMO FROM COM_BASE_INFO S WHERE S.BASECODE = ?) ||
       INSTOCK_DOC INSTOCK_DOC
  FROM (SELECT TO_CHAR(SYSDATE, 'YYMMDD') ||
               LPAD(NVL(MAX(SUBSTR(T.INSTOCK_DOC, 9)), 0) + 1, 5, 0) INSTOCK_DOC
          FROM YDM_BC_INLIST T
         WHERE INSTOCK_SQE LIKE
               (SELECT S.MEMO FROM COM_BASE_INFO S WHERE S.BASECODE = ?) ||
               TO_CHAR(SYSDATE, 'YYMMDD') || '%')
	]]>
	</query>

	<query id="HttLoadingService.queryZcInList" desc="查询入库单号">
		<![CDATA[
SELECT (SELECT S.MEMO FROM COM_BASE_INFO S WHERE S.BASECODE = ?) ||
       INSTOCK_DOC INSTOCK_DOC
  FROM (SELECT TO_CHAR(SYSDATE, 'YYMMDD') ||
               LPAD(NVL(MAX(SUBSTR(T.INSTOCK_DOC, 9)), 0) + 1, 5, 0) INSTOCK_DOC
          FROM YDM_ZC_INLIST T
         WHERE INSTOCK_SQE LIKE
               (SELECT S.MEMO FROM COM_BASE_INFO S WHERE S.BASECODE = ?) ||
               TO_CHAR(SYSDATE, 'YYMMDD') || '%')
	]]>
	</query>

	<query id="HttLoadingService.queryOut" desc="查询出库流水号">
	<![CDATA[
      SELECT ? ||
         LPAD(SUBSTR(NVL(MAX(T.OUTSTOCK_SQE), '0000'), -4, 4) + 1, 4, '0') AS OUTSTOCK_SQE
    FROM YDM_BC_OUTLIST T
   WHERE TO_CHAR(T.CREATE_TIME,'YYYY-MM-DD') = TO_CHAR(SYSDATE, 'YYYY-MM-DD')
     AND T.OUTSTOCK_DOC = ?
	]]>
	</query>

	
	<query id="HttLoadingService.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.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.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_DES,
               T.SOURE_CODE,
               T.SOURE_NAME,
               T.MNG_LOCK_FLAG,
               B.STORAGE_NO,
               B.LOCATION_NO,
               B.LARY_NO,
               B.LOC_NO,
               B.STORAGE_ATTR,
               B.STORAGE_ATTR_NAME,
               B.STORAGE_TYPE_NO,
               B.STORAGE_TYPE_NAME,
               B.MANAGEMENT_NO,
               B.MANAGEMENT_NAME,
               B.DEPARTMENT_CODE,
               B.DEPARTMENT_DESC,
               T.STOVE_NO
          FROM MAT_BC_M T, YDM_BC_BUTTRESS B
         WHERE T.MAT_NO = B.MAT_NO
           AND T.PRODUCT_FLAG = '801401'
           AND T.MAT_STATUS = '80150103'
           AND  NVL(T.JUGDE_APPLY_CODE,'/') =NVL(?, '/')
           AND T.JUDGE_STOVE_NO = ?
           AND NVL(T.BATCH_NO, '/') = NVL(?, '/')
           AND NVL(T.BATCH_GROUD_NO, '/') = NVL(?, '/')
             AND T.HEAT_PLAN_NO_NEXT = ?
       --    AND  B.MANAGEMENT_NO IN
      -- (SELECT DEPARTMENT_CODE FROM COM_BASE_PLINE WHERE PLINE_CODE = ?)
  -- AND STORAGE_ATTR = '800302'
         AND T.NEXT_PROCESS_CDOE = 'F'
         ORDER BY DECODE(B.STORAGE_NO,?,0,1),  NVL(T.LOCK_FLAG,'0'),NVL(T.MNG_LOCK_FLAG,'0'),  T.MAT_NO ASC) T1
 WHERE ROWNUM < ?
		]]>
	</query>

	<query id="HttLoadingService.queryMatZc2" 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.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.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_DES,
               T.SOURE_CODE,
               T.SOURE_NAME,
               T.MNG_LOCK_FLAG,
               B.STORAGE_NO,
               B.LOCATION_NO,
               B.LARY_NO,
               B.LOC_NO,
               B.STORAGE_ATTR,
               B.STORAGE_ATTR_NAME,
               B.STORAGE_TYPE_NO,
               B.STORAGE_TYPE_NAME,
               B.MANAGEMENT_NO,
               B.MANAGEMENT_NAME,
               B.DEPARTMENT_CODE,
               B.DEPARTMENT_DESC,
               T.STOVE_NO
          FROM MAT_BC_M T, YDM_BC_BUTTRESS B
         WHERE T.MAT_NO = B.MAT_NO
           AND T.PRODUCT_FLAG = '801401'
           AND T.MAT_STATUS = '80150103'
           AND T.JUDGE_STOVE_NO = ?
           AND HEAT_PLAN_NO_NEXT = ?
       --    AND  B.MANAGEMENT_NO IN
      -- (SELECT DEPARTMENT_CODE FROM COM_BASE_PLINE WHERE PLINE_CODE = ?)
  -- AND STORAGE_ATTR = '800302'
         AND T.NEXT_PROCESS_CDOE = 'F'
         ORDER BY DECODE(B.STORAGE_NO,?,0,1),  NVL(T.LOCK_FLAG,'0'),NVL(T.MNG_LOCK_FLAG,'0'),  T.MAT_NO ASC) T1
 WHERE ROWNUM < ?
		]]>
	</query>

	<query id="HttLoadingService.UpdatePath" desc="修改队列表工艺路径">
		<![CDATA[
UPDATE PORT_HTT_BATCH_SAMPLE_RESULT T
   SET T.PRC_TECHNOLOGY_PATH = SUBSTR(T.PRC_TECHNOLOGY_PATH, 1,0) || ? ||
                               SUBSTR(T.PRC_TECHNOLOGY_PATH,2, LENGTH(T.PRC_TECHNOLOGY_PATH))
 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="HttLoadingService.doPlnBeside" desc="修改计划表结炉状态">
	<![CDATA[
 UPDATE PLN_ZY_RCL_M SET BESIDE_STATUS = ? WHERE HEAT_PLAN_NO = ?
	]]>
	</query>
	<query id="HttLoadingService.updateMatNoStuts" desc="修改材料表状态">
	<![CDATA[
UPDATE MAT_BC_M
   SET MAT_STATUS       = '80150102',
       HANGING_FLAG     = '0',
       LOCK_LIKU        = '0',
       ORDER_NO         = '',
       ORDER_SEQ        = '',
       ORDER_SEQ_NO     = '',
       ORD_PK           = '',
       ORD_LN_PK        = '',
       ORD_LN_DLY_PK    = '',
       PRO_PLAN_ID_NEXT = '',
       GX_PLAN_NO_NEXT  = ''
 WHERE JUDGE_STOVE_NO = ?
   AND BATCH_NO = ?
   AND BATCH_GROUD_NO = ?
   AND JUGDE_APPLY_CODE = ?
     AND PRODUCT_FLAG = '801401'
         AND MAT_STATUS = '80150103'
      AND NEXT_PROCESS_CDOE = 'F'
	]]>
	</query>
	<query id="HttLoadingService.queryCountRclM" desc="查询计划下剩余上料支、吨">
		<![CDATA[
SELECT COUNT(*) COUNT,NVL(SUM(T.PRO_NUM),0) PRO_NUM,NVL(SUM(T.PRO_WT),0) PRO_WT  FROM HTT_LOADING_RESULT T  WHERE HEAT_PLAN_NO=?
AND HEAT_PLAN_SQE = ?
AND PROCESS_SEQ =1
		]]>
	</query>

	<query id="HttLoadingService.queryMaxProcess" desc="查询计划下管号队列最大循环次数">
		<![CDATA[
SELECT NVL(MAX(PROCESS_SEQ), 1) PROCESS_SEQ
  FROM PORT_HTT_BATCH_SAMPLE_RESULT
 WHERE HEAT_PLAN_NO = ?

		]]>
	</query>

	<query id="HttLoadingService.updateAllFailStatus" desc="将全废品的炉计划置生产完成">
		<![CDATA[
UPDATE PLN_ZY_RCL_M T
  SET PLANSTATUS = '40'
  WHERE HEAT_PLAN_NO = ?
  AND NOT EXISTS (SELECT 1
  FROM PORT_HTT_BATCH_SAMPLE_RESULT
  WHERE HEAT_PLAN_NO = T.HEAT_PLAN_NO
  AND MAT_STATUS <> '10'
  AND MAT_STATUS <> '30'
  AND MAT_STATUS <> '40')
  AND PLANSTATUS = '20'
		]]>
	</query>

	<query id="HttLoadingService.CancelAllFailStatus" desc="将全废品的炉计划置生产完成">
		<![CDATA[
UPDATE PLN_ZY_RCL_M T
  SET PLANSTATUS = '20'
  WHERE HEAT_PLAN_NO = ?
  AND PLANSTATUS = '30'
		]]>
	</query>


	<query id="HttLoadingService.QueryPhyBatchNo" desc="">
		<![CDATA[
	SELECT DISTINCT PHY_BATCH_NO
	FROM PORT_HTT_BATCH_SAMPLE_RESULT T
	WHERE PHY_BATCH_NO IS NOT NULL
	AND HEAT_PLAN_NO =?
	AND PROCESS_SEQ = (SELECT real_process_seq FROM pln_zy_rcl_m WHERE heat_plan_no = t.heat_plan_no) 
		]]>
	</query>

	<query id="HttLoadingService.QueryPortHttByPhyBatch" desc="">
		<![CDATA[
	SELECT *
	FROM PORT_HTT_BATCH_SAMPLE_RESULT
	WHERE HEAT_PLAN_NO =?
	AND PHY_BATCH_NO = ?
	AND BAR_CODE  IS NULL
	AND (MAT_STATUS = '00' OR MAT_STATUS = '20' OR OP_PROCESS>'600209')
		]]>
	</query>


	<query id="HttLoadingService.QueryMaxBarCode" desc="">
		<![CDATA[
  SELECT SUBSTR(NVL(MAX(T.BAR_CODE), '000'), -3, 3) + 1 AS MaxSeq
    FROM PORT_HTT_BATCH_SAMPLE_RESULT T
   WHERE HEAT_PLAN_NO = ?
     AND PHY_BATCH_NO = ?
      AND PROCESS_SEQ = (SELECT real_process_seq FROM pln_zy_rcl_m WHERE heat_plan_no = t.heat_plan_no)
		]]>
	</query>


	<query id="HttLoadingService.QueryOldBatchNo" desc="">
		<![CDATA[
 SELECT BATCH_NO FROM PLN_ZY_RCL_C  WHERE JUDGE_STOVE_NO=? AND BATCH_NO <> ? AND ROWNUM = 1
		]]>
	</query>

</queryMap>