From db33e82d022b8d5cad9b14253622011c740da110 Mon Sep 17 00:00:00 2001
From: Olga Nemt <on.nemtina@digitaldrilling.ru>
Date: Mon, 25 Mar 2024 09:36:57 +0500
Subject: [PATCH] =?UTF-8?q?=D0=A1=D0=BC=D0=B5=D0=BD=D0=B0=20=D1=82=D0=B8?=
 =?UTF-8?q?=D0=BF=D0=BE=D0=B2=20=D0=B4=D0=B0=D1=82=20=D0=B2=D0=BD=D1=83?=
 =?UTF-8?q?=D1=82=D1=80=D0=B8=20DailyReportService,=20ReportService=20?=
 =?UTF-8?q?=D0=B8=20SheduleController?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 AsbCloudApp/Services/IScheduleService.cs                 | 4 ++--
 .../Services/DailyReport/DailyReportService.cs           | 8 +++-----
 AsbCloudInfrastructure/Services/ReportService.cs         | 9 +++++----
 AsbCloudWebApi/Controllers/ScheduleController.cs         | 2 +-
 4 files changed, 11 insertions(+), 12 deletions(-)

diff --git a/AsbCloudApp/Services/IScheduleService.cs b/AsbCloudApp/Services/IScheduleService.cs
index 5a28b4c2..81c0d385 100644
--- a/AsbCloudApp/Services/IScheduleService.cs
+++ b/AsbCloudApp/Services/IScheduleService.cs
@@ -19,7 +19,7 @@ namespace AsbCloudApp.Services
         /// <param name="workTime"></param>
         /// <param name="token"></param>
         /// <returns></returns>
-        Task<IEnumerable<ScheduleDto>> GetAsync(int idWell, DateTime workTime, CancellationToken token);
+        Task<IEnumerable<ScheduleDto>> GetAsync(int idWell, DateTimeOffset workTime, CancellationToken token);
         
         /// <summary>
         /// получить бурильщика по idWell и времени
@@ -28,7 +28,7 @@ namespace AsbCloudApp.Services
         /// <param name="workTime"></param>
         /// <param name="token"></param>
         /// <returns></returns>
-        Task<DrillerDto?> GetOrDefaultDrillerAsync(int idWell, DateTime workTime, CancellationToken token);
+        Task<DrillerDto?> GetOrDefaultDrillerAsync(int idWell, DateTimeOffset workTime, CancellationToken token);
 
         /// <summary>
         /// Получить расписание смен
diff --git a/AsbCloudInfrastructure/Services/DailyReport/DailyReportService.cs b/AsbCloudInfrastructure/Services/DailyReport/DailyReportService.cs
index a188426e..7570a95f 100644
--- a/AsbCloudInfrastructure/Services/DailyReport/DailyReportService.cs
+++ b/AsbCloudInfrastructure/Services/DailyReport/DailyReportService.cs
@@ -135,7 +135,7 @@ public class DailyReportService : IDailyReportService
 		await UpdateSubsystemBlockAsync(dailyReport, cancellationToken);
 		
 		await AddTrajectoryBlockAsync(dailyReport, cancellationToken);
-		await AddScheduleBlockAsync(dailyReport, cancellationToken);
+		await AddScheduleBlockAsync(dailyReport, geDate, cancellationToken);
 		await AddProcessMapWellDrillingBlockAsync(dailyReport, cancellationToken);
 
 		AddFactWellOperationBlock(dailyReport, factWellOperations);
@@ -315,11 +315,9 @@ public class DailyReportService : IDailyReportService
 		};
 	}
 
-	private async Task AddScheduleBlockAsync(DailyReportDto dailyReport, CancellationToken cancellationToken)
+	private async Task AddScheduleBlockAsync(DailyReportDto dailyReport, DateTimeOffset workDate, CancellationToken cancellationToken)
 	{
-		var workDate = dailyReport.Date.ToDateTime(TimeOnly.MinValue, DateTimeKind.Unspecified);
-		
-		dailyReport.ScheduleBlock = (await scheduleRepository.GetAsync(dailyReport.IdWell, workDate, cancellationToken))
+        dailyReport.ScheduleBlock = (await scheduleRepository.GetAsync(dailyReport.IdWell, workDate, cancellationToken))
 			.Select(s => new ScheduleRecordDto
 			{
 				ShiftStart = s.ShiftStart,
diff --git a/AsbCloudInfrastructure/Services/ReportService.cs b/AsbCloudInfrastructure/Services/ReportService.cs
index 04d7c63b..4d321525 100644
--- a/AsbCloudInfrastructure/Services/ReportService.cs
+++ b/AsbCloudInfrastructure/Services/ReportService.cs
@@ -87,6 +87,7 @@ public class ReportService : IReportService
     public async Task<IEnumerable<ReportPropertiesDto>> GetAllReportsByWellAsync(int idWell, CancellationToken token)
     {
         var timezoneOffset = wellService.GetTimezone(idWell).Hours;
+        var timeSpan = TimeSpan.FromHours(timezoneOffset);
         var propertiesQuery = db.ReportProperties.Include(r => r.File)
          .Where(p => p.IdWell == idWell)
         .OrderBy(o => o.File.UploadDate)
@@ -106,12 +107,12 @@ public class ReportService : IReportService
                 IdWell = p.File.IdWell,
                 Name = p.File.Name,
                 Size = p.File.Size,
-                UploadDate = p.File.UploadDate.ToOffset(TimeSpan.FromHours(timezoneOffset)),
+                UploadDate = p.File.UploadDate.ToOffset(timeSpan),
             },
             IdWell = p.IdWell,
-            Date = p.File.UploadDate.ToRemoteDateTime(timezoneOffset),
-            Begin = p.Begin.ToRemoteDateTime(timezoneOffset),
-            End = p.End.ToRemoteDateTime(timezoneOffset),
+            Date = p.File.UploadDate.ToOffset(timeSpan),
+            Begin = p.Begin.ToOffset(timeSpan),
+            End = p.End.ToOffset(timeSpan),
             Step = p.Step,
             Format = p.Format == 0 ? ".pdf" : ".las"
         });
diff --git a/AsbCloudWebApi/Controllers/ScheduleController.cs b/AsbCloudWebApi/Controllers/ScheduleController.cs
index a8c73d30..cc56a296 100644
--- a/AsbCloudWebApi/Controllers/ScheduleController.cs
+++ b/AsbCloudWebApi/Controllers/ScheduleController.cs
@@ -33,7 +33,7 @@ namespace AsbCloudWebApi.Controllers
         /// <param name="token"></param>
         /// <returns>бурильщик</returns>
         [HttpGet("driller")]
-        public async Task<ActionResult<DrillerDto?>> GetDrillerAsync(int idWell, DateTime workTime, CancellationToken token)
+        public async Task<ActionResult<DrillerDto?>> GetDrillerAsync(int idWell, DateTimeOffset workTime, CancellationToken token)
         {
             if (!await UserHasAccesToWellAsync(idWell, token))
                 return Forbid();