using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Threading;
using AsbCloudApp.Data.ProcessMaps;
using AsbCloudApp.Repositories;
using AsbCloudApp.Requests;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Http;
using AsbCloudApp.Services;
namespace AsbCloudWebApi.Controllers.SAUB;
///
/// Данные РТК для SAUB
///
[ApiController]
[Route("api/[controller]")]
public class TelemetryProcessMapController : ControllerBase
{
private readonly IWellService wellService;
private readonly ITelemetryService telemetryService;
private readonly IWellDrillingProcessMapRepository wellDrillingProcessMapRepository;
private readonly IWellReamProcessMapRepository wellReamProcessMapRepository;
public TelemetryProcessMapController(IWellService wellService,
ITelemetryService telemetryService,
IWellDrillingProcessMapRepository wellDrillingProcessMapRepository,
IWellReamProcessMapRepository wellReamProcessMapRepository)
{
this.wellService = wellService;
this.telemetryService = telemetryService;
this.wellDrillingProcessMapRepository = wellDrillingProcessMapRepository;
this.wellReamProcessMapRepository = wellReamProcessMapRepository;
}
///
/// Получение РТК бурение по Uid телеметрии
///
/// Уникальный Id телеметрии
/// Дата с которой требуется получить РТК
///
///
[HttpGet("wellDrillingProcessMap")]
[ProducesResponseType(typeof(IEnumerable), StatusCodes.Status200OK)]
[ProducesResponseType(typeof(ValidationProblemDetails), StatusCodes.Status400BadRequest)]
public async Task GetWellDrillingProcessMapByUidAsync(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 wellDrillingProcessMapRepository.GetAsync(new WellDrillingProcessMapRequest
{
IdWell = idWell.Value,
UpdateFrom = updateFrom
}, cancellationToken);
return Ok(wellDrillingProcessMaps);
}
///
/// Получение РТК проработки по Uid телеметрии
///
/// Уникальный Id телеметрии
/// Дата с которой требуется получить РТК
///
///
[HttpGet("wellReamProcessMap")]
[ProducesResponseType(typeof(IEnumerable), StatusCodes.Status200OK)]
[ProducesResponseType(typeof(ValidationProblemDetails), StatusCodes.Status400BadRequest)]
public async Task GetWellReamProcessMapByUidAsync(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 wellReamProcessMapRepository.GetAsync(new WellReamProcessMapRequest
{
IdWell = idWell.Value,
UpdateFrom = updateFrom
}, cancellationToken);
return Ok(wellReamProcessMaps);
}
}