DD.WellWorkover.Cloud/AsbCloudInfrastructure/Repository/TrajectoryFactRepository.cs

54 lines
1.8 KiB
C#
Raw Normal View History

using AsbCloudApp.Data;
using AsbCloudApp.Repositories;
using AsbCloudApp.Services;
using AsbCloudDb.Model;
using Microsoft.EntityFrameworkCore;
using System.Collections.Generic;
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
{
private readonly IAsbCloudDbContext db;
private readonly IWellService wellService;
2023-05-30 11:21:07 +05:00
public TrajectoryFactRepository(IAsbCloudDbContext db, IWellService wellService)
{
this.db = db;
this.wellService = wellService;
}
2023-05-30 11:21:07 +05:00
public async Task<IEnumerable<TrajectoryGeoFactDto>> GetAsync(int idWell, CancellationToken token)
{
var well = await wellService.GetOrDefaultAsync(idWell,
token);
if (well is null)
return Enumerable.Empty<TrajectoryGeoFactDto>();
var entities = await db.Record7
.AsNoTracking()
.Where(x => x.IdTelemetry == well.IdTelemetry)
.Where(coord => coord.Deptsvym != null && coord.Svyinc != null && coord.Svyazc != null)
.OrderBy(e => e.Deptsvym)
.ToArrayAsync(token);
var result = entities
2023-05-30 11:21:07 +05:00
.Select(coord => new TrajectoryGeoFactDto
{
IdWell = idWell,
AzimuthMagnetic = coord.Svymtf,
VerticalDepth = coord.Deptsvyv,
2023-05-30 11:21:07 +05:00
WellboreDepth = coord.Deptsvym!.Value,
ZenithAngle = coord.Svyinc!.Value,
AzimuthGeo = coord.Svyazc!.Value
})
.ToArray();
return result;
}
}
}