forked from ddrilling/AsbCloudServer
Изменение TelemetryService
Добавлен новый метод
This commit is contained in:
parent
bb2840c20a
commit
004b772503
@ -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>
|
||||
|
@ -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)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user