diff --git a/AsbCloudApp/Data/SAUB/TelemetryInfoDto.cs b/AsbCloudApp/Data/SAUB/TelemetryInfoDto.cs
index 732fca23..10b36719 100644
--- a/AsbCloudApp/Data/SAUB/TelemetryInfoDto.cs
+++ b/AsbCloudApp/Data/SAUB/TelemetryInfoDto.cs
@@ -67,3 +67,19 @@ public class TelemetryInfoDto
///
public string? Comment { get; set; }
}
+
+///
+/// Информация о телеметрии скважины
+///
+public class WellTelemetryInfoDto
+{
+ ///
+ /// Идентификатор скважины
+ ///
+ public int IdWell { get; set; }
+
+ ///
+ /// Информация о телеметрии
+ ///
+ public TelemetryInfoDto Info { get; set; } = null!;
+}
\ No newline at end of file
diff --git a/AsbCloudApp/Requests/TelemetryInfoRequest.cs b/AsbCloudApp/Requests/TelemetryInfoRequest.cs
index fb6f68d4..82b36a32 100644
--- a/AsbCloudApp/Requests/TelemetryInfoRequest.cs
+++ b/AsbCloudApp/Requests/TelemetryInfoRequest.cs
@@ -11,10 +11,10 @@ public class TelemetryInfoRequest
public int IdCompany { get; set; }
///
- /// Определяет состояние скважины
+ /// Необязательный параметр. Определяет состояние скважины
/// 0 - неизвестно,
/// 1 - в работе,
/// 2 - завершена
///
- public int IdWellState { get; set; }
+ public int? IdWellState { get; set; }
}
\ No newline at end of file
diff --git a/AsbCloudApp/Services/ITelemetryService.cs b/AsbCloudApp/Services/ITelemetryService.cs
index 9ebdb36e..e59ef022 100644
--- a/AsbCloudApp/Services/ITelemetryService.cs
+++ b/AsbCloudApp/Services/ITelemetryService.cs
@@ -69,7 +69,7 @@ public interface ITelemetryService
///
///
///
- Task> GetInfoAsync(TelemetryInfoRequest request, CancellationToken token);
+ Task> GetInfoAsync(TelemetryInfoRequest request, CancellationToken token);
///
/// Слить данные телеметрии в одну
diff --git a/AsbCloudInfrastructure/Services/SAUB/TelemetryService.cs b/AsbCloudInfrastructure/Services/SAUB/TelemetryService.cs
index d67f3a18..96db61ce 100644
--- a/AsbCloudInfrastructure/Services/SAUB/TelemetryService.cs
+++ b/AsbCloudInfrastructure/Services/SAUB/TelemetryService.cs
@@ -78,15 +78,18 @@ public class TelemetryService : ITelemetryService
DropTelemetryCache();
}
- public async Task> GetInfoAsync(TelemetryInfoRequest request, CancellationToken token)
+ public async Task> GetInfoAsync(TelemetryInfoRequest request, CancellationToken token)
{
- var idTelemetries = await db.Set()
+ var wells = db.Set()
.Include(x => x.RelationCompaniesWells)
- .Where(x => x.RelationCompaniesWells.Any(y => y.IdCompany == request.IdCompany) &&
- x.IdState == request.IdWellState)
- .Where(x => x.IdTelemetry.HasValue)
- .Select(x => x.IdTelemetry!.Value)
- .ToArrayAsync(token);
+ .Where(x => x.RelationCompaniesWells.Any(y => y.IdCompany == request.IdCompany));
+
+ if (request.IdWellState.HasValue)
+ wells = wells.Where(x => x.IdState == request.IdWellState);
+
+ var idTelemetries = await wells.Where(x => x.IdTelemetry.HasValue)
+ .Select(x => x.IdTelemetry!.Value)
+ .ToArrayAsync(token);
var key = $"TelemetryInfo_{string.Join("", idTelemetries)}";
@@ -94,19 +97,25 @@ public class TelemetryService : ITelemetryService
{
entry.AbsoluteExpirationRelativeToNow = TimeSpan.FromMinutes(10);
- var query = db.Set()
+ var telemetries = await db.Set()
+ .Include(x => x.Well)
.Where(x => idTelemetries.Contains(x.Id))
- .OrderBy(x => x.Info.DrillingStartDate);
-
- var entities = await query
+ .OrderBy(x => x.Info.DrillingStartDate)
.AsNoTracking()
.ToArrayAsync(token);
- var dtos = entities.Select(x =>
+ var dtos = telemetries.Select(x =>
{
- var dto = x.Info.Adapt();
- dto.DrillingStartDate = x.Info.DrillingStartDate.ToRemoteDateTime(dto.TimeZoneOffsetTotalHours);
- return dto;
+ var info = x.Info.Adapt();
+ info.DrillingStartDate = x.Info.DrillingStartDate.ToRemoteDateTime(info.TimeZoneOffsetTotalHours);
+
+ var dto = new WellTelemetryInfoDto
+ {
+ IdWell = x.Well!.Id,
+ Info = info
+ };
+
+ return dto;
});
return dtos;
diff --git a/AsbCloudWebApi/Controllers/TelemetryInfoController.cs b/AsbCloudWebApi/Controllers/TelemetryInfoController.cs
index b7890f18..d12acecc 100644
--- a/AsbCloudWebApi/Controllers/TelemetryInfoController.cs
+++ b/AsbCloudWebApi/Controllers/TelemetryInfoController.cs
@@ -28,7 +28,8 @@ public class TelemetryInfoController : ControllerBase
///
/// Получить список версий прошивок
///
- /// Определяет состояние скважины
+ /// Необязательный параметр. Определяет состояние скважины
+ /// null - возвращаются все записи
/// 0 - неизвестно,
/// 1 - в работе,
/// 2 - завершена
@@ -36,8 +37,8 @@ public class TelemetryInfoController : ControllerBase
///
[HttpGet]
[Permission]
- [ProducesResponseType(typeof(IEnumerable), StatusCodes.Status200OK)]
- public async Task GetAsync([FromQuery] int idWellState, CancellationToken token)
+ [ProducesResponseType(typeof(IEnumerable), StatusCodes.Status200OK)]
+ public async Task GetAsync([FromQuery] int? idWellState, CancellationToken token)
{
var idCompany = User.GetCompanyId();