From f9b1884a3919f0b8b9380bf481a3b3ef1d68b725 Mon Sep 17 00:00:00 2001 From: Olga Nemt Date: Wed, 26 Jun 2024 17:48:15 +0500 Subject: [PATCH] =?UTF-8?q?=D0=A0=D0=A2=D0=9A=20=D0=BF=D0=BB=D0=B0=D0=BD?= =?UTF-8?q?=20=D0=B2=D1=8B=D1=85=D0=BE=D0=B4=20=D1=81=D1=82=D0=B0=D1=82?= =?UTF-8?q?=D0=B8=D1=87=D0=B5=D1=81=D0=BA=D0=BE=D0=B3=D0=BE=20=D0=B7=D0=B0?= =?UTF-8?q?=D0=BC=D0=B5=D1=80=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...essMapPlanFunctionsAnticrashRotationDto.cs | 28 +++++++++++++ ...ProcessMapPlanFunctionsStaticMeasureDto.cs | 16 +++++++ AsbCloudDb/Model/AsbCloudDbContext.cs | 11 +++++ AsbCloudDb/Model/IAsbCloudDbContext.cs | 1 + .../ProcessMapPlanFunctionsStaticMeasure.cs | 18 ++++++++ AsbCloudInfrastructure/DependencyInjection.cs | 14 +++++++ ...ssMapPlanFunctionsStaticMeasureTemplate.cs | 17 ++++++++ ...PlanFunctionsStaticMeasureExportService.cs | 30 +++++++++++++ ...cessMapPlanFunctionsStaticMeasureParser.cs | 42 +++++++++++++++++++ ...MapPlanFunctionsStaticMeasureController.cs | 28 +++++++++++++ 10 files changed, 205 insertions(+) create mode 100644 AsbCloudApp/Data/ProcessMaps/ProcessMapPlanFunctionsAnticrashRotationDto.cs create mode 100644 AsbCloudApp/Data/ProcessMaps/ProcessMapPlanFunctionsStaticMeasureDto.cs create mode 100644 AsbCloudDb/Model/ProcessMapPlan/ProcessMapPlanFunctionsStaticMeasure.cs create mode 100644 AsbCloudInfrastructure/Services/ExcelServices/Templates/ProcessMapPlanTemplates/ProcessMapPlanFunctionsStaticMeasureTemplate.cs create mode 100644 AsbCloudInfrastructure/Services/ProcessMapPlan/Export/ProcessMapPlanFunctionsStaticMeasureExportService.cs create mode 100644 AsbCloudInfrastructure/Services/ProcessMapPlan/Parser/ProcessMapPlanFunctionsStaticMeasureParser.cs create mode 100644 AsbCloudWebApi/Controllers/ProcessMaps/ProcessMapPlanFunctionsStaticMeasureController.cs diff --git a/AsbCloudApp/Data/ProcessMaps/ProcessMapPlanFunctionsAnticrashRotationDto.cs b/AsbCloudApp/Data/ProcessMaps/ProcessMapPlanFunctionsAnticrashRotationDto.cs new file mode 100644 index 00000000..62efab64 --- /dev/null +++ b/AsbCloudApp/Data/ProcessMaps/ProcessMapPlanFunctionsAnticrashRotationDto.cs @@ -0,0 +1,28 @@ +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace AsbCloudApp.Data.ProcessMaps; + +/// +/// РТК план противоаварийное вращение +/// +public class ProcessMapPlanFunctionsAnticrashRotationDto : ProcessMapPlanBaseDto +{ + /// + /// Минимальные обороты ВСП, об/мин + /// + [Range(0.0, 250.0)] + public double MinRPM { get; set; } + + /// + /// Минимальный расход для запуска оборотов ВСП, л/сек + /// + [Range(1.0, 100.0)] + public double MinСonsumptionStartingFlowRate { get; set; } + + /// + /// Максимально допустимый момент на ВСП при противоаварийном вращении, кН*м + /// + [Range(1.0, 35.0)] + public double TopDriveTorqueLimitMax { get; set; } +} \ No newline at end of file diff --git a/AsbCloudApp/Data/ProcessMaps/ProcessMapPlanFunctionsStaticMeasureDto.cs b/AsbCloudApp/Data/ProcessMaps/ProcessMapPlanFunctionsStaticMeasureDto.cs new file mode 100644 index 00000000..40c65a54 --- /dev/null +++ b/AsbCloudApp/Data/ProcessMaps/ProcessMapPlanFunctionsStaticMeasureDto.cs @@ -0,0 +1,16 @@ +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace AsbCloudApp.Data.ProcessMaps; + +/// +/// РТК план выход статического замера +/// +public class ProcessMapPlanFunctionsStaticMeasureDto : ProcessMapPlanBaseDto +{ + /// + /// Время ожидания выхода сигнала с ТМС, сек. + /// + [Range(0.0, 1800.0)] + public double SignalWaitingTime { get; set; } +} \ No newline at end of file diff --git a/AsbCloudDb/Model/AsbCloudDbContext.cs b/AsbCloudDb/Model/AsbCloudDbContext.cs index 7ffece5e..1bd345c5 100644 --- a/AsbCloudDb/Model/AsbCloudDbContext.cs +++ b/AsbCloudDb/Model/AsbCloudDbContext.cs @@ -39,6 +39,7 @@ namespace AsbCloudDb.Model public virtual DbSet ProcessMapPlanFunctionsUpgradeNoload => Set(); public virtual DbSet ProcessMapPlanFunctionsOscillation => Set(); public virtual DbSet ProcessMapPlanFunctionsAnticrashRotation => Set(); + public virtual DbSet ProcessMapPlanFunctionsStaticMeasure => Set(); public virtual DbSet DrillingProgramParts => Set(); public virtual DbSet FileCategories => Set(); @@ -557,6 +558,11 @@ namespace AsbCloudDb.Model .WithMany() .OnDelete(DeleteBehavior.Restrict); + modelBuilder.Entity() + .HasOne(p => p.Author) + .WithMany() + .OnDelete(DeleteBehavior.Restrict); + modelBuilder.Entity() .HasOne(p => p.Editor) .WithMany() @@ -652,6 +658,11 @@ namespace AsbCloudDb.Model .WithMany() .OnDelete(DeleteBehavior.Restrict); + modelBuilder.Entity() + .HasOne(p => p.Editor) + .WithMany() + .OnDelete(DeleteBehavior.Restrict); + DefaultData.DefaultContextData.Fill(modelBuilder); } diff --git a/AsbCloudDb/Model/IAsbCloudDbContext.cs b/AsbCloudDb/Model/IAsbCloudDbContext.cs index 68b7b7a4..1b7667d0 100644 --- a/AsbCloudDb/Model/IAsbCloudDbContext.cs +++ b/AsbCloudDb/Model/IAsbCloudDbContext.cs @@ -100,6 +100,7 @@ namespace AsbCloudDb.Model DbSet ProcessMapPlanFunctionsUpgradeNoload { get; } DbSet ProcessMapPlanFunctionsOscillation { get; } DbSet ProcessMapPlanFunctionsAnticrashRotation { get; } + DbSet ProcessMapPlanFunctionsStaticMeasure { get; } Task RefreshMaterializedViewAsync(string mwName, CancellationToken token); Task RefreshMaterializedViewAsync(CancellationToken token) where TEntity : class; diff --git a/AsbCloudDb/Model/ProcessMapPlan/ProcessMapPlanFunctionsStaticMeasure.cs b/AsbCloudDb/Model/ProcessMapPlan/ProcessMapPlanFunctionsStaticMeasure.cs new file mode 100644 index 00000000..c4dca7ef --- /dev/null +++ b/AsbCloudDb/Model/ProcessMapPlan/ProcessMapPlanFunctionsStaticMeasure.cs @@ -0,0 +1,18 @@ +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_functions_static_measure"), Comment("Выход статического замера")] +public class ProcessMapPlanFunctionsStaticMeasure : ProcessMapPlanBase +{ + [Column("signal_waiting_time"), Comment("Время ожидания выхода сигнала с ТМС, сек.")] + [Range(0.0, 1800.0)] + [Required] + public double SignalWaitingTime { get; set; } + + [ForeignKey(nameof(IdPrevious))] + public virtual ProcessMapPlanFunctionsStaticMeasure? Previous { get; set; } +} \ No newline at end of file diff --git a/AsbCloudInfrastructure/DependencyInjection.cs b/AsbCloudInfrastructure/DependencyInjection.cs index 94ad1a35..d342492c 100644 --- a/AsbCloudInfrastructure/DependencyInjection.cs +++ b/AsbCloudInfrastructure/DependencyInjection.cs @@ -264,6 +264,13 @@ namespace AsbCloudInfrastructure { Item = src.Adapt() }); + + TypeAdapterConfig>.NewConfig() + .Include>() + .Map(dest => dest, src => new ChangeLogDto() + { + Item = src.Adapt() + }); } public static IServiceCollection AddInfrastructure(this IServiceCollection services, IConfiguration configuration) @@ -401,6 +408,10 @@ namespace AsbCloudInfrastructure IChangeLogRepository, ProcessMapPlanBaseRepository>(); + services.AddTransient< + IChangeLogRepository, + ProcessMapPlanBaseRepository>(); + services.AddTransient(); services.AddTransient(); @@ -465,6 +476,7 @@ namespace AsbCloudInfrastructure services.AddTransient>(); services.AddTransient>(); services.AddTransient>(); + services.AddTransient>(); services.AddTransient(); services.AddTransient(); services.AddTransient(); @@ -538,6 +550,7 @@ namespace AsbCloudInfrastructure services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); services.AddTransient(); services.AddTransient(); @@ -563,6 +576,7 @@ namespace AsbCloudInfrastructure services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); services.AddTransient(); services.AddTransient(); diff --git a/AsbCloudInfrastructure/Services/ExcelServices/Templates/ProcessMapPlanTemplates/ProcessMapPlanFunctionsStaticMeasureTemplate.cs b/AsbCloudInfrastructure/Services/ExcelServices/Templates/ProcessMapPlanTemplates/ProcessMapPlanFunctionsStaticMeasureTemplate.cs new file mode 100644 index 00000000..4bdd00eb --- /dev/null +++ b/AsbCloudInfrastructure/Services/ExcelServices/Templates/ProcessMapPlanTemplates/ProcessMapPlanFunctionsStaticMeasureTemplate.cs @@ -0,0 +1,17 @@ +using System.Collections.Generic; + +namespace AsbCloudInfrastructure.Services.ExcelServices.Templates.ProcessMapPlanTemplates; + +public class ProcessMapPlanFunctionsStaticMeasureTemplate : ITemplateParameters +{ + public string SheetName => "Выход статического замера"; + + public int HeaderRowsCount => 2; + + public string FileName => "ProcessMapPlanFunctionsStaticMeasureTemplate.xlsx"; + + public IDictionary Cells => new Dictionary + { + + }; +} \ No newline at end of file diff --git a/AsbCloudInfrastructure/Services/ProcessMapPlan/Export/ProcessMapPlanFunctionsStaticMeasureExportService.cs b/AsbCloudInfrastructure/Services/ProcessMapPlan/Export/ProcessMapPlanFunctionsStaticMeasureExportService.cs new file mode 100644 index 00000000..7dda5fa1 --- /dev/null +++ b/AsbCloudInfrastructure/Services/ProcessMapPlan/Export/ProcessMapPlanFunctionsStaticMeasureExportService.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 ProcessMapPlanFunctionsStaticMeasureExportService : ProcessMapPlanExportService +{ + public ProcessMapPlanFunctionsStaticMeasureExportService( + IChangeLogRepository processMapPlanRepository, + IWellService wellService) + : base(processMapPlanRepository, wellService) + { + } + + protected override ITemplateParameters TemplateParameters { get; } = new ProcessMapPlanFunctionsStaticMeasureTemplate(); + + 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/ProcessMapPlanFunctionsStaticMeasureParser.cs b/AsbCloudInfrastructure/Services/ProcessMapPlan/Parser/ProcessMapPlanFunctionsStaticMeasureParser.cs new file mode 100644 index 00000000..c286f7cc --- /dev/null +++ b/AsbCloudInfrastructure/Services/ProcessMapPlan/Parser/ProcessMapPlanFunctionsStaticMeasureParser.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 ProcessMapPlanFunctionsStaticMeasureParser : ProcessMapPlanParser +{ + public ProcessMapPlanFunctionsStaticMeasureParser(IWellOperationRepository wellOperationRepository) + : base(wellOperationRepository) + { + } + + protected override ITemplateParameters TemplateParameters => new ProcessMapPlanFunctionsStaticMeasureTemplate(); + + protected override ProcessMapPlanFunctionsStaticMeasureDto 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/ProcessMapPlanFunctionsStaticMeasureController.cs b/AsbCloudWebApi/Controllers/ProcessMaps/ProcessMapPlanFunctionsStaticMeasureController.cs new file mode 100644 index 00000000..8d1e29b0 --- /dev/null +++ b/AsbCloudWebApi/Controllers/ProcessMaps/ProcessMapPlanFunctionsStaticMeasureController.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; + +/// +/// РТК план выход статического замера +/// +public class ProcessMapPlanFunctionsStaticMeasureController : + ProcessMapPlanBaseController +{ + public ProcessMapPlanFunctionsStaticMeasureController( + IChangeLogRepository repository, + IWellService wellService, + ProcessMapPlanFunctionsStaticMeasureParser parserService, + ITelemetryService telemetryService, + ProcessMapPlanFunctionsStaticMeasureExportService processMapPlanExportService) + : base(repository, wellService, parserService, processMapPlanExportService, telemetryService) + { + } + + protected override string TemplateFileName => "ЕЦП_шаблон_файла_РТК_план_выход_статического_замера.xlsx"; +} \ No newline at end of file