forked from ddrilling/AsbCloudServer
67 lines
2.7 KiB
C#
67 lines
2.7 KiB
C#
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);
|
||
}
|
||
} |