<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="">
	<query id="PlanLuRCL.queryOrderRCL" desc="查询PLN_Order_RCL_S表">
             <![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,
       t.PLAN_TIME_B,
       t.ADD_WT_IN,
       t.ADD_NUM_IN,
       t.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, 
       Decode(t.MCount,0,'无','有') as MStatus,
       t.MCount from (SELECT 
       S.PRO_ORDER_NO,
       S.PRO_PLAN_ID,
       S.GX_PLAN_NO,
       S.PLAN_GROUP_ID,
       S.ORDER_SOURCE,
       S.ORD_LN_DLY_PK,
       S.PLN_DIVIDE_ID,
       S.ORDER_NO,
       S.ORDER_SEQ,
       S.DELIVERY_NO,
       S.REQ_BL_ID,
       S.PLINE_CODE,
       S.PLINE_NAME,
       S.INWL_ID,
       S.INWL_DESC,
       S.OUTWL_ID,
       S.OUTWL_DESC,
       S.GRADECODE,
       S.GRADENAME,
       S.OUTDIAMETER,
       S.WALLTHICK,
       S.LENGTHDISC,
       S.LENGTHMAX_IN,
       S.LENGTHMIN_IN,
       S.LENGTH_IN,
       S.AIMLENGTH,
       S.IN_WEIGHT_S,
       S.IN_NUM_S,
       S.WEIGTH_S,
       S.NUM_S,
       S.MATCH_WT_IN,
       S.MATCH_NUM_IN,
       DECODE(S.IF_MONITOR_RCL,'0','否','1'，'是') IF_MONITOR_RCL,
       S.PRDCR_NO,
       S.MONITOR_POINT,
       S.CRAFT_FILE_NO,
       S.CRAFT_FILE_MAN,
       S.CRAFT_SEQ,
       S.STATION_ROAD,
       S.GX_PRO_SEQ,
       S.PLAN_USETIME,
       TO_CHAR(S.PLAN_TIME_B, 'YYYY-MM-DD HH24:MI:SS') PLAN_TIME_B,
       TO_CHAR(S.PLAN_TIME_E, 'YYYY-MM-DD HH24:MI:SS') PLAN_TIME_E,
       S.BATCHED_WT,
       S.BATCHED_NUM,
       S.FINISHWEIGHT,
       S.FINISHNUM,
       DECODE(S.EXE_STATUS,'0','计划','1','生产中','2','完成','3','关闭A') EXE_STATUS,
       (SELECT count(T.MAT_NO)
      FROM MAT_ZC_M T, YDM_ZC_BUTTRESS T1
     WHERE T.MAT_NO = T1.MAT_NO
          AND T.PRODUCT_FLAG ='801401'
               AND T.MAT_STATUS='80150102'
               AND T.MNG_LOCK_FLAG='0'
               AND T.LOCK_FLAG = '0'
               AND T.PRO_ORDER_ID is null
       AND T.MATERIAL_NO = S.INWL_ID
		    AND T1.STORAGE_NO  in (select a.storage_no
			  from ydm_bs_storage a,
			  (select b.department_code,b.department_code_p  from com_base_pline b where b.process_code = 'F' ) c 
			  where a.storage_attr = '800304' 
			   and  a.storage_type_no = '800202' 
			      and a.management_no = c.department_code 
			   and a.department_code = c.department_code_p )) MCount,
       DECODE(S.IS_REPAIR_PLN,'0','否','1'，'是') IS_REPAIR_PLN,
       S.REPAIR_TYPE,
       S.ZY_BATCH_ID,
       S.ADD_WT_IN,
       S.ADD_NUM_IN,
       DECODE(S.ISENDGX,'0','否','1'，'是') ISENDGX,
       S.CIC,
       S.PIC,
       S.SIC,
       S.DIC,
       S.WIC,
       S.GIC,
       DECODE(S.IS_PLAN_OK,'0','否','1'，'是') IS_PLAN_OK,
       S.STEELCODE,
       S.STEELNAME,
       S.PRO_MONTH,
       S.PREVIOUS_GX,
       S.PREV_GXPLAN_ID
 FROM PLN_ORDER_RCL_S S) t
                 ]]>
	</query>
	<query id="PlanLuRCL.queryZyRCL" desc="查询PLN_ZY_RCL_M表">
             <![CDATA[
			SELECT 
			BATCH_GROUD_NO,
       OUT_NUM_REAL,
       HEAT_PLAN_NO,
       ZY_BATCH_ID,
       PROD_INDEX,
       PRO_PLAN_ID,
       GX_PLAN_NO,
       GX_NAME_LAST,
       LAST_HEAT_PLAN_NO,
       HEATNO_LAST,
       LAST_BATCH_NO,
       PLINE_CODE,
       PLINE_NAME,
       DECODE(ISENDGX,'0','否','1'，'是') 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,
       DECODE(IF_WL_MATCHED,'0','否','1'，'是') IF_WL_MATCHED,
       OUTWL_ID,
       OUTWL_DESC,
       OUT_WT,
       OUT_NUM,
       DECODE(IF_MONITOR_RCL,'0','否','1'，'是') IF_MONITOR_RCL,
       PRDCR_NO,
       MONITOR_POINT,
       CRAFT_FILE_NO,
       CRAFT_FILE_MAN,
       CRAFT_SEQ,
       STATION_ROAD,
       DECODE(PLANSTATUS,'0','计划','1','下发','2','生产中','3','生产完成','4','关闭A') PLANSTATUS,
       CREATE_NAME,
       TO_CHAR(CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       UPDATE_NAME,
       TO_CHAR(UPDATE_TIME, 'YYYY-MM-DD HH24:MI:SS') UPDATE_TIME,
       IN_WT_REAL,
       IN_NUM_REAL,
       OUT_WT_REAL
 FROM PLN_ZY_RCL_M             ]]>
	</query>
	<query id="PlanLuRCL.AddNewRows" desc="插入PLN_ZY_RCL_M表">
             <![CDATA[
                 INSERT INTO PLN_ZY_RCL_M(
        BATCH_GROUD_NO,
        OUT_NUM_REAL,
        HEAT_PLAN_NO,
        ZY_BATCH_ID,
        PROD_INDEX,
        PRO_PLAN_ID,
        GX_PLAN_NO,
        GX_NAME_LAST,
        LAST_HEAT_PLAN_NO,
        HEATNO_LAST,
        LAST_BATCH_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,
        STATION_ROAD,
        PLANSTATUS,
        CREATE_NAME,
        CREATE_TIME,
        UPDATE_NAME,
        UPDATE_TIME,
        IN_WT_REAL,
        IN_NUM_REAL,
        OUT_WT_REAL)
 VALUES( 
        '#BATCH_GROUD_NO#',
        '#OUT_NUM_REAL#',
        '#HEAT_PLAN_NO#',
        '#ZY_BATCH_ID#',
        '#PROD_INDEX#',
        '#PRO_PLAN_ID#',
        '#GX_PLAN_NO#',
        '#GX_NAME_LAST#',
        '#LAST_HEAT_PLAN_NO#',
        '#HEATNO_LAST#',
        '#LAST_BATCH_NO#',
        '#PLINE_CODE#',
        '#PLINE_NAME#',
        DECODE('#ISENDGX#','否','0','是'，'1'，'#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#',
        DECODE('#IF_WL_MATCHED#','否','0','是'，'1'，'#IF_WL_MATCHED#'),
        '#OUTWL_ID#',
        '#OUTWL_DESC#',
        '#OUT_WT#',
        '#OUT_NUM#',
        DECODE('#IF_MONITOR_RCL#','否','0','是'，'1'，'#IF_MONITOR_RCL#'),
        '#PRDCR_NO#',
        '#MONITOR_POINT#',
        '#CRAFT_FILE_NO#',
        '#CRAFT_FILE_MAN#',
        '#CRAFT_SEQ#',
        '#STATION_ROAD#',
        DECODE('#PLANSTATUS#','计划','0','下发','1','生产中','2','生产完成','3','关闭A','4','#PLANSTATUS#'),
        '#CREATE_NAME#',
        SYSDATE,
        '#UPDATE_NAME#',
        '',
        '#IN_WT_REAL#',
        '#IN_NUM_REAL#',
        '#OUT_WT_REAL#')


		         ]]>  
	</query>
	<query id="PlanLuRCL.UpdateRCLORDER_WT_NUM" desc="更新PLN_ORDER_RCL_S表炉计划已排量">
             <![CDATA[
                UPDATE PLN_ORDER_RCL_S
				   SET 
				        BATCHED_WT = ?,
				        BATCHED_NUM = ?
				 WHERE
				 PRO_PLAN_ID = ? and
				        GX_PLAN_NO = ?
			         ]]>  
	</query>
	<query id="PlanLuRCL.UpdateOrderRCL_MATCH_WT_NUM" desc="更新PLN_Order_DBK_S表投入利库量">
             <![CDATA[
               	 UPDATE PLN_ORDER_RCL_S
				   SET 
				         Match_Wt_In = ?,
			        Match_Num_In = ?
				 WHERE
				 PRO_PLAN_ID = ? and
				        GX_PLAN_NO = ?
                 ]]>
	</query>
	<query id="PlanLuRCL.UpdateZYRCL_WT_NUM" desc="更新PLN_ZY_RCL_M的投入和产出量">
             <![CDATA[
               	 UPDATE PLN_ZY_RCL_M
				   SET 
				        IN_WT = ?,
				        IN_NUM = ?,
				        OUT_NUM=?,
				        OUT_WT=?,
				        UPDATE_NAME=?,
				        UPDATE_TIME = SYSDATE
				 WHERE
				 		HEAT_PLAN_NO=?
                 ]]>
	</query>
	<query id="PlanLuRCL.queryMaxHeat_Plan_No" desc="查询PLN_ZY_RCL_M表最大的">
             <![CDATA[
               select max(to_number("SUBSTR"(HEAT_PLAN_NO, 10, 4))) as num FROM(select HEAT_PLAN_NO from PLN_ZY_RCL_M t where to_char(t.CREATE_TIME,'yyyymmdd')=to_char(sysdate,'yyyymmdd'))
            ]]>     
	</query>
	<query id="PlanLuRCL.deleteZyRclM" desc="删除指定的PLN_ZY_RCL_M行">
             <![CDATA[
               DELETE FROM PLN_ZY_RCL_M WHERE HEAT_PLAN_NO = ?
			         ]]>  
	</query>
</queryMap>