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: Сделать инициализацию кеша телеметрии более явной.