From 4ff7b7340325349adace899db85b60e2e1d90397 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?= Date: Wed, 20 Dec 2023 16:42:39 +0500 Subject: [PATCH] =?UTF-8?q?=D0=A4=D0=B8=D0=BA=D1=81=20=D1=80=D0=B5=D0=BF?= =?UTF-8?q?=D0=BE=D0=B7=D0=B8=D1=82=D0=BE=D1=80=D0=B8=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. Поправлена выборка в репозитории с траекториями 2. В репозитории с операциями по скважине добавлено приведение ко времени куста. --- .../Repository/TrajectoryNnbRepository.cs | 18 +++++++++++++++--- .../Repository/WellOperationRepository.cs | 9 +++++++-- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/AsbCloudInfrastructure/Repository/TrajectoryNnbRepository.cs b/AsbCloudInfrastructure/Repository/TrajectoryNnbRepository.cs index 3a3692d9..a55e465f 100644 --- a/AsbCloudInfrastructure/Repository/TrajectoryNnbRepository.cs +++ b/AsbCloudInfrastructure/Repository/TrajectoryNnbRepository.cs @@ -9,20 +9,26 @@ using System.Collections.Generic; using System.Linq; using System.Threading; using System.Threading.Tasks; +using AsbCloudApp.Services; namespace AsbCloudInfrastructure.Repository { public class TrajectoryNnbRepository : ITrajectoryNnbRepository { private readonly IAsbCloudDbContext db; - public TrajectoryNnbRepository(IAsbCloudDbContext db) + private readonly IWellService wellService; + + public TrajectoryNnbRepository(IAsbCloudDbContext db, + IWellService wellService) { this.db = db; + this.wellService = wellService; } private IQueryable BuildQuery(TrajectoryRequest request) { var well = db.Wells.SingleOrDefault(w => w.Id == request.IdWell); + var timezone = wellService.GetTimezone(request.IdWell); if (well is null) throw new ArgumentInvalidException($"Скважина с Id: {request.IdWell} не найдена", nameof(request.IdWell)); @@ -31,10 +37,16 @@ namespace AsbCloudInfrastructure.Repository .Where(x => x.IdTelemetry == well.IdTelemetry); if (request.GeDate.HasValue) - query = query.Where(r => r.DateTime >= request.GeDate.Value); + { + var geDate = request.GeDate.Value.ToUtcDateTimeOffset(timezone.Hours); + query = query.Where(r => r.DateTime >= geDate); + } if (request.LeDate.HasValue) - query = query.Where(r => r.DateTime <= request.LeDate.Value); + { + var leDate = request.LeDate.Value.ToUtcDateTimeOffset(timezone.Hours); + query = query.Where(r => r.DateTime <= leDate); + } return query.OrderBy(e => e.Deptsvym); } diff --git a/AsbCloudInfrastructure/Repository/WellOperationRepository.cs b/AsbCloudInfrastructure/Repository/WellOperationRepository.cs index b87d5a46..fbc94e02 100644 --- a/AsbCloudInfrastructure/Repository/WellOperationRepository.cs +++ b/AsbCloudInfrastructure/Repository/WellOperationRepository.cs @@ -186,15 +186,20 @@ public class WellOperationRepository : IWellOperationRepository public async Task GetDatesRangeAsync(int idWell, int idType, CancellationToken cancellationToken) { + var timezone = wellService.GetTimezone(idWell); + var query = db.WellOperations.Where(o => o.IdWell == idWell && o.IdType == idType); if (!await query.AnyAsync(cancellationToken)) return null; + + var minDate = await query.MinAsync(o => o.DateStart, cancellationToken); + var maxDate = await query.MaxAsync(o => o.DateStart, cancellationToken); return new DatesRangeDto { - From = (await query.MinAsync(o => o.DateStart, cancellationToken)).Date, - To = (await query.MaxAsync(o => o.DateStart, cancellationToken)).Date + From = minDate.ToRemoteDateTime(timezone.Hours), + To = maxDate.ToRemoteDateTime(timezone.Hours) }; }