#5908066 Суточный рапорт. Блок КНБК

This commit is contained in:
ai.astrakhantsev 2022-09-21 09:41:01 +05:00
parent df5c98838d
commit 67e4913c84
2 changed files with 19 additions and 1 deletions

View File

@ -1,5 +1,6 @@
namespace AsbCloudApp.Data.DailyReport
{
#nullable enable
/// <summary>
/// Блоки для формирования суточного рапорта
/// </summary>
@ -13,7 +14,7 @@
/// <summary>
/// блок КНБК
/// </summary>
public BhaDto Bha { get; set; } = new();
public BhaDto? Bha { get; set; } = new();
/// <summary>
/// блок безметражные работы
@ -35,4 +36,5 @@
/// </summary>
public SignDto Sign { get; set; } = new();
}
#nullable disable
}

View File

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