From 1ffe0d6df88b5d9f300b1b762fbb081634b60b31 Mon Sep 17 00:00:00 2001 From: Olga Nemt Date: Sun, 30 Jun 2024 19:43:25 +0500 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=BE=D0=B4=D1=85=D0=BE=D0=B4=20=D0=BA?= =?UTF-8?q?=20=D0=B7=D0=B0=D0=B1=D0=BE=D1=8E=20=D0=B2=20=D1=80=D0=BE=D1=82?= =?UTF-8?q?=D0=BE=D1=80=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ProcessMapPlanRotorLoweringBit.cs | 31 ++++++++++++++ .../ProcessMapPlanRotorLoweringBitTemplate.cs | 17 ++++++++ ...essMapPlanRotorLoweringBitExportService.cs | 30 +++++++++++++ .../ProcessMapPlanRotorLoweringBitParser.cs | 42 +++++++++++++++++++ ...rocessMapPlanRotorLoweringBitController.cs | 28 +++++++++++++ 5 files changed, 148 insertions(+) create mode 100644 AsbCloudDb/Model/ProcessMapPlan/ProcessMapPlanRotorLoweringBit.cs create mode 100644 AsbCloudInfrastructure/Services/ExcelServices/Templates/ProcessMapPlanTemplates/ProcessMapPlanRotorLoweringBitTemplate.cs create mode 100644 AsbCloudInfrastructure/Services/ProcessMapPlan/Export/ProcessMapPlanRotorLoweringBitExportService.cs create mode 100644 AsbCloudInfrastructure/Services/ProcessMapPlan/Parser/ProcessMapPlanRotorLoweringBitParser.cs create mode 100644 AsbCloudWebApi/Controllers/ProcessMaps/Operations/ProcessMapPlanRotorLoweringBitController.cs diff --git a/AsbCloudDb/Model/ProcessMapPlan/ProcessMapPlanRotorLoweringBit.cs b/AsbCloudDb/Model/ProcessMapPlan/ProcessMapPlanRotorLoweringBit.cs new file mode 100644 index 00000000..8e6460eb --- /dev/null +++ b/AsbCloudDb/Model/ProcessMapPlan/ProcessMapPlanRotorLoweringBit.cs @@ -0,0 +1,31 @@ +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using AsbCloudDb.Model.ProcessMapPlan; +using Microsoft.EntityFrameworkCore; + +namespace AsbCloudDb.Model.ProcessMaps; + +[Table("t_process_map_plan_rotor_lowering_bit"), Comment("РТК подход к забою в роторе")] +public class ProcessMapPlanRotorLoweringBit : ProcessMapPlanBase +{ + [Column("time_load_capacity_min"), Comment("Время выработки минимальное, сек")] + [Range(0.0, 800.0)] + [Required] + public double TimeLoadCapacityMin { get; set; } + + [Column("differential_pressure_min"), Comment("Перепад давления минимальный, атм")] + [Range(0.1, 400.0)] + [Required] + public double DifferentialPressureMin { get; set; } + + [Column("weight_on_bit_min"), Comment("Нагрузка минимальная, т")] + [Range(0.1, 99.0)] + [Required] + public double WeightOnBitMin { get; set; } + + [Column("note"), Comment("Примечание"), StringLength(1024)] + public string Note { get; set; } = string.Empty; + + [ForeignKey(nameof(IdPrevious))] + public virtual ProcessMapPlanLoadCapacity? Previous { get; set; } +} \ No newline at end of file diff --git a/AsbCloudInfrastructure/Services/ExcelServices/Templates/ProcessMapPlanTemplates/ProcessMapPlanRotorLoweringBitTemplate.cs b/AsbCloudInfrastructure/Services/ExcelServices/Templates/ProcessMapPlanTemplates/ProcessMapPlanRotorLoweringBitTemplate.cs new file mode 100644 index 00000000..043e76f8 --- /dev/null +++ b/AsbCloudInfrastructure/Services/ExcelServices/Templates/ProcessMapPlanTemplates/ProcessMapPlanRotorLoweringBitTemplate.cs @@ -0,0 +1,17 @@ +using System.Collections.Generic; + +namespace AsbCloudInfrastructure.Services.ExcelServices.Templates.ProcessMapPlanTemplates; + +public class ProcessMapPlanRotorLoweringBitTemplate : ITemplateParameters +{ + public string SheetName => "Подход к забою в роторе"; + + public int HeaderRowsCount => 2; + + public string FileName => "ProcessMapPlanRotorLoweringBitTemplate.xlsx"; + + public IDictionary Cells => new Dictionary + { + + }; +} \ No newline at end of file diff --git a/AsbCloudInfrastructure/Services/ProcessMapPlan/Export/ProcessMapPlanRotorLoweringBitExportService.cs b/AsbCloudInfrastructure/Services/ProcessMapPlan/Export/ProcessMapPlanRotorLoweringBitExportService.cs new file mode 100644 index 00000000..28e09717 --- /dev/null +++ b/AsbCloudInfrastructure/Services/ProcessMapPlan/Export/ProcessMapPlanRotorLoweringBitExportService.cs @@ -0,0 +1,30 @@ +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; +using System.Threading; +using System.Threading.Tasks; + +namespace AsbCloudInfrastructure.Services.ProcessMapPlan.Export; + +public class ProcessMapPlanRotorLoweringBitExportService : ProcessMapPlanExportService +{ + public ProcessMapPlanRotorLoweringBitExportService( + IChangeLogRepository processMapPlanRepository, + IWellService wellService) + : base(processMapPlanRepository, wellService) + { + } + + protected override ITemplateParameters TemplateParameters { get; } = new ProcessMapPlanRotorLoweringBitTemplate(); + + 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/ProcessMapPlanRotorLoweringBitParser.cs b/AsbCloudInfrastructure/Services/ProcessMapPlan/Parser/ProcessMapPlanRotorLoweringBitParser.cs new file mode 100644 index 00000000..a83f89ba --- /dev/null +++ b/AsbCloudInfrastructure/Services/ProcessMapPlan/Parser/ProcessMapPlanRotorLoweringBitParser.cs @@ -0,0 +1,42 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using AsbCloudApp.Data.ProcessMaps; +using AsbCloudApp.Repositories; +using AsbCloudInfrastructure.Services.ExcelServices.Templates; +using AsbCloudInfrastructure.Services.ExcelServices.Templates.ProcessMapPlanTemplates; + +namespace AsbCloudInfrastructure.Services.ProcessMapPlan.Parser; + +public class ProcessMapPlanRotorLoweringBitParser : ProcessMapPlanParser +{ + public ProcessMapPlanRotorLoweringBitParser(IWellOperationRepository wellOperationRepository) + : base(wellOperationRepository) + { + } + + protected override ITemplateParameters TemplateParameters => new ProcessMapPlanLoadCapacityTemplate(); + + protected override ProcessMapPlanRotorLoweringBitDto BuildDto(IDictionary row, int rowNumber) + { + var dto = base.BuildDto(row, rowNumber); + + 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/AsbCloudWebApi/Controllers/ProcessMaps/Operations/ProcessMapPlanRotorLoweringBitController.cs b/AsbCloudWebApi/Controllers/ProcessMaps/Operations/ProcessMapPlanRotorLoweringBitController.cs new file mode 100644 index 00000000..d7a4ed32 --- /dev/null +++ b/AsbCloudWebApi/Controllers/ProcessMaps/Operations/ProcessMapPlanRotorLoweringBitController.cs @@ -0,0 +1,28 @@ +using AsbCloudApp.Data.ProcessMaps; +using AsbCloudApp.Repositories; +using AsbCloudApp.Requests; +using AsbCloudApp.Services; +using AsbCloudDb.Model.ProcessMaps; +using AsbCloudInfrastructure.Services.ProcessMapPlan.Export; +using AsbCloudInfrastructure.Services.ProcessMapPlan.Parser; + +namespace AsbCloudWebApi.Controllers.ProcessMaps.Operations; + +/// +/// РТК план подход к забою в роторе +/// +public class ProcessMapPlanRotorLoweringBitController : + ProcessMapPlanBaseController +{ + public ProcessMapPlanRotorLoweringBitController( + IChangeLogRepository repository, + IWellService wellService, + ProcessMapPlanRotorLoweringBitParser parserService, + ITelemetryService telemetryService, + ProcessMapPlanRotorLoweringBitExportService processMapPlanExportService) + : base(repository, wellService, parserService, processMapPlanExportService, telemetryService) + { + } + + protected override string TemplateFileName => "ЕЦП_шаблон_файла_РТК_план_подход_к_забою_в_роторе.xlsx"; +} \ No newline at end of file