изменение фильтрации запроса в методе получения интервалов глубин,

мелкие правки
This commit is contained in:
eugeniy_ivanov 2022-11-03 15:57:45 +05:00
parent 087a9e26fa
commit f8502b68a1
5 changed files with 21 additions and 15 deletions

View File

@ -43,11 +43,12 @@ namespace AsbCloudApp.Services
/// <summary>
/// Получить интервалы глубин по всем скважинам
/// </summary>
/// <param name="telemetryIds">список ИД телеметрий активных скважин</param>
/// <param name="gtDate"></param>
/// <param name="ltDate"></param>
/// <param name="token"></param>
/// <returns>кортеж - ид телеметрии, интервалы глубины забоя </returns>
Task<IEnumerable<(int,double, double)>?> GetDepthIntervalAllOperationsAsync(DateTimeOffset gtDate, DateTimeOffset ltDate, CancellationToken token);
/// <returns>кортеж - ид телеметрии, интервалы глубины забоя (ротор,слайд) </returns>
Task<IEnumerable<(int idTelemetry,double depthIntervalRotor, double depthIntervalSlide)>?> GetDepthIntervalAllOperationsAsync(IEnumerable<int> telemetryIds,DateTimeOffset gtDate, DateTimeOffset ltDate, CancellationToken token);
/// <summary>
/// Удалить операции

View File

@ -55,7 +55,7 @@ namespace AsbCloudApp.Services.Subsystems
/// <param name="ltDate"></param>
/// <param name="token"></param>
/// <returns></returns>
Task<IEnumerable<SubsystemActiveWellStatDto>?> GetStatByActiveWell(int idCompany, DateTime? gtDate, DateTime? ltDate, CancellationToken token);
Task<IEnumerable<SubsystemActiveWellStatDto>?> GetStatByActiveWells(int idCompany, DateTime? gtDate, DateTime? ltDate, CancellationToken token);
}
#nullable disable
}

View File

@ -82,25 +82,30 @@ namespace AsbCloudInfrastructure.Services.DetectOperations
var schedules = await scheduleService.GetByIdWellAsync(request.IdWell, token);
var dtos = data.Select(o => Convert(o, well, operationValues, schedules));
return dtos;
}
}
public async Task<IEnumerable<(int, double, double)>?> GetDepthIntervalAllOperationsAsync(DateTimeOffset gtDate, DateTimeOffset ltDate, CancellationToken token)
public async Task<IEnumerable<(int idTelemetry, double depthIntervalRotor, double depthIntervalSlide)>?> GetDepthIntervalAllOperationsAsync(IEnumerable<int> telemetryIds, DateTimeOffset gtDate, DateTimeOffset ltDate, CancellationToken token)
{
var query = db.Set<DetectedOperation>()
.Include(o => o.OperationCategory)
.Where(o => o.DateStart >= gtDate)
.Where(o => o.DateEnd <= ltDate);
.Where(o => o.DateEnd <= ltDate)
.Where(o => telemetryIds.Contains(o.IdTelemetry))
.GroupBy(g => g.IdTelemetry)
.Select(g => new
{
IdTelemetry = g.Key,
RotorDepthInterval = g.Where(o => o.IdCategory == 1).Sum(o => o.DepthEnd - o.DepthStart),
SlideDepthInterval = g.Where(o => o.IdCategory == 3).Sum(o => o.DepthEnd - o.DepthStart)
});
var data = await query.ToListAsync(token);
if (data.Any())
{
var result = data.GroupBy(g => g.IdTelemetry)
.Select(g =>
var result = data.Select(g =>
(
g.Key,
g.Where(o => o.IdCategory == 1).Sum(o => o.DepthEnd - o.DepthStart),
g.Where(o => o.IdCategory == 3).Sum(o => o.DepthEnd - o.DepthStart)
g.IdTelemetry,
g.RotorDepthInterval,
g.SlideDepthInterval
));
return result;
}

View File

@ -198,7 +198,7 @@ namespace AsbCloudInfrastructure.Services.Subsystems
public async Task<IEnumerable<SubsystemActiveWellStatDto>?> GetStatByActiveWells(int idCompany, DateTime? gtDate, DateTime? ltDate, CancellationToken token)
{
var activeWell = await GetActiveWellByCompany(idCompany, token);
var activeWell = await GetActiveWellsByCompany(idCompany, token);
var telemetryIds = activeWell.Select(w => w.IdTelemetry).Distinct();
var firstWell = activeWell.FirstOrDefault();
if (firstWell == null)

View File

@ -60,7 +60,7 @@ namespace AsbCloudWebApi.Controllers.Subsystems
var idCompany = User.GetCompanyId();
if (!idCompany.HasValue)
return Forbid();
var subsystemResult = await subsystemOperationTimeService.GetStatByActiveWell(idCompany.Value, GtDate, LtDate, token);
var subsystemResult = await subsystemOperationTimeService.GetStatByActiveWells(idCompany.Value, GtDate, LtDate, token);
return Ok(subsystemResult);
}