forked from ddrilling/AsbCloudServer
изменение фильтрации запроса в методе получения интервалов глубин,
мелкие правки
This commit is contained in:
parent
087a9e26fa
commit
f8502b68a1
@ -43,11 +43,12 @@ namespace AsbCloudApp.Services
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Получить интервалы глубин по всем скважинам
|
/// Получить интервалы глубин по всем скважинам
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <param name="telemetryIds">список ИД телеметрий активных скважин</param>
|
||||||
/// <param name="gtDate"></param>
|
/// <param name="gtDate"></param>
|
||||||
/// <param name="ltDate"></param>
|
/// <param name="ltDate"></param>
|
||||||
/// <param name="token"></param>
|
/// <param name="token"></param>
|
||||||
/// <returns>кортеж - ид телеметрии, интервалы глубины забоя </returns>
|
/// <returns>кортеж - ид телеметрии, интервалы глубины забоя (ротор,слайд) </returns>
|
||||||
Task<IEnumerable<(int,double, double)>?> GetDepthIntervalAllOperationsAsync(DateTimeOffset gtDate, DateTimeOffset ltDate, CancellationToken token);
|
Task<IEnumerable<(int idTelemetry,double depthIntervalRotor, double depthIntervalSlide)>?> GetDepthIntervalAllOperationsAsync(IEnumerable<int> telemetryIds,DateTimeOffset gtDate, DateTimeOffset ltDate, CancellationToken token);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Удалить операции
|
/// Удалить операции
|
||||||
|
@ -55,7 +55,7 @@ namespace AsbCloudApp.Services.Subsystems
|
|||||||
/// <param name="ltDate"></param>
|
/// <param name="ltDate"></param>
|
||||||
/// <param name="token"></param>
|
/// <param name="token"></param>
|
||||||
/// <returns></returns>
|
/// <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
|
#nullable disable
|
||||||
}
|
}
|
||||||
|
@ -82,25 +82,30 @@ namespace AsbCloudInfrastructure.Services.DetectOperations
|
|||||||
var schedules = await scheduleService.GetByIdWellAsync(request.IdWell, token);
|
var schedules = await scheduleService.GetByIdWellAsync(request.IdWell, token);
|
||||||
var dtos = data.Select(o => Convert(o, well, operationValues, schedules));
|
var dtos = data.Select(o => Convert(o, well, operationValues, schedules));
|
||||||
return dtos;
|
return dtos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<IEnumerable<(int idTelemetry, double depthIntervalRotor, double depthIntervalSlide)>?> GetDepthIntervalAllOperationsAsync(IEnumerable<int> telemetryIds, DateTimeOffset gtDate, DateTimeOffset ltDate, CancellationToken token)
|
||||||
|
|
||||||
public async Task<IEnumerable<(int, double, double)>?> GetDepthIntervalAllOperationsAsync(DateTimeOffset gtDate, DateTimeOffset ltDate, CancellationToken token)
|
|
||||||
{
|
{
|
||||||
var query = db.Set<DetectedOperation>()
|
var query = db.Set<DetectedOperation>()
|
||||||
.Include(o => o.OperationCategory)
|
.Include(o => o.OperationCategory)
|
||||||
.Where(o => o.DateStart >= gtDate)
|
.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);
|
var data = await query.ToListAsync(token);
|
||||||
if (data.Any())
|
if (data.Any())
|
||||||
{
|
{
|
||||||
var result = data.GroupBy(g => g.IdTelemetry)
|
var result = data.Select(g =>
|
||||||
.Select(g =>
|
|
||||||
(
|
(
|
||||||
g.Key,
|
g.IdTelemetry,
|
||||||
g.Where(o => o.IdCategory == 1).Sum(o => o.DepthEnd - o.DepthStart),
|
g.RotorDepthInterval,
|
||||||
g.Where(o => o.IdCategory == 3).Sum(o => o.DepthEnd - o.DepthStart)
|
g.SlideDepthInterval
|
||||||
));
|
));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -198,7 +198,7 @@ namespace AsbCloudInfrastructure.Services.Subsystems
|
|||||||
|
|
||||||
public async Task<IEnumerable<SubsystemActiveWellStatDto>?> GetStatByActiveWells(int idCompany, DateTime? gtDate, DateTime? ltDate, CancellationToken token)
|
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 telemetryIds = activeWell.Select(w => w.IdTelemetry).Distinct();
|
||||||
var firstWell = activeWell.FirstOrDefault();
|
var firstWell = activeWell.FirstOrDefault();
|
||||||
if (firstWell == null)
|
if (firstWell == null)
|
||||||
|
@ -60,7 +60,7 @@ namespace AsbCloudWebApi.Controllers.Subsystems
|
|||||||
var idCompany = User.GetCompanyId();
|
var idCompany = User.GetCompanyId();
|
||||||
if (!idCompany.HasValue)
|
if (!idCompany.HasValue)
|
||||||
return Forbid();
|
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);
|
return Ok(subsystemResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user