From 7872e068ba3d419cdbd52e5fb6308c15e06a0b5f Mon Sep 17 00:00:00 2001 From: Olga Nemt Date: Wed, 9 Oct 2024 10:07:50 +0500 Subject: [PATCH] =?UTF-8?q?=D0=90=D0=B2=D1=82=D0=BE=D1=82=D0=B5=D1=81?= =?UTF-8?q?=D1=82=D1=8B=20(=D0=BF=D1=80=D0=BE=D0=B4=D0=BE=D0=BB=D0=B6?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5)=20+=20=D0=BF=D1=80=D0=B0=D0=B2=D0=BA?= =?UTF-8?q?=D0=B0=20=D0=B1=D1=8D=D0=BA=D0=B0=20=D0=BF=D0=BE=20=D1=80=D0=B5?= =?UTF-8?q?=D0=B7=D1=83=D0=BB=D1=8C=D1=82=D0=B0=D1=82=D0=B0=D0=BC=20=D1=82?= =?UTF-8?q?=D0=B5=D1=81=D1=82=D0=B8=D1=80=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8?= =?UTF-8?q?=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DataSaubStatDtillingQualityServiceTest.cs | 109 +++++++++++++----- .../DataSaubStatDrillingQualityService.cs | 12 +- 2 files changed, 88 insertions(+), 33 deletions(-) diff --git a/AsbCloudInfrastructure.Tests/Services/DataSaubStat/DataSaubStatDtillingQualityServiceTest.cs b/AsbCloudInfrastructure.Tests/Services/DataSaubStat/DataSaubStatDtillingQualityServiceTest.cs index 4a6b876b..ed2b07d0 100644 --- a/AsbCloudInfrastructure.Tests/Services/DataSaubStat/DataSaubStatDtillingQualityServiceTest.cs +++ b/AsbCloudInfrastructure.Tests/Services/DataSaubStat/DataSaubStatDtillingQualityServiceTest.cs @@ -58,27 +58,13 @@ public class DataSaubStatDtillingQualityServiceTest }, }; - private List detectedOperationDtos = new List() { - new DetectedOperationDto { - Id = 1, - DateEnd = DateTimeOffset.UtcNow, - DateStart = DateTimeOffset.UtcNow.AddHours(-1), - DepthStart = 1, - DepthEnd = 2, - IdCategory = 5002, - IdTelemetry = 1, - Value = 1, - IdEditor = 1, - IdUserAtStart = 1 - } - }; private List telemetryDataSaubDtos = new List { new TelemetryDataSaubDto() { IdTelemetry = 1, DateTime = DateTime.UtcNow.AddMinutes(-30), - AxialLoad = 1, + AxialLoad = 800, AxialLoadLimitMax = 1, AxialLoadSp = 1, BitDepth = 1, @@ -117,7 +103,7 @@ public class DataSaubStatDtillingQualityServiceTest RotorTorqueIdle = 1, RotorTorqueSp = 1, RotorTorqueLimitMax = 1, - WellDepth = 10, + WellDepth = 800, } }; @@ -134,24 +120,81 @@ public class DataSaubStatDtillingQualityServiceTest var telemetrySaubDto = telemetryDataSaubDtos.FirstOrDefault(); if (telemetrySaubDto != null) { - var telemetrySaubDto1 = CreateTelemetryDataSaubItem(telemetrySaubDto, 1, 1); + //idFeedRegulator depthWell + //1 800 + //1 900 + //1 1000 + //1 900 + //1 1200 + //1 1300 + //1 1100 + //1 1500 + //2 1600 + //Ожидаемые результаты для idFeedRegulator: + // depthWell = (1000 - 800) + (1300 - 900) + (1600 - 1100) = + var telemetrySaubDto1 = CreateTelemetryDataSaubItem( + telemetrySaubDto, + wellDepth: 900, + bitDepth: 900, + idFeedRegulator: 1, + dateTime: DateTime.UtcNow.AddMinutes(20)); telemetryDataSaubDtos.Add(telemetrySaubDto1); - var telemetrySaubDto2 = telemetrySaubDto.Adapt(); - telemetrySaubDto2.WellDepth = 2; - telemetrySaubDto2.BitDepth = 2; - telemetrySaubDto2.IdFeedRegulator = 1; - telemetrySaubDto2.DateTime = telemetrySaubDto1.DateTime.AddMinutes(20); + var telemetrySaubDto2 = CreateTelemetryDataSaubItem( + telemetrySaubDto, + wellDepth: 1000, + bitDepth: 1000, + idFeedRegulator: 1, + dateTime: DateTime.UtcNow.AddMinutes(20)); telemetryDataSaubDtos.Add(telemetrySaubDto2); - var telemetrySaubDto3 = telemetrySaubDto.Adapt(); - telemetrySaubDto3.WellDepth = 2; - telemetrySaubDto3.BitDepth = 2; - telemetrySaubDto3.IdFeedRegulator = 1; - telemetrySaubDto3.DateTime = telemetrySaubDto2.DateTime.AddMinutes(20); + var telemetrySaubDto3 = CreateTelemetryDataSaubItem( + telemetrySaubDto, + wellDepth: 900, + bitDepth: 900, + idFeedRegulator: 1, + dateTime: DateTime.UtcNow.AddMinutes(20)); telemetryDataSaubDtos.Add(telemetrySaubDto3); - + var telemetrySaubDto4 = CreateTelemetryDataSaubItem( + telemetrySaubDto, + wellDepth: 1200, + bitDepth: 1200, + idFeedRegulator: 1, + dateTime: DateTime.UtcNow.AddMinutes(20)); + telemetryDataSaubDtos.Add(telemetrySaubDto4); + + var telemetrySaubDto5 = CreateTelemetryDataSaubItem( + telemetrySaubDto, + wellDepth: 1300, + bitDepth: 1300, + idFeedRegulator: 1, + dateTime: DateTime.UtcNow.AddMinutes(20)); + telemetryDataSaubDtos.Add(telemetrySaubDto5); + + var telemetrySaubDto6 = CreateTelemetryDataSaubItem( + telemetrySaubDto, + wellDepth: 1100, + bitDepth: 1100, + idFeedRegulator: 1, + dateTime: DateTime.UtcNow.AddMinutes(20)); + telemetryDataSaubDtos.Add(telemetrySaubDto6); + + var telemetrySaubDto7 = CreateTelemetryDataSaubItem( + telemetrySaubDto, + wellDepth: 1500, + bitDepth: 1500, + idFeedRegulator: 1, + dateTime: DateTime.UtcNow.AddMinutes(20)); + telemetryDataSaubDtos.Add(telemetrySaubDto7); + + var telemetrySaubDto8 = CreateTelemetryDataSaubItem( + telemetrySaubDto, + wellDepth: 1600, + bitDepth: 1600, + idFeedRegulator: 2, + dateTime: DateTime.UtcNow.AddMinutes(20)); + telemetryDataSaubDtos.Add(telemetrySaubDto8); } dataSaubServiceMock @@ -167,13 +210,15 @@ public class DataSaubStatDtillingQualityServiceTest private TelemetryDataSaubDto CreateTelemetryDataSaubItem( TelemetryDataSaubDto telemetrySaubDto, float wellDepth, - float bitDepth) + float bitDepth, + short idFeedRegulator, + DateTime dateTime) { var telemetrySaubDto1 = telemetrySaubDto.Adapt(); telemetrySaubDto1.WellDepth = wellDepth; telemetrySaubDto1.BitDepth = bitDepth; - telemetrySaubDto1.IdFeedRegulator = 1; - telemetrySaubDto1.DateTime = DateTime.UtcNow.AddMinutes(20); + telemetrySaubDto1.IdFeedRegulator = idFeedRegulator; + telemetrySaubDto1.DateTime = dateTime; return telemetrySaubDto1; } @@ -181,7 +226,7 @@ public class DataSaubStatDtillingQualityServiceTest [Fact] public async Task Create_1DataSaubStatItems_ShouldReturn__Success() { - var insertedDataSaubStatCount = 1; + var insertedDataSaubStatCount = 2; diff --git a/AsbCloudInfrastructure/Services/DataSaubStatDrillingQualityService.cs b/AsbCloudInfrastructure/Services/DataSaubStatDrillingQualityService.cs index b51c69d6..41c4adee 100644 --- a/AsbCloudInfrastructure/Services/DataSaubStatDrillingQualityService.cs +++ b/AsbCloudInfrastructure/Services/DataSaubStatDrillingQualityService.cs @@ -120,7 +120,17 @@ public class DataSaubStatDrillingQualityService : IDataSaubStatDrillingQualitySe if (indexStart < 0) break; - indexEnd = Array.FindIndex(dataSaub, indexStart, t => t.IdFeedRegulator != idFeedRegulator); + indexEnd = indexStart + 1; + for (var i = indexStart + 1; i < dataSaub.Count(); i++) + { + if (dataSaub[i].WellDepth >= dataSaub[i - 1].WellDepth) + indexEnd = i; + else if (dataSaub[i].IdFeedRegulator != idFeedRegulator) + break; + else + break; + + } if (indexEnd < 0) indexEnd = dataSaub.Length - 1;