From edb7d93a624477b32d50f044245eb0799eb1e4c3 Mon Sep 17 00:00:00 2001 From: Olga Nemt Date: Wed, 16 Oct 2024 18:02:38 +0500 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D1=80=D0=B0=D0=B1=D0=BE=D1=82?= =?UTF-8?q?=D0=B0=D0=BD=D1=8B=20=D0=B0=D0=B2=D1=82=D0=BE=D1=82=D0=B5=D1=81?= =?UTF-8?q?=D1=82=D1=8B=20+=20=D0=9C=D0=B5=D1=82=D0=BE=D0=B4,=20=D0=BA?= =?UTF-8?q?=D0=BE=D1=82=D0=BE=D1=80=D1=8B=D0=B9=20=D0=BE=D1=82=D0=B4=D0=B0?= =?UTF-8?q?=D0=B5=D1=82=20=D0=BD=D0=B0=20=D1=84=D1=80=D0=BE=D0=BD=D1=82=20?= =?UTF-8?q?=D0=B4=D0=B0=D0=BD=D0=BD=D1=8B=D0=B5=20=D0=BE=20=D0=BA=D0=B0?= =?UTF-8?q?=D1=87=D0=B5=D1=81=D1=82=D0=B2=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Repositories/IDataSaubStatRepository.cs | 6 +- .../Requests/DrillingQualityRequest.cs | 27 ++++++ .../IDataSaubStatDrillingQualityService.cs | 8 ++ .../AsbCloudInfrastructure.Tests.csproj | 8 ++ .../DataSaubStatDrillingQualityDtoMap.cs | 26 +++--- .../MapData/TelemetryDataSaubMap.cs | 87 +++++++++---------- .../DataSaubStatDtillingQualityServiceTest.cs | 47 +++++++--- .../Services/DataSaubStat/test1.csv | 33 ++++--- .../Services/DataSaubStat/test2.csv | 32 +++++++ .../Services/DataSaubStat/test2_result.csv | 8 ++ .../Services/DataSaubStat/test3.csv | 33 +++++++ .../Services/DataSaubStat/test3_result.csv | 10 +++ .../Repository/DataSaubStatRepository.cs | 17 +++- .../DataSaubStatDrillingQualityService.cs | 74 ++++++++++++---- .../Report/ProcessMapReportDrillingService.cs | 2 +- .../Controllers/ServiceOperationController.cs | 59 +++++++++++++ 16 files changed, 370 insertions(+), 107 deletions(-) create mode 100644 AsbCloudApp/Requests/DrillingQualityRequest.cs create mode 100644 AsbCloudInfrastructure.Tests/Services/DataSaubStat/test2.csv create mode 100644 AsbCloudInfrastructure.Tests/Services/DataSaubStat/test2_result.csv create mode 100644 AsbCloudInfrastructure.Tests/Services/DataSaubStat/test3.csv create mode 100644 AsbCloudInfrastructure.Tests/Services/DataSaubStat/test3_result.csv create mode 100644 AsbCloudWebApi/Controllers/ServiceOperationController.cs diff --git a/AsbCloudApp/Repositories/IDataSaubStatRepository.cs b/AsbCloudApp/Repositories/IDataSaubStatRepository.cs index edda1fab..d3f6fab8 100644 --- a/AsbCloudApp/Repositories/IDataSaubStatRepository.cs +++ b/AsbCloudApp/Repositories/IDataSaubStatRepository.cs @@ -14,14 +14,14 @@ public interface IDataSaubStatRepository : ITelemetryDataEditorService where TDto : IDataSaubStatDto { /// - /// Получение записей по ключу телеметрии + /// Получение записей по ключам телеметрий /// - /// ключ телеметрии + /// ключи телеметрий /// начальная дата /// конечная дата /// /// - Task> GetAsync(int idTelemetry, DateTimeOffset geDate, DateTimeOffset leDate, CancellationToken token); + Task> GetAsync(IEnumerable idsTelemetries, DateTimeOffset geDate, DateTimeOffset leDate, CancellationToken token); /// /// Получение последних по дате окончания бурения записей в разрезе телеметрий diff --git a/AsbCloudApp/Requests/DrillingQualityRequest.cs b/AsbCloudApp/Requests/DrillingQualityRequest.cs new file mode 100644 index 00000000..8d8d17e8 --- /dev/null +++ b/AsbCloudApp/Requests/DrillingQualityRequest.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; + +namespace AsbCloudApp.Requests; + +/// +/// Запрос на получение записей качества бурения +/// +public class DrillingQualityRequest +{ + /// + /// идентификаторы скважин + /// + [Required] + public IEnumerable IdsWell { get; set; } = null!; + + /// + /// Больше или равно дате + /// + public DateTimeOffset GeDate { get; set; } = DateTimeOffset.MinValue; + + /// + /// Меньше или равно дате + /// + public DateTimeOffset LeDate { get; set; } = DateTimeOffset.MaxValue; +} diff --git a/AsbCloudApp/Services/DataSaubStat/IDataSaubStatDrillingQualityService.cs b/AsbCloudApp/Services/DataSaubStat/IDataSaubStatDrillingQualityService.cs index 8adbfc39..cba74318 100644 --- a/AsbCloudApp/Services/DataSaubStat/IDataSaubStatDrillingQualityService.cs +++ b/AsbCloudApp/Services/DataSaubStat/IDataSaubStatDrillingQualityService.cs @@ -1,4 +1,5 @@ using AsbCloudApp.Data; +using AsbCloudApp.Requests; using System; using System.Collections.Generic; using System.Threading; @@ -34,4 +35,11 @@ public interface IDataSaubStatDrillingQualityService DateTimeOffset geDate, CancellationToken token); + /// + /// Получение записей DrillingQualityDto по параметрам + /// + /// параметры запроса + /// + /// + Task> GetStatAsync(DrillingQualityRequest request, CancellationToken token); } diff --git a/AsbCloudInfrastructure.Tests/AsbCloudInfrastructure.Tests.csproj b/AsbCloudInfrastructure.Tests/AsbCloudInfrastructure.Tests.csproj index 3a1d909a..ae3665cf 100644 --- a/AsbCloudInfrastructure.Tests/AsbCloudInfrastructure.Tests.csproj +++ b/AsbCloudInfrastructure.Tests/AsbCloudInfrastructure.Tests.csproj @@ -9,6 +9,10 @@ + + + + @@ -16,6 +20,10 @@ + + + + diff --git a/AsbCloudInfrastructure.Tests/MapData/DataSaubStatDrillingQualityDtoMap.cs b/AsbCloudInfrastructure.Tests/MapData/DataSaubStatDrillingQualityDtoMap.cs index d6499973..990aa5d2 100644 --- a/AsbCloudInfrastructure.Tests/MapData/DataSaubStatDrillingQualityDtoMap.cs +++ b/AsbCloudInfrastructure.Tests/MapData/DataSaubStatDrillingQualityDtoMap.cs @@ -1,16 +1,22 @@ -using AsbCloudApp.Data; -using CsvHelper.Configuration; +using CsvHelper.Configuration.Attributes; namespace AsbCloudInfrastructure.Tests.MapData { - public class DataSaubStatDrillingQualityDtoMap : ClassMap + public class DataSaubStatDrillingQualityDtoMap { - public DataSaubStatDrillingQualityDtoMap() - { - Map(m => m.IdTelemetry).Name("id_telemetry"); - Map(m => m.DepthStart).Name("depth_start"); - Map(m => m.DepthEnd).Name("depth_end"); - Map(m => m.DepthDrillingQuality).Name("depth_drilling_quality"); - } + [Name("id_telemetry")] + public int IdTelemetry { get; set; } + + [Name("depth_start")] + public float DepthStart { get; set; } + + [Name("depth_end")] + public float DepthEnd { get; set; } + + [Name("depth_drilling_quality")] + public float DepthDrillingQuality { get; set; } + + [Name("id_feed_regulator")] + public short? IdFeedRegulator { get; set; } } } diff --git a/AsbCloudInfrastructure.Tests/MapData/TelemetryDataSaubMap.cs b/AsbCloudInfrastructure.Tests/MapData/TelemetryDataSaubMap.cs index 9b679a55..80d74b44 100644 --- a/AsbCloudInfrastructure.Tests/MapData/TelemetryDataSaubMap.cs +++ b/AsbCloudInfrastructure.Tests/MapData/TelemetryDataSaubMap.cs @@ -1,54 +1,47 @@ -using AsbCloudApp.Data.SAUB; -using CsvHelper.Configuration; +using CsvHelper.Configuration.Attributes; +using System; namespace AsbCloudInfrastructure.Tests.MapData { - public class TelemetryDataSaubMap : ClassMap + public class TelemetryDataSaubMap { - public TelemetryDataSaubMap() - { - Map(m => m.AxialLoad).Name("axial_load"); - Map(m => m.AxialLoadLimitMax).Name("axial_load_limit_max"); - Map(m => m.AxialLoadSp).Name("axial_load_sp"); - Map(m => m.BitDepth).Name("bit_depth"); - Map(m => m.BlockPosition).Name("block_position"); - Map(m => m.BlockPositionMax).Name("block_position_max"); - Map(m => m.BlockPositionMin).Name("block_position_min"); - Map(m => m.BlockSpeed).Name("block_speed"); - Map(m => m.BlockSpeedSp).Name("block_speed_sp"); - Map(m => m.BlockSpeedSpDevelop).Name("block_speed_sp_develop"); - Map(m => m.BlockSpeedSpRotor).Name("block_speed_sp_rotor"); - Map(m => m.BlockSpeedSpSlide).Name("block_speed_sp_slide"); - Map(m => m.DateTime).Name("date"); - Map(m => m.Flow).Name("flow"); - Map(m => m.FlowDeltaLimitMax).Name("flow_delta_limit_max"); - Map(m => m.FlowIdle).Name("flow_idle"); - Map(m => m.HookWeight).Name("hook_weight"); - Map(m => m.HookWeightIdle).Name("hook_weight_idle"); - Map(m => m.HookWeightLimitMax).Name("hook_weight_limit_max"); - Map(m => m.HookWeightLimitMin).Name("hook_weight_limit_min"); - Map(m => m.IdFeedRegulator).Name("id_feed_regulator"); - Map(m => m.IdTelemetry).Name("id_telemetry"); - Map(m => m.Mode).Name("mode"); - Map(m => m.Mse).Name("mse"); - Map(m => m.MseState).Name("mse_state"); - Map(m => m.Pressure).Name("pressure"); - Map(m => m.PressureDeltaLimitMax).Name("pressure_delta_limit_max"); - Map(m => m.PressureIdle).Name("pressure_idle"); - Map(m => m.PressureSp).Name("pressure_sp"); - Map(m => m.PressureSpDevelop).Name("pressure_sp_develop"); - Map(m => m.PressureSpRotor).Name("pressure_sp_rotor"); - Map(m => m.PressureSpSlide).Name("pressure_sp_slide"); - Map(m => m.Pump1Flow).Name("pump1_flow"); - Map(m => m.Pump0Flow).Name("pump0_flow"); - Map(m => m.Pump2Flow).Name("pump2_flow"); - Map(m => m.RotorSpeed).Name("rotor_speed"); - Map(m => m.RotorTorque).Name("rotor_torque"); - Map(m => m.RotorTorqueIdle).Name("rotor_torque_idle"); - Map(m => m.RotorTorqueLimitMax).Name("rotor_torque_limit_max"); - Map(m => m.RotorTorqueSp).Name("rotor_torque_sp"); - Map(m => m.WellDepth).Name("well_depth"); + [Name("id_telemetry")] + public int IdTelemetry { get; set; } - } + [Name("date")] + public DateTime DateTime { get; set; } + + [Name("well_depth")] + public float WellDepth { get; set; } + + [Name("bit_depth")] + public float BitDepth { get; set; } + + [Name("block_speed")] + public float? BlockSpeed { get; set; } + + [Name("block_speed_sp")] + public float? BlockSpeedSp { get; set; } + + [Name("pressure")] + public float Pressure { get; set; } + + [Name("pressure_sp")] + public float? PressureSp { get; set; } + + [Name("axial_load")] + public float AxialLoad { get; set; } + + [Name("axial_load_sp")] + public float? AxialLoadSp { get; set; } + + [Name("rotor_torque")] + public float RotorTorque { get; set; } + + [Name("rotor_torque_sp")] + public float? RotorTorqueSp { get; set; } + + [Name("id_feed_regulator")] + public short? IdFeedRegulator { get; set; } } } diff --git a/AsbCloudInfrastructure.Tests/Services/DataSaubStat/DataSaubStatDtillingQualityServiceTest.cs b/AsbCloudInfrastructure.Tests/Services/DataSaubStat/DataSaubStatDtillingQualityServiceTest.cs index 04fe2b83..0ad9700c 100644 --- a/AsbCloudInfrastructure.Tests/Services/DataSaubStat/DataSaubStatDtillingQualityServiceTest.cs +++ b/AsbCloudInfrastructure.Tests/Services/DataSaubStat/DataSaubStatDtillingQualityServiceTest.cs @@ -5,6 +5,7 @@ using AsbCloudApp.Services; using AsbCloudInfrastructure.Services; using AsbCloudInfrastructure.Tests.MapData; using CsvHelper; +using Mapster; using NSubstitute; using System; using System.Globalization; @@ -22,6 +23,7 @@ public class DataSaubStatDtillingQualityServiceTest private readonly IDataSaubStatRepository dataSaubStatRepositoryMock = Substitute.For>(); private readonly ITelemetryDataCache telemetryDataCacheMock = Substitute.For>(); private readonly ITelemetryDataSaubService dataSaubServiceMock = Substitute.For(); + private readonly ITelemetryService telemetryServiceMock = Substitute.For(); private DataSaubStatDrillingQualityService dataSaubStatService; @@ -30,11 +32,14 @@ public class DataSaubStatDtillingQualityServiceTest dataSaubStatService = new DataSaubStatDrillingQualityService( dataSaubStatRepositoryMock, telemetryDataCacheMock, - dataSaubServiceMock); + dataSaubServiceMock, + telemetryServiceMock); } [Theory] - [InlineData("DataSaubStat.test1.csv", "DataSaubStat.test1_result.csv")] + [InlineData("DataSaubStat.test3.csv", "DataSaubStat.test3_result.csv")] + [InlineData("DataSaubStat.test2.csv", "DataSaubStat.test2_result.csv")] + //[InlineData("DataSaubStat.test1.csv", "DataSaubStat.test1_result.csv")] public async Task Create_DataSaubStatDrillingQuality_From_CSVFile_ShouldReturn_Success( string pathMockData, string pathResult @@ -51,20 +56,21 @@ public class DataSaubStatDtillingQualityServiceTest using var stream = Assembly.GetExecutingAssembly() .GetManifestResourceStream(resourceName)!; - var actual = Enumerable.Empty(); + var actualData = Enumerable.Empty(); using (var reader = new StreamReader(stream)) using (var csv = new CsvReader(reader, CultureInfo.InvariantCulture)) { - csv.Context.RegisterClassMap(); - var records = csv.GetRecords().ToList(); + var dataSaubMaps = csv.GetRecords().ToList(); + + var dtos = dataSaubMaps.Select(x => x.Adapt()).ToArray(); dataSaubServiceMock .Get(Arg.Any(), Arg.Any(), Arg.Any(), Arg.Any(), Arg.Any(), Arg.Any()) - .Returns(records); + .Returns(dtos); //act - actual = await dataSaubStatService.CreateStatDrillingQualityForTelemetry(1, DateTimeOffset.UnixEpoch, CancellationToken.None); + actualData = await dataSaubStatService.CreateStatDrillingQualityForTelemetry(1, DateTimeOffset.UnixEpoch, CancellationToken.None); } resourceName = Assembly.GetExecutingAssembly() @@ -81,18 +87,31 @@ public class DataSaubStatDtillingQualityServiceTest using (var reader = new StreamReader(stream2)) using (var csv = new CsvReader(reader, CultureInfo.InvariantCulture)) { - csv.Context.RegisterClassMap(); - var expected = csv.GetRecords().ToList(); + var dataSaubMaps = csv.GetRecords().ToList(); + var expectedData = dataSaubMaps.Select(x => x.Adapt()).ToArray(); //assert + var actual = actualData + .OrderBy(d => d.IdFeedRegulator) + .ToArray(); + + var expected = expectedData + .OrderBy(d => d.IdFeedRegulator) + .ToArray(); + Assert.Equal(expected.Count(), actual.Count()); - var expectedItem = expected.FirstOrDefault()!; - var actualItem = actual.FirstOrDefault()!; + for (var i = 0; i < actual.Count(); i++) + { + var expectedItem = expected[i]; + var actualItem = actual[i]; + + Assert.True(Math.Abs(expectedItem.DepthStart - actualItem.DepthStart) < 0.000001); + Assert.True(Math.Abs(expectedItem.DepthEnd - actualItem.DepthEnd) < 0.000001); + Assert.True(Math.Abs(expectedItem.DepthDrillingQuality - actualItem.DepthDrillingQuality) < 0.000001); + } + - Assert.True(Math.Abs(expectedItem.DepthStart - actualItem.DepthStart) < 0.000001); - Assert.True(Math.Abs(expectedItem.DepthEnd - actualItem.DepthEnd) < 0.000001); - Assert.True(Math.Abs(expectedItem.DepthDrillingQuality - actualItem.DepthDrillingQuality) < 0.000001); } } } diff --git a/AsbCloudInfrastructure.Tests/Services/DataSaubStat/test1.csv b/AsbCloudInfrastructure.Tests/Services/DataSaubStat/test1.csv index 2b765dd9..406f23f8 100644 --- a/AsbCloudInfrastructure.Tests/Services/DataSaubStat/test1.csv +++ b/AsbCloudInfrastructure.Tests/Services/DataSaubStat/test1.csv @@ -1,12 +1,21 @@ -"id_telemetry","date","mode","id_user","well_depth","bit_depth","block_position","block_position_min","block_position_max","block_speed","block_speed_sp","block_speed_sp_rotor","block_speed_sp_slide","block_speed_sp_develop","pressure","pressure_idle","pressure_sp","pressure_sp_rotor","pressure_sp_slide","pressure_sp_develop","pressure_delta_limit_max","axial_load","axial_load_sp","axial_load_limit_max","hook_weight","hook_weight_idle","hook_weight_limit_min","hook_weight_limit_max","rotor_torque","rotor_torque_idle","rotor_torque_sp","rotor_torque_limit_max","rotor_speed","flow","flow_idle","flow_delta_limit_max","id_feed_regulator","mse_state","mse","pump0_flow","pump1_flow","pump2_flow" -419,2023-02-24 06:52:03.000 +0500,1,1,46.0,46.0,18.561,0.0,0.0,0,100.0,100.0,50.0,100.0,3.2787943,3.0,35.0,35.0,21.0,18.0,45.0,0.0,4.0,4.5,25.296837,25.0,0.0,0.0,0.9,0.0,24.0,28.0,20.1,0.0,0.0,3.0,1,0,0.62367916,,, -419,2023-02-24 06:52:27.000 +0500,1,1,46.0,46.0,18.561,0.0,0.0,0.0,100.0,100.0,50.0,100.0,3.2657084,3.0,35.0,35.0,21.0,18.0,45.0,0.0,4.0,4.5,25.288881,25.0,0.0,0.0,0.7005794,0.0,24.0,28.0,20.1,0.0,0.0,3.0,1,0,0.58552027,,, -419,2023-02-24 06:52:01.000 +0500,1,1,46.0,46.0,18.561,0.0,0.0,0,100.0,100.0,50.0,100.0,3.281889,3.0,35.0,35.0,21.0,18.0,45.0,0.0,4.0,4.5,25.290037,25.0,0.0,0.0,1.1,0.0,24.0,28.0,20.0,0.0,0.0,3.0,1,0,0.6230831,,, -419,2023-02-24 06:52:02.000 +0500,1,1,46.0,46.0,18.561,0.0,0.0,0,100.0,100.0,50.0,100.0,3.2758698,3.0,35.0,35.0,21.0,18.0,45.0,0.0,4.0,4.5,25.298437,25.0,0.0,0.0,0.8,0.0,24.0,28.0,20.1,0.0,0.0,3.0,1,0,0.61103106,,, -419,2023-02-24 06:52:04.000 +0500,0,1,46.0,46.0,18.561,0.0,0.0,0,100.0,100.0,50.0,100.0,3.2403529,3.0,35.0,35.0,21.0,18.0,45.0,0.0,4.0,4.5,25.283327,25.0,0.0,0.0,0.99897236,0.0,24.0,28.0,20.1,0.0,0.0,3.0,1,0,0.5451977,,, -419,2023-02-24 06:52:28.000 +0500,1,1,46.0,46.0,18.561,0.0,0.0,0.0,100.0,100.0,50.0,100.0,3.2521386,3.0,35.0,35.0,21.0,18.0,45.0,0.0,4.0,4.5,25.271387,25.0,0.0,0.0,0.9986298,0.0,24.0,28.0,20.1,0.0,0.0,3.0,1,0,0.5644083,,, -419,2023-02-24 06:52:29.000 +0500,0,1,46.0,46.0,18.559,0.0,0.0,0.0,100.0,100.0,50.0,100.0,3.2965276,3.0,35.0,35.0,21.0,18.0,45.0,0.0,4.0,4.5,25.279978,25.0,0.0,0.0,0.7880506,0.0,24.0,28.0,20.1,0.0,0.0,3.0,1,0,0.6650865,,, -419,2023-02-24 06:52:49.000 +0500,1,1,46.0,46.0,18.347,0.0,0.0,0.02323297,100.0,100.0,50.0,100.0,3.3215039,3.0,35.0,35.0,21.0,18.0,45.0,0.0,4.0,4.5,25.196453,25.0,0.0,0.0,0.8,0.0,24.0,28.0,20.1,0.0,0.0,3.0,1,0,0.7197559,,, -419,2023-02-24 06:52:50.000 +0500,1,1,46.0,46.0,18.347,0.0,0.0,0.008542753,100.0,100.0,50.0,100.0,3.2545505,3.0,35.0,35.0,21.0,18.0,45.0,0.0,4.0,4.5,25.18471,25.0,0.0,0.0,0.8,0.0,24.0,28.0,20.1,0.0,0.0,3.0,1,0,0.5640507,,, -419,2023-02-24 06:52:53.000 +0500,1,1,46.0,46.0,18.207,0.0,0.0,11.310025,100.0,100.0,50.0,100.0,3.271237,3.0,35.0,35.0,21.0,18.0,45.0,0.0,4.0,4.5,25.770308,25.0,0.0,0.0,0.99922925,0.0,24.0,28.0,20.1,0.0,0.0,3.0,1,0,0.60237646,,, -419,2023-02-24 15:29:12.000 +0500,1,1,251.28,251.28,11.062,0.5,0.0,52.383633,53.0,53.0,50.0,50.0,46.114864,32.0,68.0,68.0,50.0,47.0,45.0,0.5221672,8.0,11.0,28.4907,29.0,0.0,0.0,5.401707,0.0,24.0,28.0,19.8,0.0,0.0,3.0,1,0,26.786428,,, +"id_telemetry","date","well_depth","bit_depth","block_speed","block_speed_sp","pressure","pressure_sp","axial_load","axial_load_sp","rotor_torque","rotor_torque_sp","id_feed_regulator" +618,2023-02-24 06:52:03.000 +0500,303.545989990234,64.1760025024414,45.00,50.00,3.71015930175781,52.00,2.8034496307373,8.00,0.00,23.00,1 +618,2023-02-24 06:52:03.000 +0500,313.545989990234,63.5940017700195,46.00,50.00,3.69481015205383,52.00,2.04865455627441,8.00,0.00,23.00,1 +618,2023-02-24 06:52:03.000 +0500,323.545989990234,63.0130004882813,47.00,50.00,3.7329523563385,52.00,2.90703392028809,8.00,0.00,23.00,1 +618,2023-02-24 06:52:03.000 +0500,333.545989990234,62.4309997558594,48.00,50.00,3.70306921005249,52.00,2.17815017700195,8.00,0.00,23.00,1 +618,2023-02-24 06:52:03.000 +0500,343.545989990234,61.8499984741211,49.00,50.00,3.69618034362793,52.00,2.45234489440918,8.00,0.00,23.00,1 +618,2023-02-24 06:52:03.000 +0500,353.545989990234,61.2560005187988,50.00,50.00,3.72630000114441,52.00,3.2121467590332,8.00,0.00,23.00,1 +618,2023-02-24 06:52:03.000 +0500,363.545989990234,60.6679992675781,51.00,50.00,3.70950126647949,52.00,2.8408260345459,8.00,0.00,23.00,1 +618,2023-02-24 06:52:03.000 +0500,373.545989990234,60.0870018005371,52.00,50.00,3.73658561706543,52.00,1.16445922851563,8.00,0.00,23.00,1 +618,2023-02-24 06:52:03.000 +0500,383.545989990234,59.4939994812012,53.00,50.00,3.68171286582947,52.00,2.30134773254395,8.00,0.00,23.00,1 +618,2023-02-24 06:52:03.000 +0500,393.545989990234,58.9070014953613,54.00,50.00,3.72104644775391,52.00,1.91220664978027,8.00,0.00,23.00,1 +618,2023-02-24 06:52:03.000 +0500,403.545989990234,58.3199996948242,55.00,50.00,3.75041079521179,52.00,1.29618453979492,8.00,0.00,23.00,1 +618,2023-02-24 06:52:03.000 +0500,413.545989990234,57.7270011901856,56.00,50.00,3.71274995803833,52.00,2.0904655456543,8.00,0.00,23.00,1 +618,2023-02-24 06:52:03.000 +0500,423.545989990234,57.1389999389648,57.00,50.00,3.73990893363953,52.00,2.42434310913086,8.00,0.00,23.00,1 +618,2023-02-24 06:52:03.000 +0500,433.545989990234,56.5460014343262,58.00,50.00,3.7690634727478,52.00,2.07949066162109,8.00,0.00,23.00,1 +618,2023-02-24 06:52:03.000 +0500,443.545989990234,55.9589996337891,59.00,50.00,3.7951807975769,52.00,1.98602676391602,8.00,0.00,23.00,1 +618,2023-02-24 06:52:03.000 +0500,453.545989990234,55.3660011291504,60.00,50.00,3.84931874275208,52.00,2.41486930847168,8.00,0.00,23.00,1 +618,2023-02-24 06:52:03.000 +0500,463.545989990234,54.7719993591309,61.00,50.00,3.91031193733215,52.00,2.98539924621582,8.00,0.00,23.00,1 +618,2023-02-24 06:52:03.000 +0500,473.545989990234,54.1790008544922,62.00,50.00,3.95907807350159,52.00,2.65116500854492,8.00,0.00,23.00,1 +618,2023-02-24 06:52:03.000 +0500,483.545989990234,53.5919990539551,63.00,50.00,3.98743534088135,52.00,1.92432594299316,8.00,0.00,23.00,1 +618,2023-02-24 06:52:03.000 +0500,493.545989990234,53.0050010681152,64.00,50.00,4.02055215835571,52.00,2.56299781799316,8.00,0.00,23.00,1 diff --git a/AsbCloudInfrastructure.Tests/Services/DataSaubStat/test2.csv b/AsbCloudInfrastructure.Tests/Services/DataSaubStat/test2.csv new file mode 100644 index 00000000..cf5aa8b8 --- /dev/null +++ b/AsbCloudInfrastructure.Tests/Services/DataSaubStat/test2.csv @@ -0,0 +1,32 @@ +"id_telemetry","date","well_depth","bit_depth","block_speed","block_speed_sp","pressure","pressure_sp","axial_load","axial_load_sp","rotor_torque","rotor_torque_sp","id_feed_regulator" +618,2023-02-24 06:52:03.000 +0500,205.00,204.00,100.00,80.00,80.00,105.00,0.00,10.00,10.00,13.00,1 +618,2023-02-24 06:52:03.000 +0500,205.00,204.99,90.00,80.00,70.00,105.00,0.00,10.00,10.00,13.00,0 +618,2023-02-24 06:52:03.000 +0500,205.00,205.00,80.00,80.00,150.00,105.00,3.00,10.00,10.00,13.00,1 +618,2023-02-24 06:52:03.000 +0500,207.00,207.00,70.00,80.00,57.00,105.00,4.00,10.00,10.00,13.00,1 +618,2023-02-24 06:52:03.000 +0500,210.00,210.00,78.00,80.00,62.00,105.00,8.00,10.00,10.00,13.00,1 +618,2023-02-24 06:52:03.000 +0500,210.00,209.00,82.00,80.00,93.00,105.00,0.00,10.00,10.00,13.00,0 +618,2023-02-24 06:52:03.000 +0500,210.00,209.77,81.00,80.00,32.00,105.00,0.30,10.00,10.00,13.00,1 +618,2023-02-24 06:52:03.000 +0500,210.00,210.00,90.00,80.00,66.00,70.00,7.00,10.00,11.00,13.00,2 +618,2023-02-24 06:52:03.000 +0500,213.00,213.00,90.00,80.00,33.00,70.00,6.00,10.00,12.00,13.00,2 +618,2023-02-24 06:52:03.000 +0500,216.00,216.00,30.00,80.00,74.00,70.00,5.00,10.00,12.00,13.00,2 +618,2023-02-24 06:52:03.000 +0500,219.00,219.00,5.00,80.00,35.00,70.00,7.00,10.00,12.50,13.00,4 +618,2023-02-24 06:52:03.000 +0500,222.00,222.00,90.00,80.00,99.00,70.00,2.00,10.00,13.60,13.00,4 +618,2023-02-24 06:52:03.000 +0500,222.00,221.00,33.00,80.00,20.00,70.00,0.00,10.00,13.00,13.00,4 +618,2023-02-24 06:52:03.000 +0500,222.00,222.00,100.00,100.00,96.00,70.00,4.00,10.00,12.00,13.00,1 +618,2023-02-24 06:52:03.000 +0500,225.00,225.00,106.00,100.00,78.00,70.00,5.00,10.00,11.00,13.00,1 +618,2023-02-24 06:52:03.000 +0500,228.00,228.00,102.00,100.00,77.00,70.00,6.00,10.00,12.00,13.00,1 +618,2023-02-24 06:52:03.000 +0500,231.00,231.00,98.00,100.00,85.00,70.00,8.00,12.00,11.00,13.00,1 +618,2023-02-24 06:52:03.000 +0500,234.00,234.00,200.00,100.00,32.00,70.00,5.00,12.00,10.00,15.00,0 +618,2023-02-24 06:52:03.000 +0500,237.00,237.00,200.00,100.00,88.00,70.00,9.00,12.00,10.00,15.00,0 +618,2023-02-24 06:52:03.000 +0500,240.00,240.00,94.00,100.00,63.00,70.00,6.00,12.00,11.00,15.00,1 +618,2023-02-24 06:52:03.000 +0500,240.00,233.00,96.00,100.00,66.00,70.00,0.00,12.00,10.00,15.00,1 +618,2023-02-24 06:52:03.000 +0500,240.00,240.00,82.00,80.00,92.00,105.00,0.50,12.00,11.00,15.00,1 +618,2023-02-24 06:52:03.000 +0500,243.00,243.00,12.00,80.00,100.00,105.00,11.50,12.00,12.00,15.00,3 +618,2023-02-24 06:52:03.000 +0500,246.00,246.00,15.00,80.00,92.00,105.00,11.00,12.00,11.00,15.00,3 +618,2023-02-24 06:52:03.000 +0500,249.00,249.00,36.00,80.00,90.00,105.00,12.00,12.00,14.00,15.00,3 +618,2023-02-24 06:52:03.000 +0500,252.00,252.00,55.00,80.00,60.00,105.00,12.50,12.00,13.00,15.00,3 +618,2023-02-24 06:52:03.000 +0500,255.00,255.00,78.00,80.00,90.00,105.00,12.00,12.00,14.00,15.00,3 +618,2023-02-24 06:52:03.000 +0500,258.00,258.00,33.00,80.00,80.00,105.00,10.00,12.00,14.70,15.00,4 +618,2023-02-24 06:52:03.000 +0500,261.00,261.00,54.00,80.00,70.00,105.00,10.00,12.00,18.00,15.00,4 +618,2023-02-24 06:52:03.000 +0500,262.00,262.00,55.00,80.00,90.00,105.00,10.00,12.00,13.00,15.00,0 +618,2023-02-24 06:52:03.000 +0500,262.00,261.00,57.00,80.00,90.00,105.00,0.00,12.00,10.00,15.00,0 diff --git a/AsbCloudInfrastructure.Tests/Services/DataSaubStat/test2_result.csv b/AsbCloudInfrastructure.Tests/Services/DataSaubStat/test2_result.csv new file mode 100644 index 00000000..7e1057af --- /dev/null +++ b/AsbCloudInfrastructure.Tests/Services/DataSaubStat/test2_result.csv @@ -0,0 +1,8 @@ +"id_telemetry","depth_start","depth_end","id_feed_regulator","depth_drilling_quality" +618,205.00,210.00,1,2.00 +618,210.00,219.00,2,6.00 +618,219.00,222.00,4,3.00 +618,222.00,234.00,1,9.00 +618,240.00,243.00,1,3.00 +618,243.00,258.00,3,12.00 +618,258.00,262.00,4,3.00 diff --git a/AsbCloudInfrastructure.Tests/Services/DataSaubStat/test3.csv b/AsbCloudInfrastructure.Tests/Services/DataSaubStat/test3.csv new file mode 100644 index 00000000..83f053c2 --- /dev/null +++ b/AsbCloudInfrastructure.Tests/Services/DataSaubStat/test3.csv @@ -0,0 +1,33 @@ +"id_telemetry","date","well_depth","bit_depth","block_speed","block_speed_sp","pressure","pressure_sp","axial_load","axial_load_sp","rotor_torque","rotor_torque_sp","id_feed_regulator" +618,2023-02-24 06:52:03.000 +0500,326.00,325.00,100.00,80.00,80.00,105.00,0.00,10.00,10.00,13.00,0 +618,2023-02-24 06:52:03.000 +0500,326.00,325.99,90.00,80.00,70.00,105.00,0.00,10.00,10.00,13.00,0 +618,2023-02-24 06:52:03.000 +0500,326.00,326.00,87.00,90.00,150.00,105.00,3.00,10.00,10.00,13.00,1 +618,2023-02-24 06:52:03.000 +0500,328.00,328.00,70.00,80.00,57.00,105.00,4.00,10.00,10.00,13.00,1 +618,2023-02-24 06:52:03.000 +0500,331.00,331.00,92.00,90.00,62.00,105.00,8.00,10.00,10.00,13.00,1 +618,2023-02-24 06:52:03.000 +0500,331.00,330.00,82.00,80.00,93.00,105.00,0.00,10.00,10.00,13.00,0 +618,2023-02-24 06:52:03.000 +0500,331.00,330.77,81.00,80.00,32.00,105.00,9.90,10.00,10.00,13.00,3 +618,2023-02-24 06:52:03.000 +0500,331.00,331.00,90.00,80.00,66.00,70.00,7.00,10.00,11.00,13.00,3 +618,2023-02-24 06:52:03.000 +0500,334.00,334.00,90.00,80.00,33.00,70.00,10.30,10.00,12.00,13.00,3 +618,2023-02-24 06:52:03.000 +0500,337.00,337.00,79.00,80.00,74.00,70.00,5.00,10.00,12.00,13.00,1 +618,2023-02-24 06:52:03.000 +0500,340.00,340.00,83.00,80.00,35.00,70.00,7.00,10.00,12.50,13.00,1 +618,2023-02-24 06:52:03.000 +0500,343.00,343.00,90.00,80.00,99.00,70.00,2.00,10.00,13.60,13.00,2 +618,2023-02-24 06:52:03.000 +0500,343.00,342.00,33.00,80.00,20.00,70.00,0.00,10.00,13.00,13.00,2 +618,2023-02-24 06:52:03.000 +0500,343.00,343.00,100.00,100.00,96.00,70.00,4.00,10.00,12.00,13.00,1 +618,2023-02-24 06:52:03.000 +0500,346.00,346.00,106.00,100.00,78.00,70.00,5.00,10.00,11.00,13.00,1 +618,2023-02-24 06:52:03.000 +0500,349.00,349.00,102.00,100.00,77.00,70.00,6.00,10.00,12.00,13.00,1 +618,2023-02-24 06:52:03.000 +0500,352.00,352.00,98.00,100.00,85.00,70.00,8.00,12.00,11.00,13.00,1 +618,2023-02-24 06:52:03.000 +0500,355.00,355.00,200.00,100.00,69.00,70.00,5.00,12.00,10.00,15.00,2 +618,2023-02-24 06:52:03.000 +0500,358.00,358.00,200.00,100.00,72.00,70.00,9.00,12.00,10.00,15.00,2 +618,2023-02-24 06:52:03.000 +0500,361.00,361.00,94.00,100.00,63.00,70.00,6.00,12.00,11.00,15.00,4 +618,2023-02-24 06:52:03.000 +0500,361.00,354.00,96.00,100.00,66.00,70.00,0.00,12.00,15.00,15.00,4 +618,2023-02-24 06:52:03.000 +0500,361.00,361.00,82.00,80.00,92.00,105.00,0.50,12.00,15.20,15.00,4 +618,2023-02-24 06:52:03.000 +0500,364.00,364.00,12.00,80.00,100.00,105.00,11.50,12.00,14.50,15.00,4 +618,2023-02-24 06:52:03.000 +0500,367.00,367.00,15.00,80.00,92.00,105.00,11.00,12.00,11.00,15.00,4 +618,2023-02-24 06:52:03.000 +0500,370.00,370.00,81.00,80.00,90.00,105.00,12.00,12.00,14.00,15.00,1 +618,2023-02-24 06:52:03.000 +0500,373.00,373.00,55.00,80.00,60.00,105.00,12.50,12.00,13.00,15.00,3 +618,2023-02-24 06:52:03.000 +0500,376.00,376.00,78.00,80.00,90.00,105.00,12.00,12.00,14.00,15.00,3 +618,2023-02-24 06:52:03.000 +0500,379.00,379.00,33.00,80.00,80.00,105.00,10.00,12.00,14.70,15.00,4 +618,2023-02-24 06:52:03.000 +0500,382.00,382.00,54.00,80.00,70.00,105.00,10.00,12.00,18.00,15.00,4 +618,2023-02-24 06:52:03.000 +0500,383.00,383.00,55.00,80.00,90.00,105.00,10.00,12.00,13.00,15.00,0 +618,2023-02-24 06:52:03.000 +0500,383.00,382.00,57.00,80.00,90.00,105.00,0.00,12.00,10.00,15.00,0 + diff --git a/AsbCloudInfrastructure.Tests/Services/DataSaubStat/test3_result.csv b/AsbCloudInfrastructure.Tests/Services/DataSaubStat/test3_result.csv new file mode 100644 index 00000000..3627439e --- /dev/null +++ b/AsbCloudInfrastructure.Tests/Services/DataSaubStat/test3_result.csv @@ -0,0 +1,10 @@ +"id_telemetry","depth_start","depth_end","id_feed_regulator","depth_drilling_quality" +618,326.00,331.00,1,2.00 +618,331.00,337.00,3,3.00 +618,337.00,343.00,1,6.00 +618,343.00,355.00,1,9.00 +618,355.00,361.00,2,6.00 +618,361.00,370.00,4,6.00 +618,370.00,373.00,1,3.00 +618,373.00,379.00,3,6.00 +618,379.00,383.00,4,3.00 diff --git a/AsbCloudInfrastructure/Repository/DataSaubStatRepository.cs b/AsbCloudInfrastructure/Repository/DataSaubStatRepository.cs index 3a6c19e0..065bbb3a 100644 --- a/AsbCloudInfrastructure/Repository/DataSaubStatRepository.cs +++ b/AsbCloudInfrastructure/Repository/DataSaubStatRepository.cs @@ -40,19 +40,28 @@ public class DataSaubStatRepository : IDataSaubStatRepository> GetAsync(int idTelemetry, DateTimeOffset geDate, DateTimeOffset leDate, CancellationToken token) + public async Task> GetAsync(IEnumerable idsTelemetries, DateTimeOffset geDate, DateTimeOffset leDate, CancellationToken token) { - var timeSpan = TimeSpan.FromHours(telemetryService.GetTimezone(idTelemetry).Hours); + //todo + var timeSpanDict = new Dictionary(); + + idsTelemetries = idsTelemetries.Distinct(); + foreach (var idTelemetry in idsTelemetries) + { + var timeSpan = TimeSpan.FromHours(telemetryService.GetTimezone(idTelemetry).Hours); + timeSpanDict.Add(idTelemetry, timeSpan); + } + var geDateUtc = geDate.ToUniversalTime(); var leDateUtc = leDate.ToUniversalTime(); var stats = await db.Set() - .Where(s => s.IdTelemetry == idTelemetry) + .Where(s => idsTelemetries.Contains(s.IdTelemetry)) .Where(s => s.DateStart >= geDateUtc) .Where(s => s.DateEnd <= leDateUtc) .ToArrayAsync(token); - var result = stats.Select(s => ConvertToDto(s, timeSpan)); + var result = stats.Select(s => ConvertToDto(s, timeSpanDict[s.IdTelemetry])); return result; } diff --git a/AsbCloudInfrastructure/Services/DataSaubStatDrillingQualityService.cs b/AsbCloudInfrastructure/Services/DataSaubStatDrillingQualityService.cs index a058a9c4..f83932db 100644 --- a/AsbCloudInfrastructure/Services/DataSaubStatDrillingQualityService.cs +++ b/AsbCloudInfrastructure/Services/DataSaubStatDrillingQualityService.cs @@ -17,25 +17,33 @@ public class DataSaubStatDrillingQualityService : IDataSaubStatDrillingQualitySe private IDataSaubStatRepository dataSaubStatDrillingQualityRepository; private ITelemetryDataSaubService dataSaubService; private ITelemetryDataCache telemetryDataCache; + private ITelemetryService telemetryService; + + private static int IdFeedRegulatorRop = 1; + private static int IdFeedRegulatorPressureDelta = 2; + private static int IdFeedRegulatorAxialLoad = 3; + private static int IdFeedRegulatorTorque = 4; public Dictionary> QualitySettingsForFeedRegulators { get; } public DataSaubStatDrillingQualityService( IDataSaubStatRepository dataSaubStatDrillingQualityRepository, ITelemetryDataCache telemetryDataCache, - ITelemetryDataSaubService dataSaubService) + ITelemetryDataSaubService dataSaubService, + ITelemetryService telemetryService) { this.dataSaubStatDrillingQualityRepository = dataSaubStatDrillingQualityRepository; this.dataSaubService = dataSaubService; this.telemetryDataCache = telemetryDataCache; + this.telemetryService = telemetryService; Predicate hasQualityWithIdFeedRegulator1 = (TelemetryDataSaubDto spanItem) => (spanItem.BlockSpeed >= spanItem.BlockSpeedSp * 0.95 && spanItem.BlockSpeed <= spanItem.BlockSpeedSp * 1.05); Predicate hasQualityWithIdFeedRegulator2 = (TelemetryDataSaubDto spanItem) - => (spanItem.Pressure >= (spanItem.PressureSp - spanItem.PressureIdle) - 5 - && spanItem.Pressure <= (spanItem.PressureSp - spanItem.PressureIdle) + 5); + => (spanItem.Pressure >= (spanItem.PressureSp) - 5 + && spanItem.Pressure <= (spanItem.PressureSp) + 5); Predicate hasQualityWithIdFeedRegulator3 = (TelemetryDataSaubDto spanItem) => (spanItem.AxialLoad >= (spanItem.AxialLoadSp - 0.5) @@ -46,10 +54,10 @@ public class DataSaubStatDrillingQualityService : IDataSaubStatDrillingQualitySe && spanItem.RotorTorque <= (spanItem.RotorTorqueSp + 0.5)); QualitySettingsForFeedRegulators = new Dictionary>() { - { 1, hasQualityWithIdFeedRegulator1 }, - { 2, hasQualityWithIdFeedRegulator2 }, - { 3, hasQualityWithIdFeedRegulator3 }, - { 4, hasQualityWithIdFeedRegulator4 }, + { IdFeedRegulatorRop, hasQualityWithIdFeedRegulator1 }, + { IdFeedRegulatorPressureDelta, hasQualityWithIdFeedRegulator2 }, + { IdFeedRegulatorAxialLoad, hasQualityWithIdFeedRegulator3 }, + { IdFeedRegulatorTorque, hasQualityWithIdFeedRegulator4 }, }; } @@ -96,7 +104,7 @@ public class DataSaubStatDrillingQualityService : IDataSaubStatDrillingQualitySe if (dataSaub is not TelemetryDataSaubDto[] dataSaubArray) dataSaubArray = dataSaub.ToArray(); - + foreach (var item in QualitySettingsForFeedRegulators) { var data = CreateDataSaubStatDrillingQuality(item.Key, item.Value, dataSaubArray); @@ -125,16 +133,11 @@ public class DataSaubStatDrillingQualityService : IDataSaubStatDrillingQualitySe indexEnd = FindIndexEnd(indexStart, idFeedRegulator, dataSaub); var length = indexEnd - indexStart + 1; - - if (length <= 2) - continue; - var subset = dataSaub.AsSpan(indexStart, length); if ((subset[^1].WellDepth - subset[0].WellDepth) < 0.15) continue; // мелкие выборки не учитываем. - var stats = CalcStatsDrillingQuality(idFeedRegulator, subset, checkQuality); result.Add(stats); @@ -151,9 +154,7 @@ public class DataSaubStatDrillingQualityService : IDataSaubStatDrillingQualitySe { indexEnd = i; } - else if (dataSaub[i].IdFeedRegulator != idFeedRegulator) - break; - else + if (dataSaub[i].IdFeedRegulator != idFeedRegulator) break; } return indexEnd; @@ -185,4 +186,45 @@ public class DataSaubStatDrillingQualityService : IDataSaubStatDrillingQualitySe return result; } + + public async Task> GetStatAsync(DrillingQualityRequest request, CancellationToken token) + { + var telemetries = telemetryService.GetOrDefaultTelemetriesByIdsWells(request.IdsWell); + var idsTelemetriesWithIdWell = telemetries + .Where(t => t.IdWell.HasValue) + .ToDictionary(t => t.Id, t => t.IdWell!.Value); + + var dataSaubStatDrillingQuality = await dataSaubStatDrillingQualityRepository.GetAsync(idsTelemetriesWithIdWell.Keys, request.GeDate, request.LeDate, token); + + var dtosGroupedByIdTelemetries = dataSaubStatDrillingQuality + .GroupBy(s => new { s.IdTelemetry, s.IdFeedRegulator }) + .Select(stat => new + { + IdFeedRegulator = stat.Key.IdFeedRegulator, + IdTelemetry = stat.Key.IdTelemetry, + Kpd = (stat.Sum(s => s.DepthDrillingQuality) / stat.Sum(s => s.DepthEnd - s.DepthStart)) * 100, + }) + .GroupBy(stat => stat.IdTelemetry); + + var result = new List(); + foreach (var dtos in dtosGroupedByIdTelemetries) + { + var kpdValuesByIdFeedRegulator = dtos + .GroupBy(d => d.IdFeedRegulator) + .ToDictionary(d => d.Key, d => d.FirstOrDefault()!.Kpd); + + var item = new DrillingQualityDto() + { + IdWell = idsTelemetriesWithIdWell[dtos.Key], + KpdAxialLoad = kpdValuesByIdFeedRegulator.GetValueOrDefault(IdFeedRegulatorAxialLoad), + KpdPressureDelta = kpdValuesByIdFeedRegulator.GetValueOrDefault(IdFeedRegulatorPressureDelta), + KpdRop = kpdValuesByIdFeedRegulator.GetValueOrDefault(IdFeedRegulatorRop), + KpdTorque = kpdValuesByIdFeedRegulator.GetValueOrDefault(IdFeedRegulatorTorque) + }; + + result.Add(item); + } + + return result; + } } diff --git a/AsbCloudInfrastructure/Services/ProcessMaps/Report/ProcessMapReportDrillingService.cs b/AsbCloudInfrastructure/Services/ProcessMaps/Report/ProcessMapReportDrillingService.cs index ec166d5d..8f05761f 100644 --- a/AsbCloudInfrastructure/Services/ProcessMaps/Report/ProcessMapReportDrillingService.cs +++ b/AsbCloudInfrastructure/Services/ProcessMaps/Report/ProcessMapReportDrillingService.cs @@ -88,7 +88,7 @@ public class ProcessMapReportDrillingService : IProcessMapReportDrillingService var geDate = wellOperations.Min(p => p.DateStart); var leDate = wellOperations.Max(p => (p.DateStart.AddHours(p.DurationHours))); var dataSaubStats = - (await dataSaubStatRepository.GetAsync(well.IdTelemetry.Value, geDate, leDate, token)).ToArray(); + (await dataSaubStatRepository.GetAsync([well.IdTelemetry.Value], geDate, leDate, token)).ToArray(); if (!dataSaubStats.Any()) return Enumerable.Empty(); diff --git a/AsbCloudWebApi/Controllers/ServiceOperationController.cs b/AsbCloudWebApi/Controllers/ServiceOperationController.cs new file mode 100644 index 00000000..8221cd8f --- /dev/null +++ b/AsbCloudWebApi/Controllers/ServiceOperationController.cs @@ -0,0 +1,59 @@ +using AsbCloudApp.Data; +using AsbCloudApp.Services; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Threading; +using System.Threading.Tasks; +using AsbCloudApp.Services.WellReport; +using Microsoft.AspNetCore.Http; +using System; +using AsbCloudApp.Repositories; +using System.Linq; +using AsbCloudApp.Requests; +using AsbCloudInfrastructure.Services; + +namespace AsbCloudWebApi.Controllers; + +/// +/// +/// +[Route("api/[controller]")] +[ApiController] +//[Authorize] +public class ServiceOperationController : ControllerBase +{ + private readonly IWellService wellService; + private readonly IDataSaubStatRepository dataSaubStatRepository; + private readonly ITelemetryService telemetryService; + private readonly IDataSaubStatDrillingQualityService dataSaubStatDrillingQualityService; + + public ServiceOperationController( + IWellService wellService, + ITelemetryService telemetryService, + IDataSaubStatDrillingQualityService dataSaubStatDrillingQualityService, + IDataSaubStatRepository dataSaubStatRepository) + { + this.wellService = wellService; + this.dataSaubStatRepository = dataSaubStatRepository; + this.telemetryService = telemetryService; + this.dataSaubStatDrillingQualityService = dataSaubStatDrillingQualityService; + } + + /// + /// Возвращает данные для страницы "Качество" + /// + /// Параметры запроса + /// Токен отмены задачи + /// + [HttpGet("drillingQuality")] + [Permission] + [ProducesResponseType(typeof(IEnumerable), (int)System.Net.HttpStatusCode.OK)] + public async Task GetDataSaubStatDrillingQualityAsync( + [FromQuery] DrillingQualityRequest request, CancellationToken token) + { + var result = await dataSaubStatDrillingQualityService.GetStatAsync(request, token); + return Ok(result); + } +}