/// <summary> 将Eclipse生产数据转换成SimON生产数据 </summary> public SCHEDULE ConvertToSimON(SCHEDULE sch, WELL location, DateTime startTime, BaseFile history) { // Todo :保存SCH SCHEDULE schedule = new SCHEDULE("SCHEDULE"); List <string> wellNames = new List <string>(); List <WELSPECS> ws = sch.FindAll <WELSPECS>(); // Todo :查找所有井名 ws.ForEach(l => wellNames.AddRange(l.Items.Select(k => k.jm0))); List <NAME> histNames = new List <NAME>(); // Todo :初始化名称 生产_historyproduction.dat wellNames.ForEach(l => histNames.Add(new NAME("NAME") { WellName = l })); histNames.ForEach(l => history.Key.Add(l)); // Todo :初始化完井WELL数据 List <NAME> names = new List <NAME>(); wellNames.ForEach(l => names.Add(new NAME("NAME") { WellName = l })); names.ForEach(l => location.Add(l)); List <DATES> ds = sch.FindAll <DATES>(); string format = "井名:{0} ({1},{2})"; // Todo :添加起始信息到时间步 DATES start = new DATES("DATES", startTime); sch.DeleteAll <DATES>(); start.AddRange <BaseKey>(sch.Keys); ds.Insert(0, start); List <PERF> comAllTemp = new List <PERF>(); foreach (DATES d in ds) { // Todo :对缓存中完井井名去重复取最后一条 var distincts = comAllTemp.GroupBy(l => l.WellName + l.I0 + l.J1 + l.K12).ToList(); comAllTemp.Clear(); foreach (var item in distincts) { comAllTemp.Add(item.Last()); } // 创建SimON日期 TIME time = new TIME("TIME"); time.Date = d.DateTime; schedule.Add(time); var wconprod = d.FindAll <WCONPROD>(); var wconhist = d.FindAll <WCONHIST>(); var wconinje = d.FindAll <WCONINJE>(); var wconinjh = d.FindAll <WCONINJH>(); // 完井数据(考虑到排序) List <BaseKey> compdats = d.FindAll <BaseKey>(l => l is COMPDAT || l is WELOPEN); List <WPIMULT> wpimult = d.FindAll <WPIMULT>(); List <WELOPEN> welopen = d.FindAll <WELOPEN>(); #region - 添加没有生产信息的完井 - // 添加完井数据 foreach (BaseKey c in compdats) { if (c is COMPDAT) { COMPDAT com = c as COMPDAT; foreach (COMPDAT.Item citem in com.Items) { // Todo :过滤有生产数据的,用后面方法处理 if (wconprod.Exists(l => l.Items.Exists(k => k.jm0 == citem.jm0))) { continue; } if (wconhist.Exists(l => l.Items.Exists(k => k.wellName0 == citem.jm0))) { continue; } if (wconinje.Exists(l => l.Items.Exists(k => k.jm0 == citem.jm0))) { continue; } if (wconinjh.Exists(l => l.Items.Exists(k => k.jm0 == citem.jm0))) { continue; } WELLCTRL well = time.Find <WELLCTRL>(l => l.WellName0 == citem.jm0); if (well == null) { // Todo :创建一个空的生产信息 well = new WELLCTRL("WELLCTRL"); well.ProType = SimONProductType.NA; well.WellName0 = citem.jm0; time.Add(well); } NAME name = names.Find(l => l.WellName == well.WellName0); #region - SCh数据 - PERF perf = new PERF("PERF"); perf.WellName = well.WellName0; perf.I0 = citem.i1; perf.J1 = citem.j2; perf.K12 = citem.swg3; perf.K23 = citem.xwg4; perf.Kgbs4 = citem.kgbz5; perf.Jzs6 = citem.ljyz7; perf.WjfxX7 = citem.skfx12 == "X" ? "DX" : "0"; perf.WjfxY8 = citem.skfx12 == "Y" ? "DY" : "0"; perf.WjfxZ9 = citem.skfx12 == "Z" ? "DZ" : "0"; perf.Bp10 = citem.bpxs10; // Todo :查找井指数乘子 foreach (WPIMULT wp in wpimult) { var v = wp.Items.Find(l => l.jm0 == well.WellName0); if (v != null) { perf.Jzscz5 = v.jzscz1; break; } } // Todo :增加前先删除存在的重复数据 well.DeleteAll <PERF>(l => l.I0 == perf.I0 && l.J1 == perf.J1 && l.K12 == perf.K12); well.Add(perf); #endregion #region - WELL数据 - NAME.Item nameItem = new NAME.Item(); nameItem.i0 = citem.i1; nameItem.j1 = citem.j2; nameItem.k12 = citem.swg3; nameItem.k23 = citem.xwg4; nameItem.kgbz4 = citem.kgbz5; //nameItem.wi5 = "NA";// v.Value.skin.Value.Value.ToString(); //nameItem.dx6 = v.Value.wellIndex.Value.GetValue(v.Value.wellIndex.GetUnitValue(_ecl)).ToString(); //nameItem.dy7 = v.Value.wellDirection.Value.Value == "X" ? "0" : v.Value.wellDirection.Value.Value == "Y" ? "1" : "2"; nameItem.bpxs9 = citem.bpxs10; nameItem.jj10 = (citem.jtnj8.ToDouble() / 2).ToString(); name.Items.Add(nameItem); #endregion comAllTemp.Add(perf); } } else if (c is WELOPEN) { WELOPEN wp = c as WELOPEN; foreach (var v in wp.Items) { // Todo :过滤有生产数据的,用后面方法处理 if (wconprod.Exists(l => l.Items.Exists(k => k.jm0 == v.jm0))) { continue; } if (wconhist.Exists(l => l.Items.Exists(k => k.wellName0 == v.jm0))) { continue; } if (wconinje.Exists(l => l.Items.Exists(k => k.jm0 == v.jm0))) { continue; } if (wconinjh.Exists(l => l.Items.Exists(k => k.jm0 == v.jm0))) { continue; } // WELOPEN //'G13' 'SHUT' 0 0 0 2 * / // / // Todo :查找之前所有完井 var coms = comAllTemp.FindAll(l => l.WellName == v.jm0); Predicate <PERF> match = l => true; // Todo :0 或 *表示默认值全都取 if (v.i2 != KeyConfiger.EclipseDefalt && v.i2 != "0") { match += l => l.I0 == v.i2; } if (v.j3 != KeyConfiger.EclipseDefalt && v.j3 != "0") { match += l => l.J1 == v.j3; } if (v.k4 != KeyConfiger.EclipseDefalt && v.k4 != "0") { match += l => l.K12 == v.k4; } var findComs = coms.FindAll(match); WELLCTRL well = time.Find <WELLCTRL>(l => l.WellName0 == v.jm0); if (well == null) { // Todo :创建一个空的生产信息 well = new WELLCTRL("WELLCTRL"); well.ProType = SimONProductType.NA; well.WellName0 = v.jm0; time.Add(well); } // Todo :增加WELOPEN控制的完井 foreach (var fitem in findComs) { PERF perf = fitem.Copy(); perf.Kgbs4 = v.jz1; // Todo :增加前先删除存在的重复数据 well.DeleteAll <PERF>(l => l.I0 == fitem.I0 && l.J1 == fitem.J1 && l.K12 == fitem.K12); well.Add(perf); } } } //this.ConvertCompadat(well, names, compdats, wpimult, comAllTemp); } #endregion foreach (var item in wconprod) { foreach (WCONPROD.ItemHY it in item.Items) { // 生产数据 WELLCTRL well = new WELLCTRL("WELLCTRL"); well.WellName0 = it.jm0; well = this.ConvertToSimON(it, d, histNames); if (well != null) { this.ConvertCompadat(well, names, compdats, wpimult, comAllTemp); time.Add(well); } } } foreach (var item in wconhist) { foreach (WCONHIST.Item it in item.Items) { // 生产数据 WELLCTRL well = new WELLCTRL("WELLCTRL"); well.WellName0 = it.wellName0; well = this.ConvertToSimON(it, d, histNames); this.ConvertCompadat(well, names, compdats, wpimult, comAllTemp); time.Add(well); } } foreach (var item in wconinje) { foreach (WCONINJE.ItemHY it in item.Items) { // 生产数据 WELLCTRL well = new WELLCTRL("WELLCTRL"); well.WellName0 = it.jm0; well = this.ConvertToSimON(it, d, histNames); this.ConvertCompadat(well, names, compdats, wpimult, comAllTemp); time.Add(well); } } foreach (var item in wconinjh) { foreach (WCONINJH.Item it in item.Items) { // 生产数据 WELLCTRL well = new WELLCTRL("WELLCTRL"); well.WellName0 = it.jm0; well = this.ConvertToSimON(it, d, histNames); this.ConvertCompadat(well, names, compdats, wpimult, comAllTemp); time.Add(well); } } //// Todo :将之前的完井信息都加入到缓存中 //foreach (var item in compdats) //{ // comAllTemp.AddRange(item.Items); //} } return(schedule); }
/// <summary> 通关生产数据创建生产数据(目前只应用在FieldGoal案例重启) </summary> public SCHEDULE InitRestartSchduleRestartCase(SCHEDULE sch, RestartInfoModelSimON model, string name, DateTime time, DateTime endtime, Dictionary <string, double> wellProducts, int datype) { // 创建关键字 SCHEDULE schedule = new SCHEDULE("SCHEDULE"); INCLUDE include = new INCLUDE("INCLUDE"); include.FileName = name + "_SCH.DAT"; include.FilePath = Path.GetDirectoryName(model.ResultFilePath) + "//" + include.FileName; model.SchPath = include.FilePath; schedule.Add(include); include.Add(new USESTARTTIME("USESTARTTIME")); include.Add(new RECURRENT("WELLSCHED")); TIME start = new TIME("TIME", time); foreach (var item in wellProducts) { WELLCTRL well = new WELLCTRL("WELLCTRL"); well.WellName0 = item.Key; well.ProType = datype == 0 ? SimONProductType.GRAT : datype == 1? SimONProductType.ORAT: SimONProductType.LRAT; well.Jcyblxz2 = item.Value.ToString(); start.Add(well); } TIME startAdd = new TIME("TIME", time.AddDays(1)); TIME end = new TIME("TIME", endtime); end.Add(new RegisterKeys.SimON.STEPRST("STEPRST")); List <VFPINJ> Vins = sch.FindAll <VFPINJ>(); List <VFPPROD> Vpns = sch.FindAll <VFPPROD>(); if (Vins.Count > 0) { include.AddRange(Vins); } if (Vpns.Count > 0) { include.AddRange(Vpns); } include.Add(start); if (startAdd.Date < end.Date) { include.Add(startAdd); } if (end.Date.Date == start.Date.Date) { include.Add(startAdd); } else { include.Add(end); } // HTodo :保存生产文件 include.Save(); return(schedule); // HTodo :示例如下 //USESTARTTIME //WELLSCHED //TIME 20140209D // WELL 'PROD1' 4 9000 1500 // WELL 'INIJ1' 5 6000 NA //TIME 20140210D //TIME 20140309D //RESTART }