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