Изменение TelemetryService

Добавлен новый метод
This commit is contained in:
Степанов Дмитрий 2024-08-21 14:52:31 +05:00
parent bb2840c20a
commit 004b772503
2 changed files with 36 additions and 0 deletions

View File

@ -1,5 +1,6 @@
using AsbCloudApp.Data;
using AsbCloudApp.Data.SAUB;
using AsbCloudApp.Requests;
using System;
using System.Collections.Generic;
using System.IO;
@ -62,6 +63,14 @@ public interface ITelemetryService
/// <returns></returns>
Task UpdateInfoAsync(string uid, TelemetryInfoDto info, CancellationToken token);
/// <summary>
/// Получить данные о телеметрии
/// </summary>
/// <param name="request"></param>
/// <param name="token"></param>
/// <returns></returns>
Task<IEnumerable<TelemetryInfoDto>> GetInfoAsync(TelemetryInfoRequest request, CancellationToken token);
/// <summary>
/// Слить данные телеметрии в одну
/// </summary>

View File

@ -14,6 +14,7 @@ using System.Linq;
using System.Text.Csv;
using System.Threading;
using System.Threading.Tasks;
using AsbCloudApp.Requests;
namespace AsbCloudInfrastructure.Services.SAUB;
@ -78,6 +79,32 @@ public class TelemetryService : ITelemetryService
DropTelemetryCache();
}
public async Task<IEnumerable<TelemetryInfoDto>> GetInfoAsync(TelemetryInfoRequest request, CancellationToken token)
{
var idTelemetries = await db.Set<Well>().Include(x => x.RelationCompaniesWells)
.Where(x => x.RelationCompaniesWells.Any(y => y.IdCompany == request.IdCompany) &&
x.IdState == request.IdWellState)
.Select(x => x.IdTelemetry)
.ToArrayAsync(token);
var query = db.Set<Telemetry>()
.Where(x => idTelemetries.Contains(x.Id));
if (request.SortFields?.Any() == true)
query = query.SortBy(request.SortFields);
var entities = await query
.AsNoTracking()
.ToArrayAsync(token);
return entities.Select(x =>
{
var dto = x.Info.Adapt<TelemetryInfoDto>();
dto.DrillingStartDate = x.Info.DrillingStartDate.ToRemoteDateTime(dto.TimeZoneOffsetTotalHours);
return dto;
});
}
[Obsolete("This method will be private. Use TelemetryDto.TimeZone prop.")]
public SimpleTimezoneDto GetTimezone(int idTelemetry)
{