2022-12-27 14:30:52 +05:00
|
|
|
|
using AsbCloudApp.Data.ProcessMap;
|
2022-04-11 18:00:34 +05:00
|
|
|
|
using AsbCloudApp.Services;
|
2023-02-08 10:42:54 +05:00
|
|
|
|
using AsbCloudDb.Model;
|
|
|
|
|
using AsbCloudInfrastructure.Services.ProcessMap;
|
2022-04-11 18:00:34 +05:00
|
|
|
|
using Microsoft.AspNetCore.Authorization;
|
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
2021-10-14 10:18:43 +05:00
|
|
|
|
using System;
|
2021-10-13 17:34:32 +05:00
|
|
|
|
using System.Collections.Generic;
|
2022-12-07 12:39:13 +05:00
|
|
|
|
using System.Linq;
|
2021-10-13 17:34:32 +05:00
|
|
|
|
using System.Threading;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace AsbCloudWebApi.Controllers
|
|
|
|
|
{
|
2022-12-07 10:52:35 +05:00
|
|
|
|
#nullable enable
|
2021-10-13 17:34:32 +05:00
|
|
|
|
/// <summary>
|
2022-12-07 08:49:21 +05:00
|
|
|
|
/// РТК
|
2021-10-13 17:34:32 +05:00
|
|
|
|
/// </summary>
|
|
|
|
|
[ApiController]
|
2022-06-09 11:19:52 +05:00
|
|
|
|
[Route("api/[controller]")]
|
2021-10-14 16:16:35 +05:00
|
|
|
|
[Authorize]
|
2022-12-07 08:47:41 +05:00
|
|
|
|
public class ProcessMapController : CrudWellRelatedController<ProcessMapDto, IProcessMapRepository>
|
2021-10-13 17:34:32 +05:00
|
|
|
|
{
|
|
|
|
|
private readonly ITelemetryService telemetryService;
|
2022-12-14 08:41:19 +05:00
|
|
|
|
private readonly IProcessMapReportService processMapReportService;
|
2023-02-08 10:42:54 +05:00
|
|
|
|
private readonly IProcessMapService processMapService;
|
2021-10-13 17:34:32 +05:00
|
|
|
|
|
2023-02-08 10:42:54 +05:00
|
|
|
|
public ProcessMapController(
|
|
|
|
|
IWellService wellService,
|
|
|
|
|
IProcessMapRepository repository,
|
|
|
|
|
IProcessMapReportService processMapReportService,
|
|
|
|
|
IProcessMapService processMapService,
|
2022-06-09 11:19:52 +05:00
|
|
|
|
ITelemetryService telemetryService)
|
2022-12-14 08:41:19 +05:00
|
|
|
|
: base(wellService, repository)
|
2021-10-13 17:34:32 +05:00
|
|
|
|
{
|
|
|
|
|
this.telemetryService = telemetryService;
|
2022-12-14 08:41:19 +05:00
|
|
|
|
this.processMapReportService = processMapReportService;
|
2023-02-08 10:42:54 +05:00
|
|
|
|
this.processMapService = processMapService;
|
|
|
|
|
|
2021-10-13 17:34:32 +05:00
|
|
|
|
}
|
2022-04-11 18:00:34 +05:00
|
|
|
|
|
2021-10-13 17:34:32 +05:00
|
|
|
|
/// <summary>
|
2022-01-05 17:50:45 +05:00
|
|
|
|
/// Возвращает все значения для коридоров бурения по uid панели
|
2021-10-13 17:34:32 +05:00
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="uid"> uid панели </param>
|
2021-10-14 10:18:43 +05:00
|
|
|
|
/// <param name="updateFrom"> Дата, с которой следует искать новые параметры </param>
|
2021-10-13 17:34:32 +05:00
|
|
|
|
/// <param name="token"> Токен отмены задачи </param>
|
2022-01-05 17:50:45 +05:00
|
|
|
|
/// <returns> Список параметров для коридоров бурения </returns>
|
2021-10-14 11:46:17 +05:00
|
|
|
|
[HttpGet]
|
2022-12-07 12:39:13 +05:00
|
|
|
|
[Obsolete("use GetByUidAsync(..) instead")]
|
2022-06-09 11:19:52 +05:00
|
|
|
|
[Route("/api/telemetry/{uid}/drillFlowChart")]
|
2021-10-14 16:16:35 +05:00
|
|
|
|
[AllowAnonymous]
|
2022-12-05 12:39:25 +05:00
|
|
|
|
[ProducesResponseType(typeof(IEnumerable<ProcessMapDto>), (int)System.Net.HttpStatusCode.OK)]
|
2022-12-07 12:39:13 +05:00
|
|
|
|
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<ProcessMapDto>();
|
|
|
|
|
return Ok(dto);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Возвращает РТК по uid телеметрии
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="uid"> uid телеметрии </param>
|
|
|
|
|
/// <param name="updateFrom"> Дата, с которой следует искать новые параметры </param>
|
|
|
|
|
/// <param name="token"> Токен отмены задачи </param>
|
|
|
|
|
/// <returns> Список параметров для коридоров бурения </returns>
|
|
|
|
|
[HttpGet]
|
|
|
|
|
[Route("/api/telemetry/{uid}/processMap")]
|
|
|
|
|
[AllowAnonymous]
|
|
|
|
|
[ProducesResponseType(typeof(IEnumerable<ProcessMapDto>), (int)System.Net.HttpStatusCode.OK)]
|
|
|
|
|
public async Task<IActionResult> GetByUidAsync(string uid, DateTime updateFrom, CancellationToken token)
|
2021-10-13 17:34:32 +05:00
|
|
|
|
{
|
2021-12-07 18:27:52 +05:00
|
|
|
|
var idWell = telemetryService.GetIdWellByTelemetryUid(uid);
|
2021-10-14 16:16:35 +05:00
|
|
|
|
if (idWell is null)
|
|
|
|
|
return BadRequest($"Wrong uid {uid}");
|
2022-04-11 18:00:34 +05:00
|
|
|
|
|
2022-06-09 11:19:52 +05:00
|
|
|
|
var dto = await service.GetAllAsync((int)idWell,
|
2021-10-14 10:18:43 +05:00
|
|
|
|
updateFrom, token);
|
2022-04-11 18:00:34 +05:00
|
|
|
|
|
2021-10-13 17:34:32 +05:00
|
|
|
|
return Ok(dto);
|
|
|
|
|
}
|
2022-04-11 18:00:34 +05:00
|
|
|
|
|
2022-12-05 12:39:25 +05:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Выгрузка расширенной РТК
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="wellId"></param>
|
2022-12-14 08:41:19 +05:00
|
|
|
|
/// /// <param name="token"></param>
|
2022-12-05 12:39:25 +05:00
|
|
|
|
/// <returns></returns>
|
|
|
|
|
/// <exception cref="NotImplementedException"></exception>
|
|
|
|
|
[HttpGet]
|
2022-12-07 12:57:28 +05:00
|
|
|
|
[Route("getReportFile/{wellId}")]
|
2022-12-07 10:57:23 +05:00
|
|
|
|
[ProducesResponseType(typeof(PhysicalFileResult), (int)System.Net.HttpStatusCode.OK)]
|
2022-12-14 08:41:19 +05:00
|
|
|
|
public async Task<IActionResult> GetReportFileAsync(int wellId, CancellationToken token)
|
2022-12-05 12:39:25 +05:00
|
|
|
|
{
|
2022-12-14 08:41:19 +05:00
|
|
|
|
var stream = await processMapReportService.MakeReportAsync(wellId, token);
|
|
|
|
|
if (stream != null)
|
|
|
|
|
{
|
|
|
|
|
var well = await wellService.GetOrDefaultAsync(wellId, token);
|
|
|
|
|
if (well is null)
|
|
|
|
|
return NoContent();
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
var fileName = $"РТК по скважине {well.Caption} куст {well.Cluster}.xlsx";
|
|
|
|
|
return File(stream, "application/octet-stream", fileName);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
return NoContent();
|
2022-12-05 12:39:25 +05:00
|
|
|
|
}
|
2022-12-07 08:47:41 +05:00
|
|
|
|
|
2023-02-08 10:42:54 +05:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Выгрузка режимной карты по бурению скважины
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="wellId"></param>
|
|
|
|
|
/// <param name="token"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpGet]
|
|
|
|
|
[Route("getDrillProcessMap/{wellId}")]
|
|
|
|
|
[ProducesResponseType(typeof(IEnumerable<ProcessMapReportDto>), (int)System.Net.HttpStatusCode.OK)]
|
|
|
|
|
public async Task<IActionResult> GetDrillProcessMap(int wellId, CancellationToken token)
|
|
|
|
|
{
|
|
|
|
|
var data = await processMapService.GetProcessMapAsync(wellId, token);
|
|
|
|
|
if (data != null)
|
|
|
|
|
{
|
|
|
|
|
return Ok(data);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
return NoContent();
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-07 08:47:41 +05:00
|
|
|
|
/// <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);
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-07 12:39:13 +05:00
|
|
|
|
/// <summary>
|
2022-12-07 08:47:41 +05:00
|
|
|
|
/// Редактировать запись по 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;
|
2022-12-14 09:10:01 +05:00
|
|
|
|
return await base.UpdateAsync(value, token);
|
2022-12-07 08:47:41 +05:00
|
|
|
|
}
|
2021-10-13 17:34:32 +05:00
|
|
|
|
}
|
2022-12-07 10:52:35 +05:00
|
|
|
|
#nullable disable
|
2021-10-13 17:34:32 +05:00
|
|
|
|
}
|