From 19117d988feaf010c09b05f9a715d3ed52a00bb2 Mon Sep 17 00:00:00 2001 From: Olga Nemt Date: Thu, 31 Aug 2023 14:12:01 +0500 Subject: [PATCH] =?UTF-8?q?GetDepthIntervalSubsystem=20=D0=BF=D1=80=D0=B8?= =?UTF-8?q?=20=D0=90=D0=9F=D0=94=20=D0=B2=20=D1=80=D0=BE=D1=82=D0=BE=D1=80?= =?UTF-8?q?=D0=B5=20=D0=B8=20=D1=81=D0=BB=D0=B0=D0=B9=D0=B4=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SubsystemOperationTimeService.cs | 53 +++++++++++++++++-- 1 file changed, 50 insertions(+), 3 deletions(-) diff --git a/AsbCloudInfrastructure/Services/Subsystems/SubsystemOperationTimeService.cs b/AsbCloudInfrastructure/Services/Subsystems/SubsystemOperationTimeService.cs index 11c3014b..45b4c3fd 100644 --- a/AsbCloudInfrastructure/Services/Subsystems/SubsystemOperationTimeService.cs +++ b/AsbCloudInfrastructure/Services/Subsystems/SubsystemOperationTimeService.cs @@ -26,6 +26,8 @@ namespace AsbCloudInfrastructure.Services.Subsystems private readonly ICrudRepository subsystemService; private readonly IDetectedOperationService detectedOperationService; public const int IdSubsystemAKB = 1; + public const int IdSubsystemAKBRotor = 11; + public const int IdSubsystemAKBSlide = 12; public const int IdSubsystemMSE = 2; public const int IdSubsystemSpin = 65536; public const int IdSubsystemTorque = 65537; @@ -105,7 +107,7 @@ namespace AsbCloudInfrastructure.Services.Subsystems return null; var depthInterval = GetDepthInterval(detectedOperations); - var statList = CalcStat(data,depthInterval); + var statList = CalcStat(data,depthInterval, request); return statList; } @@ -157,7 +159,10 @@ namespace AsbCloudInfrastructure.Services.Subsystems return items; } - private IEnumerable CalcStat(IEnumerable dtos, (double depthIntervalRotor, double depthIntervalSlide) depthInterval) + private IEnumerable CalcStat( + IEnumerable dtos, + (double depthIntervalRotor, double depthIntervalSlide) depthInterval, + SubsystemOperationTimeRequest? request = null) { var groupedDataSubsystems = dtos .OrderBy(o => o.Id) @@ -167,6 +172,7 @@ namespace AsbCloudInfrastructure.Services.Subsystems var result = groupedDataSubsystems.Select(g => { var depthIntervalSubsystem = GetDepthIntervalSubsystem(g.Key, depthInterval); + //var depthIntervalSubsystem = CalcInterval(request?.GtDepth, request?.LtDepth, g); var periodGroup = g.Sum(o => (o.DateEnd - o.DateStart).TotalHours); var periodGroupDepth = g.Sum(o => o.DepthEnd - o.DepthStart); var subsystemStat = new SubsystemStatDto() @@ -174,7 +180,10 @@ namespace AsbCloudInfrastructure.Services.Subsystems IdSubsystem = g.Key, SubsystemName = subsystemService.GetOrDefault(g.Key)?.Name ?? "unknown", UsedTimeHours = periodGroup, + //% использования = суммарная проходка АПД в слайде + /// суммарную проходку автоопределенных операций в слайде. KUsage = periodGroupDepth / depthIntervalSubsystem, + //KUsage = depthIntervalSubsystem / ((request?.LtDepth ?? 0) - (request?.GtDepth ?? 0)), SumDepthInterval = periodGroupDepth, OperationCount = g.Count(), }; @@ -191,7 +200,7 @@ namespace AsbCloudInfrastructure.Services.Subsystems IdSubsystem = 1, SubsystemName = "АПД", UsedTimeHours = apdParts.Sum(part => part.UsedTimeHours), - KUsage = apdParts.Sum(part => part.KUsage) / apdParts.Count(), + KUsage = apdParts.Sum(part => part.KUsage), SumDepthInterval = apdParts.Sum(part => part.SumDepthInterval), OperationCount = apdParts.Sum(part => part.OperationCount), }; @@ -200,6 +209,34 @@ namespace AsbCloudInfrastructure.Services.Subsystems return result; } + + private double CalcInterval(double? gtDepth, double? ltDepth, IGrouping g) + { + var operations = g.ToList(); + double sum = 0; + foreach(var operation in operations) + { + var start = operation.DepthStart; + if(gtDepth.HasValue) + { + if (operation.DepthStart < gtDepth) + { + start = (double)gtDepth; + } + } + var end = operation.DepthEnd; + if (ltDepth.HasValue) + { + if (operation.DepthEnd > ltDepth) + { + start = (double)ltDepth; + } + } + sum += (end - start); + } + return sum; + } + private static (double depthIntervalRotor, double depthIntervalSlide) GetDepthInterval (IEnumerable detectedOperations) { var depthIntervalRotor = detectedOperations.Where(o => o.IdCategory == WellOperationCategory.IdRotor) @@ -218,6 +255,16 @@ namespace AsbCloudInfrastructure.Services.Subsystems { depthIntervalSubsystem = depthInterval.depthIntervalRotor + depthInterval.depthIntervalSlide; } + //AKB - Rotor + if (idSubsystem == IdSubsystemAKBRotor) + { + depthIntervalSubsystem = depthInterval.depthIntervalRotor; + } + //AKB - Slide + if (idSubsystem == IdSubsystemAKBSlide) + { + depthIntervalSubsystem = depthInterval.depthIntervalSlide; + } //Spin if (idSubsystem == IdSubsystemSpin) {