diff --git a/AsbCloudInfrastructure/Services/WellReport/WellReport.xlsx b/AsbCloudInfrastructure/Services/WellReport/WellReport.xlsx index 9cd5370e..74646abe 100644 Binary files a/AsbCloudInfrastructure/Services/WellReport/WellReport.xlsx and b/AsbCloudInfrastructure/Services/WellReport/WellReport.xlsx differ diff --git a/AsbCloudInfrastructure/Services/WellReport/WellReportService.cs b/AsbCloudInfrastructure/Services/WellReport/WellReportService.cs index cf9ef0fe..cc5baa23 100644 --- a/AsbCloudInfrastructure/Services/WellReport/WellReportService.cs +++ b/AsbCloudInfrastructure/Services/WellReport/WellReportService.cs @@ -129,7 +129,8 @@ public class WellReportService : IWellReportService private async Task> 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(); + 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(); - var sectionReport = new SectionReportDto - { - IdSection = group.Key, - SubsystemsStat = await subsystemService.GetStatAsync(subsystemRequest, token), - OperatingMode = new PlanFactDto - { - 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() + }; - 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),