Фикс в логике сервиса

Не трубуется обязательно сопоставление факта с планом в режимах бурения
This commit is contained in:
Степанов Дмитрий 2024-09-04 14:37:07 +05:00
parent 60800d10ed
commit 05d3a9d7b7
2 changed files with 33 additions and 25 deletions

View File

@ -129,7 +129,8 @@ public class WellReportService : IWellReportService
private async Task<IEnumerable<SectionReportDto>> GetSectionReportsAsync(int idWell, CancellationToken token)
{
var factWellOperationsBySection = factWellOperations.GroupBy(x => x.IdWellSectionType);
var factWellOperationsBySection = factWellOperations.GroupBy(x => x.IdWellSectionType)
.ToDictionary(x => x.Key, x => x.AsEnumerable());
var processMapPlanRequest = new ProcessMapPlanBaseRequestWithWell(idWell);
@ -145,32 +146,39 @@ public class WellReportService : IWellReportService
.GroupBy(x => x.IdWellSectionType)
.ToDictionary(x => x.Key, x => x.AsEnumerable());
var sectionReports = new List<SectionReportDto>();
var idsSection = factWellOperationsBySection.Keys
.Concat(processMapPlanRotorBySection.Keys)
.Concat(processMapReportBySection.Keys)
.Distinct();
foreach (var group in factWellOperationsBySection)
{
var subsystemRequest = new SubsystemRequest
{
IdWell = idWell,
GeDepth = group.Min(y => y.DepthStart),
LeDepth = group.Max(y => y.DepthEnd)
};
var sectionReports = new List<SectionReportDto>();
var sectionReport = new SectionReportDto
{
IdSection = group.Key,
SubsystemsStat = await subsystemService.GetStatAsync(subsystemRequest, token),
OperatingMode = new PlanFactDto<OperatingModeDto>
{
Fact = new OperatingModeDto
{
DepthStart = group.Min(w => w.DepthStart),
DepthEnd = group.Max(w => w.DepthEnd)
}
}
};
foreach (var idSection in idsSection)
{
var sectionReport = new SectionReportDto
{
IdSection = idSection,
OperatingMode = new PlanFactDto<OperatingModeDto>()
};
if (processMapPlanRotorBySection.TryGetValue(group.Key, out var processMapPlanRotor))
if (factWellOperationsBySection.TryGetValue(idSection, out var factOperations))
{
var subsystemRequest = new SubsystemRequest
{
IdWell = idWell,
GeDepth = factOperations.Min(y => y.DepthStart),
LeDepth = factOperations.Max(y => y.DepthEnd)
};
sectionReport.SubsystemsStat = await subsystemService.GetStatAsync(subsystemRequest, token);
sectionReport.OperatingMode.Fact = new OperatingModeDto
{
DepthStart = factOperations.Min(w => w.DepthStart),
DepthEnd = factOperations.Max(w => w.DepthEnd)
};
}
if (processMapPlanRotorBySection.TryGetValue(idSection, out var processMapPlanRotor))
sectionReport.OperatingMode.Plan = new OperatingModeDto
{
DepthStart = processMapPlanRotor.Min(p => p.DepthStart),
@ -191,7 +199,7 @@ public class WellReportService : IWellReportService
FrowRateMax = processMapPlanRotor.Max(p => p.FlowRateMax)
};
if (processMapReportBySection.TryGetValue(group.Key, out var processMapReport))
if (processMapReportBySection.TryGetValue(idSection, out var processMapReport))
sectionReport.DrillingBySetpoints = new DrillingBySetpointsDto
{
MetersByPressure = processMapReport.Sum(x => x.DeltaDepth * x.PressureDiff.SetpointUsage / 100),