forked from ddrilling/AsbCloudServer
90 lines
3.7 KiB
C#
90 lines
3.7 KiB
C#
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);
|
||
}
|
||
|
||
} |