nit WellOperationRepository renames

This commit is contained in:
ngfrolov 2023-02-22 11:25:51 +05:00
parent c7c5de563a
commit 9de4b31f2d
Signed by: ng.frolov
GPG Key ID: E99907A0357B29A7

View File

@ -68,16 +68,16 @@ namespace AsbCloudInfrastructure.Repository
var timezone = wellService.GetTimezone(idWell); var timezone = wellService.GetTimezone(idWell);
var request = new WellOperationRequest() var request = new WellOperationRequest()
{ {
IdWell = idWell IdWell = idWell,
OperationType = WellOperation.IdOperationTypePlan,
}; };
var entities = await BuildQuery(request) var entities = await BuildQuery(request)
.Where(x => x.IdType == WellOperation.IdOperationTypePlan)
.AsNoTracking() .AsNoTracking()
.ToArrayAsync(token) .ToArrayAsync(token)
.ConfigureAwait(false); .ConfigureAwait(false);
var dateLastAssosiatedPlanOperation = await getDateLastAssosiatedPlanOperation(idWell, currentDate, timezone.Hours, token); var dateLastAssosiatedPlanOperation = await GetDateLastAssosiatedPlanOperationAsync(idWell, currentDate, timezone.Hours, token);
var result = new WellOperationPlanDto() var result = new WellOperationPlanDto()
{ {
@ -88,31 +88,30 @@ namespace AsbCloudInfrastructure.Repository
return result; return result;
} }
private async Task<DateTime?> getDateLastAssosiatedPlanOperation( private async Task<DateTime?> GetDateLastAssosiatedPlanOperationAsync(
int idWell, int idWell,
DateTime? currentDate, DateTime? lessThenDate,
double timeZoneHours, double timeZoneHours,
CancellationToken token) CancellationToken token)
{ {
if (currentDate is not null) if (lessThenDate is null)
{ return null;
var currentDateOffset = currentDate.Value.ToUtcDateTimeOffset(timeZoneHours);
var timeZoneOffset = TimeSpan.FromHours(timeZoneHours);
var lastFactOperation = await db.WellOperations var currentDateOffset = lessThenDate.Value.ToUtcDateTimeOffset(timeZoneHours);
.Where(x => x.IdWell == idWell) var timeZoneOffset = TimeSpan.FromHours(timeZoneHours);
.Where(x => x.IdType == WellOperation.IdOperationTypeFact)
.Where(x => x.IdPlan != null)
.Where(x => x.DateStart < currentDateOffset)
.Include(x => x.OperationPlan)
.OrderByDescending(x => x.DateStart)
.FirstOrDefaultAsync(token)
.ConfigureAwait(false);
if (lastFactOperation is not null) var lastFactOperation = await db.WellOperations
return DateTime.SpecifyKind(lastFactOperation.OperationPlan.DateStart.UtcDateTime + timeZoneOffset, DateTimeKind.Unspecified); .Where(o => o.IdWell == idWell)
.Where(o => o.IdType == WellOperation.IdOperationTypeFact)
.Where(o => o.IdPlan != null)
.Where(o => o.DateStart < currentDateOffset)
.Include(x => x.OperationPlan)
.OrderByDescending(x => x.DateStart)
.FirstOrDefaultAsync(token)
.ConfigureAwait(false);
} if (lastFactOperation is not null)
return DateTime.SpecifyKind(lastFactOperation.OperationPlan.DateStart.UtcDateTime + timeZoneOffset, DateTimeKind.Unspecified);
return null; return null;
} }
@ -346,7 +345,6 @@ namespace AsbCloudInfrastructure.Repository
.Where(subOp => subOp.IdType == 1) .Where(subOp => subOp.IdType == 1)
.Where(subOp => WellOperationCategory.NonProductiveTimeSubIds.Contains(subOp.IdCategory)); .Where(subOp => WellOperationCategory.NonProductiveTimeSubIds.Contains(subOp.IdCategory));
var result = query.Select(o => new WellOperationDto var result = query.Select(o => new WellOperationDto
{ {
Id = o.Id, Id = o.Id,