forked from ddrilling/AsbCloudServer
Merge branch 'feature/28518041-rtk-report' of http://test.digitaldrilling.ru:8080/DDrilling/AsbCloudServer into feature/28518041-rtk-report
This commit is contained in:
commit
e649d1f61c
@ -22,17 +22,20 @@ namespace AsbCloudInfrastructure.Services.ProcessMaps.Report
|
||||
private readonly IChangeLogRepository<ProcessMapPlanDrillingDto, ProcessMapPlanBaseRequestWithWell> processMapPlanBaseRepository;
|
||||
private readonly IDataSaubStatRepository dataSaubStatRepository;
|
||||
private readonly IWellOperationRepository wellOperationRepository;
|
||||
private readonly IWellOperationCategoryRepository wellOperationCategoryRepository;
|
||||
|
||||
public ProcessMapReportDataSaubStatService(IWellService wellService,
|
||||
IChangeLogRepository<ProcessMapPlanDrillingDto, ProcessMapPlanBaseRequestWithWell> processMapPlanBaseRepository,
|
||||
IDataSaubStatRepository dataSaubStatRepository,
|
||||
IWellOperationRepository wellOperationRepository
|
||||
IWellOperationRepository wellOperationRepository,
|
||||
IWellOperationCategoryRepository wellOperationCategoryRepository
|
||||
)
|
||||
{
|
||||
this.wellService = wellService;
|
||||
this.processMapPlanBaseRepository = processMapPlanBaseRepository;
|
||||
this.dataSaubStatRepository = dataSaubStatRepository;
|
||||
this.wellOperationRepository = wellOperationRepository;
|
||||
this.wellOperationCategoryRepository = wellOperationCategoryRepository;
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<ProcessMapReportDataSaubStatDto>> GetAsync(int idWell, DataSaubStatRequest request, CancellationToken token)
|
||||
@ -81,19 +84,37 @@ namespace AsbCloudInfrastructure.Services.ProcessMaps.Report
|
||||
DataSaubStatRequest request,
|
||||
IEnumerable<ProcessMapPlanDrillingDto> processMapPlanWellDrillings,
|
||||
Span<DataSaubStatDto> dataSaubStats,
|
||||
IEnumerable<WellOperationDto> wellOperations,
|
||||
IEnumerable<WellOperationCategoryDto> wellOperationCategories
|
||||
IEnumerable<WellOperationDto> wellOperations
|
||||
)
|
||||
{
|
||||
var list = new List<ProcessMapReportDataSaubStatDto>();
|
||||
var firstElemInInterval = dataSaubStats[0];
|
||||
|
||||
int GetSection(DataSaubStatDto data)
|
||||
=> wellOperations.MinBy(o => data.DateStart - o.DateStart)!.IdWellSectionType;
|
||||
|
||||
ProcessMapPlanDrillingDto? GetProcessMapPlan(int idWellSectionType, DataSaubStatDto data)
|
||||
=> processMapPlanWellDrillings
|
||||
.Where(p => p.IdWellSectionType == idWellSectionType)
|
||||
.Where(p => p.DepthStart <= data.DepthStart)
|
||||
.Where(p => p.DepthEnd >= data.DepthStart)
|
||||
.Where(p => IsModeMatchOperationCategory(p.IdMode, data.IdCategory))
|
||||
.WhereActualAtMoment(data.DateStart)
|
||||
.FirstOrDefault();
|
||||
|
||||
var idWellSectionType = GetSection(firstElemInInterval);
|
||||
var prevProcessMapPlan = GetProcessMapPlan(idWellSectionType, firstElemInInterval);
|
||||
var indexStart = 0;
|
||||
|
||||
for (var i = 1; i < dataSaubStats.Length; i++)
|
||||
{
|
||||
var currentElem = dataSaubStats[i];
|
||||
if (IsNewInterval(currentElem, firstElemInInterval, request) || i == dataSaubStats.Length - 1)
|
||||
idWellSectionType = GetSection(currentElem);
|
||||
var processMapPlan = GetProcessMapPlan(idWellSectionType, currentElem);
|
||||
|
||||
if (IsNewInterval(currentElem, firstElemInInterval, request) || i == dataSaubStats.Length - 1 || processMapPlan != prevProcessMapPlan)
|
||||
{
|
||||
prevProcessMapPlan = processMapPlan;
|
||||
var length = i - indexStart;
|
||||
|
||||
var span = dataSaubStats.Slice(indexStart, length);
|
||||
@ -104,26 +125,7 @@ namespace AsbCloudInfrastructure.Services.ProcessMaps.Report
|
||||
var firstElemInSpan = span[0];
|
||||
var lastElemInISpan = span[^1];
|
||||
|
||||
var nearestOperation = wellOperations.MinBy(o => firstElemInSpan.DateStart - o.DateStart);
|
||||
if (nearestOperation is null)
|
||||
continue;
|
||||
|
||||
var processMapPlanFilteredByDepth = processMapPlanWellDrillings
|
||||
.Where(x => x.IdWellSectionType == nearestOperation.IdWellSectionType)
|
||||
.Where(x => x.DepthStart >= firstElemInSpan.DepthStart)
|
||||
.Where(x => x.DepthEnd <= lastElemInISpan.DepthEnd)
|
||||
.WhereActualAtMoment(DateTimeOffset.Now)
|
||||
.ToArray();
|
||||
|
||||
if (!processMapPlanFilteredByDepth.Any())
|
||||
continue;
|
||||
|
||||
var wellOperationCategoryName = wellOperationCategories.
|
||||
Where(c => c.Id == currentElem.IdCategory)
|
||||
.FirstOrDefault()
|
||||
?.Name ?? string.Empty;
|
||||
|
||||
var elem = CalcStat(processMapPlanFilteredByDepth, span, nearestOperation, wellOperationCategoryName);
|
||||
var elem = CalcStat(processMapPlan, idWellSectionType, span);
|
||||
if (elem is not null)
|
||||
list.Add(elem);
|
||||
}
|
||||
@ -131,11 +133,15 @@ namespace AsbCloudInfrastructure.Services.ProcessMaps.Report
|
||||
return list;
|
||||
}
|
||||
|
||||
private bool IsModeMatchOperationCategory(int idMode, int idCategory)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private ProcessMapReportDataSaubStatDto? CalcStat(
|
||||
ProcessMapPlanDrillingDto[] processMapPlanFilteredByDepth,
|
||||
Span<DataSaubStatDto> span,
|
||||
WellOperationDto nearestOperation,
|
||||
string wellOperationCategoryName
|
||||
ProcessMapPlanDrillingDto? processMapPlanFilteredByDepth,
|
||||
int idWellSectionType,
|
||||
Span<DataSaubStatDto> span
|
||||
)
|
||||
{
|
||||
var firstElemInInterval = span[0];
|
||||
@ -149,7 +155,7 @@ namespace AsbCloudInfrastructure.Services.ProcessMaps.Report
|
||||
return new ProcessMapReportDataSaubStatDto()
|
||||
{
|
||||
DateStart = firstElemInInterval.DateStart.DateTime,
|
||||
WellSectionTypeName = nearestOperation.WellSectionTypeName ?? string.Empty,
|
||||
WellSectionTypeName = nearestOperation.WellSectionTypeName ?? string.Empty,
|
||||
DepthStart = firstElemInInterval.DepthStart,
|
||||
DepthEnd = lastElemInInterval.DepthEnd,
|
||||
DeltaDepth = deltaDepth,
|
||||
@ -157,7 +163,7 @@ namespace AsbCloudInfrastructure.Services.ProcessMaps.Report
|
||||
DrillingMode = wellOperationCategoryName,
|
||||
PressureDiff = new ProcessMapReportDataSaubStatParamsDto()
|
||||
{
|
||||
SetpointPlanMax = processMapPlanFilteredByDepth.Max(p => p.DeltaPressurePlan),
|
||||
SetpointPlanMax = processMapPlanFilteredByDepth?.DeltaPressurePlan,
|
||||
SetpointPlanMin = processMapPlanFilteredByDepth.Min(p => p.DeltaPressurePlan),
|
||||
SetpointFact = firstElemInInterval.PressureSp - firstElemInInterval.PressureIdle,
|
||||
FactWavg = aggregatedValues.Pressure,
|
||||
|
Loading…
Reference in New Issue
Block a user