diff --git a/AsbCloudInfrastructure/Services/DailyReport/DailyReportService.cs b/AsbCloudInfrastructure/Services/DailyReport/DailyReportService.cs index ae8a3d7a..f58f0a96 100644 --- a/AsbCloudInfrastructure/Services/DailyReport/DailyReportService.cs +++ b/AsbCloudInfrastructure/Services/DailyReport/DailyReportService.cs @@ -152,6 +152,7 @@ public class DailyReportService : IDailyReportService var dailyReports = new List(); var existingDailyReports = await dailyReportRepository.GetAsync(idWell, request, cancellationToken); + var factWellOperations = await GetFactWellOperationsAsync(idWell, null, cancellationToken); if (request.GeDate.HasValue) { @@ -201,19 +202,16 @@ public class DailyReportService : IDailyReportService void AddDailyReport(DateTime date) { - var existingDailyReport = existingDailyReports.FirstOrDefault(d => d.IdWell == idWell && d.Date == date); + var dailyReport = existingDailyReports.FirstOrDefault(d => d.IdWell == idWell && d.Date == date) + ?? new DailyReportDto + { + Date = date, + IdWell = idWell + }; - if (existingDailyReport is not null) - { - dailyReports.Add(existingDailyReport); - return; - } - - dailyReports.Add(new DailyReportDto - { - Date = date, - IdWell = idWell - }); + AddFactWellOperationBlock(dailyReport, factWellOperations.Where(o => o.DateStart >= date && o.DateStart <= date.AddDays(1))); + + dailyReports.Add(dailyReport); } }