forked from ddrilling/AsbCloudServer
#5908066 Исправления
This commit is contained in:
parent
67e4913c84
commit
6cac72259c
@ -14,7 +14,7 @@
|
||||
/// <summary>
|
||||
/// блок КНБК
|
||||
/// </summary>
|
||||
public BhaDto? Bha { get; set; } = new();
|
||||
public BhaDto Bha { get; set; } = new();
|
||||
|
||||
/// <summary>
|
||||
/// блок безметражные работы
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user