#5908066 Исправления

This commit is contained in:
ai.astrakhantsev 2022-09-21 12:56:18 +05:00
parent 67e4913c84
commit 6cac72259c
2 changed files with 8 additions and 8 deletions

View File

@ -14,7 +14,7 @@
/// <summary>
/// блок КНБК
/// </summary>
public BhaDto? Bha { get; set; } = new();
public BhaDto Bha { get; set; } = new();
/// <summary>
/// блок безметражные работы

View File

@ -124,24 +124,24 @@ namespace AsbCloudInfrastructure.Services.DailyReport
ClusterName = well?.Cluster ?? "",
},
TimeBalance = await MakeTimeBalanceAsync(idWell, date, token),
Bha = await GetPrevBhaAsync(idWell, date, token)
Bha = await GetPrevOrNewBhaAsync(idWell, date, token)
};
return dto;
}
private async Task<BhaDto?> GetPrevBhaAsync(int idWell, DateTime date, CancellationToken token)
private async Task<BhaDto> GetPrevOrNewBhaAsync(int idWell, DateTime date, CancellationToken token)
{
var dateOffset = date.Date;
var entity = await db.DailyReports
.Where(x => x.IdWell == idWell)
.OrderByDescending(x => x.StartDate)
.FirstOrDefaultAsync(r => r.IdWell == idWell &&
r.StartDate.Year <= dateOffset.Year &&
r.StartDate.DayOfYear <= dateOffset.DayOfYear, token);
.FirstOrDefaultAsync(r => r.StartDate <= dateOffset, token);
if (entity is null)
return null;
return new BhaDto();
var dto = Convert(entity);
return dto?.Bha;
return dto.Bha;
}
private async Task<TimeBalanceDto> MakeTimeBalanceAsync(int idWell, DateTime date, CancellationToken token)