Добавлен парсинг РТК шаблона

This commit is contained in:
Степанов Дмитрий 2024-08-20 14:09:42 +05:00
parent 2e7af2a8da
commit 51d43d179a
5 changed files with 97 additions and 0 deletions

View File

@ -44,6 +44,7 @@
<EmbeddedResource Include="Services\ProcessMapPlan\Templates\ProcessMapPlanSwitchingOffThePump.xlsx" /> <EmbeddedResource Include="Services\ProcessMapPlan\Templates\ProcessMapPlanSwitchingOffThePump.xlsx" />
<EmbeddedResource Include="Services\ProcessMapPlan\Templates\ProcessMapPlanSwitchingToTheMode.xlsx" /> <EmbeddedResource Include="Services\ProcessMapPlan\Templates\ProcessMapPlanSwitchingToTheMode.xlsx" />
<EmbeddedResource Include="Services\ProcessMapPlan\Templates\ProcessMapPlanTFOrientation.xlsx" /> <EmbeddedResource Include="Services\ProcessMapPlan\Templates\ProcessMapPlanTFOrientation.xlsx" />
<EmbeddedResource Include="Services\ProcessMapPlan\Templates\ProcessMapPlanSubsystems.xlsx" />
<EmbeddedResource Include="Services\ProcessMaps\Report\ProcessMapReportDataSaubStatTemplate.xlsx" /> <EmbeddedResource Include="Services\ProcessMaps\Report\ProcessMapReportDataSaubStatTemplate.xlsx" />
<EmbeddedResource Include="Services\Trajectory\Templates\TrajectoryFactNnbTemplate.xlsx" /> <EmbeddedResource Include="Services\Trajectory\Templates\TrajectoryFactNnbTemplate.xlsx" />
<EmbeddedResource Include="Services\Trajectory\Templates\TrajectoryFactManualTemplate.xlsx" /> <EmbeddedResource Include="Services\Trajectory\Templates\TrajectoryFactManualTemplate.xlsx" />

View File

@ -0,0 +1,22 @@
using System.Collections.Generic;
using AsbCloudApp.Data.ProcessMaps;
namespace AsbCloudInfrastructure.Services.ExcelServices.Templates.ProcessMapPlanTemplates;
public class ProcessMapPlanSubsystemsTemplate : ITemplateParameters
{
public string SheetName => "Использование систем";
public int HeaderRowsCount => 2;
public string FileName => "ProcessMapPlanSubsystems.xlsx";
public IDictionary<string, Cell> Cells => new Dictionary<string, Cell>
{
{ nameof(ProcessMapPlanSubsystemsDto.Section), new Cell(1, typeof(string)) },
{ nameof(ProcessMapPlanSubsystemsDto.DepthStart), new Cell(2, typeof(double)) },
{ nameof(ProcessMapPlanSubsystemsDto.DepthEnd), new Cell(3, typeof(double)) },
{ nameof(ProcessMapPlanSubsystemsDto.AutoRotor), new Cell(4, typeof(double)) },
{ nameof(ProcessMapPlanSubsystemsDto.AutoSlide), new Cell(5, typeof(double)) },
{ nameof(ProcessMapPlanSubsystemsDto.AutoOscillation), new Cell(6, typeof(double)) },
{ nameof(ProcessMapPlanSubsystemsDto.Note), new Cell(7, typeof(string)) }
};
}

View File

@ -0,0 +1,30 @@
using System.Threading;
using System.Threading.Tasks;
using AsbCloudApp.Data.ProcessMaps;
using AsbCloudApp.Repositories;
using AsbCloudApp.Requests;
using AsbCloudApp.Requests.ExportOptions;
using AsbCloudApp.Services;
using AsbCloudInfrastructure.Services.ExcelServices.Templates;
using AsbCloudInfrastructure.Services.ExcelServices.Templates.ProcessMapPlanTemplates;
namespace AsbCloudInfrastructure.Services.ProcessMapPlan.Export;
public class ProcessMapPlanSubsystemsExportService : ProcessMapPlanExportService<ProcessMapPlanSubsystemsDto>
{
public ProcessMapPlanSubsystemsExportService(
IChangeLogRepository<ProcessMapPlanSubsystemsDto, ProcessMapPlanBaseRequestWithWell> processMapPlanRepository,
IWellService wellService)
: base(processMapPlanRepository, wellService)
{
}
protected override ITemplateParameters TemplateParameters => new ProcessMapPlanSubsystemsTemplate();
protected override async Task<string> BuildFileNameAsync(WellRelatedExportRequest options, CancellationToken token)
{
var caption = await wellService.GetWellCaptionByIdAsync(options.IdWell, token);
return $"{caption}_РТК_План_использование_подсистем.xlsx";
}
}

View File

@ -0,0 +1,44 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using AsbCloudApp.Data.ProcessMaps;
using AsbCloudApp.Data.ProcessMaps.Functions;
using AsbCloudApp.Repositories;
using AsbCloudInfrastructure.Services.ExcelServices.Templates;
using AsbCloudInfrastructure.Services.ExcelServices.Templates.ProcessMapPlanTemplates;
namespace AsbCloudInfrastructure.Services.ProcessMapPlan.Parser;
public class ProcessMapPlanSubsystemsParser : ProcessMapPlanParser<ProcessMapPlanSubsystemsDto>
{
public ProcessMapPlanSubsystemsParser(IWellOperationRepository wellOperationRepository)
: base(wellOperationRepository)
{
}
protected override ITemplateParameters TemplateParameters => new ProcessMapPlanSubsystemsTemplate();
protected override ProcessMapPlanSubsystemsDto BuildDto(IDictionary<string, object?> row, int rowNumber)
{
var dto = base.BuildDto(row, rowNumber);
//TODO: при парсинге всех РТК шаблонов этот код повторяется, нужно поправить
var section = sections.FirstOrDefault(s =>
string.Equals(s.Caption.Trim(), dto.Section?.Trim(), StringComparison.CurrentCultureIgnoreCase));
if (section is null)
{
var message = string.Format(XLExtentions.ProblemDetailsTemplate,
TemplateParameters.SheetName,
rowNumber,
TemplateParameters.Cells[nameof(ProcessMapPlanBaseDto.Section)],
"Указана некорректная секция");
throw new FileFormatException(message);
}
dto.IdWellSectionType = section.Id;
return dto;
}
}