From 52b1e6c04317e864f34db8c2e03c3d27dc2109c7 Mon Sep 17 00:00:00 2001 From: Olga Nemt Date: Tue, 25 Jun 2024 11:05:18 +0500 Subject: [PATCH] =?UTF-8?q?=D0=9E=D0=BF=D1=80=D0=B5=D0=B4=D0=B5=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5=20=D1=83=D0=B3=D0=BB=D0=BE=D0=B2=20?= =?UTF-8?q?=D0=BE=D1=81=D1=86=D0=B8=D0=BB=D0=BB=D1=8F=D1=86=D0=B8=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...tionDeterminationOfOscillationAnglesDto.cs | 46 +++++++++++++++++++ AsbCloudDb/Model/AsbCloudDbContext.cs | 11 +++++ AsbCloudDb/Model/IAsbCloudDbContext.cs | 1 + ...erationDeterminationOfOscillationAngles.cs | 43 +++++++++++++++++ AsbCloudInfrastructure/DependencyInjection.cs | 14 ++++++ ...eterminationOfOscillationAnglesTemplate.cs | 17 +++++++ ...inationOfOscillationAnglesExportService.cs | 30 ++++++++++++ ...nDeterminationOfOscillationAnglesParser.cs | 42 +++++++++++++++++ ...erminationOfOscillationAnglesController.cs | 28 +++++++++++ 9 files changed, 232 insertions(+) create mode 100644 AsbCloudApp/Data/ProcessMaps/ProcessMapPlanOperationDeterminationOfOscillationAnglesDto.cs create mode 100644 AsbCloudDb/Model/ProcessMapPlan/ProcessMapPlanOperationDeterminationOfOscillationAngles.cs create mode 100644 AsbCloudInfrastructure/Services/ExcelServices/Templates/ProcessMapPlanTemplates/ProcessMapPlanOperationDeterminationOfOscillationAnglesTemplate.cs create mode 100644 AsbCloudInfrastructure/Services/ProcessMapPlan/Export/ProcessMapPlanOperationDeterminationOfOscillationAnglesExportService.cs create mode 100644 AsbCloudInfrastructure/Services/ProcessMapPlan/Parser/ProcessMapPlanOperationDeterminationOfOscillationAnglesParser.cs create mode 100644 AsbCloudWebApi/Controllers/ProcessMaps/ProcessMapPlanOperationDeterminationOfOscillationAnglesController.cs diff --git a/AsbCloudApp/Data/ProcessMaps/ProcessMapPlanOperationDeterminationOfOscillationAnglesDto.cs b/AsbCloudApp/Data/ProcessMaps/ProcessMapPlanOperationDeterminationOfOscillationAnglesDto.cs new file mode 100644 index 00000000..351cc144 --- /dev/null +++ b/AsbCloudApp/Data/ProcessMaps/ProcessMapPlanOperationDeterminationOfOscillationAnglesDto.cs @@ -0,0 +1,46 @@ +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace AsbCloudApp.Data.ProcessMaps; + +/// +/// РТК план определения углов осцилляции +/// +public class ProcessMapPlanOperationDeterminationOfOscillationAnglesDto : ProcessMapPlanBaseDto +{ + /// + /// Максимальное давление, атм + /// + [Range(0.0, 400.0)] + public double MaxPressure { get; set; } + + /// + /// Перепад давления, атм. + /// + [Range(0.0, 60.0)] + public double DifferentialPressure { get; set; } + + /// + /// Уставки, т., затяжка + /// + [Range(0.0, 20.0)] + public double SetpointsTight { get; set; } + + /// + /// Уставки, т., посадка + /// + [Range(0.0, 20.0)] + public double SetpointsSlackingOff { get; set; } + + /// + /// Скорость, м/ч., Вверх + /// + [Range(0.0, 999.0)] + public double Reaming1ROPUp { get; set; } + + /// + /// Скорость, м/ч., Вниз + /// + [Range(0.0, 999.0)] + public double Reaming1ROPDown { get; set; } +} \ No newline at end of file diff --git a/AsbCloudDb/Model/AsbCloudDbContext.cs b/AsbCloudDb/Model/AsbCloudDbContext.cs index 4c0cc80d..6deaa5c5 100644 --- a/AsbCloudDb/Model/AsbCloudDbContext.cs +++ b/AsbCloudDb/Model/AsbCloudDbContext.cs @@ -27,6 +27,7 @@ namespace AsbCloudDb.Model public virtual DbSet ProcessMapPlanOperationLoadCapacity => Set(); public virtual DbSet ProcessMapPlanSurvey => Set(); public virtual DbSet ProcessMapPlanOperationPositioningOffTheBottom => Set(); + public virtual DbSet ProcessMapPlanOperationDeterminationOfOscillationAngles => Set(); public virtual DbSet DrillingProgramParts => Set(); public virtual DbSet FileCategories => Set(); public virtual DbSet Files => Set(); @@ -483,6 +484,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() @@ -518,6 +524,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 28bc88f7..c7f8e455 100644 --- a/AsbCloudDb/Model/IAsbCloudDbContext.cs +++ b/AsbCloudDb/Model/IAsbCloudDbContext.cs @@ -88,6 +88,7 @@ namespace AsbCloudDb.Model DbSet ProcessMapPlanOperationLoadCapacity { get; } DbSet ProcessMapPlanSurvey { get; } DbSet ProcessMapPlanOperationPositioningOffTheBottom { get; } + DbSet ProcessMapPlanOperationDeterminationOfOscillationAngles { get; } Task RefreshMaterializedViewAsync(string mwName, CancellationToken token); Task RefreshMaterializedViewAsync(CancellationToken token) where TEntity : class; diff --git a/AsbCloudDb/Model/ProcessMapPlan/ProcessMapPlanOperationDeterminationOfOscillationAngles.cs b/AsbCloudDb/Model/ProcessMapPlan/ProcessMapPlanOperationDeterminationOfOscillationAngles.cs new file mode 100644 index 00000000..148d3274 --- /dev/null +++ b/AsbCloudDb/Model/ProcessMapPlan/ProcessMapPlanOperationDeterminationOfOscillationAngles.cs @@ -0,0 +1,43 @@ +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_operation_oscillation_angels"), Comment("Определение углов осцилляции")] +public class ProcessMapPlanOperationDeterminationOfOscillationAngles : ProcessMapPlanBase +{ + [Column("max_pressure"), Comment("Максимальное давление, атм")] + [Range(0.0, 400.0)] + [Required] + public double MaxPressure { get; set; } + + [Column("differential_pressure"), Comment("Перепад давления, атм.")] + [Range(0.0, 60.0)] + [Required] + public double DifferentialPressure { get; set; } + + [Column("setpoints_tight"), Comment("Уставки, т., затяжка")] + [Range(0.0, 20.0)] + [Required] + public double SetpointsTight { get; set; } + + [Column("setpoints_slacking_off"), Comment("Уставки, т., посадка")] + [Range(0.0, 20.0)] + [Required] + public double SetpointsSlackingOff { get; set; } + + [Column("reaming1_rop_up"), Comment("Скорость, м/ч., Вверх")] + [Range(0.0, 999.0)] + [Required] + public double Reaming1ROPUp { get; set; } + + [Column("reaming1_rop_down"), Comment("Скорость, м/ч., Вниз")] + [Range(0.0, 999.0)] + [Required] + public double Reaming1ROPDown { get; set; } + + [ForeignKey(nameof(IdPrevious))] + public virtual ProcessMapPlanOperationDeterminationOfOscillationAngles? Previous { get; set; } +} \ No newline at end of file diff --git a/AsbCloudInfrastructure/DependencyInjection.cs b/AsbCloudInfrastructure/DependencyInjection.cs index 5482af4e..14356f82 100644 --- a/AsbCloudInfrastructure/DependencyInjection.cs +++ b/AsbCloudInfrastructure/DependencyInjection.cs @@ -180,6 +180,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) @@ -269,6 +276,10 @@ namespace AsbCloudInfrastructure IChangeLogRepository, ProcessMapPlanBaseRepository>(); + services.AddTransient< + IChangeLogRepository, + ProcessMapPlanBaseRepository>(); + services.AddTransient(); services.AddTransient(); @@ -321,6 +332,7 @@ namespace AsbCloudInfrastructure services.AddTransient>(); services.AddTransient>(); services.AddTransient>(); + services.AddTransient>(); services.AddTransient(); services.AddTransient(); services.AddTransient(); @@ -382,6 +394,7 @@ namespace AsbCloudInfrastructure services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); services.AddTransient(); services.AddTransient(); @@ -395,6 +408,7 @@ namespace AsbCloudInfrastructure services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); services.AddTransient(); services.AddTransient(); diff --git a/AsbCloudInfrastructure/Services/ExcelServices/Templates/ProcessMapPlanTemplates/ProcessMapPlanOperationDeterminationOfOscillationAnglesTemplate.cs b/AsbCloudInfrastructure/Services/ExcelServices/Templates/ProcessMapPlanTemplates/ProcessMapPlanOperationDeterminationOfOscillationAnglesTemplate.cs new file mode 100644 index 00000000..ca63f61e --- /dev/null +++ b/AsbCloudInfrastructure/Services/ExcelServices/Templates/ProcessMapPlanTemplates/ProcessMapPlanOperationDeterminationOfOscillationAnglesTemplate.cs @@ -0,0 +1,17 @@ +using System.Collections.Generic; + +namespace AsbCloudInfrastructure.Services.ExcelServices.Templates.ProcessMapPlanTemplates; + +public class ProcessMapPlanOperationDeterminationOfOscillationAnglesTemplate : ITemplateParameters +{ + public string SheetName => "Определение углов осцилляции"; + + public int HeaderRowsCount => 2; + + public string FileName => "ProcessMapPlanOperationDeterminationOfOscillationAnglesTemplate.xlsx"; + + public IDictionary Cells => new Dictionary + { + + }; +} \ No newline at end of file diff --git a/AsbCloudInfrastructure/Services/ProcessMapPlan/Export/ProcessMapPlanOperationDeterminationOfOscillationAnglesExportService.cs b/AsbCloudInfrastructure/Services/ProcessMapPlan/Export/ProcessMapPlanOperationDeterminationOfOscillationAnglesExportService.cs new file mode 100644 index 00000000..4f43f0f9 --- /dev/null +++ b/AsbCloudInfrastructure/Services/ProcessMapPlan/Export/ProcessMapPlanOperationDeterminationOfOscillationAnglesExportService.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 ProcessMapPlanOperationDeterminationOfOscillationAnglesExportService : ProcessMapPlanExportService +{ + public ProcessMapPlanOperationDeterminationOfOscillationAnglesExportService( + IChangeLogRepository processMapPlanRepository, + IWellService wellService) + : base(processMapPlanRepository, wellService) + { + } + + protected override ITemplateParameters TemplateParameters { get; } = new ProcessMapPlanOperationDeterminationOfOscillationAnglesTemplate(); + + 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/ProcessMapPlanOperationDeterminationOfOscillationAnglesParser.cs b/AsbCloudInfrastructure/Services/ProcessMapPlan/Parser/ProcessMapPlanOperationDeterminationOfOscillationAnglesParser.cs new file mode 100644 index 00000000..685b7c7d --- /dev/null +++ b/AsbCloudInfrastructure/Services/ProcessMapPlan/Parser/ProcessMapPlanOperationDeterminationOfOscillationAnglesParser.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 ProcessMapPlanOperationDeterminationOfOscillationAnglesParser : ProcessMapPlanParser +{ + public ProcessMapPlanOperationDeterminationOfOscillationAnglesParser(IWellOperationRepository wellOperationRepository) + : base(wellOperationRepository) + { + } + + protected override ITemplateParameters TemplateParameters => new ProcessMapPlanOperationDeterminationOfOscillationAnglesTemplate(); + + protected override ProcessMapPlanOperationDeterminationOfOscillationAnglesDto 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/ProcessMapPlanOperationDeterminationOfOscillationAnglesController.cs b/AsbCloudWebApi/Controllers/ProcessMaps/ProcessMapPlanOperationDeterminationOfOscillationAnglesController.cs new file mode 100644 index 00000000..7e5311f1 --- /dev/null +++ b/AsbCloudWebApi/Controllers/ProcessMaps/ProcessMapPlanOperationDeterminationOfOscillationAnglesController.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 ProcessMapPlanOperationDeterminationOfOscillationAnglesController : + ProcessMapPlanBaseController +{ + public ProcessMapPlanOperationDeterminationOfOscillationAnglesController( + IChangeLogRepository repository, + IWellService wellService, + ProcessMapPlanOperationDeterminationOfOscillationAnglesParser parserService, + ITelemetryService telemetryService, + ProcessMapPlanOperationDeterminationOfOscillationAnglesExportService processMapPlanExportService) + : base(repository, wellService, parserService, processMapPlanExportService, telemetryService) + { + } + + protected override string TemplateFileName => "ЕЦП_шаблон_файла_РТК_план_позиционирование_над_забоем.xlsx"; +} \ No newline at end of file