2023-05-11 11:50:45 +05:00
|
|
|
|
using AsbCloudApp.Data;
|
2023-05-04 16:54:09 +05:00
|
|
|
|
using AsbCloudApp.Repositories;
|
|
|
|
|
using AsbCloudApp.Services;
|
|
|
|
|
using AsbCloudDb.Model;
|
|
|
|
|
using Microsoft.EntityFrameworkCore;
|
2023-05-17 11:42:14 +05:00
|
|
|
|
using System.Collections.Generic;
|
2023-05-04 16:54:09 +05:00
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Threading;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace AsbCloudInfrastructure.Repository
|
|
|
|
|
{
|
2023-05-30 11:21:07 +05:00
|
|
|
|
internal class TrajectoryFactRepository : ITrajectoryFactRepository
|
2023-05-04 16:54:09 +05:00
|
|
|
|
{
|
|
|
|
|
private readonly IAsbCloudDbContext db;
|
|
|
|
|
private readonly IWellService wellService;
|
2023-05-30 11:21:07 +05:00
|
|
|
|
public TrajectoryFactRepository(IAsbCloudDbContext db, IWellService wellService)
|
2023-05-04 16:54:09 +05:00
|
|
|
|
{
|
|
|
|
|
this.db = db;
|
|
|
|
|
this.wellService = wellService;
|
|
|
|
|
}
|
2023-06-30 14:55:44 +05:00
|
|
|
|
|
2023-05-30 11:21:07 +05:00
|
|
|
|
public async Task<IEnumerable<TrajectoryGeoFactDto>> GetAsync(int idWell, CancellationToken token)
|
2023-05-04 16:54:09 +05:00
|
|
|
|
{
|
2023-06-30 14:55:44 +05:00
|
|
|
|
var well = await wellService.GetOrDefaultAsync(idWell,
|
|
|
|
|
token);
|
|
|
|
|
|
|
|
|
|
if (well is null)
|
|
|
|
|
return Enumerable.Empty<TrajectoryGeoFactDto>();
|
2023-05-04 16:54:09 +05:00
|
|
|
|
|
2023-05-11 15:36:49 +05:00
|
|
|
|
var entities = await db.Record7
|
2023-05-04 16:54:09 +05:00
|
|
|
|
.AsNoTracking()
|
2023-05-11 15:36:49 +05:00
|
|
|
|
.Where(x => x.IdTelemetry == well.IdTelemetry)
|
|
|
|
|
.Where(coord => coord.Deptsvym != null && coord.Svyinc != null && coord.Svyazc != null)
|
2023-05-04 16:54:09 +05:00
|
|
|
|
.OrderBy(e => e.Deptsvym)
|
2023-05-11 15:36:49 +05:00
|
|
|
|
.ToArrayAsync(token);
|
2023-05-11 11:50:45 +05:00
|
|
|
|
|
2023-05-11 15:36:49 +05:00
|
|
|
|
var result = entities
|
2023-05-30 11:21:07 +05:00
|
|
|
|
.Select(coord => new TrajectoryGeoFactDto
|
|
|
|
|
{
|
2023-06-30 14:55:44 +05:00
|
|
|
|
IdWell = idWell,
|
|
|
|
|
AzimuthMagnetic = coord.Svymtf,
|
|
|
|
|
VerticalDepth = coord.Deptsvyv,
|
|
|
|
|
NorthOrifice = coord.Svyns,
|
|
|
|
|
EastOrifice = coord.Svyew,
|
2023-05-30 11:21:07 +05:00
|
|
|
|
WellboreDepth = coord.Deptsvym!.Value,
|
|
|
|
|
ZenithAngle = coord.Svyinc!.Value,
|
|
|
|
|
AzimuthGeo = coord.Svyazc!.Value
|
|
|
|
|
})
|
2023-05-11 11:50:45 +05:00
|
|
|
|
.ToArray();
|
2023-05-11 15:36:49 +05:00
|
|
|
|
|
|
|
|
|
return result;
|
2023-05-11 11:50:45 +05:00
|
|
|
|
}
|
2023-05-04 16:54:09 +05:00
|
|
|
|
}
|
|
|
|
|
}
|