diff --git a/AsbCloudInfrastructure/AsbCloudInfrastructure.csproj b/AsbCloudInfrastructure/AsbCloudInfrastructure.csproj index 57a0258c..2942a43a 100644 --- a/AsbCloudInfrastructure/AsbCloudInfrastructure.csproj +++ b/AsbCloudInfrastructure/AsbCloudInfrastructure.csproj @@ -44,6 +44,7 @@ + diff --git a/AsbCloudInfrastructure/Services/ExcelServices/Templates/ProcessMapPlanTemplates/ProcessMapPlanSubsystemsTemplate.cs b/AsbCloudInfrastructure/Services/ExcelServices/Templates/ProcessMapPlanTemplates/ProcessMapPlanSubsystemsTemplate.cs new file mode 100644 index 00000000..53ea5180 --- /dev/null +++ b/AsbCloudInfrastructure/Services/ExcelServices/Templates/ProcessMapPlanTemplates/ProcessMapPlanSubsystemsTemplate.cs @@ -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 Cells => new Dictionary + { + { 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)) } + }; +} \ No newline at end of file diff --git a/AsbCloudInfrastructure/Services/ProcessMapPlan/Export/ProcessMapPlanSubsystemsExportService.cs b/AsbCloudInfrastructure/Services/ProcessMapPlan/Export/ProcessMapPlanSubsystemsExportService.cs new file mode 100644 index 00000000..3903a5fa --- /dev/null +++ b/AsbCloudInfrastructure/Services/ProcessMapPlan/Export/ProcessMapPlanSubsystemsExportService.cs @@ -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 +{ + public ProcessMapPlanSubsystemsExportService( + IChangeLogRepository processMapPlanRepository, + IWellService wellService) + : base(processMapPlanRepository, wellService) + { + } + + protected override ITemplateParameters TemplateParameters => new ProcessMapPlanSubsystemsTemplate(); + + protected override async Task BuildFileNameAsync(WellRelatedExportRequest options, CancellationToken token) + { + var caption = await wellService.GetWellCaptionByIdAsync(options.IdWell, token); + + return $"{caption}_РТК_План_использование_подсистем.xlsx"; + } +} \ No newline at end of file diff --git a/AsbCloudInfrastructure/Services/ProcessMapPlan/Parser/ProcessMapPlanSubsystemsParser.cs b/AsbCloudInfrastructure/Services/ProcessMapPlan/Parser/ProcessMapPlanSubsystemsParser.cs new file mode 100644 index 00000000..9adc787d --- /dev/null +++ b/AsbCloudInfrastructure/Services/ProcessMapPlan/Parser/ProcessMapPlanSubsystemsParser.cs @@ -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 +{ + public ProcessMapPlanSubsystemsParser(IWellOperationRepository wellOperationRepository) + : base(wellOperationRepository) + { + } + + protected override ITemplateParameters TemplateParameters => new ProcessMapPlanSubsystemsTemplate(); + + protected override ProcessMapPlanSubsystemsDto BuildDto(IDictionary 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; + } +} \ No newline at end of file diff --git a/AsbCloudInfrastructure/Services/ProcessMapPlan/Templates/ProcessMapPlanSubsystems.xlsx b/AsbCloudInfrastructure/Services/ProcessMapPlan/Templates/ProcessMapPlanSubsystems.xlsx new file mode 100644 index 00000000..e74656c8 Binary files /dev/null and b/AsbCloudInfrastructure/Services/ProcessMapPlan/Templates/ProcessMapPlanSubsystems.xlsx differ