From f8502b68a126fa79a06aab2d875acfe7238df0d9 Mon Sep 17 00:00:00 2001 From: eugeniy_ivanov Date: Thu, 3 Nov 2022 15:57:45 +0500 Subject: [PATCH] =?UTF-8?q?=D0=B8=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D0=B5=20=D1=84=D0=B8=D0=BB=D1=8C=D1=82=D1=80=D0=B0=D1=86?= =?UTF-8?q?=D0=B8=D0=B8=20=D0=B7=D0=B0=D0=BF=D1=80=D0=BE=D1=81=D0=B0=20?= =?UTF-8?q?=D0=B2=20=D0=BC=D0=B5=D1=82=D0=BE=D0=B4=D0=B5=20=D0=BF=D0=BE?= =?UTF-8?q?=D0=BB=D1=83=D1=87=D0=B5=D0=BD=D0=B8=D1=8F=20=D0=B8=D0=BD=D1=82?= =?UTF-8?q?=D0=B5=D1=80=D0=B2=D0=B0=D0=BB=D0=BE=D0=B2=20=D0=B3=D0=BB=D1=83?= =?UTF-8?q?=D0=B1=D0=B8=D0=BD,=20=D0=BC=D0=B5=D0=BB=D0=BA=D0=B8=D0=B5=20?= =?UTF-8?q?=D0=BF=D1=80=D0=B0=D0=B2=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Services/IDetectedOperationService.cs | 5 ++-- .../ISubsystemOperationTimeService.cs | 2 +- .../DetectedOperationService.cs | 25 +++++++++++-------- .../SubsystemOperationTimeService.cs | 2 +- .../SubsystemOperationTimeController.cs | 2 +- 5 files changed, 21 insertions(+), 15 deletions(-) diff --git a/AsbCloudApp/Services/IDetectedOperationService.cs b/AsbCloudApp/Services/IDetectedOperationService.cs index 14bfbb8a..7076b472 100644 --- a/AsbCloudApp/Services/IDetectedOperationService.cs +++ b/AsbCloudApp/Services/IDetectedOperationService.cs @@ -43,11 +43,12 @@ namespace AsbCloudApp.Services /// /// Получить интервалы глубин по всем скважинам /// + /// список ИД телеметрий активных скважин /// /// /// - /// кортеж - ид телеметрии, интервалы глубины забоя - Task?> GetDepthIntervalAllOperationsAsync(DateTimeOffset gtDate, DateTimeOffset ltDate, CancellationToken token); + /// кортеж - ид телеметрии, интервалы глубины забоя (ротор,слайд) + Task?> GetDepthIntervalAllOperationsAsync(IEnumerable telemetryIds,DateTimeOffset gtDate, DateTimeOffset ltDate, CancellationToken token); /// /// Удалить операции diff --git a/AsbCloudApp/Services/Subsystems/ISubsystemOperationTimeService.cs b/AsbCloudApp/Services/Subsystems/ISubsystemOperationTimeService.cs index 88fd3cf4..b4032552 100644 --- a/AsbCloudApp/Services/Subsystems/ISubsystemOperationTimeService.cs +++ b/AsbCloudApp/Services/Subsystems/ISubsystemOperationTimeService.cs @@ -55,7 +55,7 @@ namespace AsbCloudApp.Services.Subsystems /// /// /// - Task?> GetStatByActiveWell(int idCompany, DateTime? gtDate, DateTime? ltDate, CancellationToken token); + Task?> GetStatByActiveWells(int idCompany, DateTime? gtDate, DateTime? ltDate, CancellationToken token); } #nullable disable } diff --git a/AsbCloudInfrastructure/Services/DetectOperations/DetectedOperationService.cs b/AsbCloudInfrastructure/Services/DetectOperations/DetectedOperationService.cs index bd11afe6..f163d4c1 100644 --- a/AsbCloudInfrastructure/Services/DetectOperations/DetectedOperationService.cs +++ b/AsbCloudInfrastructure/Services/DetectOperations/DetectedOperationService.cs @@ -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?> GetDepthIntervalAllOperationsAsync(DateTimeOffset gtDate, DateTimeOffset ltDate, CancellationToken token) + public async Task?> GetDepthIntervalAllOperationsAsync(IEnumerable telemetryIds, DateTimeOffset gtDate, DateTimeOffset ltDate, CancellationToken token) { var query = db.Set() .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; } diff --git a/AsbCloudInfrastructure/Services/Subsystems/SubsystemOperationTimeService.cs b/AsbCloudInfrastructure/Services/Subsystems/SubsystemOperationTimeService.cs index 103adbc8..2ee9ea00 100644 --- a/AsbCloudInfrastructure/Services/Subsystems/SubsystemOperationTimeService.cs +++ b/AsbCloudInfrastructure/Services/Subsystems/SubsystemOperationTimeService.cs @@ -198,7 +198,7 @@ namespace AsbCloudInfrastructure.Services.Subsystems public async Task?> 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) diff --git a/AsbCloudWebApi/Controllers/Subsystems/SubsystemOperationTimeController.cs b/AsbCloudWebApi/Controllers/Subsystems/SubsystemOperationTimeController.cs index 7790472f..0d832667 100644 --- a/AsbCloudWebApi/Controllers/Subsystems/SubsystemOperationTimeController.cs +++ b/AsbCloudWebApi/Controllers/Subsystems/SubsystemOperationTimeController.cs @@ -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); }