forked from ddrilling/AsbCloudServer
Reviewed-on: http://test.digitaldrilling.ru:8080/DDrilling/AsbCloudServer/pulls/26
This commit is contained in:
commit
b1fe1c8571
24
AsbCloudApp/Data/TrajectoryVisualizationDto.cs
Normal file
24
AsbCloudApp/Data/TrajectoryVisualizationDto.cs
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
namespace AsbCloudApp.Data
|
||||||
|
{
|
||||||
|
#nullable enable
|
||||||
|
/// <summary>
|
||||||
|
/// Визуализация траектории 3D
|
||||||
|
/// </summary>
|
||||||
|
public class TrajectoryVisualizationDto
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Координаты по оси X, в сторону севера (м)
|
||||||
|
/// </summary>
|
||||||
|
public double X { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Координаты по оси Y, в сторону востока (м)
|
||||||
|
/// </summary>
|
||||||
|
public double Y { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Координаты по оси Z, глубина (м)
|
||||||
|
/// </summary>
|
||||||
|
public double Z { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -3,14 +3,14 @@ using System.Collections.Generic;
|
|||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace AsbCloudApp.Services
|
namespace AsbCloudApp.Repositories
|
||||||
{
|
{
|
||||||
#nullable enable
|
#nullable enable
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// CRUD для работы с плановой траекторией из клиента
|
/// CRUD для работы с плановой траекторией из клиента
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public interface IPlannedTrajectoryService
|
public interface IPlannedTrajectoryRepository
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Получить все добавленные по скважине координаты плановой траектории
|
/// Получить все добавленные по скважине координаты плановой траектории
|
23
AsbCloudApp/Services/ITrajectoryVisualizationService.cs
Normal file
23
AsbCloudApp/Services/ITrajectoryVisualizationService.cs
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
using AsbCloudApp.Data;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace AsbCloudApp.Services
|
||||||
|
{
|
||||||
|
#nullable enable
|
||||||
|
/// <summary>
|
||||||
|
/// Сервис "Визуализация траектории 3D"
|
||||||
|
/// </summary>
|
||||||
|
public interface ITrajectoryVisualizationService
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Получение траектории по скважине
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="idWell"></param>
|
||||||
|
/// <param name="token"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<IEnumerable<TrajectoryVisualizationDto>> GetTrajectoryAsync(int idWell, CancellationToken token);
|
||||||
|
}
|
||||||
|
#nullable disable
|
||||||
|
}
|
@ -12,7 +12,7 @@
|
|||||||
<None Remove="CommonLibs\logo_720x404.png" />
|
<None Remove="CommonLibs\logo_720x404.png" />
|
||||||
<None Remove="CommonLibs\Readme.md" />
|
<None Remove="CommonLibs\Readme.md" />
|
||||||
<None Remove="Services\DailyReport\DailyReportTemplate.xlsx" />
|
<None Remove="Services\DailyReport\DailyReportTemplate.xlsx" />
|
||||||
<None Remove="Services\PlannedTrajectory\PlannedTrajectoryTemplate.xlsx" />
|
<None Remove="Services\Trajectory\PlannedTrajectoryTemplate.xlsx" />
|
||||||
<None Remove="Services\ProcessMap\ProcessMapReportTemplate.xlsx" />
|
<None Remove="Services\ProcessMap\ProcessMapReportTemplate.xlsx" />
|
||||||
<None Remove="Services\WellOperationService\ScheduleReportTemplate.xlsx" />
|
<None Remove="Services\WellOperationService\ScheduleReportTemplate.xlsx" />
|
||||||
<None Remove="Services\WellOperationService\WellOperationImportTemplate.xlsx" />
|
<None Remove="Services\WellOperationService\WellOperationImportTemplate.xlsx" />
|
||||||
@ -30,7 +30,7 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<EmbeddedResource Include="Services\DailyReport\DailyReportTemplate.xlsx" />
|
<EmbeddedResource Include="Services\DailyReport\DailyReportTemplate.xlsx" />
|
||||||
<EmbeddedResource Include="Services\PlannedTrajectory\PlannedTrajectoryTemplate.xlsx" />
|
<EmbeddedResource Include="Services\Trajectory\PlannedTrajectoryTemplate.xlsx" />
|
||||||
<EmbeddedResource Include="Services\ProcessMap\ProcessMapReportTemplate.xlsx" />
|
<EmbeddedResource Include="Services\ProcessMap\ProcessMapReportTemplate.xlsx" />
|
||||||
<EmbeddedResource Include="Services\WellOperationService\ScheduleReportTemplate.xlsx" />
|
<EmbeddedResource Include="Services\WellOperationService\ScheduleReportTemplate.xlsx" />
|
||||||
<EmbeddedResource Include="Services\WellOperationService\WellOperationImportTemplate.xlsx" />
|
<EmbeddedResource Include="Services\WellOperationService\WellOperationImportTemplate.xlsx" />
|
||||||
@ -70,5 +70,4 @@
|
|||||||
<HintPath>CommonLibs\AsbWitsInfo.dll</HintPath>
|
<HintPath>CommonLibs\AsbWitsInfo.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -12,10 +12,10 @@ using AsbCloudInfrastructure.Services;
|
|||||||
using AsbCloudInfrastructure.Services.DailyReport;
|
using AsbCloudInfrastructure.Services.DailyReport;
|
||||||
using AsbCloudInfrastructure.Services.DetectOperations;
|
using AsbCloudInfrastructure.Services.DetectOperations;
|
||||||
using AsbCloudInfrastructure.Services.DrillingProgram;
|
using AsbCloudInfrastructure.Services.DrillingProgram;
|
||||||
using AsbCloudInfrastructure.Services.PlannedTrajectory;
|
|
||||||
using AsbCloudInfrastructure.Services.ProcessMap;
|
using AsbCloudInfrastructure.Services.ProcessMap;
|
||||||
using AsbCloudInfrastructure.Services.SAUB;
|
using AsbCloudInfrastructure.Services.SAUB;
|
||||||
using AsbCloudInfrastructure.Services.Subsystems;
|
using AsbCloudInfrastructure.Services.Subsystems;
|
||||||
|
using AsbCloudInfrastructure.Services.Trajectory;
|
||||||
using AsbCloudInfrastructure.Services.WellOperationService;
|
using AsbCloudInfrastructure.Services.WellOperationService;
|
||||||
using AsbCloudInfrastructure.Validators;
|
using AsbCloudInfrastructure.Validators;
|
||||||
using FluentValidation.AspNetCore;
|
using FluentValidation.AspNetCore;
|
||||||
@ -126,7 +126,6 @@ namespace AsbCloudInfrastructure
|
|||||||
services.AddTransient<IWellService, WellService>();
|
services.AddTransient<IWellService, WellService>();
|
||||||
services.AddTransient<IWellOperationImportService, WellOperationImportService>();
|
services.AddTransient<IWellOperationImportService, WellOperationImportService>();
|
||||||
services.AddTransient<IPlannedTrajectoryImportService, PlannedTrajectoryImportService>();
|
services.AddTransient<IPlannedTrajectoryImportService, PlannedTrajectoryImportService>();
|
||||||
services.AddTransient<IPlannedTrajectoryService, PlannedTrajectoryService>();
|
|
||||||
services.AddTransient<IWellOperationRepository, WellOperationRepository>();
|
services.AddTransient<IWellOperationRepository, WellOperationRepository>();
|
||||||
services.AddTransient<IScheduleReportService, ScheduleReportService>();
|
services.AddTransient<IScheduleReportService, ScheduleReportService>();
|
||||||
services.AddTransient<IDailyReportService, DailyReportService>();
|
services.AddTransient<IDailyReportService, DailyReportService>();
|
||||||
@ -140,6 +139,7 @@ namespace AsbCloudInfrastructure
|
|||||||
services.AddTransient<ILimitingParameterService, LimitingParameterService>();
|
services.AddTransient<ILimitingParameterService, LimitingParameterService>();
|
||||||
services.AddTransient<IProcessMapReportService, ProcessMapReportService>();
|
services.AddTransient<IProcessMapReportService, ProcessMapReportService>();
|
||||||
services.AddTransient<IProcessMapService, ProcessMapService>();
|
services.AddTransient<IProcessMapService, ProcessMapService>();
|
||||||
|
services.AddTransient<ITrajectoryVisualizationService, TrajectoryVisualizationService>();
|
||||||
|
|
||||||
// admin crud services:
|
// admin crud services:
|
||||||
services.AddTransient<ICrudRepository<TelemetryDto>, CrudCacheRepositoryBase<TelemetryDto, Telemetry>>(s =>
|
services.AddTransient<ICrudRepository<TelemetryDto>, CrudCacheRepositoryBase<TelemetryDto, Telemetry>>(s =>
|
||||||
@ -177,6 +177,7 @@ 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>();
|
||||||
|
|
||||||
// Subsystem service
|
// Subsystem service
|
||||||
services.AddTransient<ICrudRepository<SubsystemDto>, CrudCacheRepositoryBase<SubsystemDto, Subsystem>>();
|
services.AddTransient<ICrudRepository<SubsystemDto>, CrudCacheRepositoryBase<SubsystemDto, Subsystem>>();
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using AsbCloudApp.Data;
|
using AsbCloudApp.Data;
|
||||||
using AsbCloudApp.Exceptions;
|
using AsbCloudApp.Exceptions;
|
||||||
|
using AsbCloudApp.Repositories;
|
||||||
using AsbCloudApp.Services;
|
using AsbCloudApp.Services;
|
||||||
using AsbCloudDb.Model;
|
using AsbCloudDb.Model;
|
||||||
using Mapster;
|
using Mapster;
|
||||||
@ -10,14 +11,14 @@ using System.Linq;
|
|||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace AsbCloudInfrastructure.Services.PlannedTrajectory
|
namespace AsbCloudInfrastructure.Repository
|
||||||
{
|
{
|
||||||
#nullable enable
|
#nullable enable
|
||||||
public class PlannedTrajectoryService : IPlannedTrajectoryService
|
public class PlannedTrajectoryRepository : IPlannedTrajectoryRepository
|
||||||
{
|
{
|
||||||
private readonly IAsbCloudDbContext db;
|
private readonly IAsbCloudDbContext db;
|
||||||
private readonly IWellService wellService;
|
private readonly IWellService wellService;
|
||||||
public PlannedTrajectoryService(IAsbCloudDbContext db, IWellService wellService)
|
public PlannedTrajectoryRepository(IAsbCloudDbContext db, IWellService wellService)
|
||||||
{
|
{
|
||||||
this.db = db;
|
this.db = db;
|
||||||
this.wellService = wellService;
|
this.wellService = wellService;
|
||||||
@ -30,10 +31,12 @@ namespace AsbCloudInfrastructure.Services.PlannedTrajectory
|
|||||||
throw new ArgumentInvalidException("Все строки должны относиться к одной скважине", nameof(plannedTrajectoryRows));
|
throw new ArgumentInvalidException("Все строки должны относиться к одной скважине", nameof(plannedTrajectoryRows));
|
||||||
var offsetHours = wellService.GetTimezone(idWell).Hours;
|
var offsetHours = wellService.GetTimezone(idWell).Hours;
|
||||||
var entities = plannedTrajectoryRows
|
var entities = plannedTrajectoryRows
|
||||||
.Select(e => {
|
.Select(e =>
|
||||||
|
{
|
||||||
var entity = Convert(e, offsetHours);
|
var entity = Convert(e, offsetHours);
|
||||||
entity.Id = 0;
|
entity.Id = 0;
|
||||||
return entity;});
|
return entity;
|
||||||
|
});
|
||||||
|
|
||||||
db.PlannedTrajectories.AddRange(entities);
|
db.PlannedTrajectories.AddRange(entities);
|
||||||
return await db.SaveChangesAsync(token)
|
return await db.SaveChangesAsync(token)
|
||||||
@ -99,16 +102,16 @@ namespace AsbCloudInfrastructure.Services.PlannedTrajectory
|
|||||||
.ConfigureAwait(false);
|
.ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private PlannedTrajectoryDto Convert(AsbCloudDb.Model.PlannedTrajectory entity, double offsetHours)
|
private PlannedTrajectoryDto Convert(PlannedTrajectory entity, double offsetHours)
|
||||||
{
|
{
|
||||||
var dto = entity.Adapt<PlannedTrajectoryDto>();
|
var dto = entity.Adapt<PlannedTrajectoryDto>();
|
||||||
dto.UpdateDate = entity.UpdateDate.ToRemoteDateTime(offsetHours);
|
dto.UpdateDate = entity.UpdateDate.ToRemoteDateTime(offsetHours);
|
||||||
return dto;
|
return dto;
|
||||||
}
|
}
|
||||||
|
|
||||||
private AsbCloudDb.Model.PlannedTrajectory Convert(PlannedTrajectoryDto dto, double offsetHours)
|
private PlannedTrajectory Convert(PlannedTrajectoryDto dto, double offsetHours)
|
||||||
{
|
{
|
||||||
var entity = dto.Adapt<AsbCloudDb.Model.PlannedTrajectory>();
|
var entity = dto.Adapt<PlannedTrajectory>();
|
||||||
entity.UpdateDate = DateTime.Now.ToUtcDateTimeOffset(offsetHours);
|
entity.UpdateDate = DateTime.Now.ToUtcDateTimeOffset(offsetHours);
|
||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
@ -1,4 +1,5 @@
|
|||||||
using AsbCloudApp.Data;
|
using AsbCloudApp.Data;
|
||||||
|
using AsbCloudApp.Repositories;
|
||||||
using AsbCloudApp.Services;
|
using AsbCloudApp.Services;
|
||||||
using ClosedXML.Excel;
|
using ClosedXML.Excel;
|
||||||
using System;
|
using System;
|
||||||
@ -8,7 +9,7 @@ using System.Linq;
|
|||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace AsbCloudInfrastructure.Services.PlannedTrajectory
|
namespace AsbCloudInfrastructure.Services.Trajectory
|
||||||
{
|
{
|
||||||
#nullable enable
|
#nullable enable
|
||||||
public class PlannedTrajectoryImportService : IPlannedTrajectoryImportService
|
public class PlannedTrajectoryImportService : IPlannedTrajectoryImportService
|
||||||
@ -18,7 +19,7 @@ namespace AsbCloudInfrastructure.Services.PlannedTrajectory
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
private readonly IWellService wellService;
|
private readonly IWellService wellService;
|
||||||
private readonly IPlannedTrajectoryService plannedTrajectoryService;
|
private readonly IPlannedTrajectoryRepository plannedTrajectoryService;
|
||||||
|
|
||||||
private const string templateFileName = "PlannedTrajectoryTemplate.xlsx";
|
private const string templateFileName = "PlannedTrajectoryTemplate.xlsx";
|
||||||
private const string usingTemplateFile = "AsbCloudInfrastructure.Services.PlannedTrajectory";
|
private const string usingTemplateFile = "AsbCloudInfrastructure.Services.PlannedTrajectory";
|
||||||
@ -40,7 +41,7 @@ namespace AsbCloudInfrastructure.Services.PlannedTrajectory
|
|||||||
private const int ColumnOrificeOffset = 14;
|
private const int ColumnOrificeOffset = 14;
|
||||||
private const int ColumnComment = 15;
|
private const int ColumnComment = 15;
|
||||||
|
|
||||||
public PlannedTrajectoryImportService(IWellService wellService, IPlannedTrajectoryService plannedTrajectoryService)
|
public PlannedTrajectoryImportService(IWellService wellService, IPlannedTrajectoryRepository plannedTrajectoryService)
|
||||||
{
|
{
|
||||||
|
|
||||||
this.wellService = wellService;
|
this.wellService = wellService;
|
||||||
@ -56,7 +57,7 @@ namespace AsbCloudInfrastructure.Services.PlannedTrajectory
|
|||||||
return stream;
|
return stream;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<string> GetFileNameAsync (int idWell, CancellationToken token)
|
public async Task<string> GetFileNameAsync(int idWell, CancellationToken token)
|
||||||
{
|
{
|
||||||
var fileName = await wellService.GetWellCaptionByIdAsync(idWell, token) + "_plannedTrajectory.xlsx";
|
var fileName = await wellService.GetWellCaptionByIdAsync(idWell, token) + "_plannedTrajectory.xlsx";
|
||||||
return fileName;
|
return fileName;
|
||||||
@ -128,7 +129,7 @@ namespace AsbCloudInfrastructure.Services.PlannedTrajectory
|
|||||||
row.IdUser = idUser;
|
row.IdUser = idUser;
|
||||||
}
|
}
|
||||||
|
|
||||||
var rowsCount = await SavePlannedTrajectoryAsync(idWell,trajectoryRows, deletePrevRows, token);
|
var rowsCount = await SavePlannedTrajectoryAsync(idWell, trajectoryRows, deletePrevRows, token);
|
||||||
return rowsCount;
|
return rowsCount;
|
||||||
}
|
}
|
||||||
|
|
@ -0,0 +1,57 @@
|
|||||||
|
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
|
||||||
|
{
|
||||||
|
#nullable enable
|
||||||
|
public class TrajectoryVisualizationService : ITrajectoryVisualizationService
|
||||||
|
{
|
||||||
|
private readonly IPlannedTrajectoryRepository repository;
|
||||||
|
|
||||||
|
public TrajectoryVisualizationService(IPlannedTrajectoryRepository repository)
|
||||||
|
{
|
||||||
|
this.repository = repository;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<IEnumerable<TrajectoryVisualizationDto>> GetTrajectoryAsync(int idWell, CancellationToken token)
|
||||||
|
{
|
||||||
|
var geoCoordinates = (await repository.GetAsync(idWell, token)).ToArray();
|
||||||
|
|
||||||
|
if (geoCoordinates.Length < 2)
|
||||||
|
return Enumerable.Empty<TrajectoryVisualizationDto>();
|
||||||
|
|
||||||
|
var cartesianCoordinates = new List<TrajectoryVisualizationDto>(geoCoordinates.Length) {
|
||||||
|
new (),
|
||||||
|
};
|
||||||
|
|
||||||
|
for (var i = 1; i < geoCoordinates.Length; i++)
|
||||||
|
{
|
||||||
|
var intervalGeoParams = geoCoordinates[i - 1];
|
||||||
|
var deltaWellLength = geoCoordinates[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.Add(coordinates);
|
||||||
|
}
|
||||||
|
|
||||||
|
return cartesianCoordinates;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,90 @@
|
|||||||
|
using AsbCloudApp.Data;
|
||||||
|
using AsbCloudApp.Repositories;
|
||||||
|
using AsbCloudInfrastructure.Services;
|
||||||
|
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 TrajectoryVisualizationServiceTest
|
||||||
|
{
|
||||||
|
private Mock<IPlannedTrajectoryRepository> MakePlannedTrajectoryRepositoryMock(IEnumerable<PlannedTrajectoryDto> dateForGetMethod)
|
||||||
|
{
|
||||||
|
var mock = new Mock<IPlannedTrajectoryRepository>();
|
||||||
|
|
||||||
|
mock.Setup(r => r.GetAsync(It.IsAny<int>(), It.IsAny<CancellationToken>()))
|
||||||
|
.Returns(Task.FromResult(dateForGetMethod));
|
||||||
|
|
||||||
|
return mock;
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task GetTrajectoryAsync_SameCounts()
|
||||||
|
{
|
||||||
|
var plannedTrajectory = new PlannedTrajectoryDto[]
|
||||||
|
{
|
||||||
|
new() { AzimuthGeo = 0d, ZenithAngle = 0d, WellboreDepth = 0d},
|
||||||
|
new() { AzimuthGeo = 0d, ZenithAngle = 0d, WellboreDepth = 10d},
|
||||||
|
new() { AzimuthGeo = 0d, ZenithAngle = 30d, WellboreDepth = 20d},
|
||||||
|
new() { AzimuthGeo = 30d, ZenithAngle = 0d, WellboreDepth = 30d},
|
||||||
|
new() { AzimuthGeo = 30d, ZenithAngle = 90d, WellboreDepth = 40d},
|
||||||
|
new() { AzimuthGeo = 0d, ZenithAngle = 0d, WellboreDepth = 50d},
|
||||||
|
};
|
||||||
|
|
||||||
|
var mock = MakePlannedTrajectoryRepositoryMock(plannedTrajectory);
|
||||||
|
var service = new TrajectoryVisualizationService(mock.Object);
|
||||||
|
var result = await service.GetTrajectoryAsync(1, CancellationToken.None);
|
||||||
|
|
||||||
|
Assert.Equal(plannedTrajectory.Length, result.Count());
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task GetTrajectoryAsync_StraigthBore()
|
||||||
|
{
|
||||||
|
var plannedTrajectory = new PlannedTrajectoryDto[]
|
||||||
|
{
|
||||||
|
new() { AzimuthGeo = 0d, ZenithAngle = 0d, WellboreDepth = 0d},
|
||||||
|
new() { AzimuthGeo = 0d, ZenithAngle = 0d, WellboreDepth = 0d},
|
||||||
|
new() { AzimuthGeo = 0d, ZenithAngle = 0d, WellboreDepth = 20d},
|
||||||
|
new() { AzimuthGeo = 0d, ZenithAngle = 0d, WellboreDepth = 20d},
|
||||||
|
new() { AzimuthGeo = 0d, ZenithAngle = 0d, WellboreDepth = 30d},
|
||||||
|
new() { AzimuthGeo = 0d, ZenithAngle = 0d, WellboreDepth = 50d},
|
||||||
|
};
|
||||||
|
|
||||||
|
var mock = MakePlannedTrajectoryRepositoryMock(plannedTrajectory);
|
||||||
|
var service = new TrajectoryVisualizationService(mock.Object);
|
||||||
|
var result = await service.GetTrajectoryAsync(1, CancellationToken.None);
|
||||||
|
var lastPoint = result.Last();
|
||||||
|
|
||||||
|
Assert.Equal(0d, lastPoint.X, 0.1d);
|
||||||
|
Assert.Equal(0d, lastPoint.Y, 0.1d);
|
||||||
|
Assert.Equal(50d, lastPoint.Z, 0.1d);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task GetTrajectoryAsync_Match()
|
||||||
|
{
|
||||||
|
var plannedTrajectory = new PlannedTrajectoryDto[]
|
||||||
|
{
|
||||||
|
new() { AzimuthGeo = 0d, ZenithAngle = 0d, WellboreDepth = 0d},
|
||||||
|
new() { AzimuthGeo = 30d, ZenithAngle = 30d, WellboreDepth = 10d},
|
||||||
|
new() { AzimuthGeo = 0d, ZenithAngle = 0d, WellboreDepth = 20d},
|
||||||
|
};
|
||||||
|
|
||||||
|
var mock = MakePlannedTrajectoryRepositoryMock(plannedTrajectory);
|
||||||
|
var service = new TrajectoryVisualizationService(mock.Object);
|
||||||
|
var result = await service.GetTrajectoryAsync(1, CancellationToken.None);
|
||||||
|
var lastPoint = result.Last();
|
||||||
|
var tolerance = 0.001d;
|
||||||
|
|
||||||
|
Assert.InRange(lastPoint.Z, 10 + tolerance, 20 - tolerance);
|
||||||
|
Assert.InRange(lastPoint.Y, 0 + tolerance, 10 - tolerance);
|
||||||
|
Assert.InRange(lastPoint.X, 0 + tolerance, 10 - tolerance);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,5 @@
|
|||||||
using AsbCloudApp.Data;
|
using AsbCloudApp.Data;
|
||||||
|
using AsbCloudApp.Repositories;
|
||||||
using AsbCloudApp.Services;
|
using AsbCloudApp.Services;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
@ -21,13 +22,18 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
{
|
{
|
||||||
private readonly IWellService wellService;
|
private readonly IWellService wellService;
|
||||||
private readonly IPlannedTrajectoryImportService plannedTrajectoryImportService;
|
private readonly IPlannedTrajectoryImportService plannedTrajectoryImportService;
|
||||||
private readonly IPlannedTrajectoryService plannedTrajectoryService;
|
private readonly IPlannedTrajectoryRepository plannedTrajectoryRepository;
|
||||||
|
private readonly ITrajectoryVisualizationService trajectoryVisualizationService;
|
||||||
|
|
||||||
public PlannedTrajectoryController(IWellService wellService, IPlannedTrajectoryImportService plannedTrajectoryImportService, IPlannedTrajectoryService plannedTrajectoryService)
|
public PlannedTrajectoryController(IWellService wellService,
|
||||||
|
IPlannedTrajectoryImportService plannedTrajectoryImportService,
|
||||||
|
IPlannedTrajectoryRepository plannedTrajectoryRepository,
|
||||||
|
ITrajectoryVisualizationService trajectoryVisualizationService)
|
||||||
{
|
{
|
||||||
this.plannedTrajectoryImportService = plannedTrajectoryImportService;
|
this.plannedTrajectoryImportService = plannedTrajectoryImportService;
|
||||||
this.wellService = wellService;
|
this.wellService = wellService;
|
||||||
this.plannedTrajectoryService = plannedTrajectoryService;
|
this.plannedTrajectoryRepository = plannedTrajectoryRepository;
|
||||||
|
this.trajectoryVisualizationService = trajectoryVisualizationService;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -121,7 +127,7 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
if (!await CanUserAccessToWellAsync(idWell,
|
if (!await CanUserAccessToWellAsync(idWell,
|
||||||
token).ConfigureAwait(false))
|
token).ConfigureAwait(false))
|
||||||
return Forbid();
|
return Forbid();
|
||||||
var result = await plannedTrajectoryService.GetAsync(idWell, token);
|
var result = await plannedTrajectoryRepository.GetAsync(idWell, token);
|
||||||
return Ok(result);
|
return Ok(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -146,7 +152,7 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
return Forbid();
|
return Forbid();
|
||||||
row.IdUser = idUser.Value;
|
row.IdUser = idUser.Value;
|
||||||
row.IdWell = idWell;
|
row.IdWell = idWell;
|
||||||
var result = await plannedTrajectoryService.AddAsync(row, token);
|
var result = await plannedTrajectoryRepository.AddAsync(row, token);
|
||||||
return Ok(result);
|
return Ok(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -174,7 +180,7 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
item.IdUser = idUser.Value;
|
item.IdUser = idUser.Value;
|
||||||
item.IdWell = idWell;
|
item.IdWell = idWell;
|
||||||
}
|
}
|
||||||
var result = await plannedTrajectoryService.AddRangeAsync(rows, token);
|
var result = await plannedTrajectoryRepository.AddRangeAsync(rows, token);
|
||||||
return Ok(result);
|
return Ok(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -200,7 +206,7 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
row.Id = idRow;
|
row.Id = idRow;
|
||||||
row.IdUser = idUser.Value;
|
row.IdUser = idUser.Value;
|
||||||
row.IdWell = idWell;
|
row.IdWell = idWell;
|
||||||
var result = await plannedTrajectoryService.UpdateAsync(row, token);
|
var result = await plannedTrajectoryRepository.UpdateAsync(row, token);
|
||||||
return Ok(result);
|
return Ok(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -220,11 +226,29 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
token).ConfigureAwait(false))
|
token).ConfigureAwait(false))
|
||||||
return Forbid();
|
return Forbid();
|
||||||
|
|
||||||
var result = await plannedTrajectoryService.DeleteRangeAsync(new int[] { idRow }, token);
|
var result = await plannedTrajectoryRepository.DeleteRangeAsync(new int[] { idRow }, token);
|
||||||
|
|
||||||
return Ok(result);
|
return Ok(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Получение координат для визуализации траектории
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="idWell"></param>
|
||||||
|
/// <param name="token"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet]
|
||||||
|
[ProducesResponseType(typeof(IEnumerable<TrajectoryVisualizationDto>), (int)System.Net.HttpStatusCode.OK)]
|
||||||
|
public async Task<IActionResult> GetTrajectoryAsync(int idWell, CancellationToken token)
|
||||||
|
{
|
||||||
|
if (!await CanUserAccessToWellAsync(idWell,
|
||||||
|
token).ConfigureAwait(false))
|
||||||
|
return Forbid();
|
||||||
|
|
||||||
|
var result = await trajectoryVisualizationService.GetTrajectoryAsync(idWell, token);
|
||||||
|
return Ok(result);
|
||||||
|
}
|
||||||
|
|
||||||
private async Task<bool> CanUserAccessToWellAsync(int idWell, CancellationToken token = default)
|
private async Task<bool> CanUserAccessToWellAsync(int idWell, CancellationToken token = default)
|
||||||
{
|
{
|
||||||
int? idCompany = User.GetCompanyId();
|
int? idCompany = User.GetCompanyId();
|
||||||
|
Loading…
Reference in New Issue
Block a user