From d07f5f182af58d5674fdd9d416c30612d0bfc900 Mon Sep 17 00:00:00 2001 From: Olga Nemt Date: Tue, 20 Feb 2024 15:54:18 +0500 Subject: [PATCH] =?UTF-8?q?=D0=97=D0=B0=D0=BC=D0=B5=D0=BD=D0=B0=20=D1=80?= =?UTF-8?q?=D0=B5=D0=BF=D0=BE=D0=B7=D0=B8=D1=82=D0=BE=D1=80=D0=B8=D1=8F=20?= =?UTF-8?q?ProcessMapPlanRepository=20=D0=BD=D0=B0=20ChangeLogRepositoryAb?= =?UTF-8?q?stract?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ProcessMaps/ProcessMapPlanWellReamDto.cs | 2 +- .../Repositories/IProcessMapPlanRepository.cs | 32 -- .../Repositories/IWellCompositeRepository.cs | 4 +- .../ProcessMaps/IProcessMapPlanService.cs | 3 +- ...ocessMapReportWellDrillingExportService.cs | 19 - .../IProcessMapReportWellDrillingService.cs | 20 - .../AsbCloudInfrastructure.csproj | 1 - AsbCloudInfrastructure/DependencyInjection.cs | 52 ++- .../Repository/ProcessMapPlanRepository.cs | 89 ----- .../Repository/WellCompositeRepository.cs | 15 +- .../DailyReport/DailyReportService.cs | 13 +- .../ProcessMaps/ProcessMapPlanService.cs | 91 ++--- ...ocessMapReportWellDrillingExportService.cs | 195 ---------- .../ProcessMapReportWellDrillingService.cs | 235 ----------- ...ProcessMapPlanImportWellDrillingService.cs | 368 ------------------ ...cessMapPlanImportWellDrillingTemplate.xlsx | Bin 12611 -> 0 bytes .../Services/WellInfoService.cs | 32 +- .../Services/DailyReportServiceTest.cs | 21 +- .../ProcessMaps/ProcessMapPlanServiceTests.cs | 28 +- .../ProcessMaps/ProcessMapBaseController.cs | 48 +-- .../ProcessMapWellDrillingController.cs | 85 +--- .../ProcessMapWellReamController.cs | 23 +- AsbCloudWebApi/appsettings.json | 6 +- 23 files changed, 176 insertions(+), 1206 deletions(-) delete mode 100644 AsbCloudApp/Repositories/IProcessMapPlanRepository.cs delete mode 100644 AsbCloudApp/Services/ProcessMaps/WellDrilling/IProcessMapReportWellDrillingExportService.cs delete mode 100644 AsbCloudApp/Services/ProcessMaps/WellDrilling/IProcessMapReportWellDrillingService.cs delete mode 100644 AsbCloudInfrastructure/Repository/ProcessMapPlanRepository.cs delete mode 100644 AsbCloudInfrastructure/Services/ProcessMaps/Report/ProcessMapReportWellDrillingExportService.cs delete mode 100644 AsbCloudInfrastructure/Services/ProcessMaps/Report/ProcessMapReportWellDrillingService.cs delete mode 100644 AsbCloudInfrastructure/Services/ProcessMaps/WellDrilling/ProcessMapPlanImportWellDrillingService.cs delete mode 100644 AsbCloudInfrastructure/Services/ProcessMaps/WellDrilling/ProcessMapPlanImportWellDrillingTemplate.xlsx diff --git a/AsbCloudApp/Data/ProcessMaps/ProcessMapPlanWellReamDto.cs b/AsbCloudApp/Data/ProcessMaps/ProcessMapPlanWellReamDto.cs index e577ff86..ed3c57da 100644 --- a/AsbCloudApp/Data/ProcessMaps/ProcessMapPlanWellReamDto.cs +++ b/AsbCloudApp/Data/ProcessMaps/ProcessMapPlanWellReamDto.cs @@ -6,7 +6,7 @@ namespace AsbCloudApp.Data.ProcessMaps; /// /// РТК план проработка скважины /// -public class ProcessMapPlanWellReamDto : ProcessMapPlanBaseDto, IValidatableObject +public class ProcessMapPlanWellReamDto : AsbCloudApp.Data.ProcessMapPlan.ProcessMapPlanBaseDto, IValidatableObject { /// /// Количество повторений diff --git a/AsbCloudApp/Repositories/IProcessMapPlanRepository.cs b/AsbCloudApp/Repositories/IProcessMapPlanRepository.cs deleted file mode 100644 index 7e41cb58..00000000 --- a/AsbCloudApp/Repositories/IProcessMapPlanRepository.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System.Collections.Generic; -using System.Threading.Tasks; -using System.Threading; -using AsbCloudApp.Data.ProcessMaps; -using AsbCloudApp.Requests; -using AsbCloudApp.Services; -using System; - -namespace AsbCloudApp.Repositories; - -/// -/// РТК план -/// -[Obsolete] -public interface IProcessMapPlanRepository : IRepositoryWellRelated - where TDto : ProcessMapPlanBaseDto -{ - /// - /// Получить РТК по коллекции параметров - /// - /// - /// - /// - Task> GetAsync(IEnumerable requests, CancellationToken cancellationToken); - - /// - /// Удалить РТК по скважине - /// - /// - /// - Task RemoveByWellAsync(int idWell); -} diff --git a/AsbCloudApp/Repositories/IWellCompositeRepository.cs b/AsbCloudApp/Repositories/IWellCompositeRepository.cs index 5354a587..e03fec53 100644 --- a/AsbCloudApp/Repositories/IWellCompositeRepository.cs +++ b/AsbCloudApp/Repositories/IWellCompositeRepository.cs @@ -1,8 +1,8 @@ using AsbCloudApp.Data; +using AsbCloudApp.Data.ProcessMapPlan; using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; -using AsbCloudApp.Data.ProcessMaps; namespace AsbCloudApp.Repositories { @@ -34,6 +34,6 @@ namespace AsbCloudApp.Repositories /// /// /// - Task> GetCompositeProcessMap(int idWell, CancellationToken token); + Task> GetCompositeProcessMap(int idWell, CancellationToken token); } } diff --git a/AsbCloudApp/Services/ProcessMaps/IProcessMapPlanService.cs b/AsbCloudApp/Services/ProcessMaps/IProcessMapPlanService.cs index 2400dddf..7068ed47 100644 --- a/AsbCloudApp/Services/ProcessMaps/IProcessMapPlanService.cs +++ b/AsbCloudApp/Services/ProcessMaps/IProcessMapPlanService.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; using AsbCloudApp.Data; -using AsbCloudApp.Data.ProcessMaps; namespace AsbCloudApp.Services.ProcessMaps; @@ -10,7 +9,7 @@ namespace AsbCloudApp.Services.ProcessMaps; /// РТК /// public interface IProcessMapPlanService - where T : ProcessMapPlanBaseDto + where T : AsbCloudApp.Data.ProcessMapPlan.ProcessMapPlanBaseDto { /// /// Получение РТК план по скважине diff --git a/AsbCloudApp/Services/ProcessMaps/WellDrilling/IProcessMapReportWellDrillingExportService.cs b/AsbCloudApp/Services/ProcessMaps/WellDrilling/IProcessMapReportWellDrillingExportService.cs deleted file mode 100644 index 4a262fa8..00000000 --- a/AsbCloudApp/Services/ProcessMaps/WellDrilling/IProcessMapReportWellDrillingExportService.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System.IO; -using System.Threading.Tasks; -using System.Threading; - -namespace AsbCloudApp.Services.ProcessMaps.WellDrilling; - -/// -/// Сервис экспорт РТК -/// -public interface IProcessMapReportWellDrillingExportService -{ - /// - /// Сформировать файл с данными - /// - /// - /// - /// - Task<(string Name, Stream File)?> ExportAsync(int idWell, CancellationToken cancellationToken); -} \ No newline at end of file diff --git a/AsbCloudApp/Services/ProcessMaps/WellDrilling/IProcessMapReportWellDrillingService.cs b/AsbCloudApp/Services/ProcessMaps/WellDrilling/IProcessMapReportWellDrillingService.cs deleted file mode 100644 index 52079d92..00000000 --- a/AsbCloudApp/Services/ProcessMaps/WellDrilling/IProcessMapReportWellDrillingService.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System.Collections.Generic; -using System.Threading; -using System.Threading.Tasks; -using AsbCloudApp.Data.ProcessMaps.Report; - -namespace AsbCloudApp.Services.ProcessMaps.WellDrilling; - -/// -/// Сервис формирования отчёта РТК бурение -/// -public interface IProcessMapReportWellDrillingService -{ - /// - /// Получить отчёт РТК по бурению - /// - /// - /// - /// - Task> GetAsync(int idWell, CancellationToken token); -} \ No newline at end of file diff --git a/AsbCloudInfrastructure/AsbCloudInfrastructure.csproj b/AsbCloudInfrastructure/AsbCloudInfrastructure.csproj index 5579d2b2..c690af5c 100644 --- a/AsbCloudInfrastructure/AsbCloudInfrastructure.csproj +++ b/AsbCloudInfrastructure/AsbCloudInfrastructure.csproj @@ -48,7 +48,6 @@ - diff --git a/AsbCloudInfrastructure/DependencyInjection.cs b/AsbCloudInfrastructure/DependencyInjection.cs index ce742684..72e1bde2 100644 --- a/AsbCloudInfrastructure/DependencyInjection.cs +++ b/AsbCloudInfrastructure/DependencyInjection.cs @@ -1,23 +1,27 @@ -using System; -using System.Collections.Generic; -using AsbCloudApp.Data; +using AsbCloudApp.Data; +using AsbCloudApp.Data.DailyReport.Blocks.TimeBalance; using AsbCloudApp.Data.DrillTestReport; using AsbCloudApp.Data.Manuals; +using AsbCloudApp.Data.ProcessMapPlan; using AsbCloudApp.Data.ProcessMaps; using AsbCloudApp.Data.SAUB; using AsbCloudApp.Data.Subsystems; using AsbCloudApp.Data.Trajectory; using AsbCloudApp.Data.WellOperationImport.Options; using AsbCloudApp.Repositories; +using AsbCloudApp.Requests; using AsbCloudApp.Services; +using AsbCloudApp.Services.DailyReport; using AsbCloudApp.Services.Notifications; using AsbCloudApp.Services.ProcessMaps; using AsbCloudApp.Services.ProcessMaps.WellDrilling; using AsbCloudApp.Services.WellOperationImport; using AsbCloudDb.Model; +using AsbCloudDb.Model.DailyReports.Blocks.TimeBalance; using AsbCloudDb.Model.Manuals; using AsbCloudDb.Model.ProcessMaps; using AsbCloudDb.Model.Trajectory; +using AsbCloudDb.Model.WellSections; using AsbCloudInfrastructure.Background; using AsbCloudInfrastructure.Repository; using AsbCloudInfrastructure.Services; @@ -25,12 +29,14 @@ using AsbCloudInfrastructure.Services.DailyReport; using AsbCloudInfrastructure.Services.DetectOperations; using AsbCloudInfrastructure.Services.DrillingProgram; using AsbCloudInfrastructure.Services.DrillTestReport; +using AsbCloudInfrastructure.Services.ProcessMapPlan.Parser; +using AsbCloudInfrastructure.Services.ProcessMaps; using AsbCloudInfrastructure.Services.ProcessMaps.Report; -using AsbCloudInfrastructure.Services.ProcessMaps.WellDrilling; using AsbCloudInfrastructure.Services.SAUB; using AsbCloudInfrastructure.Services.Subsystems; using AsbCloudInfrastructure.Services.Trajectory; using AsbCloudInfrastructure.Services.Trajectory.Export; +using AsbCloudInfrastructure.Services.Trajectory.Parser; using AsbCloudInfrastructure.Services.WellOperationImport; using AsbCloudInfrastructure.Services.WellOperationImport.FileParser; using AsbCloudInfrastructure.Services.WellOperationService; @@ -39,16 +45,7 @@ using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Caching.Memory; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; -using AsbCloudApp.Data.DailyReport.Blocks.TimeBalance; -using AsbCloudApp.Services.DailyReport; -using AsbCloudDb.Model.DailyReports.Blocks.TimeBalance; -using AsbCloudDb.Model.WellSections; -using AsbCloudInfrastructure.Services.ProcessMaps; -using AsbCloudApp.Data.ProcessMapPlan; -using AsbCloudApp.Requests; -using AsbCloudInfrastructure.Services.Parser; -using AsbCloudInfrastructure.Services.ProcessMapPlan.Parser; -using AsbCloudInfrastructure.Services.Trajectory.Parser; +using System; namespace AsbCloudInfrastructure { @@ -144,21 +141,21 @@ namespace AsbCloudInfrastructure .Map(dest => dest.TopDriveSpeedLimitMax, src => src.TopDriveSpeed.LimitMax) .Map(dest => dest.TopDriveTorquePlan, src => src.TopDriveTorque.Plan) .Map(dest => dest.TopDriveTorqueLimitMax, src => src.TopDriveTorque.LimitMax); - - + + TypeAdapterConfig.GlobalSettings.Default.Config .ForType() .Map(dest => dest.DurationHours, src => new PlanFactDto() { - Plan = src.DurationHoursPlan, - Fact = src.DurationHoursFact + Plan = src.DurationHoursPlan, + Fact = src.DurationHoursFact }); TypeAdapterConfig.GlobalSettings.Default.Config .ForType() .Map(dest => dest.WellDepth, src => new PlanFactDto() { - Plan = src.WellDepthPlan + Plan = src.WellDepthPlan }); } @@ -188,8 +185,6 @@ namespace AsbCloudInfrastructure services.AddSingleton(provider => ReduceSamplingService.GetInstance(configuration)); services.AddTransient(); - services.AddTransient, ProcessMapPlanRepository>(); - services.AddTransient, ProcessMapPlanRepository>(); services.AddTransient(); services.AddTransient(); services.AddTransient(); @@ -204,7 +199,6 @@ namespace AsbCloudInfrastructure services.AddTransient(); services.AddScoped(); services.AddTransient(); - services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); @@ -219,17 +213,19 @@ namespace AsbCloudInfrastructure services.AddTransient(); services.AddTransient(); services.AddTransient(); - services.AddTransient(); - services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient< - IChangeLogRepository, + IChangeLogRepository, ProcessMapPlanBaseRepository>(); + services.AddTransient< + IChangeLogRepository, + ProcessMapPlanBaseRepository>(); + services.AddTransient(); services.AddTransient(); @@ -304,7 +300,7 @@ namespace AsbCloudInfrastructure services.AddTransient, WitsRecordRepository>(); services.AddTransient, WitsRecordRepository>(); services.AddTransient, WitsRecordRepository>(); - + services.AddTransient(); services.AddTransient, DrillTestReportMakerService>(); @@ -326,10 +322,10 @@ namespace AsbCloudInfrastructure services.AddTransient(); services.AddTransient(); services.AddTransient(); - + services.AddTransient, CrudWellRelatedRepositoryBase>(); - services.AddTransient, ProcessMapPlanService>(); + services.AddTransient, ProcessMapPlanService>(); services.AddTransient, ProcessMapPlanService>(); services.AddTransient(); diff --git a/AsbCloudInfrastructure/Repository/ProcessMapPlanRepository.cs b/AsbCloudInfrastructure/Repository/ProcessMapPlanRepository.cs deleted file mode 100644 index a2a78659..00000000 --- a/AsbCloudInfrastructure/Repository/ProcessMapPlanRepository.cs +++ /dev/null @@ -1,89 +0,0 @@ -using System.Collections.Generic; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; -using AsbCloudApp.Data.ProcessMaps; -using AsbCloudApp.Exceptions; -using AsbCloudApp.Repositories; -using AsbCloudApp.Requests; -using AsbCloudApp.Services; -using AsbCloudDb.Model; -using AsbCloudDb.Model.ProcessMaps; -using Microsoft.EntityFrameworkCore; - -namespace AsbCloudInfrastructure.Repository; - -public class ProcessMapPlanRepository : CrudWellRelatedRepositoryBase, - IProcessMapPlanRepository - where TDto : ProcessMapPlanBaseDto - where TEntity : ProcessMapBase -{ - private readonly IWellService wellService; - - public ProcessMapPlanRepository(IAsbCloudDbContext context, IWellService wellService) - : base(context, dbSet => - dbSet - .Include(p => p.WellSectionType) - .Include(p => p.Well)) - { - this.wellService = wellService; - } - - public async Task> GetAsync(IEnumerable requests, CancellationToken cancellationToken) - { - var query = BuildQuery(requests); - - var entities = await query.ToArrayAsync(cancellationToken); - - return entities.Select(Convert); - } - - public Task RemoveByWellAsync(int idWell) - { - var query = GetQuery().Where(x => x.IdWell == idWell); - - dbSet.RemoveRange(query); - - return dbContext.SaveChangesAsync(CancellationToken.None); - } - - private IQueryable BuildQuery(IEnumerable requests) - { - var queries = requests - .Select(request => BuildQuery(request)) - .ToArray(); - - var query = queries.FirstOrDefault() - ?? throw new ArgumentInvalidException(nameof(requests), "Пустые запросы недопустимы"); - - for ( var i = 1; i < queries.Length; i++) - query = query.Union(queries[i]); - - query = query - .Distinct() - .OrderBy(e => e.DepthStart) - .ThenBy(e => e.Id) - .AsNoTracking(); - - return query; - } - - private IQueryable BuildQuery(ProcessMapPlanRequest request) - { - var query = GetQuery(); - - query = query.Where(p => p.IdWell == request.IdWell); - - if (request.IdWellSectionType is not null) - query = query.Where(p => p.IdWellSectionType == request.IdWellSectionType); - - if (request.UpdateFrom is not null) - { - var timezone = wellService.GetTimezone(request.IdWell); - var updateFromUtc = request.UpdateFrom?.ToUtcDateTimeOffset(timezone.Hours); - - query = query.Where(p => p.LastUpdate >= updateFromUtc); - } - return query; - } -} \ No newline at end of file diff --git a/AsbCloudInfrastructure/Repository/WellCompositeRepository.cs b/AsbCloudInfrastructure/Repository/WellCompositeRepository.cs index 0f30f1a4..86860d79 100644 --- a/AsbCloudInfrastructure/Repository/WellCompositeRepository.cs +++ b/AsbCloudInfrastructure/Repository/WellCompositeRepository.cs @@ -1,4 +1,5 @@ using AsbCloudApp.Data; +using AsbCloudApp.Data.ProcessMapPlan; using AsbCloudApp.Data.ProcessMaps; using AsbCloudApp.Repositories; using AsbCloudApp.Requests; @@ -17,12 +18,14 @@ namespace AsbCloudInfrastructure.Repository public class WellCompositeRepository : IWellCompositeRepository { private readonly IAsbCloudDbContext db; - private readonly IProcessMapPlanRepository processMapPlanWellDrillingRepository; + private readonly IChangeLogRepository processMapPlanDrillingRepository; - public WellCompositeRepository(IAsbCloudDbContext db, IProcessMapPlanRepository processMapPlanWellDrillingRepository) + public WellCompositeRepository( + IAsbCloudDbContext db, + IChangeLogRepository processMapPlanDrillingRepository) { this.db = db; - this.processMapPlanWellDrillingRepository = processMapPlanWellDrillingRepository; + this.processMapPlanDrillingRepository = processMapPlanDrillingRepository; } /// @@ -50,7 +53,7 @@ namespace AsbCloudInfrastructure.Repository } /// - public async Task> GetCompositeProcessMap(int idWell, CancellationToken token) + public async Task> GetCompositeProcessMap(int idWell, CancellationToken token) { var dtos = await GetAsync(idWell, token); @@ -59,8 +62,8 @@ namespace AsbCloudInfrastructure.Repository IdWellSectionType = x.IdWellSectionType }); - var result = await processMapPlanWellDrillingRepository.GetAsync(requests, token); - return result; + //var result = await processMapPlanDrillingRepository.GetAsync(requests, token); + return Enumerable.Empty(); } private static WellComposite Convert(int idWell, WellCompositeDto dto) diff --git a/AsbCloudInfrastructure/Services/DailyReport/DailyReportService.cs b/AsbCloudInfrastructure/Services/DailyReport/DailyReportService.cs index 87108fd2..29dd68ce 100644 --- a/AsbCloudInfrastructure/Services/DailyReport/DailyReportService.cs +++ b/AsbCloudInfrastructure/Services/DailyReport/DailyReportService.cs @@ -29,7 +29,7 @@ public class DailyReportService : IDailyReportService private readonly IScheduleRepository scheduleRepository; private readonly IWellOperationRepository wellOperationRepository; private readonly ISubsystemService subsystemService; - private readonly IProcessMapReportWellDrillingService processMapReportWellDrillingService; + private readonly IProcessMapReportDataSaubStatService processMapReportDataSaubStatService; private readonly IDetectedOperationService detectedOperationService; public DailyReportService(IWellService wellService, @@ -38,7 +38,7 @@ public class DailyReportService : IDailyReportService IScheduleRepository scheduleRepository, IWellOperationRepository wellOperationRepository, ISubsystemService subsystemService, - IProcessMapReportWellDrillingService processMapReportWellDrillingService, + IProcessMapReportDataSaubStatService processMapReportDataSaubStatService, IDetectedOperationService detectedOperationService) { this.wellService = wellService; @@ -47,7 +47,7 @@ public class DailyReportService : IDailyReportService this.scheduleRepository = scheduleRepository; this.wellOperationRepository = wellOperationRepository; this.subsystemService = subsystemService; - this.processMapReportWellDrillingService = processMapReportWellDrillingService; + this.processMapReportDataSaubStatService = processMapReportDataSaubStatService; this.detectedOperationService = detectedOperationService; } @@ -374,8 +374,9 @@ public class DailyReportService : IDailyReportService { var geDate = dailyReport.Date.ToDateTime(TimeOnly.MinValue, DateTimeKind.Unspecified); var leDate = dailyReport.Date.AddDays(1).ToDateTime(TimeOnly.MinValue, DateTimeKind.Unspecified); - - dailyReport.ProcessMapWellDrillingBlock = (await processMapReportWellDrillingService.GetAsync(dailyReport.IdWell, + + var request = new DataSaubStatRequest(); + dailyReport.ProcessMapWellDrillingBlock = (await processMapReportDataSaubStatService.GetAsync(dailyReport.IdWell, request, cancellationToken)).Where(p => p.DateStart >= geDate && p.DateStart <= leDate) .GroupBy(p => p.DrillingMode) .Select(g => new ProcessMapWellDrillingRecordDto @@ -387,7 +388,7 @@ public class DailyReportService : IDailyReportService Plan = g.Sum(p => p.Rop.Plan), Fact = g.Sum(p => p.Rop.Fact) }, - MechDrillingHours = g.Sum(p => p.MechDrillingHours) + MechDrillingHours = g.Sum(p => p.DrilledTime) }); } diff --git a/AsbCloudInfrastructure/Services/ProcessMaps/ProcessMapPlanService.cs b/AsbCloudInfrastructure/Services/ProcessMaps/ProcessMapPlanService.cs index 2737e899..27e0170e 100644 --- a/AsbCloudInfrastructure/Services/ProcessMaps/ProcessMapPlanService.cs +++ b/AsbCloudInfrastructure/Services/ProcessMaps/ProcessMapPlanService.cs @@ -1,65 +1,68 @@ +using AsbCloudApp.Data; +using AsbCloudApp.Data.ProcessMaps; +using AsbCloudApp.Repositories; +using AsbCloudApp.Requests; +using AsbCloudApp.Services; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.Linq; using System.Threading; using System.Threading.Tasks; -using AsbCloudApp.Data; -using AsbCloudApp.Data.ProcessMaps; -using AsbCloudApp.Repositories; -using AsbCloudApp.Services; -using AsbCloudApp.Services.ProcessMaps; namespace AsbCloudInfrastructure.Services.ProcessMaps; -public class ProcessMapPlanService : IProcessMapPlanService - where T : ProcessMapPlanBaseDto +public class ProcessMapPlanService : AsbCloudApp.Services.ProcessMaps.IProcessMapPlanService + where T : AsbCloudApp.Data.ProcessMapPlan.ProcessMapPlanBaseDto { - private readonly ICrudRepository wellSectionTypeRepository; - private readonly IProcessMapPlanRepository processMapPlanRepository; - private readonly IRepositoryWellRelated wellSectionPlanRepository; + private readonly ICrudRepository wellSectionTypeRepository; + private readonly IChangeLogRepository processMapPlanBaseRepository; + private readonly IRepositoryWellRelated wellSectionPlanRepository; - public ProcessMapPlanService(ICrudRepository wellSectionTypeRepository, - IProcessMapPlanRepository processMapPlanRepository, - IRepositoryWellRelated wellSectionPlanRepository) - { - this.wellSectionTypeRepository = wellSectionTypeRepository; - this.processMapPlanRepository = processMapPlanRepository; - this.wellSectionPlanRepository = wellSectionPlanRepository; - } + public ProcessMapPlanService( + ICrudRepository wellSectionTypeRepository, + IChangeLogRepository processMapPlanBaseRepository, + IRepositoryWellRelated wellSectionPlanRepository) + { + this.wellSectionTypeRepository = wellSectionTypeRepository; + this.processMapPlanBaseRepository = processMapPlanBaseRepository; + this.wellSectionPlanRepository = wellSectionPlanRepository; + } - public async Task>> GetAsync(int idWell, CancellationToken cancellationToken) - { - var wellSectionTypes = await wellSectionTypeRepository.GetAllAsync(cancellationToken); + public async Task>> GetAsync(int idWell, CancellationToken cancellationToken) + { + var wellSectionTypes = await wellSectionTypeRepository.GetAllAsync(cancellationToken); - var processMapsPlan = await processMapPlanRepository.GetByIdWellAsync(idWell, cancellationToken); + var request = new ProcessMapPlanBaseRequestWithWell(idWell); - var wellSectionsPlan = await wellSectionPlanRepository.GetByIdWellAsync(idWell, cancellationToken); + var processMapsPlan = await processMapPlanBaseRepository.Get(request, cancellationToken); - return processMapsPlan.Select(processMapPlan => - { - var wellSectionPlan = wellSectionsPlan.FirstOrDefault(s => s.IdSectionType == processMapPlan.IdWellSectionType); + var wellSectionsPlan = await wellSectionPlanRepository.GetByIdWellAsync(idWell, cancellationToken); - var isValid = wellSectionPlan is not null && wellSectionPlan.DepthStart <= processMapPlan.DepthStart && - wellSectionPlan.DepthEnd >= processMapPlan.DepthEnd; + return processMapsPlan.Select(processMapPlan => + { + var wellSectionPlan = wellSectionsPlan.FirstOrDefault(s => s.IdSectionType == processMapPlan.IdWellSectionType); - var validationResult = new ValidationResultDto - { - Item = processMapPlan - }; + var isValid = wellSectionPlan is not null && wellSectionPlan.DepthStart <= processMapPlan.DepthStart && + wellSectionPlan.DepthEnd >= processMapPlan.DepthEnd; - if (isValid) - return validationResult; + var validationResult = new ValidationResultDto + { + Item = processMapPlan + }; - var wellSectionType = wellSectionTypes.FirstOrDefault(s => s.Id == processMapPlan.IdWellSectionType); + if (isValid) + return validationResult; - validationResult.Warnings = new ValidationResult[] - { - new($"Конструкция секции: {wellSectionType?.Caption}; " + - $"Интервал бурения от {processMapPlan.DepthStart} до {processMapPlan.DepthEnd} не совпадает с данными указанными на странице " + - $"Конструкция скважины / План", new[] { nameof(processMapPlan.DepthStart), nameof(processMapPlan.DepthEnd) }) - }; + var wellSectionType = wellSectionTypes.FirstOrDefault(s => s.Id == processMapPlan.IdWellSectionType); - return validationResult; - }); - } + validationResult.Warnings = new ValidationResult[] + { + new($"Конструкция секции: {wellSectionType?.Caption}; " + + $"Интервал бурения от {processMapPlan.DepthStart} до {processMapPlan.DepthEnd} не совпадает с данными указанными на странице " + + $"Конструкция скважины / План", new[] { nameof(processMapPlan.DepthStart), nameof(processMapPlan.DepthEnd) }) + }; + + return validationResult; + }); + } } \ No newline at end of file diff --git a/AsbCloudInfrastructure/Services/ProcessMaps/Report/ProcessMapReportWellDrillingExportService.cs b/AsbCloudInfrastructure/Services/ProcessMaps/Report/ProcessMapReportWellDrillingExportService.cs deleted file mode 100644 index 9e1cb6db..00000000 --- a/AsbCloudInfrastructure/Services/ProcessMaps/Report/ProcessMapReportWellDrillingExportService.cs +++ /dev/null @@ -1,195 +0,0 @@ -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Reflection; -using System.Threading; -using System.Threading.Tasks; -using AsbCloudApp.Data.ProcessMaps.Report; -using AsbCloudApp.Services; -using AsbCloudApp.Services.ProcessMaps.WellDrilling; -using ClosedXML.Excel; - -namespace AsbCloudInfrastructure.Services.ProcessMaps.Report; - -public class ProcessMapReportWellDrillingExportService : IProcessMapReportWellDrillingExportService -{ - const int firstColumn = 2; - const int lastColumn = 42; - - const int headerRowsCount = 5; - - private readonly IWellService wellService; - private readonly IProcessMapReportWellDrillingService processMapReportWellDrillingService; - - public ProcessMapReportWellDrillingExportService(IWellService wellService, - IProcessMapReportWellDrillingService processMapReportWellDrillingService) - { - this.wellService = wellService; - this.processMapReportWellDrillingService = processMapReportWellDrillingService; - } - - - public async Task<(string Name, Stream File)?> ExportAsync(int idWell, CancellationToken cancellationToken) - { - var well = await wellService.GetOrDefaultAsync(idWell, cancellationToken); - - if (well is null) - return null; - - var stream = GetExcelTemplateStream(); - using var workbook = new XLWorkbook(stream); - - var data = await processMapReportWellDrillingService.GetAsync(idWell, cancellationToken); - - FillProcessMapToWorkbook(workbook, data); - - MemoryStream memoryStream = new(); - workbook.SaveAs(memoryStream, new SaveOptions { }); - memoryStream.Seek(0, SeekOrigin.Begin); - - var name = $"РТК бурение. Отчёт по скважине {well.Caption} куст {well.Cluster}.xlsx"; - - return (name, memoryStream); - } - - private static void FillProcessMapToWorkbook(XLWorkbook workbook, - IEnumerable data) - { - const string sheetName = "Отчёт"; - - var sheet = workbook.GetWorksheet(sheetName); - - var dataBySections = data.GroupBy(p => p.IdWellSectionType); - FillSheet(sheet, dataBySections); - } - - private static void FillSheet(IXLWorksheet sheet, - IEnumerable> dataBySections) - { - var startRow = headerRowsCount + 1; - foreach (var sectionData in dataBySections) - { - if (sectionData.Any()) - startRow = FillSection(sheet, sectionData, startRow); - } - } - - private static int FillSection(IXLWorksheet sheet, IGrouping sectionData, - int row) - { - var rowStart = row; - var sectionName = sectionData.FirstOrDefault()?.WellSectionTypeName - ?? sectionData.Key.ToString(); - - sheet.Range(row, firstColumn, row, lastColumn) - .Merge() - .FirstCell() - .SetCellValue(sectionName) - .Style - .Fill.SetBackgroundColor(XLColor.LightGray); - row++; - foreach (var interval in sectionData) - row = FillIntervalData(sheet, interval, row); - - var sectionStyle = sheet.Range(rowStart, firstColumn, row - 1, lastColumn).Style; - SetBorders(sectionStyle); - return row; - } - - private static int FillIntervalData(IXLWorksheet sheet, ProcessMapReportWellDrillingDto interval, int row) - { - const int columnDepth = firstColumn + 1; - const int columnDate = firstColumn + 2; - const int columnRopTime = firstColumn + 3; - const int columnMode = firstColumn + 4; - - sheet.Cell(row, firstColumn).SetCellValue(interval.DepthStart); - sheet.Cell(row, columnDepth).SetCellValue(interval.DepthEnd); - sheet.Cell(row, columnDate).SetCellValue(interval.DateStart); - sheet.Cell(row, columnRopTime).SetCellValue(interval.MechDrillingHours); - - row = FillIntervalModeData(sheet, interval, columnMode, row); - - return row; - } - - private static int FillIntervalModeData(IXLWorksheet sheet, ProcessMapReportWellDrillingDto modeData, - int column, int row) - { - int columnDeltaDepth = column + 1; - int columnPressure = columnDeltaDepth + 1; - int columnLoad = columnPressure + 5; - int columnTorque = columnLoad + 5; - int columnSpeed = columnTorque + 5; - int columnUsagePlan = columnSpeed + 5; - int columnUsageFact = columnUsagePlan + 1; - int columnRop = columnUsageFact + 12; - - sheet.Cell(row, column).SetCellValue(modeData.DrillingMode); - - sheet.Cell(row, columnDeltaDepth).SetCellValue(modeData.DeltaDepth); - - FillIntervalModeDataParam(sheet, modeData.PressureDiff, columnPressure, row); - FillIntervalModeDataParam(sheet, modeData.AxialLoad, columnLoad, row); - FillIntervalModeDataParam(sheet, modeData.TopDriveTorque, columnTorque, row); - FillIntervalModeDataSpeed(sheet, modeData.SpeedLimit, columnSpeed, row); - - sheet.Cell(row, columnUsagePlan).SetCellValue(modeData.UsagePlan); - sheet.Cell(row, columnUsageFact).SetCellValue(modeData.UsageFact); - sheet.Cell(row, columnRop).SetCellValue(modeData.Rop.Fact); - - return row + 1; - } - - private static void FillIntervalModeDataParam(IXLWorksheet sheet, - ProcessMapReportWellDrillingParamsDto dataParam, int column, int row) - { - const int columnOffsetSpPlan = 0; - const int columnOffsetSpFact = 1; - const int columnOffsetFact = 2; - const int columnOffsetLimit = 3; - const int columnOffsetPercent = 4; - - sheet.Cell(row, column + columnOffsetSpPlan).SetCellValue(dataParam.SetpointPlan); - sheet.Cell(row, column + columnOffsetSpFact).SetCellValue(dataParam.SetpointFact); - sheet.Cell(row, column + columnOffsetFact).SetCellValue(dataParam.Fact); - sheet.Cell(row, column + columnOffsetLimit).SetCellValue(dataParam.Limit); - sheet.Cell(row, column + columnOffsetPercent).SetCellValue(dataParam.SetpointUsage); - } - - private static void FillIntervalModeDataSpeed(IXLWorksheet sheet, - ProcessMapReportWellDrillingParamsDto dataParam, int column, int row) - { - const int columnOffsetSpPlan = 0; - const int columnOffsetSpFact = 1; - const int columnOffsetFact = 2; - const int columnOffsetLimit = 3; - const int columnOffsetPercent = 4; - - sheet.Cell(row, column + columnOffsetSpPlan).SetCellValue(dataParam.SetpointPlan); - sheet.Cell(row, column + columnOffsetSpFact).SetCellValue(dataParam.SetpointFact); - sheet.Cell(row, column + columnOffsetFact).SetCellValue(dataParam.Fact); - sheet.Cell(row, column + columnOffsetLimit).SetCellValue(dataParam.Limit); - sheet.Cell(row, column + columnOffsetPercent).SetCellValue(dataParam.SetpointUsage); - } - - //TODO: использовать метод расширения, избавиться от этого метода - private static Stream GetExcelTemplateStream() - { - var stream = Assembly.GetExecutingAssembly() - .GetManifestResourceStream( - "AsbCloudInfrastructure.Services.ProcessMaps.Report.ProcessMapReportTemplate.xlsx"); - - return stream!; - } - - //TODO: нужен ли этот метод? Это можно настроить в шаблоне - private static void SetBorders(IXLStyle style) - { - style.Border.RightBorder = XLBorderStyleValues.Thin; - style.Border.LeftBorder = XLBorderStyleValues.Thin; - style.Border.TopBorder = XLBorderStyleValues.Thin; - style.Border.BottomBorder = XLBorderStyleValues.Thin; - style.Border.InsideBorder = XLBorderStyleValues.Thin; - } -} \ No newline at end of file diff --git a/AsbCloudInfrastructure/Services/ProcessMaps/Report/ProcessMapReportWellDrillingService.cs b/AsbCloudInfrastructure/Services/ProcessMaps/Report/ProcessMapReportWellDrillingService.cs deleted file mode 100644 index eb63d709..00000000 --- a/AsbCloudInfrastructure/Services/ProcessMaps/Report/ProcessMapReportWellDrillingService.cs +++ /dev/null @@ -1,235 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; -using AsbCloudApp.Data; -using AsbCloudApp.Data.ProcessMaps; -using AsbCloudApp.Data.ProcessMaps.Report; -using AsbCloudApp.Data.SAUB; -using AsbCloudApp.Exceptions; -using AsbCloudApp.Repositories; -using AsbCloudApp.Services; -using AsbCloudApp.Services.ProcessMaps.WellDrilling; -using AsbCloudInfrastructure.Services.ProcessMaps.Report.Data; - -namespace AsbCloudInfrastructure.Services.ProcessMaps.Report; - -public class ProcessMapReportWellDrillingService : IProcessMapReportWellDrillingService -{ - private readonly IWellService wellService; - private readonly IProcessMapPlanRepository processMapPlanWellDrillingRepository; - private readonly ITelemetryDataSaubService telemetryDataSaubService; - private readonly IWellOperationRepository wellOperationRepository; - - public ProcessMapReportWellDrillingService(IWellService wellService, - IProcessMapPlanRepository processMapPlanWellDrillingRepository, - ITelemetryDataSaubService telemetryDataSaubService, - IWellOperationRepository wellOperationRepository) - { - this.wellService = wellService; - this.processMapPlanWellDrillingRepository = processMapPlanWellDrillingRepository; - this.telemetryDataSaubService = telemetryDataSaubService; - this.wellOperationRepository = wellOperationRepository; - } - - public async Task> GetAsync(int idWell, - CancellationToken token) - { - var well = await wellService.GetOrDefaultAsync(idWell, token) - ?? throw new ArgumentInvalidException(nameof(idWell), $"Скважина с Id: {idWell} не найдена"); - - if (!well.IdTelemetry.HasValue) - return Enumerable.Empty(); - - var processMapPlanWellDrillings = await processMapPlanWellDrillingRepository.GetByIdWellAsync(idWell, token); - - if (!processMapPlanWellDrillings.Any()) - return Enumerable.Empty(); - - var telemetryDataStat = - (await telemetryDataSaubService.GetTelemetryDataStatAsync(well.IdTelemetry.Value, token)).ToArray(); - - if (!telemetryDataStat.Any()) - return Enumerable.Empty(); - - var result = CalcByIntervals(processMapPlanWellDrillings, telemetryDataStat); - - return result; - } - - private IEnumerable CalcByIntervals( - IEnumerable processMapPlanWellDrillings, - TelemetryDataSaubStatDto[] telemetryDataStat) - { - var processMapIntervals = CalcDepthIntervals(processMapPlanWellDrillings); - - var result = new List(processMapIntervals.Count() * 4); - - var telemetryIndexStart = - Array.FindIndex(telemetryDataStat, t => t.WellDepthMin >= processMapIntervals.First().DepthStart); - if (telemetryIndexStart < 0) - return Enumerable.Empty(); - - IDictionary sectionTypes = wellOperationRepository - .GetSectionTypes() - .ToDictionary(s => s.Id, s => s.Caption); - - foreach (var interval in processMapIntervals) - { - var processMapPlanWellDrillingInterval = processMapPlanWellDrillings - .Where(p => p.DepthStart <= interval.DepthEnd && p.DepthEnd >= interval.DepthStart); - - if (!processMapPlanWellDrillingInterval.Any()) - continue; - - var telemetryIndexEnd = Array.FindIndex(telemetryDataStat, telemetryIndexStart, - t => t.WellDepthMin >= interval.DepthEnd); - if (telemetryIndexEnd < 0) - telemetryIndexEnd = telemetryDataStat.Length - 1; - var telemetryDataInterval = - telemetryDataStat.AsSpan(telemetryIndexStart, telemetryIndexEnd - telemetryIndexStart); - - IEnumerable subIntervalsResult = - CalcSubIntervals(interval, processMapPlanWellDrillingInterval, telemetryDataInterval, sectionTypes); - - result.AddRange(subIntervalsResult); - telemetryIndexStart = telemetryIndexEnd; - } - - return result; - } - - private static IEnumerable<(double DepthStart, double DepthEnd)> CalcDepthIntervals( - IEnumerable processMapPlanWellDrillings) - { - if (!processMapPlanWellDrillings.Any()) - yield break; - - var intervalStarts = processMapPlanWellDrillings - .OrderBy(i => i.DepthStart) - .Select(p => p.DepthStart) - .Distinct() - .ToArray(); - - for (var i = 1; i < intervalStarts.Length; i++) - yield return (intervalStarts[i - 1], intervalStarts[i]); - - yield return (intervalStarts[^1], processMapPlanWellDrillings.Max(p => p.DepthEnd)); - } - - private static IEnumerable CalcSubIntervals( - (double DepthStart, double DepthEnd) interval, - IEnumerable processMapPlanWellDrillingInterval, - Span telemetryDataInterval, - IDictionary sectionTypes) - { - var telemetryDataIntervalLength = telemetryDataInterval.Length; - if (telemetryDataInterval.Length == 0) - return Enumerable.Empty(); - - var result = new List(); - var telemetryIndexStart = 0; - var subInterval = interval; - - for (var i = telemetryIndexStart + 1; i < telemetryDataIntervalLength; i++) - { - if (IsDifferent(telemetryDataInterval[telemetryIndexStart], telemetryDataInterval[i])) - { - subInterval.DepthEnd = telemetryDataInterval[i - 1].WellDepthMax; - var telemetryRowSpan = telemetryDataInterval[telemetryIndexStart..(i - 1)]; - - if (!telemetryRowSpan.IsEmpty) - { - var intervalReportRow = CalcSubIntervalReportRow(subInterval, processMapPlanWellDrillingInterval, - telemetryRowSpan, sectionTypes); - result.Add(intervalReportRow); - } - - telemetryIndexStart = i; - subInterval.DepthStart = subInterval.DepthEnd; - } - } - - subInterval.DepthEnd = interval.DepthEnd; - var intervalReportRowLast = CalcSubIntervalReportRow(subInterval, processMapPlanWellDrillingInterval, - telemetryDataInterval[telemetryIndexStart..telemetryDataIntervalLength], sectionTypes); - result.Add(intervalReportRowLast); - return result; - } - - private static ProcessMapReportWellDrillingDto CalcSubIntervalReportRow( - (double DepthStart, double DepthEnd) subInterval, - IEnumerable processMapPlanWellDrillings, - Span telemetryRowSpan, - IDictionary sectionTypes) - { - var telemetryStat = new TelemetryStat(telemetryRowSpan); - var processMapByMode = processMapPlanWellDrillings.FirstOrDefault(p => p.IdMode == telemetryStat.IdMode); - var processMapFirst = processMapPlanWellDrillings.First(); - var idWellSectionType = processMapByMode?.IdWellSectionType ?? processMapFirst.IdWellSectionType; - - var result = new ProcessMapReportWellDrillingDto - { - IdWell = processMapByMode?.IdWell ?? processMapFirst.IdWell, - IdWellSectionType = idWellSectionType, - WellSectionTypeName = sectionTypes[idWellSectionType], - - DepthStart = subInterval.DepthStart, - DepthEnd = subInterval.DepthEnd, - DateStart = telemetryStat.DateStart, - - MechDrillingHours = telemetryStat.DrillingHours, - DrillingMode = telemetryStat.ModeName, - - DeltaDepth = telemetryStat.DeltaDepth, - - PressureDiff = telemetryStat.Pressure.MakeParams(processMapByMode?.Pressure.Plan), - AxialLoad = telemetryStat.AxialLoad.MakeParams(processMapByMode?.AxialLoad.Plan), - TopDriveTorque = telemetryStat.RotorTorque.MakeParams(processMapByMode?.TopDriveTorque.Plan), - SpeedLimit = telemetryStat.BlockSpeed.MakeParams(processMapByMode?.RopPlan), - - Rop = new PlanFactDto - { - Plan = processMapByMode?.RopPlan, - Fact = telemetryStat.Rop - }, - - UsagePlan = processMapByMode?.UsageSaub ?? telemetryStat.UsagePredictPlan, - UsageFact = telemetryStat.UsageSaub, - }; - return result; - } - - private static bool IsDifferent(TelemetryDataSaubStatDto intervalStart, TelemetryDataSaubStatDto current) - { - if (intervalStart.WellDepthMin > current.WellDepthMin) - return true; - - if (intervalStart.IdMode != current.IdMode) - return true; - - if (Math.Abs(intervalStart.PressureSp - current.PressureSp) > 5d) - return true; - - if (Math.Abs(intervalStart.AxialLoadSp - current.AxialLoadSp) > 1d) - return true; - - if (Math.Abs(intervalStart.RotorTorqueSp - current.RotorTorqueSp) > 5d) - return true; - - var blockSpeedSpDiff = Math.Abs(intervalStart.BlockSpeedSp - current.BlockSpeedSp); - if (!(blockSpeedSpDiff > 5d)) - return false; - - switch (intervalStart.BlockSpeedSp) - { - case <= 30: - case > 30 when blockSpeedSpDiff > 15d: - case > 80 when blockSpeedSpDiff > 20d: - return true; - } - - return false; - } -} \ No newline at end of file diff --git a/AsbCloudInfrastructure/Services/ProcessMaps/WellDrilling/ProcessMapPlanImportWellDrillingService.cs b/AsbCloudInfrastructure/Services/ProcessMaps/WellDrilling/ProcessMapPlanImportWellDrillingService.cs deleted file mode 100644 index 454daa7a..00000000 --- a/AsbCloudInfrastructure/Services/ProcessMaps/WellDrilling/ProcessMapPlanImportWellDrillingService.cs +++ /dev/null @@ -1,368 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Reflection; -using System.Threading; -using System.Threading.Tasks; -using AsbCloudApp.Data; -using AsbCloudApp.Data.ProcessMaps; -using AsbCloudApp.Exceptions; -using AsbCloudApp.Repositories; -using AsbCloudApp.Services; -using AsbCloudApp.Services.ProcessMaps; -using ClosedXML.Excel; - -namespace AsbCloudInfrastructure.Services.ProcessMaps.WellDrilling; - -/* - * password for ProcessMapImportTemplate.xlsx is ASB2020! - */ - -[Obsolete] -public class ProcessMapPlanImportWellDrillingService : IProcessMapPlanImportService -{ - private readonly IProcessMapPlanRepository processMapPlanWellDrillingRepository; - private readonly ICrudRepository wellSectionTypeRepository; - private readonly IWellService wellService; - - private const string sheetNamePlan = "План"; - - private const int headerRowsCount = 2; - - private const int columnSection = 1; - private const int columnMode = 2; - private const int columnDepthStart = 3; - private const int columnDepthEnd = 4; - private const int columnPressurePlan = 5; - private const int columnPressureLimitMax = 6; - private const int columnAxialLoadPlan = 7; - private const int columnAxialLoadLimitMax = 8; - private const int columnTopDriveTorquePlan = 9; - private const int columnTopDriveTorqueLimitMax = 10; - private const int columnTopDriveSpeedPlan = 11; - private const int columnTopDriveSpeedLimitMax = 12; - private const int columnFlowPlan = 13; - private const int columnFlowLimitMax = 14; - private const int columnRopPlan = 15; - private const int columnUsageSaub = 16; - private const int columnUsageSpin = 17; - private const int columnComment = 18; - - private WellSectionTypeDto[] sections = null!; - - public ProcessMapPlanImportWellDrillingService(IProcessMapPlanRepository processMapPlanWellDrillingRepository, - ICrudRepository wellSectionTypeRepository, - IWellService wellService) - { - this.processMapPlanWellDrillingRepository = processMapPlanWellDrillingRepository; - this.wellSectionTypeRepository = wellSectionTypeRepository; - this.wellService = wellService; - } - - public async Task ImportAsync(int idWell, int idUser, bool deleteProcessMapPlansBeforeImport, Stream stream, - CancellationToken cancellationToken) - { - sections = (await wellSectionTypeRepository.GetAllAsync(cancellationToken)).ToArray(); - - using var workBook = new XLWorkbook(stream); - - var wellDrillingProcessMaps = ParseWorkBook(workBook); - - if (deleteProcessMapPlansBeforeImport) - await processMapPlanWellDrillingRepository.RemoveByWellAsync(idWell); - - foreach (var wellDrillingProcessMap in wellDrillingProcessMaps) - { - wellDrillingProcessMap.IdWell = idWell; - wellDrillingProcessMap.IdUser = idUser; - } - - await processMapPlanWellDrillingRepository.InsertRangeAsync(wellDrillingProcessMaps, cancellationToken); - } - - public async Task<(string Name, Stream File)> ExportAsync(int idWell, CancellationToken cancellationToken) - { - var well = await wellService.GetOrDefaultAsync(idWell, cancellationToken) - ?? throw new ArgumentInvalidException(nameof(idWell), $"Скважины с {idWell} не существует"); - - sections = (await wellSectionTypeRepository.GetAllAsync(cancellationToken)).ToArray(); - - var processMapPlans = (await processMapPlanWellDrillingRepository.GetByIdWellAsync(idWell, - cancellationToken)).ToArray(); - - var file = await GenerateExcelFileStreamAsync(processMapPlans, cancellationToken); - - var fileName = $"РТК-план бурение по скважине {well.Caption} куст {well.Cluster}.xlsx"; - - return (fileName, file); - } - - public async Task<(string Name, Stream File)> GetExcelTemplateStreamAsync(CancellationToken cancellationToken) - { - var resourceName = Assembly.GetExecutingAssembly() - .GetManifestResourceNames() - .FirstOrDefault(n => n.EndsWith("ProcessMapPlanImportWellDrillingTemplate.xlsx"))!; - - using var stream = Assembly.GetExecutingAssembly() - .GetManifestResourceStream(resourceName)!; - - var memoryStream = new MemoryStream(); - await stream.CopyToAsync(memoryStream, cancellationToken); - memoryStream.Position = 0; - - var name = "ЕЦП_шаблон_файла_РТК_бурение.xlsx"; - - return (name, memoryStream); - } - - private void AddToWorkbook(XLWorkbook workbook, IEnumerable processMapPlanWellDrillings) - { - var sheet = workbook.GetWorksheet(sheetNamePlan); - - AddToSheet(sheet, processMapPlanWellDrillings.ToArray()); - } - - private void AddToSheet(IXLWorksheet sheet, IList processMapPlanWellDrillings) - { - if (!processMapPlanWellDrillings.Any()) - return; - - for (int i = 0; i < processMapPlanWellDrillings.Count; i++) - { - var row = sheet.Row(1 + i + headerRowsCount); - AddToRow(row, processMapPlanWellDrillings[i]); - } - } - - private void AddToRow(IXLRow row, ProcessMapPlanWellDrillingDto processMapPlanWellDrillings) - { - var section = sections.First(x => x.Id == processMapPlanWellDrillings.IdWellSectionType).Caption; - var modeCaption = GetModeCaption(processMapPlanWellDrillings.IdMode); - - row.Cell(columnSection).SetCellValue(section); - row.Cell(columnMode).SetCellValue(modeCaption); - row.Cell(columnDepthStart).SetCellValue(processMapPlanWellDrillings.DepthStart); - row.Cell(columnDepthEnd).SetCellValue(processMapPlanWellDrillings.DepthEnd); - row.Cell(columnPressurePlan).SetCellValue(processMapPlanWellDrillings.Pressure.Plan); - row.Cell(columnPressureLimitMax).SetCellValue(processMapPlanWellDrillings.Pressure.LimitMax); - row.Cell(columnAxialLoadPlan).SetCellValue(processMapPlanWellDrillings.AxialLoad.Plan); - row.Cell(columnAxialLoadLimitMax).SetCellValue(processMapPlanWellDrillings.AxialLoad.LimitMax); - row.Cell(columnTopDriveTorquePlan).SetCellValue(processMapPlanWellDrillings.TopDriveTorque.Plan); - row.Cell(columnTopDriveTorqueLimitMax).SetCellValue(processMapPlanWellDrillings.TopDriveTorque.LimitMax); - row.Cell(columnTopDriveSpeedPlan).SetCellValue(processMapPlanWellDrillings.TopDriveSpeed.Plan); - row.Cell(columnTopDriveSpeedLimitMax).SetCellValue(processMapPlanWellDrillings.TopDriveSpeed.LimitMax); - row.Cell(columnFlowPlan).SetCellValue(processMapPlanWellDrillings.Flow.Plan); - row.Cell(columnFlowLimitMax).SetCellValue(processMapPlanWellDrillings.Flow.LimitMax); - row.Cell(columnRopPlan).SetCellValue(processMapPlanWellDrillings.RopPlan); - row.Cell(columnUsageSaub).SetCellValue(processMapPlanWellDrillings.UsageSaub); - row.Cell(columnUsageSpin).SetCellValue(processMapPlanWellDrillings.UsageSpin); - row.Cell(columnComment).SetCellValue(processMapPlanWellDrillings.Comment); - } - - private IEnumerable ParseWorkBook(IXLWorkbook workbook) - { - var sheet = workbook.GetWorksheet(sheetNamePlan); - return ParseSheet(sheet); - } - - private IEnumerable ParseSheet(IXLWorksheet sheet) - { - const int columnsCount = 17; - - if (sheet.RangeUsed().RangeAddress.LastAddress.ColumnNumber < columnsCount) - throw new FileFormatException($"Лист {sheet.Name} содержит меньшее количество столбцов."); - - var rowsCount = sheet.RowsUsed().Count() - headerRowsCount; - - if (rowsCount <= 0) - return Array.Empty(); - - var processMapPlans = new ProcessMapPlanWellDrillingDto[rowsCount]; - - var parseErrors = new List(); - - for (int i = 0; i < processMapPlans.Length; i++) - { - var row = sheet.Row(1 + i + headerRowsCount); - - try - { - processMapPlans[i] = ParseRow(row); - } - catch (FileFormatException ex) - { - parseErrors.Add(ex.Message); - } - } - - if (parseErrors.Any()) - throw new FileFormatException(string.Join("\r\n", parseErrors)); - - return processMapPlans; - } - - private ProcessMapPlanWellDrillingDto ParseRow(IXLRow row) - { - var wellSectionTypeCaption = row.Cell(columnSection).GetCellValue()?.Trim().ToLower(); - var modeName = row.Cell(columnMode).GetCellValue()?.Trim().ToLower(); - var depthStart = row.Cell(columnDepthStart).GetCellValue(); - var depthEnd = row.Cell(columnDepthEnd).GetCellValue(); - var pressurePlan = row.Cell(columnPressurePlan).GetCellValue(); - var pressureLimitMax = row.Cell(columnPressureLimitMax).GetCellValue(); - var axialLoadPlan = row.Cell(columnAxialLoadPlan).GetCellValue(); - var axialLoadLimitMax = row.Cell(columnAxialLoadLimitMax).GetCellValue(); - var topDriveTorquePlan = row.Cell(columnTopDriveTorquePlan).GetCellValue(); - var topDriveTorqueLimitMax = row.Cell(columnTopDriveTorqueLimitMax).GetCellValue(); - var topDriveSpeedPlan = row.Cell(columnTopDriveSpeedPlan).GetCellValue(); - var topDriveSpeedLimitMax = row.Cell(columnTopDriveSpeedLimitMax).GetCellValue(); - var flowPlan = row.Cell(columnFlowPlan).GetCellValue(); - var flowLimitMax = row.Cell(columnFlowLimitMax).GetCellValue(); - var ropPlan = row.Cell(columnRopPlan).GetCellValue(); - var usageSaub = row.Cell(columnUsageSaub).GetCellValue(); - var usageSpin = row.Cell(columnUsageSpin).GetCellValue(); - var comment = row.Cell(columnComment).GetCellValue(); - - var wellSection = sections.FirstOrDefault(s => s.Caption.Trim().ToLower() == wellSectionTypeCaption) - ?? throw new FileFormatException( - $"Лист {row.Worksheet.Name}. В строке {row.RowNumber()} указана некорректная секция"); - - if(string.IsNullOrEmpty(modeName)) - throw new FileFormatException( - $"Лист {row.Worksheet.Name}. В строке {row.RowNumber()} не указан режим"); - - var idMode = GetIdMode(modeName) - ?? throw new FileFormatException( - $"Лист {row.Worksheet.Name}. В строке {row.RowNumber()} указан некорректный режим"); - - if (depthStart is < 0 or > 99999.9) - throw new FileFormatException( - $"Лист {row.Worksheet.Name}. В строке {row.RowNumber()} указана некорректная стартовая глубина"); - - if (depthEnd is < 0 or > 99999.9) - throw new FileFormatException( - $"Лист {row.Worksheet.Name}. В строке {row.RowNumber()} указана некорректная конечная глубина"); - - if (pressurePlan is < 0 or > 50000) - throw new FileFormatException( - $"Лист {row.Worksheet.Name}. В строке {row.RowNumber()} указано некорректное плановое значение перепада давления"); - - if (pressureLimitMax is < 0 or > 50000) - throw new FileFormatException( - $"Лист {row.Worksheet.Name}. В строке {row.RowNumber()} указано некорректное ограничение перепада давления"); - - if (axialLoadPlan is < 0 or > 50000) - throw new FileFormatException( - $"Лист {row.Worksheet.Name}. В строке {row.RowNumber()} указано некорректное плановое значение нагрузки"); - - if (axialLoadLimitMax is < 0 or > 50000) - throw new FileFormatException( - $"Лист {row.Worksheet.Name}. В строке {row.RowNumber()} указано некорректное ограничение нагрузки"); - - if (topDriveTorquePlan is < 0 or > 50000) - throw new FileFormatException( - $"Лист {row.Worksheet.Name}. В строке {row.RowNumber()} указано некорректное плановое значение момента на ВСП"); - - if (topDriveTorqueLimitMax is < 0 or > 50000) - throw new FileFormatException( - $"Лист {row.Worksheet.Name}. В строке {row.RowNumber()} указано некорректное ограничение момента на ВСП"); - - if (topDriveSpeedPlan is < 0 or > 50000) - throw new FileFormatException( - $"Лист {row.Worksheet.Name}. В строке {row.RowNumber()} указано некорректное плановое значение оборотов на ВСП"); - - if (topDriveSpeedLimitMax is < 0 or > 50000) - throw new FileFormatException( - $"Лист {row.Worksheet.Name}. В строке {row.RowNumber()} указано некорректное ограничения оборота на ВСП"); - - if (flowPlan is < 0 or > 50000) - throw new FileFormatException( - $"Лист {row.Worksheet.Name}. В строке {row.RowNumber()} указано некорректное плановое значение расхода"); - - if (flowLimitMax is < 0 or > 50000) - throw new FileFormatException( - $"Лист {row.Worksheet.Name}. В строке {row.RowNumber()} указано некорректное ограничение расхода"); - - if (ropPlan is < 0 or > 99999.9) - throw new FileFormatException( - $"Лист {row.Worksheet.Name}. В строке {row.RowNumber()} указано некорректное плановое значение механической скорости"); - - if (usageSaub is < 0 or > 100) - throw new FileFormatException( - $"Лист {row.Worksheet.Name}. В строке {row.RowNumber()} указан некорректный плановый процент использования АКБ"); - - if (usageSpin is < 0 or > 100) - throw new FileFormatException( - $"Лист {row.Worksheet.Name}. В строке {row.RowNumber()} указан некорректные плановый процент использования spin master"); - - return new() - { - IdWellSectionType = wellSection.Id, - IdMode = idMode, - DepthStart = depthStart, - LastUpdate = DateTime.UtcNow, - DepthEnd = depthEnd, - Pressure = new() - { - Plan = pressurePlan, - LimitMax = pressureLimitMax - }, - AxialLoad = new() - { - Plan = axialLoadPlan, - LimitMax = axialLoadLimitMax - }, - TopDriveTorque = new() - { - Plan = topDriveTorquePlan, - LimitMax = topDriveTorqueLimitMax - }, - TopDriveSpeed = new() - { - Plan = topDriveSpeedPlan, - LimitMax = topDriveSpeedLimitMax - }, - Flow = new() - { - Plan = flowPlan, - LimitMax = flowLimitMax - }, - RopPlan = ropPlan, - UsageSaub = usageSaub, - UsageSpin = usageSpin, - Comment = comment - }; - } - - private async Task GenerateExcelFileStreamAsync(ProcessMapPlanWellDrillingDto[] processMapPlanWellDrillings, - CancellationToken cancellationToken) - { - using var excelTemplateStream = (await GetExcelTemplateStreamAsync(cancellationToken)).File; - - using var workbook = new XLWorkbook(excelTemplateStream); - - AddToWorkbook(workbook, processMapPlanWellDrillings); - - MemoryStream memoryStream = new(); - workbook.SaveAs(memoryStream, new SaveOptions { }); - memoryStream.Seek(0, SeekOrigin.Begin); - return memoryStream; - } - - private static int? GetIdMode(string modeName) => - modeName switch - { - "ручной" => 0, - "ротор" => 1, - "слайд" => 2, - _ => null - }; - - private static string GetModeCaption(int idMode) - => idMode switch - { - 1 => "Ротор", - 2 => "Слайд", - _ => "Ручной", - }; -} \ No newline at end of file diff --git a/AsbCloudInfrastructure/Services/ProcessMaps/WellDrilling/ProcessMapPlanImportWellDrillingTemplate.xlsx b/AsbCloudInfrastructure/Services/ProcessMaps/WellDrilling/ProcessMapPlanImportWellDrillingTemplate.xlsx deleted file mode 100644 index bdf13143446f1d64a808c157f915d943dcf5d610..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 12611 zcmeHtWkVfXw(Z8H+(%Z#gF%+%VKv)iL4p*{6&UJ zX3|ui9jsjmGH7S#yOdk`S-)=q(@_EC(TuvTG*2Oo3n@iS5(`J<8Qb(*g<-WRk!SYQ zmycQGwMmMR#E>s)R0{>gdp3jJ9FoOD5ql;LHAQ2=S6%GEB$za*s&B*+IvN?EjkK5u zLS{!`RM8j!Hs^ytgCRyp67~>5f<1WoU6VpBHEcCe19j|JB~J$h321$v7{dm zM#Uk1$s>5CR%rUPGv;!0Ov?sp&YHFLXw5JKc@VJ4~a+;ExS&H+OLa>8_JI-dZGpIE*h5^BY%MZnD(M_J9oF zhrFBgIQn*u?S7+;|EaM-CXly>ZucYp^She8y@3Jb|HD?BR2WHb-mgf%nMu_irSSuq@(La$kyHj|5w)+}9zbzf zxLvqQ7n5|Sa_Nkvsc0?Dmm1w96`i{ju0x)tSHpopE5ZxG{G9HuIV7X;-SD9rWI<5r zM^#8|3rF5b;&i6(QcC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oYhi9(8Gkp)r-PUTwM?Fo}c z;yq^mp5py3{(Er!3xJRM&jw diff --git a/AsbCloudInfrastructure/Services/WellInfoService.cs b/AsbCloudInfrastructure/Services/WellInfoService.cs index 1bdd8ad9..e40acc4e 100644 --- a/AsbCloudInfrastructure/Services/WellInfoService.cs +++ b/AsbCloudInfrastructure/Services/WellInfoService.cs @@ -1,6 +1,9 @@ using AsbCloudApp.Data; +using AsbCloudApp.Data.ProcessMapPlan; using AsbCloudApp.Data.SAUB; using AsbCloudApp.Data.WITS; +using AsbCloudApp.IntegrationEvents; +using AsbCloudApp.IntegrationEvents.Interfaces; using AsbCloudApp.Repositories; using AsbCloudApp.Requests; using AsbCloudApp.Services; @@ -12,9 +15,6 @@ using System.Collections.Generic; using System.Linq; using System.Threading; using System.Threading.Tasks; -using AsbCloudApp.Data.ProcessMaps; -using AsbCloudApp.IntegrationEvents; -using AsbCloudApp.IntegrationEvents.Interfaces; namespace AsbCloudInfrastructure.Services; @@ -32,7 +32,7 @@ public class WellInfoService { var wellService = services.GetRequiredService(); var operationsStatService = services.GetRequiredService(); - var processMapPlanWellDrillingRepository = services.GetRequiredService>(); + var processMapPlanWellDrillingRepository = services.GetRequiredService>(); var subsystemService = services.GetRequiredService(); var telemetryDataSaubCache = services.GetRequiredService>(); var messageHub = services.GetRequiredService>(); @@ -42,8 +42,13 @@ public class WellInfoService var wellsIds = activeWells.Select(w => w.Id); - var processMapPlanWellDrillingRequests = wellsIds.Select(id => new ProcessMapPlanRequest { IdWell = id }); - var processMapPlanWellDrillings = await processMapPlanWellDrillingRepository.GetAsync(processMapPlanWellDrillingRequests, token); + var processMapPlanWellDrillingRequests = wellsIds.Select(id => new ProcessMapPlanBaseRequestWithWell(id)); + var processMapPlanWellDrillings = new List(); + foreach (var processMapPlanWellDrillingRequest in processMapPlanWellDrillingRequests) + { + var processMaps = await processMapPlanWellDrillingRepository.Get(processMapPlanWellDrillingRequest, token); + processMapPlanWellDrillings.AddRange(processMaps); + } var wellDepthByProcessMap = processMapPlanWellDrillings .GroupBy(p => p.IdWell) @@ -61,7 +66,8 @@ public class WellInfoService var count = activeWells.Count(); var i = 0d; - WellMapInfo = activeWells.Select(well => { + WellMapInfo = activeWells.Select(well => + { var wellMapInfo = well.Adapt(); wellMapInfo.IdState = well.IdState; onProgressCallback($"Start updating info by well({well.Id}): {well.Caption}", i++ / count); @@ -88,7 +94,7 @@ public class WellInfoService .OrderBy(p => p.DepthEnd); int? idSection = wellLastFactSection?.Id; - ProcessMapPlanWellDrillingDto? processMapPlanWellDrilling = null; + ProcessMapPlanDrillingDto? processMapPlanWellDrilling = null; if (idSection.HasValue) { @@ -112,25 +118,25 @@ public class WellInfoService wellMapInfo.AxialLoad = new() { - Plan = processMapPlanWellDrilling?.AxialLoad.Plan, + Plan = processMapPlanWellDrilling?.AxialLoadPlan, Fact = lastSaubTelemetry?.AxialLoad }; wellMapInfo.TopDriveSpeed = new() { - Plan = processMapPlanWellDrilling?.TopDriveSpeed.Plan, + Plan = processMapPlanWellDrilling?.TopDriveSpeedPlan, Fact = lastSaubTelemetry?.RotorSpeed }; wellMapInfo.TopDriveTorque = new() { - Plan = processMapPlanWellDrilling?.TopDriveTorque.Plan, + Plan = processMapPlanWellDrilling?.TopDriveTorquePlan, Fact = lastSaubTelemetry?.RotorTorque }; wellMapInfo.Pressure = new() { - Plan = processMapPlanWellDrilling?.Pressure.Plan, + Plan = processMapPlanWellDrilling?.DeltaPressurePlan, Fact = lastSaubTelemetry?.Pressure }; @@ -233,7 +239,7 @@ public class WellInfoService } public WellMapInfoWithTelemetryStat? FirstOrDefault(Func predicate) - { + { var first = WellMapInfo.FirstOrDefault(predicate); if (first is WellMapInfoWithComanies wellMapInfoWithComanies) return Convert(wellMapInfoWithComanies); diff --git a/AsbCloudWebApi.Tests/Services/DailyReportServiceTest.cs b/AsbCloudWebApi.Tests/Services/DailyReportServiceTest.cs index 52b2044d..5f3f21d3 100644 --- a/AsbCloudWebApi.Tests/Services/DailyReportServiceTest.cs +++ b/AsbCloudWebApi.Tests/Services/DailyReportServiceTest.cs @@ -1,8 +1,3 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; using AsbCloudApp.Data; using AsbCloudApp.Data.DailyReport; using AsbCloudApp.Data.DailyReport.Blocks.Sign; @@ -19,6 +14,11 @@ using AsbCloudApp.Services; using AsbCloudApp.Services.ProcessMaps.WellDrilling; using AsbCloudInfrastructure.Services.DailyReport; using NSubstitute; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; using Xunit; namespace AsbCloudWebApi.Tests.Services; @@ -110,7 +110,7 @@ public class DailyReportServiceTest } }; - private readonly ProcessMapReportWellDrillingDto fakeProcessMapReportWellDrilling = new() + private readonly ProcessMapReportDataSaubStatDto fakeProcessMapReportWellDrilling = new() { DrillingMode = "Ротор", DateStart = new DateTime(2023, 10, 26), @@ -120,7 +120,7 @@ public class DailyReportServiceTest Plan = 300, Fact = 500 }, - MechDrillingHours = 100 + DrilledTime = 100 }; private readonly WellSectionTypeDto fakeSectionType = new() @@ -207,7 +207,7 @@ public class DailyReportServiceTest private readonly IScheduleRepository scheduleRepositoryMock = Substitute.For(); private readonly IWellOperationRepository wellOperationRepositoryMock = Substitute.For(); private readonly ISubsystemService subsystemServiceMock = Substitute.For(); - private readonly IProcessMapReportWellDrillingService processMapReportWellDrillingServiceMock = Substitute.For(); + private readonly IProcessMapReportDataSaubStatService processMapReportWellDrillingServiceMock = Substitute.For(); private readonly IDetectedOperationService detectedOperationServiceMock = Substitute.For(); private readonly DailyReportService dailyReportService; @@ -215,6 +215,7 @@ public class DailyReportServiceTest private readonly DailyReportDto fakeDailyReport; private readonly WellDto fakeWell; private readonly DatesRangeDto fakeDatesRange; + private readonly DataSaubStatRequest fakeRequest = new DataSaubStatRequest(); public DailyReportServiceTest() { @@ -284,7 +285,7 @@ public class DailyReportServiceTest scheduleRepositoryMock.GetAsync(Arg.Any(), Arg.Any(), Arg.Any()) .ReturnsForAnyArgs(new[] { fakeShedule }); - processMapReportWellDrillingServiceMock.GetAsync(Arg.Any(), Arg.Any()) + processMapReportWellDrillingServiceMock.GetAsync(Arg.Any(), fakeRequest, Arg.Any()) .ReturnsForAnyArgs(new[] { fakeProcessMapReportWellDrilling }); wellServiceMock.GetTimezone(Arg.Any()) @@ -461,7 +462,7 @@ public class DailyReportServiceTest Assert.Equal(fakeProcessMapReportWellDrilling.Rop.Plan, processMapWellDrillingRecord.Rop.Plan); Assert.Equal(fakeProcessMapReportWellDrilling.Rop.Fact, processMapWellDrillingRecord.Rop.Fact); Assert.Equal(fakeProcessMapReportWellDrilling.DeltaDepth, processMapWellDrillingRecord.WellBoreDepth); - Assert.Equal(fakeProcessMapReportWellDrilling.MechDrillingHours, processMapWellDrillingRecord.MechDrillingHours); + Assert.Equal(fakeProcessMapReportWellDrilling.DrilledTime, processMapWellDrillingRecord.MechDrillingHours); } [Fact] diff --git a/AsbCloudWebApi.Tests/Services/ProcessMaps/ProcessMapPlanServiceTests.cs b/AsbCloudWebApi.Tests/Services/ProcessMaps/ProcessMapPlanServiceTests.cs index df1b5a8b..3680516d 100644 --- a/AsbCloudWebApi.Tests/Services/ProcessMaps/ProcessMapPlanServiceTests.cs +++ b/AsbCloudWebApi.Tests/Services/ProcessMaps/ProcessMapPlanServiceTests.cs @@ -1,13 +1,15 @@ +using AsbCloudApp.Data; +using AsbCloudApp.Data.ProcessMapPlan; +using AsbCloudApp.Data.ProcessMaps; +using AsbCloudApp.Repositories; +using AsbCloudApp.Requests; +using AsbCloudApp.Services; +using AsbCloudInfrastructure.Services.ProcessMaps; +using NSubstitute; using System.Collections.Generic; using System.Linq; using System.Threading; using System.Threading.Tasks; -using AsbCloudApp.Data; -using AsbCloudApp.Data.ProcessMaps; -using AsbCloudApp.Repositories; -using AsbCloudApp.Services; -using AsbCloudInfrastructure.Services.ProcessMaps; -using NSubstitute; using Xunit; namespace AsbCloudWebApi.Tests.Services.ProcessMaps; @@ -43,17 +45,17 @@ public class ProcessMapPlanServiceTests private readonly ICrudRepository wellSectionTypeRepositoryMock = Substitute.For>(); - private readonly IProcessMapPlanRepository processMapPlanRepositoryMock = - Substitute.For>(); + private readonly IChangeLogRepository processMapPlanRepositoryMock = + Substitute.For>(); private readonly IRepositoryWellRelated wellSectionPlanRepositoryMock = Substitute.For>(); - private readonly ProcessMapPlanService processMapPlanService; + private readonly ProcessMapPlanService processMapPlanService; public ProcessMapPlanServiceTests() { - processMapPlanService = new ProcessMapPlanService(wellSectionTypeRepositoryMock, + processMapPlanService = new ProcessMapPlanService(wellSectionTypeRepositoryMock, processMapPlanRepositoryMock, wellSectionPlanRepositoryMock); wellSectionPlanRepositoryMock.GetByIdWellAsync(Arg.Any(), Arg.Any()) @@ -71,7 +73,7 @@ public class ProcessMapPlanServiceTests public async Task GetAsync_ReturnsValidatedCollectionProcessMapPlanWellDrilling(int depthStart, int depthEnd, bool isValidCollection) { //arrange - var fakeCollectionProcessMapPlanWellDrilling = new ProcessMapPlanWellDrillingDto[] + var fakeCollectionProcessMapPlanWellDrilling = new ProcessMapPlanDrillingDto[] { new() { @@ -81,8 +83,8 @@ public class ProcessMapPlanServiceTests } }; - processMapPlanRepositoryMock.GetByIdWellAsync(Arg.Any(), Arg.Any()) - .ReturnsForAnyArgs(fakeCollectionProcessMapPlanWellDrilling); + processMapPlanRepositoryMock.Get(Arg.Any(), Arg.Any()) + .ReturnsForAnyArgs(fakeCollectionProcessMapPlanWellDrilling); //act var result = (await processMapPlanService.GetAsync(idWell, CancellationToken.None)).ToArray(); diff --git a/AsbCloudWebApi/Controllers/ProcessMaps/ProcessMapBaseController.cs b/AsbCloudWebApi/Controllers/ProcessMaps/ProcessMapBaseController.cs index 0d47f808..06eda3da 100644 --- a/AsbCloudWebApi/Controllers/ProcessMaps/ProcessMapBaseController.cs +++ b/AsbCloudWebApi/Controllers/ProcessMaps/ProcessMapBaseController.cs @@ -1,10 +1,5 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; -using AsbCloudApp.Data; -using AsbCloudApp.Data.ProcessMaps; +using AsbCloudApp.Data; +using AsbCloudApp.Data.ProcessMapPlan; using AsbCloudApp.Exceptions; using AsbCloudApp.Repositories; using AsbCloudApp.Requests; @@ -16,6 +11,11 @@ using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.SignalR; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; namespace AsbCloudWebApi.Controllers.ProcessMaps; @@ -33,11 +33,11 @@ public abstract class ProcessMapBaseController : ControllerBase private readonly IWellService wellService; private readonly IUserRepository userRepository; private readonly ICrudRepository wellSectionRepository; - private readonly IProcessMapPlanRepository repository; + private readonly IChangeLogRepository repository; private readonly IProcessMapPlanService service; protected ProcessMapBaseController(IWellService wellService, - IProcessMapPlanRepository repository, + IChangeLogRepository repository, IUserRepository userRepository, ICrudRepository wellSectionRepository, IHubContext telemetryHubContext, @@ -67,7 +67,7 @@ public abstract class ProcessMapBaseController : ControllerBase return idUser.Value; } } - + /// /// Создание плановой РТК /// @@ -81,14 +81,12 @@ public abstract class ProcessMapBaseController : ControllerBase public virtual async Task InsertAsync(T processMap, int idWell, CancellationToken cancellationToken) { processMap.IdWell = idWell; - processMap.IdUser = IdUser; - processMap.LastUpdate = DateTime.UtcNow; await CheckIsExistsWellSectionTypeAsync(processMap.IdWellSectionType, cancellationToken); await AssertUserHasAccessToEditProcessMapAsync(processMap.IdWell, cancellationToken); - var result = await repository.InsertAsync(processMap, cancellationToken); + var result = await repository.InsertRange(IdUser, new T[1] { processMap }, cancellationToken); await NotifyUsersBySignalR(idWell, cancellationToken); @@ -108,14 +106,12 @@ public abstract class ProcessMapBaseController : ControllerBase public virtual async Task UpdateAsync(T processMap, int idWell, CancellationToken cancellationToken) { processMap.IdWell = idWell; - processMap.IdUser = IdUser; - processMap.LastUpdate = DateTime.UtcNow; await CheckIsExistsWellSectionTypeAsync(processMap.IdWellSectionType, cancellationToken); await AssertUserHasAccessToEditProcessMapAsync(idWell, cancellationToken); - var result = await repository.UpdateAsync(processMap, cancellationToken); + var result = await repository.UpdateRange(IdUser, new T[1] { processMap }, cancellationToken); if (result == ICrudRepository.ErrorIdNotFound) return this.ValidationBadRequest(nameof(processMap.Id), $"РТК с Id: {processMap.Id} не существует"); @@ -138,7 +134,7 @@ public abstract class ProcessMapBaseController : ControllerBase { await AssertUserHasAccessToEditProcessMapAsync(idWell, cancellationToken); - var result = await repository.DeleteAsync(id, cancellationToken); + var result = await repository.DeleteRange(IdUser, new int[] { id }, cancellationToken); await NotifyUsersBySignalR(idWell, cancellationToken); @@ -161,7 +157,7 @@ public abstract class ProcessMapBaseController : ControllerBase if (!processMaps.Any()) return NoContent(); - + return Ok(processMaps); } @@ -183,14 +179,11 @@ public abstract class ProcessMapBaseController : ControllerBase if (!idWell.HasValue) return this.ValidationBadRequest(nameof(uid), $"Wrong uid {uid}"); - var requests = new[] { new ProcessMapPlanRequest - { - IdWell = idWell.Value, - UpdateFrom = updateFrom - } - }; + var request = new ProcessMapPlanBaseRequestWithWell(idWell.Value) { + UpdateFrom = updateFrom, + }; - var processMaps = await repository.GetAsync(requests, cancellationToken); + var processMaps = await repository.Get(request, cancellationToken); return Ok(processMaps); } @@ -212,7 +205,8 @@ public abstract class ProcessMapBaseController : ControllerBase protected async Task NotifyUsersBySignalR(int idWell, CancellationToken cancellationToken) { - var dtos = await repository.GetByIdWellAsync(idWell, cancellationToken); + var request = new ProcessMapPlanBaseRequestWithWell(idWell); + var dtos = await repository.Get(request, cancellationToken); await telemetryHubContext.Clients .Group($"{SignalRGroup}_{idWell}") @@ -222,6 +216,6 @@ public abstract class ProcessMapBaseController : ControllerBase private async Task CheckIsExistsWellSectionTypeAsync(int idWellSectionType, CancellationToken cancellationToken) { _ = await wellSectionRepository.GetOrDefaultAsync(idWellSectionType, cancellationToken) - ?? throw new ArgumentInvalidException(nameof(ProcessMapPlanWellDrillingDto.IdWellSectionType), $"Тип секции с Id: {idWellSectionType} не найден"); + ?? throw new ArgumentInvalidException(nameof(ProcessMapPlanDrillingDto.IdWellSectionType), $"Тип секции с Id: {idWellSectionType} не найден"); } } \ No newline at end of file diff --git a/AsbCloudWebApi/Controllers/ProcessMaps/ProcessMapWellDrillingController.cs b/AsbCloudWebApi/Controllers/ProcessMaps/ProcessMapWellDrillingController.cs index 9c284220..c67d8e63 100644 --- a/AsbCloudWebApi/Controllers/ProcessMaps/ProcessMapWellDrillingController.cs +++ b/AsbCloudWebApi/Controllers/ProcessMaps/ProcessMapWellDrillingController.cs @@ -1,5 +1,5 @@ using AsbCloudApp.Data; -using AsbCloudApp.Data.ProcessMaps; +using AsbCloudApp.Data.ProcessMapPlan; using AsbCloudApp.Data.ProcessMaps.Report; using AsbCloudApp.Repositories; using AsbCloudApp.Requests; @@ -11,10 +11,7 @@ using AsbCloudWebApi.SignalR.Clients; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.SignalR; -using System; using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; -using System.IO; using System.Threading; using System.Threading.Tasks; @@ -23,28 +20,25 @@ namespace AsbCloudWebApi.Controllers.ProcessMaps; /// /// РТК бурение /// -public class ProcessMapWellDrillingController : ProcessMapBaseController +public class ProcessMapWellDrillingController : ProcessMapBaseController { private readonly IProcessMapReportDataSaubStatService processMapReportDataSaubStatService; private readonly IProcessMapReportDataSaubStatExportService processMapReportDataSaubStatExportService; - private readonly IProcessMapPlanImportService processMapPlanImportService; protected override string SignalRGroup => "ProcessMapWellDrilling"; public ProcessMapWellDrillingController(IWellService wellService, - IProcessMapPlanRepository repository, + IChangeLogRepository repository, IUserRepository userRepository, IProcessMapReportDataSaubStatExportService processMapReportDataSaubStatExportService, - IProcessMapPlanImportService processMapPlanImportService, IProcessMapReportDataSaubStatService processMapReportDataSaubStatService, ICrudRepository wellSectionRepository, IHubContext telemetryHubContext, ITelemetryService telemetryService, - IProcessMapPlanService service) + IProcessMapPlanService service) : base(wellService, repository, userRepository, wellSectionRepository, telemetryHubContext, telemetryService, service) { this.processMapReportDataSaubStatExportService = processMapReportDataSaubStatExportService; - this.processMapPlanImportService = processMapPlanImportService; this.processMapReportDataSaubStatService = processMapReportDataSaubStatService; } @@ -83,75 +77,4 @@ public class ProcessMapWellDrillingController : ProcessMapBaseController - /// Импорт РТК бурение план - /// - /// Id скважины - /// - /// - /// - /// - [Obsolete] - [HttpPost("import/{options}")] - [ProducesResponseType(typeof(ValidationProblemDetails), StatusCodes.Status400BadRequest)] - public async Task ImportAsync(int idWell, - int options, - [Required] IFormFile file, - CancellationToken cancellationToken) - { - await AssertUserHasAccessToEditProcessMapAsync(idWell, cancellationToken); - - if (Path.GetExtension(file.FileName).ToLower() != ".xlsx") - return this.ValidationBadRequest(nameof(file), "Требуется xlsx файл."); - - using Stream stream = file.OpenReadStream(); - - try - { - await processMapPlanImportService.ImportAsync(idWell, - IdUser, - (options & 1) > 0, - stream, - cancellationToken); - - await NotifyUsersBySignalR(idWell, cancellationToken); - } - catch (FileFormatException ex) - { - return this.ValidationBadRequest(nameof(file), ex.Message); - } - - return Ok(); - } - - /// - /// Экспорт РТК бурение план - /// - /// Id скважины - /// - /// - [Obsolete] - [HttpGet("export")] - [ProducesResponseType(typeof(PhysicalFileResult), StatusCodes.Status200OK, "application/octet-stream")] - [ProducesResponseType(typeof(ValidationProblemDetails), StatusCodes.Status400BadRequest)] - public async Task ExportAsync(int idWell, CancellationToken cancellationToken) - { - var processMapsFile = await processMapPlanImportService.ExportAsync(idWell, cancellationToken); - - return File(processMapsFile.File, "application/octet-stream", processMapsFile.Name); - } - - /// - /// Возвращает шаблон файла для импорта - /// - /// Запрашиваемый файл - [Obsolete] - [HttpGet("template")] - [ProducesResponseType(typeof(PhysicalFileResult), StatusCodes.Status200OK, "application/octet-stream")] - public async Task GetTemplateAsync(CancellationToken cancellationToken) - { - var template = await processMapPlanImportService.GetExcelTemplateStreamAsync(cancellationToken); - return File(template.File, "application/octet-stream", template.Name); - } } \ No newline at end of file diff --git a/AsbCloudWebApi/Controllers/ProcessMaps/ProcessMapWellReamController.cs b/AsbCloudWebApi/Controllers/ProcessMaps/ProcessMapWellReamController.cs index b9c5ea94..aa81ec2b 100644 --- a/AsbCloudWebApi/Controllers/ProcessMaps/ProcessMapWellReamController.cs +++ b/AsbCloudWebApi/Controllers/ProcessMaps/ProcessMapWellReamController.cs @@ -1,6 +1,7 @@ using AsbCloudApp.Data; using AsbCloudApp.Data.ProcessMaps; using AsbCloudApp.Repositories; +using AsbCloudApp.Requests; using AsbCloudApp.Services; using AsbCloudApp.Services.ProcessMaps; using AsbCloudWebApi.SignalR; @@ -14,16 +15,16 @@ namespace AsbCloudWebApi.Controllers.ProcessMaps; /// public class ProcessMapWellReamController : ProcessMapBaseController { - public ProcessMapWellReamController(IWellService wellService, - IProcessMapPlanRepository repository, - IUserRepository userRepository, - ICrudRepository wellSectionRepository, - IHubContext telemetryHubContext, - ITelemetryService telemetryService, - IProcessMapPlanService service) - : base(wellService, repository, userRepository, wellSectionRepository, telemetryHubContext, telemetryService, service) - { - } + public ProcessMapWellReamController(IWellService wellService, + IChangeLogRepository repository, + IUserRepository userRepository, + ICrudRepository wellSectionRepository, + IHubContext telemetryHubContext, + ITelemetryService telemetryService, + IProcessMapPlanService service) + : base(wellService, repository, userRepository, wellSectionRepository, telemetryHubContext, telemetryService, service) + { + } - protected override string SignalRGroup => "ProcessMapWellReam"; + protected override string SignalRGroup => "ProcessMapWellReam"; } \ No newline at end of file diff --git a/AsbCloudWebApi/appsettings.json b/AsbCloudWebApi/appsettings.json index 72d50f57..5294ebe7 100644 --- a/AsbCloudWebApi/appsettings.json +++ b/AsbCloudWebApi/appsettings.json @@ -7,10 +7,10 @@ } }, "ConnectionStrings": { - "DefaultConnection": "Host=localhost;Database=postgres;Username=postgres;Password=q;Persist Security Info=True", - "DebugConnection": "Host=localhost;Database=postgres;Username=postgres;Password=q;Persist Security Info=True;Include Error Detail=True", + "DefaultConnection": "Host=localhost;Database=postgres2;Username=postgres;Password=q;Persist Security Info=True", + "DebugConnection": "Host=localhost;Database=postgres2;Username=postgres;Password=q;Persist Security Info=True;Include Error Detail=True", "TestConnection": "Host=localhost;Database=test;Username=postgres;Password=q;Persist Security Info=True;Include Error Detail=True", - "LocalConnection": "Host=localhost;Database=postgres;Username=postgres;Password=q;Persist Security Info=True" + "LocalConnection": "Host=localhost;Database=postgres2;Username=postgres;Password=q;Persist Security Info=True" }, "AllowedHosts": "*", "ContentPath": "../data",