diff --git a/AsbCloudApp/Data/ProcessMaps/ProcessMapPlanFunctionsDrillTestDto.cs b/AsbCloudApp/Data/ProcessMaps/ProcessMapPlanFunctionsDrillTestDto.cs index f7d359d0..cb9a1836 100644 --- a/AsbCloudApp/Data/ProcessMaps/ProcessMapPlanFunctionsDrillTestDto.cs +++ b/AsbCloudApp/Data/ProcessMaps/ProcessMapPlanFunctionsDrillTestDto.cs @@ -1,5 +1,4 @@ using System.ComponentModel.DataAnnotations; -using System.ComponentModel.DataAnnotations.Schema; namespace AsbCloudApp.Data.ProcessMaps; diff --git a/AsbCloudApp/Data/ProcessMaps/ProcessMapPlanFunctionsShockTestDto.cs b/AsbCloudApp/Data/ProcessMaps/ProcessMapPlanFunctionsShockTestDto.cs new file mode 100644 index 00000000..d1206259 --- /dev/null +++ b/AsbCloudApp/Data/ProcessMaps/ProcessMapPlanFunctionsShockTestDto.cs @@ -0,0 +1,57 @@ +using System.ComponentModel.DataAnnotations; + +namespace AsbCloudApp.Data.ProcessMaps; + +/// +/// РТК план shocktest +/// +public class ProcessMapPlanFunctionsShockTestDto : ProcessMapPlanBaseDto +{ + /// + /// StickSlip + /// + [Range(0.0, 1000.0)] + public double StickSlip { get; set; } + + /// + /// Whirl + /// + [Range(0.0, 1000.0)] + public double Whirl { get; set; } + + /// + /// Осевые вибрации + /// + [Range(0.0, 1000.0)] + public double AxialVibrations { get; set; } + + /// + /// Комбинированные вибрации + /// + [Range(0.0, 1000.0)] + public double CombinedVibrations { get; set; } + + /// + /// Нагрузка минимальная, т + /// + [Range(1.0, 30.0)] + public double WeightOnBitMin { get; set; } + + /// + /// Минимальные обороты на ВСП, об/мин. + /// + [Range(5, 200)] + public int RevolutionPerMinuteMin { get; set; } + + /// + /// Автозапуск или Предупреждение + /// + [Required] + public int IdAutostartOrWarning { get; set; } + + /// + /// Примечание + /// + [StringLength(1024)] + public string Note { get; set; } = string.Empty; +} \ No newline at end of file diff --git a/AsbCloudDb/Model/AsbCloudDbContext.cs b/AsbCloudDb/Model/AsbCloudDbContext.cs index 1efbb45d..14564500 100644 --- a/AsbCloudDb/Model/AsbCloudDbContext.cs +++ b/AsbCloudDb/Model/AsbCloudDbContext.cs @@ -33,6 +33,7 @@ namespace AsbCloudDb.Model public virtual DbSet ProcessMapPlanOperationSwitchMode => Set(); public virtual DbSet ProcessMapPlanFunctionsDrillTest => Set(); public virtual DbSet ProcessMapPlanFunctionsShockTest => Set(); + public virtual DbSet ProcessMapPlanFunctionsDamper => Set(); public virtual DbSet DrillingProgramParts => Set(); public virtual DbSet FileCategories => Set(); public virtual DbSet Files => Set(); @@ -520,6 +521,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() @@ -585,6 +591,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 81610a3b..fa451394 100644 --- a/AsbCloudDb/Model/IAsbCloudDbContext.cs +++ b/AsbCloudDb/Model/IAsbCloudDbContext.cs @@ -94,6 +94,7 @@ namespace AsbCloudDb.Model DbSet ProcessMapPlanOperationSwitchMode { get; } DbSet ProcessMapPlanFunctionsDrillTest { get; } DbSet ProcessMapPlanFunctionsShockTest { get; } + DbSet ProcessMapPlanFunctionsDamper { get; } Task RefreshMaterializedViewAsync(string mwName, CancellationToken token); Task RefreshMaterializedViewAsync(CancellationToken token) where TEntity : class; diff --git a/AsbCloudDb/Model/ProcessMapPlan/ProcessMapPlanFunctionsDamper.cs b/AsbCloudDb/Model/ProcessMapPlan/ProcessMapPlanFunctionsDamper.cs new file mode 100644 index 00000000..5a2f94f3 --- /dev/null +++ b/AsbCloudDb/Model/ProcessMapPlan/ProcessMapPlanFunctionsDamper.cs @@ -0,0 +1,21 @@ +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_damper"), Comment("Демпфер")] +public class ProcessMapPlanFunctionsDamper : ProcessMapPlanBase +{ + [Column("stickslip"), Comment("StickSlip")] + [Range(0.0, 1000.0)] + [Required] + public double StickSlip { get; set; } + + [Column("note"), Comment("Примечание"), StringLength(1024)] + public string Note { get; set; } = string.Empty; + + [ForeignKey(nameof(IdPrevious))] + public virtual ProcessMapPlanFunctionsDamper? Previous { get; set; } +} \ No newline at end of file diff --git a/AsbCloudInfrastructure/DependencyInjection.cs b/AsbCloudInfrastructure/DependencyInjection.cs index b9ce1119..a684afca 100644 --- a/AsbCloudInfrastructure/DependencyInjection.cs +++ b/AsbCloudInfrastructure/DependencyInjection.cs @@ -222,6 +222,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) @@ -335,6 +342,10 @@ namespace AsbCloudInfrastructure IChangeLogRepository, ProcessMapPlanBaseRepository>(); + services.AddTransient< + IChangeLogRepository, + ProcessMapPlanBaseRepository>(); + services.AddTransient(); services.AddTransient(); @@ -393,6 +404,7 @@ namespace AsbCloudInfrastructure services.AddTransient>(); services.AddTransient>(); services.AddTransient>(); + services.AddTransient>(); services.AddTransient(); services.AddTransient(); services.AddTransient(); @@ -460,6 +472,7 @@ namespace AsbCloudInfrastructure services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); services.AddTransient(); services.AddTransient(); @@ -479,6 +492,7 @@ namespace AsbCloudInfrastructure services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); services.AddTransient(); services.AddTransient(); diff --git a/AsbCloudInfrastructure/Services/ExcelServices/Templates/ProcessMapPlanTemplates/ProcessMapPlanFunctionsDamperTemplate.cs b/AsbCloudInfrastructure/Services/ExcelServices/Templates/ProcessMapPlanTemplates/ProcessMapPlanFunctionsDamperTemplate.cs new file mode 100644 index 00000000..e5bb03e5 --- /dev/null +++ b/AsbCloudInfrastructure/Services/ExcelServices/Templates/ProcessMapPlanTemplates/ProcessMapPlanFunctionsDamperTemplate.cs @@ -0,0 +1,17 @@ +using System.Collections.Generic; + +namespace AsbCloudInfrastructure.Services.ExcelServices.Templates.ProcessMapPlanTemplates; + +public class ProcessMapPlanFunctionsDamperTemplate : ITemplateParameters +{ + public string SheetName => "Демпфер"; + + public int HeaderRowsCount => 2; + + public string FileName => "ProcessMapPlanFunctionsDamperTemplate.xlsx"; + + public IDictionary Cells => new Dictionary + { + + }; +} \ No newline at end of file diff --git a/AsbCloudInfrastructure/Services/ProcessMapPlan/Export/ProcessMapPlanFunctionsDamperExportService.cs b/AsbCloudInfrastructure/Services/ProcessMapPlan/Export/ProcessMapPlanFunctionsDamperExportService.cs new file mode 100644 index 00000000..f05c130c --- /dev/null +++ b/AsbCloudInfrastructure/Services/ProcessMapPlan/Export/ProcessMapPlanFunctionsDamperExportService.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 ProcessMapPlanFunctionsDamperExportService : ProcessMapPlanExportService +{ + public ProcessMapPlanFunctionsDamperExportService( + IChangeLogRepository processMapPlanRepository, + IWellService wellService) + : base(processMapPlanRepository, wellService) + { + } + + protected override ITemplateParameters TemplateParameters { get; } = new ProcessMapPlanFunctionsDamperTemplate(); + + 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/ProcessMapPlanFunctionsDamperParser.cs b/AsbCloudInfrastructure/Services/ProcessMapPlan/Parser/ProcessMapPlanFunctionsDamperParser.cs new file mode 100644 index 00000000..d57c3055 --- /dev/null +++ b/AsbCloudInfrastructure/Services/ProcessMapPlan/Parser/ProcessMapPlanFunctionsDamperParser.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 ProcessMapPlanFunctionsDamperParser : ProcessMapPlanParser +{ + public ProcessMapPlanFunctionsDamperParser(IWellOperationRepository wellOperationRepository) + : base(wellOperationRepository) + { + } + + protected override ITemplateParameters TemplateParameters => new ProcessMapPlanFunctionsDamperTemplate(); + + protected override ProcessMapPlanFunctionsDamperDto 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/ProcessMapPlanFunctionsDamperController.cs b/AsbCloudWebApi/Controllers/ProcessMaps/ProcessMapPlanFunctionsDamperController.cs new file mode 100644 index 00000000..f9a13a4f --- /dev/null +++ b/AsbCloudWebApi/Controllers/ProcessMaps/ProcessMapPlanFunctionsDamperController.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 ProcessMapPlanFunctionsDamperController : + ProcessMapPlanBaseController +{ + public ProcessMapPlanFunctionsDamperController( + IChangeLogRepository repository, + IWellService wellService, + ProcessMapPlanFunctionsDamperParser parserService, + ITelemetryService telemetryService, + ProcessMapPlanFunctionsDamperExportService processMapPlanExportService) + : base(repository, wellService, parserService, processMapPlanExportService, telemetryService) + { + } + + protected override string TemplateFileName => "ЕЦП_шаблон_файла_РТК_план_демпфер.xlsx"; +} \ No newline at end of file