DD.WellWorkover.Cloud/AsbCloudWebApi/Controllers/ProcessMapController.cs

91 lines
3.4 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 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 ProcessMapController : CrudWellRelatedController<ProcessMapDto, IProcessMapRepository>
{
private readonly ITelemetryService telemetryService;
public ProcessMapController(IWellService wellService, IProcessMapRepository 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<ProcessMapDto>), (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);
}
/// <summary>
/// Выгрузка расширенной РТК
/// </summary>
/// <param name="wellId"></param>
/// <returns></returns>
/// <exception cref="NotImplementedException"></exception>
[HttpGet]
[Route("{wellId}")]
public IActionResult GetReportFileAsync(int wellId)
{
throw new NotImplementedException();
}
/// <summary>
/// Добавить запись
/// </summary>
/// <param name="value"></param>
/// <param name="token"></param>
/// <returns></returns>
[HttpPost]
public override async Task<ActionResult<int>> InsertAsync([FromBody] ProcessMapDto value, CancellationToken token)
{
value.IdUser = User.GetUserId() ?? -1;
return await base.InsertAsync(value, token);
}
// <summary>
/// Редактировать запись по id
/// </summary>
/// <param name="value">запись</param>
/// <param name="token"></param>
/// <returns>1 - успешно отредактировано, 0 - нет</returns>
[HttpPut]
public override async Task<ActionResult<int>> UpdateAsync([FromBody] ProcessMapDto value, CancellationToken token)
{
value.IdUser = User.GetUserId() ?? -1;
return await base.InsertAsync(value, token);
}
}
}