forked from ddrilling/AsbCloudServer
#8103063 fix
This commit is contained in:
parent
ccbc499754
commit
ecdade0913
@ -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
|
||||
/// <param name="token"></param>
|
||||
/// <returns></returns>
|
||||
Task<int> SaveAsync(int idWell, IEnumerable<WellCompositeDto> wellComposites, CancellationToken token);
|
||||
|
||||
/// <summary>
|
||||
/// Получение РТК по композитной скважине
|
||||
/// </summary>
|
||||
/// <param name="idWell"></param>
|
||||
/// <param name="token"></param>
|
||||
/// <returns></returns>
|
||||
Task<IEnumerable<ProcessMapDto>> GetCompositeProcessMap(int idWell, CancellationToken token);
|
||||
}
|
||||
#nullable disable
|
||||
}
|
||||
|
20
AsbCloudApp/Requests/WellCompositeRequest.cs
Normal file
20
AsbCloudApp/Requests/WellCompositeRequest.cs
Normal file
@ -0,0 +1,20 @@
|
||||
namespace AsbCloudApp.Requests
|
||||
{
|
||||
#nullable enable
|
||||
/// <summary>
|
||||
/// Параметры для запроса получения РТК
|
||||
/// </summary>
|
||||
public class WellCompositeRequest
|
||||
{
|
||||
/// <summary>
|
||||
/// Идентификатор скважины
|
||||
/// </summary>
|
||||
public int IdWell { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Тип секции
|
||||
/// </summary>
|
||||
public int? IdWellSectionType { get; set; }
|
||||
}
|
||||
#nullable disable
|
||||
}
|
@ -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
|
||||
/// <summary>
|
||||
/// ÐÒÊ
|
||||
/// </summary>
|
||||
@ -20,5 +22,14 @@ namespace AsbCloudApp.Services
|
||||
/// <returns></returns>
|
||||
Task<IEnumerable<ProcessMapDto>> GetAllAsync(int idWell,
|
||||
DateTime? updateFrom, CancellationToken token = default);
|
||||
|
||||
/// <summary>
|
||||
/// Ïîëó÷èòü ïàðàìåòðû áóðåíèÿ
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <param name="token"></param>
|
||||
/// <returns></returns>
|
||||
Task<IEnumerable<ProcessMapDto>?> GetByRequesProcessMaplAsync(WellCompositeRequest request, CancellationToken token);
|
||||
}
|
||||
#nullable disable
|
||||
}
|
@ -20,14 +20,6 @@ namespace AsbCloudApp.Services
|
||||
/// <param name="token"></param>
|
||||
/// <returns></returns>
|
||||
Task<IEnumerable<ProcessMapReportDto>> GetProcessMapAsync(int idWell, CancellationToken token);
|
||||
|
||||
/// <summary>
|
||||
/// Получение РТК по композитной скважине
|
||||
/// </summary>
|
||||
/// <param name="dtos"></param>
|
||||
/// <param name="token"></param>
|
||||
/// <returns></returns>
|
||||
Task<IEnumerable<ProcessMapDto>> GetCompositeData(int idWell, CancellationToken token);
|
||||
}
|
||||
#nullable disable
|
||||
}
|
||||
|
@ -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<IEnumerable<ProcessMapDto>?> 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<int> InsertAsync(ProcessMapDto dto,
|
||||
CancellationToken token)
|
||||
{
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
@ -44,6 +50,57 @@ namespace AsbCloudInfrastructure.Repository
|
||||
return db.SaveChangesAsync(token);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public async Task<IEnumerable<ProcessMapDto>> GetCompositeProcessMap(int idWell, CancellationToken token)
|
||||
{
|
||||
var result = new List<ProcessMapDto>();
|
||||
|
||||
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<WellComposite>();
|
||||
|
@ -46,6 +46,7 @@ namespace AsbCloudInfrastructure.Services.ProcessMap
|
||||
this.wellCompositeRepository = wellCompositeRepository;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public async Task<IEnumerable<ProcessMapReportDto>> GetProcessMapAsync(int idWell, CancellationToken token)
|
||||
{
|
||||
var well = wellService.GetOrDefault(idWell)
|
||||
@ -71,48 +72,6 @@ namespace AsbCloudInfrastructure.Services.ProcessMap
|
||||
return result;
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<ProcessMapDto>> GetCompositeData(int idWell, CancellationToken token)
|
||||
{
|
||||
var result = new List<ProcessMapDto>();
|
||||
|
||||
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<IEnumerable<SubsystemOperationTimeDto>?> GetOperationTimeAsync(int idWell, CancellationToken token)
|
||||
{
|
||||
var request = new SubsystemOperationTimeRequest
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -68,12 +65,21 @@ namespace AsbCloudWebApi.Controllers
|
||||
return Ok(result);
|
||||
}
|
||||
|
||||
[HttpGet("getCompositeData")]
|
||||
/// <summary>
|
||||
/// Получение РТК по композитной скважине
|
||||
/// </summary>
|
||||
/// <param name="idWell"></param>
|
||||
/// <param name="token"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("getCompositeProcessMap")]
|
||||
[Permission]
|
||||
[ProducesResponseType(typeof(IEnumerable<ProcessMapDto>), (int)System.Net.HttpStatusCode.OK)]
|
||||
public async Task<IActionResult> GetCompositeData(int idWell, CancellationToken token = default)
|
||||
public async Task<IActionResult> 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);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user