Merge branch 'feature/22492122-get-drill-test-data' of http://test.digitaldrilling.ru:8080/DDrilling/AsbCloudServer into feature/22492122-get-drill-test-data

This commit is contained in:
Olga Nemt 2023-10-17 17:12:19 +05:00
commit 83d952bab6
4 changed files with 23 additions and 28 deletions

View File

@ -26,17 +26,25 @@ namespace AsbCloudApp.Services
Task<IEnumerable<TDto>> GetAsync(int idWell,
DateTime dateBegin = default, double intervalSec = 600d,
int approxPointsCount = 1024, CancellationToken token = default);
/// <summary>
/// Получить данные тех. процесса
/// </summary>
/// <param name="idWell"></param>
/// <param name="request"></param>
/// <param name="token"></param>
/// <returns></returns>
Task<IEnumerable<TDto>> GetAsync(int idWell, TelemetryDataRequest request, CancellationToken token);
/// <summary>
/// Получение статистики за период
/// Получение периода за период
/// </summary>
/// <param name="idWell"></param>
/// <param name="start"></param>
/// <param name="end"></param>
/// <param name="token"></param>
/// <returns></returns>
Task<DatesRangeDto?> GetRangeAsync(int idWell, DateTimeOffset start, DateTimeOffset end, CancellationToken token);
DatesRangeDto? GetRange(int idWell, DateTimeOffset start, DateTimeOffset end);
/// <summary>
/// добавить/изменить данные тех. процесса (используется панелью)

View File

@ -203,40 +203,27 @@ namespace AsbCloudInfrastructure.Services.SAUB
}
/// <inheritdoc/>
public virtual async Task<DatesRangeDto?> GetRangeAsync(
int idWell,
DateTimeOffset start,
DateTimeOffset end,
CancellationToken token)
public DatesRangeDto? GetRange(int idWell, DateTimeOffset start, DateTimeOffset end)
{
var telemetry = telemetryService.GetOrDefaultTelemetryByIdWell(idWell);
if (telemetry is null)
return default;
var timezone = telemetryService.GetTimezone(telemetry.Id);
var startUtc = start.ToOffset(TimeSpan.Zero);
var endUtc = end.ToOffset(TimeSpan.Zero);
var datesRange = telemetryDataCache.GetOrDefaultDataDateRange(telemetry.Id);
var dbSet = db.Set<TEntity>();
var query = dbSet
.Where(i => i.IdTelemetry == telemetry.Id)
.Where(i => i.DateTime >= startUtc)
.Where(i => i.DateTime <= endUtc)
.GroupBy(i => i.IdTelemetry)
.Select(g => new
{
DateStart = g.Min(i => i.DateTime),
DateEnd = g.Max(i => i.DateTime),
});
if (datesRange is null)
return null;
var data = await query.FirstOrDefaultAsync(token);
if (data is null)
return default;
var from = datesRange.From > start.DateTime
? datesRange.From : start.DateTime;
var to = datesRange.To < end.DateTime
? datesRange.To : end.DateTime;
return new DatesRangeDto
{
From = data.DateStart.ToRemoteDateTime(timezone.Hours),
To = data.DateEnd.ToRemoteDateTime(timezone.Hours),
From = from,
To = to,
};
}

View File

@ -153,7 +153,7 @@ namespace AsbCloudWebApi.Controllers.SAUB
if (!isCompanyOwnsWell)
return Forbid();
var content = await telemetryDataService.GetRangeAsync(idWell, start, end, token);
var content = telemetryDataService.GetRange(idWell, start, end);
return Ok(content);
}

View File

@ -68,7 +68,7 @@ namespace AsbCloudWebApi.Controllers.Subsystems
if (!await UserHasAccesToWellAsync(idWell, token))
return Forbid();
var dateRange = await telemetryDataSaubService.GetRangeAsync(idWell, DateTimeOffset.MinValue, DateTimeOffset.MaxValue, token);
var dateRange = telemetryDataSaubService.GetRange(idWell, DateTimeOffset.MinValue, DateTimeOffset.MaxValue);
return Ok(dateRange);
}