From 6c722e5478dc05433586f0046cba20e23353dbd7 Mon Sep 17 00:00:00 2001 From: ngfrolov Date: Thu, 12 Oct 2023 17:54:05 +0500 Subject: [PATCH] =?UTF-8?q?=D1=83=D0=B2=D0=B5=D0=BB=D0=B8=D1=87=D0=B8?= =?UTF-8?q?=D0=BB=20timeout=20=D0=B4=D0=BB=D1=8F=20=D0=BE=D1=82=D0=B2?= =?UTF-8?q?=D0=B5=D1=82=D0=B0=20=D0=91=D0=94=20=D0=B4=D0=BB=D1=8F=20=D1=84?= =?UTF-8?q?=D0=BE=D0=BD=D0=BE=D0=B2=D1=8B=D1=85=20=D0=B7=D0=B0=D0=B4=D0=B0?= =?UTF-8?q?=D1=87.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Background/WorkLimitingParameterCalc.cs | 1 + .../Subsystems/WorkSubsystemOperationTimeCalc.cs | 13 +++++++------ AsbCloudInfrastructure/Startup.cs | 4 ++-- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/AsbCloudInfrastructure/Background/WorkLimitingParameterCalc.cs b/AsbCloudInfrastructure/Background/WorkLimitingParameterCalc.cs index 76749e07..c0d6eb48 100644 --- a/AsbCloudInfrastructure/Background/WorkLimitingParameterCalc.cs +++ b/AsbCloudInfrastructure/Background/WorkLimitingParameterCalc.cs @@ -22,6 +22,7 @@ public class WorkLimitingParameterCalc : Work protected override async Task Action(string id, IServiceProvider services, Action onProgressCallback, CancellationToken token) { using var db = services.GetRequiredService(); + db.Database.SetCommandTimeout(TimeSpan.FromMinutes(5)); var lastDetectedDates = await db.LimitingParameter .GroupBy(o => o.IdTelemetry) .Select(g => new diff --git a/AsbCloudInfrastructure/Services/Subsystems/WorkSubsystemOperationTimeCalc.cs b/AsbCloudInfrastructure/Services/Subsystems/WorkSubsystemOperationTimeCalc.cs index bda4bbe4..5b9d00f8 100644 --- a/AsbCloudInfrastructure/Services/Subsystems/WorkSubsystemOperationTimeCalc.cs +++ b/AsbCloudInfrastructure/Services/Subsystems/WorkSubsystemOperationTimeCalc.cs @@ -15,7 +15,7 @@ using System.Threading.Tasks; namespace AsbCloudInfrastructure.Services.Subsystems; -public class WorkSubsystemOperationTimeCalc: Work +public class WorkSubsystemOperationTimeCalc : Work { private const int idSubsytemTorqueMaster = 65537; private const int idSubsytemSpinMaster = 65536; @@ -23,7 +23,7 @@ public class WorkSubsystemOperationTimeCalc: Work private const int idSubsystemAPDSlide = 12; private const int idSubsytemMse = 2; - public WorkSubsystemOperationTimeCalc() + public WorkSubsystemOperationTimeCalc() : base("Subsystem operation time calc") { Timeout = TimeSpan.FromMinutes(20); @@ -32,7 +32,7 @@ public class WorkSubsystemOperationTimeCalc: Work protected override async Task Action(string id, IServiceProvider services, Action onProgressCallback, CancellationToken token) { using var db = services.GetRequiredService(); - + db.Database.SetCommandTimeout(TimeSpan.FromMinutes(5)); var lastDetectedDates = await db.SubsystemOperationTimes .GroupBy(o => o.IdTelemetry) .Select(g => new @@ -61,7 +61,7 @@ public class WorkSubsystemOperationTimeCalc: Work var i = 0d; foreach (var item in telemetryLastDetectedDates) { - onProgressCallback($"Start hanling telemetry: {item.IdTelemetry} from {item.LastDate}", i++ / count); + onProgressCallback($"Start handling telemetry: {item.IdTelemetry} from {item.LastDate}", i++ / count); var newOperationsSaub = await OperationTimeSaubAsync(item.IdTelemetry, item.LastDate ?? DateTimeOffset.MinValue, db, token); if (newOperationsSaub?.Any() == true) { @@ -114,7 +114,7 @@ public class WorkSubsystemOperationTimeCalc: Work $" lag(mode,1) over (order by date) as mode_lag, " + $" lead(mode,1) over (order by date) as mode_lead " + $" from t_telemetry_data_saub " + - $" where id_telemetry = {idTelemetry} and well_depth is not null and well_depth > 0" + + $" where id_telemetry = {idTelemetry} and well_depth is not null and well_depth > 0 " + $" order by date ) as tt " + $"where (tt.mode_lag is null or (tt.mode != tt.mode_lag and tt.mode_lead != tt.mode_lag)) and tt.date >= '{begin:u}' " + $"order by tt.date;"; @@ -278,7 +278,8 @@ public class WorkSubsystemOperationTimeCalc: Work .Where(d => d.WellDepth != null) .Where(d => d.WellDepth > 0) .GroupBy(d => Math.Ceiling(d.WellDepth ?? 0 * 10)) - .Select(g => new { + .Select(g => new + { DateMin = g.Min(d => d.DateTime), DepthMin = g.Min(d => d.WellDepth) ?? 0, }) diff --git a/AsbCloudInfrastructure/Startup.cs b/AsbCloudInfrastructure/Startup.cs index d00de488..9aff9ca9 100644 --- a/AsbCloudInfrastructure/Startup.cs +++ b/AsbCloudInfrastructure/Startup.cs @@ -1,7 +1,6 @@ using AsbCloudApp.Services; using AsbCloudDb.Model; using AsbCloudInfrastructure.Services.DetectOperations; -using AsbCloudInfrastructure.Services.Subsystems; using AsbCloudInfrastructure.Services; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.DependencyInjection; @@ -12,6 +11,7 @@ using System.Threading; using AsbCloudInfrastructure.Background; using AsbCloudApp.Data.SAUB; using AsbCloudInfrastructure.Services.SAUB; +using AsbCloudInfrastructure.Services.Subsystems; namespace AsbCloudInfrastructure { @@ -23,7 +23,7 @@ namespace AsbCloudInfrastructure var provider = scope.ServiceProvider; var context = provider.GetRequiredService(); - context.Database.SetCommandTimeout(TimeSpan.FromSeconds(2 * 60)); + context.Database.SetCommandTimeout(TimeSpan.FromMinutes(5)); context.Database.Migrate(); // TODO: Сделать инициализацию кеша телеметрии более явной.