<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="">
	<query id="PlanLuDBK.queryZYDBK" desc="查询PLN_ZY_DBK_S表">
             <![CDATA[
                SELECT 
                BATCH_GROUD_NO,
			       HEAT_PLAN_NO,
			       ZY_BATCH_ID,
			       PROD_INDEX,
			       PRO_PLAN_ID,
			       GX_PLAN_NO,
			       PLINE_CODE,
			       PLINE_NAME,
			       ZG_HEAT_PLAN_NO,
			       HEATNO_LAST,
			       ZG_BATCH_NO,
			       DECODE(ISENDGX,'0','否','1'，'是') ISENDGX,
			       ORDER_SOURCE,
			       ORD_LN_DLY_PK,
			       ORDER_NO,
			       ORDER_SEQ,
			       DELIVERY_NO,
			       REQ_BL_ID,
			       GRADECODE,
			       GRADENAME,
			       AIMOUTDIAMETER,
			       AIMWALLTHICK,
			       AIMLENGTH,
			       OUTDIAMETER_IN,
			       WALLTHICK_IN,
			       LENGTH_IN,
			       LENGTHMAX_IN,
			       LENGTHMIN_IN,
			       LEN_CUTHEAD,
			       LEN_CUTEND,
			       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_DBK,'0','否','1'，'是') IF_MONITOR_DBK,
			       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_DBK_M
                 ]]>
	</query>
	<query id="PlanLuDBK.queryOrderDBK" desc="查询PLN_Order_DBK_S表">
             <![CDATA[
                select g.*, Decode(MCount,0,'无','有') as MStatus from (SELECT 
			       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.ADD_WT_IN,
			       S.ADD_NUM_IN,
			       S.OUTWL_DESC,
			       S.WEIGTH_S,
			       S.NUM_S,
			       S.GX_PRO_SEQ,
			       S.PLAN_USETIME,
			       TO_CHAR(PLAN_TIME_B, 'YYYY-MM-DD HH24:MI:SS') PLAN_TIME_B,
			       TO_CHAR(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 = 'E' ) 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.OUTDIAMETER,
			       S.WALLTHICK,
			       S.LENGTHDISC,
			       S.AIMOUTDIAMETER,
			       S.AIMWALLTHICK,
			       S.AIMLENGTH,
			       S.OUTDIAMETER_IN,
			       S.WALLTHICK_IN,
			       S.LENGTH_IN,
			       S.LEN_CUTHEAD,
			       S.LEN_CUTEND,
			       S.LENGTHMAX_IN,
			       S.LENGTHMIN_IN,
			       S.IN_WEIGHT_S,
			       S.IN_NUM_S,
			       S.MATCH_WT_IN,
			       S.MATCH_NUM_IN,
			       DECODE(S.ISENDGX,'0','否','1'，'是') ISENDGX,
			       DECODE(S.IF_MONITOR_DBK,'0','否','1'，'是') IF_MONITOR_DBK,
			       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.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.GRADECODE,
			       S.GRADENAME,
			       S.PRO_MONTH,
			       S.PREVIOUS_GX,
			       S.PREV_GXPLAN_ID,
			       S.PRO_ORDER_NO,
			       S.PRO_PLAN_ID,
			       S.GX_PLAN_NO,
			       S.PLAN_GROUP_ID
			 FROM PLN_ORDER_DBK_S S) g
                 ]]>
	</query>
	<query id="PlanLuDBK.insertZYDBK" desc="插入PLN_ZY_DBK_M表">
             <![CDATA[
               INSERT INTO PLN_ZY_DBK_M(
			        BATCH_GROUD_NO,
			        HEAT_PLAN_NO,
			        ZY_BATCH_ID,
			        PROD_INDEX,
			        PRO_PLAN_ID,
			        GX_PLAN_NO,
			        PLINE_CODE,
			        PLINE_NAME,
			        ZG_HEAT_PLAN_NO,
			        HEATNO_LAST,
			        ZG_BATCH_NO,
			        ISENDGX,
			        ORDER_SOURCE,
			        ORD_LN_DLY_PK,
			        ORDER_NO,
			        ORDER_SEQ,
			        DELIVERY_NO,
			        REQ_BL_ID,
			        GRADECODE,
			        GRADENAME,
			        AIMOUTDIAMETER,
			        AIMWALLTHICK,
			        AIMLENGTH,
			        OUTDIAMETER_IN,
			        WALLTHICK_IN,
			        LENGTH_IN,
			        LENGTHMAX_IN,
			        LENGTHMIN_IN,
			        LEN_CUTHEAD,
			        LEN_CUTEND,
			        INWL_ID,
			        INWL_DESC,
			        IN_WT,
			        IN_NUM,
			        IF_WL_MATCHED,
			        OUTWL_ID,
			        OUTWL_DESC,
			        OUT_WT,
			        OUT_NUM,
			        IF_MONITOR_DBK,
			        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#',
			        '#PLINE_CODE#',
			        '#PLINE_NAME#',
			        '#ZG_HEAT_PLAN_NO#',
			        '#HEATNO_LAST#',
			        '#ZG_BATCH_NO#',
			        DECODE('#ISENDGX#','否','0','是'，'1','#ISENDGX#'),
			        '#ORDER_SOURCE#',
			        '#ORD_LN_DLY_PK#',
			        '#ORDER_NO#',
			        '#ORDER_SEQ#',
			        '#DELIVERY_NO#',
			        '#REQ_BL_ID#',
			        '#GRADECODE#',
			        '#GRADENAME#',
			        '#AIMOUTDIAMETER#',
			        '#AIMWALLTHICK#',
			        '#AIMLENGTH#',
			        '#OUTDIAMETER_IN#',
			        '#WALLTHICK_IN#',
			        '#LENGTH_IN#',
			        '#LENGTHMAX_IN#',
			        '#LENGTHMIN_IN#',
			        '#LEN_CUTHEAD#',
			        '#LEN_CUTEND#',
			        '#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_DBK#','否','0','是'，'1','#IF_MONITOR_DBK#'),
			        '#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="PlanLuDBK.UpdateOrderDBK_WT_NUM" desc="更新PLN_Order_DBK_S表炉计划已排量">
             <![CDATA[
               	 UPDATE PLN_ORDER_DBK_S
				   SET 
				        BATCHED_WT = ?,
				        BATCHED_NUM = ?
				 WHERE
				 PRO_PLAN_ID = ? and
				        GX_PLAN_NO = ?
                 ]]>
	</query>
	<query id="PlanLuDBK.UpdateZYDBK_WT_NUM" desc="更新PLN_ZY_DBK_M的投入产出量">
             <![CDATA[
               	 UPDATE PLN_ZY_DBK_M
				   SET 
				        IN_WT = ?,
				        IN_NUM = ?,
				        OUT_NUM=?,
				        OUT_WT=?,
				        UPDATE_NAME=?,
				        UPDATE_TIME = SYSDATE
				 WHERE
				 		HEAT_PLAN_NO=?
                 ]]>
	</query>
	<query id="PlanLuDBK.UpdateOrderDBK_MATCH_WT_NUM" desc="更新PLN_Order_DBK_S表">
             <![CDATA[
               	 UPDATE PLN_ORDER_DBK_S
				   SET 
				         Match_Wt_In = ?,
			        Match_Num_In = ?
				 WHERE
				 PRO_PLAN_ID = ? and
				        GX_PLAN_NO = ?
                 ]]>
	</query>
	<query id="PlanLuDBK.queryMaxHeat_Plan_No" desc="查询PLN_ZY_DBK_M表最大的">
             <![CDATA[
               select max(to_number("SUBSTR"(HEAT_PLAN_NO, 10, 4))) as num FROM(select HEAT_PLAN_NO from PLN_ZY_DBK_M t where to_char(t.CREATE_TIME,'yyyymmdd')=to_char(sysdate,'yyyymmdd'))
                 ]]>
	</query>
	<query id="PlanLuDBK.UpdateOrderDBK_WT_NUM_ENTITY" desc="更新PLN_Order_DBK_S表投入利库量">
             <![CDATA[
               	  UPDATE PLN_ORDER_DBK_S
   					SET 
			        BATCHED_WT = '#BATCHED_WT#',
			        BATCHED_NUM = '#BATCHED_NUM#'
					 WHERE
					PRO_PLAN_ID = ? and
			        GX_PLAN_NO = ?
                 ]]>
	</query>
	<query id="PlanLuDBK.deleteZyDbkM" desc="删除指定的的作业计划">
             <![CDATA[
               	  DELETE FROM PLN_ZY_DBK_M WHERE HEAT_PLAN_NO = ?
                 ]]>
	</query>
	<query id="PlanLuDBK.queryOrderDBKNormal" desc="查询镦拔扩工序订单">
             <![CDATA[
               	   SELECT 
			       LEN_CUTHEAD,
			       LEN_CUTEND,
			       LENGTHMAX_IN,
			       LENGTHMIN_IN,
			       IN_WEIGHT_S,
			       IN_NUM_S,
			       ADD_WT_IN,
			       ADD_NUM_IN,
			       MATCH_WT_IN,
			       MATCH_NUM_IN,
			       ISENDGX,
			       IF_MONITOR_DBK,
			       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,
			       GRADECODE,
			       GRADENAME,
			       PRO_MONTH,
			       PREVIOUS_GX,
			       PREV_GXPLAN_ID,
			       IF_EXPORT,
			       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,
			       TO_CHAR(PLAN_TIME_B, 'YYYY-MM-DD HH24:MI:SS') PLAN_TIME_B,
			       TO_CHAR(PLAN_TIME_E, 'YYYY-MM-DD HH24:MI:SS') PLAN_TIME_E,
			       EXE_STATUS,
			       IS_REPAIR_PLN,
			       REPAIR_TYPE,
			       OUTDIAMETER,
			       WALLTHICK,
			       LENGTHDISC,
			       AIMOUTDIAMETER,
			       AIMWALLTHICK,
			       AIMLENGTH,
			       OUTDIAMETER_IN,
			       WALLTHICK_IN,
			       LENGTH_IN
			 FROM PLN_ORDER_DBK_S
                 ]]>
	</query>
</queryMap>