<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="自动生成热处理炉计划类">

	<query id="GeneratePlanStoveF.getQcmZgJugdeApply" desc="查询钢管申请判定表">
            <![CDATA[
         SELECT 
       T.JUGDE_APPLY_CODE,
       T.JUDGE_STOVE_NO,
       T.BATCH_NO,
       T.BATCH_GROUD_NO,
       T.PROCESS_CODE,
       T.PLINE_CODE,
       T.ACT_COUNT,
       T.ACT_WEIGHT,
       T.ACT_THEORY_WEIGHT,
       T.PRO_ORDER_ID,
       T.FACE_RESULT_CODE,
       T.SPEC_RESULT_CODE,
       T.CHEM_RESULT_CODE,
       T.PHY_RESULT_CODE,
       T.DETECT_RESULT_CODE,
       T.WPRESSURE_RESULT_CODE,
       T.PROCESS_RESULT_CODE,
       T.FACE_RESULT_PATH,
       T.SPEC_RESULT_PATH,
       T.CHEM_RESULT_PATH,
       T.PHY_RESULT_PATH,
       T.DETECT_RESULT_PATH,
       T.WPRESSURE_RESULT_PATH,
       T.PROCESS_RESULT_PATH,
       T.VALIDFLAG,
       T.APPLY_NAME,
       TO_CHAR(T.APPLY_TIME, 'YYYY-MM-DD HH24:MI:SS') APPLY_TIME,
       T.MEMO,
       T.QUALITY_GROUP,
       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.CRAF_NO,
       T.LOT_NO,
       T.PLINE_NAME,
       T.PRO_ORDER_NO,
       T.TARGET,
       T.PROCESS_STATUS,
       T.MAT_GOWHERE_CODE,
       T.MAT_GOWHERE_NAME,
       T.ACT_DIMATER,
       T.ACT_HEIGHT,
       T.ACT_LEN_MIN,
       T.ACT_LEN_MAX,
       T.JUDGE_RESULT_CODE,
       T.JUDGE_RESULT,
       TO_CHAR(T.JUDGE_RESULT_TIME, 'YYYY-MM-DD HH24:MI:SS') JUDGE_RESULT_TIME,
       T.JUDGE_MAKER,
       T.IF_SET_ZY_PLAN
 FROM QCM_ZG_JUGDE_APPLY T
 WHERE 1=1
              ]]>
	</query>

	<query id="GeneratePlanStoveF.getPlnOrderRclSEntity" desc="查询热处理排产">
            <![CDATA[
          SELECT 
       T.PRO_ORDER_NO,
       T.PRO_PLAN_ID,
       T.GX_PLAN_NO,
       T.PLAN_GROUP_ID,
       T.ORDER_SOURCE,
       T.ORD_LN_DLY_PK,
       T.PLN_DIVIDE_ID,
       T.ORDER_NO,
       T.ORDER_SEQ,
       T.DELIVERY_NO,
       T.REQ_BL_ID,
       T.PLINE_CODE,
       T.PLINE_NAME,
       T.INWL_ID,
       T.INWL_DESC,
       T.OUTWL_ID,
       T.OUTWL_DESC,
       T.GRADECODE,
       T.GRADENAME,
       T.OUTDIAMETER,
       T.WALLTHICK,
       T.LENGTHDISC,
       T.LENGTHMAX_IN,
       T.LENGTHMIN_IN,
       T.LENGTH_IN,
       T.AIMLENGTH,
       T.IN_WEIGHT_S,
       T.IN_NUM_S,
       T.WEIGTH_S,
       T.NUM_S,
       T.MATCH_WT_IN,
       T.MATCH_NUM_IN,
       T.IF_MONITOR_RCL,
       T.PRDCR_NO,
       T.MONITOR_POINT,
       T.CRAFT_FILE_NO,
       T.CRAFT_FILE_MAN,
       T.CRAFT_SEQ,
       T.STATION_ROAD,
       T.GX_PRO_SEQ,
       T.PLAN_USETIME,
       TO_CHAR(T.PLAN_TIME_B, 'YYYY-MM-DD HH24:MI:SS') PLAN_TIME_B,
       TO_CHAR(T.PLAN_TIME_E, 'YYYY-MM-DD HH24:MI:SS') PLAN_TIME_E,
       T.BATCHED_WT,
       T.BATCHED_NUM,
       T.FINISHWEIGHT,
       T.FINISHNUM,
       T.EXE_STATUS,
       T.IS_REPAIR_PLN,
       T.REPAIR_TYPE,
       T.ZY_BATCH_ID,
       T.ADD_WT_IN,
       T.ADD_NUM_IN,
       T.ISENDGX,
       T.CIC,
       T.PIC,
       T.SIC,
       T.DIC,
       T.WIC,
       T.GIC,
       T.IS_PLAN_OK,
       T.STEELCODE,
       T.STEELNAME,
       T.PRO_MONTH,
       T.PREVIOUS_GX,
       T.PREV_GXPLAN_ID,
       T.IF_EXPORT,
       TO_CHAR(T.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       T.MEMO,
       TO_CHAR(T.ISSUED_TIME, 'YYYY-MM-DD HH24:MI:SS') ISSUED_TIME,
       T.ISSUED_MAN,
       TO_CHAR(T.LAST_UNDOWN_TIME, 'YYYY-MM-DD HH24:MI:SS') LAST_UNDOWN_TIME,
       T.LAST_UNDOWN_MAN,
       T.VERSION_NO,
       T.PROCESSING_COST,
       T.TOTAL_COST,
       T.IF_STOVE_ISSUED,
       TO_CHAR(T.STOVE_ISSUED_TIME, 'YYYY-MM-DD HH24:MI:SS') STOVE_ISSUED_TIME,
       T.STOVE_ISSUED_MAN,
       T.IS_ONLOAD_LINE,
       T.PROCESS_CODE_C,
       T.PROCESS_DESC_C
 FROM PLN_ORDER_RCL_S T
 WHERE
T.PRO_PLAN_ID  in (SELECT T1.PRO_PLAN_ID
                          FROM PLN_ORDER_DBK T1,PLN_ORDER_ZG T2
                         WHERE T1.PLAN_GROUP_ID=T2.Plan_Group_Id AND T2.PRO_PLAN_ID=? )
 ORDER BY T.PLAN_TIME_B  
              ]]>
	</query>

	<query id="GeneratePlanStoveF.getPlnZyRclReadyEntity" desc="查询热处理虚拟炉计划">
            <![CDATA[
     SELECT 
       T.PRO_PLAN_ID,
       T.GX_PLAN_NO,
       T.READY_PLAN_NO,
       T.ZY_BATCH_ID,
       T.PLINE_CODE,
       T.PLINE_NAME,
       T.PREVIOUS_GX,
       T.ZG_HEAT_PLAN_NO,
       T.DBK_HEAT_PLAN_NO,
       T.JUDGE_STOVE_NO,
       T.LAST_BATCH_NO,
       T.BATCH_GROUD_NO,
       T.ORDER_SOURCE,
       T.ORD_LN_DLY_PK,
       T.ORDER_NO,
       T.ORDER_SEQ,
       T.DELIVERY_NO,
       T.REQ_BL_ID,
       T.OUTWL_ID,
       T.OUTWL_DESC,
       T.ALLOT_NUM,
       T.ALLOT_WT,
       T.IF_MATCH_ODD,
       T.IF_DO_HEAT_PLAN,
       TO_CHAR(T.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       T.REAL_ALLOT_NUM,
       T.REAL_ALLOT_WT,
       T.REAL_STOVE_NO,
       T.CRAFT_FILE_NO,
       T.CRAFT_SEQ,
       T.SEC_CRAFT_FILE_NO,
       T.OUT_JUDGE_STD
 FROM PLN_ZY_RCL_READY T
 WHERE 1=1
              ]]>
	</query>
	<query id="GeneratePlanStoveF.addPlnZyRclReadyEntity" desc="新增作业计划">
            <![CDATA[
           INSERT INTO PLN_ZY_RCL_M(
        HEAT_PLAN_NO,
        ZY_BATCH_ID,
        PROD_INDEX,
        PRO_PLAN_ID,
        GX_PLAN_NO,
        READY_PLAN_NO,
        GX_NAME_LAST,
        LAST_HEAT_PLAN_NO,
        HEATNO_LAST,
        LAST_BATCH_NO,
        BATCH_GROUD_NO,
        PLINE_CODE,
        PLINE_NAME,
        ISENDGX,
        ORDER_SOURCE,
        ORD_LN_DLY_PK,
        ORDER_NO,
        ORDER_SEQ,
        DELIVERY_NO,
        REQ_BL_ID,
        STEELCODE,
        STEELNAME,
        GRADECODE,
        GRADENAME,
        OUTDIAMETER,
        WALLTHICK,
        LENGTHDISC,
        CP_LENGTHMIN,
        CP_LENGTHMAX,
        OUTDIAMETER_IN,
        WALLTHICK_IN,
        LENGTH_IN,
        LENGTHMAX_IN,
        LENGTHMIN_IN,
        LENGTH_OUT,
        INWL_ID,
        INWL_DESC,
        IN_WT,
        IN_NUM,
        IF_WL_MATCHED,
        OUTWL_ID,
        OUTWL_DESC,
        OUT_WT,
        OUT_NUM,
        IF_MONITOR_RCL,
        PRDCR_NO,
        MONITOR_POINT,
        CRAFT_FILE_NO,
        CRAFT_FILE_MAN,
        CRAFT_SEQ,
        SEC_CRAFT_FILE_NO,
        STATION_ROAD,
        PLANSTATUS,
        CREATE_NAME,
        CREATE_TIME,
        UPDATE_NAME,
        UPDATE_TIME,
        IN_WT_REAL,
        IN_NUM_REAL,
        OUT_WT_REAL,
        OUT_NUM_REAL,
        IN_JUDGE_STD,
        PER_STATUS,
        BESIDE_STATUS,
        STORAGE_NO1,
        STORAGE_NAME1,
        STORAGE_NO2,
        STORAGE_NAME2,
        JUGDE_APPLY_CODE,
        QUALITY_GROUP,
        MAT_GOWHERE_CODE)
 VALUES( 
        '#HEAT_PLAN_NO#',
        '#ZY_BATCH_ID#',
        '#PROD_INDEX#',
        '#PRO_PLAN_ID#',
        '#GX_PLAN_NO#',
        '#READY_PLAN_NO#',
        '#GX_NAME_LAST#',
        '#LAST_HEAT_PLAN_NO#',
        '#HEATNO_LAST#',
        '#LAST_BATCH_NO#',
        '#BATCH_GROUD_NO#',
        '#PLINE_CODE#',
        '#PLINE_NAME#',
        '#ISENDGX#',
        '#ORDER_SOURCE#',
        '#ORD_LN_DLY_PK#',
        '#ORDER_NO#',
        '#ORDER_SEQ#',
        '#DELIVERY_NO#',
        '#REQ_BL_ID#',
        '#STEELCODE#',
        '#STEELNAME#',
        '#GRADECODE#',
        '#GRADENAME#',
        '#OUTDIAMETER#',
        '#WALLTHICK#',
        '#LENGTHDISC#',
        '#CP_LENGTHMIN#',
        '#CP_LENGTHMAX#',
        '#OUTDIAMETER_IN#',
        '#WALLTHICK_IN#',
        '#LENGTH_IN#',
        '#LENGTHMAX_IN#',
        '#LENGTHMIN_IN#',
        '#LENGTH_OUT#',
        '#INWL_ID#',
        '#INWL_DESC#',
        '#IN_WT#',
        '#IN_NUM#',
        '#IF_WL_MATCHED#',
        '#OUTWL_ID#',
        '#OUTWL_DESC#',
        '#OUT_WT#',
        '#OUT_NUM#',
        '#IF_MONITOR_RCL#',
        '#PRDCR_NO#',
        '#MONITOR_POINT#',
        '#CRAFT_FILE_NO#',
        '#CRAFT_FILE_MAN#',
        '#CRAFT_SEQ#',
        '#SEC_CRAFT_FILE_NO#',
        '#STATION_ROAD#',
        '#PLANSTATUS#',
        '#CREATE_NAME#',
        SYSDATE,
        '#UPDATE_NAME#',
        NULL,
        '#IN_WT_REAL#',
        '#IN_NUM_REAL#',
        '#OUT_WT_REAL#',
        '#OUT_NUM_REAL#',
        '#IN_JUDGE_STD#',
        '#PER_STATUS#',
        '#BESIDE_STATUS#',
        '#STORAGE_NO1#',
        '#STORAGE_NAME1#',
        '#STORAGE_NO2#',
        '#STORAGE_NAME2#',
        '#JUGDE_APPLY_CODE#',
        '#QUALITY_GROUP#',
        '#MAT_GOWHERE_CODE#')
              ]]>
	</query>

	<query id="GeneratePlanStoveF.updatePlnZyRclReady" desc="修改热处理虚拟炉计划">
            <![CDATA[
                UPDATE PLN_ZY_RCL_READY T
   SET T.REAL_ALLOT_NUM  = NVL(T.REAL_ALLOT_NUM, 0) + TO_NUMBER(?),
       T.REAL_ALLOT_WT   = NVL(T.REAL_ALLOT_WT, 0) + TO_NUMBER(?),
       T.IF_DO_HEAT_PLAN = '1'
 WHERE T.PRO_PLAN_ID = ?
   AND T.GX_PLAN_NO = ?
   AND T.READY_PLAN_NO = ?      
              ]]>
	</query>

	<query id="GeneratePlanStoveF.updateMatZcM" desc="修改库存数据">
            <![CDATA[
    update MAT_ZC_M T
   SET T.MAT_STATUS        = ?,
       T.HTT_HEAT_PLAN_NO  = ?,
       T.HTT_PRO_ORDER_ID  = ?,
       T.HTT_GX_PLAN_NO    = ?,
       T.HTT_PRO_ORDER_ID1 = T.HTT_PRO_ORDER_ID,
       T.HTT_GX_PLAN_NO1   = T.HTT_GX_PLAN_NO
 WHERE T.MAT_NO = ?
              ]]>
	</query>

	<query id="GeneratePlanStoveF.queryMatZcMNo" desc="查询库存数据ID">
            <![CDATA[
           SELECT T.MAT_NO
  FROM MAT_ZC_M T
 WHERE T.JUGDE_APPLY_CODE = ?
   AND T.JUDGE_STOVE_NO = ?
   AND T.BATCH_NO = ?
   AND T.BATCH_GROUD_NO = ?
   AND T.QUALITY_GROUP_ZG = ?
   AND T.MAT_GOWHERE_CODE=?
 ORDER BY T.MAT_NO
              ]]>
	</query>


	<query id="GeneratePlanStoveF.updateQcmZgJugdeApply" desc="修改钢管申请判定表">
            <![CDATA[
   UPDATE QCM_ZG_JUGDE_APPLY T
   SET T.IF_SET_ZY_PLAN = '1'
 WHERE T.JUGDE_APPLY_CODE = ?
   AND T.JUDGE_STOVE_NO = ?
   AND T.BATCH_NO = ?
   AND T.BATCH_GROUD_NO = ?
   AND T.QUALITY_GROUP = ?
              ]]>
	</query>

	<query id="GeneratePlanStoveF.updatePlnOrderRclSRealBatch" desc="修改排产实际挂料">
            <![CDATA[
UPDATE PLN_ORDER_RCL_S T
   SET T.REAL_BATCH_NUM = NVL(TO_NUMBER(T.REAL_BATCH_NUM), 0) + TO_NUMBER(?),
       T.REAL_BATCH_WT  = NVL(TO_NUMBER(T.REAL_BATCH_WT), 0) + TO_NUMBER(?)
 WHERE T.PRO_PLAN_ID = ?
   AND T.GX_PLAN_NO = ?
              ]]>
	</query>

	<query id="GeneratePlanStoveF.getStorageNo" desc="查询仓库号">
            <![CDATA[
SELECT T1.STORAGE_NO,
       (SELECT T2.STORAGE_NAME
          FROM YDM_BS_STORAGE T2
         WHERE T2.STORAGE_NO = T1.STORAGE_NO) STORAGE_NAME
  FROM MAT_ZC_M T, YDM_ZC_BUTTRESS T1
 WHERE T.MAT_NO = T1.MAT_NO
   AND T.JUGDE_APPLY_CODE = ?
   AND T.JUDGE_STOVE_NO = ?
   AND T.BATCH_NO = ?
   AND T.BATCH_GROUD_NO = ?
   AND T.QUALITY_GROUP_ZG = ?
   AND T.MAT_GOWHERE_CODE = ?
 GROUP BY T1.STORAGE_NO
              ]]>
	</query>


	<query id="GeneratePlanStoveF.getMaxHeatPlanNoF" desc="查询炉号最大序号">
            <![CDATA[
           SELECT TO_NUMBER(SUBSTR(NVL(MAX(T.HEAT_PLAN_NO), 'D000000000000'), 10, 4)) + 1 AS HEAT_PLAN_NO
  FROM PLN_ZY_RCL_M T
 WHERE SUBSTR(T.HEAT_PLAN_NO, 2, 8) = ?
              ]]>
	</query>

	<query id="GeneratePlanStoveF.getProdIndexF" desc="查询最大批次生产序号">
            <![CDATA[
            SELECT TO_NUMBER(NVL(MAX(T.PROD_INDEX), '0')) + 1 PROD_INDEX
  FROM PLN_ZY_RCL_M T
 WHERE T.ZY_BATCH_ID = ?
              ]]>
	</query>


</queryMap>