using AsbCloudApp.Data; using AsbCloudApp.Data.ProcessMap; using AsbCloudApp.Data.SAUB; using AsbCloudApp.Exceptions; using AsbCloudApp.Repositories; using AsbCloudApp.Requests; using AsbCloudApp.Services; using AsbCloudApp.Services.Subsystems; using AsbCloudDb.Model; using AsbCloudApp.Data.Subsystems; using System; using System.Collections.Generic; using System.Linq; using System.Threading; using System.Threading.Tasks; namespace AsbCloudInfrastructure.Services.ProcessMap { #nullable enable public partial class ProcessMapReportService : IProcessMapReportService { private readonly IWellService wellService; private readonly IWellOperationRepository wellOperationRepository; private readonly IProcessMapPlanRepository processMapPlanRepository; private readonly ITelemetryDataSaubService telemetryDataSaubService; private readonly ILimitingParameterRepository limitingParameterRepository; private readonly ISubsystemOperationTimeService subsystemOperationTimeService; public ProcessMapReportService( IWellService wellService, IWellOperationRepository wellOperationService, IProcessMapPlanRepository processMapPlanRepository, ITelemetryDataSaubService telemetryDataSaubService, ILimitingParameterRepository limitingParameterRepository, ISubsystemOperationTimeService subsystemOperationTimeService) { this.wellService = wellService; this.wellOperationRepository = wellOperationService; this.processMapPlanRepository = processMapPlanRepository; this.telemetryDataSaubService = telemetryDataSaubService; this.limitingParameterRepository = limitingParameterRepository; this.subsystemOperationTimeService = subsystemOperationTimeService; } /// public async Task> GetProcessMapAsync(int idWell, CancellationToken token) { var well = wellService.GetOrDefault(idWell) ?? throw new ArgumentInvalidException("idWell not found", nameof(idWell)); var idTelemetry = well.IdTelemetry ?? throw new ArgumentInvalidException("telemetry by well not found", nameof(idWell)); var processMapPlan = await processMapPlanRepository.GetByIdWellAsync(idWell, token); if(!processMapPlan.Any()) return Enumerable.Empty(); var telemetryDataStat = await telemetryDataSaubService.GetTelemetryDataStatAsync(idTelemetry, token); var result = CalcByIntervals(processMapPlan, telemetryDataStat); return result; } private IEnumerable CalcByIntervals(IEnumerable processMapPlan, IEnumerable telemetryDataStat) { var result = new List(processMapPlan.Count() * 4); var intervals = GetProcessMapIntervals(processMapPlan); return result; } private IEnumerable<(double, double)> GetProcessMapIntervals(IEnumerable processMapPlan) { return Enumerable.Empty<(double, double)>(); } private static DateTime GetInterpolatedDate(WellOperationDto operation, double depth) { var ratio = (depth - operation.DepthStart) / (operation.DepthEnd - operation.DepthStart); var deltaHours = operation.DurationHours * ratio; var interpolatedDate = operation.DateStart + TimeSpan.FromHours(deltaHours); return interpolatedDate; } private static IEnumerable<(double min, double max)> SplitByIntervals(double min, double max) { const double step = 100; var iMin = min; var iMax = (1 + (int)(min / step)) * step; for (; iMax < max; iMax += step) { yield return (iMin, iMax); iMin = iMax; } yield return (iMin, max); } } #nullable disable }