Фильтр статистики по дате, а не по глубине

This commit is contained in:
Olga Nemt 2024-02-14 15:28:37 +05:00
parent 08e0a4fb38
commit 0f93c637e0
3 changed files with 10 additions and 7 deletions

View File

@ -1,4 +1,5 @@
using AsbCloudApp.Data;
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
@ -14,11 +15,11 @@ namespace AsbCloudApp.Repositories
/// Получение записей по ключу телеметрии
/// </summary>
/// <param name="idTelemetry">ключ телеметрии</param>
/// <param name="geDepth">начальная глубина</param>
/// <param name="leDepth">конечная глубина</param>
/// <param name="geDate">начальная дата</param>
/// <param name="leDate">конечная дата</param>
/// <param name="token"></param>
/// <returns></returns>
Task<IEnumerable<DataSaubStatDto>> GetAsync(int idTelemetry, double geDepth, double leDepth, CancellationToken token);
Task<IEnumerable<DataSaubStatDto>> GetAsync(int idTelemetry, DateTimeOffset geDate, DateTimeOffset leDate, CancellationToken token);
/// <summary>
/// Получение последних по дате окончания бурения записей в разрезе телеметрий

View File

@ -40,14 +40,14 @@ namespace AsbCloudInfrastructure.Repository
return result;
}
public async Task<IEnumerable<DataSaubStatDto>> GetAsync(int idTelemetry, double geDepth, double leDepth, CancellationToken token)
public async Task<IEnumerable<DataSaubStatDto>> GetAsync(int idTelemetry, DateTimeOffset geDate, DateTimeOffset leDate, CancellationToken token)
{
var timeSpan = TimeSpan.FromHours(telemetryService.GetTimezone(idTelemetry).Hours);
var stats = await db.Set<DataSaubStat>()
.Where(s => s.IdTelemetry == idTelemetry)
.Where(s => s.DepthStart >= geDepth)
.Where(s => s.DepthEnd <= leDepth)
.Where(s => s.DateStart >= geDate)
.Where(s => s.DateEnd <= leDate)
.ToArrayAsync(token);
var result = stats.Select(s => ConvertToDto(s, timeSpan));

View File

@ -67,8 +67,10 @@ namespace AsbCloudInfrastructure.Services.ProcessMaps.Report
if (!wellOperations.Any())
return Enumerable.Empty<ProcessMapReportDataSaubStatDto>();
var geDate = wellOperations.Min(p => p.DateStart).ToUniversalTime();
var leDate = wellOperations.Max(p => (p.DateStart.AddHours(p.DurationHours))).ToUniversalTime();
var dataSaubStats =
(await dataSaubStatRepository.GetAsync(well.IdTelemetry.Value, geDepth, leDepth, token)).ToArray();
(await dataSaubStatRepository.GetAsync(well.IdTelemetry.Value, geDate, leDate, token)).ToArray();
if (!dataSaubStats.Any())
return Enumerable.Empty<ProcessMapReportDataSaubStatDto>();