<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="炉次合并">

	<query id="FrmSteelMerge.UpdateFurnOrd" desc="修改炉次订单重量">
             <![CDATA[
      UPDATE PLN_STEELFOR_ORD T
   SET T.TOT_WEIGHT_M = TO_NUMBER(T.TOT_WEIGHT_M) + TO_NUMBER(?),
       T.TOT_MUM_M    = TO_NUMBER(T.TOT_MUM_M) + TO_NUMBER(?)
 WHERE T.FURNACENO = ?
   AND T.SEQUENCENO = ?
                  ]]>
	</query>
	<query id="FrmSteelMerge.QueryFurnGirdOrd" desc="查询选择Gird炉次是否全部合并">
             <![CDATA[
        SELECT SUM(T.TOT_WEIGHT_M) TOT_WEIGHT_M, SUM(T.TOT_MUM_M) TOT_MUM_M,
        MIN(CCM_SEQ) CCM_SEQ,MAX(SEQUENCENO) CUT_NUM,COUNT(*) COUNT,MIN(WEIGHT_M) WEIGHT_M
  FROM PLN_STEELFOR_ORD T
 WHERE T.FURNACENO = ?
 AND T.CCM_PLN_TYPE ='00'
    
                  ]]>
	</query>
	<query id="FrmSteelMerge.DeleteFurnOrd" desc="删除炉次订单">
      <![CDATA[
      DELETE PLN_STEELFOR_ORD  WHERE FURNACENO = ? AND SEQUENCENO = ? 
      ]]>
	</query>
	<query id="FrmSteelMerge.Updatefurnace" desc="修改炉次重量">
      <![CDATA[      
UPDATE PLN_STEELFORFURNACE T
   SET T.WEIGHT= TO_NUMBER(T.WEIGHT)+TO_NUMBER(?),
       T.QUANTITY = TO_NUMBER(T.QUANTITY)+TO_NUMBER(?),
       T.CIC     =
       (SELECT LISTAGG(CIC, ',') WITHIN GROUP(ORDER BY CIC) CIC
          FROM (SELECT DISTINCT T.CIC
                  FROM PLN_STEELFOR_ORD T
                 WHERE T.FURNACENO = ? AND T.CCM_PLN_TYPE ='00'))    
 WHERE T.FURNACENO = ?
      ]]>
	</query>
	<query id="FrmSteelMerge.Deletefurnace" desc="删除炉次">
      <![CDATA[
      DELETE PLN_STEELFORFURNACE T  WHERE T.FURNACENO = ? 
      ]]>
	</query>
	<query id="FrmSteelMerge.QueryFurnOrd" desc="根据铸造订单,排产序号,CIC,合并炉次是否有相同记录">
             <![CDATA[
SELECT T.*
  FROM PLN_STEELFOR_ORD T
 WHERE T.FURNACENO = ?
   AND T.PRO_PLAN_ID = ?
   AND T.GX_PLAN_NO = ?　
   AND T.CIC = ?
   AND T.SURPLUSFLAG = '0'
   AND T.CCM_PLN_TYPE ='00'
                  ]]>
	</query>
	<query id="FrmSteelMerge.QueryMaxSequenceno" desc="查询最大炉次订单顺序号">
      <![CDATA[
SELECT MAX(T.SEQUENCENO) SEQUENCENO
  FROM PLN_STEELFOR_ORD T
 WHERE T.FURNACENO = ?
 AND T.CCM_PLN_TYPE ='00'
   --AND T.SURPLUSFLAG='0' 
   AND (T.SURPLUS_TYPE NOT IN ('2','3') OR T.SURPLUS_TYPE IS NULL)
        ]]>
	</query>
	<query id="FrmSteelMerge.AddFurnOrd" desc="新增炉次订单">
      <![CDATA[
       INSERT INTO PLN_STEELFOR_ORD(
        FURNACENO,
        SEQUENCENO,
        FURNACENO_SEQ,
        PRO_PLAN_ID,
        GX_PLAN_NO,
        CAST_NO,
        CAST_SEQ,
        CAST_STOVE_SEQ,
        CCM_SEQ,
        STOVE_NO,
        JUDGE_STOVE_NO,
        JUDGE_STOVE_NO_SEQ,
        FLAG_STOVE_NO,
        STATUS,
        CCM_STATE,
        CCM_PLN_TYPE,
        GPTYPE,
        CASTINGTYPE,
        PLINE_CODE,
        PLINE_NAME,
        CCMID,
        FLOWNO,
        EF_PLINE_CODE,
        EF_PLINE_NAME,
        WLID_IN,
        WLDESC_IN,
        MATERIAL_NO,
        MATERIAL_NAME,
        GRADECODE,
        GRADENAME,
        DIAMETER,
        LEN_GP_SINGLE,
        CUT_NUM_GP,
        LENGTH_M,
        WEIGHT_GP_ONE,
        WEIGHT_M,
        TOT_MUM_M,
        TOT_WEIGHT_M,
        ACT_WEIGHT_M,
        ACT_MUM_M,
        SURPLUSFLAG,
        EXCESS_WT,
        EXCESS_NUM,
        SURPLUS_TYPE,
        IF_SURPLUS_ALLOTED,
        CIC,
        PIC,
        SIC,
        DIC,
        CHEM_JUDGE_ID,
        PHY_JUDGE_ID,
        COLLIGATE_JUDGE_ID,
        MEMO,
        MAKEMAN,
        MAKETIME,
        DOWNMAN,
        DOWNTIME,
        PRO_MONTH,
        ORDER_NO,
        FINAL_USER_DESC,
        STEELCODE,
        STEELNAME,
        PRODUCCODE,
        PRODUCNAME,
        GOWHERE_CODE,
        GOWHERE_NAME,
        ISENDGX,
        STATE_LK,
        IF_MONITOR_LG,
        PRDCR_NO,CUT_NUM)
 VALUES( 
        '#FURNACENO#',
        '#SEQUENCENO#',
        '#FURNACENO_SEQ#',
        '#PRO_PLAN_ID#',
        '#GX_PLAN_NO#',
        '#CAST_NO#',
        '#CAST_SEQ#',
        '#CAST_STOVE_SEQ#',
        '#CCM_SEQ#',
        '#STOVE_NO#',
        '#JUDGE_STOVE_NO#',
        '#JUDGE_STOVE_NO_SEQ#',
        '#FLAG_STOVE_NO#',
        '#STATUS#',
        '#CCM_STATE#',
        '#CCM_PLN_TYPE#',
        '#GPTYPE#',
        '#CASTINGTYPE#',
        '#PLINE_CODE#',
        '#PLINE_NAME#',
        '#CCMID#',
        '#FLOWNO#',
        '#EF_PLINE_CODE#',
        '#EF_PLINE_NAME#',
        '#WLID_IN#',
        '#WLDESC_IN#',
        '#MATERIAL_NO#',
        '#MATERIAL_NAME#',
        '#GRADECODE#',
        '#GRADENAME#',
        '#DIAMETER#',
        '#LEN_GP_SINGLE#',
        '#CUT_NUM_GP#',
        '#LENGTH_M#',
        '#WEIGHT_GP_ONE#',
        '#WEIGHT_M#',
        '#TOT_MUM_M#',
        '#TOT_WEIGHT_M#',
        '#ACT_WEIGHT_M#',
        '#ACT_MUM_M#',
        '#SURPLUSFLAG#',
        '#EXCESS_WT#',
        '#EXCESS_NUM#',
        '#SURPLUS_TYPE#',
        '#IF_SURPLUS_ALLOTED#',
        '#CIC#',
        '#PIC#',
        '#SIC#',
        '#DIC#',
        '#CHEM_JUDGE_ID#',
        '#PHY_JUDGE_ID#',
        '#COLLIGATE_JUDGE_ID#',
        '#MEMO#',
        '#MAKEMAN#',
        TO_DATE('#MAKETIME#','YYYY-MM-DD HH24:MI:SS'),
        '#DOWNMAN#',
        TO_DATE('#DOWNTIME#','YYYY-MM-DD HH24:MI:SS'),
        '#PRO_MONTH#',
        '#ORDER_NO#',
        '#FINAL_USER_DESC#',
        '#STEELCODE#',
        '#STEELNAME#',
        '#PRODUCCODE#',
        '#PRODUCNAME#',
        '#GOWHERE_CODE#',
        '#GOWHERE_NAME#',
        '#ISENDGX#',
        '#STATE_LK#',
        '#IF_MONITOR_LG#',
        '#PRDCR_NO#','#CUT_NUM#')
      ]]>
	</query>
	<query id="FrmSteelMerge.getDoGraderCIC" desc="查询钢种索引码及钢种索引码集合">
      <![CDATA[
      
SELECT T1.* FROM(SELECT T.CIC,
       T.CHEM_NAME,
       T.STDMIN_SIGN || T.STDMIN STDMIN,
       T.STDMAX_SIGN || T.STDMAX STDMAX,
       T.STDTARGET,
       T.CHEM_CODE 
  FROM CRAFT_ORD_DESIGN_STD_CIC T
 WHERE T.PROCESS_CODE = 'A'
   AND T.VALIDFLAG = '1'
   AND T.SPECL_FL = '2'
   AND T.CIC = (SELECT DISTINCT G.CIC
                  FROM PLN_STEELFOR_ORD G
                 WHERE G.FURNACENO = ? AND G.CCM_PLN_TYPE ='00')
   AND T.DESGIN_KEY =
       (SELECT MAX(T.DESGIN_KEY)
          FROM CRAFT_ORD_DESIGN T
         WHERE T.ORD_LN_PK =
               (SELECT MAX(T1.ORD_LN_PK)
                  FROM PLN_ORDER_ZG_S T, PLN_SALEORD T1
                 WHERE T.ORD_LN_DLY_PK = T1.ORD_LN_DLY_PK
                   AND T.GPREQ_ID =
                       (SELECT MAX(G.PRO_PLAN_ID)
                          FROM PLN_STEELFOR_ORD G
                         WHERE G.FURNACENO = ? AND G.CCM_PLN_TYPE ='00'))
           AND T.CRAFT_SEQ =
               (SELECT MAX(T.CRAFT_SEQ)
                  FROM PLN_ORDER_ZG_S T, PLN_SALEORD T1
                 WHERE T.ORD_LN_DLY_PK = T1.ORD_LN_DLY_PK
                   AND T.GPREQ_ID =
                       (SELECT MAX(G.PRO_PLAN_ID)
                          FROM PLN_STEELFOR_ORD G
                         WHERE G.FURNACENO = ? AND G.CCM_PLN_TYPE ='00')))
UNION ALL
SELECT T.CIC,
       T.CHEM_NAME,
       T.STDMIN_SIGN || T.STDMIN STDMIN,
       T.STDMAX_SIGN || T.STDMAX STDMAX,
       T.STDTARGET,
       T.CHEM_CODE
  FROM CRAFT_ORD_DESIGN_STD_CIC T
 WHERE T.PROCESS_CODE = 'A'
   AND T.VALIDFLAG = '1'
   AND T.SPECL_FL = '2'
   AND T.CIC = (SELECT DISTINCT G.CIC
                  FROM PLN_STEELFOR_ORD G
                 WHERE G.FURNACENO = ? AND G.CCM_PLN_TYPE ='00')
   AND T.DESGIN_KEY =
       (SELECT MAX(T.DESGIN_KEY)
          FROM CRAFT_ORD_DESIGN T
         WHERE T.ORD_LN_PK =
               (SELECT MAX(T1.ORD_LN_PK)
                  FROM PLN_ORDER_ZG_S T, PLN_SALEORD T1
                 WHERE T.ORD_LN_DLY_PK = T1.ORD_LN_DLY_PK
                   AND T.GPREQ_ID =
                       (SELECT MAX(G.PRO_PLAN_ID)
                          FROM PLN_STEELFOR_ORD G
                         WHERE G.FURNACENO = ? AND G.CCM_PLN_TYPE ='00'))
           AND T.CRAFT_SEQ =
               (SELECT MAX(T.CRAFT_SEQ)
                  FROM PLN_ORDER_ZG_S T, PLN_SALEORD T1
                 WHERE T.ORD_LN_DLY_PK = T1.ORD_LN_DLY_PK
                   AND T.GPREQ_ID =
                       (SELECT MAX(G.PRO_PLAN_ID)
                          FROM PLN_STEELFOR_ORD G
                         WHERE G.FURNACENO = ? AND G.CCM_PLN_TYPE ='00')))
UNION ALL
SELECT '交集' CIC,
       T.CHEM_NAME,
       T.STDMIN_SIGN || T.STDMIN STDMIN,
       T.STDMAX_SIGN || T.STDMAX STDMAX,
       T.STDTARGET,
       T.CHEM_CODE
  FROM PLN_STEELFORFURNACE_CIC T
 WHERE T.FURNACENO_ALL = ?
    OR T.FURNACENO_ALL = ?) T1 ORDER BY T1.CIC,T1.CHEM_CODE
      
         ]]>
	</query>
	<query id="FrmSteelMerge.getUpdateSteeleCic" desc="修改交集成分标准表">
      <![CDATA[
      UPDATE PLN_STEELFORFURNACE_CIC
   SET STDTARGET = ?
 WHERE (FURNACENO_ALL = ? OR FURNACENO_ALL = ?)
   AND CHEM_NAME = ?
       ]]>
	</query>
	<query id="FrmSteelMerge.getCastFurnNoList" desc="通过浇次查询炉次信息">
      <![CDATA[
      SELECT T.FURNACENO,
       T.FURNACENO_SEQ,
       T.CAST_NO,
       T.CAST_SEQ,
       T.CAST_STOVE_SEQ,
       T.STOVE_NO,
       T.BOF_TYPE,
       T.STATUS,
       T.HEAT_STATE,
       T.CASTINGTYPE,
       T.EF_PLINE_CODE,
       T.EF_PLINE_NAME,
       T.EF_AGE,
       T.PLINE_CODE,
       T.PLINE_NAME,
       T.CCMID,
       T.WLID_IN,
       T.WLDESC_IN,
       T.MATERIAL_NO,
       T.MATERIAL_NAME,
       T.GRADECODE,
       T.GRADENAME,
       T.CIC,
       TO_CHAR(T.PLN_STARTTIME, 'YYYY-MM-DD HH24:MI:SS') PLN_STARTTIME,
       TO_CHAR(T.PLN_ENDTIME, 'YYYY-MM-DD HH24:MI:SS') PLN_ENDTIME,
       T.AIM_STEEL_QTY,
       T.QUANTITY,
       T.WEIGHT,
       T.OLD_FURNACENO,
       T.OLD_STOVE_NO,
       T.PLAN_ROUTE,
       T.FACT_ROUTE,
       TO_CHAR(T.STARTTIME, 'YYYY-MM-DD HH24:MI:SS') STARTTIME,
       TO_CHAR(T.ENDTIME, 'YYYY-MM-DD HH24:MI:SS') ENDTIME,
       TO_CHAR(T.BOF_STARTTIME, 'YYYY-MM-DD HH24:MI:SS') BOF_STARTTIME,
       TO_CHAR(T.BOF_ENDTIME, 'YYYY-MM-DD HH24:MI:SS') BOF_ENDTIME,
       TO_CHAR(T.CAS_STARTTIME, 'YYYY-MM-DD HH24:MI:SS') CAS_STARTTIME,
       TO_CHAR(T.CAS_ENDTIME, 'YYYY-MM-DD HH24:MI:SS') CAS_ENDTIME,
       TO_CHAR(T.VD_STARTTIME, 'YYYY-MM-DD HH24:MI:SS') VD_STARTTIME,
       TO_CHAR(T.VD_ENDTIME, 'YYYY-MM-DD HH24:MI:SS') VD_ENDTIME,
       TO_CHAR(T.RH_STARTTIME, 'YYYY-MM-DD HH24:MI:SS') RH_STARTTIME,
       TO_CHAR(T.RH_ENDTIME, 'YYYY-MM-DD HH24:MI:SS') RH_ENDTIME,
       TO_CHAR(T.LFS_STARTTIME, 'YYYY-MM-DD HH24:MI:SS') LFS_STARTTIME,
       TO_CHAR(T.LFS_ENDTIME, 'YYYY-MM-DD HH24:MI:SS') LFS_ENDTIME,
       TO_CHAR(T.CCM_STARTTIME, 'YYYY-MM-DD HH24:MI:SS') CCM_STARTTIME,
       TO_CHAR(T.CCM_ENDTIME, 'YYYY-MM-DD HH24:MI:SS') CCM_ENDTIME,
       T.SURPLUSFLAG,
       T.IF_MONITOR_LG,
       T.PRDCR_NO,
       T.CHEM_JUDGE_ID,
       T.PLANREMARK,
       T.REMARK,
       T.MAKEMAN,
       TO_CHAR(T.MAKETIME, 'YYYY-MM-DD HH24:MI:SS') MAKETIME,
       T.DOWNMAN,
       TO_CHAR(T.DOWNTIME, 'YYYY-MM-DD HH24:MI:SS') DOWNTIME,
       T.PRO_MONTH,
       T.CLOSEMAN,
       TO_CHAR(T.CLOSETIME, 'YYYY-MM-DD HH24:MI:SS') CLOSETIME,
       T.CRAFT_NO,
       T.CRAFT_PATH,
       T.IF_CONFIRM,
       T.BATCHING_CODE,
       T.BATCHING_NAME,
       T.HOTMETAL_NUM,
       T.IRON_NUM,
       T.STEELSCRAP_NUM,
       T.JUDGE_FLAG FROM PLN_STEELFORFURNACE T WHERE T.CAST_NO = ?
       ORDER BY T.FURNACENO_SEQ
       ]]>
	</query>
	<query id="FrmSteelMerge.getSteelFurnSeqHb" desc="通过爐號查询炉次信息">
      <![CDATA[
      SELECT T.FURNACENO,
       T.FURNACENO_SEQ,
       T.CAST_NO,
       T.CAST_SEQ,
       T.CAST_STOVE_SEQ,
       T.STOVE_NO,
       T.BOF_TYPE,
       T.STATUS,
       T.HEAT_STATE,
       T.CASTINGTYPE,
       T.EF_PLINE_CODE,
       T.EF_PLINE_NAME,
       T.EF_AGE,
       T.PLINE_CODE,
       T.PLINE_NAME,
       T.CCMID,
       T.WLID_IN,
       T.WLDESC_IN,
       T.MATERIAL_NO,
       T.MATERIAL_NAME,
       T.GRADECODE,
       T.GRADENAME,
       T.CIC,
       TO_CHAR(T.PLN_STARTTIME, 'YYYY-MM-DD HH24:MI:SS') PLN_STARTTIME,
       TO_CHAR(T.PLN_ENDTIME, 'YYYY-MM-DD HH24:MI:SS') PLN_ENDTIME,
       T.AIM_STEEL_QTY,
       T.QUANTITY,
       T.WEIGHT,
       T.OLD_FURNACENO,
       T.OLD_STOVE_NO,
       T.PLAN_ROUTE,
       T.FACT_ROUTE,
       TO_CHAR(T.STARTTIME, 'YYYY-MM-DD HH24:MI:SS') STARTTIME,
       TO_CHAR(T.ENDTIME, 'YYYY-MM-DD HH24:MI:SS') ENDTIME,
       TO_CHAR(T.BOF_STARTTIME, 'YYYY-MM-DD HH24:MI:SS') BOF_STARTTIME,
       TO_CHAR(T.BOF_ENDTIME, 'YYYY-MM-DD HH24:MI:SS') BOF_ENDTIME,
       TO_CHAR(T.CAS_STARTTIME, 'YYYY-MM-DD HH24:MI:SS') CAS_STARTTIME,
       TO_CHAR(T.CAS_ENDTIME, 'YYYY-MM-DD HH24:MI:SS') CAS_ENDTIME,
       TO_CHAR(T.VD_STARTTIME, 'YYYY-MM-DD HH24:MI:SS') VD_STARTTIME,
       TO_CHAR(T.VD_ENDTIME, 'YYYY-MM-DD HH24:MI:SS') VD_ENDTIME,
       TO_CHAR(T.RH_STARTTIME, 'YYYY-MM-DD HH24:MI:SS') RH_STARTTIME,
       TO_CHAR(T.RH_ENDTIME, 'YYYY-MM-DD HH24:MI:SS') RH_ENDTIME,
       TO_CHAR(T.LFS_STARTTIME, 'YYYY-MM-DD HH24:MI:SS') LFS_STARTTIME,
       TO_CHAR(T.LFS_ENDTIME, 'YYYY-MM-DD HH24:MI:SS') LFS_ENDTIME,
       TO_CHAR(T.CCM_STARTTIME, 'YYYY-MM-DD HH24:MI:SS') CCM_STARTTIME,
       TO_CHAR(T.CCM_ENDTIME, 'YYYY-MM-DD HH24:MI:SS') CCM_ENDTIME,
       T.SURPLUSFLAG,
       T.IF_MONITOR_LG,
       T.PRDCR_NO,
       T.CHEM_JUDGE_ID,
       T.PLANREMARK,
       T.REMARK,
       T.MAKEMAN,
       TO_CHAR(T.MAKETIME, 'YYYY-MM-DD HH24:MI:SS') MAKETIME,
       T.DOWNMAN,
       TO_CHAR(T.DOWNTIME, 'YYYY-MM-DD HH24:MI:SS') DOWNTIME,
       T.PRO_MONTH,
       T.CLOSEMAN,
       TO_CHAR(T.CLOSETIME, 'YYYY-MM-DD HH24:MI:SS') CLOSETIME,
       T.CRAFT_NO,
       T.CRAFT_PATH,
       T.IF_CONFIRM,
       T.BATCHING_CODE,
       T.BATCHING_NAME,
       T.HOTMETAL_NUM,
       T.IRON_NUM,
       T.STEELSCRAP_NUM,
       T.JUDGE_FLAG FROM PLN_STEELFORFURNACE T WHERE T.FURNACENO = ?
       ]]>
	</query>
	<query id="FrmSteelMerge.getOrderOrdStee" desc="查询连铸订单信息">
      <![CDATA[
      SELECT T.FURNACENO,
        T.SEQUENCENO,
        T.FURNACENO_SEQ,
        T.PRO_PLAN_ID,
        T.GX_PLAN_NO,
        T.CAST_NO,
        T.CAST_SEQ,
        T.CAST_STOVE_SEQ,
        T.CCM_SEQ,
        T.STOVE_NO,
        T.JUDGE_STOVE_NO,
        T.JUDGE_STOVE_NO_SEQ,
        T.FLAG_STOVE_NO,
        T.STATUS,
        T.CCM_STATE,
        T.CCM_PLN_TYPE,
        T.GPTYPE,
        T.CASTINGTYPE,
        T.PLINE_CODE,
        T.PLINE_NAME,
        T.CCMID,
        T.FLOWNO,
        T.EF_PLINE_CODE,
        T.EF_PLINE_NAME,
        T.WLID_IN,
        T.WLDESC_IN,
        T.MATERIAL_NO,
        T.MATERIAL_NAME,
        T.GRADECODE,
        T.GRADENAME,
        T.DIAMETER,
        T.LEN_GP_SINGLE,
        T.CUT_NUM_GP,
        T.LENGTH_M,
        T.WEIGHT_GP_ONE,
        T.WEIGHT_M,
        T.TOT_MUM_M,
        T.TOT_WEIGHT_M,
        T.ACT_WEIGHT_M,
        T.ACT_MUM_M,
        T.SURPLUSFLAG,
        T.EXCESS_WT,
        T.EXCESS_NUM,
        T.SURPLUS_TYPE,
        T.IF_SURPLUS_ALLOTED,
        T.CIC,
        T.PIC,
        T.SIC,
        T.DIC,
        T.CHEM_JUDGE_ID,
        T.PHY_JUDGE_ID,
        T.COLLIGATE_JUDGE_ID,
        T.MEMO,
        T.MAKEMAN,
        TO_CHAR(T.MAKETIME,'YYYY-MM-DD HH24:MI:SS'),
        T.DOWNMAN,
        TO_CHAR(T.DOWNTIME,'YYYY-MM-DD HH24:MI:SS'),
        T.PRO_MONTH,
        T.ORDER_NO,
        T.FINAL_USER_DESC,
        T.STEELCODE,
        T.STEELNAME,
        T.PRODUCCODE,
        T.PRODUCNAME,
        T.GOWHERE_CODE,
        T.GOWHERE_NAME,
        T.ISENDGX,
        T.STATE_LK,
        T.IF_MONITOR_LG,
        T.PRDCR_NO,T.PDEPT_NAME,T.PRDCR_MAN,T.CUT_NUM,T1.IF_CONFIRM
        FROM PLN_STEELFOR_ORD T, PLN_STEELFORCAST T1
 WHERE T1.CAST_NO=T.CAST_NO  AND T.CCM_PLN_TYPE ='00'
       ]]>
	</query>
	<query id="FrmSteelMerge.getQueryCraftLgM" desc="查询是否存在同钢种，同炼钢产线，同CIC 的工艺文件">
      <![CDATA[
SELECT count(*) COUNT
  FROM CRAFT_LG2_M T
 WHERE T.VERSION_NO='1'  AND T.CIC LIKE '%'||?||'%'
   AND T.GRADECODE = ?
   AND T.PLINE_CODE = ?
   AND T.CRAFT_ROUTE= ?
       ]]>
	</query>
	<query id="FrmSteelMerge.getQueryCraftLgMNo" desc="查询是否存在同钢种，同炼钢产线，同CIC 的工艺文件">
      <![CDATA[
SELECT T.CRAFT_NO
  FROM CRAFT_LG2_M T
 WHERE  T.CIC = ?
   AND T.GRADECODE = ?
   AND T.PLINE_CODE = ?
   AND T.CRAFT_ROUTE= ?
   ORDER BY DEFAULTCRAFT DESC
       ]]>
	</query>
	<query id="FrmSteelMerge.getUpdateFurnNoCraftNo" desc="工艺文件只有一个的时候修改炉次表">
      <![CDATA[   
UPDATE PLN_STEELFORFURNACE
   SET CRAFT_NO =?
 WHERE FURNACENO = ?
        ]]>
	</query>
	<query id="FrmSteelMerge.getUpdatePlnZzCraftNo" desc="工艺文件只有一个的时候修改订单表">
      <![CDATA[   
UPDATE PLN_ORDER_CAST_S
   SET CRAFT_NO =?
 WHERE PRO_PLAN_ID = ?
 AND GX_PLAN_NO=?
        ]]>
	</query>
	<query id="FrmSteelMerge.getUpdateFurnConfirm" desc="修改确认标志">
      <![CDATA[   
UPDATE PLN_STEELFORFURNACE
   SET IF_CONFIRM =?
   WHERE FURNACENO = ?
        ]]>
	</query>
	<query id="FrmSteelMerge.getUpdateFurnConfirmPlnORDER" desc="修改确认标志铸造">
      <![CDATA[   
UPDATE PLN_ORDER_CAST_S
   SET IF_CONFIRM =?
   WHERE PRO_PLAN_ID = ? AND GX_PLAN_NO=?
        ]]>
	</query>
	<query id="FrmSteelMerge.doUpdateScheme" desc="调整配料方案">
      <![CDATA[   
UPDATE PLN_STEELFORFURNACE
   SET BATCHING_CODE  = ?,
       BATCHING_NAME  = ?,
       HOTMETAL_NUM   = ?,
       IRON_NUM       = ?,
       STEELSCRAP_NUM = ?
 WHERE FURNACENO = ?
        ]]>
	</query>
	<query id="FrmSteelMerge.doUpdateLenght" desc="修改炉次订单单倍坯长">
      <![CDATA[   
     UPDATE PLN_STEELFOR_ORD T
   SET T.LEN_GP_SINGLE = ?,
       T.LENGTH_M      = ?,
       T.WEIGHT_GP_ONE = ?,
       T.WEIGHT_M      = ?,
       T.TOT_MUM_M     = ?,
       T.TOT_WEIGHT_M  =?,
       T.CUT_NUM_GP    =?
 WHERE T.FURNACENO = ?
   AND T.SEQUENCENO = ?
       ]]>
	</query>
	<query id="FrmSteelMerge.getQueryCastFurnTime" desc="查询浇次炉次信息">
      <![CDATA[   
    SELECT 
       T.CAST_NO,
       T.CAST_SEQ,
       T.FURNACENO,
       T.FURNACENO_SEQ,
       TO_CHAR(T.PLN_STARTTIME, 'YYYY-MM-DD HH24:MI:SS') PLN_STARTTIME,
       TO_CHAR(T.PLN_ENDTIME, 'YYYY-MM-DD HH24:MI:SS') PLN_ENDTIME
  FROM  PLN_STEELFORFURNACE T
 WHERE T.FURNACENO = ?
   AND T.EF_PLINE_CODE = ?
 ORDER BY T.FURNACENO_SEQ ASC
       ]]>
	</query>
	<query id="FrmSteelMerge.UpdateDoProMemo" desc="修改计划/工艺备注">
      <![CDATA[  
      UPDATE PLN_ORDER_CAST_S T
   SET T.PROGY_MEMO = '#PROGY_MEMO#',
       T.MEMO = '#MEMO#'
 WHERE T.PRO_PLAN_ID = '#PRO_PLAN_ID#'
   AND T.GX_PLAN_NO = '#GX_PLAN_NO#' 
         ]]>
	</query>
	<query id="FrmSteelMerge.getQueryCicAll" desc="查询CIC交集">
      <![CDATA[ 
      SELECT * FROM PLN_STEELFORFURNACE_CIC T WHERE  INSTR(T.CIC, ?) > 0  
       ]]>
	</query>
	<query id="FrmSteelMerge.addFurnaceOrd" desc="新增余材">
      <![CDATA[ 
      INSERT INTO PLN_STEELFOR_ORD(
        FURNACENO,
        SEQUENCENO,
        FURNACENO_SEQ,
        PRO_PLAN_ID,
        GX_PLAN_NO,
        CAST_NO,
        CAST_SEQ,
        CAST_STOVE_SEQ,
        CCM_SEQ,
        STOVE_NO,
        JUDGE_STOVE_NO,
        JUDGE_STOVE_NO_SEQ,
        FLAG_STOVE_NO,
        STATUS,
        CCM_STATE,
        CCM_PLN_TYPE,
        GPTYPE,
        CASTINGTYPE,
        PLINE_CODE,
        PLINE_NAME,
        CCMID,
        FLOWNO,
        EF_PLINE_CODE,
        EF_PLINE_NAME,
        WLID_IN,
        WLDESC_IN,
        MATERIAL_NO,
        MATERIAL_NAME,
        GRADECODE,
        GRADENAME,
        DIAMETER,
        LEN_GP_SINGLE,
        CUT_NUM_GP,
        LENGTH_M,
        WEIGHT_GP_ONE,
        WEIGHT_M,
        TOT_MUM_M,
        TOT_WEIGHT_M,
        ACT_WEIGHT_M,
        ACT_MUM_M,
        SURPLUSFLAG,
        EXCESS_WT,
        EXCESS_NUM,
        SURPLUS_TYPE,
        IF_SURPLUS_ALLOTED,
        CIC,
        PIC,
        SIC,
        DIC,
        CHEM_JUDGE_ID,
        PHY_JUDGE_ID,
        COLLIGATE_JUDGE_ID,
        MEMO,
        MAKEMAN,
        MAKETIME,
        DOWNMAN,
        DOWNTIME,
        PRO_MONTH,
        ORDER_NO,
        FINAL_USER_DESC,
        STEELCODE,
        STEELNAME,
        PRODUCCODE,
        PRODUCNAME,
        GOWHERE_CODE,
        GOWHERE_NAME,
        ISENDGX,
        STATE_LK,
        IF_MONITOR_LG,
        PRDCR_NO,CUT_NUM)
 VALUES( 
        '#FURNACENO#',
        '#SEQUENCENO#',
        '#FURNACENO_SEQ#',
        '#PRO_PLAN_ID#',
        '#GX_PLAN_NO#',
        '#CAST_NO#',
        '#CAST_SEQ#',
        '#CAST_STOVE_SEQ#',
        '#CCM_SEQ#',
        '#STOVE_NO#',
        '#JUDGE_STOVE_NO#',
        '#JUDGE_STOVE_NO_SEQ#',
        '#FLAG_STOVE_NO#',
        '#STATUS#',
        '#CCM_STATE#',
        '#CCM_PLN_TYPE#',
        '#GPTYPE#',
        '#CASTINGTYPE#',
        '#PLINE_CODE#',
        '#PLINE_NAME#',
        '#CCMID#',
        '#FLOWNO#',
        '#EF_PLINE_CODE#',
        '#EF_PLINE_NAME#',
        '#WLID_IN#',
        '#WLDESC_IN#',
        '#MATERIAL_NO#',
        '#MATERIAL_NAME#',
        '#GRADECODE#',
        '#GRADENAME#',
        '#DIAMETER#',
        '#LEN_GP_SINGLE#',
        '#CUT_NUM_GP#',
        '#LENGTH_M#',
        '#WEIGHT_GP_ONE#',
        '#WEIGHT_M#',
        '#TOT_MUM_M#',
        '#TOT_WEIGHT_M#',
        '#ACT_WEIGHT_M#',
        '#ACT_MUM_M#',
        '#SURPLUSFLAG#',
        '#EXCESS_WT#',
        '#EXCESS_NUM#',
        '#SURPLUS_TYPE#',
        '#IF_SURPLUS_ALLOTED#',
        '#CIC#',
        '#PIC#',
        '#SIC#',
        '#DIC#',
        '#CHEM_JUDGE_ID#',
        '#PHY_JUDGE_ID#',
        '#COLLIGATE_JUDGE_ID#',
        '#MEMO#',
        '#MAKEMAN#',
        SYSDATE,
        '#DOWNMAN#',
        SYSDATE,
        '#PRO_MONTH#',
        '#ORDER_NO#',
        '#FINAL_USER_DESC#',
        '#STEELCODE#',
        '#STEELNAME#',
        '#PRODUCCODE#',
        '#PRODUCNAME#',
        '#GOWHERE_CODE#',
        '#GOWHERE_NAME#',
        '#ISENDGX#',
        '#STATE_LK#',
        '#IF_MONITOR_LG#',
        '#PRDCR_NO#','#CUT_NUM#') 
       ]]>
	</query>
	<query id="FrmSteelMerge.getMaxMegerNo" desc="查询炉次订单合并编号">
      <![CDATA[  
      SELECT ? || LPAD(SUBSTR(NVL(MAX(T.MERGE_NO), '00'), -2, 2) + 1, 2, '0') AS MERGE_NO
  FROM PLN_STEELFOR_MERGE T
 WHERE T.FURNACENO = ?
      ]]>
	</query>
	<query id="FrmSteelMerge.addMegerNo" desc="新增炉次订单合并记录">
      <![CDATA[  
 INSERT INTO PLN_STEELFOR_MERGE(
        MERGE_NO,
        MERGE_SEQ,
        PRO_PLAN_ID,
        GX_PLAN_NO,
        LEN_GP_SINGLE,
        CUT_NUM_GP,
        WEIGHT_GP_ONE,
        TOT_MUM_M,
        TOT_WEIGHT_M,
        CIC,
        PIC,
        SIC,
        DIC,
        MAKEMAN,
        MAKETIME,
        ORDER_NO,
        FINAL_USER_DESC,
        STEELCODE,
        STEELNAME,
        PRODUCCODE,
        PRODUCNAME,
        IF_MONITOR_LG,
        PRDCR_NO,FURNACENO,PDEPT_NAME,PRDCR_MAN,STATE_LK)
 VALUES( 
        ?,
        ?,
        '#PRO_PLAN_ID#',
        '#GX_PLAN_NO#',
        '#LEN_GP_SINGLE#',
        '#CUT_NUM_GP#',
        '#WEIGHT_GP_ONE#',
        '#TOT_MUM_M#',
        '#TOT_WEIGHT_M#',
        '#CIC#',
        '#PIC#',
        '#SIC#',
        '#DIC#',
        '#MAKEMAN#',
        TO_DATE(?,'YYYY-MM-DD HH24:MI:SS'),
        '#ORDER_NO#',
        '#FINAL_USER_DESC#',
        '#STEELCODE#',
        '#STEELNAME#',
        '#PRODUCCODE#',
        '#PRODUCNAME#',
        '#IF_MONITOR_LG#',
        '#PRDCR_NO#','#FURNACENO#','#PDEPT_NAME#','#PRDCR_MAN#','#STATE_LK#')
      ]]>
	</query>
	<query id="FrmSteelMerge.queryOrderMax" desc="获取产线对应最大余材订单合同">
      <![CDATA[  
      SELECT ? || LPAD(SUBSTR(NVL(MAX(T.MERGE_NO), '00'), -2, 2) + 1, 2, '0') AS MERGE_NO
  FROM PLN_STEELFOR_MERGE T
 WHERE T.FURNACENO = ?
      ]]>
	</query>
	<query id="FrmSteelMerge.updateAimSteelWt" desc="修改目标钢水量">
      <![CDATA[    
DECLARE
BEGIN
  FOR MYROW IN (SELECT CASE
                         WHEN COUNT(*) = 0 THEN
                          0
                         ELSE
                          CEIL(SUM(NVL(T.WEIGHT, 0)) / COUNT(*))
                       END AIM_STEEL_QTY,
                       CASE
                         WHEN COUNT(*) = 0 THEN
                          0
                         ELSE
                          SUM((SELECT SUM(NVL(O.TOT_WEIGHT_M, 0))
                                FROM PLN_STEELFOR_ORD O
                               WHERE O.CAST_NO = ?
                                 AND O.SURPLUSFLAG = '0'
                                 AND O.FURNACENO = T.FURNACENO AND O.CCM_PLN_TYPE ='00')) / COUNT(*)
                       END AVERAGE_QTY
                  FROM PLN_STEELFORFURNACE T
                 WHERE T.CAST_NO = ?) LOOP
    UPDATE PLN_STEELFORFURNACE T
       SET T.AIM_STEEL_QTY = MYROW.AIM_STEEL_QTY
     WHERE T.CAST_NO = ?;
    UPDATE PLN_STEELFORCAST T
       SET T.AIM_STEEL_QTY = MYROW.AIM_STEEL_QTY,
           T.AVERAGE_QTY   = MYROW.AVERAGE_QTY
     WHERE T.CAST_NO = ?;
  END LOOP;
END;

      
         ]]>
	</query>
</queryMap>