From 5259a1c7307b6c15c3bfbfd75c41ae22f9471906 Mon Sep 17 00:00:00 2001 From: KharchenkoVV Date: Fri, 25 Jun 2021 15:10:05 +0500 Subject: [PATCH] =?UTF-8?q?CS2-24:=20=D0=9F=D1=80=D0=B0=D0=B2=D0=BA=D0=B8?= =?UTF-8?q?=20=D0=BA=20=D0=BF=D1=80=D0=B5=D0=B4=D1=8B=D0=B4=D1=83=D1=89?= =?UTF-8?q?=D0=B8=D0=BC=203=20=D0=BA=D0=BE=D0=BC=D0=BC=D0=B8=D1=82=D0=B0?= =?UTF-8?q?=D0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AsbCloudApp/Data/WellDepthToDayDto.cs | 4 +- AsbCloudApp/Services/IAnalyticsService.cs | 2 +- AsbCloudApp/Services/ISaubDataCache.cs | 3 +- AsbCloudApp/Services/ITelemetryService.cs | 1 + AsbCloudDb/Model/AsbCloudDbContext.cs | 2 +- AsbCloudDb/Model/IAsbCloudDbContext.cs | 2 +- AsbCloudInfrastructure/DependencyInjection.cs | 2 +- .../Services/AnalyticsService.cs | 112 ++++++++++-------- .../Services/DataService.cs | 20 +--- ...ntainer.cs => OperationDetectorService.cs} | 12 +- .../Services/SaubDataCache.cs | 30 +++++ .../Services/SaubEventsCache.cs | 15 --- .../Services/TelemetryService.cs | 3 + .../Controllers/AnalyticsController.cs | 12 +- 14 files changed, 121 insertions(+), 99 deletions(-) rename AsbCloudInfrastructure/Services/{OperationDetectorsContainer.cs => OperationDetectorService.cs} (93%) create mode 100644 AsbCloudInfrastructure/Services/SaubDataCache.cs delete mode 100644 AsbCloudInfrastructure/Services/SaubEventsCache.cs diff --git a/AsbCloudApp/Data/WellDepthToDayDto.cs b/AsbCloudApp/Data/WellDepthToDayDto.cs index 7b4bc175..2fddc8b8 100644 --- a/AsbCloudApp/Data/WellDepthToDayDto.cs +++ b/AsbCloudApp/Data/WellDepthToDayDto.cs @@ -4,8 +4,8 @@ namespace AsbCloudApp.Data { public class WellDepthToDayDto { - public double? WellDepth { get; set; } - public double? BitDepth { get; set; } + public double WellDepth { get; set; } + public double BitDepth { get; set; } public DateTime Date { get; set; } } } diff --git a/AsbCloudApp/Services/IAnalyticsService.cs b/AsbCloudApp/Services/IAnalyticsService.cs index dccfd467..735c545f 100644 --- a/AsbCloudApp/Services/IAnalyticsService.cs +++ b/AsbCloudApp/Services/IAnalyticsService.cs @@ -9,7 +9,7 @@ namespace AsbCloudApp.Services { IEnumerable GetWellDepthToDay(int wellId); IEnumerable GetWellDepthToInterval(int wellId, - int intervalHours = 24, int intervalMinutes = 0, int beginHour = 8, int beginMinutes = 0); + int intervalHoursTimestamp, int workBeginTimestamp); IEnumerable GetOperationsSummary(int wellId, DateTime begin = default, DateTime end = default); IEnumerable GetOperationsToTime(int wellId, diff --git a/AsbCloudApp/Services/ISaubDataCache.cs b/AsbCloudApp/Services/ISaubDataCache.cs index 0f01fd49..60fa3710 100644 --- a/AsbCloudApp/Services/ISaubDataCache.cs +++ b/AsbCloudApp/Services/ISaubDataCache.cs @@ -5,6 +5,7 @@ namespace AsbCloudApp.Services { public interface ISaubDataCache { - Dictionary> GetSaubData(); + IEnumerable GetOrCreateCache(int telemetryId); + void AddData(DataSaubBase data); } } diff --git a/AsbCloudApp/Services/ITelemetryService.cs b/AsbCloudApp/Services/ITelemetryService.cs index 91abbfc4..192d38d1 100644 --- a/AsbCloudApp/Services/ITelemetryService.cs +++ b/AsbCloudApp/Services/ITelemetryService.cs @@ -7,6 +7,7 @@ namespace AsbCloudApp.Services { int? GetWellIdByTelemetryUid(string uid); int GetOrCreateTemetryIdByUid(string uid); + double GetTimezoneOffsetByTelemetryId(int idTelemetry); void UpdateInfo(string uid, TelemetryInfoDto info); Telemetry GetTelemetryByWellId(int wellId); } diff --git a/AsbCloudDb/Model/AsbCloudDbContext.cs b/AsbCloudDb/Model/AsbCloudDbContext.cs index c762892a..69175f00 100644 --- a/AsbCloudDb/Model/AsbCloudDbContext.cs +++ b/AsbCloudDb/Model/AsbCloudDbContext.cs @@ -255,7 +255,7 @@ namespace AsbCloudDb.Model return (datesRange.From, datesRange.To); } - public IEnumerable<(double?, double?, DateTime)> GetDepthToInterval (int telemetryId, + public IEnumerable<(double? MinDepth, double? MaxDepth, DateTime BeginPeriodDate)> GetDepthToInterval (int telemetryId, int intervalHoursTimestamp, int workStartTimestamp, double timezoneOffset) { //TODO: Сменить на LINQ группирование diff --git a/AsbCloudDb/Model/IAsbCloudDbContext.cs b/AsbCloudDb/Model/IAsbCloudDbContext.cs index 1341bf61..9b5958a0 100644 --- a/AsbCloudDb/Model/IAsbCloudDbContext.cs +++ b/AsbCloudDb/Model/IAsbCloudDbContext.cs @@ -31,7 +31,7 @@ namespace AsbCloudDb.Model IQueryable GetWellsByCustomer(int idCustomer); IQueryable GetUsersByLogin(string login); (DateTime From, DateTime To) GetDatesRange(int idTelemetry) where T : class, IIdTelemetryDate; - IEnumerable<(double?, double?, DateTime)> GetDepthToInterval(int telemetryId, + IEnumerable<(double? MinDepth, double? MaxDepth, DateTime BeginPeriodDate)> GetDepthToInterval(int telemetryId, int intervalHoursTimestamp, int workStartTimestamp, double timezoneOffset); Task CreatePartitionAsync(string propertyName, int id, CancellationToken token = default) where TEntity : class; } diff --git a/AsbCloudInfrastructure/DependencyInjection.cs b/AsbCloudInfrastructure/DependencyInjection.cs index 62c481ba..488b0f10 100644 --- a/AsbCloudInfrastructure/DependencyInjection.cs +++ b/AsbCloudInfrastructure/DependencyInjection.cs @@ -25,7 +25,7 @@ namespace AsbCloudInfrastructure services.AddSingleton(new CacheDb()); services.AddSingleton(); services.AddSingleton(); - services.AddSingleton(); + services.AddSingleton(); services.AddTransient(); services.AddTransient(); diff --git a/AsbCloudInfrastructure/Services/AnalyticsService.cs b/AsbCloudInfrastructure/Services/AnalyticsService.cs index 5293e987..ed8e4233 100644 --- a/AsbCloudInfrastructure/Services/AnalyticsService.cs +++ b/AsbCloudInfrastructure/Services/AnalyticsService.cs @@ -12,19 +12,17 @@ namespace AsbCloudInfrastructure.Services { private readonly IAsbCloudDbContext db; private readonly ITelemetryService telemetryService; - private readonly CacheTable cacheTelemetry; private readonly CacheTable cacheOperations; - private readonly IEnumerable operationDetectors; + private readonly OperationDetectorService operationDetectorService; private readonly IEnumerable operations; public AnalyticsService(IAsbCloudDbContext db, ITelemetryService telemetryService, CacheDb cacheDb) { this.db = db; this.telemetryService = telemetryService; - cacheTelemetry = cacheDb.GetCachedTable((AsbCloudDbContext)db); cacheOperations = cacheDb.GetCachedTable((AsbCloudDbContext)db); operations = cacheOperations.Select(c => true); - operationDetectors = new OperationDetectorsContainer(operations).Detectors; + operationDetectorService = new OperationDetectorService(operations); } public IEnumerable GetWellDepthToDay(int wellId) @@ -51,36 +49,34 @@ namespace AsbCloudInfrastructure.Services return depthToTimeData.Select(d => new WellDepthToDayDto { - WellDepth = d.WellDepth, - BitDepth = d.BitDepth, + WellDepth = d.WellDepth ?? 0.0, + BitDepth = d.BitDepth ?? 0.0, Date = d.Date }).ToList(); } public IEnumerable GetWellDepthToInterval(int wellId, - int intervalHours = 24, int intervalMinutes = 0, int workBeginHour = 8, int workBeginMinutes = 0) + int intervalHoursTimestamp, int workBeginTimestamp) { - var intervalTime = new TimeSpan(intervalHours, intervalMinutes, 0) == default - ? new TimeSpan(24, 0, 0) - : new TimeSpan(intervalHours, intervalMinutes, 0); - var workDayBeginTime = new TimeSpan(workBeginHour, workBeginMinutes, 0) == default - ? new TimeSpan(8, 0, 0) - : new TimeSpan(intervalHours, intervalMinutes, 0); ; + intervalHoursTimestamp = intervalHoursTimestamp == 0 ? 86400 : intervalHoursTimestamp; + + var intervalTime = new TimeSpan(0, 0, intervalHoursTimestamp); + var workDayBeginTime = new TimeSpan(0, 0, workBeginTimestamp); var telemetry = telemetryService.GetTelemetryByWellId(wellId); if (telemetry is null) return null; - var timezoneOffset = cacheTelemetry.FirstOrDefault(t => t.Id == telemetry.Id).Info.TimeZoneOffsetTotalHours; + var timezoneOffset = telemetryService.GetTimezoneOffsetByTelemetryId(telemetry.Id); var drillingPeriodsInfo = db.GetDepthToInterval(telemetry.Id, (int)intervalTime.TotalSeconds, (int)workDayBeginTime.TotalSeconds, timezoneOffset); var wellDepthToIntervalData = drillingPeriodsInfo.Select(d => new WellDepthToIntervalDto { - IntervalStartDate = d.Item3, - IntervalDepthProgress = (d.Item2 - d.Item1) ?? 0.0 / intervalHours + IntervalStartDate = d.BeginPeriodDate, + IntervalDepthProgress = (d.MaxDepth - d.MinDepth) ?? 0.0 / intervalHoursTimestamp }).OrderBy(d => d.IntervalStartDate).ToList(); return wellDepthToIntervalData; @@ -226,12 +222,24 @@ namespace AsbCloudInfrastructure.Services public DrillingAnalysis GetDrillingAnalysis(IEnumerable dataSaubBases) { - var saubWellDepths = dataSaubBases.Select(s => s.WellDepth); - var saubBitDepths = dataSaubBases.Select(s => s.BitDepth); - var saubBlockPositions = dataSaubBases.Select(s => s.BlockPosition); - var saubRotorSpeeds = dataSaubBases.Select(s => s.RotorSpeed); - var saubPressures = dataSaubBases.Select(s => s.Pressure); - var saubHookWeights = dataSaubBases.Select(s => s.HookWeight); + var saubWellDepths = dataSaubBases.Select(s => (s.WellDepth, + TotalSeconds: (s.Date - + new DateTime(1970, 1, 1, 0, 0, 0)).TotalSeconds - 1530000000)); + var saubBitDepths = dataSaubBases.Select(s => (s.BitDepth, + TotalSeconds: (s.Date - + new DateTime(1970, 1, 1, 0, 0, 0)).TotalSeconds - 1530000000)); + var saubBlockPositions = dataSaubBases.Select(s => (s.BlockPosition, + TotalSeconds: (s.Date - + new DateTime(1970, 1, 1, 0, 0, 0)).TotalSeconds - 1530000000)); + var saubRotorSpeeds = dataSaubBases.Select(s => (s.RotorSpeed, + TotalSeconds: (s.Date - + new DateTime(1970, 1, 1, 0, 0, 0)).TotalSeconds - 1530000000)); + var saubPressures = dataSaubBases.Select(s => (s.Pressure, + TotalSeconds: (s.Date - + new DateTime(1970, 1, 1, 0, 0, 0)).TotalSeconds - 1530000000)); + var saubHookWeights = dataSaubBases.Select(s => (s.HookWeight, + TotalSeconds: (s.Date - + new DateTime(1970, 1, 1, 0, 0, 0)).TotalSeconds - 1530000000)); var wellDepthChangingIndex = GetAForLinearFormula(saubWellDepths); var bitPositionChangingIndex = GetAForLinearFormula(saubBitDepths); @@ -244,38 +252,30 @@ namespace AsbCloudInfrastructure.Services { IdTelemetry = dataSaubBases.First().IdTelemetry, Date = dataSaubBases.Last().Date, - IsDepthChanges = wellDepthChangingIndex >= 1.0 || wellDepthChangingIndex <= -1.0, - IsDepthNotChanges = wellDepthChangingIndex < 1.0 && wellDepthChangingIndex > -1.0, - IsBitRising = bitPositionChangingIndex <= -1.0, - IsBitGoesDown = bitPositionChangingIndex >= 1.0, - IsBitStandsStill = bitPositionChangingIndex < 1.0 && bitPositionChangingIndex > -1.0, - IsBitDepthLess20 = (saubBitDepths.Sum() / saubBitDepths.Count()) < 20.0, - IsBlockRising = blockPositionChangingIndex <= -1.0, - IsBlockGoesDown = blockPositionChangingIndex >= 1.0, - IsBlockStandsStill = blockPositionChangingIndex < 1.0 && blockPositionChangingIndex > -1.0, - IsRotorSpeedLess3 = (saubRotorSpeeds.Sum() / saubRotorSpeeds.Count()) < 3.0, - IsRotorSpeedMore3 = (saubRotorSpeeds.Sum() / saubRotorSpeeds.Count()) >= 3.0, - IsPressureLess20 = (saubPressures.Sum() / saubPressures.Count()) < 20.0, - IsPressureMore20 = (saubPressures.Sum() / saubPressures.Count()) >= 20.0, - IsHookWeightNotChanges = hookWeightChangingIndex < 1.0 && hookWeightChangingIndex > 1.0, - IsHookWeightLess3 = (saubHookWeights.Sum() / saubHookWeights.Count()) < 3.0, + IsDepthChanges = wellDepthChangingIndex >= 0.0001 || wellDepthChangingIndex <= -0.0001, + IsDepthNotChanges = wellDepthChangingIndex < 0.0001 && wellDepthChangingIndex > -0.0001, + IsBitRising = bitPositionChangingIndex >= 0.0001, + IsBitGoesDown = bitPositionChangingIndex <= -0.0001, + IsBitStandsStill = bitPositionChangingIndex < 0.0001 && bitPositionChangingIndex > -0.0001, + IsBitDepthLess20 = (saubBitDepths.Sum(s => s.BitDepth) / saubBitDepths.Count()) < 20.0, + IsBlockRising = blockPositionChangingIndex >= 0.0001, + IsBlockGoesDown = blockPositionChangingIndex <= -0.0001, + IsBlockStandsStill = blockPositionChangingIndex < 0.001 && blockPositionChangingIndex > -0.0001, + IsRotorSpeedLess3 = (saubRotorSpeeds.Sum(s => s.RotorSpeed) / saubRotorSpeeds.Count()) < 3, + IsRotorSpeedMore3 = (saubRotorSpeeds.Sum(s => s.RotorSpeed) / saubRotorSpeeds.Count()) >= 3, + IsPressureLess20 = (saubPressures.Sum(s => s.Pressure) / saubPressures.Count()) < 20.0, + IsPressureMore20 = (saubPressures.Sum(s => s.Pressure) / saubPressures.Count()) >= 20.0, + IsHookWeightNotChanges = hookWeightChangingIndex < 0.0001 && hookWeightChangingIndex > 0.0001, + IsHookWeightLess3 = (saubHookWeights.Sum(s => s.HookWeight) / saubHookWeights.Count()) < 3.0, IdOperation = 1 }; - drillingAnalysis.IdOperation = GetOperation(drillingAnalysis).Id; + drillingAnalysis.IdOperation = operationDetectorService.DetectOperation(drillingAnalysis).Id; return drillingAnalysis; } - private Operation GetOperation(DrillingAnalysis data) - { - var operation = operationDetectors.OrderBy(d => d.Order).First(o => o.Detect(data)).Operation - ?? new Operation { Id = 1, Name = "Невозможно определить операцию" }; - - return operations.FirstOrDefault(o => o.Name.Equals(operation.Name)); - } - - private static double GetAForLinearFormula(IEnumerable rawData) + private static double GetAForLinearFormula(IEnumerable<(double?, double)> rawData) { var (xSum, ySum, xySum, x2Sum) = GetFormulaVariables(rawData); @@ -283,13 +283,21 @@ namespace AsbCloudInfrastructure.Services (xSum * xSum - rawData.Count() * x2Sum); } - private static (int xSum, double ySum, double xySum, int x2Sum) GetFormulaVariables( - IEnumerable rawData) + private static double GetBForLinearFormula(IEnumerable<(double?, double)> rawData) { - var data = rawData.Select((d, i) => new + var (xSum, ySum, xySum, x2Sum) = GetFormulaVariables(rawData); + + return (xSum * xySum - x2Sum * ySum) / + (xSum * xSum - rawData.Count() * x2Sum); + } + + private static (double xSum, double ySum, double xySum, double x2Sum) GetFormulaVariables( + IEnumerable<(double? value, double timestamp)> rawData) + { + var data = rawData.Select((d) => new { - X = i, - Y = d ?? 0.0 + X = d.timestamp, + Y = d.value ?? 0.0 }); var xSum = data.Sum(d => d.X); var ySum = data.Sum(d => d.Y); diff --git a/AsbCloudInfrastructure/Services/DataService.cs b/AsbCloudInfrastructure/Services/DataService.cs index d8ecaf59..a1d472f1 100644 --- a/AsbCloudInfrastructure/Services/DataService.cs +++ b/AsbCloudInfrastructure/Services/DataService.cs @@ -14,19 +14,19 @@ namespace AsbCloudInfrastructure.Services private readonly IAsbCloudDbContext db; private readonly ITelemetryService telemetryService; private readonly IAnalyticsService analyticsService; - private readonly ISaubDataCache saubEventsCache; + private readonly ISaubDataCache saubDataCache; private readonly IMapper mapper; private readonly CacheTable cacheTelemetry; private readonly CacheTable cacheWells; public DataService(IAsbCloudDbContext db, ITelemetryService telemetryService, - IAnalyticsService analyticsService, ISaubDataCache saubEventsCache, + IAnalyticsService analyticsService, ISaubDataCache saubDataCache, CacheDb cacheDb, MapperConfiguration mapperConfiguration) { this.db = db; this.telemetryService = telemetryService; this.analyticsService = analyticsService; - this.saubEventsCache = saubEventsCache; + this.saubDataCache = saubDataCache; mapper = mapperConfiguration.CreateMapper(); cacheTelemetry = cacheDb.GetCachedTable((AsbCloudDbContext)db); cacheWells = cacheDb.GetCachedTable((AsbCloudDbContext)db); @@ -99,20 +99,12 @@ namespace AsbCloudInfrastructure.Services dataSaub.IdTelemetry = telemetryId; db.DataSaubBases.Add(dataSaub); - if (!saubEventsCache.GetSaubData().ContainsKey(dataSaub.IdTelemetry)) - saubEventsCache.GetSaubData()[dataSaub.IdTelemetry] = new List(); + saubDataCache.AddData(dataSaub); - var cachedSaubData = saubEventsCache.GetSaubData()[dataSaub.IdTelemetry]; - - cachedSaubData.Add(dataSaub); - - if (cachedSaubData.Count > 1) + if (saubDataCache.GetOrCreateCache(dataSaub.IdTelemetry).Count() > 1) { - if (cachedSaubData.Count > 10) - cachedSaubData.RemoveAt(1); - var drillingAnalysis = analyticsService.GetDrillingAnalysis( - cachedSaubData); + saubDataCache.GetOrCreateCache(dataSaub.IdTelemetry)); db.DrillingAnalysis.Add(drillingAnalysis); } diff --git a/AsbCloudInfrastructure/Services/OperationDetectorsContainer.cs b/AsbCloudInfrastructure/Services/OperationDetectorService.cs similarity index 93% rename from AsbCloudInfrastructure/Services/OperationDetectorsContainer.cs rename to AsbCloudInfrastructure/Services/OperationDetectorService.cs index bbec1bf9..f9d72218 100644 --- a/AsbCloudInfrastructure/Services/OperationDetectorsContainer.cs +++ b/AsbCloudInfrastructure/Services/OperationDetectorService.cs @@ -4,13 +4,13 @@ using AsbCloudDb.Model; namespace AsbCloudInfrastructure.Services { - public class OperationDetectorsContainer + public class OperationDetectorService { - public IEnumerable Detectors; + private readonly IEnumerable detectors; - public OperationDetectorsContainer(IEnumerable operations) + public OperationDetectorService(IEnumerable operations) { - Detectors = new List() + detectors = new List() { new OperationDetector { @@ -159,5 +159,9 @@ namespace AsbCloudInfrastructure.Services } }; } + + public Operation DetectOperation(DrillingAnalysis data) => + detectors.OrderBy(d => d.Order).First(o => o.Detect(data)).Operation + ?? new Operation { Id = 1, Name = "Невозможно определить операцию" }; } } diff --git a/AsbCloudInfrastructure/Services/SaubDataCache.cs b/AsbCloudInfrastructure/Services/SaubDataCache.cs new file mode 100644 index 00000000..3621a6dc --- /dev/null +++ b/AsbCloudInfrastructure/Services/SaubDataCache.cs @@ -0,0 +1,30 @@ +using System.Collections.Generic; +using AsbCloudApp.Services; +using AsbCloudDb.Model; + +namespace AsbCloudInfrastructure.Services +{ + public class SaubDataCache : ISaubDataCache + { + private readonly Dictionary> saubData = + new Dictionary>(); + + public IEnumerable GetOrCreateCache(int telemetryId) + { + if (!saubData.ContainsKey(telemetryId)) + saubData[telemetryId] = new List(); + + return saubData[telemetryId]; + } + + public void AddData(DataSaubBase data) + { + GetOrCreateCache(data.IdTelemetry); + + saubData[data.IdTelemetry].Add(data); + + if (saubData[data.IdTelemetry].Count > 10) + saubData[data.IdTelemetry].RemoveAt(1); + } + } +} diff --git a/AsbCloudInfrastructure/Services/SaubEventsCache.cs b/AsbCloudInfrastructure/Services/SaubEventsCache.cs deleted file mode 100644 index f265e4ce..00000000 --- a/AsbCloudInfrastructure/Services/SaubEventsCache.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System.Collections.Generic; -using AsbCloudApp.Services; -using AsbCloudDb.Model; - -namespace AsbCloudInfrastructure.Services -{ - public class SaubEventsCache : ISaubDataCache - { - private readonly Dictionary> saubData = - new Dictionary>(); - - public Dictionary> GetSaubData() => - saubData; - } -} diff --git a/AsbCloudInfrastructure/Services/TelemetryService.cs b/AsbCloudInfrastructure/Services/TelemetryService.cs index d03b5f3c..9151987a 100644 --- a/AsbCloudInfrastructure/Services/TelemetryService.cs +++ b/AsbCloudInfrastructure/Services/TelemetryService.cs @@ -25,6 +25,9 @@ namespace AsbCloudInfrastructure.Services public int? GetWellIdByTelemetryUid(string uid) => GetWellByTelemetryUid(uid)?.Id; + public double GetTimezoneOffsetByTelemetryId(int idTelemetry) => + cacheTelemetry.FirstOrDefault(t => t.Id == idTelemetry).Info.TimeZoneOffsetTotalHours; + public void UpdateInfo(string uid, TelemetryInfoDto info) { var telemetry = GetOrCreateTelemetryByUid(uid); diff --git a/AsbCloudWebApi/Controllers/AnalyticsController.cs b/AsbCloudWebApi/Controllers/AnalyticsController.cs index 8ffb62c4..d0142912 100644 --- a/AsbCloudWebApi/Controllers/AnalyticsController.cs +++ b/AsbCloudWebApi/Controllers/AnalyticsController.cs @@ -48,15 +48,13 @@ namespace AsbCloudWebApi.Controllers /// Возвращает данные по глубине скважины за период /// /// id скважины - /// количество часов в интервале выборки - /// количество минут в интервале выборки - /// время начала рабочей смены (в часах) - /// время начала рабочей смены (в минутах) + /// количество секунд в необходимом интервале времени + /// количество секунд в времени начала смены /// Коллекцию данных по глубине скважины за период [HttpGet] [Route("{wellId}/wellDepthToInterval")] [ProducesResponseType(typeof(IEnumerable), (int)System.Net.HttpStatusCode.OK)] - public IActionResult GetWellDepthToInterval(int wellId, int intervalHours, int intervalMinutes, int workBeginHour, int workBeginMinutes) + public IActionResult GetWellDepthToInterval(int wellId, int intervalHoursTimestamp, int workBeginTimestamp) { int? idCustomer = User.GetCustomerId(); @@ -66,7 +64,7 @@ namespace AsbCloudWebApi.Controllers if (!wellService.CheckWellOwnership((int)idCustomer, wellId)) return Forbid(); - var wellDepthToIntervalData = analyticsService.GetWellDepthToInterval(wellId, intervalHours, intervalMinutes, workBeginHour, workBeginMinutes); + var wellDepthToIntervalData = analyticsService.GetWellDepthToInterval(wellId, intervalHoursTimestamp, workBeginTimestamp); return Ok(wellDepthToIntervalData); } @@ -117,7 +115,7 @@ namespace AsbCloudWebApi.Controllers if (!wellService.CheckWellOwnership((int)idCustomer, wellId)) return Forbid(); - var analytics = GetOperationsToTime(wellId, begin, end); + var analytics = analyticsService.GetOperationsToTime(wellId, begin, end); return Ok(analytics); }