<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="">
	<query id="PlanLuZG.queryZYZGM" desc="查询PLN_ZY_ZG_M表">
             <![CDATA[
                SELECT 
       HEAT_PLAN_NO,
       ZY_BATCH_ID,
       PROD_INDEX,
       PRO_PLAN_ID,
       GX_PLAN_NO,
       GPREQ_ID,
       HEATNO_LAST,
       PLINE_CODE,
       PLINE_NAME,
       DECODE(ISENDGX,'0','否','1'，'是') ISENDGX,
       ORDER_SOURCE,
       ORD_LN_DLY_PK,
       ORDER_NO,
       ORDER_SEQ,
       DELIVERY_NO,
       REQ_BL_ID,
       GRADECODE,
       GRADENAME,
       LEN_ROLL_MAX,
       LEN_ROLL_MIN,
       AIMOUTDIAMETER,
       AIMWALLTHICK,
       AIMLENGTH,
       DIAMETER_GP,
       LENGTH_GP,
       LEN_GP_SINGLE,
       ROLL_LENGTH,
       LEN_CUTHEAD,
       LEN_CUTEND,
       OUTNUM_CUT,
       DIAMETER_MANDREL,
       PASS_CODE,
       PASS_NAME,
       INWL_ID,
       INWL_DESC,
       CUT_SINGLE_WT,
       CUT_SINGLE_NUM,
       DECODE(IF_WL_MATCHED,'0','否','1'，'是') IF_WL_MATCHED,
       OUTWL_ID,
       OUTWL_DESC,
       OUT_WT,
       OUT_NUM,
       DECODE(IF_MONITOR_ZG,'0','否','1'，'是') IF_MONITOR_ZG,
       PRDCR_NO,
       MONITOR_POINT,
       CRAFT_FILE_NO,
       CRAFT_FILE_MAN,
       CRAFT_SEQ,
       STATION_ROAD,
       DECODE(PLANSTATUS,'0','计划','1','下发','2','生产中','3','生产完成','4','关闭A') PLANSTATUS,
       IN_WT_REAL,
       IN_NUM_REAL,
       OUT_WT_REAL,
       OUT_NUM_REAL,
       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,
       PLAN_GP_NUM
 FROM PLN_ZY_ZG_M
                 ]]>
	</query>
	<query id="PlanLuZG.queryZYZGC" desc="查询PLN_ZY_ZG_C表">
             <![CDATA[
                  SELECT 
       LEN_GP_SINGLE,
       MULTIPLE_NUM,
       IN_GP_WT,
       IN_GP_NUM,
       CUT_SINGLE_WT,
       CUT_SINGLE_NUM,
       IN_GP_WT_REAL,
       IN_GP_NUM_REAL,
       SINGLE_WT_REAL,
       SINGLE_NUM_REAL,
       CUTZY_STATUS,
       HEAT_PLAN_NO,
       GP_CUT_NO,
       ZY_BATCH_ID,
       PRO_PLAN_ID,
       GX_PLAN_NO,
       PLINE_CODE,
       PLINE_NAME,
       GPREQ_ID,
       HEATNO_LAST,
       LENGTH_GP
 FROM PLN_ZY_ZG_C
                 ]]>
	</query>
	<query id="PlanLuZG.queryOrderZG" desc="查询PLN_Order_ZG_S表">
             <![CDATA[
                   select t.CIC_GROUP_GP,
				       t.PIC_GROUP_GP,
				       t.SIC_GROUP_GP,
				       t.DIC_GROUP_GP,
				       t.WIC_GROUP_GP,
				       t.GIC_GROUP_GP,
				       t.CIC_GP,
				       t.PIC_GP,
				       t.SIC_GP,
				       t.DIC_GP,
				       t.WIC_GP,
				       t.GIC_GP,
				       t.LEN_CUTHEAD,
				       t.LEN_CUTEND,
				       t.OUTNUM_CUT,
				       t.DIAMETER_MANDREL,
				       t.PASS_CODE,
				       t.PASS_NAME,
				       t.IN_WEIGHT_S,
				       t.IN_NUM_S,
				       t.WEIGTH_S,
				       t.NUM_S,
				       t.ADD_WT_IN,
				       t.ADD_NUM_IN,
				       t.MATCH_WT_IN,
				       t.MATCH_NUM_IN,
				       t.ISENDGX,
				       t.IF_MONITOR_ZG,
				       t.PRDCR_NO,
				       t.MONITOR_POINT,
				       t.CRAFT_FILE_NO,
				       t.CRAFT_FILE_MAN,
				       t.CRAFT_SEQ,
				       t.STATION_ROAD,
				       t.PRO_MONTH,
				       t.CIC,
				       t.PIC,
				       t.SIC,
				       t.DIC,
				       t.WIC,
				       t.GIC,
				       t.GX_PRO_SEQ,
				       t.PLAN_USETIME,
				       t.PLAN_TIME_B,
				       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.IS_PLAN_OK,
				       t.GPREQ_IF_OK,
				       t.GPREQ_ID,
				       t.ZY_BATCH_ID,
				       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.STEELCODE,
				       t.STEELNAME,
				       t.GRADECODE,
				       t.GRADENAME,
				       t.OUTDIAMETER,
				       t.WALLTHICK,
				       t.LENGTHDISC,
				       t.INWL_ID,
				       t.INWL_DESC,
				       t.OUTWL_ID,
				       t.OUTWL_DESC,
				       t.LEN_ROLL_MAX,
				       t.LEN_ROLL_MIN,
				       t.AIMOUTDIAMETER,
				       t.AIMWALLTHICK,
				       t.AIMLENGTH,
				       t.DIAMETER_GP,
				       t.LEN_GP_SINGLE,
				       t.ROLL_LENGTH
				       , Decode(t.MCount,0,'无','有') as MStatus,
				       t.MCount from (SELECT 
				       S.CIC_GROUP_GP,
				       S.PIC_GROUP_GP,
				       S.SIC_GROUP_GP,
				       S.DIC_GROUP_GP,
				       S.WIC_GROUP_GP,
				       S.GIC_GROUP_GP,
				       S.CIC_GP,
				       S.PIC_GP,
				       S.SIC_GP,
				       S.DIC_GP,
				       S.WIC_GP,
				       S.GIC_GP,
				       S.LEN_CUTHEAD,
				       S.LEN_CUTEND,
				       S.OUTNUM_CUT,
				       S.DIAMETER_MANDREL,
				       S.PASS_CODE,
				       S.PASS_NAME,
				       S.IN_WEIGHT_S,
				       S.IN_NUM_S,
				       S.WEIGTH_S,
				       S.NUM_S,
				       S.ADD_WT_IN,
				       S.ADD_NUM_IN,
				       S.MATCH_WT_IN,
				       S.MATCH_NUM_IN,
				       DECODE(S.ISENDGX,'0','否','1'，'是') ISENDGX,
				       DECODE(S.IF_MONITOR_ZG,'0','否','1'，'是') IF_MONITOR_ZG,
				       S.PRDCR_NO,
				       S.MONITOR_POINT,
				       S.CRAFT_FILE_NO,
				       S.CRAFT_FILE_MAN,
				       S.CRAFT_SEQ,
				       S.STATION_ROAD,
				       S.PRO_MONTH,
				       S.CIC,
				       S.PIC,
				       S.SIC,
				       S.DIC,
				       S.WIC,
				       S.GIC,
				       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_GP_M T, YDM_GP_BUTTRESS T1
				         WHERE T.MAT_NO = T1.MAT_NO
				         AND PRODUCT_FLAG ='801401'
				         AND T.MATERIAL_NO =  S.INWL_ID
				         AND T.PRO_ORDER_NO IS NULL
				                    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 = 'D' ) 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 )
				                   AND MAT_STATUS='80150102'
				                   AND LOCK_FLAG = '0') MCount,
				       DECODE(S.IS_REPAIR_PLN,'0','否','1'，'是') IS_REPAIR_PLN,
				       S.REPAIR_TYPE,
				       DECODE(S.IS_PLAN_OK,'0','否','1'，'是') IS_PLAN_OK,
				       S.GPREQ_IF_OK,
				       S.GPREQ_ID,
				       S.ZY_BATCH_ID,
				       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.STEELCODE,
				       S.STEELNAME,
				       S.GRADECODE,
				       S.GRADENAME,
				       S.OUTDIAMETER,
				       S.WALLTHICK,
				       S.LENGTHDISC,
				       S.INWL_ID,
				       S.INWL_DESC,
				       S.OUTWL_ID,
				       S.OUTWL_DESC,
				       S.LEN_ROLL_MAX,
				       S.LEN_ROLL_MIN,
				       S.AIMOUTDIAMETER,
				       S.AIMWALLTHICK,
				       S.AIMLENGTH,
				       S.DIAMETER_GP,
				       S.LEN_GP_SINGLE,
				       S.ROLL_LENGTH
				 FROM PLN_ORDER_ZG_S S) t
                 ]]>
	</query>
	
	<query id="PlanLuZG.insertZYZGM" desc="插入PLN_ZY_ZG_M表">
             <![CDATA[
                  INSERT INTO PLN_ZY_ZG_M(
        HEAT_PLAN_NO,
        ZY_BATCH_ID,
        PROD_INDEX,
        PRO_PLAN_ID,
        GX_PLAN_NO,
        GPREQ_ID,
        HEATNO_LAST,
        PLINE_CODE,
        PLINE_NAME,
        ISENDGX,
        ORDER_SOURCE,
        ORD_LN_DLY_PK,
        ORDER_NO,
        ORDER_SEQ,
        DELIVERY_NO,
        REQ_BL_ID,
        GRADECODE,
        GRADENAME,
        LEN_ROLL_MAX,
        LEN_ROLL_MIN,
        AIMOUTDIAMETER,
        AIMWALLTHICK,
        AIMLENGTH,
        DIAMETER_GP,
        LENGTH_GP,
        LEN_GP_SINGLE,
        ROLL_LENGTH,
        LEN_CUTHEAD,
        LEN_CUTEND,
        OUTNUM_CUT,
        DIAMETER_MANDREL,
        PASS_CODE,
        PASS_NAME,
        INWL_ID,
        INWL_DESC,
        CUT_SINGLE_WT,
        CUT_SINGLE_NUM,
        IF_WL_MATCHED,
        OUTWL_ID,
        OUTWL_DESC,
        OUT_WT,
        OUT_NUM,
        IF_MONITOR_ZG,
        PRDCR_NO,
        MONITOR_POINT,
        CRAFT_FILE_NO,
        CRAFT_FILE_MAN,
        CRAFT_SEQ,
        STATION_ROAD,
        PLANSTATUS,
        IN_WT_REAL,
        IN_NUM_REAL,
        OUT_WT_REAL,
        OUT_NUM_REAL,
        CREATE_NAME,
        CREATE_TIME,
        UPDATE_NAME,
        UPDATE_TIME,
        PLAN_GP_NUM)
 VALUES( 
        '#HEAT_PLAN_NO#',
        '#ZY_BATCH_ID#',
        '#PROD_INDEX#',
        '#PRO_PLAN_ID#',
        '#GX_PLAN_NO#',
        '#GPREQ_ID#',
        '#HEATNO_LAST#',
        '#PLINE_CODE#',
        '#PLINE_NAME#',
        DECODE('#ISENDGX#','否','0','是'，'1','#ISENDGX#'),
        '#ORDER_SOURCE#',
        '#ORD_LN_DLY_PK#',
        '#ORDER_NO#',
        '#ORDER_SEQ#',
        '#DELIVERY_NO#',
        '#REQ_BL_ID#',
        '#GRADECODE#',
        '#GRADENAME#',
        '#LEN_ROLL_MAX#',
        '#LEN_ROLL_MIN#',
        '#AIMOUTDIAMETER#',
        '#AIMWALLTHICK#',
        '#AIMLENGTH#',
        '#DIAMETER_GP#',
        '#LENGTH_GP#',
        '#LEN_GP_SINGLE#',
        '#ROLL_LENGTH#',
        '#LEN_CUTHEAD#',
        '#LEN_CUTEND#',
        '#OUTNUM_CUT#',
        '#DIAMETER_MANDREL#',
        '#PASS_CODE#',
        '#PASS_NAME#',
        '#INWL_ID#',
        '#INWL_DESC#',
        '#CUT_SINGLE_WT#',
        '#CUT_SINGLE_NUM#',
        DECODE('#IF_WL_MATCHED#','否','0','是'，'1','#IF_WL_MATCHED#'),
        '#OUTWL_ID#',
        '#OUTWL_DESC#',
        '#OUT_WT#',
        '#OUT_NUM#',
        DECODE('#IF_MONITOR_ZG#','否','0','是'，'1','#IF_MONITOR_ZG#'),
        '#PRDCR_NO#',
        '#MONITOR_POINT#',
        '#CRAFT_FILE_NO#',
        '#CRAFT_FILE_MAN#',
        '#CRAFT_SEQ#',
        '#STATION_ROAD#',
        DECODE('#PLANSTATUS#','计划','0','下发','1','生产中','2','生产完成','3','关闭A','4','#PLANSTATUS#'),
        '#IN_WT_REAL#',
        '#IN_NUM_REAL#',
        '#OUT_WT_REAL#',
        '#OUT_NUM_REAL#',
        '#CREATE_NAME#',
        SYSDATE,
        '#UPDATE_NAME#',
        '',
        '#PLAN_GP_NUM#')
                 ]]>
	</query>
		<query id="PlanLuZG.insertZYZGC" desc="插入PLN_ZY_ZG_C表">
             <![CDATA[
                 INSERT INTO PLN_ZY_ZG_C(
			        LEN_GP_SINGLE,
			        MULTIPLE_NUM,
			        IN_GP_WT,
			        IN_GP_NUM,
			        CUT_SINGLE_WT,
			        CUT_SINGLE_NUM,
			        IN_GP_WT_REAL,
			        IN_GP_NUM_REAL,
			        SINGLE_WT_REAL,
			        SINGLE_NUM_REAL,
			        CUTZY_STATUS,
			        HEAT_PLAN_NO,
			        GP_CUT_NO,
			        ZY_BATCH_ID,
			        PRO_PLAN_ID,
			        GX_PLAN_NO,
			        PLINE_CODE,
			        PLINE_NAME,
			        GPREQ_ID,
			        HEATNO_LAST,
			        LENGTH_GP)
			 VALUES( 
			        '#LEN_GP_SINGLE#',
			        '#MULTIPLE_NUM#',
			        '#IN_GP_WT#',
			        '#IN_GP_NUM#',
			        '#CUT_SINGLE_WT#',
			        '#CUT_SINGLE_NUM#',
			        '#IN_GP_WT_REAL#',
			        '#IN_GP_NUM_REAL#',
			        '#SINGLE_WT_REAL#',
			        '#SINGLE_NUM_REAL#',
			        '#CUTZY_STATUS#',
			        '#HEAT_PLAN_NO#',
			        '#GP_CUT_NO#',
			        '#ZY_BATCH_ID#',
			        '#PRO_PLAN_ID#',
			        '#GX_PLAN_NO#',
			        '#PLINE_CODE#',
			        '#PLINE_NAME#',
			        '#GPREQ_ID#',
			        '#HEATNO_LAST#',
			        '#LENGTH_GP#')
                 ]]>
	</query>
		<query id="PlanLuZG.UpdateOrderZG_WT_NUM" desc="更新PLN_Order_DBK_S表的炉计划已排量">
             <![CDATA[
               	 UPDATE PLN_ORDER_ZG_S
				   SET 
				        BATCHED_WT = ?,
				        BATCHED_NUM = ?
				 WHERE
				 PRO_PLAN_ID = ? and
				        GX_PLAN_NO = ?
			        ]]>
	</query>
	<query id="PlanLuZG.UpdateOrderZG_MATCH_WT_NUM" desc="更新PLN_Order_DBK_S表投入利库量">
             <![CDATA[
               	 UPDATE PLN_ORDER_ZG_S
				   SET 
				         Match_Wt_In = ?,
			        Match_Num_In = ?
				 WHERE
				 PRO_PLAN_ID = ? and
				        GX_PLAN_NO = ?
                 ]]>
	</query>
	<query id="PlanLuZG.UpdateZYZG_WT_NUM" desc="更新PLN_ZY_ZG_M表的单倍坯量和计划产出量">
             <![CDATA[
               	 update pln_zy_zg_m m
					set
					m.cut_single_num = ?,
					m.cut_single_wt = ?,
					m.out_num = ?,
					m.out_wt = ?,
					m.update_name = ?,
					m.PLAN_GP_NUM = ?,
					m.update_time = sysdate
					where m.heat_plan_no = ?
                 ]]>
	</query>
	<query id="PlanLuZG.UpdateZYZGC_GPWT_GPNUM" desc="更新PLAN_ZY_ZG_C的单倍坯量和计划投入量">
             <![CDATA[
               	 update pln_zy_zg_c c 
					set 
					c.cut_single_num =?,
					c.cut_single_wt = ?,
					c.in_gp_num =?,
					c.in_gp_wt = ?
					where c.heat_plan_no = ? AND c.GP_CUT_NO = ?
                 ]]>
	</query>
	<query id="PlanLuZG.queryMaxHeat_Plan_No" desc="查询PLN_ZY_JGX_M表最大的">
             <![CDATA[
               select max(to_number("SUBSTR"(HEAT_PLAN_NO, 10, 4))) as num FROM(select HEAT_PLAN_NO from PLN_ZY_ZG_M t where to_char(t.CREATE_TIME,'yyyymmdd')=to_char(sysdate,'yyyymmdd'))
                 ]]>
	</query>
	<query id="PlanLuZG.deleteZyZgM" desc="删除PLAN_ZY_ZG_M">
             <![CDATA[
               DELETE FROM PLN_ZY_ZG_M WHERE HEAT_PLAN_NO = ?
			         ]]>  
	</query>
	<query id="PlanLuZG.deleteZyZgC" desc="删除指定炉计划号的PLAN_ZY_ZG_C的所有记录">
             <![CDATA[
               DELETE FROM PLN_ZY_ZG_C WHERE HEAT_PLAN_NO = ?
			         ]]>  
	</query>
	<query id="PlanLuZG.deleteZyZgCByCutNo" desc="删除指定的PLAN_ZY_ZG_C的">
             <![CDATA[
               DELETE FROM PLN_ZY_ZG_C WHERE HEAT_PLAN_NO = ? AND GP_CUT_NO = ?
			         ]]>  
	</query>
	<query id="PlanLuZG.queryInNumInOrder" desc="查询指定工序订单的所排的所有炉计划量投入量">
             <![CDATA[
               select sum(c.in_gp_num) from pln_zy_zg_m m,pln_zy_zg_c c where m.heat_plan_no = c.heat_plan_no and m.pro_plan_id = ? and m.gx_plan_no = ?
			         ]]>  
	</query>
	
</queryMap>