forked from ddrilling/AsbCloudServer
#8636739 Визуализация траектории 3D
This commit is contained in:
parent
d47fa1b09c
commit
7127dfd9bb
@ -1,41 +0,0 @@
|
||||
namespace AsbCloudDb.Model
|
||||
{
|
||||
#nullable enable
|
||||
/// <summary>
|
||||
/// Данные для визуализации траектории
|
||||
/// </summary>
|
||||
public class TrajectoryVisualizationDataDto
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Глубина по стволу
|
||||
/// </summary>
|
||||
public double WellboreDepth { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Зенит
|
||||
/// </summary>
|
||||
public double Zenith { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Азимут
|
||||
/// </summary>
|
||||
public double Azimuth { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Координаты по оси X
|
||||
/// </summary>
|
||||
public double X { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Координаты по оси Y
|
||||
/// </summary>
|
||||
public double Y { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Координаты по оси Z
|
||||
/// </summary>
|
||||
public double Z { get; set; }
|
||||
}
|
||||
#nullable disable
|
||||
}
|
@ -3,18 +3,8 @@
|
||||
/// <summary>
|
||||
/// Визуализация траектории 3D
|
||||
/// </summary>
|
||||
public class TrajectoryVisualizationDto : IWellRelated
|
||||
{
|
||||
|
||||
/// <inheritdoc/>
|
||||
public int IdWell { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Плоскость
|
||||
/// </summary>
|
||||
public double Flat { get; set; }
|
||||
|
||||
/// <summary>
|
||||
public class TrajectoryVisualizationDto
|
||||
{/// <summary>
|
||||
/// Координаты по оси X
|
||||
/// </summary>
|
||||
public double X { get; set; }
|
||||
|
@ -3,14 +3,14 @@ using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AsbCloudApp.Services
|
||||
namespace AsbCloudApp.Repositories
|
||||
{
|
||||
#nullable enable
|
||||
/// <summary>
|
||||
/// CRUD для работы с плановой траекторией из клиента
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public interface IPlannedTrajectoryService
|
||||
public interface IPlannedTrajectoryRepository
|
||||
{
|
||||
/// <summary>
|
||||
/// Получить все добавленные по скважине координаты плановой траектории
|
@ -1,23 +0,0 @@
|
||||
using AsbCloudDb.Model;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AsbCloudApp.Repositories
|
||||
{
|
||||
#nullable enable
|
||||
/// <summary>
|
||||
/// Визуализация траектории 3D
|
||||
/// </summary>
|
||||
public interface ITrajectoryVisualizationRepository
|
||||
{
|
||||
/// <summary>
|
||||
/// Получение данных для расчета
|
||||
/// </summary>
|
||||
/// <param name="idWell"></param>
|
||||
/// <param name="token"></param>
|
||||
/// <returns></returns>
|
||||
Task<IEnumerable<TrajectoryVisualizationDataDto>> GetAllAsync(int idWell, CancellationToken token);
|
||||
}
|
||||
#nullable disable
|
||||
}
|
@ -126,7 +126,6 @@ namespace AsbCloudInfrastructure
|
||||
services.AddTransient<IWellService, WellService>();
|
||||
services.AddTransient<IWellOperationImportService, WellOperationImportService>();
|
||||
services.AddTransient<IPlannedTrajectoryImportService, PlannedTrajectoryImportService>();
|
||||
services.AddTransient<IPlannedTrajectoryService, PlannedTrajectoryService>();
|
||||
services.AddTransient<IWellOperationRepository, WellOperationRepository>();
|
||||
services.AddTransient<IScheduleReportService, ScheduleReportService>();
|
||||
services.AddTransient<IDailyReportService, DailyReportService>();
|
||||
@ -178,7 +177,7 @@ namespace AsbCloudInfrastructure
|
||||
services.AddTransient<ILimitingParameterRepository, LimitingParameterRepository>();
|
||||
services.AddTransient<ITelemetryWirelineRunOutRepository, TelemetryWirelineRunOutRepository>();
|
||||
services.AddTransient<IWellFinalDocumentsRepository, WellFinalDocumentsRepository>();
|
||||
services.AddTransient<ITrajectoryVisualizationRepository, TrajectoryVisualizationRepository>();
|
||||
services.AddTransient<IPlannedTrajectoryRepository, PlannedTrajectoryRepository>();
|
||||
|
||||
// Subsystem service
|
||||
services.AddTransient<ICrudRepository<SubsystemDto>, CrudCacheRepositoryBase<SubsystemDto, Subsystem>>();
|
||||
|
@ -1,5 +1,6 @@
|
||||
using AsbCloudApp.Data;
|
||||
using AsbCloudApp.Exceptions;
|
||||
using AsbCloudApp.Repositories;
|
||||
using AsbCloudApp.Services;
|
||||
using AsbCloudDb.Model;
|
||||
using Mapster;
|
||||
@ -10,31 +11,33 @@ using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AsbCloudInfrastructure.Services.PlannedTrajectory
|
||||
namespace AsbCloudInfrastructure.Repository
|
||||
{
|
||||
#nullable enable
|
||||
public class PlannedTrajectoryService : IPlannedTrajectoryService
|
||||
public class PlannedTrajectoryRepository : IPlannedTrajectoryRepository
|
||||
{
|
||||
private readonly IAsbCloudDbContext db;
|
||||
private readonly IWellService wellService;
|
||||
public PlannedTrajectoryService(IAsbCloudDbContext db, IWellService wellService)
|
||||
public PlannedTrajectoryRepository(IAsbCloudDbContext db, IWellService wellService)
|
||||
{
|
||||
this.db = db;
|
||||
this.wellService = wellService;
|
||||
}
|
||||
/// <inheritdoc/>
|
||||
public async Task<int> AddRangeAsync(IEnumerable<PlannedTrajectoryDto> plannedTrajectoryRows, CancellationToken token)
|
||||
{
|
||||
{
|
||||
var idWell = plannedTrajectoryRows.First().IdWell;
|
||||
if (!plannedTrajectoryRows.All(r => r.IdWell == idWell))
|
||||
throw new ArgumentInvalidException("Все строки должны относиться к одной скважине", nameof(plannedTrajectoryRows));
|
||||
var offsetHours = wellService.GetTimezone(idWell).Hours;
|
||||
var entities = plannedTrajectoryRows
|
||||
.Select(e => {
|
||||
.Select(e =>
|
||||
{
|
||||
var entity = Convert(e, offsetHours);
|
||||
entity.Id = 0;
|
||||
return entity;});
|
||||
|
||||
return entity;
|
||||
});
|
||||
|
||||
db.PlannedTrajectories.AddRange(entities);
|
||||
return await db.SaveChangesAsync(token)
|
||||
.ConfigureAwait(false);
|
||||
@ -46,7 +49,7 @@ namespace AsbCloudInfrastructure.Services.PlannedTrajectory
|
||||
var offsetHours = wellService.GetTimezone(plannedTrajectoryRow.IdWell).Hours;
|
||||
var entity = Convert(plannedTrajectoryRow, offsetHours);
|
||||
entity.Id = 0;
|
||||
db.PlannedTrajectories.Add(entity);
|
||||
db.PlannedTrajectories.Add(entity);
|
||||
return await db.SaveChangesAsync(token)
|
||||
.ConfigureAwait(false);
|
||||
}
|
||||
@ -77,13 +80,13 @@ namespace AsbCloudInfrastructure.Services.PlannedTrajectory
|
||||
var well = wellService.GetOrDefault(idWell);
|
||||
if (well is null || well.Timezone is null)
|
||||
throw new ArgumentInvalidException("idWell doesn`t exist", nameof(idWell));
|
||||
var offsetHours = well.Timezone.Hours;
|
||||
var offsetHours = well.Timezone.Hours;
|
||||
var query = db.PlannedTrajectories
|
||||
.AsNoTracking()
|
||||
.Where(x => x.IdWell == idWell);
|
||||
.Where(x => x.IdWell == idWell);
|
||||
var entities = await query
|
||||
.OrderBy(e => e.WellboreDepth)
|
||||
.ToListAsync(token);
|
||||
.ToListAsync(token);
|
||||
var result = entities
|
||||
.Select(r => Convert(r, offsetHours));
|
||||
return result;
|
||||
@ -99,19 +102,19 @@ namespace AsbCloudInfrastructure.Services.PlannedTrajectory
|
||||
.ConfigureAwait(false);
|
||||
}
|
||||
|
||||
private PlannedTrajectoryDto Convert(AsbCloudDb.Model.PlannedTrajectory entity, double offsetHours)
|
||||
{
|
||||
var dto = entity.Adapt<PlannedTrajectoryDto>();
|
||||
private PlannedTrajectoryDto Convert(PlannedTrajectory entity, double offsetHours)
|
||||
{
|
||||
var dto = entity.Adapt<PlannedTrajectoryDto>();
|
||||
dto.UpdateDate = entity.UpdateDate.ToRemoteDateTime(offsetHours);
|
||||
return dto;
|
||||
}
|
||||
|
||||
private AsbCloudDb.Model.PlannedTrajectory Convert(PlannedTrajectoryDto dto, double offsetHours)
|
||||
{
|
||||
var entity = dto.Adapt<AsbCloudDb.Model.PlannedTrajectory>();
|
||||
private PlannedTrajectory Convert(PlannedTrajectoryDto dto, double offsetHours)
|
||||
{
|
||||
var entity = dto.Adapt<PlannedTrajectory>();
|
||||
entity.UpdateDate = DateTime.Now.ToUtcDateTimeOffset(offsetHours);
|
||||
return entity;
|
||||
}
|
||||
}
|
||||
}
|
||||
#nullable disable
|
||||
}
|
@ -1,44 +0,0 @@
|
||||
using AsbCloudApp.Repositories;
|
||||
using AsbCloudDb.Model;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AsbCloudInfrastructure.Repository
|
||||
{
|
||||
#nullable enable
|
||||
public class TrajectoryVisualizationRepository : ITrajectoryVisualizationRepository
|
||||
{
|
||||
private readonly IAsbCloudDbContext context;
|
||||
|
||||
public TrajectoryVisualizationRepository(IAsbCloudDbContext context)
|
||||
{
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public async Task<IEnumerable<TrajectoryVisualizationDataDto>> GetAllAsync(int idWell, CancellationToken token)
|
||||
{
|
||||
var dtos = await context.PlannedTrajectories
|
||||
.Where(t => t.IdWell == idWell)
|
||||
.OrderBy(x => x.UpdateDate)
|
||||
.Select(x => Convert(x))
|
||||
.ToListAsync(token)
|
||||
.ConfigureAwait(false);
|
||||
|
||||
return dtos;
|
||||
}
|
||||
|
||||
private static TrajectoryVisualizationDataDto Convert(PlannedTrajectory dto)
|
||||
{
|
||||
return new TrajectoryVisualizationDataDto {
|
||||
WellboreDepth = dto.WellboreDepth,
|
||||
Azimuth = dto.AzimuthGeo,
|
||||
Zenith = dto.ZenithAngle
|
||||
};
|
||||
}
|
||||
}
|
||||
#nullable disable
|
||||
}
|
@ -1,4 +1,5 @@
|
||||
using AsbCloudApp.Data;
|
||||
using AsbCloudApp.Repositories;
|
||||
using AsbCloudApp.Services;
|
||||
using ClosedXML.Excel;
|
||||
using System;
|
||||
@ -18,7 +19,7 @@ namespace AsbCloudInfrastructure.Services.PlannedTrajectory
|
||||
*/
|
||||
|
||||
private readonly IWellService wellService;
|
||||
private readonly IPlannedTrajectoryService plannedTrajectoryService;
|
||||
private readonly IPlannedTrajectoryRepository plannedTrajectoryService;
|
||||
|
||||
private const string templateFileName = "PlannedTrajectoryTemplate.xlsx";
|
||||
private const string usingTemplateFile = "AsbCloudInfrastructure.Services.PlannedTrajectory";
|
||||
@ -40,7 +41,7 @@ namespace AsbCloudInfrastructure.Services.PlannedTrajectory
|
||||
private const int ColumnOrificeOffset = 14;
|
||||
private const int ColumnComment = 15;
|
||||
|
||||
public PlannedTrajectoryImportService(IWellService wellService, IPlannedTrajectoryService plannedTrajectoryService)
|
||||
public PlannedTrajectoryImportService(IWellService wellService, IPlannedTrajectoryRepository plannedTrajectoryService)
|
||||
{
|
||||
|
||||
this.wellService = wellService;
|
||||
|
@ -11,9 +11,9 @@ namespace AsbCloudInfrastructure.Services
|
||||
{
|
||||
public class TrajectoryVisualizationService : ITrajectoryVisualizationService
|
||||
{
|
||||
private readonly ITrajectoryVisualizationRepository repository;
|
||||
private readonly IPlannedTrajectoryRepository repository;
|
||||
|
||||
public TrajectoryVisualizationService(ITrajectoryVisualizationRepository repository)
|
||||
public TrajectoryVisualizationService(IPlannedTrajectoryRepository repository)
|
||||
{
|
||||
this.repository = repository;
|
||||
}
|
||||
@ -21,22 +21,21 @@ namespace AsbCloudInfrastructure.Services
|
||||
public async Task<IEnumerable<TrajectoryVisualizationDto>> GetTrajectoryAsync(int idWell, CancellationToken token)
|
||||
{
|
||||
var result = new List<TrajectoryVisualizationDto>();
|
||||
var dto = (await repository.GetAllAsync(idWell, token)).ToArray();
|
||||
var dto = (await repository.GetAsync(idWell, token)).ToArray();
|
||||
|
||||
var prevData = dto[0];
|
||||
var prevCoordinates = new TrajectoryVisualizationDto();
|
||||
for (var i = 1; i < dto.Length; i++)
|
||||
{
|
||||
var data = dto[i];
|
||||
var flat = GetFlat(data.WellboreDepth, prevData.WellboreDepth, data.Zenith);
|
||||
var x = data.X = GetX(data.Azimuth, flat, prevData.X);
|
||||
var y = data.Y = GetY(data.Azimuth, flat, prevData.Y);
|
||||
var z = data.Z = GetZ(data.WellboreDepth, prevData.WellboreDepth, data.Zenith, prevData.Z);
|
||||
var flat = GetFlat(data.WellboreDepth, prevData.WellboreDepth, data.ZenithAngle);
|
||||
var x = prevCoordinates.X = GetX(data.AzimuthGeo, flat, prevCoordinates.X);
|
||||
var y = prevCoordinates.Y = GetY(data.AzimuthGeo, flat, prevCoordinates.Y);
|
||||
var z = prevCoordinates.Z = GetZ(data.WellboreDepth, prevData.WellboreDepth, data.ZenithAngle, prevCoordinates.Z);
|
||||
prevData = data;
|
||||
|
||||
var coordinates = new TrajectoryVisualizationDto
|
||||
{
|
||||
IdWell = idWell,
|
||||
Flat = flat,
|
||||
X = x,
|
||||
Y = y,
|
||||
Z = z
|
||||
|
@ -1,4 +1,5 @@
|
||||
using AsbCloudApp.Data;
|
||||
using AsbCloudApp.Repositories;
|
||||
using AsbCloudApp.Services;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
@ -21,13 +22,13 @@ namespace AsbCloudWebApi.Controllers
|
||||
{
|
||||
private readonly IWellService wellService;
|
||||
private readonly IPlannedTrajectoryImportService plannedTrajectoryImportService;
|
||||
private readonly IPlannedTrajectoryService plannedTrajectoryService;
|
||||
private readonly IPlannedTrajectoryRepository plannedTrajectoryRepository;
|
||||
|
||||
public PlannedTrajectoryController(IWellService wellService, IPlannedTrajectoryImportService plannedTrajectoryImportService, IPlannedTrajectoryService plannedTrajectoryService)
|
||||
public PlannedTrajectoryController(IWellService wellService, IPlannedTrajectoryImportService plannedTrajectoryImportService, IPlannedTrajectoryRepository plannedTrajectoryRepository)
|
||||
{
|
||||
this.plannedTrajectoryImportService = plannedTrajectoryImportService;
|
||||
this.wellService = wellService;
|
||||
this.plannedTrajectoryService = plannedTrajectoryService;
|
||||
this.plannedTrajectoryRepository = plannedTrajectoryRepository;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -121,7 +122,7 @@ namespace AsbCloudWebApi.Controllers
|
||||
if (!await CanUserAccessToWellAsync(idWell,
|
||||
token).ConfigureAwait(false))
|
||||
return Forbid();
|
||||
var result = await plannedTrajectoryService.GetAsync(idWell, token);
|
||||
var result = await plannedTrajectoryRepository.GetAsync(idWell, token);
|
||||
return Ok(result);
|
||||
}
|
||||
|
||||
@ -146,7 +147,7 @@ namespace AsbCloudWebApi.Controllers
|
||||
return Forbid();
|
||||
row.IdUser = idUser.Value;
|
||||
row.IdWell = idWell;
|
||||
var result = await plannedTrajectoryService.AddAsync(row, token);
|
||||
var result = await plannedTrajectoryRepository.AddAsync(row, token);
|
||||
return Ok(result);
|
||||
}
|
||||
|
||||
@ -174,7 +175,7 @@ namespace AsbCloudWebApi.Controllers
|
||||
item.IdUser = idUser.Value;
|
||||
item.IdWell = idWell;
|
||||
}
|
||||
var result = await plannedTrajectoryService.AddRangeAsync(rows, token);
|
||||
var result = await plannedTrajectoryRepository.AddRangeAsync(rows, token);
|
||||
return Ok(result);
|
||||
}
|
||||
|
||||
@ -200,7 +201,7 @@ namespace AsbCloudWebApi.Controllers
|
||||
row.Id = idRow;
|
||||
row.IdUser = idUser.Value;
|
||||
row.IdWell = idWell;
|
||||
var result = await plannedTrajectoryService.UpdateAsync(row, token);
|
||||
var result = await plannedTrajectoryRepository.UpdateAsync(row, token);
|
||||
return Ok(result);
|
||||
}
|
||||
|
||||
@ -220,7 +221,7 @@ namespace AsbCloudWebApi.Controllers
|
||||
token).ConfigureAwait(false))
|
||||
return Forbid();
|
||||
|
||||
var result = await plannedTrajectoryService.DeleteRangeAsync(new int[] { idRow }, token);
|
||||
var result = await plannedTrajectoryRepository.DeleteRangeAsync(new int[] { idRow }, token);
|
||||
|
||||
return Ok(result);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user