forked from ddrilling/AsbCloudServer
Отдельные сервисы для плановой и фактической траектории
This commit is contained in:
parent
9530982794
commit
8c45b36623
@ -4,7 +4,17 @@
|
|||||||
/// DTO объединяющее плановые и фактические значения
|
/// DTO объединяющее плановые и фактические значения
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="T"></typeparam>
|
/// <typeparam name="T"></typeparam>
|
||||||
public class PlanFactBase<T>
|
public class PlanFactDto<T> : PlanFactBase<T, T>
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// DTO объединяющее плановые и фактические значения
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T"></typeparam>
|
||||||
|
/// <typeparam name="V"></typeparam>
|
||||||
|
public class PlanFactBase<T, V>
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Плановое значение
|
/// Плановое значение
|
||||||
@ -14,6 +24,6 @@
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Фактическое значение
|
/// Фактическое значение
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public T? Fact { get; set; }
|
public V? Fact { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -3,7 +3,7 @@
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// План-факт статистики по операциям за секцию скважины
|
/// План-факт статистики по операциям за секцию скважины
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class StatSectionDto : PlanFactBase<StatOperationsDto>, IId
|
public class StatSectionDto : PlanFactDto<StatOperationsDto>, IId
|
||||||
{
|
{
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
@ -45,7 +45,7 @@ namespace AsbCloudApp.Data
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// статистика за всю скважину
|
/// статистика за всю скважину
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public PlanFactBase<StatOperationsDto> Total { get; set; } = new();
|
public PlanFactDto<StatOperationsDto> Total { get; set; } = new();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// компании участвующие в строительстве скважины
|
/// компании участвующие в строительстве скважины
|
||||||
|
@ -1,13 +0,0 @@
|
|||||||
namespace AsbCloudApp.Data
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Формирование визуализации траектории 3D
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="WellboreDepth">Глубина ствола</param>
|
|
||||||
/// <param name="ZenithAngle">Зенитный угол</param>
|
|
||||||
/// <param name="AzimuthGeo">Азимут географиеский</param>
|
|
||||||
public record TrajectoryDto(
|
|
||||||
double WellboreDepth,
|
|
||||||
double ZenithAngle,
|
|
||||||
double AzimuthGeo);
|
|
||||||
}
|
|
35
AsbCloudApp/Data/TrajectoryFactDto.cs
Normal file
35
AsbCloudApp/Data/TrajectoryFactDto.cs
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
namespace AsbCloudApp.Data;
|
||||||
|
|
||||||
|
public class TrajectoryDto
|
||||||
|
{
|
||||||
|
public double WellboreDepth { get; set; }
|
||||||
|
public double ZenithAngle { get; set; }
|
||||||
|
public double AzimuthGeo { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Формирование визуализации траектории 3D
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="WellboreDepth">Глубина ствола</param>
|
||||||
|
/// <param name="ZenithAngle">Зенитный угол</param>
|
||||||
|
/// <param name="AzimuthGeo">Азимут географиеский</param>
|
||||||
|
public class TrajectoryFactDto : TrajectoryDto
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="WellboreDepth"></param>
|
||||||
|
/// <param name="ZenithAngle"></param>
|
||||||
|
/// <param name="AzimuthGeo"></param>
|
||||||
|
/// <param name="Radius"></param>
|
||||||
|
/// <param name="Comment"></param>
|
||||||
|
public class TrajectoryPlanDto : TrajectoryDto
|
||||||
|
{
|
||||||
|
public double? Radius { get; set; }
|
||||||
|
public string? Comment { get; set; }
|
||||||
|
}
|
||||||
|
|
@ -3,7 +3,7 @@
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Визуализация траектории 3D
|
/// Визуализация траектории 3D
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class TrajectoryVisualizationDto
|
public class TrajectoryVisualizationFactDto
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Координаты по оси X, в сторону востока (м)
|
/// Координаты по оси X, в сторону востока (м)
|
18
AsbCloudApp/Data/TrajectoryVisualizationPlanDto.cs
Normal file
18
AsbCloudApp/Data/TrajectoryVisualizationPlanDto.cs
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
namespace AsbCloudApp.Data
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Визуализация траектории 3D для посторения радиуса цели
|
||||||
|
/// </summary>
|
||||||
|
public class TrajectoryVisualizationPlanDto : TrajectoryVisualizationFactDto
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// радиус цели
|
||||||
|
/// </summary>
|
||||||
|
public double? Radius { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// комментарий
|
||||||
|
/// </summary>
|
||||||
|
public string? Comment { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -22,7 +22,7 @@ namespace AsbCloudApp.Data
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Плановая и текущая глубина
|
/// Плановая и текущая глубина
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public PlanFactBase<double?> WellDepth { get; set; } = null!;
|
public PlanFactDto<double?> WellDepth { get; set; } = null!;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Отставание от ГГД, %
|
/// Отставание от ГГД, %
|
||||||
@ -32,12 +32,12 @@ namespace AsbCloudApp.Data
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Механическая скорость проходки, последней операции бурения
|
/// Механическая скорость проходки, последней операции бурения
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public PlanFactBase<double?> ROP { get; set; } = null!;
|
public PlanFactDto<double?> ROP { get; set; } = null!;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Рейсовая скорость проходки, последнего рейса
|
/// Рейсовая скорость проходки, последнего рейса
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public PlanFactBase<double?> RaceSpeed { get; set; } = null!;
|
public PlanFactDto<double?> RaceSpeed { get; set; } = null!;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Процент использования АКБ
|
/// Процент использования АКБ
|
||||||
|
@ -12,6 +12,12 @@ namespace AsbCloudApp.Repositories
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public interface IActualTrajectoryRepository : ITrajectoryRepository
|
public interface IActualTrajectoryRepository : ITrajectoryRepository
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Получение траектории для 3D-визуализации
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="idWell">ключ скважины</param>
|
||||||
|
/// <param name="token"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<IEnumerable<TrajectoryFactDto>> GetTrajectoryAsync(int idWell, CancellationToken token);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -59,5 +59,13 @@ namespace AsbCloudApp.Repositories
|
|||||||
/// <param name="token"></param>
|
/// <param name="token"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<int> DeleteByIdWellAsync(int idWell, CancellationToken token);
|
Task<int> DeleteByIdWellAsync(int idWell, CancellationToken token);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Получение траектории для 3D-визуализации
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="idWell">ключ скважины</param>
|
||||||
|
/// <param name="token"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<IEnumerable<TrajectoryPlanDto>> GetTrajectoryAsync(int idWell, CancellationToken token);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,12 +13,6 @@ namespace AsbCloudApp.Repositories
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public interface ITrajectoryRepository
|
public interface ITrajectoryRepository
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// Получение траектории для 3D-визуализации
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="idWell">ключ скважины</param>
|
|
||||||
/// <param name="token"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
Task<IEnumerable<TrajectoryDto>> GetTrajectoryAsync(int idWell, CancellationToken token);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,14 +8,14 @@ namespace AsbCloudApp.Services
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Сервис "Визуализация траектории 3D"
|
/// Сервис "Визуализация траектории 3D"
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface ITrajectoryVisualizationService
|
public interface ITrajectoryVisualizationService<T>
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Получение плановой и фактической траектории по скважине
|
/// Получение плановой или фактической траектории по скважине
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="idWell">ключ скважины</param>
|
/// <param name="idWell">ключ скважины</param>
|
||||||
/// <param name="token"></param>
|
/// <param name="token"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<PlanFactBase<IEnumerable<TrajectoryVisualizationDto>>> GetTrajectoryAsync(int idWell, CancellationToken token);
|
Task<IEnumerable<T>> GetVisualizationAsync(int idWell, CancellationToken token);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -136,7 +136,11 @@ namespace AsbCloudInfrastructure
|
|||||||
services.AddTransient<ILimitingParameterService, LimitingParameterService>();
|
services.AddTransient<ILimitingParameterService, LimitingParameterService>();
|
||||||
services.AddTransient<IProcessMapReportMakerService, ProcessMapReportMakerService>();
|
services.AddTransient<IProcessMapReportMakerService, ProcessMapReportMakerService>();
|
||||||
services.AddTransient<IProcessMapReportService, ProcessMapReportService>();
|
services.AddTransient<IProcessMapReportService, ProcessMapReportService>();
|
||||||
services.AddTransient<ITrajectoryVisualizationService, TrajectoryVisualizationService>();
|
|
||||||
|
services.AddTransient<TrajectoryVisualizationBaseService>();
|
||||||
|
services.AddTransient<ITrajectoryVisualizationService<TrajectoryVisualizationPlanDto>, TrajectoryVisualizationPlanService>();
|
||||||
|
services.AddTransient<ITrajectoryVisualizationService<TrajectoryVisualizationFactDto>, TrajectoryVisualizationFactService>();
|
||||||
|
|
||||||
services.AddTransient<IGtrRepository, GtrWitsRepository>();
|
services.AddTransient<IGtrRepository, GtrWitsRepository>();
|
||||||
|
|
||||||
// admin crud services:
|
// admin crud services:
|
||||||
|
@ -21,7 +21,7 @@ namespace AsbCloudInfrastructure.Repository
|
|||||||
this.wellService = wellService;
|
this.wellService = wellService;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<IEnumerable<TrajectoryDto>> GetTrajectoryAsync(int idWell, CancellationToken token)
|
public async Task<IEnumerable<TrajectoryFactDto>> GetTrajectoryAsync(int idWell, CancellationToken token)
|
||||||
{
|
{
|
||||||
|
|
||||||
var well = wellService.GetOrDefault(idWell);
|
var well = wellService.GetOrDefault(idWell);
|
||||||
@ -37,7 +37,7 @@ namespace AsbCloudInfrastructure.Repository
|
|||||||
.ToArrayAsync(token);
|
.ToArrayAsync(token);
|
||||||
|
|
||||||
var result = entities
|
var result = entities
|
||||||
.Select(coord => new TrajectoryDto(coord.Deptsvym!.Value, coord.Svyinc!.Value, coord.Svyazc!.Value))
|
.Select(coord => new TrajectoryFactDto(coord.Deptsvym!.Value, coord.Svyinc!.Value, coord.Svyazc!.Value))
|
||||||
.ToArray();
|
.ToArray();
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
@ -116,7 +116,7 @@ namespace AsbCloudInfrastructure.Repository
|
|||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<IEnumerable<TrajectoryDto>> GetTrajectoryAsync(int idWell, CancellationToken token)
|
public async Task<IEnumerable<TrajectoryPlanDto>> GetTrajectoryAsync(int idWell, CancellationToken token)
|
||||||
{
|
{
|
||||||
var well = wellService.GetOrDefault(idWell);
|
var well = wellService.GetOrDefault(idWell);
|
||||||
if (well is null || well.Timezone is null)
|
if (well is null || well.Timezone is null)
|
||||||
@ -127,7 +127,7 @@ namespace AsbCloudInfrastructure.Repository
|
|||||||
.Where(x => x.IdWell == idWell);
|
.Where(x => x.IdWell == idWell);
|
||||||
|
|
||||||
return await query
|
return await query
|
||||||
.Select(coord => new TrajectoryDto(coord.WellboreDepth, coord.ZenithAngle, coord.AzimuthGeo))
|
.Select(coord => new TrajectoryPlanDto(coord.WellboreDepth, coord.ZenithAngle, coord.AzimuthGeo, coord.RadiusTarget, coord.Comment))
|
||||||
.ToArrayAsync()
|
.ToArrayAsync()
|
||||||
.ConfigureAwait(false);
|
.ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,53 @@
|
|||||||
|
using AsbCloudApp.Data;
|
||||||
|
using AsbCloudApp.Repositories;
|
||||||
|
using AsbCloudApp.Services;
|
||||||
|
using DocumentFormat.OpenXml.Spreadsheet;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace AsbCloudInfrastructure.Services.Trajectory
|
||||||
|
{
|
||||||
|
public class TrajectoryVisualizationBaseService
|
||||||
|
{
|
||||||
|
private ITrajectoryVisualizationService<TrajectoryVisualizationPlanDto> planTrajectoryVisualizationService;
|
||||||
|
private ITrajectoryVisualizationService<TrajectoryVisualizationFactDto> factTrajectoryVisualizationService;
|
||||||
|
|
||||||
|
public TrajectoryVisualizationBaseService(
|
||||||
|
ITrajectoryVisualizationService<TrajectoryVisualizationPlanDto> _planTrajectoryVisualizationService,
|
||||||
|
ITrajectoryVisualizationService<TrajectoryVisualizationFactDto> _factTrajectoryVisualizationService)
|
||||||
|
{
|
||||||
|
this.planTrajectoryVisualizationService = _planTrajectoryVisualizationService;
|
||||||
|
this.factTrajectoryVisualizationService = _factTrajectoryVisualizationService;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Получение плановой и фактической траектории по скважине
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="idWell">ключ скважины</param>
|
||||||
|
/// <param name="token"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task<PlanFactBase<IEnumerable<TrajectoryVisualizationPlanDto>, IEnumerable<TrajectoryVisualizationFactDto>>> GetTrajectoryAsync(int idWell, CancellationToken token)
|
||||||
|
{
|
||||||
|
var result = new PlanFactBase<IEnumerable<TrajectoryVisualizationPlanDto>, IEnumerable<TrajectoryVisualizationFactDto>>();
|
||||||
|
|
||||||
|
result.Plan = await planTrajectoryVisualizationService.GetVisualizationAsync(idWell, token);
|
||||||
|
result.Fact = await factTrajectoryVisualizationService.GetVisualizationAsync(idWell, token);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected void Calculate(TrajectoryDto prev, TrajectoryDto current) {
|
||||||
|
var intervalGeoParams = prev;
|
||||||
|
var deltaWellLength = current.WellboreDepth - intervalGeoParams.WellboreDepth;
|
||||||
|
var projectionLengthToXYSurface = deltaWellLength * Math.Sin(intervalGeoParams.ZenithAngle* Math.PI / 180);
|
||||||
|
|
||||||
|
var dDepth = deltaWellLength * Math.Cos(intervalGeoParams.ZenithAngle * Math.PI / 180);
|
||||||
|
var dNorth = projectionLengthToXYSurface * Math.Sin(intervalGeoParams.AzimuthGeo * Math.PI / 180);
|
||||||
|
var dEast = projectionLengthToXYSurface * Math.Cos(intervalGeoParams.AzimuthGeo * Math.PI / 180);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -9,48 +9,42 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace AsbCloudInfrastructure.Services.Trajectory
|
namespace AsbCloudInfrastructure.Services.Trajectory
|
||||||
{
|
{
|
||||||
public class TrajectoryVisualizationService : ITrajectoryVisualizationService
|
public class TrajectoryVisualizationFactService : ITrajectoryVisualizationService<TrajectoryVisualizationFactDto>
|
||||||
{
|
{
|
||||||
private readonly IPlannedTrajectoryRepository plannedRepository;
|
private readonly IActualTrajectoryRepository actualRepository;
|
||||||
private readonly IActualTrajectoryRepository factualRepository;
|
|
||||||
|
|
||||||
public TrajectoryVisualizationService(IPlannedTrajectoryRepository plannedRepository, IActualTrajectoryRepository factualRepository)
|
public TrajectoryVisualizationFactService(IActualTrajectoryRepository actualRepository)
|
||||||
{
|
{
|
||||||
this.plannedRepository = plannedRepository;
|
this.actualRepository = actualRepository;
|
||||||
this.factualRepository = factualRepository;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Получение плановой и фактической траектории по скважине
|
/// Визуализация для фактической траектории по скважине
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="idWell">ключ скважины</param>
|
/// <param name="idWell">ключ скважины</param>
|
||||||
/// <param name="token"></param>
|
/// <param name="token"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task<PlanFactBase<IEnumerable<TrajectoryVisualizationDto>>> GetTrajectoryAsync(int idWell, CancellationToken token)
|
public async Task<IEnumerable<TrajectoryVisualizationFactDto>> GetVisualizationAsync(int idWell, CancellationToken token)
|
||||||
{
|
{
|
||||||
var result = new PlanFactBase<IEnumerable<TrajectoryVisualizationDto>>();
|
var geoFactCoordinates = await actualRepository.GetTrajectoryAsync(idWell, token);
|
||||||
|
|
||||||
var geoPlanCoordinates = await plannedRepository.GetTrajectoryAsync(idWell, token);
|
var visualization = GetTrajectoryVisualisation(geoFactCoordinates);
|
||||||
var geoFactCoordinates = await factualRepository.GetTrajectoryAsync(idWell, token);
|
return visualization;
|
||||||
|
|
||||||
result.Plan = GetTrajectoryVisualisation(geoPlanCoordinates);
|
|
||||||
result.Fact = GetTrajectoryVisualisation(geoFactCoordinates);
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
record struct Location(double North, double East, double Depth);
|
record struct Location(double North, double East, double Depth);
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Формирует список координат для визуализации трактории 3D
|
/// Формирует список координат для визуализации трактории 3D
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="geoCoordinates"></param>
|
/// <param name="geoCoordinates"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
private IEnumerable<TrajectoryVisualizationDto> GetTrajectoryVisualisation(IEnumerable<TrajectoryDto> geoCoordinates)
|
private IEnumerable<TrajectoryVisualizationFactDto> GetTrajectoryVisualisation(IEnumerable<TrajectoryFactDto> geoCoordinates)
|
||||||
{
|
{
|
||||||
var geoCoordinatesLength = geoCoordinates.Count();
|
var geoCoordinatesLength = geoCoordinates.Count();
|
||||||
if (geoCoordinatesLength < 2)
|
if (geoCoordinatesLength < 2)
|
||||||
return new TrajectoryVisualizationDto[0];
|
return new TrajectoryVisualizationFactDto[0];
|
||||||
|
|
||||||
var cartesianCoordinates = new Location[geoCoordinatesLength];
|
var cartesianCoordinates = new Location[geoCoordinatesLength];
|
||||||
cartesianCoordinates[0] = new();
|
cartesianCoordinates[0] = new();
|
||||||
@ -75,7 +69,7 @@ namespace AsbCloudInfrastructure.Services.Trajectory
|
|||||||
cartesianCoordinates[i] = coordinates;
|
cartesianCoordinates[i] = coordinates;
|
||||||
}
|
}
|
||||||
|
|
||||||
return cartesianCoordinates.Select(location => new TrajectoryVisualizationDto { X = location.East, Y = - location.Depth, Z = - location.North});
|
return cartesianCoordinates.Select(location => new TrajectoryVisualizationFactDto { X = location.East, Y = - location.Depth, Z = - location.North});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -0,0 +1,84 @@
|
|||||||
|
using AsbCloudApp.Data;
|
||||||
|
using AsbCloudApp.Repositories;
|
||||||
|
using AsbCloudApp.Services;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace AsbCloudInfrastructure.Services.Trajectory
|
||||||
|
{
|
||||||
|
public class TrajectoryVisualizationPlanService : ITrajectoryVisualizationService<TrajectoryVisualizationPlanDto>
|
||||||
|
{
|
||||||
|
private readonly IPlannedTrajectoryRepository plannedRepository;
|
||||||
|
|
||||||
|
public TrajectoryVisualizationPlanService(IPlannedTrajectoryRepository plannedRepository)
|
||||||
|
{
|
||||||
|
this.plannedRepository = plannedRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Визуализация для плановой траектории по скважине
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="idWell">ключ скважины</param>
|
||||||
|
/// <param name="token"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task<IEnumerable<TrajectoryVisualizationPlanDto>> GetVisualizationAsync(int idWell, CancellationToken token)
|
||||||
|
{
|
||||||
|
var coords = await plannedRepository.GetTrajectoryAsync(idWell, token);
|
||||||
|
return GetTrajectoryVisualisation(coords);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Формирует список координат для визуализации трактории 3D
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="geoCoordinates"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
private IEnumerable<TrajectoryVisualizationPlanDto> GetTrajectoryVisualisation(IEnumerable<TrajectoryPlanDto> geoCoordinates)
|
||||||
|
{
|
||||||
|
var geoCoordinatesLength = geoCoordinates.Count();
|
||||||
|
if (geoCoordinatesLength < 2)
|
||||||
|
return new TrajectoryVisualizationPlanDto[0];
|
||||||
|
|
||||||
|
var cartesianCoordinates = new Location[geoCoordinatesLength];
|
||||||
|
cartesianCoordinates[0] = new();
|
||||||
|
|
||||||
|
var geoCoordinatesArray = geoCoordinates.OrderBy(c => c.WellboreDepth).ToArray();
|
||||||
|
for (var i = 1; i < geoCoordinatesLength; i++)
|
||||||
|
{
|
||||||
|
var intervalGeoParams = geoCoordinatesArray[i - 1];
|
||||||
|
var deltaWellLength = geoCoordinatesArray[i].WellboreDepth - intervalGeoParams.WellboreDepth;
|
||||||
|
var projectionLengthToXYSurface = deltaWellLength * Math.Sin(intervalGeoParams.ZenithAngle * Math.PI / 180);
|
||||||
|
|
||||||
|
var dDepth = deltaWellLength * Math.Cos(intervalGeoParams.ZenithAngle * Math.PI / 180);
|
||||||
|
var dNorth = projectionLengthToXYSurface * Math.Sin(intervalGeoParams.AzimuthGeo * Math.PI / 180);
|
||||||
|
var dEast = projectionLengthToXYSurface * Math.Cos(intervalGeoParams.AzimuthGeo * Math.PI / 180);
|
||||||
|
|
||||||
|
var preCoordinates = cartesianCoordinates[i - 1];
|
||||||
|
var coordinates = new Location(
|
||||||
|
preCoordinates.North + dNorth,
|
||||||
|
preCoordinates.East + dEast,
|
||||||
|
preCoordinates.Depth + dDepth,
|
||||||
|
geoCoordinatesArray[i].Radius,
|
||||||
|
geoCoordinatesArray[i].Comment
|
||||||
|
);
|
||||||
|
|
||||||
|
cartesianCoordinates[i] = coordinates;
|
||||||
|
}
|
||||||
|
|
||||||
|
return cartesianCoordinates.Select(location => new TrajectoryVisualizationPlanDto {
|
||||||
|
X = location.East,
|
||||||
|
Y = -location.Depth,
|
||||||
|
Z = -location.North,
|
||||||
|
Comment = location.Comment,
|
||||||
|
Radius = location.Radius
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -237,7 +237,7 @@ namespace AsbCloudInfrastructure.Services.WellOperationService
|
|||||||
return sections;
|
return sections;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static PlanFactBase<StatOperationsDto> GetStatTotal(IEnumerable<WellOperation> operations,
|
private static PlanFactDto<StatOperationsDto> GetStatTotal(IEnumerable<WellOperation> operations,
|
||||||
int idWellState, double timezoneOffsetH)
|
int idWellState, double timezoneOffsetH)
|
||||||
{
|
{
|
||||||
var operationsPlan = operations.Where(o => o.IdType == WellOperation.IdOperationTypePlan);
|
var operationsPlan = operations.Where(o => o.IdType == WellOperation.IdOperationTypePlan);
|
||||||
@ -245,7 +245,7 @@ namespace AsbCloudInfrastructure.Services.WellOperationService
|
|||||||
var factEnd = CalcStat(operationsFact, timezoneOffsetH);
|
var factEnd = CalcStat(operationsFact, timezoneOffsetH);
|
||||||
if (factEnd is not null && idWellState != 2)
|
if (factEnd is not null && idWellState != 2)
|
||||||
factEnd.End = null;
|
factEnd.End = null;
|
||||||
var section = new PlanFactBase<StatOperationsDto>
|
var section = new PlanFactDto<StatOperationsDto>
|
||||||
{
|
{
|
||||||
Plan = CalcStat(operationsPlan, timezoneOffsetH),
|
Plan = CalcStat(operationsPlan, timezoneOffsetH),
|
||||||
Fact = factEnd,
|
Fact = factEnd,
|
||||||
|
@ -1,40 +0,0 @@
|
|||||||
using AsbCloudApp.Data.SAUB;
|
|
||||||
using AsbCloudApp.Services;
|
|
||||||
using AsbCloudDb.Model;
|
|
||||||
using AsbCloudInfrastructure.Services.SAUB;
|
|
||||||
using Moq;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Xunit;
|
|
||||||
|
|
||||||
namespace AsbCloudWebApi.Tests.ServicesTests;
|
|
||||||
|
|
||||||
public class EventServiceTest
|
|
||||||
{
|
|
||||||
private readonly AsbCloudDbContext context;
|
|
||||||
private readonly EventService service;
|
|
||||||
|
|
||||||
public EventServiceTest()
|
|
||||||
{
|
|
||||||
context = TestHelpter.MakeRealTestContext();
|
|
||||||
var telemetryTracker = new Mock<ITelemetryTracker>();
|
|
||||||
var imezoneServiceMock = new Mock<ITimezoneService>();
|
|
||||||
var telemetryService = new TelemetryService(context, TestHelpter.MemoryCache, telemetryTracker.Object, imezoneServiceMock.Object);
|
|
||||||
service = new EventService(context, TestHelpter.MemoryCache, telemetryService);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public async Task Upsert_telemetry_events()
|
|
||||||
{
|
|
||||||
var dtos = new List<EventDto>
|
|
||||||
{
|
|
||||||
new EventDto {Id = 1, IdCategory = 1, Message = "Test message 1"},
|
|
||||||
new EventDto {Id = 2, IdCategory = 1, Message = "Test message 2"}
|
|
||||||
};
|
|
||||||
|
|
||||||
await service.UpsertAsync("uid", dtos);
|
|
||||||
|
|
||||||
Assert.Equal(2, context.TelemetryEvents.Count());
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,87 +0,0 @@
|
|||||||
using AsbCloudApp.Data;
|
|
||||||
using AsbCloudApp.Data.SAUB;
|
|
||||||
using AsbCloudApp.Services;
|
|
||||||
using AsbCloudDb.Model;
|
|
||||||
using AsbCloudInfrastructure.Services.SAUB;
|
|
||||||
using Moq;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Threading;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Xunit;
|
|
||||||
|
|
||||||
namespace AsbCloudWebApi.Tests.ServicesTests
|
|
||||||
{
|
|
||||||
public class TelemetryDataSaubServiceTest
|
|
||||||
{
|
|
||||||
private readonly Mock<ITelemetryTracker> telemetryTracker;
|
|
||||||
private readonly Mock<ITimezoneService> timezoneService;
|
|
||||||
private readonly SimpleTimezoneDto timezone;
|
|
||||||
private readonly AsbCloudDbContext context;
|
|
||||||
private readonly TelemetryService telemetryService;
|
|
||||||
private readonly TelemetryUserService telemetryUserService;
|
|
||||||
private readonly TelemetryDataCache<TelemetryDataSaubDto> telemetryDataSaubCache;
|
|
||||||
private readonly DateTime drillingStartDate;
|
|
||||||
private readonly string uuid;
|
|
||||||
public TelemetryDataSaubServiceTest()
|
|
||||||
{
|
|
||||||
timezone = new() { Hours = 7 };
|
|
||||||
drillingStartDate = new DateTime(2022, 1, 1, 0, 0, 0, DateTimeKind.Unspecified);
|
|
||||||
uuid = drillingStartDate.ToString("yyyyMMdd_HHmmssfff");
|
|
||||||
|
|
||||||
AsbCloudInfrastructure.DependencyInjection.MapsterSetup();
|
|
||||||
|
|
||||||
telemetryTracker = new Mock<ITelemetryTracker>();
|
|
||||||
timezoneService = new Mock<ITimezoneService>();
|
|
||||||
timezoneService.Setup(s => s.GetOrDefaultByCoordinatesAsync(It.IsAny<double>(), It.IsAny<double>(), It.IsAny<CancellationToken>()))
|
|
||||||
.Returns(Task.FromResult(timezone));
|
|
||||||
timezoneService.Setup(s => s.GetOrDefaultByCoordinates(It.IsAny<double>(), It.IsAny<double>()))
|
|
||||||
.Returns(timezone);
|
|
||||||
|
|
||||||
context = TestHelpter.MakeRealTestContext();
|
|
||||||
telemetryService = new TelemetryService(context, TestHelpter.MemoryCache, telemetryTracker.Object, timezoneService.Object);
|
|
||||||
telemetryUserService = new TelemetryUserService(context, telemetryService, TestHelpter.MemoryCache);
|
|
||||||
telemetryDataSaubCache = TelemetryDataCache<TelemetryDataSaubDto>.GetInstance<TelemetryDataSaub>(context, out Task _);
|
|
||||||
var info = new TelemetryInfoDto
|
|
||||||
{
|
|
||||||
TimeZoneOffsetTotalHours = timezone.Hours,
|
|
||||||
DrillingStartDate = drillingStartDate,
|
|
||||||
};
|
|
||||||
telemetryService.UpdateInfoAsync(uuid, info, CancellationToken.None).Wait();
|
|
||||||
|
|
||||||
}
|
|
||||||
~TelemetryDataSaubServiceTest()
|
|
||||||
{
|
|
||||||
var ts = context.Telemetries.Where(t => t.RemoteUid == uuid);
|
|
||||||
context.Telemetries.RemoveRange(ts);
|
|
||||||
context.SaveChanges();
|
|
||||||
context?.Dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public async Task UpdateDataAsync()
|
|
||||||
{
|
|
||||||
// Arrange
|
|
||||||
var telemetryDataSaubService = new TelemetryDataSaubService(context, telemetryService, telemetryUserService, telemetryDataSaubCache);
|
|
||||||
|
|
||||||
var now = DateTimeOffset.UtcNow.ToOffset(TimeSpan.FromHours(timezone.Hours)).DateTime;
|
|
||||||
var tuser = "Завулон";
|
|
||||||
var newData = new List<TelemetryDataSaubDto>
|
|
||||||
{
|
|
||||||
new TelemetryDataSaubDto{
|
|
||||||
DateTime = now,
|
|
||||||
AxialLoad = 1,
|
|
||||||
MseState = 1,
|
|
||||||
User = tuser,
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// act
|
|
||||||
var affected = await telemetryDataSaubService.UpdateDataAsync(uuid, newData, CancellationToken.None);
|
|
||||||
|
|
||||||
// assert
|
|
||||||
Assert.Equal(1, affected);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -13,7 +13,7 @@ namespace AsbCloudWebApi.Tests.ServicesTests
|
|||||||
{
|
{
|
||||||
public class TrajectoryVisualizationServiceTest
|
public class TrajectoryVisualizationServiceTest
|
||||||
{
|
{
|
||||||
private Mock<T> MakeTrajectoryRepositoryMock<T>(IEnumerable<TrajectoryDto> dateForGetMethod)
|
private Mock<T> MakeTrajectoryRepositoryMock<T>(IEnumerable<TrajectoryFactDto> dateForGetMethod)
|
||||||
where T : class, ITrajectoryRepository
|
where T : class, ITrajectoryRepository
|
||||||
{
|
{
|
||||||
var mock = new Mock<T>();
|
var mock = new Mock<T>();
|
||||||
@ -27,7 +27,7 @@ namespace AsbCloudWebApi.Tests.ServicesTests
|
|||||||
[Fact]
|
[Fact]
|
||||||
public async Task GetTrajectoryAsync_SameCounts()
|
public async Task GetTrajectoryAsync_SameCounts()
|
||||||
{
|
{
|
||||||
var plannedTrajectory = new TrajectoryDto[]
|
var plannedTrajectory = new TrajectoryFactDto[]
|
||||||
{
|
{
|
||||||
new(0d, 0d, 0d),
|
new(0d, 0d, 0d),
|
||||||
new(0d, 0d, 10d),
|
new(0d, 0d, 10d),
|
||||||
@ -37,7 +37,7 @@ namespace AsbCloudWebApi.Tests.ServicesTests
|
|||||||
new(0d, 0d, 50d),
|
new(0d, 0d, 50d),
|
||||||
};
|
};
|
||||||
|
|
||||||
var actualTrajectory = new TrajectoryDto[]
|
var actualTrajectory = new TrajectoryFactDto[]
|
||||||
{
|
{
|
||||||
new(0, 0, 0),
|
new(0, 0, 0),
|
||||||
new(30,30,10),
|
new(30,30,10),
|
||||||
@ -55,7 +55,7 @@ namespace AsbCloudWebApi.Tests.ServicesTests
|
|||||||
[Fact]
|
[Fact]
|
||||||
public async Task GetTrajectoryAsync_StraigthBore()
|
public async Task GetTrajectoryAsync_StraigthBore()
|
||||||
{
|
{
|
||||||
var trajectory = new TrajectoryDto[]
|
var trajectory = new TrajectoryFactDto[]
|
||||||
{
|
{
|
||||||
new(0, 0, 0),
|
new(0, 0, 0),
|
||||||
new(0, 0, 0),
|
new(0, 0, 0),
|
||||||
@ -84,7 +84,7 @@ namespace AsbCloudWebApi.Tests.ServicesTests
|
|||||||
[Fact]
|
[Fact]
|
||||||
public async Task GetTrajectoryAsync_Match()
|
public async Task GetTrajectoryAsync_Match()
|
||||||
{
|
{
|
||||||
var trajectory = new TrajectoryDto[]
|
var trajectory = new TrajectoryFactDto[]
|
||||||
{
|
{
|
||||||
new(0, 0, 0),
|
new(0, 0, 0),
|
||||||
new(10, 30, 30),
|
new(10, 30, 30),
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
using AsbCloudApp.Data;
|
using AsbCloudApp.Data;
|
||||||
using AsbCloudApp.Repositories;
|
using AsbCloudApp.Repositories;
|
||||||
using AsbCloudApp.Services;
|
using AsbCloudApp.Services;
|
||||||
|
using AsbCloudInfrastructure.Services.Trajectory;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
@ -23,12 +24,12 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
private readonly IWellService wellService;
|
private readonly IWellService wellService;
|
||||||
private readonly IPlannedTrajectoryImportService plannedTrajectoryImportService;
|
private readonly IPlannedTrajectoryImportService plannedTrajectoryImportService;
|
||||||
private readonly IPlannedTrajectoryRepository plannedTrajectoryRepository;
|
private readonly IPlannedTrajectoryRepository plannedTrajectoryRepository;
|
||||||
private readonly ITrajectoryVisualizationService trajectoryVisualizationService;
|
private readonly TrajectoryVisualizationBaseService trajectoryVisualizationService;
|
||||||
|
|
||||||
public PlannedTrajectoryController(IWellService wellService,
|
public PlannedTrajectoryController(IWellService wellService,
|
||||||
IPlannedTrajectoryImportService plannedTrajectoryImportService,
|
IPlannedTrajectoryImportService plannedTrajectoryImportService,
|
||||||
IPlannedTrajectoryRepository plannedTrajectoryRepository,
|
IPlannedTrajectoryRepository plannedTrajectoryRepository,
|
||||||
ITrajectoryVisualizationService trajectoryVisualizationService)
|
TrajectoryVisualizationBaseService trajectoryVisualizationService)
|
||||||
{
|
{
|
||||||
this.plannedTrajectoryImportService = plannedTrajectoryImportService;
|
this.plannedTrajectoryImportService = plannedTrajectoryImportService;
|
||||||
this.wellService = wellService;
|
this.wellService = wellService;
|
||||||
@ -231,7 +232,7 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
/// <param name="token"></param>
|
/// <param name="token"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[ProducesResponseType(typeof(PlanFactBase<IEnumerable<TrajectoryVisualizationDto>>), (int)System.Net.HttpStatusCode.OK)]
|
[ProducesResponseType(typeof(PlanFactBase<IEnumerable<TrajectoryVisualizationPlanDto>, IEnumerable<TrajectoryVisualizationFactDto>>), (int)System.Net.HttpStatusCode.OK)]
|
||||||
public async Task<IActionResult> GetPlanFactTrajectoryAsync(int idWell, CancellationToken token)
|
public async Task<IActionResult> GetPlanFactTrajectoryAsync(int idWell, CancellationToken token)
|
||||||
{
|
{
|
||||||
if (!await CanUserAccessToWellAsync(idWell,
|
if (!await CanUserAccessToWellAsync(idWell,
|
||||||
|
@ -39,47 +39,4 @@ namespace ConsoleApp1
|
|||||||
public IConfigurationSection GetSection(string key) => this;
|
public IConfigurationSection GetSection(string key) => this;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static class ServiceFactory
|
|
||||||
{
|
|
||||||
|
|
||||||
private static readonly DbContextOptions<AsbCloudDbContext> options = new DbContextOptionsBuilder<AsbCloudDbContext>()
|
|
||||||
.UseNpgsql("Host=localhost;Database=postgres;Username=postgres;Password=q;Persist Security Info=True")
|
|
||||||
.Options;
|
|
||||||
|
|
||||||
static ConfigurationService ConfigurationService { get; } = new ConfigurationService();
|
|
||||||
static TimezoneService TimezoneService { get; } = new TimezoneService();
|
|
||||||
public static AsbCloudDbContext Context { get; } = MakeContext();
|
|
||||||
public static AsbCloudDbContext MakeContext()
|
|
||||||
=> MakeContext(options);
|
|
||||||
|
|
||||||
public static IMemoryCache MemoryCache = new MemoryCache(new MemoryCacheOptions());
|
|
||||||
|
|
||||||
public static AsbCloudDbContext MakeContext(DbContextOptions<AsbCloudDbContext> options)
|
|
||||||
=> new (options);
|
|
||||||
|
|
||||||
public static AsbCloudDbContext MakeContext(string cusomConnectionString)
|
|
||||||
=> MakeContext(new DbContextOptionsBuilder<AsbCloudDbContext>().UseNpgsql(cusomConnectionString).Options);
|
|
||||||
|
|
||||||
public static void MapsterSetup()
|
|
||||||
=> AsbCloudInfrastructure.DependencyInjection.MapsterSetup();
|
|
||||||
|
|
||||||
public static TelemetryTracker MakeTelemetryTracker()
|
|
||||||
=> new (ConfigurationService, MemoryCache);
|
|
||||||
|
|
||||||
public static TelemetryService MakeTelemetryService()
|
|
||||||
=> new (Context, MemoryCache, MakeTelemetryTracker(), TimezoneService);
|
|
||||||
|
|
||||||
public static WellService MakeWellService()
|
|
||||||
=> new (Context, MemoryCache, MakeTelemetryService(), TimezoneService);
|
|
||||||
|
|
||||||
public static WellOperationRepository MakeWellOperationRepository()
|
|
||||||
=> new (Context, MemoryCache, MakeWellService());
|
|
||||||
|
|
||||||
public static OperationsStatService MakeOperationsStatService()
|
|
||||||
=> new (Context, MemoryCache, MakeWellService());
|
|
||||||
|
|
||||||
public static ScheduleReportService MakeScheduleReportService()
|
|
||||||
=> new(MakeOperationsStatService(), MakeWellService());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user