From 60381a68ec051a155f66b70418f5341d7198bd29 Mon Sep 17 00:00:00 2001 From: Olga Nemt Date: Mon, 22 Apr 2024 09:38:00 +0500 Subject: [PATCH 1/2] =?UTF-8?q?=D0=94=D0=BE=D0=BF=D0=BE=D0=BB=D0=BD=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20=D1=88=D0=B0=D0=B1=D0=BB=D0=BE=D0=BD=D0=B0?= =?UTF-8?q?=20=D0=BA=D0=BE=D0=BC=D0=BF=D0=BE=D0=B7=D0=B8=D1=82=D0=BD=D0=BE?= =?UTF-8?q?=D0=B9=20=D1=81=D0=BA=D0=B2=D0=B0=D0=B6=D0=B8=D0=BD=D1=8B=20?= =?UTF-8?q?=D0=BE=D0=BF=D0=B5=D1=80=D0=B0=D1=86=D0=B8=D1=8F=D0=BC=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Services/WellCompositeOperationService.cs | 35 +++++++++++++++---- 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/AsbCloudInfrastructure/Services/WellCompositeOperationService.cs b/AsbCloudInfrastructure/Services/WellCompositeOperationService.cs index fe1f4880..cc944835 100644 --- a/AsbCloudInfrastructure/Services/WellCompositeOperationService.cs +++ b/AsbCloudInfrastructure/Services/WellCompositeOperationService.cs @@ -37,28 +37,41 @@ public class WellCompositeOperationService : IWellCompositeOperationService private static Dictionary<(int, int), int> SettingsForSectionCategoryChange = new Dictionary<(int, int), int>() { { (2, 5096), 5013 }, { (2, 5008), 5013 }, + { (2, 5002), 5113 }, + { (2, 5003), 5113 }, { (3, 5096), 5084 }, { (3, 5008), 5084 }, { (3, 5085), 5015 }, { (3, 5014), 5015 }, + { (3, 5002), 5113 }, + { (3, 5003), 5113 }, { (31, 5014), 5015 }, { (31, 5012), 5013 }, { (31, 5083), 5013 }, + { (31, 5002), 5113 }, + { (31, 5003), 5113 }, { (4, 5085), 5015 }, { (4, 5087), 5015 }, { (4, 5014), 5015 }, { (4, 5053), 5037 }, { (4, 5084), 5096 }, { (4, 5086), 5013 }, + { (4, 5002), 5113 }, + { (4, 5003), 5113 }, { (6, 5085), 5015 }, { (6, 5036), 5034 }, - { (6, 5035), 5097 } + { (6, 5035), 5097 }, + { (6, 5002), 5113 }, + { (6, 5003), 5113 }, + { (6, 5021), 5095 }, + { (6, 5086), 5012 } + }; private HashSet<(int IdSectionType, int IdCategory)> WellSectionTypesWithCategories = new HashSet<(int IdSectionType, int IdCategory)>() { { (2, 5001) }, - { (2, 5003) }, + { (2, 5113) }, { (2, 5013) }, { (2, 5000) }, { (2, 5022) }, @@ -70,7 +83,7 @@ public class WellCompositeOperationService : IWellCompositeOperationService { (3, 5015) }, { (3, 5037) }, { (3, 5057) }, - { (3, 5003) }, + { (3, 5113) }, { (3, 5036) }, { (3, 5084) }, { (3, 5013) }, @@ -86,7 +99,7 @@ public class WellCompositeOperationService : IWellCompositeOperationService { (31, 5015) }, { (31, 5037) }, { (31, 5057) }, - { (31, 5003) }, + { (31, 5113) }, { (31, 5036) }, { (31, 5013) }, { (31, 5022) }, @@ -102,7 +115,7 @@ public class WellCompositeOperationService : IWellCompositeOperationService { (4, 5037) }, { (4, 5097) }, { (4, 5057) }, - { (4, 5003) }, + { (4, 5113) }, { (4, 5036) }, { (4, 5008) }, { (4, 5003) }, @@ -121,7 +134,17 @@ public class WellCompositeOperationService : IWellCompositeOperationService { (6, 5037) }, { (6, 5097) }, { (6, 5057) }, - { (6, 5003) } + { (6, 5113) }, + { (6, 5036) }, + { (6, 5013) }, + { (6, 5000) }, + { (6, 5022) }, + { (6, 5093) }, + { (6, 5017) }, + { (6, 5095) }, + { (6, 5012) }, + { (6, 5040) }, + { (6, 5092) } }; public WellCompositeOperationService( From 4576a40ab00b361cfaffbf07b5c483fa3e299752 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D1=82=D0=B5=D0=BF=D0=B0=D0=BD=D0=BE=D0=B2=20=D0=94?= =?UTF-8?q?=D0=BC=D0=B8=D1=82=D1=80=D0=B8=D0=B9?= Date: Mon, 22 Apr 2024 11:40:14 +0300 Subject: [PATCH 2/2] =?UTF-8?q?=D0=A4=D0=B8=D0=BA=D1=81=20Drill=20test?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AsbCloudApp/Repositories/IDrillTestRepository.cs | 4 ++-- .../Repository/DrillTestRepository.cs | 14 +++++++++----- AsbCloudWebApi/Controllers/DrillTestController.cs | 11 ++++++----- .../SignalR/Clients/ITelemetryHubClient.cs | 4 ++-- 4 files changed, 19 insertions(+), 14 deletions(-) diff --git a/AsbCloudApp/Repositories/IDrillTestRepository.cs b/AsbCloudApp/Repositories/IDrillTestRepository.cs index 22f11a06..b009273b 100644 --- a/AsbCloudApp/Repositories/IDrillTestRepository.cs +++ b/AsbCloudApp/Repositories/IDrillTestRepository.cs @@ -33,9 +33,9 @@ namespace AsbCloudApp.Repositories /// Сохранить данные drill_test /// /// ключ телеметрии - /// запись drill test + /// записи drill test /// /// - Task SaveDataAsync(int idTelemetry, DrillTestBaseDto dto, CancellationToken token); + Task SaveDataAsync(int idTelemetry, IEnumerable dtos, CancellationToken token); } } diff --git a/AsbCloudInfrastructure/Repository/DrillTestRepository.cs b/AsbCloudInfrastructure/Repository/DrillTestRepository.cs index d8700929..961dd67b 100644 --- a/AsbCloudInfrastructure/Repository/DrillTestRepository.cs +++ b/AsbCloudInfrastructure/Repository/DrillTestRepository.cs @@ -63,16 +63,20 @@ namespace AsbCloudInfrastructure.Repository return dto; } - public async Task SaveDataAsync(int idTelemetry, DrillTestBaseDto dto, CancellationToken token) + public async Task SaveDataAsync(int idTelemetry, IEnumerable dtos, CancellationToken token) { - var entity = dto.Adapt(); - entity.IdTelemetry = idTelemetry; - db.DrillTests.Add(entity); + var entities = dtos.Select(dto => + { + var entity = dto.Adapt(); + entity.IdTelemetry = idTelemetry; + return entity; + }); + db.DrillTests.AddRange(entities); var result = await db.SaveChangesAsync(token); return result; } - private DrillTestDto Convert(DrillTest entity) + private static DrillTestDto Convert(DrillTest entity) { var dto = entity.Adapt(); dto.TimeStampStart = dto.TimeStampStart.ToRemoteDateTime(dto.Telemetry?.TimeZone?.Hours ?? 0); diff --git a/AsbCloudWebApi/Controllers/DrillTestController.cs b/AsbCloudWebApi/Controllers/DrillTestController.cs index 8562e54c..18a30bf4 100644 --- a/AsbCloudWebApi/Controllers/DrillTestController.cs +++ b/AsbCloudWebApi/Controllers/DrillTestController.cs @@ -11,6 +11,7 @@ using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.SignalR; using System; +using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.Net; using System.Threading; @@ -51,27 +52,27 @@ public class DrillTestController : ControllerBase /// Сохраняет в БД. /// /// уникальный идентификатор записи drill_test - /// запись drill test + /// записи drill test /// /// [AllowAnonymous] [HttpPost("api/telemetry/{uid}/[controller]")] public async Task PostDataAsync( - string uid, - [FromBody] DrillTestBaseDto dto, + string uid, + [FromBody] IEnumerable dtos, CancellationToken token) { var telemetry = telemetryService.GetOrCreateTelemetryByUid(uid); if (telemetry is null) throw new Exception($"Telemetry with RemoteUid: {uid} does not exist."); - await drillTestRepository.SaveDataAsync(telemetry.Id, dto, token); + await drillTestRepository.SaveDataAsync(telemetry.Id, dtos, token); var idWell = telemetryService.GetIdWellByTelemetryUid(uid); if (idWell is not null) _ = Task.Run(async () => { var clients = telemetryHubContext.Clients.Group($"well_{idWell}"); - await clients.ReceiveDrilltestData(dto, token); + await clients.ReceiveDrilltestData(dtos, token); }, CancellationToken.None); return Ok(); diff --git a/AsbCloudWebApi/SignalR/Clients/ITelemetryHubClient.cs b/AsbCloudWebApi/SignalR/Clients/ITelemetryHubClient.cs index 2e831d1e..5e8869cf 100644 --- a/AsbCloudWebApi/SignalR/Clients/ITelemetryHubClient.cs +++ b/AsbCloudWebApi/SignalR/Clients/ITelemetryHubClient.cs @@ -17,10 +17,10 @@ namespace AsbCloudWebApi.SignalR.Clients /// Отправка клиенту уведомления о доставке с панели drill test данных. /// Для подписки на метод необходимо отправить сообщение в формате $"well_{idWell}" /// - /// + /// /// /// - Task ReceiveDrilltestData(DrillTestBaseDto dto, CancellationToken token); + Task ReceiveDrilltestData(IEnumerable dtos, CancellationToken token); /// /// Обновление записей РТК