diff --git a/AsbCloudDb/Model/ProcessMapPlan/ProcessMapPlanSlideLoweringBit.cs b/AsbCloudDb/Model/ProcessMapPlan/ProcessMapPlanSlideLoweringBit.cs new file mode 100644 index 00000000..232ea90d --- /dev/null +++ b/AsbCloudDb/Model/ProcessMapPlan/ProcessMapPlanSlideLoweringBit.cs @@ -0,0 +1,51 @@ +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_slide_lowering_bit"), Comment("РТК подход к забою в слайде")] +public class ProcessMapPlanSlideLoweringBit : ProcessMapPlanBase +{ + [Column("pressure_max"), Comment("Максимально допустимое давление, атм.")] + [Range(0.0, 400.0)] + [Required] + public double PressureMax { get; set; } + + [Column("differential_pressure"), Comment("Перепад давления уставка, атм.")] + [Range(0.0, 60.0)] + [Required] + public double DifferentialPressure { get; set; } + + [Column("slacking_off"), Comment("Посадка, т.")] + [Range(0.0, 20.0)] + [Required] + public double SlackingOff { get; set; } + + [Column("torque_max"), Comment("Максимально допустимый момент, кН*м.")] + [Range(0.0, 35.0)] + [Required] + public double TorqueMax { get; set; } + + [Column("rop_down"), Comment("Скорость вниз, м/ч.")] + [Range(0.0, 999.0)] + [Required] + public double RopDown { get; set; } + + [Column("rpm_down"), Comment("Обороты вниз, об/мин.")] + [Range(0.0, 270.0)] + [Required] + public double RpmDown { get; set; } + + [Column("flow_rate_down"), Comment("Расход вниз, л/с.")] + [Range(0.0, 100.0)] + [Required] + public double FlowRateDown { get; set; } + + [Column("note"), Comment("Примечание"), StringLength(1024)] + public string Note { get; set; } = string.Empty; + + [ForeignKey(nameof(IdPrevious))] + public virtual ProcessMapPlanRotorLoweringBit? Previous { get; set; } +} \ No newline at end of file diff --git a/AsbCloudInfrastructure/Services/ExcelServices/Templates/ProcessMapPlanTemplates/ProcessMapPlanSlideLoweringBitTemplate.cs b/AsbCloudInfrastructure/Services/ExcelServices/Templates/ProcessMapPlanTemplates/ProcessMapPlanSlideLoweringBitTemplate.cs new file mode 100644 index 00000000..3ee25be6 --- /dev/null +++ b/AsbCloudInfrastructure/Services/ExcelServices/Templates/ProcessMapPlanTemplates/ProcessMapPlanSlideLoweringBitTemplate.cs @@ -0,0 +1,17 @@ +using System.Collections.Generic; + +namespace AsbCloudInfrastructure.Services.ExcelServices.Templates.ProcessMapPlanTemplates; + +public class ProcessMapPlanSlideLoweringBitTemplate : ITemplateParameters +{ + public string SheetName => "Подход к забою в слайде"; + + public int HeaderRowsCount => 2; + + public string FileName => "ProcessMapPlanSlideLoweringBitTemplate.xlsx"; + + public IDictionary Cells => new Dictionary + { + + }; +} \ No newline at end of file diff --git a/AsbCloudInfrastructure/Services/ProcessMapPlan/Export/ProcessMapPlanSlideLoweringBitExportService.cs b/AsbCloudInfrastructure/Services/ProcessMapPlan/Export/ProcessMapPlanSlideLoweringBitExportService.cs new file mode 100644 index 00000000..b7a75c3e --- /dev/null +++ b/AsbCloudInfrastructure/Services/ProcessMapPlan/Export/ProcessMapPlanSlideLoweringBitExportService.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 ProcessMapPlanSlideLoweringBitExportService : ProcessMapPlanExportService +{ + public ProcessMapPlanSlideLoweringBitExportService( + IChangeLogRepository processMapPlanRepository, + IWellService wellService) + : base(processMapPlanRepository, wellService) + { + } + + protected override ITemplateParameters TemplateParameters { get; } = new ProcessMapPlanSlideLoweringBitTemplate(); + + 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 index a83f89ba..32443cb4 100644 --- a/AsbCloudInfrastructure/Services/ProcessMapPlan/Parser/ProcessMapPlanRotorLoweringBitParser.cs +++ b/AsbCloudInfrastructure/Services/ProcessMapPlan/Parser/ProcessMapPlanRotorLoweringBitParser.cs @@ -16,7 +16,7 @@ public class ProcessMapPlanRotorLoweringBitParser : ProcessMapPlanParser new ProcessMapPlanLoadCapacityTemplate(); + protected override ITemplateParameters TemplateParameters => new ProcessMapPlanRotorLoweringBitTemplate(); protected override ProcessMapPlanRotorLoweringBitDto BuildDto(IDictionary row, int rowNumber) { diff --git a/AsbCloudInfrastructure/Services/ProcessMapPlan/Parser/ProcessMapPlanSlideLoweringBitParser.cs b/AsbCloudInfrastructure/Services/ProcessMapPlan/Parser/ProcessMapPlanSlideLoweringBitParser.cs new file mode 100644 index 00000000..2eefebbf --- /dev/null +++ b/AsbCloudInfrastructure/Services/ProcessMapPlan/Parser/ProcessMapPlanSlideLoweringBitParser.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 ProcessMapPlanSlideLoweringBitParser : ProcessMapPlanParser +{ + public ProcessMapPlanSlideLoweringBitParser(IWellOperationRepository wellOperationRepository) + : base(wellOperationRepository) + { + } + + protected override ITemplateParameters TemplateParameters => new ProcessMapPlanSlideLoweringBitTemplate(); + + protected override ProcessMapPlanSlideLoweringBitDto 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/ProcessMapPlanSlideLoweringBitController.cs b/AsbCloudWebApi/Controllers/ProcessMaps/Operations/ProcessMapPlanSlideLoweringBitController.cs new file mode 100644 index 00000000..88674f71 --- /dev/null +++ b/AsbCloudWebApi/Controllers/ProcessMaps/Operations/ProcessMapPlanSlideLoweringBitController.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 ProcessMapPlanSlideLoweringBitController : + ProcessMapPlanBaseController +{ + public ProcessMapPlanSlideLoweringBitController( + IChangeLogRepository repository, + IWellService wellService, + ProcessMapPlanSlideLoweringBitParser parserService, + ITelemetryService telemetryService, + ProcessMapPlanSlideLoweringBitExportService processMapPlanExportService) + : base(repository, wellService, parserService, processMapPlanExportService, telemetryService) + { + } + + protected override string TemplateFileName => "ЕЦП_шаблон_файла_РТК_план_подход_к_забою_в_слайде.xlsx"; +} \ No newline at end of file