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

67 lines
2.7 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.ProcessMaps.Report;
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>
[HttpGet("report")]
[ProducesResponseType(typeof(IEnumerable<ProcessMapReportDataSaubStatDto>), StatusCodes.Status200OK)]
public async Task<IActionResult> GetReportAsync(int idWell, [FromQuery] DataSaubStatRequest request, CancellationToken cancellationToken)
{
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);
}
}