DD.WellWorkover.Cloud/AsbCloudWebApi/Controllers/SAUB/TelemetryProcessMapController.cs
2023-10-09 17:16:02 +05:00

90 lines
3.7 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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;
/// <summary>
/// Данные РТК для SAUB
/// </summary>
[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;
}
/// <summary>
/// Получение РТК бурение по Uid телеметрии
/// </summary>
/// <param name="uid">Уникальный Id телеметрии</param>
/// <param name="updateFrom">Дата с которой требуется получить РТК</param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
[HttpGet("wellDrillingProcessMap")]
[ProducesResponseType(typeof(IEnumerable<WellDrillingProcessMapDto>), StatusCodes.Status200OK)]
[ProducesResponseType(typeof(ValidationProblemDetails), StatusCodes.Status400BadRequest)]
public async Task<IActionResult> 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);
}
/// <summary>
/// Получение РТК проработки по Uid телеметрии
/// </summary>
/// <param name="uid">Уникальный Id телеметрии</param>
/// <param name="updateFrom">Дата с которой требуется получить РТК</param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
[HttpGet("wellReamProcessMap")]
[ProducesResponseType(typeof(IEnumerable<WellReamProcessMapDto>), StatusCodes.Status200OK)]
[ProducesResponseType(typeof(ValidationProblemDetails), StatusCodes.Status400BadRequest)]
public async Task<IActionResult> 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);
}
}