From 1dadc968828d5e89209491a8684e7abf5bd8d171 Mon Sep 17 00:00:00 2001 From: KharchenkoVV Date: Tue, 20 Jul 2021 11:50:35 +0500 Subject: [PATCH] =?UTF-8?q?=D0=97=D0=B0=D0=BC=D0=B5=D0=BD=D0=B5=D0=BD?= =?UTF-8?q?=D1=8B=20"Hours"=20=D0=BD=D0=B0=20"Seconds"=20=D0=B2=20=D0=B8?= =?UTF-8?q?=D0=BC=D0=B5=D0=BD=D0=B0=D1=85=20Unix=20timestamp=20=D0=BF?= =?UTF-8?q?=D0=B0=D1=80=D0=B0=D0=BC=D0=B5=D1=82=D1=80=D0=BE=D0=B2.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Services/AnalyticsService.cs | 16 ++++++++-------- .../Controllers/AnalyticsController.cs | 18 +++++++++--------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/AsbCloudInfrastructure/Services/AnalyticsService.cs b/AsbCloudInfrastructure/Services/AnalyticsService.cs index 31551b97..6e9a0f5b 100644 --- a/AsbCloudInfrastructure/Services/AnalyticsService.cs +++ b/AsbCloudInfrastructure/Services/AnalyticsService.cs @@ -59,9 +59,9 @@ namespace AsbCloudInfrastructure.Services } public IEnumerable GetWellDepthToInterval(int wellId, - int intervalHoursTimestamp, int workBeginTimestamp) + int intervalSeconds, int workBeginSeconds) { - intervalHoursTimestamp = intervalHoursTimestamp == 0 ? 86400 : intervalHoursTimestamp; + intervalSeconds = intervalSeconds == 0 ? 86400 : intervalSeconds; var telemetry = telemetryService.GetTelemetryByWellId(wellId); @@ -70,13 +70,13 @@ namespace AsbCloudInfrastructure.Services var timezoneOffset = telemetryService.GetTimezoneOffsetByTelemetryId(telemetry.Id); - var drillingPeriodsInfo = db.GetDepthToInterval(telemetry.Id, intervalHoursTimestamp, - workBeginTimestamp, timezoneOffset); + var drillingPeriodsInfo = db.GetDepthToInterval(telemetry.Id, intervalSeconds, + workBeginSeconds, timezoneOffset); var wellDepthToIntervalData = drillingPeriodsInfo.Select(d => new WellDepthToIntervalDto { IntervalStartDate = d.BeginPeriodDate, - IntervalDepthProgress = (d.MaxDepth - d.MinDepth) ?? 0.0 / intervalHoursTimestamp + IntervalDepthProgress = (d.MaxDepth - d.MinDepth) ?? 0.0 / intervalSeconds }).OrderBy(d => d.IntervalStartDate).ToList(); return wellDepthToIntervalData; @@ -110,9 +110,9 @@ namespace AsbCloudInfrastructure.Services } public IEnumerable GetOperationsToInterval(int wellId, - int intervalHoursTimestamp, int workBeginTimestamp) + int intervalSeconds, int workBeginSeconds) { - intervalHoursTimestamp = intervalHoursTimestamp == 0 ? 86400 : intervalHoursTimestamp; + intervalSeconds = intervalSeconds == 0 ? 86400 : intervalSeconds; var telemetry = telemetryService.GetTelemetryByWellId(wellId); @@ -126,7 +126,7 @@ namespace AsbCloudInfrastructure.Services a.IdOperation != null join o in db.Operations on a.IdOperation equals o.Id group a by new { - Interval = Math.Floor((a.UnixDate - workBeginTimestamp + timezoneOffset) / intervalHoursTimestamp), + Interval = Math.Floor((a.UnixDate - workBeginSeconds + timezoneOffset) / intervalSeconds), OperationId = a.IdOperation, o.Name } into g select new diff --git a/AsbCloudWebApi/Controllers/AnalyticsController.cs b/AsbCloudWebApi/Controllers/AnalyticsController.cs index ef246888..e7947017 100644 --- a/AsbCloudWebApi/Controllers/AnalyticsController.cs +++ b/AsbCloudWebApi/Controllers/AnalyticsController.cs @@ -49,22 +49,22 @@ namespace AsbCloudWebApi.Controllers /// Возвращает данные по глубине скважины за период /// /// id скважины - /// количество секунд в необходимом интервале времени - /// количество секунд в времени начала смены + /// количество секунд в необходимом интервале времени + /// количество секунд в времени начала смены /// Коллекцию данных по глубине скважины за период [HttpGet] [Route("{wellId}/wellDepthToInterval")] [ProducesResponseType(typeof(IEnumerable), (int)System.Net.HttpStatusCode.OK)] public IActionResult GetWellDepthToInterval(int wellId, - int intervalHoursTimestamp, int workBeginTimestamp) + int intervalSeconds, int workBeginSeconds) { int? idCustomer = User.GetCustomerId(); if (idCustomer is null || !wellService.CheckWellOwnership((int)idCustomer, wellId)) return Forbid(); - var wellDepthToIntervalData = analyticsService.GetWellDepthToInterval(wellId, - intervalHoursTimestamp, workBeginTimestamp); + var wellDepthToIntervalData = analyticsService.GetWellDepthToInterval(wellId, + intervalSeconds, workBeginSeconds); if (wellDepthToIntervalData is null || !wellDepthToIntervalData.Any()) return NoContent(); @@ -101,22 +101,22 @@ namespace AsbCloudWebApi.Controllers /// Возвращает детальные данные по операциям на скважине за период /// /// id скважины - /// количество секунд в необходимом интервале времени - /// количество секунд в времени начала смены + /// количество секунд в необходимом интервале времени + /// количество секунд в времени начала смены /// Коллекцию операций на скважине [HttpGet] [Route("{wellId}/operationsToInterval")] [ProducesResponseType(typeof(IEnumerable), (int)System.Net.HttpStatusCode.OK)] public IActionResult GetOperationsToInterval(int wellId, - int intervalHoursTimestamp, int workBeginTimestamp) + int intervalSeconds, int workBeginSeconds) { int? idCustomer = User.GetCustomerId(); if (idCustomer is null || !wellService.CheckWellOwnership((int)idCustomer, wellId)) return Forbid(); - var analytics = analyticsService.GetOperationsToInterval(wellId, intervalHoursTimestamp, workBeginTimestamp); + var analytics = analyticsService.GetOperationsToInterval(wellId, intervalSeconds, workBeginSeconds); if (analytics is null || !analytics.Any()) return NoContent();