forked from ddrilling/AsbCloudServer
Merge branch 'dev' into feature/22492122-get-drill-test-data
This commit is contained in:
commit
fffb367fcd
@ -26,17 +26,25 @@ namespace AsbCloudApp.Services
|
|||||||
Task<IEnumerable<TDto>> GetAsync(int idWell,
|
Task<IEnumerable<TDto>> GetAsync(int idWell,
|
||||||
DateTime dateBegin = default, double intervalSec = 600d,
|
DateTime dateBegin = default, double intervalSec = 600d,
|
||||||
int approxPointsCount = 1024, CancellationToken token = default);
|
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);
|
Task<IEnumerable<TDto>> GetAsync(int idWell, TelemetryDataRequest request, CancellationToken token);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Получение статистики за период
|
/// Получение периода за период
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="idWell"></param>
|
/// <param name="idWell"></param>
|
||||||
/// <param name="start"></param>
|
/// <param name="start"></param>
|
||||||
/// <param name="end"></param>
|
/// <param name="end"></param>
|
||||||
/// <param name="token"></param>
|
/// <param name="token"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<DatesRangeDto?> GetRangeAsync(int idWell, DateTimeOffset start, DateTimeOffset end, CancellationToken token);
|
DatesRangeDto? GetRange(int idWell, DateTimeOffset start, DateTimeOffset end);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// добавить/изменить данные тех. процесса (используется панелью)
|
/// добавить/изменить данные тех. процесса (используется панелью)
|
||||||
|
@ -203,40 +203,27 @@ namespace AsbCloudInfrastructure.Services.SAUB
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public virtual async Task<DatesRangeDto?> GetRangeAsync(
|
public DatesRangeDto? GetRange(int idWell, DateTimeOffset start, DateTimeOffset end)
|
||||||
int idWell,
|
|
||||||
DateTimeOffset start,
|
|
||||||
DateTimeOffset end,
|
|
||||||
CancellationToken token)
|
|
||||||
{
|
{
|
||||||
var telemetry = telemetryService.GetOrDefaultTelemetryByIdWell(idWell);
|
var telemetry = telemetryService.GetOrDefaultTelemetryByIdWell(idWell);
|
||||||
if (telemetry is null)
|
if (telemetry is null)
|
||||||
return default;
|
return default;
|
||||||
|
|
||||||
var timezone = telemetryService.GetTimezone(telemetry.Id);
|
var datesRange = telemetryDataCache.GetOrDefaultDataDateRange(telemetry.Id);
|
||||||
var startUtc = start.ToOffset(TimeSpan.Zero);
|
|
||||||
var endUtc = end.ToOffset(TimeSpan.Zero);
|
|
||||||
|
|
||||||
var dbSet = db.Set<TEntity>();
|
if (datesRange is null)
|
||||||
var query = dbSet
|
return null;
|
||||||
.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),
|
|
||||||
});
|
|
||||||
|
|
||||||
var data = await query.FirstOrDefaultAsync(token);
|
var from = datesRange.From > start.DateTime
|
||||||
if (data is null)
|
? datesRange.From : start.DateTime;
|
||||||
return default;
|
|
||||||
|
var to = datesRange.To < end.DateTime
|
||||||
|
? datesRange.To : end.DateTime;
|
||||||
|
|
||||||
return new DatesRangeDto
|
return new DatesRangeDto
|
||||||
{
|
{
|
||||||
From = data.DateStart.ToRemoteDateTime(timezone.Hours),
|
From = from,
|
||||||
To = data.DateEnd.ToRemoteDateTime(timezone.Hours),
|
To = to,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -153,7 +153,7 @@ namespace AsbCloudWebApi.Controllers.SAUB
|
|||||||
if (!isCompanyOwnsWell)
|
if (!isCompanyOwnsWell)
|
||||||
return Forbid();
|
return Forbid();
|
||||||
|
|
||||||
var content = await telemetryDataService.GetRangeAsync(idWell, start, end, token);
|
var content = telemetryDataService.GetRange(idWell, start, end);
|
||||||
|
|
||||||
return Ok(content);
|
return Ok(content);
|
||||||
}
|
}
|
||||||
|
@ -68,7 +68,7 @@ namespace AsbCloudWebApi.Controllers.Subsystems
|
|||||||
if (!await UserHasAccesToWellAsync(idWell, token))
|
if (!await UserHasAccesToWellAsync(idWell, token))
|
||||||
return Forbid();
|
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);
|
return Ok(dateRange);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user