diff --git a/AsbCloudApp/Repositories/IChangeLogRepository.cs b/AsbCloudApp/Repositories/IChangeLogRepository.cs
index 92c747f7..b63edda2 100644
--- a/AsbCloudApp/Repositories/IChangeLogRepository.cs
+++ b/AsbCloudApp/Repositories/IChangeLogRepository.cs
@@ -2,6 +2,7 @@
using AsbCloudApp.Requests;
using System;
using System.Collections.Generic;
+using System.Linq;
using System.Threading;
using System.Threading.Tasks;
@@ -10,7 +11,7 @@ namespace AsbCloudApp.Repositories;
///
/// Репозиторий для записей с историей
///
-public interface IChangeLogRepository
+public interface IChangeLogRepository
where TDto : IId
{
///
@@ -92,13 +93,12 @@ public interface IChangeLogRepository
///
///
Task> GetCurrent(TRequest request, CancellationToken token);
+
///
- /// Получение измененных записей за определенный момент времени
+ /// Получение объекта, реализующего интерфейс IChangeLogRepositoryBuilder
+ /// для последующих вызовов методов фильтрации по запросам
///
- /// фильтр по changeLog
- /// фильтр по данным внутри changeLog
- ///
///
- Task>> GetChangeLogByMoment(ChangeLogRequest changeLogRequest, TRequest dataRequest, CancellationToken token);
+ IChangeLogRepositoryBuilder GetRequestBuilder(ChangeLogRequest request);
}
diff --git a/AsbCloudApp/Repositories/IChangeLogRepositoryBuilder.cs b/AsbCloudApp/Repositories/IChangeLogRepositoryBuilder.cs
new file mode 100644
index 00000000..9d51774d
--- /dev/null
+++ b/AsbCloudApp/Repositories/IChangeLogRepositoryBuilder.cs
@@ -0,0 +1,40 @@
+using AsbCloudApp.Data;
+using System;
+using System.Collections.Generic;
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace AsbCloudApp.Repositories;
+
+///
+/// Интерфейс для работы с объектами, содержащими историю изменений
+///
+///
+///
+public interface IChangeLogRepositoryBuilder
+ where TDto : IId
+{
+ ///
+ /// Применение запроса
+ ///
+ /// Запрос
+ ///
+ ///
+ IChangeLogRepositoryBuilder ApplyRequest(TRequest request, CancellationToken token);
+
+ ///
+ /// Материализация записей
+ ///
+ ///
+ ///
+ ///
+ Task> GetData(TimeSpan offset, CancellationToken token);
+
+ ///
+ /// Материализация записей с историей
+ ///
+ ///
+ ///
+ ///
+ Task>> GetChangeLogData(TimeSpan offset, CancellationToken token);
+}
diff --git a/AsbCloudApp/Requests/ProcessMapPlanBaseRequest.cs b/AsbCloudApp/Requests/ProcessMapPlanBaseRequest.cs
index 62e3934d..2b4cd30d 100644
--- a/AsbCloudApp/Requests/ProcessMapPlanBaseRequest.cs
+++ b/AsbCloudApp/Requests/ProcessMapPlanBaseRequest.cs
@@ -5,7 +5,7 @@ namespace AsbCloudApp.Requests;
///
/// Запрос для получения РТК план
///
-public class ProcessMapPlanBaseRequest : ChangeLogRequest
+public class ProcessMapPlanBaseRequest
{
///
/// Вернуть данные, которые поменялись с указанной даты
@@ -24,7 +24,7 @@ public class ProcessMapPlanBaseRequest : ChangeLogRequest
/// Копирующий конструктор
///
/// Параметры запроса
- public ProcessMapPlanBaseRequest(ProcessMapPlanBaseRequest request) : base(request)
+ public ProcessMapPlanBaseRequest(ProcessMapPlanBaseRequest request)
{
UpdateFrom = request.UpdateFrom;
}
diff --git a/AsbCloudInfrastructure/DependencyInjection.cs b/AsbCloudInfrastructure/DependencyInjection.cs
index 319b0bc2..e692200d 100644
--- a/AsbCloudInfrastructure/DependencyInjection.cs
+++ b/AsbCloudInfrastructure/DependencyInjection.cs
@@ -196,12 +196,12 @@ namespace AsbCloudInfrastructure
services.AddTransient();
services.AddTransient<
- IChangeLogRepository,
- ProcessMapPlanBaseRepository>();
+ IChangeLogRepository,
+ ProcessMapPlanBaseRepository>();
services.AddTransient<
- IChangeLogRepository,
- ProcessMapPlanBaseRepository>();
+ IChangeLogRepository,
+ ProcessMapPlanBaseRepository>();
services.AddTransient();
diff --git a/AsbCloudInfrastructure/Repository/ChangeLogRepositoryAbstract.cs b/AsbCloudInfrastructure/Repository/ChangeLogRepositoryAbstract.cs
index bd10e36b..767534df 100644
--- a/AsbCloudInfrastructure/Repository/ChangeLogRepositoryAbstract.cs
+++ b/AsbCloudInfrastructure/Repository/ChangeLogRepositoryAbstract.cs
@@ -3,9 +3,12 @@ using AsbCloudApp.Exceptions;
using AsbCloudApp.Repositories;
using AsbCloudApp.Requests;
using AsbCloudDb.Model;
+using iText.Signatures;
+using iText.StyledXmlParser.Jsoup.Nodes;
using Mapster;
using Microsoft.EntityFrameworkCore;
using Npgsql;
+using Org.BouncyCastle.Asn1.Ocsp;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -14,10 +17,9 @@ using System.Threading.Tasks;
namespace AsbCloudInfrastructure.Repository;
-public abstract class ChangeLogRepositoryAbstract : IChangeLogRepository
+public abstract class ChangeLogRepositoryAbstract : IChangeLogRepository
where TDto : AsbCloudApp.Data.IId
where TEntity : ChangeLogAbstract
- where TRequest : ChangeLogRequest
{
protected readonly IAsbCloudDbContext db;
@@ -26,6 +28,57 @@ public abstract class ChangeLogRepositoryAbstract : ICh
this.db = db;
}
+ private class ChangeLogRepositoryBuilder : IChangeLogRepositoryBuilder
+ {
+ private readonly ChangeLogRepositoryAbstract Repository;
+ private IQueryable Query;
+
+ public ChangeLogRepositoryBuilder(
+ ChangeLogRepositoryAbstract repository,
+ ChangeLogRequest request)
+ {
+ this.Repository = repository;
+ this.Query = repository.db.Set();
+
+ if (request.Moment.HasValue)
+ {
+ var momentUtc = request.Moment.Value.ToUniversalTime();
+
+ this.Query = this.Query
+ .Where(e => e.Creation <= momentUtc)
+ .Where(e => e.Obsolete == null || e.Obsolete >= momentUtc);
+ }
+ }
+
+ public IChangeLogRepositoryBuilder ApplyRequest(TRequest request, CancellationToken token)
+ {
+ this.Query = Repository.BuildQuery(request, Query);
+ return this;
+ }
+
+ public async Task> GetData(TimeSpan offset, CancellationToken token)
+ {
+
+ var dtos = await this.Query.Select(e => Repository.Convert(e, offset))
+ .ToArrayAsync(token);
+ return dtos;
+ }
+
+ public async Task>> GetChangeLogData(TimeSpan offset, CancellationToken token)
+ {
+ var dtos = await this.Query.Select(e => Repository.ConvertChangeLogDto(e, offset))
+ .ToArrayAsync(token);
+ return dtos;
+ }
+ }
+
+ public IChangeLogRepositoryBuilder GetRequestBuilder(ChangeLogRequest request)
+ {
+ var builder = new ChangeLogRepositoryBuilder(this, request);
+
+ return builder;
+ }
+
public async Task InsertRange(int idUser, IEnumerable dtos, CancellationToken token)
{
var result = 0;
@@ -134,6 +187,7 @@ public abstract class ChangeLogRepositoryAbstract : ICh
public async Task Clear(int idUser, TRequest request, CancellationToken token)
{
var updateTime = DateTimeOffset.UtcNow;
+
var query = BuildQuery(request);
query = query.Where(e => e.Obsolete == null);
@@ -239,7 +293,7 @@ public abstract class ChangeLogRepositoryAbstract : ICh
return dtos;
}
- private async Task>> CreateChangeLogDto(IQueryable query, TimeSpan offset, CancellationToken token)
+ public async Task>> CreateChangeLogDto(IQueryable query, TimeSpan offset, CancellationToken token)
{
var entities = await query
.OrderBy(e => e.Creation)
@@ -251,37 +305,25 @@ public abstract class ChangeLogRepositoryAbstract : ICh
return dtos;
}
- public async Task>> GetChangeLogByMoment(ChangeLogRequest changeLogRequest, TRequest dataRequest, CancellationToken token)
- {
- var query = BuildQuery(dataRequest);
- if (changeLogRequest.Moment.HasValue)
- {
- var momentUtc = changeLogRequest.Moment.Value.ToUniversalTime();
- query = query
- .Where(e => e.Creation <= momentUtc)
- .Where(e => e.Obsolete == null || e.Obsolete >= momentUtc);
- }
-
- TimeSpan offset = GetTimezoneOffset(dataRequest);
- var dtos = await CreateChangeLogDto(query, offset, token);
-
- return dtos;
- }
-
public async Task> GetCurrent(TRequest request, CancellationToken token)
{
var changeLogRequest = new ChangeLogRequest()
{
Moment = new DateTimeOffset(3000, 1, 1, 0, 0, 0, TimeSpan.Zero)
};
- var entities = await GetChangeLogByMoment(changeLogRequest, request, token);
- var result = entities.Select(e => e.Item);
- return result;
+
+ var builder = new ChangeLogRepositoryBuilder(this, changeLogRequest);
+ builder.ApplyRequest(request, token);
+
+ var offset = GetTimezoneOffset(request);
+ var dtos = await builder.GetData(offset, token);
+
+ return dtos;
}
protected abstract TimeSpan GetTimezoneOffset(TRequest request);
- protected abstract IQueryable BuildQuery(TRequest request);
+ protected abstract IQueryable BuildQuery(TRequest request, IQueryable? query = null);
protected virtual TEntity Convert(TDto dto)
{
@@ -332,4 +374,5 @@ public abstract class ChangeLogRepositoryAbstract : ICh
if (pgException.SqlState == PostgresErrorCodes.ForeignKeyViolation)
throw new ArgumentInvalidException("dtos", pgException.Message + "\r\n" + pgException.Detail);
}
+
}
diff --git a/AsbCloudInfrastructure/Repository/IChangeLogReposiroryBuilder.cs b/AsbCloudInfrastructure/Repository/IChangeLogReposiroryBuilder.cs
new file mode 100644
index 00000000..c0327135
--- /dev/null
+++ b/AsbCloudInfrastructure/Repository/IChangeLogReposiroryBuilder.cs
@@ -0,0 +1,5 @@
+namespace AsbCloudInfrastructure.Repository;
+
+internal interface IChangeLogReposiroryBuilder
+{
+}
\ No newline at end of file
diff --git a/AsbCloudInfrastructure/Repository/ProcessMapPlanBaseRepository.cs b/AsbCloudInfrastructure/Repository/ProcessMapPlanBaseRepository.cs
index 7f84a052..5343cd00 100644
--- a/AsbCloudInfrastructure/Repository/ProcessMapPlanBaseRepository.cs
+++ b/AsbCloudInfrastructure/Repository/ProcessMapPlanBaseRepository.cs
@@ -9,7 +9,7 @@ using System.Linq;
namespace AsbCloudInfrastructure.Repository;
-public class ProcessMapPlanBaseRepository : ChangeLogRepositoryAbstract
+public class ProcessMapPlanBaseRepository : ChangeLogRepositoryAbstract
where TDto : ProcessMapPlanBaseDto
where TEntity : ProcessMapPlanBase
{
@@ -21,15 +21,18 @@ public class ProcessMapPlanBaseRepository : ChangeLogRepositoryAb
this.wellService = wellService;
}
- protected override IQueryable BuildQuery(ProcessMapPlanBaseRequestWithWell request)
+ protected override IQueryable BuildQuery(ProcessMapPlanBaseRequestWithWell request, IQueryable? query = null)
{
- var query = db
- .Set()
- .Include(e => e.Author)
- .Include(e => e.Editor)
- .Include(e => e.Well)
- .Include(e => e.WellSectionType)
- .Where(e => e.IdWell == request.IdWell);
+ if(query is null)
+ {
+ query = db.Set();
+ }
+
+ query = query.Include(e => e.Author)
+ .Include(e => e.Editor)
+ .Include(e => e.Well)
+ .Include(e => e.WellSectionType)
+ .Where(e => e.IdWell == request.IdWell);
if (request.UpdateFrom.HasValue)
{
@@ -37,8 +40,6 @@ public class ProcessMapPlanBaseRepository : ChangeLogRepositoryAb
query = query.Where(e => e.Creation >= from || e.Obsolete >= from);
}
-
-
return query;
}
diff --git a/AsbCloudInfrastructure/Repository/WellCompositeRepository.cs b/AsbCloudInfrastructure/Repository/WellCompositeRepository.cs
index e5da1ba8..3c4c22e2 100644
--- a/AsbCloudInfrastructure/Repository/WellCompositeRepository.cs
+++ b/AsbCloudInfrastructure/Repository/WellCompositeRepository.cs
@@ -3,6 +3,7 @@ using AsbCloudApp.Data.ProcessMaps;
using AsbCloudApp.Repositories;
using AsbCloudApp.Requests;
using AsbCloudDb.Model;
+using AsbCloudDb.Model.ProcessMaps;
using Mapster;
using Microsoft.EntityFrameworkCore;
using System;
@@ -16,11 +17,11 @@ namespace AsbCloudInfrastructure.Repository;
public class WellCompositeRepository : IWellCompositeRepository
{
private readonly IAsbCloudDbContext db;
- private readonly IChangeLogRepository processMapPlanDrillingRepository;
+ private readonly IChangeLogRepository processMapPlanDrillingRepository;
public WellCompositeRepository(
IAsbCloudDbContext db,
- IChangeLogRepository processMapPlanDrillingRepository)
+ IChangeLogRepository processMapPlanDrillingRepository)
{
this.db = db;
this.processMapPlanDrillingRepository = processMapPlanDrillingRepository;
diff --git a/AsbCloudInfrastructure/Services/DetectOperations/WorkOperationDetection.cs b/AsbCloudInfrastructure/Services/DetectOperations/WorkOperationDetection.cs
index d001471e..42291195 100644
--- a/AsbCloudInfrastructure/Services/DetectOperations/WorkOperationDetection.cs
+++ b/AsbCloudInfrastructure/Services/DetectOperations/WorkOperationDetection.cs
@@ -43,7 +43,11 @@ public class WorkOperationDetection: Work
var telemetryId = telemetryIds[i];
var beginDate = lastDetectedDates.TryGetValue(telemetryId, out var date) ? date : (DateTimeOffset?)null;
-
+ if(telemetryId == 939)
+ {
+ ;
+ }
+
onProgressCallback($"Start detecting telemetry: {telemetryId} from {beginDate}", i / telemetryIds.Length);
var detectedOperations = await detectedOperationService.DetectOperationsAsync(telemetryId, beginDate, token);
diff --git a/AsbCloudInfrastructure/Services/ProcessMapPlan/Export/ProcessMapPlanDrillingExportService.cs b/AsbCloudInfrastructure/Services/ProcessMapPlan/Export/ProcessMapPlanDrillingExportService.cs
index 5b0935d2..97d17fcf 100644
--- a/AsbCloudInfrastructure/Services/ProcessMapPlan/Export/ProcessMapPlanDrillingExportService.cs
+++ b/AsbCloudInfrastructure/Services/ProcessMapPlan/Export/ProcessMapPlanDrillingExportService.cs
@@ -8,15 +8,16 @@ using AsbCloudApp.Repositories;
using AsbCloudApp.Requests;
using AsbCloudApp.Requests.ExportOptions;
using AsbCloudApp.Services;
+using AsbCloudDb.Model.ProcessMaps;
using AsbCloudInfrastructure.Services.ExcelServices.Templates;
using AsbCloudInfrastructure.Services.ExcelServices.Templates.ProcessMapPlanTemplates;
namespace AsbCloudInfrastructure.Services.ProcessMapPlan.Export;
-public class ProcessMapPlanDrillingExportService : ProcessMapPlanExportService
+public class ProcessMapPlanDrillingExportService : ProcessMapPlanExportService
{
public ProcessMapPlanDrillingExportService(
- IChangeLogRepository processMapPlanRepository,
+ IChangeLogRepository processMapPlanRepository,
IWellService wellService)
: base(processMapPlanRepository, wellService)
{
diff --git a/AsbCloudInfrastructure/Services/ProcessMapPlan/Export/ProcessMapPlanExportService.cs b/AsbCloudInfrastructure/Services/ProcessMapPlan/Export/ProcessMapPlanExportService.cs
index 8f8596ab..5ea43b18 100644
--- a/AsbCloudInfrastructure/Services/ProcessMapPlan/Export/ProcessMapPlanExportService.cs
+++ b/AsbCloudInfrastructure/Services/ProcessMapPlan/Export/ProcessMapPlanExportService.cs
@@ -12,14 +12,14 @@ using AsbCloudInfrastructure.Services.ExcelServices;
namespace AsbCloudInfrastructure.Services.ProcessMapPlan.Export;
-public abstract class ProcessMapPlanExportService : ExportExcelService
+public abstract class ProcessMapPlanExportService : ExportExcelService
where TDto : ProcessMapPlanBaseDto
{
protected readonly IWellService wellService;
- private readonly IChangeLogRepository processMapPlanRepository;
+ private readonly IChangeLogRepository processMapPlanRepository;
- protected ProcessMapPlanExportService(IChangeLogRepository processMapPlanRepository,
+ protected ProcessMapPlanExportService(IChangeLogRepository processMapPlanRepository,
IWellService wellService)
{
this.processMapPlanRepository = processMapPlanRepository;
@@ -28,10 +28,7 @@ public abstract class ProcessMapPlanExportService : ExportExcelService> GetDtosAsync(WellRelatedExportRequest options, CancellationToken token)
{
- var request = new ProcessMapPlanBaseRequestWithWell(options.IdWell)
- {
- Moment = DateTimeOffset.UtcNow
- };
+ var request = new ProcessMapPlanBaseRequestWithWell(options.IdWell);
var dtos = await processMapPlanRepository.GetCurrent(request, token);
return dtos;
diff --git a/AsbCloudInfrastructure/Services/ProcessMapPlan/Export/ProcessMapPlanReamExportService.cs b/AsbCloudInfrastructure/Services/ProcessMapPlan/Export/ProcessMapPlanReamExportService.cs
index c3dc5d69..12e9ac7c 100644
--- a/AsbCloudInfrastructure/Services/ProcessMapPlan/Export/ProcessMapPlanReamExportService.cs
+++ b/AsbCloudInfrastructure/Services/ProcessMapPlan/Export/ProcessMapPlanReamExportService.cs
@@ -5,17 +5,18 @@ using AsbCloudApp.Repositories;
using AsbCloudApp.Requests;
using AsbCloudApp.Requests.ExportOptions;
using AsbCloudApp.Services;
+using AsbCloudDb.Model.ProcessMaps;
using AsbCloudInfrastructure.Services.ExcelServices.Templates;
using AsbCloudInfrastructure.Services.ExcelServices.Templates.ProcessMapPlanTemplates;
namespace AsbCloudInfrastructure.Services.ProcessMapPlan.Export;
-public class ProcessMapPlanReamExportService : ProcessMapPlanExportService
+public class ProcessMapPlanReamExportService : ProcessMapPlanExportService
{
protected override ITemplateParameters TemplateParameters => new ProcessMapPlanReamTemplate();
public ProcessMapPlanReamExportService(
- IChangeLogRepository processMapPlanRepository,
+ IChangeLogRepository processMapPlanRepository,
IWellService wellService)
: base(processMapPlanRepository, wellService)
{
diff --git a/AsbCloudInfrastructure/Services/ProcessMaps/Report/ProcessMapReportDrillingService.cs b/AsbCloudInfrastructure/Services/ProcessMaps/Report/ProcessMapReportDrillingService.cs
index 5b51ba62..c550ef2b 100644
--- a/AsbCloudInfrastructure/Services/ProcessMaps/Report/ProcessMapReportDrillingService.cs
+++ b/AsbCloudInfrastructure/Services/ProcessMaps/Report/ProcessMapReportDrillingService.cs
@@ -14,19 +14,20 @@ using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using AsbCloudApp.Data.WellOperation;
+using AsbCloudDb.Model.ProcessMaps;
namespace AsbCloudInfrastructure.Services.ProcessMaps.Report;
public class ProcessMapReportDrillingService : IProcessMapReportDrillingService
{
private readonly IWellService wellService;
- private readonly IChangeLogRepository processMapPlanBaseRepository;
+ private readonly IChangeLogRepository processMapPlanBaseRepository;
private readonly IDataSaubStatRepository dataSaubStatRepository;
private readonly IWellOperationRepository wellOperationRepository;
private readonly IWellOperationCategoryRepository wellOperationCategoryRepository;
public ProcessMapReportDrillingService(IWellService wellService,
- IChangeLogRepository processMapPlanBaseRepository,
+ IChangeLogRepository processMapPlanBaseRepository,
IDataSaubStatRepository dataSaubStatRepository,
IWellOperationRepository wellOperationRepository,
IWellOperationCategoryRepository wellOperationCategoryRepository
diff --git a/AsbCloudInfrastructure/Services/WellInfoService.cs b/AsbCloudInfrastructure/Services/WellInfoService.cs
index 2f395d01..f1528df6 100644
--- a/AsbCloudInfrastructure/Services/WellInfoService.cs
+++ b/AsbCloudInfrastructure/Services/WellInfoService.cs
@@ -7,6 +7,7 @@ using AsbCloudApp.IntegrationEvents.Interfaces;
using AsbCloudApp.Repositories;
using AsbCloudApp.Requests;
using AsbCloudApp.Services;
+using AsbCloudDb.Model.ProcessMaps;
using AsbCloudInfrastructure.Background;
using Mapster;
using Microsoft.Extensions.DependencyInjection;
@@ -32,7 +33,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>();
@@ -43,10 +44,7 @@ public class WellInfoService
var wellsIds = activeWells.Select(w => w.Id);
- var processMapPlanWellDrillingRequests = wellsIds.Select(id => new ProcessMapPlanBaseRequestWithWell(id)
- {
- Moment = DateTimeOffset.UtcNow.AddDays(1)
- });
+ var processMapPlanWellDrillingRequests = wellsIds.Select(id => new ProcessMapPlanBaseRequestWithWell(id));
var processMapPlanWellDrillings = new List();
foreach (var processMapPlanWellDrillingRequest in processMapPlanWellDrillingRequests)
{
diff --git a/AsbCloudInfrastructure/Startup.cs b/AsbCloudInfrastructure/Startup.cs
index 68c0d5b7..25f4ba61 100644
--- a/AsbCloudInfrastructure/Startup.cs
+++ b/AsbCloudInfrastructure/Startup.cs
@@ -30,11 +30,11 @@ namespace AsbCloudInfrastructure
var backgroundWorker = provider.GetRequiredService();
backgroundWorker.Add(TimeSpan.FromDays(1));
- backgroundWorker.Add(TimeSpan.FromMinutes(30));
- backgroundWorker.Add(TimeSpan.FromMinutes(15));
- backgroundWorker.Add(TimeSpan.FromMinutes(15));
- backgroundWorker.Add(TimeSpan.FromMinutes(30));
- backgroundWorker.Add(MakeMemoryMonitoringWork(), TimeSpan.FromMinutes(1));
+ backgroundWorker.Add(TimeSpan.FromMinutes(0));
+ backgroundWorker.Add(TimeSpan.FromMinutes(0));
+ backgroundWorker.Add(TimeSpan.FromMinutes(0));
+ backgroundWorker.Add(TimeSpan.FromMinutes(0));
+ backgroundWorker.Add(MakeMemoryMonitoringWork(), TimeSpan.FromMinutes(0));
var notificationBackgroundWorker = provider.GetRequiredService();
}
diff --git a/AsbCloudWebApi.IntegrationTests/Clients/IProcessMapPlanDrillingClient.cs b/AsbCloudWebApi.IntegrationTests/Clients/IProcessMapPlanDrillingClient.cs
index 51655328..59e32900 100644
--- a/AsbCloudWebApi.IntegrationTests/Clients/IProcessMapPlanDrillingClient.cs
+++ b/AsbCloudWebApi.IntegrationTests/Clients/IProcessMapPlanDrillingClient.cs
@@ -24,13 +24,13 @@ public interface IProcessMapPlanDrillingClient where TDto : ProcessMapPlan
[Get(BaseRoute)]
Task>> Get(int idWell);
- [Get($"{BaseRoute}/history")]
+ [Get($"{BaseRoute}/changelogByMoment")]
Task>>> Get(int idWell, DateTimeOffset? moment);
[Get("/api/telemetry/{uid}/ProcessMapPlanDrilling")]
Task>>> Get(string uid, DateTimeOffset? updateFrom);
- [Get($"{BaseRoute}/changeLog")]
+ [Get($"{BaseRoute}/changeLogForDate")]
Task>> GetChangeLog(int idWell, DateOnly? date);
[Get($"{BaseRoute}/dates")]
diff --git a/AsbCloudWebApi.Tests/Services/ProcessMaps/ProcessMapReportDataSaubStatServiceTest.cs b/AsbCloudWebApi.Tests/Services/ProcessMaps/ProcessMapReportDataSaubStatServiceTest.cs
index 33f837bd..8cbcdbf8 100644
--- a/AsbCloudWebApi.Tests/Services/ProcessMaps/ProcessMapReportDataSaubStatServiceTest.cs
+++ b/AsbCloudWebApi.Tests/Services/ProcessMaps/ProcessMapReportDataSaubStatServiceTest.cs
@@ -5,10 +5,12 @@ using AsbCloudApp.Repositories;
using AsbCloudApp.Requests;
using AsbCloudApp.Services;
using AsbCloudDb.Model;
+using AsbCloudDb.Model.ProcessMaps;
using AsbCloudInfrastructure.Services.ProcessMaps.Report;
using NSubstitute;
using System;
using System.Collections.Generic;
+using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Xunit;
@@ -22,8 +24,8 @@ public class ProcessMapReportDataSaubStatServiceTest
private IWellService wellService
= Substitute.For();
- private IChangeLogRepository processMapPlanBaseRepository
- = Substitute.For>();
+ private IChangeLogRepository processMapPlanBaseRepository
+ = Substitute.For>();
private IWellOperationRepository wellOperationRepository
= Substitute.For();
@@ -131,6 +133,12 @@ public class ProcessMapReportDataSaubStatServiceTest
Comment = "s",
},
};
+
+ private readonly static IEnumerable> processMapPlanChangeLog = processMapPlan.Select(p => new ChangeLogDto()
+ {
+ Item = p,
+ });
+
private readonly static IEnumerable operations = new List()
{
new()
@@ -257,6 +265,9 @@ public class ProcessMapReportDataSaubStatServiceTest
processMapPlanBaseRepository.GetCurrent(Arg.Any(), Arg.Any())
.Returns(processMapPlan);
+ processMapPlanBaseRepository.GetChangeLogForDate(Arg.Any(), null, Arg.Any())
+ .Returns(processMapPlanChangeLog);
+
wellOperationRepository.GetAsync(Arg.Any(), Arg.Any())
.Returns(operations);
diff --git a/AsbCloudWebApi/Controllers/ProcessMaps/ProcessMapPlanBaseController.cs b/AsbCloudWebApi/Controllers/ProcessMaps/ProcessMapPlanBaseController.cs
index bac90f07..953c6c04 100644
--- a/AsbCloudWebApi/Controllers/ProcessMaps/ProcessMapPlanBaseController.cs
+++ b/AsbCloudWebApi/Controllers/ProcessMaps/ProcessMapPlanBaseController.cs
@@ -8,8 +8,11 @@ using AsbCloudApp.Requests.ParserOptions;
using AsbCloudApp.Services;
using AsbCloudApp.Services.Export;
using AsbCloudApp.Services.Parsers;
+using AsbCloudDb.Model.ProcessMapPlan;
+using DocumentFormat.OpenXml.Drawing;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
+using Microsoft.AspNetCore.Http.HttpResults;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
@@ -27,16 +30,17 @@ namespace AsbCloudWebApi.Controllers.ProcessMaps;
[ApiController]
[Route("api/well/{idWell}/[controller]")]
[Authorize]
-public abstract class ProcessMapPlanBaseController : ControllerBase
+public abstract class ProcessMapPlanBaseController : ControllerBase
+ where TEntity : ProcessMapPlanBase
where TDto : ProcessMapPlanBaseDto
{
- private readonly IChangeLogRepository repository;
+ private readonly IChangeLogRepository repository;
private readonly IWellService wellService;
private readonly IParserService parserService;
private readonly ITelemetryService telemetryService;
private readonly IExportService processMapPlanExportService;
- protected ProcessMapPlanBaseController(IChangeLogRepository repository,
+ protected ProcessMapPlanBaseController(IChangeLogRepository repository,
IWellService wellService,
IParserService parserService,
IExportService processMapPlanExportService,
@@ -144,6 +148,7 @@ public abstract class ProcessMapPlanBaseController : ControllerBase
await AssertUserHasAccessToWell(idWell, token);
var serviceRequest = new ProcessMapPlanBaseRequestWithWell(idWell);
+
var result = await repository.GetCurrent(serviceRequest, token);
return Ok(result);
}
@@ -162,18 +167,20 @@ public abstract class ProcessMapPlanBaseController : ControllerBase
{
await AssertUserHasAccessToWell(idWell, token);
- var serviceRequest = new ProcessMapPlanBaseRequestWithWell(idWell)
- {
- Moment = moment,
- };
+ var dataRequest = new ProcessMapPlanBaseRequestWithWell(idWell);
var changeLogRequest = new ChangeLogRequest()
{
Moment = moment
};
- var result = await repository.GetChangeLogByMoment(changeLogRequest, serviceRequest, token);
- return Ok(result);
+ var builder = repository.GetRequestBuilder(changeLogRequest);
+ builder.ApplyRequest(dataRequest, token);
+
+ var offset = wellService.GetTimezone(idWell).Offset;
+ var dtos = await builder.GetChangeLogData(offset, token);
+
+ return Ok(dtos);
}
///
diff --git a/AsbCloudWebApi/Controllers/ProcessMaps/ProcessMapPlanDrillingController.cs b/AsbCloudWebApi/Controllers/ProcessMaps/ProcessMapPlanDrillingController.cs
index e2193a58..14a5d782 100644
--- a/AsbCloudWebApi/Controllers/ProcessMaps/ProcessMapPlanDrillingController.cs
+++ b/AsbCloudWebApi/Controllers/ProcessMaps/ProcessMapPlanDrillingController.cs
@@ -2,6 +2,7 @@
using AsbCloudApp.Repositories;
using AsbCloudApp.Requests;
using AsbCloudApp.Services;
+using AsbCloudDb.Model.ProcessMaps;
using AsbCloudInfrastructure.Services.ProcessMapPlan.Export;
using AsbCloudInfrastructure.Services.ProcessMapPlan.Parser;
@@ -10,9 +11,9 @@ namespace AsbCloudWebApi.Controllers.ProcessMaps;
///
/// РТК план бурения
///
-public class ProcessMapPlanDrillingController : ProcessMapPlanBaseController
+public class ProcessMapPlanDrillingController : ProcessMapPlanBaseController
{
- public ProcessMapPlanDrillingController(IChangeLogRepository repository,
+ public ProcessMapPlanDrillingController(IChangeLogRepository repository,
IWellService wellService,
ProcessMapPlanDrillingParser parserService,
ITelemetryService telemetryService,
diff --git a/AsbCloudWebApi/Controllers/ProcessMaps/ProcessMapPlanReamController.cs b/AsbCloudWebApi/Controllers/ProcessMaps/ProcessMapPlanReamController.cs
index 7482686a..349cf42d 100644
--- a/AsbCloudWebApi/Controllers/ProcessMaps/ProcessMapPlanReamController.cs
+++ b/AsbCloudWebApi/Controllers/ProcessMaps/ProcessMapPlanReamController.cs
@@ -2,6 +2,7 @@
using AsbCloudApp.Repositories;
using AsbCloudApp.Requests;
using AsbCloudApp.Services;
+using AsbCloudDb.Model.ProcessMaps;
using AsbCloudInfrastructure.Services.ProcessMapPlan.Export;
using AsbCloudInfrastructure.Services.ProcessMapPlan.Parser;
@@ -10,9 +11,9 @@ namespace AsbCloudWebApi.Controllers.ProcessMaps;
///
/// РТК план проработка
///
-public class ProcessMapPlanReamController : ProcessMapPlanBaseController
+public class ProcessMapPlanReamController : ProcessMapPlanBaseController
{
- public ProcessMapPlanReamController(IChangeLogRepository repository,
+ public ProcessMapPlanReamController(IChangeLogRepository repository,
IWellService wellService,
ProcessMapPlanReamParser parserService,
ITelemetryService telemetryService,