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;