<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="接箍炉计划">

	<query id="FrmPlanStoveH.queryPlanStoveMH" desc="查询接箍虚拟炉计划">
            <![CDATA[
SELECT T.HEAT_PLAN_NO,
       T.PRO_PLAN_ID,
       T.JG_GROUP_ID,
       T.GX_PLAN_NO,
       T.JUDGE_STOVE_NO,
       T.PLINE_CODE,
       T.PLINE_NAME,
       T.CODE_JG_BL,
       T.BL_WL_ID,
       T.BL_WL_DESC,
       T.STEELCODE,
       T.STEELNAME,
       T.GRADECODE,
       T.GRADENAME,
       T.MIN_D,
       T.MIN_H,
       T.AIMLENGTH_BL,
       T.AIM_CUT_LEN,
       T.LENGTH_MIN,
       T.LENGTH_MAX,
       T.TAPER,
       T.CODE_JG,
       T.MODEL_CODE,
       T.MODEL_DESC,
       T.OUTDIAMETER,
       T.WALLTHICK,
       T.SPEC_JG,
       T.SPEC_JG_DESC,
       (SELECT T1.BASENAME FROM COM_BASE_INFO T1 WHERE T1.BASECODE=T.STYLE_JG  AND T1.VALIDFLAG='1')  STYLE_JG,
       T.DIAMETER,
       T.CHECK_J_VAL,
       T.AIMLENGTH,
       T.SINGLEWEIGHT,
       T.COAT_TYPE,
       T.PLAN_JG_NUM,
       T.PLAN_BL_NUM,
       T.PLAN_BL_WT,
       T.MONITORDEMAND,
       DECODE(T.IF_MONITOR_JG, '1', '是', '/') IF_MONITOR_JG,
       T.PRDCR_NO,
       T.CUT_MACH_GRP_NO,
       T.CUT_MACH_GRP_NM,
       (SELECT T1.BASENAME FROM COM_BASE_INFO T1 WHERE T1.BASECODE=T.DEMAND_COPPER  AND T1.VALIDFLAG='1')  DEMAND_COPPER,
       T.LATHE_GRP_NO,
       T.LATHE_GRP_NM,
       DECODE(T.PLANSTATUS,
              '00',
              '计划',
              '10',
              '下发',
              '20',
              '生产中',
              '30',
              '生产完成',
              '40',
              '关闭') PLANSTATUS,
       T.MEMO,
       T.CREATE_NAME,
       TO_CHAR(T.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       T.UPDATE_NAME,
       TO_CHAR(T.UPDATE_TIME, 'YYYY-MM-DD HH24:MI:SS') UPDATE_TIME,
       T.CUST_ALPHA_NO,
       T.ORDER_SPECIAL_DESC,
       T.ALPHA_CODE,
       T.CRAFT_FILE_NO,
       T.CRAFT_SEQ,
       T.ORD_LN_DLY_PK,
       T.SINGLE_CUT_NUN,
       DECODE(T.IF_MATCH_ODD, '0', '正常计划','2','组炉计划','3','精整利库', '利库计划') IF_MATCH_ODD,
       DECODE(T.IF_DO_HEAT_PLAN, '1', '是', '/') IF_DO_HEAT_PLAN,
       T.OUTWL_ID,
       T.OUTWL_DESC,
       T.STOVE_NO,
       T.FLAG_STOVE_NO,
       T.GX_PRO_SEQ,
       T.PRO_DAY,
       T.BAL_YEAR_MONTH,
       T.PROD_STANDARD,
       T.OUTPUT_STANDARD,
       T.UPPER_HEATPLAN_ID,
       T.FEED_HEAT_NO,
       S.PLN_DIVIDE_ID,
       DECODE(T.IS_LOAD_FLAG,'1','是','否')IS_LOAD_FLAG,
       (SELECT MAX(DECODE(Z.PLANSTATUS,
                          '00',
                          '计划',
                          '10',
                          '下发',
                          '20',
                          '生产中',
                          '30',
                          '生产完成',
                          '40',
                          '关闭'))
          FROM PLN_ZY_RCL_M Z
         WHERE Z.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO) PLANSTATUS_GX,
       T.UPPER_PROCESS_CODE,T.STD_CODE,
       T.STD_NAME,T.STD_STYLE,T.STD_STYLE_DESC,
       T.PRODUCCODE_JG,T.PRODUCCODE_JG_DESC,
        (SELECT DECODE(MIN(S1.EXE_STATUS),
                      '0',
                      '计划',
                      '1',
                      '生产中',
                      '2',
                      '已生产',
                      '3',
                      '关闭')
          FROM PLN_ORDER_JGX_S S1, PLN_ORDER_JG J, PLN_JG_AND_BL B
 WHERE J.PRO_PLAN_ID = B.PRO_PLAN_ID
   AND S1.ORD_LN_DLY_PK = J.ORD_LN_DLY_PK
   AND B.REQ_BL_ID = S.ORD_LN_DLY_PK) CP_EXE_STATUS  
  FROM PLN_ZY_JG_M T, PLN_GX_JG_PROP_S S
 WHERE T.PRO_PLAN_ID = S.PRO_PLAN_ID
   AND T.GX_PLAN_NO = S.GX_PLAN_NO
 ]]>
	</query>

	<query id="FrmPlanStoveH.queryPlanStoveReadyH" desc="查询接箍实际炉计划">
            <![CDATA[ 
SELECT T.HEAT_PLAN_NO,
       T.PRO_PLAN_ID,
       T.JG_GROUP_ID,
       T.GX_PLAN_NO,
       T.JUDGE_STOVE_NO,
       T.PLINE_CODE,
       T.PLINE_NAME,
       T.CODE_JG_BL,
       T.BL_WL_ID,
       T.BL_WL_DESC,
       T.STEELCODE,
       T.STEELNAME,
       T.GRADECODE,
       T.GRADENAME,
       T.MIN_D,
       T.MIN_H,
       T.AIMLENGTH_BL,
       T.AIM_CUT_LEN,
       T.LENGTH_MIN,
       T.LENGTH_MAX,
       T.TAPER,
       T.CODE_JG,
       T.MODEL_CODE,
       T.MODEL_DESC,
       T.OUTDIAMETER,
       T.WALLTHICK,
       T.SPEC_JG,
       T.SPEC_JG_DESC,
      (SELECT T1.BASENAME FROM COM_BASE_INFO T1 WHERE T1.BASECODE=T.STYLE_JG  AND T1.VALIDFLAG='1')  STYLE_JG,
       T.DIAMETER,
       T.CHECK_J_VAL,
       T.AIMLENGTH,
       T.SINGLEWEIGHT,
       T.COAT_TYPE,
       NVL(T.PLAN_JG_NUM,0) PLAN_JG_NUM,
       NVL(T.PLAN_BL_NUM,0) PLAN_BL_NUM,
       NVL(T.PLAN_BL_WT,0) PLAN_BL_WT,
       T.MONITORDEMAND,
       DECODE(T.IF_MONITOR_JG, '1', '是', '/') IF_MONITOR_JG,
       T.PRDCR_NO,
       T.CUT_MACH_GRP_NO,
       T.CUT_MACH_GRP_NM,
        (SELECT T1.BASENAME FROM COM_BASE_INFO T1 WHERE T1.BASECODE=T.DEMAND_COPPER  AND T1.VALIDFLAG='1') DEMAND_COPPER,
       T.LATHE_GRP_NO,
       T.LATHE_GRP_NM,
       DECODE(T.PLANSTATUS,
              '00',
              '计划',
              '10',
              '下发',
              '20',
              '生产中',
              '30',
              '生产完成',
              '40',
              '关闭') PLANSTATUS,
       T.MEMO,
       T.CREATE_NAME,
       TO_CHAR(T.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       T.UPDATE_NAME,
       TO_CHAR(T.UPDATE_TIME, 'YYYY-MM-DD HH24:MI:SS') UPDATE_TIME,
       T.CUST_ALPHA_NO,
       T.ORDER_SPECIAL_DESC,
       T.ALPHA_CODE,
       T.CRAFT_FILE_NO,
       T.CRAFT_SEQ,
       T.ORD_LN_DLY_PK,
       T.SINGLE_CUT_NUN,
       DECODE(T.IF_MATCH_ODD, '0', '正常计划','2','精整利库', '利库计划') IF_MATCH_ODD,
       DECODE(T.IF_DO_HEAT_PLAN, '1', '是', '/') IF_DO_HEAT_PLAN,
       T.OUTWL_ID,
       T.OUTWL_DESC,
       T.STOVE_NO,
       T.FLAG_STOVE_NO,
       T.GX_PRO_SEQ,
       T.PRO_DAY,
       T.BAL_YEAR_MONTH,
       T.PROD_STANDARD,
       T.OUTPUT_STANDARD,
       T.UPPER_HEATPLAN_ID,
       T.FEED_HEAT_NO,
       (SELECT MAX(DECODE(Z.PLANSTATUS,
                          '00',
                          '计划',
                          '10',
                          '下发',
                          '20',
                          '生产中',
                          '30',
                          '生产完成',
                          '40',
                          '关闭'))
          FROM PLN_ZY_RCL_M Z
         WHERE Z.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO) PLANSTATUS_GX,
       T.UPPER_PROCESS_CODE,
       T1.HEAT_PLAN_SQE,
       T1.JUGDE_APPLY_CODE,
       T1.OUT_JG_NUM,
       T1.USE_BL_NUM,
       T1.USE_BL_WT,T.STD_CODE,
       T.STD_NAME,T.STD_STYLE,T.STD_STYLE_DESC,
       T.PRODUCCODE_JG,T.PRODUCCODE_JG_DESC,T1.BATCH_NO,
       T1.BATCH_GROUD_NO,
       T1.REAL_OUTDOUBLE_NUM,
       T1.REAL_OUTDOUBLE_WT,
       T1.REAL_INDOUBLE_NUM,T1.REAL_INDOUBLE_WT,
        (SELECT DECODE(MIN(S1.EXE_STATUS),
                      '0',
                      '计划',
                      '1',
                      '生产中',
                      '2',
                      '已生产',
                      '3',
                      '关闭')
          FROM PLN_ORDER_JGX_S S1, PLN_ORDER_JG J, PLN_JG_AND_BL B
 WHERE J.PRO_PLAN_ID = B.PRO_PLAN_ID
   AND S1.ORD_LN_DLY_PK = J.ORD_LN_DLY_PK
   AND B.REQ_BL_ID = T.ORD_LN_DLY_PK) EXE_STATUS ,
   NVL((SELECT DECODE(max(P.ZY_BILL_STATUS),
                      '0',
                      '计划',
                      '1',
                      '下发',
                      '2',
                      '生产中',
                      '3',
                      '生产完成',
                      '4',
                      '关闭')   
          FROM PLN_ZY_JG_WORKBILL P
         WHERE P.HEAT_PLAN_NO = T1.HEAT_PLAN_NO
           AND P.JUDGE_STOVE_NO = T1.JUDGE_STOVE_NO
           AND P.BATCH_NO = T1.BATCH_NO) ,'无工单') ZY_BILL_STATUS
       
  FROM PLN_ZY_JG_M T, PLN_ZY_JG_C T1
 WHERE T.HEAT_PLAN_NO = T1.HEAT_PLAN_NO(+)
              ]]>
	</query>
	<query id="FrmPlanStoveH.getPlnMatBcJg" desc="查询库存">
            <![CDATA[
SELECT *
  FROM (SELECT T.*
          FROM MAT_BC_M T
         WHERE T.JUDGE_STOVE_NO = ?
           AND T.BATCH_NO = ?
           AND T.BATCH_GROUD_NO = ?
           AND NVL(T.JUGDE_APPLY_CODE ,'/')= NVL(?,'/')
           AND T.QCM_STAUS = '00'
           AND T.HANGING_FLAG = '1'
           AND T.HEAT_PLAN_NO_NEXT=?
         ORDER BY T.MAT_NO ASC)
 WHERE ROWNUM <= ?
             ]]>
	</query>
	<query id = "FrmPlanStoveH.updateLoadFlag" desc  = "修改标识">
		DECLARE
		BEGIN
		UPDATE PLN_ZY_JG_M T
		SET T.IS_LOAD_FLAG = '#IS_LOAD_FLAG#'
		WHERE T.HEAT_PLAN_NO = '#HEAT_PLAN_NO#';
		UPDATE PLN_ZY_JG_WORKBILL T
		SET T.IS_LOAD_FLAG = '#IS_LOAD_FLAG#'
		WHERE T.HEAT_PLAN_NO = '#HEAT_PLAN_NO#';
		END;
	</query>
</queryMap>