DD.WellWorkover.Cloud/AsbCloudWebApi/Controllers/ProcessMaps/ProcessMapReportDrillingController.cs

67 lines
2.7 KiB
C#
Raw Normal View History

using AsbCloudApp.Data.ProcessMaps.Report;
2024-02-21 15:08:51 +05:00
using AsbCloudApp.Requests;
using AsbCloudApp.Services.ProcessMaps.WellDrilling;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
namespace AsbCloudWebApi.Controllers.ProcessMaps;
/// <summary>
/// РТК отчет по бурению
/// </summary>
[ApiController]
[Route("api/well/{idWell:int}/[controller]")]
[Authorize]
public class ProcessMapReportDrillingController: ControllerBase
{
private readonly IProcessMapReportDrillingService processMapReportDrillingService;
private readonly IProcessMapReportDrillingExportService processMapReportDrillingExportService;
public ProcessMapReportDrillingController(
IProcessMapReportDrillingExportService processMapReportDrillingExportService,
IProcessMapReportDrillingService processMapReportDrillingService)
{
this.processMapReportDrillingExportService = processMapReportDrillingExportService;
this.processMapReportDrillingService = processMapReportDrillingService;
}
/// <summary>
/// Получение данных для отчета РТК бурение
/// </summary>
/// <param name="idWell">Id</param>
/// <param name="request">параметры запроса</param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
2024-02-21 15:11:26 +05:00
[HttpGet("report")]
2024-02-21 15:08:51 +05:00
[ProducesResponseType(typeof(IEnumerable<ProcessMapReportDataSaubStatDto>), StatusCodes.Status200OK)]
2024-02-21 15:11:26 +05:00
public async Task<IActionResult> GetReportAsync(int idWell, [FromQuery] DataSaubStatRequest request, CancellationToken cancellationToken)
2024-02-21 15:08:51 +05:00
{
var report = await processMapReportDrillingService.GetAsync(idWell, request, cancellationToken);
return Ok(report);
}
/// <summary>
/// Экспорт отчета РТК бурение
/// </summary>
/// <param name="idWell">Id скважины</param>
/// <param name="request">Параметры запроса</param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
[HttpGet("report/export")]
[ProducesResponseType(typeof(PhysicalFileResult), StatusCodes.Status200OK, "application/octet-stream")]
[ProducesResponseType(StatusCodes.Status204NoContent)]
public async Task<IActionResult> ExportReportAsync(int idWell, [FromQuery] DataSaubStatRequest request, CancellationToken cancellationToken)
{
var report = await processMapReportDrillingExportService.ExportAsync(idWell, request, cancellationToken);
if (report is null)
return NoContent();
return File(report.Value.File, "application/octet-stream", report.Value.Name);
}
}