You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

558 lines
21 KiB
C#

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using WorkData;
using WorkData.Entity;
using System.IO;
using System.Linq;
//using DQ.Construction.NewLook.Utility;
using System.Text.RegularExpressions;
using InterfaceWorkAreaData.LoadCurveData;
namespace InterfaceWorkAreaData
{
class KepWorkAreaData : IWorkAreaData
{
eDataSourceType type { get; }
internal KepWorkAreaData()
{
type = eDataSourceType.kep;
}
public bool isConn()
{
return true ;
}
public bool Conn(string ds)
{
dataSource = ds;// + "\\sys.db"; // "D:\\kev\\阳101井区20250521\\sys.db";
Config.ProjectPath = Path.GetDirectoryName(dataSource + "\\sys.db");
return true;
}
public string dataSource { get; set; }
public List<cWellBaseInfo> getWellsInfo()
{
List<WellBase> lstWellBase = DBHelp.Db.Queryable<WellBase>().ToList();
List<cWellBaseInfo> results = new List<cWellBaseInfo>(capacity: lstWellBase.Count);
for (int i = 0; i < lstWellBase.Count; i++)
{
cWellBaseInfo winfo = new cWellBaseInfo();
winfo.id = lstWellBase[i].ID;
winfo.strID = lstWellBase[i].Unique;
winfo.WellName = lstWellBase[i].JH;
winfo.WellCode = lstWellBase[i].JH;
winfo.x = lstWellBase[i].X;
winfo.y = lstWellBase[i].Y;
winfo.BushingLevel = lstWellBase[i].BXHB;
winfo.finishedDepth = lstWellBase[i].WZJS;
winfo.xBottom = lstWellBase[i].X2;
winfo.yBottom = lstWellBase[i].Y2;
results.Add(winfo);
}
return results;
}
//public List<string> getWellCurveNames(string wellname)
//{
// List<string> results = new List<string>();
// return results;
//}
//public List<cWellCurve> getWellCurves(string wellname)
//{
// List<cWellCurve> results = new List<cWellCurve>();
// return results;
//}
//public cWellCurve getWellCurve(string wellname, string curveName)
//{
// cWellCurve results = new cWellCurve();
// return results;
//}
public List<cDiscrete> getWellDiscretes(string wellname)
{
List<cDiscrete> results = new List<cDiscrete>();
return results;
}
public List<string> getWellDiscreteNames(string wellname)
{
List<string> results = new List<string>();
return results;
}
//public List<cStratum> getWellStratums(string wellname)
//{
// List<cStratum> results = new List<cStratum>();
// return results;
//}
//public List<cResult> getWellResults(string wellname)
//{
// List<cResult> results = new List<cResult>();
// return results;
//}
public ResultDataInfo getCurvesData(string wellName, ref DataTable table)
{
ResultDataInfo result = new ResultDataInfo();
List<WellCurveFile> lstWellCurve = DBHelp.Db.Queryable<WellCurveFile>().Where(it => (it.JH == wellName)).ToList();
if(lstWellCurve.Count >0)
{
string filename =dataSource+ "\\"+ lstWellCurve[0].FilePath;
result = LasHelper.LasFileToDataTable(ref table, filename, LasHelper.GetType(filename)?.BodyName, 0);
}
return result ;
}
public List<cPerforation> getWellPerforations(string wellname)
{
List<WellPerforation> lstWellPerforations= DBHelp.Db.Queryable<WellPerforation>().Where(it => (it.JH == wellname)).ToList();
List<cPerforation> results = new List<cPerforation>(capacity: lstWellPerforations.Count);
for(int i = 0; i< lstWellPerforations.Count; i++)
{
cPerforation tper = new cPerforation();
tper.id = lstWellPerforations[i].ID;
tper.top = lstWellPerforations[i].DS;
tper.bottom = lstWellPerforations[i].DS2;
tper.layer = lstWellPerforations[i].CW;
tper.perforationMethod = lstWellPerforations[i].SK;
results.Add(tper);
}
return results;
}
public List<cFaultPoint> getWellFaultPoints(string wellname)
{
List<WellBreakPoint> lstWellFaults = DBHelp.Db.Queryable<WellBreakPoint>().Where(it => (it.JH == wellname)).ToList();
List<cFaultPoint> results = new List<cFaultPoint>(capacity: lstWellFaults.Count);
for(int i = 0; i < lstWellFaults.Count; i++)
{
cFaultPoint faultPt = new cFaultPoint();
faultPt.id = lstWellFaults[i].ID;
faultPt.faultName = lstWellFaults[i].DCBH;
faultPt.depth = lstWellFaults[i].DDSD;
faultPt.faultTopLayer = lstWellFaults[i].DSDC;
faultPt.faultBottomLayer = lstWellFaults[i].DSDC2;
faultPt.compareWellTop = lstWellFaults[i].DBJDS;
faultPt.compareWellBottom = lstWellFaults[i].DBJDS2;
results.Add(faultPt);
}
return results;
}
public List<cWellTrackPoint> getWellTrajectory(string wellname)
{
List<WellDeflection> lstwellDeflections = EntityHelp.GetWellDeflectionsByWellName(wellname);// DBHelp.Db.Queryable<WellDeflection>().Where(it => (it.JH == wellname)).ToList();
if(lstwellDeflections == null)
{
lstwellDeflections = new List<WellDeflection>();
}
List<cWellTrackPoint> results = new List<cWellTrackPoint>(capacity: lstwellDeflections.Count);
for (int i = 0; i < lstwellDeflections.Count; i++)
{
cWellTrackPoint trackPt = new cWellTrackPoint();
trackPt.id = lstwellDeflections[i].ID;
trackPt.depth = lstwellDeflections[i].JS;
trackPt.bevel = lstwellDeflections[i].JXJ;
trackPt.azimuth = lstwellDeflections[i].FWJ;
trackPt.depthV = lstwellDeflections[i].CS;
trackPt.x = lstwellDeflections[i].X;
trackPt.y = lstwellDeflections[i].Y;
results.Add(trackPt);
}
return results;
}
public List<cWellStratification> getWellStratification()
{
List<GeologicalStratification> lstwellStrati = DBHelp.Db.Queryable<GeologicalStratification>().OrderBy(it=>it.Level).ToList();
List<cWellStratification> results = new List<cWellStratification>(capacity: lstwellStrati.Count);
for(int i = 0; i< lstwellStrati.Count; i++)
{
cWellStratification wstrati = new cWellStratification();
wstrati.id = lstwellStrati[i].ID;
wstrati.level = lstwellStrati[i].Level;
if(lstwellStrati[i].Name != null)
wstrati.name = lstwellStrati[i].Name;
wstrati.parentId = lstwellStrati[i].ParentID;
wstrati.code = lstwellStrati[i].Code;
wstrati.order = lstwellStrati[i].Order;
results.Add(wstrati);
}
return results;
}
public List<cWellSandSet> getWellSandSets(string wellname)
{
List<InterpretDrillWellLayered> lstwellLayers = DBHelp.Db.Queryable<InterpretDrillWellLayered>().Where(it => (it.JH == wellname)).OrderBy(it=>it.SD).ToList();
List<cWellSandSet> results = new List<cWellSandSet>(capacity: lstwellLayers.Count);
for(int i = 0; i< lstwellLayers.Count; i++)
{
if (lstwellLayers[i].DJSD == null && lstwellLayers[i].HD == null)
continue;
cWellSandSet sandset = new cWellSandSet();
sandset.id = lstwellLayers[i].ID;
sandset.top = lstwellLayers[i].SD ?? 0;
sandset.bottom = lstwellLayers[i].DJSD ?? 0;
sandset.name = lstwellLayers[i].CW;
sandset.result = lstwellLayers[i].JSJL ?? "";
results.Add(sandset);
}
return results;
}
public List<cStratumDivision> getStratumDivisions()
{
List<StratumDivision> lstStratum = DBHelp.Db.Queryable<StratumDivision>().OrderBy(it => it.ID).ToList();
List < cStratumDivision > results = new List<cStratumDivision>(capacity: lstStratum.Count);
for(int i = 0; i< lstStratum.Count; i++)
{
cStratumDivision tstratum = new cStratumDivision();
tstratum.id = lstStratum[i].ID;
tstratum.name = lstStratum[i].name;
tstratum.code = lstStratum[i].code;
tstratum.parentID = lstStratum[i].parentID;
tstratum.classname = lstStratum[i].classname;
tstratum.orderId = lstStratum[i].orderId;
results.Add(tstratum);
}
return results;
}
public List<cWellReservesLayer> getReservesLayers(string wellname)
{
List<WellReservesLayer> lstLayers = DBHelp.Db.Queryable<WellReservesLayer>().Where(it => (it.Well == wellname)).ToList();
List<cWellReservesLayer> results = new List<cWellReservesLayer>(capacity: lstLayers.Count);
for(int i = 0; i< lstLayers.Count; i++)
{
cWellReservesLayer tLayer = new cWellReservesLayer();
tLayer.id = lstLayers[i].ID;
// tLayer.well = lstLayers[i].Well;
tLayer.layer = lstLayers[i].Layer;
tLayer.topSecondSandstone = lstLayers[i].TopSecondSandstone;
tLayer.bottomSecondSandstone = lstLayers[i].BottomSecondSandstone;
tLayer.topFirstSandstone = lstLayers[i].TopFirstSandstone;
tLayer.bottomFirstSandstone = lstLayers[i].BottomFirstSandstone;
tLayer.pureEffectiveTopEstimate = lstLayers[i].PureEffectiveTopEstimate;
tLayer.pureEffectiveThicknessEstimate = lstLayers[i].PureEffectiveThicknessEstimate;
tLayer.electricLogInterpretation = lstLayers[i].ElectricLogInterpretation;
tLayer.facies = lstLayers[i].Facies??"";
tLayer.subfacies = lstLayers[i].Subfacies??"";
tLayer.viewEffectiveTop = lstLayers[i].ViewEffectiveTop;
tLayer.viewEffectiveThickness = lstLayers[i].ViewEffectiveThickness;
results.Add(tLayer);
}
return results;
}
public List<cWellInnerLayer> getInnerLayers(string wellname)
{
List<WellInnerLayer> lstLayers = DBHelp.Db.Queryable<WellInnerLayer>().Where(it => (it.Well == wellname)).ToList();
List<cWellInnerLayer> results = new List<cWellInnerLayer>(capacity: lstLayers.Count);
for(int i = 0; i < lstLayers.Count; i++)
{
cWellInnerLayer tLayer = new cWellInnerLayer();
tLayer.id = lstLayers[i].ID;
tLayer.top = lstLayers[i].top;
tLayer.bottom = lstLayers[i].bottom;
tLayer.thickness = lstLayers[i].thickness;
tLayer.type = lstLayers[i].type;
results.Add(tLayer);
}
return results;
}
public List<cWellCycle> getWellCycles(string wellname, int termType) //1= 长期旋回2=中期旋回,3=短期旋回,
{
List<cWellCycle> results = new List<cWellCycle>();
if(termType == 1)
{
results = getCycleLongterm(wellname);
}
else if(termType == 2)
{
results = getCycleMediumterm(wellname);
}
else if(termType == 3)
{
results = getCycleShortterm(wellname);
}
return results;
}
List<cWellCycle> getCycleLongterm(string wellname)
{
List<CycleLongterm> lstLayers = DBHelp.Db.Queryable<CycleLongterm>().Where(it => (it.Well == wellname)).ToList();
List<cWellCycle> results = new List<cWellCycle>(capacity: lstLayers.Count);
for (int i = 0; i < lstLayers.Count; i++)
{
cWellCycle tLayer = new cWellCycle();
tLayer.id = lstLayers[i].ID;
tLayer.top = lstLayers[i].top;
tLayer.bottom = lstLayers[i].bottom;
tLayer.type = lstLayers[i].type;
results.Add(tLayer);
}
return results;
}
List<cWellCycle> getCycleShortterm(string wellname)
{
List<CycleShortterm> lstLayers = DBHelp.Db.Queryable<CycleShortterm>().Where(it => (it.Well == wellname)).ToList();
List<cWellCycle> results = new List<cWellCycle>(capacity: lstLayers.Count);
for (int i = 0; i < lstLayers.Count; i++)
{
cWellCycle tLayer = new cWellCycle();
tLayer.id = lstLayers[i].ID;
tLayer.top = lstLayers[i].top;
tLayer.bottom = lstLayers[i].bottom;
tLayer.type = lstLayers[i].type;
results.Add(tLayer);
}
return results;
}
List<cWellCycle> getCycleMediumterm(string wellname)
{
List<CycleMediumterm> lstLayers = DBHelp.Db.Queryable<CycleMediumterm>().Where(it => (it.Well == wellname)).ToList();
List<cWellCycle> results = new List<cWellCycle>(capacity: lstLayers.Count);
for (int i = 0; i < lstLayers.Count; i++)
{
cWellCycle tLayer = new cWellCycle();
tLayer.id = lstLayers[i].ID;
tLayer.top = lstLayers[i].top;
tLayer.bottom = lstLayers[i].bottom;
tLayer.type = lstLayers[i].type;
results.Add(tLayer);
}
return results;
}
public List<cWellLithology> getWellLithologys(string wellname)
{
List<WellLithology> lstliths = DBHelp.Db.Queryable<WellLithology>().Where(it => (it.Well == wellname)).ToList();
List<cWellLithology> results = new List<cWellLithology>(capacity: lstliths.Count);
for( int i = 0; i< lstliths.Count; i++)
{
cWellLithology tLith = new cWellLithology();
tLith.id = lstliths[i].ID;
tLith.top = lstliths[i].top;
tLith.bottom = lstliths[i].bottom;
tLith.color = lstliths[i].color;
tLith.oilcontent = lstliths[i].oilcontent;
tLith.inclusions = lstliths[i].inclusions;
tLith.structure = lstliths[i].structure;
tLith.lithologyprefix = lstliths[i].lithologyprefix;
tLith.lithology = lstliths[i].lithology;
results.Add(tLith);
}
return results;
}
public List<cWellCoring> getWellCorings(string wellname)
{
List<WellCoring> list = DBHelp.Db.Queryable<WellCoring>().Where(it => (it.Well == wellname)).ToList();
List<cWellCoring> results = new List<cWellCoring>();
for(int i = 0; i < list.Count; i++)
{
cWellCoring tCoring = new cWellCoring();
tCoring.id = list[i].ID;
tCoring.top = list[i].top??0;
tCoring.bottom = list[i].bottom ?? 0;
tCoring.date = list[i].date ?? "";
tCoring.layer = list[i].layer ?? "";
tCoring.method = list[i].method ?? "";
tCoring.length = list[i].length ?? 0;
tCoring.oilsaturatedlength = list[i].length ?? 0;
tCoring.diameter = list[i].diameter ?? 0;
tCoring.times = list[i].times ?? 0;
tCoring.firstlayer = list[i].firstlayer ?? "";
tCoring.secondlayer = list[i].secondlayer ?? "";
tCoring.thridlayer = list[i].thirdlayer ?? "";
results.Add(tCoring);
}
return results;
}
public List<cWellSideWallCoring> getWellSideWallCorings(string wellname)
{
List<WellSideWallCoring> list = DBHelp.Db.Queryable<WellSideWallCoring>().Where(it => (it.Well == wellname)).ToList();
List<cWellSideWallCoring> results = new List<cWellSideWallCoring>();
for (int i = 0; i < list.Count; i++)
{
cWellSideWallCoring tCoring = new cWellSideWallCoring();
tCoring.id = list[i].ID;
tCoring.top = list[i].top ?? 0;
tCoring.oilcontent = list[i].oilcontent ?? "";
tCoring.lithology = list[i].lithology ?? "";
tCoring.lithologyprefix = list[i].lithologyprefix ?? "";
tCoring.number = list[i].number ?? 0;
tCoring.color = list[i].color;
tCoring.structure = list[i].structure;
tCoring.inclusions = list[i].inclusions;
tCoring.firstlayer = list[i].firstlayer ?? "";
tCoring.secondlayer = list[i].secondlayer ?? "";
tCoring.thridlayer = list[i].thirdlayer ?? "";
results.Add(tCoring);
}
return results;
}
public List<cWellOilTest> getWellOilTests(string wellname)
{
List<cWellOilTest> results = new List<cWellOilTest>();
List<WellTestTotal>lstTest = DBHelp.Db.Queryable<WellTestTotal>().Where(it => (it.JH == wellname)).ToList();
string topbot,tstr;
for( int i = 0; i< lstTest.Count; i++)
{
cWellOilTest tTest = new cWellOilTest();
tTest.id = lstTest[i].ID;
topbot = lstTest[i].SKJD;
var matches = Regex.Matches(topbot, @"[\d.]+");
if (matches.Count == 2)
{
tTest.top = double.Parse(matches[0].Value);
tTest.bottom = double.Parse(matches[1].Value);
}
else
continue;
tstr = lstTest[i].DaylyOil;
if(double.TryParse(tstr, out double ddayoil))
{
tTest.dayOil = ddayoil;
}
tstr = lstTest[i].DaylyWater;
if (double.TryParse(tstr, out double ddayWater))
{
tTest.dayWater = ddayWater;
}
tstr = lstTest[i].DaylyWater;
if (double.TryParse(tstr, out double ddayGas))
{
tTest.dayGas = ddayGas;
}
tstr = lstTest[i].AllOil;
if (double.TryParse(tstr, out double dsumOil))
{
tTest.sumOil = dsumOil;
}
tstr = lstTest[i].AllWater;
if (double.TryParse(tstr, out double dsumWater))
{
tTest.sumWater = dsumWater;
}
tstr = lstTest[i].AllGas;
if (double.TryParse(tstr, out double dsumGas))
{
tTest.sumGas = dsumGas;
}
tTest.verdict = lstTest[i].SYJL;
tTest.layer = lstTest[i].CW;
tTest.method = lstTest[i].SYHCS;
tTest.staticMpa = lstTest[i].YlJy ?? 0;
tTest.caseMpa = lstTest[i].YlTy??0;
tTest.flowMpa = lstTest[i].YlLy??0;
if (double.TryParse(lstTest[i].YYXZDensity, out double density))
{
tTest.density = density;
}
else
tTest.density = 0;
if (double.TryParse(lstTest[i].YYXZViscosity, out double viscosity))
{
tTest.viscosity = viscosity;
}
else
tTest.viscosity = 0;
tstr = lstTest[i].Date;
matches = Regex.Matches(tstr, @"[\d.]+");
if (matches.Count == 2)
{
tTest.startTime = matches[0].Value;
tTest.endTime = matches[1].Value;
}
if (double.TryParse(lstTest[i].WdJw, out double wdjw))
tTest.staticTemperature = wdjw;
else
tTest.staticTemperature = 0;
tTest.thickness = lstTest[i].HD ?? 0;
if (double.TryParse(lstTest[i].GzzdCSHCC, out double stroke))
{
tTest.stroke = stroke;
}
else
{
tTest.stroke = 0;
}
results.Add(tTest);
}
return results;
}
}
}