forked from ddrilling/AsbCloudServer
#5908066 Суточный рапорт. Блок КНБК
This commit is contained in:
parent
df5c98838d
commit
67e4913c84
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user