From e9386b5897e0adeea8e566d17621e6904d1ca65d 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: Mon, 25 Mar 2024 07:33:42 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A1=D0=B8=D0=BD=D1=85=D1=80=D0=BE=D0=BD?= =?UTF-8?q?=D0=BD=D0=BE=D0=B5=20=D0=BF=D0=BE=D0=BB=D1=83=D1=87=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D0=B5=20=D0=B4=D0=B8=D0=B0=D0=BF=D0=B0=D0=B7=D0=BE=D0=BD?= =?UTF-8?q?=D0=B0=20=D0=B4=D0=B0=D1=82=20=D0=BE=D0=BF=D0=B5=D1=80=D0=B0?= =?UTF-8?q?=D1=86=D0=B8=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Repositories/IWellOperationRepository.cs | 8 +++++++ .../Repository/WellOperationRepository.cs | 22 ++++++++++++++++--- .../Services/WellService.cs | 5 ++--- 3 files changed, 29 insertions(+), 6 deletions(-) diff --git a/AsbCloudApp/Repositories/IWellOperationRepository.cs b/AsbCloudApp/Repositories/IWellOperationRepository.cs index ffc69970..2c2817d2 100644 --- a/AsbCloudApp/Repositories/IWellOperationRepository.cs +++ b/AsbCloudApp/Repositories/IWellOperationRepository.cs @@ -76,6 +76,14 @@ namespace AsbCloudApp.Repositories /// Task> GetSectionsAsync(IEnumerable idsWells, CancellationToken token); + /// + /// Получить диапазон дат выполнения операций + /// + /// + /// + /// + DatesRangeDto? GetDatesRange(int idWell, int idType); + /// /// Получить диапазон дат выполнения операций /// diff --git a/AsbCloudInfrastructure/Repository/WellOperationRepository.cs b/AsbCloudInfrastructure/Repository/WellOperationRepository.cs index 7532b2aa..c40efd54 100644 --- a/AsbCloudInfrastructure/Repository/WellOperationRepository.cs +++ b/AsbCloudInfrastructure/Repository/WellOperationRepository.cs @@ -47,7 +47,7 @@ public class WellOperationRepository : CrudRepositoryBase e.IdType == 1 && e.IdWell == o.IdWell) .Where(e => WellOperationCategory.NonProductiveTimeSubIds.Contains(e.IdCategory)) @@ -314,6 +314,23 @@ public class WellOperationRepository : CrudRepositoryBase o.IdWell == idWell && o.IdType == idType); + + if (!query.Any()) + return null; + + var minDate = query.Min(o => o.DateStart); + var maxDate = query.Max(o => o.DateStart); + + return new DatesRangeDto + { + From = minDate.ToOffset(minDate.Offset), + To = maxDate.ToOffset(minDate.Offset) + }; + } + public async Task GetDatesRangeAsync(int idWell, int idType, CancellationToken cancellationToken) { var query = dbContext.WellOperations.Where(o => o.IdWell == idWell && o.IdType == idType); @@ -344,7 +361,6 @@ public class WellOperationRepository : CrudRepositoryBase(); dto.DateStart = src.DateStart.ToOffset(timeZoneOffset); dto.LastUpdateDate = src.LastUpdateDate?.ToOffset(timeZoneOffset); diff --git a/AsbCloudInfrastructure/Services/WellService.cs b/AsbCloudInfrastructure/Services/WellService.cs index 1b306f15..d7c0f7d0 100644 --- a/AsbCloudInfrastructure/Services/WellService.cs +++ b/AsbCloudInfrastructure/Services/WellService.cs @@ -272,9 +272,8 @@ namespace AsbCloudInfrastructure.Services if (entity.Timezone is null) dto.Timezone = GetTimezone(entity.Id); - - //TODO: фикс - //dto.StartDate = wellOperationRepository.GetDatesRangeAsync(entity.Id, ).FirstOperationDate(entity.Id)?.ToRemoteDateTime(dto.Timezone.Hours); + + dto.StartDate = wellOperationRepository.GetDatesRange(entity.Id, WellOperation.IdOperationTypeFact)?.From.ToRemoteDateTime(dto.Timezone.Hours); dto.WellType = entity.WellType.Caption; dto.Cluster = entity.Cluster.Caption; dto.Deposit = entity.Cluster.Deposit.Caption;