diff --git a/AsbCloudApp/Repositories/IDataSaubStatDrillingQualityRepository.cs b/AsbCloudApp/Repositories/IDataSaubStatDrillingQualityRepository.cs index d607775a..849f44c4 100644 --- a/AsbCloudApp/Repositories/IDataSaubStatDrillingQualityRepository.cs +++ b/AsbCloudApp/Repositories/IDataSaubStatDrillingQualityRepository.cs @@ -20,7 +20,7 @@ public interface IDataSaubStatDrillingQualityRepository : ITelemetryDataEditorSe /// конечная дата /// /// - Task> GetAsync(int idTelemetry, DateTimeOffset geDate, DateTimeOffset leDate, CancellationToken token); + Task> GetAsync(int idTelemetry, DateTimeOffset geDate, DateTimeOffset leDate, CancellationToken token); /// /// Получение последних по дате окончания бурения записей качества в разрезе телеметрий diff --git a/AsbCloudInfrastructure/Repository/DataSaubStatDrillingQualityRepository.cs b/AsbCloudInfrastructure/Repository/DataSaubStatDrillingQualityRepository.cs index 6de63634..96cad607 100644 --- a/AsbCloudInfrastructure/Repository/DataSaubStatDrillingQualityRepository.cs +++ b/AsbCloudInfrastructure/Repository/DataSaubStatDrillingQualityRepository.cs @@ -22,7 +22,6 @@ public class DataSaubStatDrillingQualityRepository : IDataSaubStatDrillingQualit { db = dbContext; this.telemetryService = telemetryService; - } public async Task> GetLastsAsync(int[] idTelemetries, CancellationToken token) @@ -41,22 +40,21 @@ public class DataSaubStatDrillingQualityRepository : IDataSaubStatDrillingQualit return result; } - public async Task> GetAsync(int idTelemetry, DateTimeOffset geDate, DateTimeOffset leDate, CancellationToken token) + public async Task> GetAsync(int idTelemetry, DateTimeOffset geDate, DateTimeOffset leDate, CancellationToken token) { var timeSpan = TimeSpan.FromHours(telemetryService.GetTimezone(idTelemetry).Hours); var geDateUtc = geDate.ToUniversalTime(); var leDateUtc = leDate.ToUniversalTime(); - var stats = await db.Set() + var stats = await db.Set() .Where(s => s.IdTelemetry == idTelemetry) .Where(s => s.DateStart >= geDateUtc) .Where(s => s.DateEnd <= leDateUtc) .ToArrayAsync(token); - //todo - //var result = stats.Select(s => ConvertToDto(s, timeSpan)); - //return result; - return null; + var result = stats.Select(s => ConvertToDto(s, timeSpan)); + + return result; } public async Task InsertRangeAsync(IEnumerable dataSaubStats, CancellationToken token) @@ -84,9 +82,9 @@ public class DataSaubStatDrillingQualityRepository : IDataSaubStatDrillingQualit return entity; } - private IQueryable BuildQuery(TelemetryPartDeleteRequest request) + private IQueryable BuildQuery(TelemetryPartDeleteRequest request) { - var query = db.Set() + var query = db.Set() .Where(o => o.IdTelemetry == request.IdTelemetry); if (request.LeDate is not null) @@ -107,7 +105,7 @@ public class DataSaubStatDrillingQualityRepository : IDataSaubStatDrillingQualit public async Task DeleteAsync(TelemetryPartDeleteRequest request, CancellationToken token) { var query = BuildQuery(request); - db.Set().RemoveRange(query); + db.Set().RemoveRange(query); return await db.SaveChangesAsync(token); } } diff --git a/AsbCloudInfrastructure/Services/DataSaubStatDrillingQualityService.cs b/AsbCloudInfrastructure/Services/DataSaubStatDrillingQualityService.cs index a22e1007..e4ecf594 100644 --- a/AsbCloudInfrastructure/Services/DataSaubStatDrillingQualityService.cs +++ b/AsbCloudInfrastructure/Services/DataSaubStatDrillingQualityService.cs @@ -3,6 +3,7 @@ using AsbCloudApp.Data.SAUB; using AsbCloudApp.Repositories; using AsbCloudApp.Requests; using AsbCloudApp.Services; +using AsbCloudInfrastructure.Services.SAUB; using System; using System.Collections.Generic; using System.Linq; @@ -15,8 +16,8 @@ namespace AsbCloudInfrastructure.Services; public class DataSaubStatDrillingQualityService : IDataSaubStatService { private IDataSaubStatDrillingQualityRepository dataSaubStatDrillingQualityRepository; - private ITelemetryDataCache telemetryDataCache; private ITelemetryDataSaubService dataSaubService; + private ITelemetryDataCache telemetryDataCache; public Dictionary> QualitySettingsForFeedRegulators { get; } @@ -26,8 +27,8 @@ public class DataSaubStatDrillingQualityService : IDataSaubStatService ITelemetryDataSaubService dataSaubService) { this.dataSaubStatDrillingQualityRepository = dataSaubStatDrillingQualityRepository; - this.telemetryDataCache = telemetryDataCache; this.dataSaubService = dataSaubService; + this.telemetryDataCache = telemetryDataCache; Predicate hasQualityWithIdFeedRegulator1 = (TelemetryDataSaubDto spanItem) => (spanItem.BlockSpeed >= spanItem.BlockSpeedSp * 0.95 @@ -55,13 +56,11 @@ public class DataSaubStatDrillingQualityService : IDataSaubStatService public async Task CreateStatAsync(int lastDaysFilter, Action onProgressCallback, CancellationToken token) { - //to do var cacheRequest = new TelemetryDataRequest() { - GeDate = DateTime.UtcNow.AddDays(-5000) + GeDate = DateTime.UtcNow.AddDays(-lastDaysFilter) }; - var idTelemetries = new int[119]; - //telemetryDataCache.GetIds(cacheRequest).ToArray(); + var idTelemetries = telemetryDataCache.GetIds(cacheRequest).ToArray(); if (!idTelemetries.Any()) return; @@ -116,7 +115,7 @@ public class DataSaubStatDrillingQualityService : IDataSaubStatService var indexStart = 0; var indexEnd = 0; - while (indexEnd < dataSaub.Count()-1) + while (indexEnd < dataSaub.Count()) { indexStart = Array.FindIndex(dataSaub, indexEnd, t => t.IdFeedRegulator == idFeedRegulator); if (indexStart < 0) @@ -134,7 +133,7 @@ public class DataSaubStatDrillingQualityService : IDataSaubStatService var subset = dataSaub.AsSpan(indexStart, length); - if (length <= 2 || (subset[^1].WellDepth - subset[0].WellDepth) < 0.3) + if (length <= 2 || (subset[^1].WellDepth - subset[0].WellDepth) < 0.15) continue; // мелкие выборки не учитываем. diff --git a/AsbCloudWebApi/appsettings.json b/AsbCloudWebApi/appsettings.json index ae879099..06cd312e 100644 --- a/AsbCloudWebApi/appsettings.json +++ b/AsbCloudWebApi/appsettings.json @@ -7,10 +7,10 @@ } }, "ConnectionStrings": { - "DefaultConnection": "Host=192.168.0.10;Database=postgres;Username=postgres;Password=q;Persist Security Info=True", - "DebugConnection": "Host=192.168.0.10;Database=postgres;Username=postgres;Password=q;Persist Security Info=True;Include Error Detail=True", - "TestConnection": "Host=192.168.0.10;Database=test;Username=postgres;Password=q;Persist Security Info=True;Include Error Detail=True", - "LocalConnection": "Host=192.168.0.10;Database=postgres;Username=postgres;Password=q;Persist Security Info=True" + "DefaultConnection": "Host=localhost;Database=postgres;Username=postgres;Password=q;Persist Security Info=True", + "DebugConnection": "Host=localhost;Database=postgres;Username=postgres;Password=q;Persist Security Info=True;Include Error Detail=True", + "TestConnection": "Host=localhost;Database=test;Username=postgres;Password=q;Persist Security Info=True;Include Error Detail=True", + "LocalConnection": "Host=localhost;Database=postgres;Username=postgres;Password=q;Persist Security Info=True" }, "AllowedHosts": "*", "ContentPath": "../data",