diff --git a/AsbCloudApp/Data/DataSaubStat/DataSaubStatDrillingQualityDto.cs b/AsbCloudApp/Data/DataSaubStat/DataSaubStatDrillingQualityDto.cs deleted file mode 100644 index fa8c6560..00000000 --- a/AsbCloudApp/Data/DataSaubStat/DataSaubStatDrillingQualityDto.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System; -using AsbCloudApp.Data.WellOperation; - -namespace AsbCloudApp.Data; - -/// -/// dto для хранения данных статистики качества бурения -/// -public class DataSaubStatDrillingQualityDto : IId -{ - /// - /// - /// - public int Id { get; set; } - - /// - /// Дата и время начала - /// - public DateTimeOffset DateStart { get; set; } - - /// - /// Дата и время окончания - /// - public DateTimeOffset DateEnd { get; set; } - - /// - /// Глубина забоя по стволу начальная - /// - public double DepthStart { get; set; } - - /// - /// Глубина забоя по стволу конечная - /// - public double DepthEnd { get; set; } - public object DepthDrillingQuality { get; set; } -} diff --git a/AsbCloudApp/Data/DataSaubStat/DataSaubStatDto.cs b/AsbCloudApp/Data/DataSaubStat/DataSaubStatDto.cs deleted file mode 100644 index 7fa58e48..00000000 --- a/AsbCloudApp/Data/DataSaubStat/DataSaubStatDto.cs +++ /dev/null @@ -1,135 +0,0 @@ -using System; -using AsbCloudApp.Data.WellOperation; - -namespace AsbCloudApp.Data.DataSaubStat; - -/// -/// dto для хранения данных статистики сауб -/// -public class DataSaubStatDto : IId -{ - /// - /// - /// - public int Id { get; set; } - - /// - /// Дата и время начала - /// - public DateTimeOffset DateStart { get; set; } - - /// - /// Дата и время окончания - /// - public DateTimeOffset DateEnd { get; set; } - - /// - /// Глубина забоя по стволу начальная - /// - public double DepthStart { get; set; } - - /// - /// Глубина забоя по стволу конечная - /// - public double DepthEnd { get; set; } - - /// - /// Скорость бурения - /// - public double Speed { get; set; } - - /// - /// Ограничение скорости блока - /// - public double? BlockSpeedSp { get; set; } - - /// - /// Давление - /// - public double Pressure { get; set; } - - /// - /// Давление холостого хода - /// - public double? PressureIdle { get; set; } - - /// - /// Ограничение фактического давления - /// - public double? PressureSp { get; set; } - - /// - /// Фактическая нагрузка - /// - public double AxialLoad { get; set; } - - /// - /// Ограничение факт. нагрузки - /// - public double? AxialLoadSp { get; set; } - - /// - /// Максимально допустимая нагрузка - /// - public double? AxialLoadLimitMax { get; set; } - - /// - /// Фактический момент - /// - public double RotorTorque { get; set; } - - /// - /// Ограничение факт. момента - /// - public double? RotorTorqueSp { get; set; } - - /// - /// Максимально допустимый момент - /// - public double? RotorTorqueLimitMax { get; set; } - - /// - /// Работа при достижении ограничения - /// - public short? IdFeedRegulator { get; set; } - - /// - /// Фактическая скорость оборотов ВСП - /// - public double RotorSpeed { get; set; } - - /// - /// Название автоопределённой операции - /// - public int IdCategory { get; set; } - - /// - /// Флаги подсистем - /// - public int EnabledSubsystems { get; set; } - - /// - /// Наличие или отсутствие осцилляции - /// - public bool HasOscillation { get; set; } - - /// - /// Фактический расход - /// - public double Flow { get; set; } - - /// - /// Ключ телеметрии - /// - public int IdTelemetry { get; set; } - - /// - /// Телеметрия - /// - public TelemetryDto Telemetry { get; set; } = null!; - - /// - /// Категория автоопределенной операции - /// - public WellOperationCategoryDto OperationCategory { get; set; } = null!; -} diff --git a/AsbCloudApp/Repositories/IDataSaubStatDrillingQualityRepository.cs b/AsbCloudApp/Repositories/IDataSaubStatDrillingQualityRepository.cs new file mode 100644 index 00000000..67b1070f --- /dev/null +++ b/AsbCloudApp/Repositories/IDataSaubStatDrillingQualityRepository.cs @@ -0,0 +1,40 @@ +using AsbCloudApp.Data; +using AsbCloudApp.Services; +using System; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; + +namespace AsbCloudApp.Repositories; + +/// +/// Репозиторий работы с данными из таблицы t_data_daub_stat_drilling_quality +/// +public interface IDataSaubStatDrillingQualityRepository : ITelemetryDataEditorService +{ + /// + /// Получение записей по ключу телеметрии + /// + /// ключ телеметрии + /// начальная дата + /// конечная дата + /// + /// + Task> GetAsync(int idTelemetry, DateTimeOffset geDate, DateTimeOffset leDate, CancellationToken token); + + /// + /// Получение последних по дате окончания бурения записей в разрезе телеметрий + /// + /// ключи телеметрий + /// + /// + Task> GetLastsAsync(int[] idTelemetries, CancellationToken token); + + /// + /// Вставка записей статистики + /// + /// + /// + /// + Task InsertRangeAsync(IEnumerable dataSaubStats, CancellationToken token); +} diff --git a/AsbCloudApp/Repositories/IDataSaubStatRepository.cs b/AsbCloudApp/Repositories/IDataSaubStatRepository.cs index 628276bc..d419ad82 100644 --- a/AsbCloudApp/Repositories/IDataSaubStatRepository.cs +++ b/AsbCloudApp/Repositories/IDataSaubStatRepository.cs @@ -1,4 +1,4 @@ -using AsbCloudApp.Data.DataSaubStat; +using AsbCloudApp.Data; using AsbCloudApp.Services; using System; using System.Collections.Generic; diff --git a/AsbCloudDb/Model/AsbCloudDbContext.cs b/AsbCloudDb/Model/AsbCloudDbContext.cs index 94ddf0d0..3f234fc8 100644 --- a/AsbCloudDb/Model/AsbCloudDbContext.cs +++ b/AsbCloudDb/Model/AsbCloudDbContext.cs @@ -110,6 +110,7 @@ namespace AsbCloudDb.Model public DbSet DrillTests => Set(); public DbSet DataSaubStat => Set(); + public DbSet DataSaubStatDrillingQuality => Set(); public AsbCloudDbContext() : base() { Interlocked.Increment(ref referenceCount); diff --git a/AsbCloudDb/Model/IAsbCloudDbContext.cs b/AsbCloudDb/Model/IAsbCloudDbContext.cs index ab1fb60d..94879ec1 100644 --- a/AsbCloudDb/Model/IAsbCloudDbContext.cs +++ b/AsbCloudDb/Model/IAsbCloudDbContext.cs @@ -81,6 +81,7 @@ namespace AsbCloudDb.Model DbSet TrajectoriesFact { get; } DbSet WellSectionsPlan { get; } DbSet DataSaubStat { get; } + DbSet DataSaubStatDrillingQuality { get; } DatabaseFacade Database { get; } DbSet ProcessMapPlanRotor { get; } DbSet ProcessMapPlanSlide { get; } diff --git a/AsbCloudDb/Model/DataSaubStat.cs b/AsbCloudDb/Model/SaubStat/DataSaubStat.cs similarity index 100% rename from AsbCloudDb/Model/DataSaubStat.cs rename to AsbCloudDb/Model/SaubStat/DataSaubStat.cs diff --git a/AsbCloudDb/Model/SaubStat/DataSaubStatDrillingQuality.cs b/AsbCloudDb/Model/SaubStat/DataSaubStatDrillingQuality.cs new file mode 100644 index 00000000..a49dc29e --- /dev/null +++ b/AsbCloudDb/Model/SaubStat/DataSaubStatDrillingQuality.cs @@ -0,0 +1,34 @@ +using Microsoft.EntityFrameworkCore; +using System; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Text.Json.Serialization; + +namespace AsbCloudDb.Model +{ + [Table("t_data_saub_stat_drilling_quality"), Comment("Кеш-таблица для хранения данных для построения страницы \"Качество\"")] + public class DataSaubStatDrillingQuality : IId + { + [Key] + [Column("id")] + public int Id { get; set; } + + [Column("id_telemetry"), Comment("Ключ телеметрии")] + public int IdTelemetry { get; set; } + + [Column("date_start", TypeName = "timestamp with time zone"), Comment("Дата и время начала")] + public DateTimeOffset DateStart { get; set; } + + [Column("date_end", TypeName = "timestamp with time zone"), Comment("Дата и время окончания")] + public DateTimeOffset DateEnd { get; set; } + + [Column("depth_start"), Comment("Глубина забоя по стволу начальная")] + public double DepthStart { get; set; } + + [Column("depth_end"), Comment("Глубина забоя по стволу конечная")] + public double DepthEnd { get; set; } + + [ForeignKey(nameof(IdTelemetry))] + public virtual Telemetry Telemetry { get; set; } = null!; + } +} diff --git a/AsbCloudInfrastructure.Tests/Services/DataSaubStatServiceTest.cs b/AsbCloudInfrastructure.Tests/Services/DataSaubStatServiceTest.cs index 1e507f6f..80783c73 100644 --- a/AsbCloudInfrastructure.Tests/Services/DataSaubStatServiceTest.cs +++ b/AsbCloudInfrastructure.Tests/Services/DataSaubStatServiceTest.cs @@ -1,4 +1,4 @@ -using AsbCloudApp.Data.DataSaubStat; +using AsbCloudApp.Data; using AsbCloudApp.Data.DetectedOperation; using AsbCloudApp.Data.SAUB; using AsbCloudApp.Repositories; diff --git a/AsbCloudInfrastructure/Repository/DataSaubStatDrillingQualityRepository.cs b/AsbCloudInfrastructure/Repository/DataSaubStatDrillingQualityRepository.cs new file mode 100644 index 00000000..d51ada62 --- /dev/null +++ b/AsbCloudInfrastructure/Repository/DataSaubStatDrillingQualityRepository.cs @@ -0,0 +1,114 @@ +using AsbCloudApp.Data; +using AsbCloudApp.Repositories; +using AsbCloudApp.Requests; +using AsbCloudApp.Services; +using AsbCloudDb.Model; +using Mapster; +using Microsoft.EntityFrameworkCore; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; + +namespace AsbCloudInfrastructure.Repository; + +public class DataSaubStatDrillingQualityRepository : IDataSaubStatDrillingQualityRepository +{ + private readonly IAsbCloudDbContext db; + private readonly ITelemetryService telemetryService; + + public DataSaubStatDrillingQualityRepository(IAsbCloudDbContext dbContext, ITelemetryService telemetryService) + { + db = dbContext; + this.telemetryService = telemetryService; + + } + + public async Task> GetLastsAsync(int[] idTelemetries, CancellationToken token) + { + var timeZoneOffsets = idTelemetries + .Distinct() + .ToDictionary(idTelemetry => idTelemetry, idTelemetry => TimeSpan.FromHours(telemetryService.GetTimezone(idTelemetry).Hours)); + + var stats = await db.Set() + .Where(s => idTelemetries.Contains(s.IdTelemetry)) + .GroupBy(s => s.IdTelemetry, (key, group) => group.OrderByDescending(el => el.DateEnd).First()) + .ToArrayAsync(token); + //todo + //var result = stats.Select(s => ConvertToDto(s, timeZoneOffsets[s.IdTelemetry])); + + //return result; + return null; + } + + 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() + .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; + } + + public async Task InsertRangeAsync(IEnumerable dataSaubStats, CancellationToken token) + { + var entities = dataSaubStats.Select(data => ConvertToEntity(data)); + db.Set().AddRange(entities); + return await db.SaveChangesAsync(token); + } + + private static DataSaubStatDrillingQualityDto ConvertToDto(DataSaubStatDrillingQuality entity, TimeSpan timeSpan) + { + var dto = entity.Adapt(); + dto.DateStart = dto.DateStart.ToOffset(timeSpan); + dto.DateEnd = dto.DateEnd.ToOffset(timeSpan); + + return dto; + } + + private static DataSaubStatDrillingQuality ConvertToEntity(DataSaubStatDrillingQualityDto dto) + { + var entity = dto.Adapt(); + entity.DateStart = dto.DateStart.ToUniversalTime(); + entity.DateEnd = dto.DateEnd.ToUniversalTime(); + + return entity; + } + + private IQueryable BuildQuery(TelemetryPartDeleteRequest request) + { + var query = db.Set() + .Where(o => o.IdTelemetry == request.IdTelemetry); + + if (request.LeDate is not null) + { + var leDate = request.LeDate.Value.ToUniversalTime(); + query = query.Where(o => o.DateStart <= leDate); + } + + if (request.GeDate is not null) + { + var geDate = request.GeDate.Value.ToUniversalTime(); + query = query.Where(o => o.DateEnd >= geDate); + } + + return query; + } + + public async Task DeleteAsync(TelemetryPartDeleteRequest request, CancellationToken token) + { + var query = BuildQuery(request); + db.Set().RemoveRange(query); + return await db.SaveChangesAsync(token); + } +} diff --git a/AsbCloudInfrastructure/Repository/DataSaubStatRepository.cs b/AsbCloudInfrastructure/Repository/DataSaubStatRepository.cs index cb986215..d8932b28 100644 --- a/AsbCloudInfrastructure/Repository/DataSaubStatRepository.cs +++ b/AsbCloudInfrastructure/Repository/DataSaubStatRepository.cs @@ -1,4 +1,4 @@ -using AsbCloudApp.Data.DataSaubStat; +using AsbCloudApp.Data; using AsbCloudApp.Repositories; using AsbCloudApp.Requests; using AsbCloudApp.Services; diff --git a/AsbCloudInfrastructure/Services/DataSaubStatDrillingQualityService.cs b/AsbCloudInfrastructure/Services/DataSaubStatDrillingQualityService.cs index 1726af5c..9458145d 100644 --- a/AsbCloudInfrastructure/Services/DataSaubStatDrillingQualityService.cs +++ b/AsbCloudInfrastructure/Services/DataSaubStatDrillingQualityService.cs @@ -1,11 +1,8 @@ using AsbCloudApp.Data; -using AsbCloudApp.Data.DataSaubStat; -using AsbCloudApp.Data.DetectedOperation; using AsbCloudApp.Data.SAUB; using AsbCloudApp.Repositories; using AsbCloudApp.Requests; using AsbCloudApp.Services; -using AsbCloudDb.Model; using System; using System.Collections.Generic; using System.Linq; @@ -17,21 +14,43 @@ namespace AsbCloudInfrastructure.Services; public class DataSaubStatDrillingQualityService : IDataSaubStatService { - private IDataSaubStatRepository dataSaubStatRepository; + private IDataSaubStatDrillingQualityRepository dataSaubStatDrillingQualityRepository; private ITelemetryDataCache telemetryDataCache; private ITelemetryDataSaubService dataSaubService; - private IDetectedOperationRepository detectedOperationRepository; + + public Dictionary> QualitySettingsForFeedRegulators { get; } public DataSaubStatDrillingQualityService( - IDataSaubStatRepository dataSaubStatRepository, + IDataSaubStatDrillingQualityRepository dataSaubStatDrillingQualityRepository, ITelemetryDataCache telemetryDataCache, - ITelemetryDataSaubService dataSaubService, - IDetectedOperationRepository detectedOperationRepository) + ITelemetryDataSaubService dataSaubService) { - this.dataSaubStatRepository = dataSaubStatRepository; + this.dataSaubStatDrillingQualityRepository = dataSaubStatDrillingQualityRepository; this.telemetryDataCache = telemetryDataCache; this.dataSaubService = dataSaubService; - this.detectedOperationRepository = detectedOperationRepository; + + 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); + + Predicate hasQualityWithIdFeedRegulator3 = (TelemetryDataSaubDto spanItem) + => (spanItem.AxialLoad >= (spanItem.AxialLoadSp - 0.5) + && spanItem.AxialLoad <= (spanItem.AxialLoadSp + 0.5)); + + Predicate hasQualityWithIdFeedRegulator4 = (TelemetryDataSaubDto spanItem) + => (spanItem.RotorTorque >= (spanItem.RotorTorqueSp - 0.5) + && spanItem.RotorTorque <= (spanItem.RotorTorqueSp + 0.5)); + + QualitySettingsForFeedRegulators = new Dictionary>() { + { 1, hasQualityWithIdFeedRegulator1 }, + { 2, hasQualityWithIdFeedRegulator2 }, + { 3, hasQualityWithIdFeedRegulator3 }, + { 4, hasQualityWithIdFeedRegulator4 }, + }; } public async Task CreateStatAsync(int lastDaysFilter, Action onProgressCallback, CancellationToken token) @@ -47,19 +66,19 @@ public class DataSaubStatDrillingQualityService : IDataSaubStatService return; var stats = new List(); - //await dataSaubStatRepository.GetLastsAsync(idTelemetries, token); + //await dataSaubStatRepository.GetLastsAsync(idTelemetries, token); //for (var i = 0; i < idTelemetries.Length; i++) //{ // var idTelemetry = idTelemetries[i]; // var lastDate = stats.FirstOrDefault(s => s.IdTelemetry == idTelemetry)?.DateEnd.ToUniversalTime() ?? DateTimeOffset.UnixEpoch; - // var statsCount = await CreateStatForTelemetryFromDate(idTelemetry, lastDate, token); - // if(onProgressCallback != null) + // var statsCount = await CreateStatDrillingQualityForTelemetry(idTelemetry, lastDate, token); + // if (onProgressCallback != null) // onProgressCallback($"Calculate stat for telemetry: {idTelemetry}; from {lastDate}; results count: {statsCount};", 1d * i / idTelemetries.Length); //} } - private async Task CreateStatForTelemetryFromDate( + private async Task CreateStatDrillingQualityForTelemetry( int idTelemetry, DateTimeOffset geDate, CancellationToken token) @@ -74,14 +93,20 @@ public class DataSaubStatDrillingQualityService : IDataSaubStatService if (dataSaub is not TelemetryDataSaubDto[] dataSaubArray) dataSaubArray = dataSaub.ToArray(); - var dataSaubStats = CreateDataSaubStat(dataSaubArray); + var result = new List(); + foreach (var item in QualitySettingsForFeedRegulators) + { + var data = CreateDataSaubStatDrillingQuality(item.Key, item.Value, dataSaubArray); + result.AddRange(data); + } - return 0; - - //return await dataSaubStatRepository.InsertRangeAsync(dataSaubStats, token); + return await dataSaubStatDrillingQualityRepository.InsertRangeAsync(result, token); } - private static IEnumerable CreateDataSaubStat2(int idFeedRegulator, TelemetryDataSaubDto[] dataSaub) + private static IEnumerable CreateDataSaubStatDrillingQuality( + int idFeedRegulator, + Predicate checkQuality, + TelemetryDataSaubDto[] dataSaub) { var result = new List(); @@ -100,140 +125,47 @@ public class DataSaubStatDrillingQualityService : IDataSaubStatService indexEnd = dataSaub.Length - 1; if (indexEnd == indexStart) - { continue; - } - var length = indexEnd - indexStart + 1; var subset = dataSaub.AsSpan(indexStart, length); - if (length <= 2 || (subset[^1].WellDepth - subset[0].WellDepth) < 0.001) + if (length <= 2 || (subset[^1].WellDepth - subset[0].WellDepth) < 0.3) continue; // мелкие выборки не учитываем. - var stats = CalcStats(subset); + + var stats = CalcStatsDrillingQuality(idFeedRegulator, subset, checkQuality); result.Add(stats); } return result; } - private static Dictionary> CreateDataSaubStat(TelemetryDataSaubDto[] dataSaub) + private static DataSaubStatDrillingQualityDto CalcStatsDrillingQuality( + int idFeedRegulator, + Span dataSaub, + Predicate predicate + ) { - - var dict = new Dictionary>() { - { 1, new List() }, - { 2, new List() }, - { 3, new List() }, - { 4, new List() }, - }; - - foreach (var item in dict) - { - var data = CreateDataSaubStat2(item.Key, dataSaub); - item.Value.AddRange(data); - } - - return dict; - } - - private static DataSaubStatDrillingQualityDto CalcStats(Span dataSaub) - { - var depthDrillingQuality = CalcAggregate(dataSaub); - var result = new DataSaubStatDrillingQualityDto(); + result.IdTelemetry = dataSaub[0].IdTelemetry; + result.IdFeedRegulator = idFeedRegulator; result.DepthStart = dataSaub[0].WellDepth; result.DepthEnd = dataSaub[^1].WellDepth; result.DateStart = dataSaub[0].DateTime; result.DateEnd = dataSaub[^1].DateTime; + + var depthDrillingQuality = 0.0; + for (var i = 0; i < dataSaub.Length - 1; i++) + { + if (predicate(dataSaub[i])) + { + depthDrillingQuality += dataSaub[i + 1].WellDepth - dataSaub[i].WellDepth; + } + } result.DepthDrillingQuality = depthDrillingQuality; - + return result; } - - private static DataSaubStatDto CalcStat(DetectedOperationDto operation, Span span) - { - var aggregatedValues = CalcAggregate(span); - var dateStart = span[0].DateTime; - var dateEnd = span[^1].DateTime; - var depthStart = span[0].WellDepth; - var depthEnd = span[^1].WellDepth; - var speed = ((depthEnd - depthStart) / (dateEnd - dateStart).TotalHours); - - var processMapDrillingCacheItem = new DataSaubStatDto - { - DateStart = dateStart, - DateEnd = dateEnd, - DepthStart = depthStart, - DepthEnd = depthEnd, - Speed = speed, - BlockSpeedSp = span[0].BlockSpeedSp, - Pressure = aggregatedValues.Pressure, - PressureIdle = span[0].PressureIdle, - PressureSp = span[0].PressureSp, - AxialLoad = aggregatedValues.AxialLoad, - AxialLoadSp = span[0].AxialLoadSp, - AxialLoadLimitMax = span[0].AxialLoadLimitMax, - RotorTorque = aggregatedValues.RotorTorque, - RotorTorqueSp = span[0].RotorTorqueSp, - RotorTorqueLimitMax = span[0].RotorTorqueLimitMax, - IdFeedRegulator = span[0].IdFeedRegulator, - RotorSpeed = aggregatedValues.RotorSpeed, - IdCategory = operation.IdCategory, - EnabledSubsystems = operation.EnabledSubsystems, - HasOscillation = operation.EnabledSubsystems.IsAutoOscillation, - IdTelemetry = operation.IdTelemetry, - Flow = aggregatedValues.Flow - }; - return processMapDrillingCacheItem; - } - - private static ( - double Pressure, - double AxialLoad, - double RotorTorque, - double RotorSpeed, - double Flow - ) CalcAggregate(Span span) - { - var sumPressure = 0.0; - var sumAxialLoad = 0.0; - var sumRotorTorque = 0.0; - var sumRotorSpeed = 0.0; - var flow = span[0].Flow ?? 0.0; - var diffDepthTotal = span[^1].WellDepth - span[0].WellDepth; - for (var i = 0; i < span.Length - 1; i++) - { - var diffDepth = span[i + 1].WellDepth - span[i].WellDepth; - sumPressure += diffDepth * span[i].Pressure; - sumAxialLoad += diffDepth * span[i].AxialLoad; - sumRotorTorque += diffDepth * span[i].RotorTorque; - sumRotorSpeed += diffDepth * span[i].RotorSpeed; - flow = span[i + 1].Flow > flow ? span[i + 1].Flow ?? 0.0 : flow; - } - return ( - Pressure: sumPressure / diffDepthTotal, - AxialLoad: sumAxialLoad / diffDepthTotal, - RotorTorque: sumRotorTorque / diffDepthTotal, - RotorSpeed: sumRotorSpeed / diffDepthTotal, - Flow: flow - ); - } - - private static bool IsNewCacheItem(TelemetryDataSaubDto previous, TelemetryDataSaubDto current) - { - return !(current.Mode == previous.Mode) - || !(current.WellDepth >= previous.WellDepth) - || !(current.BlockSpeedSp == previous.BlockSpeedSp) - || !(current.PressureIdle == previous.PressureIdle) - || !(current.PressureSp == previous.PressureSp) - || !(current.AxialLoadSp == previous.AxialLoadSp) - || !(current.AxialLoadLimitMax == previous.AxialLoadLimitMax) - || !(current.HookWeightIdle == previous.HookWeightIdle) - || !(current.RotorTorqueIdle == previous.RotorTorqueIdle) - || !(current.RotorTorqueSp == previous.RotorTorqueSp) - || !(current.RotorTorqueLimitMax == previous.RotorTorqueLimitMax) - || !(current.IdFeedRegulator == previous.IdFeedRegulator); - } } diff --git a/AsbCloudInfrastructure/Services/DataSaubStatService.cs b/AsbCloudInfrastructure/Services/DataSaubStatService.cs index f1722ba5..82ee0416 100644 --- a/AsbCloudInfrastructure/Services/DataSaubStatService.cs +++ b/AsbCloudInfrastructure/Services/DataSaubStatService.cs @@ -1,4 +1,4 @@ -using AsbCloudApp.Data.DataSaubStat; +using AsbCloudApp.Data; using AsbCloudApp.Data.DetectedOperation; using AsbCloudApp.Data.SAUB; using AsbCloudApp.Repositories; diff --git a/AsbCloudInfrastructure/Services/ProcessMaps/Report/ProcessMapReportDrillingService.cs b/AsbCloudInfrastructure/Services/ProcessMaps/Report/ProcessMapReportDrillingService.cs index 574a320e..cae5bdce 100644 --- a/AsbCloudInfrastructure/Services/ProcessMaps/Report/ProcessMapReportDrillingService.cs +++ b/AsbCloudInfrastructure/Services/ProcessMaps/Report/ProcessMapReportDrillingService.cs @@ -1,5 +1,4 @@ using AsbCloudApp.Data; -using AsbCloudApp.Data.DataSaubStat; using AsbCloudApp.Data.ProcessMaps; using AsbCloudApp.Data.ProcessMaps.Operations; using AsbCloudApp.Data.ProcessMaps.Report; diff --git a/AsbCloudWebApi.IntegrationTests/Repository/DataSaubStatRepositoryTest.cs b/AsbCloudWebApi.IntegrationTests/Repository/DataSaubStatRepositoryTest.cs index 7919a445..e69cc692 100644 --- a/AsbCloudWebApi.IntegrationTests/Repository/DataSaubStatRepositoryTest.cs +++ b/AsbCloudWebApi.IntegrationTests/Repository/DataSaubStatRepositoryTest.cs @@ -1,4 +1,4 @@ -using AsbCloudApp.Data.DataSaubStat; +using AsbCloudApp.Data; using AsbCloudApp.Repositories; using AsbCloudDb.Model; using Mapster;