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