2024-03-22 12:42:48 +05:00
|
|
|
|
using AsbCloudApp.Data.WellOperation;
|
|
|
|
|
using AsbCloudApp.Requests;
|
|
|
|
|
using AsbCloudApp.Requests.ExportOptions;
|
|
|
|
|
using AsbCloudApp.Services;
|
|
|
|
|
using AsbCloudDb.Model;
|
|
|
|
|
using AsbCloudInfrastructure.Services.ExcelServices;
|
|
|
|
|
using AsbCloudInfrastructure.Services.ExcelServices.Templates;
|
2024-08-14 12:24:54 +05:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Threading;
|
|
|
|
|
using System.Threading.Tasks;
|
2024-03-22 12:42:48 +05:00
|
|
|
|
|
|
|
|
|
namespace AsbCloudInfrastructure.Services.WellOperations;
|
|
|
|
|
|
|
|
|
|
public class WellOperationExport<TTemplate> : ExcelExportService<WellOperationDto, WellOperationExportRequest, TTemplate>
|
2024-07-04 11:02:45 +05:00
|
|
|
|
where TTemplate : class, ITemplateParameters, new()
|
2024-03-22 12:42:48 +05:00
|
|
|
|
{
|
2024-08-14 12:24:54 +05:00
|
|
|
|
private readonly IWellService wellService;
|
|
|
|
|
private readonly IWellOperationService wellOperationService;
|
|
|
|
|
|
|
|
|
|
public WellOperationExport(
|
|
|
|
|
IWellOperationService wellOperationService,
|
|
|
|
|
IWellService wellService)
|
|
|
|
|
{
|
|
|
|
|
this.wellService = wellService;
|
|
|
|
|
this.wellOperationService = wellOperationService;
|
|
|
|
|
}
|
2024-03-22 12:42:48 +05:00
|
|
|
|
|
2024-08-14 12:24:54 +05:00
|
|
|
|
protected override async Task<string> BuildFileNameAsync(WellOperationExportRequest options, CancellationToken token)
|
|
|
|
|
{
|
|
|
|
|
var caption = await wellService.GetWellCaptionByIdAsync(options.IdWell, token);
|
2024-03-22 12:42:48 +05:00
|
|
|
|
|
2024-08-14 12:24:54 +05:00
|
|
|
|
return options.IdType switch
|
|
|
|
|
{
|
|
|
|
|
WellOperation.IdOperationTypeFact => $"{caption}_Фактические_операции.xlsx",
|
|
|
|
|
WellOperation.IdOperationTypePlan => $"{caption}_Плановые_операции.xlsx",
|
|
|
|
|
_ => throw new ArgumentOutOfRangeException(nameof(options.IdType))
|
|
|
|
|
};
|
|
|
|
|
}
|
2024-03-22 12:42:48 +05:00
|
|
|
|
|
2024-08-14 12:24:54 +05:00
|
|
|
|
protected override Task<IEnumerable<WellOperationDto>> GetDtosAsync(WellOperationExportRequest options, CancellationToken token)
|
|
|
|
|
{
|
|
|
|
|
var request = new WellOperationRequest(new[] { options.IdWell })
|
|
|
|
|
{
|
|
|
|
|
OperationType = options.IdType,
|
|
|
|
|
};
|
2024-03-22 12:42:48 +05:00
|
|
|
|
|
2024-08-14 12:24:54 +05:00
|
|
|
|
return wellOperationService.GetAsync(request, token);
|
|
|
|
|
}
|
2024-03-22 12:42:48 +05:00
|
|
|
|
}
|