diff --git a/AsbCloudApp/Data/ProcessMaps/ProcessMapPlanFunctionsUpgradeNoloadDto.cs b/AsbCloudApp/Data/ProcessMaps/ProcessMapPlanFunctionsUpgradeNoloadDto.cs new file mode 100644 index 00000000..ca780dfa --- /dev/null +++ b/AsbCloudApp/Data/ProcessMaps/ProcessMapPlanFunctionsUpgradeNoloadDto.cs @@ -0,0 +1,20 @@ +using System.ComponentModel.DataAnnotations; + +namespace AsbCloudApp.Data.ProcessMaps; + +/// +/// РТК план обновление холостого хода +/// +public class ProcessMapPlanFunctionsUpgradeNoloadDto : ProcessMapPlanBaseDto +{ + /// + /// СПУСК ОК Да/Нет + /// + public double IdDeclineSocketColumn { 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 ec6a444a..54e9acba 100644 --- a/AsbCloudDb/Model/AsbCloudDbContext.cs +++ b/AsbCloudDb/Model/AsbCloudDbContext.cs @@ -37,6 +37,7 @@ namespace AsbCloudDb.Model public virtual DbSet ProcessMapPlanFunctionsAutoHold => Set(); public virtual DbSet ProcessMapPlanFunctionsJarrDrillTool => Set(); public virtual DbSet ProcessMapPlanFunctionsUpgradeNoload => Set(); + public virtual DbSet ProcessMapPlanFunctionsOscillation => Set(); public virtual DbSet DrillingProgramParts => Set(); public virtual DbSet FileCategories => Set(); public virtual DbSet Files => Set(); @@ -544,6 +545,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() @@ -629,6 +635,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 4938f956..f662f31a 100644 --- a/AsbCloudDb/Model/IAsbCloudDbContext.cs +++ b/AsbCloudDb/Model/IAsbCloudDbContext.cs @@ -98,6 +98,7 @@ namespace AsbCloudDb.Model DbSet ProcessMapPlanFunctionsAutoHold { get; } DbSet ProcessMapPlanFunctionsJarrDrillTool { get; } DbSet ProcessMapPlanFunctionsUpgradeNoload { get; } + DbSet ProcessMapPlanFunctionsOscillation { get; } Task RefreshMaterializedViewAsync(string mwName, CancellationToken token); Task RefreshMaterializedViewAsync(CancellationToken token) where TEntity : class; diff --git a/AsbCloudDb/Model/ProcessMapPlan/ProcessMapPlanFunctionsOscillation.cs b/AsbCloudDb/Model/ProcessMapPlan/ProcessMapPlanFunctionsOscillation.cs new file mode 100644 index 00000000..1dc4aaab --- /dev/null +++ b/AsbCloudDb/Model/ProcessMapPlan/ProcessMapPlanFunctionsOscillation.cs @@ -0,0 +1,45 @@ +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_oscillation"), Comment("Осцилляция")] +public class ProcessMapPlanFunctionsOscillation : ProcessMapPlanBase +{ + [Column("optimal_oscillation_angle"), Comment("Оптимальный угол осцилляции, градусы")] + [Range(0.0, 6000.0)] + [Required] + public double OptimalOscillationAngle { get; set; } + + [Column("RPM​_right"), Comment("Скорость вправо, об/мин")] + [Range(0.0, 270.0)] + [Required] + public double RPM​Right { get; set; } + + [Column("RPM​_left"), Comment("Скорость влево, об/мин")] + [Range(0.0, 270.0)] + [Required] + public double RPM​Left { get; set; } + + [Column("torque_limit_right"), Comment("Ограничение момента вправо, кН*м")] + [Range(0.0, 35.0)] + [Required] + public double TorqueLimitRight { get; set; } + + [Column("torque_limit_left"), Comment("Ограничение момента влево, кН*м")] + [Range(0.0, 35.0)] + [Required] + public double TorqueLimitLeft { get; set; } + + [Column("id_mode"), Comment("Режим Авто/Руч")] + [Required] + public double Mode { get; set; } + + [Column("note"), Comment("Примечание"), StringLength(1024)] + public string Note { get; set; } = string.Empty; + + [ForeignKey(nameof(IdPrevious))] + public virtual ProcessMapPlanFunctionsOscillation? Previous { get; set; } +} \ No newline at end of file diff --git a/AsbCloudInfrastructure/DependencyInjection.cs b/AsbCloudInfrastructure/DependencyInjection.cs index ba779461..22e9078a 100644 --- a/AsbCloudInfrastructure/DependencyInjection.cs +++ b/AsbCloudInfrastructure/DependencyInjection.cs @@ -250,6 +250,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) @@ -379,6 +386,10 @@ namespace AsbCloudInfrastructure IChangeLogRepository, ProcessMapPlanBaseRepository>(); + services.AddTransient< + IChangeLogRepository, + ProcessMapPlanBaseRepository>(); + services.AddTransient(); services.AddTransient(); @@ -441,6 +452,7 @@ namespace AsbCloudInfrastructure services.AddTransient>(); services.AddTransient>(); services.AddTransient>(); + services.AddTransient>(); services.AddTransient(); services.AddTransient(); services.AddTransient(); @@ -512,6 +524,7 @@ namespace AsbCloudInfrastructure services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); services.AddTransient(); services.AddTransient(); @@ -535,6 +548,7 @@ namespace AsbCloudInfrastructure services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); services.AddTransient(); services.AddTransient(); diff --git a/AsbCloudInfrastructure/Services/ExcelServices/Templates/ProcessMapPlanTemplates/ProcessMapPlanFunctionsOscillationTemplate.cs b/AsbCloudInfrastructure/Services/ExcelServices/Templates/ProcessMapPlanTemplates/ProcessMapPlanFunctionsOscillationTemplate.cs new file mode 100644 index 00000000..65dfdd9f --- /dev/null +++ b/AsbCloudInfrastructure/Services/ExcelServices/Templates/ProcessMapPlanTemplates/ProcessMapPlanFunctionsOscillationTemplate.cs @@ -0,0 +1,17 @@ +using System.Collections.Generic; + +namespace AsbCloudInfrastructure.Services.ExcelServices.Templates.ProcessMapPlanTemplates; + +public class ProcessMapPlanFunctionsOscillationTemplate : ITemplateParameters +{ + public string SheetName => "Осцилляция"; + + public int HeaderRowsCount => 2; + + public string FileName => "ProcessMapPlanFunctionsOscillationTemplate.xlsx"; + + public IDictionary Cells => new Dictionary + { + + }; +} \ No newline at end of file diff --git a/AsbCloudInfrastructure/Services/ProcessMapPlan/Export/ProcessMapPlanFunctionsOscillationExportService.cs b/AsbCloudInfrastructure/Services/ProcessMapPlan/Export/ProcessMapPlanFunctionsOscillationExportService.cs new file mode 100644 index 00000000..da8631c1 --- /dev/null +++ b/AsbCloudInfrastructure/Services/ProcessMapPlan/Export/ProcessMapPlanFunctionsOscillationExportService.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 ProcessMapPlanFunctionsOscillationExportService : ProcessMapPlanExportService +{ + public ProcessMapPlanFunctionsOscillationExportService( + IChangeLogRepository processMapPlanRepository, + IWellService wellService) + : base(processMapPlanRepository, wellService) + { + } + + protected override ITemplateParameters TemplateParameters { get; } = new ProcessMapPlanFunctionsOscillationTemplate(); + + 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/ProcessMapPlanFunctionsOscillationParser.cs b/AsbCloudInfrastructure/Services/ProcessMapPlan/Parser/ProcessMapPlanFunctionsOscillationParser.cs new file mode 100644 index 00000000..b7966539 --- /dev/null +++ b/AsbCloudInfrastructure/Services/ProcessMapPlan/Parser/ProcessMapPlanFunctionsOscillationParser.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 ProcessMapPlanFunctionsOscillationParser : ProcessMapPlanParser +{ + public ProcessMapPlanFunctionsOscillationParser(IWellOperationRepository wellOperationRepository) + : base(wellOperationRepository) + { + } + + protected override ITemplateParameters TemplateParameters => new ProcessMapPlanFunctionsOscillationTemplate(); + + protected override ProcessMapPlanFunctionsOscillationDto 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/ProcessMapPlanFunctionsOscillationController.cs b/AsbCloudWebApi/Controllers/ProcessMaps/ProcessMapPlanFunctionsOscillationController.cs new file mode 100644 index 00000000..a8d1f155 --- /dev/null +++ b/AsbCloudWebApi/Controllers/ProcessMaps/ProcessMapPlanFunctionsOscillationController.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 ProcessMapPlanFunctionsOscillationController : + ProcessMapPlanBaseController +{ + public ProcessMapPlanFunctionsOscillationController( + IChangeLogRepository repository, + IWellService wellService, + ProcessMapPlanFunctionsOscillationParser parserService, + ITelemetryService telemetryService, + ProcessMapPlanFunctionsOscillationExportService processMapPlanExportService) + : base(repository, wellService, parserService, processMapPlanExportService, telemetryService) + { + } + + protected override string TemplateFileName => "ЕЦП_шаблон_файла_РТК_план_осцилляция.xlsx"; +} \ No newline at end of file