using AsbCloudApp.Data;
using AsbCloudApp.Services;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
namespace AsbCloudWebApi.Controllers
{
#nullable enable
///
/// РТК
///
[ApiController]
[Route("api/[controller]")]
[Authorize]
public class ProcessMapController : CrudWellRelatedController
{
private readonly ITelemetryService telemetryService;
public ProcessMapController(IWellService wellService, IProcessMapRepository service,
ITelemetryService telemetryService)
: base(wellService, service)
{
this.telemetryService = telemetryService;
}
///
/// Возвращает все значения для коридоров бурения по uid панели
///
/// uid панели
/// Дата, с которой следует искать новые параметры
/// Токен отмены задачи
/// Список параметров для коридоров бурения
[HttpGet]
[Obsolete("use GetByUidAsync(..) instead")]
[Route("/api/telemetry/{uid}/drillFlowChart")]
[AllowAnonymous]
[ProducesResponseType(typeof(IEnumerable), (int)System.Net.HttpStatusCode.OK)]
public IActionResult GetByTelemetry(string uid, DateTime updateFrom, CancellationToken token)
{
var idWell = telemetryService.GetIdWellByTelemetryUid(uid);
if (idWell is null)
return BadRequest($"Wrong uid {uid}");
var dto = Enumerable.Empty();
return Ok(dto);
}
///
/// Возвращает РТК по uid телеметрии
///
/// uid телеметрии
/// Дата, с которой следует искать новые параметры
/// Токен отмены задачи
/// Список параметров для коридоров бурения
[HttpGet]
[Route("/api/telemetry/{uid}/processMap")]
[AllowAnonymous]
[ProducesResponseType(typeof(IEnumerable), (int)System.Net.HttpStatusCode.OK)]
public async Task GetByUidAsync(string uid, DateTime updateFrom, CancellationToken token)
{
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);
}
///
/// Выгрузка расширенной РТК
///
///
///
///
[HttpGet]
[Route("getReportFile/{wellId}")]
[ProducesResponseType(typeof(PhysicalFileResult), (int)System.Net.HttpStatusCode.OK)]
public Task GetReportFileAsync(int wellId)
{
throw new NotImplementedException();
}
///
/// Добавить запись
///
///
///
///
[HttpPost]
public override async Task> InsertAsync([FromBody] ProcessMapDto value, CancellationToken token)
{
value.IdUser = User.GetUserId() ?? -1;
return await base.InsertAsync(value, token);
}
///
/// Редактировать запись по id
///
/// запись
///
/// 1 - успешно отредактировано, 0 - нет
[HttpPut]
public override async Task> UpdateAsync([FromBody] ProcessMapDto value, CancellationToken token)
{
value.IdUser = User.GetUserId() ?? -1;
return await base.UpdateAsync(value, token);
}
}
#nullable disable
}