forked from ddrilling/AsbCloudServer
Фикс репозиторий
1. Поправлена выборка в репозитории с траекториями 2. В репозитории с операциями по скважине добавлено приведение ко времени куста.
This commit is contained in:
parent
06a72d0dca
commit
4ff7b73403
@ -9,20 +9,26 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using AsbCloudApp.Services;
|
||||||
|
|
||||||
namespace AsbCloudInfrastructure.Repository
|
namespace AsbCloudInfrastructure.Repository
|
||||||
{
|
{
|
||||||
public class TrajectoryNnbRepository : ITrajectoryNnbRepository
|
public class TrajectoryNnbRepository : ITrajectoryNnbRepository
|
||||||
{
|
{
|
||||||
private readonly IAsbCloudDbContext db;
|
private readonly IAsbCloudDbContext db;
|
||||||
public TrajectoryNnbRepository(IAsbCloudDbContext db)
|
private readonly IWellService wellService;
|
||||||
|
|
||||||
|
public TrajectoryNnbRepository(IAsbCloudDbContext db,
|
||||||
|
IWellService wellService)
|
||||||
{
|
{
|
||||||
this.db = db;
|
this.db = db;
|
||||||
|
this.wellService = wellService;
|
||||||
}
|
}
|
||||||
|
|
||||||
private IQueryable<Record7> BuildQuery(TrajectoryRequest request)
|
private IQueryable<Record7> BuildQuery(TrajectoryRequest request)
|
||||||
{
|
{
|
||||||
var well = db.Wells.SingleOrDefault(w => w.Id == request.IdWell);
|
var well = db.Wells.SingleOrDefault(w => w.Id == request.IdWell);
|
||||||
|
var timezone = wellService.GetTimezone(request.IdWell);
|
||||||
|
|
||||||
if (well is null)
|
if (well is null)
|
||||||
throw new ArgumentInvalidException($"Скважина с Id: {request.IdWell} не найдена", nameof(request.IdWell));
|
throw new ArgumentInvalidException($"Скважина с Id: {request.IdWell} не найдена", nameof(request.IdWell));
|
||||||
@ -31,10 +37,16 @@ namespace AsbCloudInfrastructure.Repository
|
|||||||
.Where(x => x.IdTelemetry == well.IdTelemetry);
|
.Where(x => x.IdTelemetry == well.IdTelemetry);
|
||||||
|
|
||||||
if (request.GeDate.HasValue)
|
if (request.GeDate.HasValue)
|
||||||
query = query.Where(r => r.DateTime >= request.GeDate.Value);
|
{
|
||||||
|
var geDate = request.GeDate.Value.ToUtcDateTimeOffset(timezone.Hours);
|
||||||
|
query = query.Where(r => r.DateTime >= geDate);
|
||||||
|
}
|
||||||
|
|
||||||
if (request.LeDate.HasValue)
|
if (request.LeDate.HasValue)
|
||||||
query = query.Where(r => r.DateTime <= request.LeDate.Value);
|
{
|
||||||
|
var leDate = request.LeDate.Value.ToUtcDateTimeOffset(timezone.Hours);
|
||||||
|
query = query.Where(r => r.DateTime <= leDate);
|
||||||
|
}
|
||||||
|
|
||||||
return query.OrderBy(e => e.Deptsvym);
|
return query.OrderBy(e => e.Deptsvym);
|
||||||
}
|
}
|
||||||
|
@ -186,15 +186,20 @@ public class WellOperationRepository : IWellOperationRepository
|
|||||||
|
|
||||||
public async Task<DatesRangeDto?> GetDatesRangeAsync(int idWell, int idType, CancellationToken cancellationToken)
|
public async Task<DatesRangeDto?> GetDatesRangeAsync(int idWell, int idType, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
|
var timezone = wellService.GetTimezone(idWell);
|
||||||
|
|
||||||
var query = db.WellOperations.Where(o => o.IdWell == idWell && o.IdType == idType);
|
var query = db.WellOperations.Where(o => o.IdWell == idWell && o.IdType == idType);
|
||||||
|
|
||||||
if (!await query.AnyAsync(cancellationToken))
|
if (!await query.AnyAsync(cancellationToken))
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
|
var minDate = await query.MinAsync(o => o.DateStart, cancellationToken);
|
||||||
|
var maxDate = await query.MaxAsync(o => o.DateStart, cancellationToken);
|
||||||
|
|
||||||
return new DatesRangeDto
|
return new DatesRangeDto
|
||||||
{
|
{
|
||||||
From = (await query.MinAsync(o => o.DateStart, cancellationToken)).Date,
|
From = minDate.ToRemoteDateTime(timezone.Hours),
|
||||||
To = (await query.MaxAsync(o => o.DateStart, cancellationToken)).Date
|
To = maxDate.ToRemoteDateTime(timezone.Hours)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user