forked from ddrilling/AsbCloudServer
Merge branch 'dev' into feature/deny-category-choose
This commit is contained in:
commit
5bb3d440b6
@ -1,19 +0,0 @@
|
|||||||
namespace AsbCloudApp.Data
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// DTO объединяющее плановые и фактические значения
|
|
||||||
/// </summary>
|
|
||||||
/// <typeparam name="T"></typeparam>
|
|
||||||
public class PlanFactBase<T>
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Плановое значение
|
|
||||||
/// </summary>
|
|
||||||
public T? Plan { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Фактическое значение
|
|
||||||
/// </summary>
|
|
||||||
public T? Fact { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,18 +1,29 @@
|
|||||||
namespace AsbCloudApp.Data
|
namespace AsbCloudApp.Data
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Плановое и фактическое значения
|
/// DTO объединяющее плановые и фактические значения
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class PlanFactDto
|
/// <typeparam name="T"></typeparam>
|
||||||
|
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>
|
||||||
/// План
|
/// Плановое значение
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public double Plan { get; set; }
|
public T? Plan { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Факт
|
/// Фактическое значение
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public double? 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,23 +1,30 @@
|
|||||||
namespace AsbCloudApp.Data
|
namespace AsbCloudApp.Data
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Визуализация траектории 3D
|
/// Визуализация траектории 3D
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class TrajectoryVisualizationDto
|
public class TrajectoryCartesianDto
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Координаты по оси X, в сторону севера (м)
|
/// Координаты по оси X, в сторону востока (м)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public double X { get; set; }
|
public double X { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Координаты по оси Y, в сторону востока (м)
|
/// Координаты по оси Y, в высоту (м)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public double Y { get; set; }
|
public double Y { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Координаты по оси Z, глубина (м)
|
/// Координаты по оси Z, в сторону юга (м)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public double Z { get; set; }
|
public double Z { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Визуализация фактической траектории 3D
|
||||||
|
/// </summary>
|
||||||
|
public class TrajectoryCartesianFactDto : TrajectoryCartesianDto { }
|
||||||
}
|
}
|
18
AsbCloudApp/Data/TrajectoryCartesianPlanDto.cs
Normal file
18
AsbCloudApp/Data/TrajectoryCartesianPlanDto.cs
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
namespace AsbCloudApp.Data
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Визуализация траектории 3D для посторения радиуса цели
|
||||||
|
/// </summary>
|
||||||
|
public class TrajectoryCartesianPlanDto : TrajectoryCartesianFactDto
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// радиус цели
|
||||||
|
/// </summary>
|
||||||
|
public double? Radius { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// комментарий
|
||||||
|
/// </summary>
|
||||||
|
public string? Comment { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -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);
|
|
||||||
}
|
|
30
AsbCloudApp/Data/TrajectoryGeoFactDto.cs
Normal file
30
AsbCloudApp/Data/TrajectoryGeoFactDto.cs
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
namespace AsbCloudApp.Data;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Базовая географическая траектория
|
||||||
|
/// </summary>
|
||||||
|
public abstract class TrajectoryGeoDto
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Глубина по стволу
|
||||||
|
/// </summary>
|
||||||
|
public double WellboreDepth { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Угол зенитный
|
||||||
|
/// </summary>
|
||||||
|
public double ZenithAngle { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Азимут Географ.
|
||||||
|
/// </summary>
|
||||||
|
public double AzimuthGeo { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Формирование данных по фактической географической траектории
|
||||||
|
/// </summary>
|
||||||
|
public class TrajectoryGeoFactDto : TrajectoryGeoDto
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -2,9 +2,9 @@
|
|||||||
namespace AsbCloudApp.Data
|
namespace AsbCloudApp.Data
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Формирование данных по плановой траектории
|
/// Формирование данных по плановой географической траектории
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class PlannedTrajectoryDto
|
public class TrajectoryGeoPlanDto: TrajectoryGeoDto
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// ИД строки с координатами
|
/// ИД строки с координатами
|
||||||
@ -15,28 +15,16 @@ namespace AsbCloudApp.Data
|
|||||||
/// ИД скважины
|
/// ИД скважины
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int IdWell { get; set; }
|
public int IdWell { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Дата загрузки
|
/// Дата загрузки
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public DateTime UpdateDate { get; set; }
|
public DateTime UpdateDate { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// ИД пользователя
|
/// ИД пользователя
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int IdUser { get; set; }
|
public int IdUser { get; set; }
|
||||||
/// <summary>
|
|
||||||
/// Глубина по стволу
|
|
||||||
/// </summary>
|
|
||||||
public double WellboreDepth { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Угол зенитный
|
|
||||||
/// </summary>
|
|
||||||
public double ZenithAngle { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Азимут Географ.
|
|
||||||
/// </summary>
|
|
||||||
public double AzimuthGeo { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Азимут Магнитный
|
/// Азимут Магнитный
|
||||||
@ -93,6 +81,11 @@ namespace AsbCloudApp.Data
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public double OrificeOffset { get; set; }
|
public double OrificeOffset { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Радиус цели
|
||||||
|
/// </summary>
|
||||||
|
public double? Radius { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Комментарии
|
/// Комментарии
|
||||||
/// </summary>
|
/// </summary>
|
@ -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>
|
||||||
/// Процент использования АКБ
|
/// Процент использования АКБ
|
||||||
|
@ -10,8 +10,7 @@ namespace AsbCloudApp.Repositories
|
|||||||
/// CRUD для работы с фактической траекторией из клиента
|
/// CRUD для работы с фактической траекторией из клиента
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public interface IActualTrajectoryRepository : ITrajectoryRepository
|
public interface ITrajectoryFactRepository : ITrajectoryRepository<TrajectoryGeoFactDto>
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -9,23 +9,15 @@ namespace AsbCloudApp.Repositories
|
|||||||
/// CRUD для работы с плановой траекторией из клиента
|
/// CRUD для работы с плановой траекторией из клиента
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public interface IPlannedTrajectoryRepository : ITrajectoryRepository
|
public interface ITrajectoryPlanRepository : ITrajectoryRepository<TrajectoryGeoPlanDto>
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// Получить все добавленные по скважине координаты плановой траектории
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="idWell"></param>
|
|
||||||
/// <param name="token"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
Task<IEnumerable<PlannedTrajectoryDto>> GetAsync(int idWell, CancellationToken token);
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Добавить строки с координатами по одной скважине. Если в коллекции координаты для разных скважин получаем exception.
|
/// Добавить строки с координатами по одной скважине. Если в коллекции координаты для разных скважин получаем exception.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="plannedTrajectoryRows"></param>
|
/// <param name="plannedTrajectoryRows"></param>
|
||||||
/// <param name="token"></param>
|
/// <param name="token"></param>
|
||||||
/// <returns>количество записанных строк или exception с описанием</returns>
|
/// <returns>количество записанных строк или exception с описанием</returns>
|
||||||
Task<int> AddRangeAsync(IEnumerable<PlannedTrajectoryDto> plannedTrajectoryRows, CancellationToken token);
|
Task<int> AddRangeAsync(IEnumerable<TrajectoryGeoPlanDto> plannedTrajectoryRows, CancellationToken token);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Добавить одну строку с координатами
|
/// Добавить одну строку с координатами
|
||||||
@ -33,7 +25,7 @@ namespace AsbCloudApp.Repositories
|
|||||||
/// <param name="plannedTrajectoryRow"></param>
|
/// <param name="plannedTrajectoryRow"></param>
|
||||||
/// <param name="token"></param>
|
/// <param name="token"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<int> AddAsync(PlannedTrajectoryDto plannedTrajectoryRow, CancellationToken token);
|
Task<int> AddAsync(TrajectoryGeoPlanDto plannedTrajectoryRow, CancellationToken token);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Обновить строку с координатами
|
/// Обновить строку с координатами
|
||||||
@ -41,7 +33,7 @@ namespace AsbCloudApp.Repositories
|
|||||||
/// <param name="row"></param>
|
/// <param name="row"></param>
|
||||||
/// <param name="token"></param>
|
/// <param name="token"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<int> UpdateAsync(PlannedTrajectoryDto row,
|
Task<int> UpdateAsync(TrajectoryGeoPlanDto row,
|
||||||
CancellationToken token);
|
CancellationToken token);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
@ -11,14 +11,15 @@ namespace AsbCloudApp.Repositories
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Репозиторий по работе с траекторией
|
/// Репозиторий по работе с траекторией
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface ITrajectoryRepository
|
public interface ITrajectoryRepository<T>
|
||||||
|
where T : TrajectoryGeoDto
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Получение траектории для 3D-визуализации
|
/// Получить все добавленные по скважине координаты плановой траектории
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="idWell">ключ скважины</param>
|
/// <param name="idWell"></param>
|
||||||
/// <param name="token"></param>
|
/// <param name="token"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<IEnumerable<TrajectoryDto>> GetTrajectoryAsync(int idWell, CancellationToken token);
|
Task<IEnumerable<T>> GetAsync(int idWell, CancellationToken token);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,21 +0,0 @@
|
|||||||
using AsbCloudApp.Data;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Threading;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AsbCloudApp.Services
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Сервис "Визуализация траектории 3D"
|
|
||||||
/// </summary>
|
|
||||||
public interface ITrajectoryVisualizationService
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Получение плановой и фактической траектории по скважине
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="idWell">ключ скважины</param>
|
|
||||||
/// <param name="token"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
Task<PlanFactBase<IEnumerable<TrajectoryVisualizationDto>>> GetTrajectoryAsync(int idWell, CancellationToken token);
|
|
||||||
}
|
|
||||||
}
|
|
8092
AsbCloudDb/Migrations/20230523065447_Add_RadiusTarget_To_PlannedTrajectory.Designer.cs
generated
Normal file
8092
AsbCloudDb/Migrations/20230523065447_Add_RadiusTarget_To_PlannedTrajectory.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,26 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace AsbCloudDb.Migrations
|
||||||
|
{
|
||||||
|
public partial class Add_RadiusTarget_To_PlannedTrajectory : Migration
|
||||||
|
{
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.AddColumn<double>(
|
||||||
|
name: "radius_target",
|
||||||
|
table: "t_planned_trajectory",
|
||||||
|
type: "double precision",
|
||||||
|
nullable: true,
|
||||||
|
comment: "Радиус цели");
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "radius_target",
|
||||||
|
table: "t_planned_trajectory");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
8092
AsbCloudDb/Migrations/20230530070633_UpdateTable_t_planned_trajectory_Field_RadiusTarget_Rename.Designer.cs
generated
Normal file
8092
AsbCloudDb/Migrations/20230530070633_UpdateTable_t_planned_trajectory_Field_RadiusTarget_Rename.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,25 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace AsbCloudDb.Migrations
|
||||||
|
{
|
||||||
|
public partial class UpdateTable_t_planned_trajectory_Field_RadiusTarget_Rename : Migration
|
||||||
|
{
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.RenameColumn(
|
||||||
|
name: "radius_target",
|
||||||
|
table: "t_planned_trajectory",
|
||||||
|
newName: "radius");
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.RenameColumn(
|
||||||
|
name: "radius",
|
||||||
|
table: "t_planned_trajectory",
|
||||||
|
newName: "radius_target");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -2073,6 +2073,11 @@ namespace AsbCloudDb.Migrations
|
|||||||
.HasColumnName("orifice_offset")
|
.HasColumnName("orifice_offset")
|
||||||
.HasComment("Смещение от устья");
|
.HasComment("Смещение от устья");
|
||||||
|
|
||||||
|
b.Property<double?>("Radius")
|
||||||
|
.HasColumnType("double precision")
|
||||||
|
.HasColumnName("radius")
|
||||||
|
.HasComment("Радиус цели");
|
||||||
|
|
||||||
b.Property<double>("SpatialIntensity")
|
b.Property<double>("SpatialIntensity")
|
||||||
.HasColumnType("double precision")
|
.HasColumnType("double precision")
|
||||||
.HasColumnName("spatial_intensity")
|
.HasColumnName("spatial_intensity")
|
||||||
|
@ -65,6 +65,9 @@ namespace AsbCloudDb.Model
|
|||||||
[Column("comment"), Comment("Комментарии")]
|
[Column("comment"), Comment("Комментарии")]
|
||||||
public string? Comment { get; set; }
|
public string? Comment { get; set; }
|
||||||
|
|
||||||
|
[Column("radius"), Comment("Радиус цели")]
|
||||||
|
public double? Radius { get; set; }
|
||||||
|
|
||||||
[ForeignKey(nameof(IdWell))]
|
[ForeignKey(nameof(IdWell))]
|
||||||
public virtual Well Well { get; set; } = null!;
|
public virtual Well Well { get; set; } = null!;
|
||||||
|
|
||||||
|
@ -136,7 +136,9 @@ 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<TrajectoryService>();
|
||||||
|
|
||||||
services.AddTransient<IGtrRepository, GtrWitsRepository>();
|
services.AddTransient<IGtrRepository, GtrWitsRepository>();
|
||||||
|
|
||||||
// admin crud services:
|
// admin crud services:
|
||||||
@ -175,8 +177,8 @@ namespace AsbCloudInfrastructure
|
|||||||
services.AddTransient<ILimitingParameterRepository, LimitingParameterRepository>();
|
services.AddTransient<ILimitingParameterRepository, LimitingParameterRepository>();
|
||||||
services.AddTransient<ITelemetryWirelineRunOutRepository, TelemetryWirelineRunOutRepository>();
|
services.AddTransient<ITelemetryWirelineRunOutRepository, TelemetryWirelineRunOutRepository>();
|
||||||
services.AddTransient<IWellFinalDocumentsRepository, WellFinalDocumentsRepository>();
|
services.AddTransient<IWellFinalDocumentsRepository, WellFinalDocumentsRepository>();
|
||||||
services.AddTransient<IPlannedTrajectoryRepository, PlannedTrajectoryRepository>();
|
services.AddTransient<ITrajectoryPlanRepository, TrajectoryPlanRepository>();
|
||||||
services.AddTransient<IActualTrajectoryRepository, ActualTrajectoryRepository>();
|
services.AddTransient<ITrajectoryFactRepository, TrajectoryFactRepository>();
|
||||||
services.AddTransient<IFaqRepository, FaqRepository>();
|
services.AddTransient<IFaqRepository, FaqRepository>();
|
||||||
|
|
||||||
// Subsystem service
|
// Subsystem service
|
||||||
|
@ -11,19 +11,18 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace AsbCloudInfrastructure.Repository
|
namespace AsbCloudInfrastructure.Repository
|
||||||
{
|
{
|
||||||
internal class ActualTrajectoryRepository : IActualTrajectoryRepository
|
internal class TrajectoryFactRepository : ITrajectoryFactRepository
|
||||||
{
|
{
|
||||||
private readonly IAsbCloudDbContext db;
|
private readonly IAsbCloudDbContext db;
|
||||||
private readonly IWellService wellService;
|
private readonly IWellService wellService;
|
||||||
public ActualTrajectoryRepository(IAsbCloudDbContext db, IWellService wellService)
|
public TrajectoryFactRepository(IAsbCloudDbContext db, IWellService wellService)
|
||||||
{
|
{
|
||||||
this.db = db;
|
this.db = db;
|
||||||
this.wellService = wellService;
|
this.wellService = wellService;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<IEnumerable<TrajectoryDto>> GetTrajectoryAsync(int idWell, CancellationToken token)
|
public async Task<IEnumerable<TrajectoryGeoFactDto>> GetAsync(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)
|
||||||
throw new ArgumentInvalidException("idWell doesn`t exist", nameof(idWell));
|
throw new ArgumentInvalidException("idWell doesn`t exist", nameof(idWell));
|
||||||
@ -37,7 +36,12 @@ 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 TrajectoryGeoFactDto
|
||||||
|
{
|
||||||
|
WellboreDepth = coord.Deptsvym!.Value,
|
||||||
|
ZenithAngle = coord.Svyinc!.Value,
|
||||||
|
AzimuthGeo = coord.Svyazc!.Value
|
||||||
|
})
|
||||||
.ToArray();
|
.ToArray();
|
||||||
|
|
||||||
return result;
|
return result;
|
@ -14,17 +14,17 @@ using System.Threading.Tasks;
|
|||||||
namespace AsbCloudInfrastructure.Repository
|
namespace AsbCloudInfrastructure.Repository
|
||||||
{
|
{
|
||||||
|
|
||||||
public class PlannedTrajectoryRepository : IPlannedTrajectoryRepository
|
public class TrajectoryPlanRepository : ITrajectoryPlanRepository
|
||||||
{
|
{
|
||||||
private readonly IAsbCloudDbContext db;
|
private readonly IAsbCloudDbContext db;
|
||||||
private readonly IWellService wellService;
|
private readonly IWellService wellService;
|
||||||
public PlannedTrajectoryRepository(IAsbCloudDbContext db, IWellService wellService)
|
public TrajectoryPlanRepository(IAsbCloudDbContext db, IWellService wellService)
|
||||||
{
|
{
|
||||||
this.db = db;
|
this.db = db;
|
||||||
this.wellService = wellService;
|
this.wellService = wellService;
|
||||||
}
|
}
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public async Task<int> AddRangeAsync(IEnumerable<PlannedTrajectoryDto> plannedTrajectoryRows, CancellationToken token)
|
public async Task<int> AddRangeAsync(IEnumerable<TrajectoryGeoPlanDto> plannedTrajectoryRows, CancellationToken token)
|
||||||
{
|
{
|
||||||
var idWell = plannedTrajectoryRows.First().IdWell;
|
var idWell = plannedTrajectoryRows.First().IdWell;
|
||||||
if (!plannedTrajectoryRows.All(r => r.IdWell == idWell))
|
if (!plannedTrajectoryRows.All(r => r.IdWell == idWell))
|
||||||
@ -44,7 +44,7 @@ namespace AsbCloudInfrastructure.Repository
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public async Task<int> AddAsync(PlannedTrajectoryDto plannedTrajectoryRow, CancellationToken token)
|
public async Task<int> AddAsync(TrajectoryGeoPlanDto plannedTrajectoryRow, CancellationToken token)
|
||||||
{
|
{
|
||||||
var offsetHours = wellService.GetTimezone(plannedTrajectoryRow.IdWell).Hours;
|
var offsetHours = wellService.GetTimezone(plannedTrajectoryRow.IdWell).Hours;
|
||||||
var entity = Convert(plannedTrajectoryRow, offsetHours);
|
var entity = Convert(plannedTrajectoryRow, offsetHours);
|
||||||
@ -75,7 +75,7 @@ namespace AsbCloudInfrastructure.Repository
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public async Task<IEnumerable<PlannedTrajectoryDto>> GetAsync(int idWell, CancellationToken token)
|
public async Task<IEnumerable<TrajectoryGeoPlanDto>> GetAsync(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)
|
||||||
@ -93,7 +93,7 @@ namespace AsbCloudInfrastructure.Repository
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public async Task<int> UpdateAsync(PlannedTrajectoryDto row, CancellationToken token)
|
public async Task<int> UpdateAsync(TrajectoryGeoPlanDto row, CancellationToken token)
|
||||||
{
|
{
|
||||||
var offsetHours = wellService.GetTimezone(row.IdWell).Hours;
|
var offsetHours = wellService.GetTimezone(row.IdWell).Hours;
|
||||||
var entity = Convert(row, offsetHours);
|
var entity = Convert(row, offsetHours);
|
||||||
@ -102,35 +102,18 @@ namespace AsbCloudInfrastructure.Repository
|
|||||||
.ConfigureAwait(false);
|
.ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private PlannedTrajectoryDto Convert(PlannedTrajectory entity, double offsetHours)
|
private TrajectoryGeoPlanDto Convert(PlannedTrajectory entity, double offsetHours)
|
||||||
{
|
{
|
||||||
var dto = entity.Adapt<PlannedTrajectoryDto>();
|
var dto = entity.Adapt<TrajectoryGeoPlanDto>();
|
||||||
dto.UpdateDate = entity.UpdateDate.ToRemoteDateTime(offsetHours);
|
dto.UpdateDate = entity.UpdateDate.ToRemoteDateTime(offsetHours);
|
||||||
return dto;
|
return dto;
|
||||||
}
|
}
|
||||||
|
|
||||||
private PlannedTrajectory Convert(PlannedTrajectoryDto dto, double offsetHours)
|
private PlannedTrajectory Convert(TrajectoryGeoPlanDto dto, double offsetHours)
|
||||||
{
|
{
|
||||||
var entity = dto.Adapt<PlannedTrajectory>();
|
var entity = dto.Adapt<PlannedTrajectory>();
|
||||||
entity.UpdateDate = DateTime.Now.ToUtcDateTimeOffset(offsetHours);
|
entity.UpdateDate = DateTime.Now.ToUtcDateTimeOffset(offsetHours);
|
||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<IEnumerable<TrajectoryDto>> GetTrajectoryAsync(int idWell, CancellationToken token)
|
|
||||||
{
|
|
||||||
var well = wellService.GetOrDefault(idWell);
|
|
||||||
if (well is null || well.Timezone is null)
|
|
||||||
throw new ArgumentInvalidException("idWell doesn`t exist", nameof(idWell));
|
|
||||||
|
|
||||||
var query = db.PlannedTrajectories
|
|
||||||
.AsNoTracking()
|
|
||||||
.Where(x => x.IdWell == idWell);
|
|
||||||
|
|
||||||
return await query
|
|
||||||
.Select(coord => new TrajectoryDto(coord.WellboreDepth, coord.ZenithAngle, coord.AzimuthGeo))
|
|
||||||
.ToArrayAsync()
|
|
||||||
.ConfigureAwait(false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -19,7 +19,7 @@ namespace AsbCloudInfrastructure.Services.Trajectory
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
private readonly IWellService wellService;
|
private readonly IWellService wellService;
|
||||||
private readonly IPlannedTrajectoryRepository plannedTrajectoryService;
|
private readonly ITrajectoryPlanRepository plannedTrajectoryService;
|
||||||
|
|
||||||
private const string templateFileName = "PlannedTrajectoryTemplate.xlsx";
|
private const string templateFileName = "PlannedTrajectoryTemplate.xlsx";
|
||||||
private const string usingTemplateFile = "AsbCloudInfrastructure.Services.Trajectory";
|
private const string usingTemplateFile = "AsbCloudInfrastructure.Services.Trajectory";
|
||||||
@ -41,7 +41,7 @@ namespace AsbCloudInfrastructure.Services.Trajectory
|
|||||||
private const int ColumnOrificeOffset = 14;
|
private const int ColumnOrificeOffset = 14;
|
||||||
private const int ColumnComment = 15;
|
private const int ColumnComment = 15;
|
||||||
|
|
||||||
public PlannedTrajectoryImportService(IWellService wellService, IPlannedTrajectoryRepository plannedTrajectoryService)
|
public PlannedTrajectoryImportService(IWellService wellService, ITrajectoryPlanRepository plannedTrajectoryService)
|
||||||
{
|
{
|
||||||
|
|
||||||
this.wellService = wellService;
|
this.wellService = wellService;
|
||||||
@ -69,7 +69,7 @@ namespace AsbCloudInfrastructure.Services.Trajectory
|
|||||||
return MakeExelFileStream(plannedTrajectorys);
|
return MakeExelFileStream(plannedTrajectorys);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Stream MakeExelFileStream(IEnumerable<PlannedTrajectoryDto> plannedTrajectories)
|
private Stream MakeExelFileStream(IEnumerable<TrajectoryGeoPlanDto> plannedTrajectories)
|
||||||
{
|
{
|
||||||
using Stream ecxelTemplateStream = GetTemplateFile();
|
using Stream ecxelTemplateStream = GetTemplateFile();
|
||||||
using var workbook = new XLWorkbook(ecxelTemplateStream, XLEventTracking.Disabled);
|
using var workbook = new XLWorkbook(ecxelTemplateStream, XLEventTracking.Disabled);
|
||||||
@ -80,7 +80,7 @@ namespace AsbCloudInfrastructure.Services.Trajectory
|
|||||||
return memoryStream;
|
return memoryStream;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void AddPlannedTrajecoryToWorkbook(XLWorkbook workbook, IEnumerable<PlannedTrajectoryDto> plannedTrajectories)
|
private static void AddPlannedTrajecoryToWorkbook(XLWorkbook workbook, IEnumerable<TrajectoryGeoPlanDto> plannedTrajectories)
|
||||||
{
|
{
|
||||||
if (plannedTrajectories.Any())
|
if (plannedTrajectories.Any())
|
||||||
{
|
{
|
||||||
@ -91,7 +91,7 @@ namespace AsbCloudInfrastructure.Services.Trajectory
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void AddPlannedTrajecoryToSheet(IXLWorksheet sheet, IEnumerable<PlannedTrajectoryDto> plannedTrajectories)
|
private static void AddPlannedTrajecoryToSheet(IXLWorksheet sheet, IEnumerable<TrajectoryGeoPlanDto> plannedTrajectories)
|
||||||
{
|
{
|
||||||
var rowList = plannedTrajectories.ToList();
|
var rowList = plannedTrajectories.ToList();
|
||||||
for (int i = 0; i < rowList.Count; i++)
|
for (int i = 0; i < rowList.Count; i++)
|
||||||
@ -100,7 +100,7 @@ namespace AsbCloudInfrastructure.Services.Trajectory
|
|||||||
AddCoordinatesToRow(row, rowList[i]);
|
AddCoordinatesToRow(row, rowList[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private static void AddCoordinatesToRow(IXLRow row, PlannedTrajectoryDto trajectory)
|
private static void AddCoordinatesToRow(IXLRow row, TrajectoryGeoPlanDto trajectory)
|
||||||
{
|
{
|
||||||
row.Cell(ColumnWellboreDepth).Value = trajectory.WellboreDepth;
|
row.Cell(ColumnWellboreDepth).Value = trajectory.WellboreDepth;
|
||||||
row.Cell(ColumnZenithAngle).Value = trajectory.ZenithAngle;
|
row.Cell(ColumnZenithAngle).Value = trajectory.ZenithAngle;
|
||||||
@ -133,7 +133,7 @@ namespace AsbCloudInfrastructure.Services.Trajectory
|
|||||||
return rowsCount;
|
return rowsCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<int> SavePlannedTrajectoryAsync(int idWell, IEnumerable<PlannedTrajectoryDto> newRows, bool deletePrevRow, CancellationToken token)
|
private async Task<int> SavePlannedTrajectoryAsync(int idWell, IEnumerable<TrajectoryGeoPlanDto> newRows, bool deletePrevRow, CancellationToken token)
|
||||||
{
|
{
|
||||||
if (deletePrevRow)
|
if (deletePrevRow)
|
||||||
await plannedTrajectoryService.DeleteByIdWellAsync(idWell, token);
|
await plannedTrajectoryService.DeleteByIdWellAsync(idWell, token);
|
||||||
@ -141,13 +141,13 @@ namespace AsbCloudInfrastructure.Services.Trajectory
|
|||||||
return rowsCount;
|
return rowsCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
private IEnumerable<PlannedTrajectoryDto> ParseFileStream(Stream stream)
|
private IEnumerable<TrajectoryGeoPlanDto> ParseFileStream(Stream stream)
|
||||||
{
|
{
|
||||||
using var workbook = new XLWorkbook(stream, XLEventTracking.Disabled);
|
using var workbook = new XLWorkbook(stream, XLEventTracking.Disabled);
|
||||||
return ParseWorkbook(workbook);
|
return ParseWorkbook(workbook);
|
||||||
}
|
}
|
||||||
|
|
||||||
private IEnumerable<PlannedTrajectoryDto> ParseWorkbook(IXLWorkbook workbook)
|
private IEnumerable<TrajectoryGeoPlanDto> ParseWorkbook(IXLWorkbook workbook)
|
||||||
{
|
{
|
||||||
var sheetPlannedTrajectory = workbook.Worksheets.FirstOrDefault(ws => ws.Name == sheetNamePlannedTrajectory);
|
var sheetPlannedTrajectory = workbook.Worksheets.FirstOrDefault(ws => ws.Name == sheetNamePlannedTrajectory);
|
||||||
if (sheetPlannedTrajectory is null)
|
if (sheetPlannedTrajectory is null)
|
||||||
@ -156,7 +156,7 @@ namespace AsbCloudInfrastructure.Services.Trajectory
|
|||||||
return plannedTrajectoryRows;
|
return plannedTrajectoryRows;
|
||||||
}
|
}
|
||||||
|
|
||||||
private IEnumerable<PlannedTrajectoryDto> ParseSheet(IXLWorksheet sheet)
|
private IEnumerable<TrajectoryGeoPlanDto> ParseSheet(IXLWorksheet sheet)
|
||||||
{
|
{
|
||||||
if (sheet.RangeUsed().RangeAddress.LastAddress.ColumnNumber < 15)
|
if (sheet.RangeUsed().RangeAddress.LastAddress.ColumnNumber < 15)
|
||||||
throw new FileFormatException($"Лист {sheet.Name} содержит меньшее количество столбцов.");
|
throw new FileFormatException($"Лист {sheet.Name} содержит меньшее количество столбцов.");
|
||||||
@ -169,7 +169,7 @@ namespace AsbCloudInfrastructure.Services.Trajectory
|
|||||||
if (count <= 0)
|
if (count <= 0)
|
||||||
throw new FileFormatException($"Лист {sheet.Name} некорректного формата либо пустой");
|
throw new FileFormatException($"Лист {sheet.Name} некорректного формата либо пустой");
|
||||||
|
|
||||||
var trajectoryRows = new List<PlannedTrajectoryDto>(count);
|
var trajectoryRows = new List<TrajectoryGeoPlanDto>(count);
|
||||||
var parseErrors = new List<string>();
|
var parseErrors = new List<string>();
|
||||||
for (int i = 0; i < count; i++)
|
for (int i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
@ -187,7 +187,7 @@ namespace AsbCloudInfrastructure.Services.Trajectory
|
|||||||
return trajectoryRows;
|
return trajectoryRows;
|
||||||
}
|
}
|
||||||
|
|
||||||
private PlannedTrajectoryDto ParseRow(IXLRow row)
|
private TrajectoryGeoPlanDto ParseRow(IXLRow row)
|
||||||
{
|
{
|
||||||
var _wellboreDepth = row.Cell(ColumnWellboreDepth).Value;
|
var _wellboreDepth = row.Cell(ColumnWellboreDepth).Value;
|
||||||
var _zenithAngle = row.Cell(ColumnZenithAngle).Value;
|
var _zenithAngle = row.Cell(ColumnZenithAngle).Value;
|
||||||
@ -205,7 +205,7 @@ namespace AsbCloudInfrastructure.Services.Trajectory
|
|||||||
var _orificeOffset = row.Cell(ColumnOrificeOffset).Value;
|
var _orificeOffset = row.Cell(ColumnOrificeOffset).Value;
|
||||||
var _comment = row.Cell(ColumnComment).Value;
|
var _comment = row.Cell(ColumnComment).Value;
|
||||||
|
|
||||||
var trajectoryRow = new PlannedTrajectoryDto();
|
var trajectoryRow = new TrajectoryGeoPlanDto();
|
||||||
|
|
||||||
static double getDoubleValue(object value, string nameParam, IXLRow row)
|
static double getDoubleValue(object value, string nameParam, IXLRow row)
|
||||||
{
|
{
|
||||||
|
145
AsbCloudInfrastructure/Services/Trajectory/TrajectoryService.cs
Normal file
145
AsbCloudInfrastructure/Services/Trajectory/TrajectoryService.cs
Normal file
@ -0,0 +1,145 @@
|
|||||||
|
using AsbCloudApp.Data;
|
||||||
|
using AsbCloudApp.Repositories;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace AsbCloudInfrastructure.Services.Trajectory;
|
||||||
|
|
||||||
|
abstract class TrajectoryBaseService<TGeo, TCartesian>
|
||||||
|
where TGeo : TrajectoryGeoDto
|
||||||
|
where TCartesian : TrajectoryCartesianDto, new()
|
||||||
|
{
|
||||||
|
ITrajectoryRepository<TGeo> repository;
|
||||||
|
|
||||||
|
public TrajectoryBaseService(ITrajectoryRepository<TGeo> repository)
|
||||||
|
{
|
||||||
|
this.repository = repository;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected class Location
|
||||||
|
{
|
||||||
|
public double North { get; set; }
|
||||||
|
public double East { get; set; }
|
||||||
|
public double Depth { get; set; }
|
||||||
|
public TrajectoryGeoDto Trajectory { get; set; } = null!;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<IEnumerable<TCartesian>?> GetAsync(int idWell, CancellationToken token)
|
||||||
|
{
|
||||||
|
var geoCoords = await repository.GetAsync(idWell, token);
|
||||||
|
var locs = GetTrajectoryVisualisation(geoCoords);
|
||||||
|
var dtos = locs.Select(l => Convert(l));
|
||||||
|
return dtos;
|
||||||
|
}
|
||||||
|
|
||||||
|
private IEnumerable<Location> GetTrajectoryVisualisation(IEnumerable<TrajectoryGeoDto> geoCoordinates)
|
||||||
|
{
|
||||||
|
var geoCoordinatesLength = geoCoordinates.Count();
|
||||||
|
if (geoCoordinatesLength < 2)
|
||||||
|
return new Location[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 preCoordinates = cartesianCoordinates[i - 1];
|
||||||
|
var coordinates = Calculate(cartesianCoordinates[i - 1],
|
||||||
|
geoCoordinatesArray[i - 1],
|
||||||
|
geoCoordinatesArray[i]);
|
||||||
|
|
||||||
|
cartesianCoordinates[i] = coordinates;
|
||||||
|
}
|
||||||
|
|
||||||
|
return cartesianCoordinates;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Location Calculate(Location prevlocation, TrajectoryGeoDto prev, TrajectoryGeoDto 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);
|
||||||
|
|
||||||
|
return new()
|
||||||
|
{
|
||||||
|
North = prevlocation.North + dNorth,
|
||||||
|
East = prevlocation.East + dEast,
|
||||||
|
Depth = prevlocation.Depth + dDepth,
|
||||||
|
Trajectory = current,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual TCartesian Convert(Location location)
|
||||||
|
{
|
||||||
|
var result = new TCartesian()
|
||||||
|
{
|
||||||
|
X = location.East,
|
||||||
|
Y = -location.Depth,
|
||||||
|
Z = -location.North,
|
||||||
|
};
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class TrajectoryPlanService: TrajectoryBaseService<TrajectoryGeoPlanDto, TrajectoryCartesianPlanDto>
|
||||||
|
{
|
||||||
|
public TrajectoryPlanService(ITrajectoryPlanRepository repository)
|
||||||
|
:base(repository)
|
||||||
|
{}
|
||||||
|
|
||||||
|
protected override TrajectoryCartesianPlanDto Convert(Location location)
|
||||||
|
{
|
||||||
|
var result = base.Convert(location);
|
||||||
|
if (location.Trajectory is TrajectoryGeoPlanDto trajectoryPlan)
|
||||||
|
{
|
||||||
|
result.Radius = trajectoryPlan.Radius;
|
||||||
|
result.Comment = trajectoryPlan.Comment;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class TrajectoryFactService : TrajectoryBaseService<TrajectoryGeoFactDto, TrajectoryCartesianFactDto>
|
||||||
|
{
|
||||||
|
public TrajectoryFactService(ITrajectoryFactRepository repository)
|
||||||
|
: base(repository)
|
||||||
|
{ }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public class TrajectoryService
|
||||||
|
{
|
||||||
|
private TrajectoryPlanService trajectoryPlanService;
|
||||||
|
private TrajectoryFactService trajectoryFactService;
|
||||||
|
|
||||||
|
public TrajectoryService(ITrajectoryPlanRepository plannedRepository, ITrajectoryFactRepository factRepository)
|
||||||
|
{
|
||||||
|
trajectoryPlanService = new TrajectoryPlanService(plannedRepository);
|
||||||
|
trajectoryFactService = new TrajectoryFactService(factRepository);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Получение плановой и фактической траектории по скважине
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="idWell">ключ скважины</param>
|
||||||
|
/// <param name="token"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task<PlanFactBase<IEnumerable<TrajectoryCartesianPlanDto>, IEnumerable<TrajectoryCartesianFactDto>>> GetTrajectoryCartesianAsync(int idWell, CancellationToken token)
|
||||||
|
{
|
||||||
|
var result = new PlanFactBase<IEnumerable<TrajectoryCartesianPlanDto>, IEnumerable<TrajectoryCartesianFactDto>>();
|
||||||
|
|
||||||
|
result.Plan = await trajectoryPlanService.GetAsync(idWell, token);
|
||||||
|
result.Fact = await trajectoryFactService.GetAsync(idWell, token);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
@ -1,83 +0,0 @@
|
|||||||
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 TrajectoryVisualizationService : ITrajectoryVisualizationService
|
|
||||||
{
|
|
||||||
private readonly IPlannedTrajectoryRepository plannedRepository;
|
|
||||||
private readonly IActualTrajectoryRepository factualRepository;
|
|
||||||
|
|
||||||
public TrajectoryVisualizationService(IPlannedTrajectoryRepository plannedRepository, IActualTrajectoryRepository factualRepository)
|
|
||||||
{
|
|
||||||
this.plannedRepository = plannedRepository;
|
|
||||||
this.factualRepository = factualRepository;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Получение плановой и фактической траектории по скважине
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="idWell">ключ скважины</param>
|
|
||||||
/// <param name="token"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public async Task<PlanFactBase<IEnumerable<TrajectoryVisualizationDto>>> GetTrajectoryAsync(int idWell, CancellationToken token)
|
|
||||||
{
|
|
||||||
var result = new PlanFactBase<IEnumerable<TrajectoryVisualizationDto>>();
|
|
||||||
|
|
||||||
var geoPlanCoordinates = await plannedRepository.GetTrajectoryAsync(idWell, token);
|
|
||||||
var geoFactCoordinates = await factualRepository.GetTrajectoryAsync(idWell, token);
|
|
||||||
|
|
||||||
result.Plan = GetTrajectoryVisualisation(geoPlanCoordinates);
|
|
||||||
result.Fact = GetTrajectoryVisualisation(geoFactCoordinates);
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Формирует список координат для визуализации трактории 3D
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="geoCoordinates"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
private IEnumerable<TrajectoryVisualizationDto> GetTrajectoryVisualisation(IEnumerable<TrajectoryDto> geoCoordinates)
|
|
||||||
{
|
|
||||||
var geoCoordinatesLength = geoCoordinates.Count();
|
|
||||||
if (geoCoordinatesLength < 2)
|
|
||||||
return new TrajectoryVisualizationDto[0];
|
|
||||||
|
|
||||||
var cartesianCoordinates = new TrajectoryVisualizationDto[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 dz = deltaWellLength * Math.Cos(intervalGeoParams.ZenithAngle * Math.PI / 180);
|
|
||||||
var dx = projectionLengthToXYSurface * Math.Sin(intervalGeoParams.AzimuthGeo * Math.PI / 180);
|
|
||||||
var dy = projectionLengthToXYSurface * Math.Cos(intervalGeoParams.AzimuthGeo * Math.PI / 180);
|
|
||||||
|
|
||||||
var preCoordinates = cartesianCoordinates[i - 1];
|
|
||||||
var coordinates = new TrajectoryVisualizationDto
|
|
||||||
{
|
|
||||||
Z = preCoordinates.Z + dz,
|
|
||||||
X = preCoordinates.X + dx,
|
|
||||||
Y = preCoordinates.Y + dy,
|
|
||||||
};
|
|
||||||
|
|
||||||
cartesianCoordinates[i] = coordinates;
|
|
||||||
}
|
|
||||||
|
|
||||||
return cartesianCoordinates;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -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,12 +13,13 @@ namespace AsbCloudWebApi.Tests.ServicesTests
|
|||||||
{
|
{
|
||||||
public class TrajectoryVisualizationServiceTest
|
public class TrajectoryVisualizationServiceTest
|
||||||
{
|
{
|
||||||
private Mock<T> MakeTrajectoryRepositoryMock<T>(IEnumerable<TrajectoryDto> dateForGetMethod)
|
private Mock<T> MakeTrajectoryRepositoryMock<T, V>(IEnumerable<V> dateForGetMethod)
|
||||||
where T : class, ITrajectoryRepository
|
where V : TrajectoryGeoDto
|
||||||
|
where T : class, ITrajectoryRepository<V>
|
||||||
{
|
{
|
||||||
var mock = new Mock<T>();
|
var mock = new Mock<T>();
|
||||||
|
|
||||||
mock.Setup(r => r.GetTrajectoryAsync(It.IsAny<int>(), It.IsAny<CancellationToken>()))
|
mock.Setup(r => r.GetAsync(It.IsAny<int>(), It.IsAny<CancellationToken>()))
|
||||||
.Returns(Task.FromResult(dateForGetMethod));
|
.Returns(Task.FromResult(dateForGetMethod));
|
||||||
|
|
||||||
return mock;
|
return mock;
|
||||||
@ -27,27 +28,27 @@ namespace AsbCloudWebApi.Tests.ServicesTests
|
|||||||
[Fact]
|
[Fact]
|
||||||
public async Task GetTrajectoryAsync_SameCounts()
|
public async Task GetTrajectoryAsync_SameCounts()
|
||||||
{
|
{
|
||||||
var plannedTrajectory = new TrajectoryDto[]
|
var plannedTrajectory = new TrajectoryGeoPlanDto[]
|
||||||
{
|
{
|
||||||
new(0d, 0d, 0d),
|
new TrajectoryGeoPlanDto() { WellboreDepth = 0d, ZenithAngle = 0d, AzimuthGeo = 0d },
|
||||||
new(0d, 0d, 10d),
|
new TrajectoryGeoPlanDto() { WellboreDepth = 0d, ZenithAngle = 0d, AzimuthGeo = 10d },
|
||||||
new(0d, 30d, 20d),
|
new TrajectoryGeoPlanDto() { WellboreDepth = 0d, ZenithAngle = 30d, AzimuthGeo = 20d },
|
||||||
new(30d, 0d, 30d),
|
new TrajectoryGeoPlanDto() { WellboreDepth = 30d, ZenithAngle = 0d, AzimuthGeo = 30d },
|
||||||
new(30d, 90d, 40d),
|
new TrajectoryGeoPlanDto() { WellboreDepth = 30d, ZenithAngle = 90d, AzimuthGeo = 40d },
|
||||||
new(0d, 0d, 50d),
|
new TrajectoryGeoPlanDto() { WellboreDepth = 0d, ZenithAngle = 0d, AzimuthGeo = 50d },
|
||||||
};
|
};
|
||||||
|
|
||||||
var actualTrajectory = new TrajectoryDto[]
|
var actualTrajectory = new TrajectoryGeoFactDto[]
|
||||||
{
|
{
|
||||||
new(0, 0, 0),
|
new TrajectoryGeoFactDto() { WellboreDepth = 0, ZenithAngle = 0, AzimuthGeo = 0 },
|
||||||
new(30,30,10),
|
new TrajectoryGeoFactDto() { WellboreDepth = 30, ZenithAngle = 30, AzimuthGeo = 10 },
|
||||||
new(0, 0, 20),
|
new TrajectoryGeoFactDto() { WellboreDepth = 0, ZenithAngle = 0, AzimuthGeo = 20 },
|
||||||
};
|
};
|
||||||
|
|
||||||
var mockPlan = MakeTrajectoryRepositoryMock<IPlannedTrajectoryRepository>(plannedTrajectory);
|
var mockPlan = MakeTrajectoryRepositoryMock<ITrajectoryPlanRepository, TrajectoryGeoPlanDto>(plannedTrajectory);
|
||||||
var mockFact = MakeTrajectoryRepositoryMock<IActualTrajectoryRepository>(actualTrajectory);
|
var mockFact = MakeTrajectoryRepositoryMock<ITrajectoryFactRepository, TrajectoryGeoFactDto>(actualTrajectory);
|
||||||
var service = new TrajectoryVisualizationService(mockPlan.Object, mockFact.Object);
|
var service = new TrajectoryService(mockPlan.Object, mockFact.Object);
|
||||||
var result = await service.GetTrajectoryAsync(1, CancellationToken.None);
|
var result = await service.GetTrajectoryCartesianAsync(1, CancellationToken.None);
|
||||||
Assert.Equal(plannedTrajectory.Length, result.Plan?.Count());
|
Assert.Equal(plannedTrajectory.Length, result.Plan?.Count());
|
||||||
Assert.Equal(actualTrajectory.Length, result.Fact?.Count());
|
Assert.Equal(actualTrajectory.Length, result.Fact?.Count());
|
||||||
}
|
}
|
||||||
@ -55,20 +56,30 @@ namespace AsbCloudWebApi.Tests.ServicesTests
|
|||||||
[Fact]
|
[Fact]
|
||||||
public async Task GetTrajectoryAsync_StraigthBore()
|
public async Task GetTrajectoryAsync_StraigthBore()
|
||||||
{
|
{
|
||||||
var trajectory = new TrajectoryDto[]
|
var plannedTrajectory = new TrajectoryGeoPlanDto[]
|
||||||
{
|
{
|
||||||
new(0, 0, 0),
|
new TrajectoryGeoPlanDto() { WellboreDepth = 0, ZenithAngle = 0, AzimuthGeo = 0 },
|
||||||
new(0, 0, 0),
|
new TrajectoryGeoPlanDto() { WellboreDepth = 0, ZenithAngle = 0, AzimuthGeo = 0 },
|
||||||
new(20, 0, 0),
|
new TrajectoryGeoPlanDto() { WellboreDepth = 20, ZenithAngle = 0, AzimuthGeo = 0 },
|
||||||
new(20, 0, 0),
|
new TrajectoryGeoPlanDto() { WellboreDepth = 20, ZenithAngle = 0, AzimuthGeo = 0 },
|
||||||
new(30, 0, 0),
|
new TrajectoryGeoPlanDto() { WellboreDepth = 30, ZenithAngle = 0, AzimuthGeo = 0 },
|
||||||
new(50, 0, 0),
|
new TrajectoryGeoPlanDto() { WellboreDepth = 50, ZenithAngle = 0, AzimuthGeo = 0 },
|
||||||
};
|
};
|
||||||
|
|
||||||
var mockPlan = MakeTrajectoryRepositoryMock<IPlannedTrajectoryRepository>(trajectory);
|
var actualTrajectory = new TrajectoryGeoFactDto[]
|
||||||
var mockFact = MakeTrajectoryRepositoryMock<IActualTrajectoryRepository>(trajectory);
|
{
|
||||||
var service = new TrajectoryVisualizationService(mockPlan.Object, mockFact.Object);
|
new TrajectoryGeoFactDto() { WellboreDepth = 0, ZenithAngle = 0, AzimuthGeo = 0 },
|
||||||
var result = await service.GetTrajectoryAsync(1, CancellationToken.None);
|
new TrajectoryGeoFactDto() { WellboreDepth = 0, ZenithAngle = 0, AzimuthGeo = 0 },
|
||||||
|
new TrajectoryGeoFactDto() { WellboreDepth = 20, ZenithAngle = 0, AzimuthGeo = 0 },
|
||||||
|
new TrajectoryGeoFactDto() { WellboreDepth = 20, ZenithAngle = 0, AzimuthGeo = 0 },
|
||||||
|
new TrajectoryGeoFactDto() { WellboreDepth = 30, ZenithAngle = 0, AzimuthGeo = 0 },
|
||||||
|
new TrajectoryGeoFactDto() { WellboreDepth = 50, ZenithAngle = 0, AzimuthGeo = 0 },
|
||||||
|
};
|
||||||
|
|
||||||
|
var mockPlan = MakeTrajectoryRepositoryMock<ITrajectoryPlanRepository, TrajectoryGeoPlanDto>(plannedTrajectory);
|
||||||
|
var mockFact = MakeTrajectoryRepositoryMock<ITrajectoryFactRepository, TrajectoryGeoFactDto>(actualTrajectory);
|
||||||
|
var service = new TrajectoryService(mockPlan.Object, mockFact.Object);
|
||||||
|
var result = await service.GetTrajectoryCartesianAsync(1, CancellationToken.None);
|
||||||
var lastPointPlan = result.Plan!.Last();
|
var lastPointPlan = result.Plan!.Last();
|
||||||
var lastPointFact = result.Fact!.Last();
|
var lastPointFact = result.Fact!.Last();
|
||||||
|
|
||||||
@ -84,17 +95,24 @@ namespace AsbCloudWebApi.Tests.ServicesTests
|
|||||||
[Fact]
|
[Fact]
|
||||||
public async Task GetTrajectoryAsync_Match()
|
public async Task GetTrajectoryAsync_Match()
|
||||||
{
|
{
|
||||||
var trajectory = new TrajectoryDto[]
|
var plannedTrajectory = new TrajectoryGeoPlanDto[]
|
||||||
{
|
{
|
||||||
new(0, 0, 0),
|
new TrajectoryGeoPlanDto() { WellboreDepth = 0, ZenithAngle = 0, AzimuthGeo = 0 },
|
||||||
new(10, 30, 30),
|
new TrajectoryGeoPlanDto() { WellboreDepth = 10, ZenithAngle = 30, AzimuthGeo = 30 },
|
||||||
new(20, 0, 0),
|
new TrajectoryGeoPlanDto() { WellboreDepth = 20, ZenithAngle = 0, AzimuthGeo = 0 },
|
||||||
};
|
};
|
||||||
|
|
||||||
var mockPlanned = MakeTrajectoryRepositoryMock<IPlannedTrajectoryRepository>(trajectory);
|
var actualTrajectory = new TrajectoryGeoFactDto[]
|
||||||
var mockFactual = MakeTrajectoryRepositoryMock<IActualTrajectoryRepository>(trajectory);
|
{
|
||||||
var service = new TrajectoryVisualizationService(mockPlanned.Object, mockFactual.Object);
|
new TrajectoryGeoFactDto() { WellboreDepth = 0, ZenithAngle = 0, AzimuthGeo = 0 },
|
||||||
var result = await service.GetTrajectoryAsync(1, CancellationToken.None);
|
new TrajectoryGeoFactDto() { WellboreDepth = 10, ZenithAngle = 30, AzimuthGeo = 30 },
|
||||||
|
new TrajectoryGeoFactDto() { WellboreDepth = 20, ZenithAngle = 0, AzimuthGeo = 0 },
|
||||||
|
};
|
||||||
|
|
||||||
|
var mockPlanned = MakeTrajectoryRepositoryMock<ITrajectoryPlanRepository, TrajectoryGeoPlanDto>(plannedTrajectory);
|
||||||
|
var mockFactual = MakeTrajectoryRepositoryMock<ITrajectoryFactRepository, TrajectoryGeoFactDto>(actualTrajectory);
|
||||||
|
var service = new TrajectoryService(mockPlanned.Object, mockFactual.Object);
|
||||||
|
var result = await service.GetTrajectoryCartesianAsync(1, CancellationToken.None);
|
||||||
var lastPointPlan = result.Plan!.Last();
|
var lastPointPlan = result.Plan!.Last();
|
||||||
var lastPointFact = result.Fact!.Last();
|
var lastPointFact = result.Fact!.Last();
|
||||||
var tolerancePlan = 0.001d;
|
var tolerancePlan = 0.001d;
|
||||||
|
@ -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;
|
||||||
@ -22,13 +23,13 @@ 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 ITrajectoryPlanRepository plannedTrajectoryRepository;
|
||||||
private readonly ITrajectoryVisualizationService trajectoryVisualizationService;
|
private readonly TrajectoryService trajectoryVisualizationService;
|
||||||
|
|
||||||
public PlannedTrajectoryController(IWellService wellService,
|
public PlannedTrajectoryController(IWellService wellService,
|
||||||
IPlannedTrajectoryImportService plannedTrajectoryImportService,
|
IPlannedTrajectoryImportService plannedTrajectoryImportService,
|
||||||
IPlannedTrajectoryRepository plannedTrajectoryRepository,
|
ITrajectoryPlanRepository plannedTrajectoryRepository,
|
||||||
ITrajectoryVisualizationService trajectoryVisualizationService)
|
TrajectoryService trajectoryVisualizationService)
|
||||||
{
|
{
|
||||||
this.plannedTrajectoryImportService = plannedTrajectoryImportService;
|
this.plannedTrajectoryImportService = plannedTrajectoryImportService;
|
||||||
this.wellService = wellService;
|
this.wellService = wellService;
|
||||||
@ -118,7 +119,7 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
/// <returns>Список добавленных координат плановой траектории</returns>
|
/// <returns>Список добавленных координат плановой траектории</returns>
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[Route("getRows")]
|
[Route("getRows")]
|
||||||
[ProducesResponseType(typeof(IEnumerable<PlannedTrajectoryDto>), (int)System.Net.HttpStatusCode.OK)]
|
[ProducesResponseType(typeof(IEnumerable<TrajectoryGeoPlanDto>), (int)System.Net.HttpStatusCode.OK)]
|
||||||
public async Task<IActionResult> GetAsync([FromRoute] int idWell, CancellationToken token = default)
|
public async Task<IActionResult> GetAsync([FromRoute] int idWell, CancellationToken token = default)
|
||||||
{
|
{
|
||||||
if (!await CanUserAccessToWellAsync(idWell,
|
if (!await CanUserAccessToWellAsync(idWell,
|
||||||
@ -138,7 +139,7 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Route("addRow")]
|
[Route("addRow")]
|
||||||
[ProducesResponseType(typeof(int), (int)System.Net.HttpStatusCode.OK)]
|
[ProducesResponseType(typeof(int), (int)System.Net.HttpStatusCode.OK)]
|
||||||
public async Task<IActionResult> AddAsync(int idWell, [FromBody] PlannedTrajectoryDto row,
|
public async Task<IActionResult> AddAsync(int idWell, [FromBody] TrajectoryGeoPlanDto row,
|
||||||
CancellationToken token = default)
|
CancellationToken token = default)
|
||||||
{
|
{
|
||||||
if (!await CanUserAccessToWellAsync(idWell, token).ConfigureAwait(false))
|
if (!await CanUserAccessToWellAsync(idWell, token).ConfigureAwait(false))
|
||||||
@ -162,7 +163,7 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Route("addRangeRows")]
|
[Route("addRangeRows")]
|
||||||
[ProducesResponseType(typeof(int), (int)System.Net.HttpStatusCode.OK)]
|
[ProducesResponseType(typeof(int), (int)System.Net.HttpStatusCode.OK)]
|
||||||
public async Task<IActionResult> AddRangeAsync(int idWell, [FromBody] IEnumerable<PlannedTrajectoryDto> rows,
|
public async Task<IActionResult> AddRangeAsync(int idWell, [FromBody] IEnumerable<TrajectoryGeoPlanDto> rows,
|
||||||
CancellationToken token = default)
|
CancellationToken token = default)
|
||||||
{
|
{
|
||||||
if (!await CanUserAccessToWellAsync(idWell, token).ConfigureAwait(false))
|
if (!await CanUserAccessToWellAsync(idWell, token).ConfigureAwait(false))
|
||||||
@ -190,7 +191,7 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
[HttpPut("{idRow}")]
|
[HttpPut("{idRow}")]
|
||||||
[ProducesResponseType(typeof(int), (int)System.Net.HttpStatusCode.OK)]
|
[ProducesResponseType(typeof(int), (int)System.Net.HttpStatusCode.OK)]
|
||||||
public async Task<IActionResult> UpdateAsync(int idWell, int idRow,
|
public async Task<IActionResult> UpdateAsync(int idWell, int idRow,
|
||||||
[FromBody] PlannedTrajectoryDto row, CancellationToken token = default)
|
[FromBody] TrajectoryGeoPlanDto row, CancellationToken token = default)
|
||||||
{
|
{
|
||||||
if (!await CanUserAccessToWellAsync(idWell, token).ConfigureAwait(false))
|
if (!await CanUserAccessToWellAsync(idWell, token).ConfigureAwait(false))
|
||||||
return Forbid();
|
return Forbid();
|
||||||
@ -231,14 +232,14 @@ 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<TrajectoryCartesianPlanDto>, IEnumerable<TrajectoryCartesianFactDto>>), (int)System.Net.HttpStatusCode.OK)]
|
||||||
public async Task<IActionResult> GetPlanFactTrajectoryAsync(int idWell, CancellationToken token)
|
public async Task<IActionResult> GetTrajectoryCartesianPlanFactAsync(int idWell, CancellationToken token)
|
||||||
{
|
{
|
||||||
if (!await CanUserAccessToWellAsync(idWell,
|
if (!await CanUserAccessToWellAsync(idWell,
|
||||||
token).ConfigureAwait(false))
|
token).ConfigureAwait(false))
|
||||||
return Forbid();
|
return Forbid();
|
||||||
|
|
||||||
var result = await trajectoryVisualizationService.GetTrajectoryAsync(idWell, token);
|
var result = await trajectoryVisualizationService.GetTrajectoryCartesianAsync(idWell, token);
|
||||||
return Ok(result);
|
return Ok(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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