diff --git a/AsbCloudApp/Repositories/IWellCompositeRepository.cs b/AsbCloudApp/Repositories/IWellCompositeRepository.cs
index c14fd11c..8b24d32f 100644
--- a/AsbCloudApp/Repositories/IWellCompositeRepository.cs
+++ b/AsbCloudApp/Repositories/IWellCompositeRepository.cs
@@ -1,4 +1,5 @@
using AsbCloudApp.Data;
+using AsbCloudApp.Data.ProcessMap;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
@@ -27,6 +28,14 @@ namespace AsbCloudApp.Repositories
///
///
Task SaveAsync(int idWell, IEnumerable wellComposites, CancellationToken token);
+
+ ///
+ /// Получение РТК по композитной скважине
+ ///
+ ///
+ ///
+ ///
+ Task> GetCompositeProcessMap(int idWell, CancellationToken token);
}
#nullable disable
}
diff --git a/AsbCloudApp/Requests/WellCompositeRequest.cs b/AsbCloudApp/Requests/WellCompositeRequest.cs
new file mode 100644
index 00000000..893a88fd
--- /dev/null
+++ b/AsbCloudApp/Requests/WellCompositeRequest.cs
@@ -0,0 +1,20 @@
+namespace AsbCloudApp.Requests
+{
+#nullable enable
+ ///
+ /// Параметры для запроса получения РТК
+ ///
+ public class WellCompositeRequest
+ {
+ ///
+ /// Идентификатор скважины
+ ///
+ public int IdWell { get; set; }
+
+ ///
+ /// Тип секции
+ ///
+ public int? IdWellSectionType { get; set; }
+ }
+#nullable disable
+}
diff --git a/AsbCloudApp/Services/IProcessMapRepository.cs b/AsbCloudApp/Services/IProcessMapRepository.cs
index 8c9ab6f0..680045c6 100644
--- a/AsbCloudApp/Services/IProcessMapRepository.cs
+++ b/AsbCloudApp/Services/IProcessMapRepository.cs
@@ -1,4 +1,5 @@
using AsbCloudApp.Data.ProcessMap;
+using AsbCloudApp.Requests;
using System;
using System.Collections.Generic;
using System.Threading;
@@ -6,6 +7,7 @@ using System.Threading.Tasks;
namespace AsbCloudApp.Services
{
+#nullable enable
///
///
///
@@ -20,5 +22,14 @@ namespace AsbCloudApp.Services
///
Task> GetAllAsync(int idWell,
DateTime? updateFrom, CancellationToken token = default);
+
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ Task?> GetByRequesProcessMaplAsync(WellCompositeRequest request, CancellationToken token);
}
+#nullable disable
}
\ No newline at end of file
diff --git a/AsbCloudApp/Services/IProcessMapService.cs b/AsbCloudApp/Services/IProcessMapService.cs
index 4a8be8e2..f45f8c36 100644
--- a/AsbCloudApp/Services/IProcessMapService.cs
+++ b/AsbCloudApp/Services/IProcessMapService.cs
@@ -20,14 +20,6 @@ namespace AsbCloudApp.Services
///
///
Task> GetProcessMapAsync(int idWell, CancellationToken token);
-
- ///
- /// Получение РТК по композитной скважине
- ///
- ///
- ///
- ///
- Task> GetCompositeData(int idWell, CancellationToken token);
}
#nullable disable
}
diff --git a/AsbCloudInfrastructure/Repository/ProcessMapRepository.cs b/AsbCloudInfrastructure/Repository/ProcessMapRepository.cs
index f24ce61d..257791bc 100644
--- a/AsbCloudInfrastructure/Repository/ProcessMapRepository.cs
+++ b/AsbCloudInfrastructure/Repository/ProcessMapRepository.cs
@@ -1,5 +1,6 @@
using AsbCloudApp.Data;
using AsbCloudApp.Data.ProcessMap;
+using AsbCloudApp.Requests;
using AsbCloudApp.Services;
using AsbCloudDb.Model;
using Mapster;
@@ -40,6 +41,20 @@ namespace AsbCloudInfrastructure.Repository
return dtos;
}
+ public async Task?> GetByRequesProcessMaplAsync(WellCompositeRequest request, CancellationToken token)
+ {
+ var query = GetQuery().Where(e => e.IdWell == request.IdWell);
+ if (request.IdWellSectionType is not null)
+ {
+ query.Where(e => e.IdWellSectionType == request.IdWellSectionType);
+ }
+
+ var entities = await query
+ .ToListAsync(token);
+ var dtos = entities.Select(Convert).ToList();
+ return dtos;
+ }
+
public override async Task InsertAsync(ProcessMapDto dto,
CancellationToken token)
{
diff --git a/AsbCloudInfrastructure/Repository/WellCompositeRepository.cs b/AsbCloudInfrastructure/Repository/WellCompositeRepository.cs
index de56ee60..a56fa91f 100644
--- a/AsbCloudInfrastructure/Repository/WellCompositeRepository.cs
+++ b/AsbCloudInfrastructure/Repository/WellCompositeRepository.cs
@@ -1,8 +1,12 @@
using AsbCloudApp.Data;
+using AsbCloudApp.Data.ProcessMap;
using AsbCloudApp.Repositories;
+using AsbCloudApp.Requests;
+using AsbCloudApp.Services;
using AsbCloudDb.Model;
using Mapster;
using Microsoft.EntityFrameworkCore;
+using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
@@ -14,10 +18,12 @@ namespace AsbCloudInfrastructure.Repository
public class WellCompositeRepository : IWellCompositeRepository
{
private readonly IAsbCloudDbContext db;
+ private readonly IProcessMapRepository processMapRepository;
- public WellCompositeRepository(IAsbCloudDbContext db)
+ public WellCompositeRepository(IAsbCloudDbContext db, IProcessMapRepository processMapRepository)
{
this.db = db;
+ this.processMapRepository = processMapRepository;
}
///
@@ -44,6 +50,57 @@ namespace AsbCloudInfrastructure.Repository
return db.SaveChangesAsync(token);
}
+ ///
+ public async Task> GetCompositeProcessMap(int idWell, CancellationToken token)
+ {
+ var result = new List();
+
+ var dtos = await GetAsync(idWell, token);
+ foreach (var dto in dtos)
+ {
+ var processMaps = (await processMapRepository.GetByRequesProcessMaplAsync(new WellCompositeRequest
+ {
+ IdWell = dto.IdWellSrc,
+ IdWellSectionType = dto.IdWellSectionType
+ }
+ , token))?
+ .Where(x => x.IdWellSectionType == dto.IdWellSectionType)
+ .Select(x => new ProcessMapDto
+ {
+ IdWell = dto.IdWell,
+ IdWellSectionType = dto.IdWellSectionType,
+ RopPlan = x.RopPlan,
+ DepthStart = x.DepthStart,
+ DepthEnd = x.DepthEnd,
+ AxialLoad = new PlanFactDto
+ {
+ Plan = x.AxialLoad.Fact ?? 0
+ },
+ Flow = new PlanFactDto
+ {
+ Plan = x.Flow.Fact ?? x.Flow.Plan
+ },
+ Pressure = new PlanFactDto
+ {
+ Plan = x.Pressure.Fact ?? x.Pressure.Plan
+ },
+ TopDriveSpeed = new PlanFactDto
+ {
+ Plan = x.TopDriveSpeed.Fact ?? x.TopDriveSpeed.Plan
+ },
+ TopDriveTorque = new PlanFactDto
+ {
+ Plan = x.TopDriveTorque.Fact ?? x.TopDriveTorque.Plan
+ },
+ LastUpdate = DateTime.UtcNow
+ });
+
+ if (processMaps is not null)
+ result.AddRange(processMaps);
+ }
+ return result;
+ }
+
private static WellComposite Convert(int idWell, WellCompositeDto dto)
{
var entity = dto.Adapt();
diff --git a/AsbCloudInfrastructure/Services/ProcessMap/ProcessMapService.cs b/AsbCloudInfrastructure/Services/ProcessMap/ProcessMapService.cs
index 5269199d..998f61fb 100644
--- a/AsbCloudInfrastructure/Services/ProcessMap/ProcessMapService.cs
+++ b/AsbCloudInfrastructure/Services/ProcessMap/ProcessMapService.cs
@@ -46,6 +46,7 @@ namespace AsbCloudInfrastructure.Services.ProcessMap
this.wellCompositeRepository = wellCompositeRepository;
}
+ ///
public async Task> GetProcessMapAsync(int idWell, CancellationToken token)
{
var well = wellService.GetOrDefault(idWell)
@@ -71,48 +72,6 @@ namespace AsbCloudInfrastructure.Services.ProcessMap
return result;
}
- public async Task> GetCompositeData(int idWell, CancellationToken token)
- {
- var result = new List();
-
- var dtos = await wellCompositeRepository.GetAsync(idWell, token);
- foreach (var dto in dtos)
- {
- var processMaps = (await processMapRepository.GetByIdWellAsync(dto.IdWellSrc, token))!.
- Where(x => x.IdWellSectionType == dto.IdWellSectionType).
- Select(x => new ProcessMapDto {
- IdWell = dto.IdWell,
- IdWellSectionType = dto.IdWellSectionType,
- RopPlan = x.RopPlan,
- DepthStart = x.DepthStart,
- DepthEnd = x.DepthEnd,
- AxialLoad = new PlanFactDto
- {
- Plan = x.AxialLoad.Fact ?? 0
- },
- Flow = new PlanFactDto
- {
- Plan = x.Flow.Fact ?? 0
- },
- Pressure = new PlanFactDto
- {
- Plan = x.Pressure.Fact ?? 0
- },
- TopDriveSpeed = new PlanFactDto
- {
- Plan = x.TopDriveSpeed.Fact ?? 0
- },
- TopDriveTorque = new PlanFactDto
- {
- Plan = x.TopDriveTorque.Fact ?? 0
- },
- LastUpdate = DateTime.UtcNow
- });
- result.AddRange(processMaps);
- }
- return result;
- }
-
private Task?> GetOperationTimeAsync(int idWell, CancellationToken token)
{
var request = new SubsystemOperationTimeRequest
diff --git a/AsbCloudWebApi/Controllers/WellCompositeController.cs b/AsbCloudWebApi/Controllers/WellCompositeController.cs
index dbdd12a7..66a0d65b 100644
--- a/AsbCloudWebApi/Controllers/WellCompositeController.cs
+++ b/AsbCloudWebApi/Controllers/WellCompositeController.cs
@@ -21,15 +21,12 @@ namespace AsbCloudWebApi.Controllers
{
private readonly IWellCompositeRepository wellCompositeRepository;
private readonly IWellService wellService;
- private readonly IProcessMapService processMapService;
public WellCompositeController(IWellCompositeRepository wellCompositeRepository,
- IWellService wellService,
- IProcessMapService processMapService)
+ IWellService wellService)
{
this.wellCompositeRepository = wellCompositeRepository;
this.wellService = wellService;
- this.processMapService = processMapService;
}
///
@@ -68,12 +65,21 @@ namespace AsbCloudWebApi.Controllers
return Ok(result);
}
- [HttpGet("getCompositeData")]
+ ///
+ /// Получение РТК по композитной скважине
+ ///
+ ///
+ ///
+ ///
+ [HttpGet("getCompositeProcessMap")]
[Permission]
[ProducesResponseType(typeof(IEnumerable), (int)System.Net.HttpStatusCode.OK)]
- public async Task GetCompositeData(int idWell, CancellationToken token = default)
+ public async Task GetCompositeProcessMap(int idWell, CancellationToken token = default)
{
- var result = await processMapService.GetCompositeData(idWell, token).ConfigureAwait(false);
+ if (!await CanUserAccessToWellAsync(idWell, token).ConfigureAwait(false))
+ return Forbid();
+
+ var result = await wellCompositeRepository.GetCompositeProcessMap(idWell, token).ConfigureAwait(false);
return Ok(result);
}