Merge pull request 'Фиксы формирования отчёта' (#320) from fix/well_report into dev

Reviewed-on: https://test.digitaldrilling.ru:8443/DDrilling/AsbCloudServer/pulls/320
This commit is contained in:
Никита Фролов 2024-09-04 15:35:22 +05:00
commit c81b558c4c
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 idsSection = factWellOperationsBySection.Keys
.Concat(processMapPlanRotorBySection.Keys)
.Concat(processMapReportBySection.Keys)
.Distinct();
var sectionReports = new List<SectionReportDto>();
foreach (var group in factWellOperationsBySection)
foreach (var idSection in idsSection)
{
var sectionReport = new SectionReportDto
{
IdSection = idSection,
OperatingMode = new PlanFactDto<OperatingModeDto>()
};
if (factWellOperationsBySection.TryGetValue(idSection, out var factOperations))
{
var subsystemRequest = new SubsystemRequest
{
IdWell = idWell,
GeDepth = group.Min(y => y.DepthStart),
LeDepth = group.Max(y => y.DepthEnd)
GeDepth = factOperations.Min(y => y.DepthStart),
LeDepth = factOperations.Max(y => y.DepthEnd)
};
var sectionReport = new SectionReportDto
sectionReport.SubsystemsStat = await subsystemService.GetStatAsync(subsystemRequest, token);
sectionReport.OperatingMode.Fact = new OperatingModeDto
{
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)
}
}
DepthStart = factOperations.Min(w => w.DepthStart),
DepthEnd = factOperations.Max(w => w.DepthEnd)
};
}
if (processMapPlanRotorBySection.TryGetValue(group.Key, out var processMapPlanRotor))
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),