<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="镦拔扩炉计划">

	<query id="FrmPlanStoveE.queryPlanStoveME" desc="查询镦拔扩虚拟炉计划">
            <![CDATA[
SELECT T.HEAT_PLAN_NO,
       S.GX_PRO_SEQ,
       T.STOVE_NO,
       T.JUDGE_STOVE_NO,
       DECODE(T.PLANSTATUS,'00','计划','10','下发','20','生产中','30','生产完成','40','关闭') PLANSTATUS,
       DECODE(T.PER_STATUS,'00','上料开始','10','旋扩开始','20','匀整开始','30','定径开始','40','表验开始','50','测量开始','60','交库开始','/') PER_STATUS,
       DECODE(T.BESIDE_STATUS,'00','上料结束','10','旋扩结束','20','匀整结束','30','定径结束','40','表验结束','50','测量结束','60','交库结束','/') BESIDE_STATUS,
       T.UPPER_HEATPLAN_ID,
       T.PRO_PLAN_ID,
       T.GX_PLAN_NO,
       T.PLINE_CODE,
       T.PLINE_NAME,
       T.PROCESS_CODE_C,
       T.PROCESS_DESC_C,
       T.UPPER_PROCESS_CODE,
       T.NEXT_PROCESS_CODE,
       T.GOWHERE_CODE,
       T.GOWHERE_NAME,
       T.PROD_STANDARD,
       T.OUTPUT_STANDARD,
       DECODE(T.ISENDGX,'1','是','/') ISENDGX,
       DECODE(T.IF_MATCH_ODD,'1','利库计划','2','组炉计划','3','精整利库','6','本工序精整利库','正常计划') IF_MATCH_ODD,
       DECODE(T.IF_DO_HEAT_PLAN,'1','有','无') IF_DO_HEAT_PLAN,
       T.ORDER_SOURCE,
       T.ORD_LN_DLY_PK,
       T.ORDER_NO||'/'||T.ORDER_SEQ ORDER_NO,
       T.ORDER_SEQ,
       T.DELIVERY_NO,
       T.REQ_BL_ID,
       T.IF_EXPORT,
       T.PRIORITY,
       T.PRIORITY_MEMO,
       T.PRO_MONTH,
       TO_CHAR(TO_DATE(T.PRO_DAY, 'YYYY-MM-DD'), 'YYYY-MM-DD') PRO_DAY,
       TO_CHAR(TO_DATE(T.BAL_YEAR_MONTH, 'YYYY-MM'), 'YYYY-MM') BAL_YEAR_MONTH,
       DECODE(T.IF_MONITOR,'1','是','/') IF_MONITOR,
       T.PRDCR_NO,
       T.MONITOR_POINT,
       T.BOM,
       T.WHOLE_BACKLOG,
       T.WHOLE_BACKLOG_DESC,
       T.STATION_ROAD,
       T.CIC,
       T.PIC,
       T.SIC,
       T.DIC,
       T.CRAFT_FILE_NO,
       T.CRAFT_FILE_MAN,
       T.CRAFT_SEQ,
       T.SEC_CRAFT_FILE_NO,
       T.GRADECODE,
       T.GRADENAME,
       T.STEELCODE,
       T.STEELNAME,
       T.PRODUCCODE,
       T.PRODUCNAME,
       T.MODEL_CODE,
       T.MODEL_DESC,
       T.INWL_ID,
       T.INWL_DESC,
       T.OUTWL_ID,
       T.OUTWL_DESC,
       T.OUTDIAMETER_IN,
       T.WALLTHICK_IN,
       T.LENGTH_IN,
       T.LENGTHMAX_IN,
       T.LENGTHMIN_IN,
       T.OUTNUM_CUT,
       T.AIMOUTDIAMETER,
       T.AIMWALLTHICK,
       T.AIMLENGTH,
       T.AIMLENGTH_MAX,
       T.AIMLENGTH_MIN,
       T.LEN_CUTHEAD,
       T.LEN_CUTEND,
       T.PLN_INSINGLE_NUM,
       T.PLN_INSINGLE_WT,
       T.PLN_INDOUBLE_NUM,
       T.PLN_INDOUBLE_WT,
       T.PLN_OUTSINGLE_NUM,
       T.PLN_OUTSINGLE_W,
       T.PLN_OUTDOUBLE_NUM,
       T.PLN_OUTDOUBLE_W,
       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.DOWNMAN,
       TO_CHAR(T.DOWNTIME, 'YYYY-MM-DD HH24:MI:SS') DOWNTIME,
       T.INDEX_SEQ,S.PLN_DIVIDE_ID,S.ZY_BATCH_ID,T.FEED_HEAT_NO,T.MEMO,T.ZY_BATCH_ID_ZG,
       T.DECISION,
       T.FLAG_STOVE_NO,
       (SELECT MAX(DECODE(Z.PLANSTATUS,'00','计划','10','下发','20','生产中','30','生产完成','40','关闭')) FROM PLN_ZY_ZG_M Z WHERE Z.Heat_Plan_No=T.Upper_Heatplan_Id)  PLANSTATUS_GX,
       DECODE(T.IS_LOAD_FLAG,'1','是','否')IS_LOAD_FLAG,
       DECODE(T.IS_WEIGHT_FLAG,'0','否','1','是')IS_WEIGHT_FLAG
  FROM PLN_ZY_DBK_M T, PLN_ORDER_DBK_S S
 WHERE T.PRO_PLAN_ID = S.PRO_PLAN_ID
   AND T.GX_PLAN_NO = S.GX_PLAN_NO
 ]]>
	</query>

	<query id="FrmPlanStoveE.queryPlanStoveReadyE" desc="查询镦拔扩实际炉计划">
            <![CDATA[
 SELECT T.HEAT_PLAN_NO,
       T.GX_PRO_SEQ,
       CASE
         WHEN T.ZY_BATCH_ID IS NULL THEN
          (SELECT S.ZY_BATCH_ID
             FROM PLN_ORDER_DBK_S S
            WHERE S.PRO_PLAN_ID = T.PRO_PLAN_ID
              AND S.GX_PLAN_NO = T.GX_PLAN_NO)
         ELSE
          T.ZY_BATCH_ID
       END ZY_BATCH_ID,
       T.STOVE_NO,
       T.JUDGE_STOVE_NO,
       DECODE(T.PLANSTATUS,'00','计划','10','下发','20','生产中','30','生产完成','40','关闭') PLANSTATUS,
       DECODE(T.PER_STATUS,'00','上料开始','10','旋扩开始','20','匀整开始','30','定径开始','40','表验开始','50','测量开始','60','交库开始') PER_STATUS,
       DECODE(T.BESIDE_STATUS,'00','上料结束','10','旋扩结束','20','匀整结束','30','定径结束','40','表验结束','50','测量结束','60','交库结束') BESIDE_STATUS,
       T.UPPER_HEATPLAN_ID,
       T.PRO_PLAN_ID,
       T.GX_PLAN_NO,
       T.PLINE_CODE,
       T.PLINE_NAME,
       T.PROCESS_CODE_C,
       T.PROCESS_DESC_C,
       T.UPPER_PROCESS_CODE,
       T.NEXT_PROCESS_CODE,
       T.GOWHERE_CODE,
       T.GOWHERE_NAME,
       T.PROD_STANDARD,
       T.OUTPUT_STANDARD,
       DECODE(T.ISENDGX,'1','是','/') ISENDGX,
        DECODE(T.IF_MATCH_ODD, '1', '利库计划','2','组炉计划','3','精整利库', '6','本工序精整利库','正常计划') IF_MATCH_ODD,
        DECODE(T.IF_DO_HEAT_PLAN,'1','有','无') IF_DO_HEAT_PLAN,
       T.ORDER_SOURCE,
       T.ORD_LN_DLY_PK,
      T.ORDER_NO || '/' || T.ORDER_SEQ ORDER_NO,
       T.ORDER_SEQ,
       T.DELIVERY_NO,
       T.REQ_BL_ID,
       T.IF_EXPORT,
       T.PRIORITY,
       T.PRIORITY_MEMO,
       T.PRO_MONTH,
       TO_CHAR(TO_DATE(T.PRO_DAY, 'YYYY-MM-DD'), 'YYYY-MM-DD') PRO_DAY,
       TO_CHAR(TO_DATE(T.BAL_YEAR_MONTH, 'YYYY-MM'), 'YYYY-MM') BAL_YEAR_MONTH,
       DECODE(T.IF_MONITOR,'1','是','/') IF_MONITOR,
       T.PRDCR_NO,
       T.MONITOR_POINT,
       T.BOM,
       T.WHOLE_BACKLOG,
       T.WHOLE_BACKLOG_DESC,
       T.STATION_ROAD,
       T.CIC,
       T.PIC,
       T.SIC,
       T.DIC,
       T.CRAFT_FILE_NO,
       T.CRAFT_FILE_MAN,
       T.CRAFT_SEQ,
       T.SEC_CRAFT_FILE_NO,
       T.GRADECODE,
       T.GRADENAME,
       T.STEELCODE,
       T.STEELNAME,
       T.PRODUCCODE,
       T.PRODUCNAME,
       T.MODEL_CODE,
       T.MODEL_DESC,
       T.INWL_ID,
       T.INWL_DESC,
       T.OUTWL_ID,
       T.OUTWL_DESC,
       T.OUTDIAMETER_IN,
       T.WALLTHICK_IN,
       T.LENGTH_IN,
       T.LENGTHMAX_IN,
       T.LENGTHMIN_IN,
       T.OUTNUM_CUT,
       T.AIMOUTDIAMETER,
       T.AIMWALLTHICK,
       T.AIMLENGTH,
       T.AIMLENGTH_MAX,
       T.AIMLENGTH_MIN,
       T.LEN_CUTHEAD,
       T.LEN_CUTEND,
       NVL(T.PLN_INSINGLE_NUM,0) PLN_INSINGLE_NUM,
       NVL(T.PLN_INSINGLE_WT,0) PLN_INSINGLE_WT,
       NVL(T.PLN_INDOUBLE_NUM,0) PLN_INDOUBLE_NUM,
       NVL(T.PLN_INDOUBLE_WT,0) PLN_INDOUBLE_WT,
       NVL(T.PLN_OUTSINGLE_NUM,0) PLN_OUTSINGLE_NUM,
       NVL(T.PLN_OUTSINGLE_W,0) PLN_OUTSINGLE_W,
       NVL(T.PLN_OUTDOUBLE_NUM,0) PLN_OUTDOUBLE_NUM,
       NVL(T.PLN_OUTDOUBLE_W,0) PLN_OUTDOUBLE_W,
       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.DOWNMAN,
       TO_CHAR(T.DOWNTIME, 'YYYY-MM-DD HH24:MI:SS') DOWNTIME,
       T.INDEX_SEQ,  
       T1.HEAT_PLAN_SQE,
       T1.BATCH_NO,
       T1.BATCH_GROUD_NO,
       T1.JUGDE_APPLY_CODE,     
       T1.PLAN_INDOUBLE_NUM,
       T1.PLAN_INDOUBLE_WT,
       T1.REAL_INDOUBLE_NUM,
       T1.REAL_INDOUBLE_WT,
       T1.REAL_OUTDOUBLE_NUM,
       T1.REAL_OUTDOUBLE_WT,T.FEED_HEAT_NO,T.MEMO,
       T.ZY_BATCH_ID_ZG,
       T.DECISION,
       (SELECT MAX(DECODE(Z.PLANSTATUS,'00','计划','10','下发','20','生产中','30','生产完成','40','关闭')) FROM PLN_ZY_ZG_M Z WHERE Z.Heat_Plan_No=T.Upper_Heatplan_Id)  PLANSTATUS_GX,
       (SELECT NVL(SUM(M.ACT_COUNT), 0)
          FROM MAT_BC_M M
         WHERE M.JUDGE_STOVE_NO = T1.FEED_HEAT_NO
           AND NVL(M.JUGDE_APPLY_CODE, '/') = NVL(T1.JUGDE_APPLY_CODE, '/')
           AND M.HEAT_PLAN_NO_NEXT = T.HEAT_PLAN_NO
           AND M.BATCH_NO= T1.BATCH_NO
           AND M.BATCH_GROUD_NO = T1.BATCH_GROUD_NO
           AND M.MAT_STATUS = '80150103'
            AND M.NEXT_PROCESS_CDOE='E') ACT_COUNT,
   T.FLAG_STOVE_NO,
     (select GET_BUTTRESS(T1.FEED_HEAT_NO,T1.BATCH_NO,T1.BATCH_GROUD_NO,'E',T1.HEAT_PLAN_NO) from dual) Storage_No,
     (
	SELECT
		APPLY_DESC
	FROM
		QCM_PROBLEM_HANDLING
	WHERE
		JUDGE_STOVE_NO = T.FEED_HEAT_NO
		--AND ( BATCH_NO = '1' OR BATCH_NO = t1.BATCH_NO )
		--AND ( BATCH_GROUD_NO = '1' OR BATCH_GROUD_NO = t1.BATCH_GROUD_NO )
		AND PROCESS_CODE = 'E'
		AND ROWNUM = '1'
	) APPLY_DESC
  FROM PLN_ZY_DBK_M T,PLN_ZY_DBK_C T1
 WHERE T.HEAT_PLAN_NO=T1.HEAT_PLAN_NO(+)
              ]]>
	</query>
	<query id="FrmPlanStoveE.QueryPlnZYStatus" desc="查询虚拟炉计划状态">
             <![CDATA[  
            SELECT T.PLANSTATUS
   FROM PLN_ZY_DBK_M T
  WHERE 1 = 1
    AND T.JUDGE_STOVE_NO = ?
    AND T.PRO_PLAN_ID=?
    AND T.GX_PLAN_NO=?
  ORDER BY T.PLANSTATUS DESC
              ]]>
	</query>
	<query id="FrmPlanStoveE.QueryfeedJut" desc="获取在最大判定炉号">
            <![CDATA[
            SELECT  CASE
         WHEN MAX(T.JUDGE_STOVE_NO) IS NULL THEN
          '380000'
         ELSE
         '38' || LPAD(SUBSTR(NVL(MAX(T.JUDGE_STOVE_NO), '0000'), -4, 4) + 1, 4, '0')
       END JUDGE_STOVE_NO
  FROM PLN_ZY_DBK_M T
 WHERE T.JUDGE_STOVE_NO IS NOT NULL
   AND T.JUDGE_STOVE_NO LIKE '%38%'
             ]]>
	</query>
	<query id="FrmPlanStoveE.QueryFeedAll" desc="获取镦拔扩虚拟炉炉计划所有区间判定炉号">
            <![CDATA[
           SELECT T.JUDGE_STOVE_NO
          FROM PLN_ZY_ZG_M T
         WHERE T.JUDGE_STOVE_NO LIKE '%38%'
           AND T.FEED_HEAT_NO=?
 ORDER BY T.JUDGE_STOVE_NO       
               ]]>
	</query>
	<query id="FrmPlanStoveE.QueryHeatPlanNo" desc="查询该炉是否存在多个订单">
            <![CDATA[
SELECT T.HEAT_PLAN_NO, T.JUDGE_STOVE_NO, T1.GX_PRO_SEQ
          FROM PLN_ZY_DBK_M T, PLN_ORDER_DBK_S T1
         WHERE T.PRO_PLAN_ID = T1.PRO_PLAN_ID
           AND T.GX_PLAN_NO = T1.GX_PLAN_NO
           AND T.FEED_HEAT_NO= ?
 ORDER BY TO_NUMBER(T1.GX_PRO_SEQ) ASC
             ]]>
	</query>
	<query id="FrmPlanStoveE.QueryRemaDbk" desc="查询是否有上料剩余计划支">
             <![CDATA[
   SELECT T1.FEED_HEAT_NO,
       T1.JUDGE_STOVE_NO,
       T.JUGDE_APPLY_CODE,
       T1.PRO_PLAN_ID,
       T1.GX_PLAN_NO,
       T.BATCH_NO,
       T.BATCH_GROUD_NO,
       T.PLAN_INDOUBLE_NUM,
       NVL(T.REAL_INDOUBLE_NUM, 0) REAL_INDOUBLE_NUM,
       TO_NUMBER(NVL(T.PLAN_INDOUBLE_NUM, 0)) -
       TO_NUMBER(NVL(T.REAL_INDOUBLE_NUM, 0)) COUNTNUM,
         T2.ACT_COUNT,
     T2.ACT_WEIGHT,
             T1.PLANSTATUS,
              NVL(T.REAL_INDOUBLE_WT, 0) REAL_INDOUBLE_WT
  FROM PLN_ZY_DBK_C T,PLN_ZY_DBK_M T1,(SELECT NVL(SUM(M.ACT_COUNT), 0) ACT_COUNT,
               NVL(SUM(M.ACT_WEIGHT), 0) ACT_WEIGHT,
               T3.HEAT_PLAN_SQE
          FROM MAT_BC_M M, PLN_ZY_JG_C T3
         WHERE M.JUDGE_STOVE_NO = T3.JUDGE_STOVE_NO
           AND NVL(M.JUGDE_APPLY_CODE, '/') = NVL(T3.JUGDE_APPLY_CODE, '/')
           AND M.PRO_PLAN_ID_NEXT = T3.PRO_PLAN_ID
           AND M.GX_PLAN_NO_NEXT = T3.GX_PLAN_NO
           AND M.BATCH_NO = T3.BATCH_NO
           AND M.BATCH_GROUD_NO = T3.BATCH_GROUD_NO
           AND M.MAT_STATUS = '80150103'
         GROUP BY T3.HEAT_PLAN_SQE) T2
 WHERE T1.HEAT_PLAN_NO = T.HEAT_PLAN_NO(+)
   AND T.HEAT_PLAN_SQE = T2.HEAT_PLAN_SQE(+)
   AND  T.HEAT_PLAN_NO = ?
   AND T.HEAT_PLAN_SQE = ?       
             ]]>
	</query>
	<query id="FrmPlanStoveE.QueryRemaRcl" desc="查询是否有上料剩余计划支">
             <![CDATA[
   SELECT T1.JUDGE_STOVE_NO,
       T.JUGDE_APPLY_CODE,
       T1.PRO_PLAN_ID,
       T1.GX_PLAN_NO,
       T.BATCH_NO,
       T.BATCH_GROUD_NO,
       T.PLAN_INDOUBLE_NUM,
       NVL(T.REAL_INDOUBLE_NUM, 0) REAL_INDOUBLE_NUM,
       TO_NUMBER(NVL(T.PLAN_INDOUBLE_NUM, 0)) -
       TO_NUMBER(NVL(T.REAL_INDOUBLE_NUM, 0)) COUNTNUM,
             T2.ACT_COUNT,
     T2.ACT_WEIGHT,
            T1.PLANSTATUS,
             NVL(T.REAL_INDOUBLE_WT, 0) REAL_INDOUBLE_WT
  FROM PLN_ZY_RCL_C T,PLN_ZY_RCL_M T1,(SELECT NVL(SUM(M.ACT_COUNT), 0) ACT_COUNT,
               NVL(SUM(M.ACT_WEIGHT), 0) ACT_WEIGHT,
               T3.HEAT_PLAN_SQE
          FROM MAT_BC_M M, PLN_ZY_JG_C T3
         WHERE M.JUDGE_STOVE_NO = T3.JUDGE_STOVE_NO
           AND NVL(M.JUGDE_APPLY_CODE, '/') = NVL(T3.JUGDE_APPLY_CODE, '/')
           AND M.PRO_PLAN_ID_NEXT = T3.PRO_PLAN_ID
           AND M.GX_PLAN_NO_NEXT = T3.GX_PLAN_NO
           AND M.BATCH_NO = T3.BATCH_NO
           AND M.BATCH_GROUD_NO = T3.BATCH_GROUD_NO
           AND M.MAT_STATUS = '80150103'
         GROUP BY T3.HEAT_PLAN_SQE) T2
 WHERE T1.HEAT_PLAN_NO = T.HEAT_PLAN_NO(+)
   AND T.HEAT_PLAN_SQE = T2.HEAT_PLAN_SQE(+)
   AND T.HEAT_PLAN_NO = ?
   AND T.HEAT_PLAN_SQE = ?       
             ]]>
	</query>
	<query id="FrmPlanStoveE.QueryRemaJgx" desc="查询是否有上料剩余计划支">
             <![CDATA[
  SELECT T1.JUDGE_STOVE_NO,
       T.JUGDE_APPLY_CODE,
       T1.PRO_PLAN_ID,
       T1.GX_PLAN_NO,
       T.BATCH_NO,
       T.BATCH_GROUD_NO,
       T.PLAN_INDOUBLE_NUM,
       NVL(T.REAL_INDOUBLE_NUM, 0) REAL_INDOUBLE_NUM,
       TO_NUMBER(NVL(T.PLAN_INDOUBLE_NUM, 0)) -
       TO_NUMBER(NVL(T.REAL_INDOUBLE_NUM, 0)) COUNTNUM,
          T2.ACT_COUNT,
     T2.ACT_WEIGHT,
           T1.PLANSTATUS,
           NVL(T.REAL_INDOUBLE_WT, 0) REAL_INDOUBLE_WT
  FROM PLN_ZY_JGX_C T,PLN_ZY_JGX_M T1,(SELECT NVL(SUM(M.ACT_COUNT), 0) ACT_COUNT,
               NVL(SUM(M.ACT_WEIGHT), 0) ACT_WEIGHT,
               T3.HEAT_PLAN_SQE
          FROM MAT_BC_M M, PLN_ZY_JG_C T3
         WHERE M.JUDGE_STOVE_NO = T3.JUDGE_STOVE_NO
           AND NVL(M.JUGDE_APPLY_CODE, '/') = NVL(T3.JUGDE_APPLY_CODE, '/')
           AND M.PRO_PLAN_ID_NEXT = T3.PRO_PLAN_ID
           AND M.GX_PLAN_NO_NEXT = T3.GX_PLAN_NO
           AND M.BATCH_NO = T3.BATCH_NO
           AND M.BATCH_GROUD_NO = T3.BATCH_GROUD_NO
           AND M.MAT_STATUS = '80150103'
         GROUP BY T3.HEAT_PLAN_SQE) T2
 WHERE T1.HEAT_PLAN_NO = T.HEAT_PLAN_NO(+)
   AND T.HEAT_PLAN_SQE = T2.HEAT_PLAN_SQE(+)
   AND T.HEAT_PLAN_NO = ?
   AND T.HEAT_PLAN_SQE = ?       
             ]]>
	</query>
	<query id="FrmPlanStoveE.QueryRemaJg" desc="查询是否有上料剩余计划支">
             <![CDATA[
  SELECT T1.JUDGE_STOVE_NO,
       T.JUGDE_APPLY_CODE,
       T1.PRO_PLAN_ID,
       T1.GX_PLAN_NO,
       T.BATCH_NO,
       T.BATCH_GROUD_NO,
       T.USE_BL_NUM,
       NVL(T.REAL_INDOUBLE_NUM, 0) REAL_INDOUBLE_NUM,
       TO_NUMBER(NVL(T.USE_BL_NUM, 0)) -
       TO_NUMBER(NVL(T.REAL_INDOUBLE_NUM, 0)) COUNTNUM,
     T2.ACT_COUNT,
     T2.ACT_WEIGHT,
           T1.PLANSTATUS,
            NVL(T.REAL_INDOUBLE_WT, 0) REAL_INDOUBLE_WT
  FROM PLN_ZY_JG_C T,PLN_ZY_JG_M T1,(SELECT NVL(SUM(M.ACT_COUNT), 0) ACT_COUNT,
               NVL(SUM(M.ACT_WEIGHT), 0) ACT_WEIGHT,
               T3.HEAT_PLAN_SQE
          FROM MAT_BC_M M, PLN_ZY_JG_C T3
         WHERE M.JUDGE_STOVE_NO = T3.JUDGE_STOVE_NO
           AND NVL(M.JUGDE_APPLY_CODE, '/') = NVL(T3.JUGDE_APPLY_CODE, '/')
           AND M.PRO_PLAN_ID_NEXT = T3.PRO_PLAN_ID
           AND M.GX_PLAN_NO_NEXT = T3.GX_PLAN_NO
           AND M.BATCH_NO = T3.BATCH_NO
           AND M.BATCH_GROUD_NO = T3.BATCH_GROUD_NO
           AND M.MAT_STATUS = '80150103'
         GROUP BY T3.HEAT_PLAN_SQE) T2
 WHERE T1.HEAT_PLAN_NO = T.HEAT_PLAN_NO(+)
   AND T.HEAT_PLAN_SQE = T2.HEAT_PLAN_SQE(+)
   AND T.HEAT_PLAN_NO = ?
   AND T.HEAT_PLAN_SQE = ?       
             ]]>
	</query>
	<query id="FrmPlanStoveE.UpdateMatBcYc" desc="释放管坯余材">
             <![CDATA[
 UPDATE MAT_BC_M M
   SET M.PRO_PLAN_ID_NEXT = '',
       M.HEAT_PLAN_NO_NEXT = '',
       M.GX_PLAN_NO_NEXT  = '',
       M.MAT_STATUS     = DECODE(M.JUDGE_RESULT_CODE,'','80150101','80150102'),
       M.HANGING_FLAG   = '0',
       M.LOCK_LIKU        = '0'
 WHERE M.JUDGE_STOVE_NO =?
   AND NVL(M.JUGDE_APPLY_CODE, '/') = NVL(?, '/')
   AND M.PRO_PLAN_ID_NEXT = ?
   AND M.GX_PLAN_NO_NEXT = ?
   AND M.BATCH_NO = ?
   AND M.BATCH_GROUD_NO = ?
   AND M.NEXT_PROCESS_CDOE=?
   AND M.MAT_STATUS = '80150103'
               ]]>
	</query>
		<query id="FrmPlanStoveE.queryZgMSStatus" desc="查询订单状态">
            <![CDATA[
            SELECT T.* FROM PLN_ORDER_DBK_S T WHERE T.PRO_PLAN_ID=? AND T.GX_PLAN_NO=?
                 ]]>
	</query>
	<query id="FrmPlanStoveE.SelectatchId" desc="查询是否存在轧批号">
		<![CDATA[
 SELECT COUNT(*) COUNT FROM PLN_ORDER_DBK_S T  
  WHERE T.ZY_BATCH_ID =?
    AND T.PLINE_CODE= ?
    AND T.VALIDFLAG='1'
		]]>
	</query>
		<query id="FrmPlanStoveE.UpdateBatchId" desc="修改轧管排产轧批号">
		<![CDATA[
 UPDATE PLN_ORDER_DBK_S T
    SET T.ZY_BATCH_ID ='#ZY_BATCH_ID#'
  WHERE T.PRO_PLAN_ID ='#PRO_PLAN_ID#'
    AND T.GX_PLAN_NO = '#GX_PLAN_NO#'
    AND T.VALIDFLAG='1'
		]]>
	</query>
		<query id="FrmPlanStoveE.QueryMatWt" desc="查询库存可拆吨">
		<![CDATA[
SELECT SUM(T.ACT_WEIGHT) ACT_WEIGHT
  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.HEAT_PLAN_NO_NEXT = ?
   AND T.NEXT_PROCESS_CDOE = ?
   AND T.QCM_STAUS = '00'
   AND T.MAT_STATUS = '80150103'
   AND ROWNUM <= ?	
			]]>
	</query>
		<query id="FrmPlanStoveE.addPlnMDbk" desc="新增镦拔扩虚拟炉计划">
		<![CDATA[
 INSERT INTO PLN_ZY_DBK_M(
        HEAT_PLAN_NO,
        GX_PRO_SEQ,
        ZY_BATCH_ID,
        STOVE_NO,
        JUDGE_STOVE_NO,
        BATCH_NO,
        PLANSTATUS,
        UPPER_HEATPLAN_ID,
        PRO_PLAN_ID,
        GX_PLAN_NO,
        PLINE_CODE,
        PLINE_NAME,
        PROCESS_CODE_C,
        PROCESS_DESC_C,
        UPPER_PROCESS_CODE,
        NEXT_PROCESS_CODE,
        GOWHERE_CODE,
        GOWHERE_NAME,
        PROD_STANDARD,
        OUTPUT_STANDARD,
        ISENDGX,
        IF_MATCH_ODD,
        IF_DO_HEAT_PLAN,
        ORDER_SOURCE,
        ORD_LN_DLY_PK,
        ORDER_NO,
        ORDER_SEQ,
        DELIVERY_NO,
        REQ_BL_ID,
        IF_EXPORT,
        PRIORITY,
        PRIORITY_MEMO,
        PRO_MONTH,
        PRO_DAY,
        BAL_YEAR_MONTH,
        IF_MONITOR,
        PRDCR_NO,
        MONITOR_POINT,
        BOM,
        WHOLE_BACKLOG,
        WHOLE_BACKLOG_DESC,
        STATION_ROAD,
        CIC,
        PIC,
        SIC,
        DIC,
        CRAFT_FILE_NO,
        CRAFT_FILE_MAN,
        CRAFT_SEQ,
        SEC_CRAFT_FILE_NO,
        GRADECODE,
        GRADENAME,
        STEELCODE,
        STEELNAME,
        PRODUCCODE,
        PRODUCNAME,
        MODEL_CODE,
        MODEL_DESC,
        INWL_ID,
        INWL_DESC,
        OUTWL_ID,
        OUTWL_DESC,
        OUTDIAMETER_IN,
        WALLTHICK_IN,
        LENGTH_IN,
        LENGTHMAX_IN,
        LENGTHMIN_IN,
        OUTNUM_CUT,
        AIMOUTDIAMETER,
        AIMWALLTHICK,
        AIMLENGTH,
        AIMLENGTH_MAX,
        AIMLENGTH_MIN,
        LEN_CUTHEAD,
        LEN_CUTEND,
        PLN_INSINGLE_NUM,
        PLN_INSINGLE_WT,
        PLN_INDOUBLE_NUM,
        PLN_INDOUBLE_WT,
        PLN_OUTSINGLE_NUM,
        PLN_OUTSINGLE_W,
        PLN_OUTDOUBLE_NUM,
        PLN_OUTDOUBLE_W,
        CREATE_NAME,
        CREATE_TIME,
        INDEX_SEQ,
        SPEC_CODE,
        SPEC_NAME,
        STD_CODE,
        STD_NAME,
        STD_STYLE,
        STD_STYLE_DESC,
        FEED_HEAT_NO,
        MEMO,
        ZY_BATCH_ID_ZG,
        DECISION,
        PASS_CODE,
        PASS_NAME,
        FLAG_STOVE_NO,HEAT_PLAN_NO_OLD)
 VALUES( 
        ?,
        '#GX_PRO_SEQ#',
        '#ZY_BATCH_ID#',
        '#STOVE_NO#',
        '#JUDGE_STOVE_NO#',
        '#BATCH_NO#',
        '00',
        '#UPPER_HEATPLAN_ID#',
        '#PRO_PLAN_ID#',
        '#GX_PLAN_NO#',
        '#PLINE_CODE#',
        '#PLINE_NAME#',
        '#PROCESS_CODE_C#',
        '#PROCESS_DESC_C#',
        '#UPPER_PROCESS_CODE#',
        '#NEXT_PROCESS_CODE#',
        '#GOWHERE_CODE#',
        '#GOWHERE_NAME#',
        '#PROD_STANDARD#',
        '#OUTPUT_STANDARD#',
        '#ISENDGX#',
        '#IF_MATCH_ODD#',
        '#IF_DO_HEAT_PLAN#',
        '#ORDER_SOURCE#',
        '#ORD_LN_DLY_PK#',
        '#ORDER_NO#',
        '#ORDER_SEQ#',
        '#DELIVERY_NO#',
        '#REQ_BL_ID#',
        '#IF_EXPORT#',
        '#PRIORITY#',
        '#PRIORITY_MEMO#',
        '#PRO_MONTH#',
        '#PRO_DAY#',
        '#BAL_YEAR_MONTH#',
        '#IF_MONITOR#',
        '#PRDCR_NO#',
        '#MONITOR_POINT#',
        '#BOM#',
        '#WHOLE_BACKLOG#',
        '#WHOLE_BACKLOG_DESC#',
        '#STATION_ROAD#',
        '#CIC#',
        '#PIC#',
        '#SIC#',
        '#DIC#',
        '#CRAFT_FILE_NO#',
        '#CRAFT_FILE_MAN#',
        '#CRAFT_SEQ#',
        '#SEC_CRAFT_FILE_NO#',
        '#GRADECODE#',
        '#GRADENAME#',
        '#STEELCODE#',
        '#STEELNAME#',
        '#PRODUCCODE#',
        '#PRODUCNAME#',
        '#MODEL_CODE#',
        '#MODEL_DESC#',
        '#INWL_ID#',
        '#INWL_DESC#',
        '#OUTWL_ID#',
        '#OUTWL_DESC#',
        '#OUTDIAMETER_IN#',
        '#WALLTHICK_IN#',
        '#LENGTH_IN#',
        '#LENGTHMAX_IN#',
        '#LENGTHMIN_IN#',
        '#OUTNUM_CUT#',
        '#AIMOUTDIAMETER#',
        '#AIMWALLTHICK#',
        '#AIMLENGTH#',
        '#AIMLENGTH_MAX#',
        '#AIMLENGTH_MIN#',
        '#LEN_CUTHEAD#',
        '#LEN_CUTEND#',
        '#PLN_INSINGLE_NUM#',
        '#PLN_INSINGLE_WT#',
        '#PLN_INDOUBLE_NUM#',
        '#PLN_INDOUBLE_WT#',
        '#PLN_OUTSINGLE_NUM#',
        '#PLN_OUTSINGLE_W#',
        '#PLN_OUTDOUBLE_NUM#',
        '#PLN_OUTDOUBLE_W#',
        ?,
        SYSDATE,
        '#INDEX_SEQ#',
        '#SPEC_CODE#',
        '#SPEC_NAME#',
        '#STD_CODE#',
        '#STD_NAME#',
        '#STD_STYLE#',
        '#STD_STYLE_DESC#',
        '#FEED_HEAT_NO#',
        '#MEMO#',
        '#ZY_BATCH_ID_ZG#',
        '#DECISION#',
        '#PASS_CODE#',
        '#PASS_NAME#',
        '#FLAG_STOVE_NO#','#HEAT_PLAN_NO_OLD#')
			]]>
	</query>
		<query id="FrmPlanStoveE.addPlnCDbk" desc="新增镦拔扩实际炉计划">
		<![CDATA[
INSERT INTO PLN_ZY_DBK_C
  (HEAT_PLAN_NO,
   HEAT_PLAN_SQE,
   JUGDE_APPLY_CODE,
   ZY_BATCH_ID,
   STOVE_NO,
   JUDGE_STOVE_NO,
   BATCH_NO,
   BATCH_GROUD_NO,
   PRO_PLAN_ID,
   GX_PLAN_NO,
   PLINE_CODE,
   PLINE_NAME,
   OUTDIAMETER_IN,
   WALLTHICK_IN,
   OUTNUM_CUT,
   LENGTH_IN,
   LENGTHMAX_IN,
   LENGTHMIN_IN,
   PLAN_INDOUBLE_NUM,
   PLAN_INDOUBLE_WT,
   REAL_INDOUBLE_NUM,
   REAL_INDOUBLE_WT,
   REAL_OUTDOUBLE_NUM,
   REAL_OUTDOUBLE_WT,
   FEED_HEAT_NO,
   FLAG_STOVE_NO)
VALUES
  (?,
   ?,
   '#JUGDE_APPLY_CODE#',
   '#ZY_BATCH_ID#',
   '#STOVE_NO#',
   '#JUDGE_STOVE_NO#',
   '#BATCH_NO#',
   '#BATCH_GROUD_NO#',
   '#PRO_PLAN_ID#',
   '#GX_PLAN_NO#',
   '#PLINE_CODE#',
   '#PLINE_NAME#',
   '#OUTDIAMETER_IN#',
   '#WALLTHICK_IN#',
   '#OUTNUM_CUT#',
   '#LENGTH_IN#',
   '#LENGTHMAX_IN#',
   '#LENGTHMIN_IN#',
   '#PLAN_INDOUBLE_NUM#',
   '#PLAN_INDOUBLE_WT#',
   '#REAL_INDOUBLE_NUM#',
   '#REAL_INDOUBLE_WT#',
   '#REAL_OUTDOUBLE_NUM#',
   '#REAL_OUTDOUBLE_WT#',
   '#FEED_HEAT_NO#',
   '#FLAG_STOVE_NO#')	
		]]>
	</query>
		<query id="FrmPlanStoveE.UpdateMatBc" desc="修改库存炉计划ID">
		<![CDATA[
   DECLARE
BEGIN
  FOR MYROW IN (SELECT MAT_NO
                  FROM (SELECT T.MAT_NO
                          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.HEAT_PLAN_NO_NEXT = ?
                           AND T.NEXT_PROCESS_CDOE = ?
                           AND T.QCM_STAUS = '00'
                           AND T.MAT_STATUS = '80150103'
                         ORDER BY T.MAT_NO ASC)
                 WHERE ROWNUM <= ?) LOOP
    UPDATE MAT_BC_M T
       SET T.HEAT_PLAN_NO_NEXT = ? WHERE T.MAT_NO = MYROW.MAT_NO;
  END LOOP;
END;

			]]>
	</query>
	<query id = "FrmPlanStoveE.updateGoWhere" desc = "修改去向">

		UPDATE PLN_ZY_DBK_M T
		SET T.GOWHERE_CODE = '#GOWHERE_CODE#', T.GOWHERE_NAME = '#GOWHERE_NAME#'
		WHERE T.HEAT_PLAN_NO = '#HEAT_PLAN_NO#'
	</query>
	<query id = "FrmPlanStoveE.updateLoadFlag" desc = "修改上料标识">
		UPDATE PLN_ZY_DBK_M T
		SET T.IS_LOAD_FLAG = '#IS_LOAD_FLAG#'
		WHERE T.HEAT_PLAN_NO = '#HEAT_PLAN_NO#'
	</query>
	<query id = "FrmPlanStoveE.updateIsWeight" desc = "修改过磅标识">
		UPDATE PLN_ZY_DBK_M T
		SET T.IS_WEIGHT_FLAG = '#IS_WEIGHT_FLAG#'
		WHERE T.HEAT_PLAN_NO = '#HEAT_PLAN_NO#'
	</query>
	<query id = "FrmPlanStoveE.updateDbkJudgeStoveNo" desc = "修改炉计划判定炉号">
		DECLARE
		BEGIN
		UPDATE PLN_ZY_DBK_M T
		SET T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#', T.FLAG_STOVE_NO = '#JUDGE_STOVE_NO#'
		WHERE T.HEAT_PLAN_NO = '#HEAT_PLAN_NO#';
		UPDATE PLN_ZY_DBK_C T
		SET T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#', T.FLAG_STOVE_NO = '#JUDGE_STOVE_NO#'
		WHERE T.HEAT_PLAN_NO = '#HEAT_PLAN_NO#';
		END;
	</query>
</queryMap>