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