DD.WellWorkover.Cloud/AsbCloudWebApi/Controllers/SAUB/TelemetryProcessMapController.cs
2023-10-12 16:03:34 +05:00

87 lines
3.6 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;
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;
/// <summary>
/// Данные РТК для SAUB
/// </summary>
[ApiController]
[Route("api/[controller]")]
public class TelemetryProcessMapController : ControllerBase
{
private readonly ITelemetryService telemetryService;
private readonly IProcessMapPlanRepository<ProcessMapPlanWellDrillingDto> processMapPlanWellDrillingRepository;
private readonly IProcessMapPlanRepository<ProcessMapPlanWellReamDto> processMapPlanWellReamRepository;
public TelemetryProcessMapController(ITelemetryService telemetryService,
IProcessMapPlanRepository<ProcessMapPlanWellDrillingDto> processMapPlanWellDrillingRepository,
IProcessMapPlanRepository<ProcessMapPlanWellReamDto> processMapPlanWellReamRepository)
{
this.telemetryService = telemetryService;
this.processMapPlanWellDrillingRepository = processMapPlanWellDrillingRepository;
this.processMapPlanWellReamRepository = processMapPlanWellReamRepository;
}
/// <summary>
/// Получение РТК бурение по Uid телеметрии
/// </summary>
/// <param name="uid">Уникальный Id телеметрии</param>
/// <param name="updateFrom">Дата с которой требуется получить РТК</param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
[HttpGet("wellDrillingProcessMap")]
[ProducesResponseType(typeof(IEnumerable<ProcessMapPlanWellDrillingDto>), 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 processMapPlanWellDrillingRepository.GetAsync(new[] { new ProcessMapPlanRequest
{
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<ProcessMapPlanWellReamDto>), 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 processMapPlanWellReamRepository.GetAsync(new[] { new ProcessMapPlanRequest
{
IdWell = idWell.Value,
UpdateFrom = updateFrom
}}, cancellationToken);
return Ok(wellReamProcessMaps);
}
}