forked from ddrilling/AsbCloudServer
Refactor trajectory
This commit is contained in:
parent
ff6c5d7751
commit
ada2b36310
@ -1,5 +1,6 @@
|
|||||||
namespace AsbCloudApp.Data
|
namespace AsbCloudApp.Data
|
||||||
{
|
{
|
||||||
|
#nullable enable
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Визуализация траектории 3D
|
/// Визуализация траектории 3D
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -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" />
|
||||||
|
@ -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;
|
||||||
|
@ -9,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
|
||||||
@ -17,7 +17,7 @@ namespace AsbCloudInfrastructure.Services.PlannedTrajectory
|
|||||||
/*
|
/*
|
||||||
* password for PlannedTrajectoryTemplate.xlsx is Drill2022
|
* password for PlannedTrajectoryTemplate.xlsx is Drill2022
|
||||||
*/
|
*/
|
||||||
|
|
||||||
private readonly IWellService wellService;
|
private readonly IWellService wellService;
|
||||||
private readonly IPlannedTrajectoryRepository plannedTrajectoryService;
|
private readonly IPlannedTrajectoryRepository plannedTrajectoryService;
|
||||||
|
|
||||||
@ -43,7 +43,7 @@ namespace AsbCloudInfrastructure.Services.PlannedTrajectory
|
|||||||
|
|
||||||
public PlannedTrajectoryImportService(IWellService wellService, IPlannedTrajectoryRepository plannedTrajectoryService)
|
public PlannedTrajectoryImportService(IWellService wellService, IPlannedTrajectoryRepository plannedTrajectoryService)
|
||||||
{
|
{
|
||||||
|
|
||||||
this.wellService = wellService;
|
this.wellService = wellService;
|
||||||
this.plannedTrajectoryService = plannedTrajectoryService;
|
this.plannedTrajectoryService = plannedTrajectoryService;
|
||||||
}
|
}
|
||||||
@ -57,21 +57,21 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<Stream> ExportAsync(int idWell, CancellationToken token)
|
public async Task<Stream> ExportAsync(int idWell, CancellationToken token)
|
||||||
{
|
{
|
||||||
var plannedTrajectorys = await plannedTrajectoryService.GetAsync(idWell, token);
|
var plannedTrajectorys = await plannedTrajectoryService.GetAsync(idWell, token);
|
||||||
return MakeExelFileStream(plannedTrajectorys);
|
return MakeExelFileStream(plannedTrajectorys);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Stream MakeExelFileStream(IEnumerable<PlannedTrajectoryDto> plannedTrajectories)
|
private Stream MakeExelFileStream(IEnumerable<PlannedTrajectoryDto> 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);
|
||||||
AddPlannedTrajecoryToWorkbook(workbook, plannedTrajectories);
|
AddPlannedTrajecoryToWorkbook(workbook, plannedTrajectories);
|
||||||
MemoryStream memoryStream = new MemoryStream();
|
MemoryStream memoryStream = new MemoryStream();
|
||||||
@ -124,12 +124,12 @@ namespace AsbCloudInfrastructure.Services.PlannedTrajectory
|
|||||||
using var workbook = new XLWorkbook(stream, XLEventTracking.Disabled);
|
using var workbook = new XLWorkbook(stream, XLEventTracking.Disabled);
|
||||||
var trajectoryRows = ParseFileStream(stream);
|
var trajectoryRows = ParseFileStream(stream);
|
||||||
foreach (var row in trajectoryRows)
|
foreach (var row in trajectoryRows)
|
||||||
{
|
{
|
||||||
row.IdWell = idWell;
|
row.IdWell = idWell;
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -206,9 +206,9 @@ namespace AsbCloudInfrastructure.Services.PlannedTrajectory
|
|||||||
var _comment = row.Cell(ColumnComment).Value;
|
var _comment = row.Cell(ColumnComment).Value;
|
||||||
|
|
||||||
var trajectoryRow = new PlannedTrajectoryDto();
|
var trajectoryRow = new PlannedTrajectoryDto();
|
||||||
|
|
||||||
static double getDoubleValue(object value, string nameParam, IXLRow row)
|
static double getDoubleValue(object value, string nameParam, IXLRow row)
|
||||||
{
|
{
|
||||||
if (value is double _value)
|
if (value is double _value)
|
||||||
return _value;
|
return _value;
|
||||||
throw new FileFormatException($"Лист {row.Worksheet.Name}. Строка {row.RowNumber()} - некорректные данные - {nameParam}");
|
throw new FileFormatException($"Лист {row.Worksheet.Name}. Строка {row.RowNumber()} - некорректные данные - {nameParam}");
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,65 +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
|
|
||||||
{
|
|
||||||
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 result = new List<TrajectoryVisualizationDto> {
|
|
||||||
new ()
|
|
||||||
};
|
|
||||||
var dtos = (await repository.GetAsync(idWell, token)).ToArray();
|
|
||||||
|
|
||||||
var prevData = dtos[0];
|
|
||||||
var prevCoordinates = new TrajectoryVisualizationDto();
|
|
||||||
|
|
||||||
for (var i = 1; i < dtos.Length; i++)
|
|
||||||
{
|
|
||||||
var data = dtos[i];
|
|
||||||
var flat = GetFlat(data.WellboreDepth, prevData.WellboreDepth, prevData.ZenithAngle);
|
|
||||||
var x = prevCoordinates.X = GetX(prevData.AzimuthGeo, flat, prevCoordinates.X);
|
|
||||||
var y = prevCoordinates.Y = GetY(prevData.AzimuthGeo, flat, prevCoordinates.X);
|
|
||||||
var z = prevCoordinates.Z = GetZ(data.WellboreDepth, prevData.WellboreDepth, prevData.ZenithAngle, prevCoordinates.Z);
|
|
||||||
prevData = data;
|
|
||||||
|
|
||||||
var coordinates = new TrajectoryVisualizationDto
|
|
||||||
{
|
|
||||||
X = x,
|
|
||||||
Y = y,
|
|
||||||
Z = z
|
|
||||||
};
|
|
||||||
|
|
||||||
result.Add(coordinates);
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
private double GetFlat(double depthEnd, double depthStart, double zenit) =>
|
|
||||||
(depthEnd - depthStart) * Math.Sin(zenit * Math.PI / 180);
|
|
||||||
|
|
||||||
private double GetX(double azimuth, double flat, double prev) =>
|
|
||||||
prev + flat * Math.Sin(azimuth * Math.PI / 180);
|
|
||||||
|
|
||||||
private double GetY(double azimuth, double flat, double prev) =>
|
|
||||||
prev + flat * Math.Cos(azimuth * Math.PI / 180);
|
|
||||||
|
|
||||||
private double GetZ(double depthEnd, double depthStart, double zenit, double prev) =>
|
|
||||||
prev + (depthEnd - depthStart) * Math.Cos(zenit * Math.PI / 180);
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user