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 IChangeLogRepository<ProcessMapPlanDrillingDto, ProcessMapPlanBaseRequestWithWell> processMapPlanBaseRepository;
|
||||||
private readonly IDataSaubStatRepository dataSaubStatRepository;
|
private readonly IDataSaubStatRepository dataSaubStatRepository;
|
||||||
private readonly IWellOperationRepository wellOperationRepository;
|
private readonly IWellOperationRepository wellOperationRepository;
|
||||||
|
private readonly IWellOperationCategoryRepository wellOperationCategoryRepository;
|
||||||
|
|
||||||
public ProcessMapReportDataSaubStatService(IWellService wellService,
|
public ProcessMapReportDataSaubStatService(IWellService wellService,
|
||||||
IChangeLogRepository<ProcessMapPlanDrillingDto, ProcessMapPlanBaseRequestWithWell> processMapPlanBaseRepository,
|
IChangeLogRepository<ProcessMapPlanDrillingDto, ProcessMapPlanBaseRequestWithWell> processMapPlanBaseRepository,
|
||||||
IDataSaubStatRepository dataSaubStatRepository,
|
IDataSaubStatRepository dataSaubStatRepository,
|
||||||
IWellOperationRepository wellOperationRepository
|
IWellOperationRepository wellOperationRepository,
|
||||||
|
IWellOperationCategoryRepository wellOperationCategoryRepository
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
this.wellService = wellService;
|
this.wellService = wellService;
|
||||||
this.processMapPlanBaseRepository = processMapPlanBaseRepository;
|
this.processMapPlanBaseRepository = processMapPlanBaseRepository;
|
||||||
this.dataSaubStatRepository = dataSaubStatRepository;
|
this.dataSaubStatRepository = dataSaubStatRepository;
|
||||||
this.wellOperationRepository = wellOperationRepository;
|
this.wellOperationRepository = wellOperationRepository;
|
||||||
|
this.wellOperationCategoryRepository = wellOperationCategoryRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<IEnumerable<ProcessMapReportDataSaubStatDto>> GetAsync(int idWell, DataSaubStatRequest request, CancellationToken token)
|
public async Task<IEnumerable<ProcessMapReportDataSaubStatDto>> GetAsync(int idWell, DataSaubStatRequest request, CancellationToken token)
|
||||||
@ -81,19 +84,37 @@ namespace AsbCloudInfrastructure.Services.ProcessMaps.Report
|
|||||||
DataSaubStatRequest request,
|
DataSaubStatRequest request,
|
||||||
IEnumerable<ProcessMapPlanDrillingDto> processMapPlanWellDrillings,
|
IEnumerable<ProcessMapPlanDrillingDto> processMapPlanWellDrillings,
|
||||||
Span<DataSaubStatDto> dataSaubStats,
|
Span<DataSaubStatDto> dataSaubStats,
|
||||||
IEnumerable<WellOperationDto> wellOperations,
|
IEnumerable<WellOperationDto> wellOperations
|
||||||
IEnumerable<WellOperationCategoryDto> wellOperationCategories
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
var list = new List<ProcessMapReportDataSaubStatDto>();
|
var list = new List<ProcessMapReportDataSaubStatDto>();
|
||||||
var firstElemInInterval = dataSaubStats[0];
|
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;
|
var indexStart = 0;
|
||||||
|
|
||||||
for (var i = 1; i < dataSaubStats.Length; i++)
|
for (var i = 1; i < dataSaubStats.Length; i++)
|
||||||
{
|
{
|
||||||
var currentElem = dataSaubStats[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 length = i - indexStart;
|
||||||
|
|
||||||
var span = dataSaubStats.Slice(indexStart, length);
|
var span = dataSaubStats.Slice(indexStart, length);
|
||||||
@ -104,26 +125,7 @@ namespace AsbCloudInfrastructure.Services.ProcessMaps.Report
|
|||||||
var firstElemInSpan = span[0];
|
var firstElemInSpan = span[0];
|
||||||
var lastElemInISpan = span[^1];
|
var lastElemInISpan = span[^1];
|
||||||
|
|
||||||
var nearestOperation = wellOperations.MinBy(o => firstElemInSpan.DateStart - o.DateStart);
|
var elem = CalcStat(processMapPlan, idWellSectionType, span);
|
||||||
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);
|
|
||||||
if (elem is not null)
|
if (elem is not null)
|
||||||
list.Add(elem);
|
list.Add(elem);
|
||||||
}
|
}
|
||||||
@ -131,11 +133,15 @@ namespace AsbCloudInfrastructure.Services.ProcessMaps.Report
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool IsModeMatchOperationCategory(int idMode, int idCategory)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
private ProcessMapReportDataSaubStatDto? CalcStat(
|
private ProcessMapReportDataSaubStatDto? CalcStat(
|
||||||
ProcessMapPlanDrillingDto[] processMapPlanFilteredByDepth,
|
ProcessMapPlanDrillingDto? processMapPlanFilteredByDepth,
|
||||||
Span<DataSaubStatDto> span,
|
int idWellSectionType,
|
||||||
WellOperationDto nearestOperation,
|
Span<DataSaubStatDto> span
|
||||||
string wellOperationCategoryName
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
var firstElemInInterval = span[0];
|
var firstElemInInterval = span[0];
|
||||||
@ -149,7 +155,7 @@ namespace AsbCloudInfrastructure.Services.ProcessMaps.Report
|
|||||||
return new ProcessMapReportDataSaubStatDto()
|
return new ProcessMapReportDataSaubStatDto()
|
||||||
{
|
{
|
||||||
DateStart = firstElemInInterval.DateStart.DateTime,
|
DateStart = firstElemInInterval.DateStart.DateTime,
|
||||||
WellSectionTypeName = nearestOperation.WellSectionTypeName ?? string.Empty,
|
WellSectionTypeName = nearestOperation.WellSectionTypeName ?? string.Empty,
|
||||||
DepthStart = firstElemInInterval.DepthStart,
|
DepthStart = firstElemInInterval.DepthStart,
|
||||||
DepthEnd = lastElemInInterval.DepthEnd,
|
DepthEnd = lastElemInInterval.DepthEnd,
|
||||||
DeltaDepth = deltaDepth,
|
DeltaDepth = deltaDepth,
|
||||||
@ -157,7 +163,7 @@ namespace AsbCloudInfrastructure.Services.ProcessMaps.Report
|
|||||||
DrillingMode = wellOperationCategoryName,
|
DrillingMode = wellOperationCategoryName,
|
||||||
PressureDiff = new ProcessMapReportDataSaubStatParamsDto()
|
PressureDiff = new ProcessMapReportDataSaubStatParamsDto()
|
||||||
{
|
{
|
||||||
SetpointPlanMax = processMapPlanFilteredByDepth.Max(p => p.DeltaPressurePlan),
|
SetpointPlanMax = processMapPlanFilteredByDepth?.DeltaPressurePlan,
|
||||||
SetpointPlanMin = processMapPlanFilteredByDepth.Min(p => p.DeltaPressurePlan),
|
SetpointPlanMin = processMapPlanFilteredByDepth.Min(p => p.DeltaPressurePlan),
|
||||||
SetpointFact = firstElemInInterval.PressureSp - firstElemInInterval.PressureIdle,
|
SetpointFact = firstElemInInterval.PressureSp - firstElemInInterval.PressureIdle,
|
||||||
FactWavg = aggregatedValues.Pressure,
|
FactWavg = aggregatedValues.Pressure,
|
||||||
|
Loading…
Reference in New Issue
Block a user