<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="">
	<query id="PlanLuJGX.queryZYJGXM" desc="查询PLN_ZY_JGX_M的所有记录">
             <![CDATA[
                SELECT 
                BATCH_GROUD_NO,
       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,
       ORDER_SOURCE,
       ORD_LN_DLY_PK,
       ORDER_NO,
       ORDER_SEQ,
       DELIVERY_NO,
       REQ_BL_ID,
       STEELCODE,
       STEELNAME,
       OUTDIAMETER,
       WALLTHICK,
       LENGTHMAX,
       LENGTHMIN,
       LENGTHDISC,
       AIMWALLTHICK,
       AIMLENGTH,
       MODEL_CODE,
       MODEL_DESC,
       LENGTHMAX_IN,
       LENGTHMIN_IN,
       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_JGX,'0','否','1'，'是') IF_MONITOR_JGX,
       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
 FROM PLN_ZY_JGX_M
                 ]]>
	</query>
	<query id="PlanLuJGX.queryZYJGXC" desc="查询PLN_ZY_JGX_C的所有数据">
             <![CDATA[
                 SELECT 
       HEAT_PLAN_NO,
       JGX_CUT_NO,
       GX_PLAN_NO,
       PLINE_CODE,
       PLINE_NAME,
       HEATNO_LAST,
       LENGTH_IN,
       LAST_BATCH_NO,
       IN_WT,
       AIMLENGTH_CUT,
       IN_NUM,
       OUTNUM_CUT,
       CUT_OUT_WT,
       CUT_OUT_NUM,
       IN_WT_REAL,
       IN_NUM_REAL,
       CUT_WT_REAL,
       CUT_NUM_REAL,
       CUTZY_STATUS,
       ZY_BATCH_ID,
       PROD_INDEX,
       PRO_PLAN_ID
 FROM PLN_ZY_JGX_C
                 ]]>
	</query>
	<query id="PlanLuJGX.queryOrderJGX" desc="查询PLN_Order_JGX_S表">
             <![CDATA[
                 select 
       OUTLINE_SITE_250,
       CREATE_TIME,
       MEMO,
       IF_EXPORT,
       FINAL_USER_DESC,
       PROCESS_DESC_C_ZG,
       GROUP_ROLL_NAME,
       BEGIN_TIME_ZG,
       PRDCR_ADVC_DAY,
       WHOLE_BACKLOG_DESC,
       PRIORITY,
       PRIORITY_MEMO,
       DELVRY_EDATE,
       STATION_NM,
       IF_MONITOR_JGX,
       ADD_WT_IN,
       ADD_NUM_IN,
       PRDCR_NO,
       MONITOR_POINT,
       CIC,
       PIC,
       SIC,
       DIC,
       WIC,
       GIC,
       CRAFT_FILE_NO,
       CRAFT_FILE_MAN,
       CRAFT_SEQ,
       STATION_ROAD,
       BATCHED_WT,
       BATCHED_NUM,
       FINISHWEIGHT,
       FINISHNUM,
       IS_PLAN_OK,
       ZY_BATCH_ID,
       PRO_MONTH,
       PREVIOUS_GX,
       PREV_GXPLAN_ID,
       PRO_ORDER_NO,
       PRO_PLAN_ID,
       GX_PLAN_NO,
       PLAN_GROUP_ID,
       ORDER_SOURCE,
       ORD_LN_DLY_PK,
       PLN_DIVIDE_ID,
       ORDER_NO,
       ORDER_SEQ,
       DELIVERY_NO,
       REQ_BL_ID,
       PLINE_CODE,
       PLINE_NAME,
       INWL_ID,
       INWL_DESC,
       OUTWL_ID,
       OUTWL_DESC,
       WEIGTH_S,
       NUM_S,
       GX_PRO_SEQ,
       PLAN_USETIME,
       PLAN_TIME_B,
       PLAN_TIME_E,
       EXE_STATUS,
       IS_REPAIR_PLN,
       REPAIR_TYPE,
       STEELCODE,
       STEELNAME,
       OUTDIAMETER,
       WALLTHICK,
       LENGTHMAX,
       LENGTHMIN,
       LENGTHDISC,
       AIMWALLTHICK,
       AIMLENGTH,
       SHRT_LEN_RATO,
       SHORTEST,
       LONG_LEN_RATO,
       LONGEST,
       SHRT_STOVE,
       AVG_LEN_MIN,
       DIFRNC_LEN_MAX,
       SIGL_LEN,
       ENDLEN_SPECSTD,
       MODEL_CODE,
       MODEL_DESC,
       LENGTHMAX_IN,
       LENGTHMIN_IN,
       LENGTH_IN,
       OUTNUM_CUT,
       IN_WEIGHT_S,
       IN_NUM_S,
       MATCH_WT_IN,
       MATCH_NUM_IN,
       Decode(MCount,0,'无','有') as MStatus,
       MCount from (SELECT 
       DECODE(S.IF_MONITOR_JGX,'0','否','1'，'是') IF_MONITOR_JGX,
       S.PRDCR_NO,
       S.MONITOR_POINT,
       S.CIC,
       S.PIC,
       S.SIC,
       S.DIC,
       S.WIC,
       S.GIC,
       S.CRAFT_FILE_NO,
       S.CRAFT_FILE_MAN,
       S.PRIORITY_MEMO,
       S.CRAFT_SEQ,
       S.STATION_ROAD,
       S.BATCHED_WT,
       S.BATCHED_NUM,
       S.FINISHWEIGHT,
       S.FINISHNUM,
       DECODE(S.IS_PLAN_OK,'0','否','1'，'是') IS_PLAN_OK,
       S.ZY_BATCH_ID,
       S.PRO_MONTH,
       S.PRIORITY,
       S.PREVIOUS_GX,
       DECODE(S.IF_EXPORT,'0','否','1'，'是') IF_EXPORT,
       S.WHOLE_BACKLOG_DESC,
       S.PROCESS_DESC_C_ZG,
       S.GROUP_ROLL_NAME,
       S.MEMO,
       S.PREV_GXPLAN_ID,
       S.FINAL_USER_DESC,
       S.PRO_ORDER_NO,
       S.PRO_PLAN_ID,
       TO_CHAR(S.BEGIN_TIME_ZG, 'YYYY-MM-DD HH24:MI:SS') BEGIN_TIME_ZG,
       S.GX_PLAN_NO,
       S.PLAN_GROUP_ID,
       TO_CHAR(S.DELVRY_EDATE, 'YYYY-MM-DD HH24:MI:SS') DELVRY_EDATE,
       S.ORDER_SOURCE,
       S.ORD_LN_DLY_PK,
       S.OUTLINE_SITE_250,
       S.PLN_DIVIDE_ID,
       S.ORDER_NO,
       S.ORDER_SEQ,
       S.DELIVERY_NO,
       S.REQ_BL_ID,
       TO_CHAR(S.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       S.PLINE_CODE,
       S.PRDCR_ADVC_DAY,
       S.PLINE_NAME,
       S.STATION_NM,
       S.INWL_ID,
       S.INWL_DESC,
       S.ADD_WT_IN,
       S.ADD_NUM_IN,
       S.OUTWL_ID,
       S.OUTWL_DESC,
       S.WEIGTH_S,
       S.NUM_S,
       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,
       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 = 'G' ) 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.STEELCODE,
       S.STEELNAME,
       S.OUTDIAMETER,
       S.WALLTHICK,
       S.LENGTHMAX,
       S.LENGTHMIN,
       S.LENGTHDISC,
       S.AIMWALLTHICK,
       S.AIMLENGTH,
       S.SHRT_LEN_RATO,
       S.SHORTEST,
       S.LONG_LEN_RATO,
       S.LONGEST,
       S.SHRT_STOVE,
       S.AVG_LEN_MIN,
       S.DIFRNC_LEN_MAX,
       S.SIGL_LEN,
       S.ENDLEN_SPECSTD,
       S.MODEL_CODE,
       S.MODEL_DESC,
       S.LENGTHMAX_IN,
       S.LENGTHMIN_IN,
       S.LENGTH_IN,
       S.OUTNUM_CUT,
       S.IN_WEIGHT_S,
       S.IN_NUM_S,
       S.MATCH_WT_IN,
       S.MATCH_NUM_IN
 FROM PLN_ORDER_JGX_S S) t
                 ]]>
	</query>
	<query id="PlanLuJGX.insertZYJGXM" desc="插入PLN_ZY_JGX_M表">
             <![CDATA[
                INSERT INTO PLN_ZY_JGX_M(
        BATCH_GROUD_NO,
        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,
        ORDER_SOURCE,
        ORD_LN_DLY_PK,
        ORDER_NO,
        ORDER_SEQ,
        DELIVERY_NO,
        REQ_BL_ID,
        STEELCODE,
        STEELNAME,
        OUTDIAMETER,
        WALLTHICK,
        LENGTHMAX,
        LENGTHMIN,
        LENGTHDISC,
        AIMWALLTHICK,
        AIMLENGTH,
        MODEL_CODE,
        MODEL_DESC,
        LENGTHMAX_IN,
        LENGTHMIN_IN,
        INWL_ID,
        INWL_DESC,
        IN_WT,
        IN_NUM,
        IF_WL_MATCHED,
        OUTWL_ID,
        OUTWL_DESC,
        OUT_WT,
        OUT_NUM,
        IF_MONITOR_JGX,
        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)
 VALUES( 
        '#BATCH_GROUD_NO#',
        '#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#',
        '#ORDER_SOURCE#',
        '#ORD_LN_DLY_PK#',
        '#ORDER_NO#',
        '#ORDER_SEQ#',
        '#DELIVERY_NO#',
        '#REQ_BL_ID#',
        '#STEELCODE#',
        '#STEELNAME#',
        '#OUTDIAMETER#',
        '#WALLTHICK#',
        '#LENGTHMAX#',
        '#LENGTHMIN#',
        '#LENGTHDISC#',
        '#AIMWALLTHICK#',
        '#AIMLENGTH#',
        '#MODEL_CODE#',
        '#MODEL_DESC#',
        '#LENGTHMAX_IN#',
        '#LENGTHMIN_IN#',
        '#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_JGX#','否','0','是'，'1','#IF_MONITOR_JGX#'),
        '#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#',
        '')
                 ]]>
	</query>
		<query id="PlanLuJGX.insertZYJGXC" desc="插入PLN_ZY_JGX_C表">
             <![CDATA[
                INSERT INTO PLN_ZY_JGX_C(
			        HEAT_PLAN_NO,
			        JGX_CUT_NO,
			        GX_PLAN_NO,
			        PLINE_CODE,
			        PLINE_NAME,
			        HEATNO_LAST,
			        LENGTH_IN,
			        LAST_BATCH_NO,
			        IN_WT,
			        AIMLENGTH_CUT,
			        IN_NUM,
			        OUTNUM_CUT,
			        CUT_OUT_WT,
			        CUT_OUT_NUM,
			        IN_WT_REAL,
			        IN_NUM_REAL,
			        CUT_WT_REAL,
			        CUT_NUM_REAL,
			        CUTZY_STATUS,
			        ZY_BATCH_ID,
			        PROD_INDEX,
			        PRO_PLAN_ID)
			 VALUES( 
			        '#HEAT_PLAN_NO#',
			        '#JGX_CUT_NO#',
			        '#GX_PLAN_NO#',
			        '#PLINE_CODE#',
			        '#PLINE_NAME#',
			        '#HEATNO_LAST#',
			        '#LENGTH_IN#',
			        '#LAST_BATCH_NO#',
			        '#IN_WT#',
			        '#AIMLENGTH_CUT#',
			        '#IN_NUM#',
			        '#OUTNUM_CUT#',
			        '#CUT_OUT_WT#',
			        '#CUT_OUT_NUM#',
			        '#IN_WT_REAL#',
			        '#IN_NUM_REAL#',
			        '#CUT_WT_REAL#',
			        '#CUT_NUM_REAL#',
			        '#CUTZY_STATUS#',
			        '#ZY_BATCH_ID#',
			        '#PROD_INDEX#',
			        '#PRO_PLAN_ID#')
                 ]]>
	</query>
		<query id="PlanLuJGX.UpdateOrderJGX_WT_NUM" desc="更新PLN_Order_JGX_S炉计划已排量">
             <![CDATA[
			   UPDATE PLN_ORDER_JGX_S
				   SET 
				        BATCHED_WT = ?,
				        BATCHED_NUM = ?
				 WHERE
				 PRO_PLAN_ID = ? and
				        GX_PLAN_NO = ?
			        ]]>
	</query>
	<query id="PlanLuJGX.UpdateOrderJGX_MATCH_WT_NUM" desc="更新PLN_Order_JGX_S表投入利库量">
             <![CDATA[
               	 UPDATE PLN_ORDER_JGX_S
				   SET 
				         Match_Wt_In = ?,
			        Match_Num_In = ?
				 WHERE
				 PRO_PLAN_ID = ? and
				        GX_PLAN_NO = ?
                 ]]>
	</query>
	<query id="PlanLuJGX.UpdateZYJGX_WT_NUM" desc="更新PLN_ZY_JGX_M的投入产出量">
             <![CDATA[
               	 UPDATE PLN_ZY_JGX_M
				   SET 
				        IN_WT = ?,
				        IN_NUM = ?,
				        OUT_NUM=?,
				        OUT_WT=?,
				        UPDATE_NAME=?,
				        UPDATE_TIME = SYSDATE
				 WHERE
				 		HEAT_PLAN_NO=?
                 ]]>
	</query>
	<query id="PlanLuZG.UpdateZYJGXC_WT_NUM" desc="更新PLAN_ZY_JGX_C的单倍坯量和计划投入量">
             <![CDATA[
               	 update pln_zy_zg_c c 
					set 
					c.cut_out_num =?,
					c.cut_out_wt = ?,
					c.in_num =?,
					c.in_wt = ?
					where c.heat_plan_no = ? AND c.JGX_CUT_NO = ?
                 ]]>
	</query>
	<query id="PlanLuJGX.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_JGX_M t where to_char(t.CREATE_TIME,'yyyymmdd')=to_char(sysdate,'yyyymmdd'))
                 ]]>
	</query>
	<query id="PlanLuJGX.deleteZyJgxM" desc="删除指定的PLN_ZY_JGX_M行">
             <![CDATA[
               DELETE FROM PLN_ZY_JGX_M WHERE HEAT_PLAN_NO = ?
			         ]]>  
	</query>
	<query id="PlanLuJGX.deleteZyJgxC" desc="删除指定的PLN_ZY_JGX_C行">
             <![CDATA[
               DELETE FROM PLN_ZY_JGX_C WHERE HEAT_PLAN_NO = ?
			         ]]>  
	</query>
</queryMap>