forked from ddrilling/AsbCloudServer
53 lines
2.1 KiB
C#
53 lines
2.1 KiB
C#
using AsbCloudApp.Data;
|
||
using AsbCloudApp.Services;
|
||
using Microsoft.AspNetCore.Authorization;
|
||
using Microsoft.AspNetCore.Mvc;
|
||
using System;
|
||
using System.Collections.Generic;
|
||
using System.Threading;
|
||
using System.Threading.Tasks;
|
||
|
||
namespace AsbCloudWebApi.Controllers
|
||
{
|
||
/// <summary>
|
||
/// Коридоры бурения для панели бурильщика
|
||
/// </summary>
|
||
[ApiController]
|
||
[Route("api/[controller]")]
|
||
[Authorize]
|
||
public class DrillFlowChartController : CrudWellRelatedController<DrillFlowChartDto, IDrillFlowChartRepository>
|
||
{
|
||
private readonly ITelemetryService telemetryService;
|
||
|
||
public DrillFlowChartController(IWellService wellService, IDrillFlowChartRepository service,
|
||
ITelemetryService telemetryService)
|
||
: base(wellService, service)
|
||
{
|
||
this.telemetryService = telemetryService;
|
||
}
|
||
|
||
/// <summary>
|
||
/// Возвращает все значения для коридоров бурения по uid панели
|
||
/// </summary>
|
||
/// <param name="uid"> uid панели </param>
|
||
/// <param name="updateFrom"> Дата, с которой следует искать новые параметры </param>
|
||
/// <param name="token"> Токен отмены задачи </param>
|
||
/// <returns> Список параметров для коридоров бурения </returns>
|
||
[HttpGet]
|
||
[Route("/api/telemetry/{uid}/drillFlowChart")]
|
||
[AllowAnonymous]
|
||
[ProducesResponseType(typeof(IEnumerable<DrillFlowChartDto>), (int)System.Net.HttpStatusCode.OK)]
|
||
public async Task<IActionResult> GetByTelemetryAsync(string uid, DateTime updateFrom = default, CancellationToken token = default)
|
||
{
|
||
var idWell = telemetryService.GetIdWellByTelemetryUid(uid);
|
||
if (idWell is null)
|
||
return BadRequest($"Wrong uid {uid}");
|
||
|
||
var dto = await service.GetAllAsync((int)idWell,
|
||
updateFrom, token);
|
||
|
||
return Ok(dto);
|
||
}
|
||
|
||
}
|
||
} |