using System; using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; using AsbCloudApp.Data.ProcessMaps; using AsbCloudApp.Repositories; using AsbCloudApp.Requests; using AsbCloudApp.Services; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; namespace AsbCloudWebApi.Controllers.SAUB; /// /// Данные РТК для SAUB /// [ApiController] [Route("api/[controller]")] public class TelemetryProcessMapController : ControllerBase { private readonly ITelemetryService telemetryService; private readonly IProcessMapPlanRepository processMapPlanWellDrillingRepository; private readonly IProcessMapPlanRepository processMapPlanWellReamRepository; public TelemetryProcessMapController(ITelemetryService telemetryService, IProcessMapPlanRepository processMapPlanWellDrillingRepository, IProcessMapPlanRepository processMapPlanWellReamRepository) { this.telemetryService = telemetryService; this.processMapPlanWellDrillingRepository = processMapPlanWellDrillingRepository; this.processMapPlanWellReamRepository = processMapPlanWellReamRepository; } /// /// Получение РТК бурение по Uid телеметрии /// /// Уникальный Id телеметрии /// Дата с которой требуется получить РТК /// /// [HttpGet("processMapPlanWellDrilling")] [ProducesResponseType(typeof(IEnumerable), StatusCodes.Status200OK)] [ProducesResponseType(typeof(ValidationProblemDetails), StatusCodes.Status400BadRequest)] public async Task GetProcessMapPlanWellDrillingByUidAsync(string uid, DateTime updateFrom, CancellationToken cancellationToken) { var idWell = telemetryService.GetIdWellByTelemetryUid(uid); if (!idWell.HasValue) return this.ValidationBadRequest(nameof(uid), $"Wrong uid {uid}"); var wellDrillingProcessMaps = await processMapPlanWellDrillingRepository.GetAsync(new[] { new ProcessMapPlanRequest { IdWell = idWell.Value, UpdateFrom = updateFrom }}, cancellationToken); return Ok(wellDrillingProcessMaps); } /// /// Получение РТК проработки по Uid телеметрии /// /// Уникальный Id телеметрии /// Дата с которой требуется получить РТК /// /// [HttpGet("processMapPlanWellReam")] [ProducesResponseType(typeof(IEnumerable), StatusCodes.Status200OK)] [ProducesResponseType(typeof(ValidationProblemDetails), StatusCodes.Status400BadRequest)] public async Task GetProcessMapPlanWellReamByUidAsync(string uid, DateTime updateFrom, CancellationToken cancellationToken) { var idWell = telemetryService.GetIdWellByTelemetryUid(uid); if (!idWell.HasValue) return this.ValidationBadRequest(nameof(uid), $"Wrong uid {uid}"); var wellReamProcessMaps = await processMapPlanWellReamRepository.GetAsync(new[] { new ProcessMapPlanRequest { IdWell = idWell.Value, UpdateFrom = updateFrom }}, cancellationToken); return Ok(wellReamProcessMaps); } }