From 71c9be6a7397971fed93ae079d532da1615b6c2f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=D0=A1=D1=82=D0=B5=D0=BF=D0=B0=D0=BD=D0=BE=D0=B2=20=D0=94?=
 =?UTF-8?q?=D0=BC=D0=B8=D1=82=D1=80=D0=B8=D0=B9?= <falldimka007@gmail.com>
Date: Mon, 27 Nov 2023 11:20:10 +0500
Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?=
 =?UTF-8?q?=D0=BD=D0=BE=20=D0=B7=D0=B0=D0=BF=D0=BE=D0=BB=D0=BD=D0=B5=D0=BD?=
 =?UTF-8?q?=D0=B8=D0=B5=20=D0=B1=D0=BB=D0=BE=D0=BA=D0=B0=20=D1=81=20=D1=84?=
 =?UTF-8?q?=D0=B0=D0=BA=D1=82=D0=B8=D1=87=D0=B5=D1=81=D0=BA=D0=B8=D0=BC?=
 =?UTF-8?q?=D0=B8=20=D0=BE=D0=BF=D0=B5=D1=80=D0=B0=D1=86=D0=B8=D1=8F=D0=BC?=
 =?UTF-8?q?=D0=B8=20=D0=BF=D1=80=D0=B8=20=D1=84=D0=BE=D1=80=D0=BC=D0=B8?=
 =?UTF-8?q?=D1=80=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8=D0=B8=20=D1=84=D0=B8=D0=BA?=
 =?UTF-8?q?=D1=82=D0=B8=D0=B2=D0=BD=D0=BE=D0=B3=D0=BE=20=D1=81=D0=BF=D0=B8?=
 =?UTF-8?q?=D1=81=D0=BA=D0=B0=20=D1=81=D1=83=D1=82=D0=BE=D1=87=D0=BD=D1=8B?=
 =?UTF-8?q?=D1=85=20=D0=BE=D1=82=D1=87=D1=91=D1=82=D0=BE=D0=B2?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../DailyReport/DailyReportService.cs         | 22 +++++++++----------
 1 file changed, 10 insertions(+), 12 deletions(-)

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<DailyReportDto>();
 
 		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);
 		}
 	}