#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>
/// блок КНБК /// блок КНБК
/// </summary> /// </summary>
public BhaDto? Bha { get; set; } = new(); public BhaDto Bha { get; set; } = new();
/// <summary> /// <summary>
/// блок безметражные работы /// блок безметражные работы

View File

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