diff --git a/AsbCloudApp/Data/DailyReport/DailyReportDto.cs b/AsbCloudApp/Data/DailyReport/DailyReportDto.cs
index c47b8934..781a6717 100644
--- a/AsbCloudApp/Data/DailyReport/DailyReportDto.cs
+++ b/AsbCloudApp/Data/DailyReport/DailyReportDto.cs
@@ -1,5 +1,6 @@
namespace AsbCloudApp.Data.DailyReport
{
+#nullable enable
///
/// Блоки для формирования суточного рапорта
///
@@ -13,7 +14,7 @@
///
/// блок КНБК
///
- public BhaDto Bha { get; set; } = new();
+ public BhaDto? Bha { get; set; } = new();
///
/// блок безметражные работы
@@ -35,4 +36,5 @@
///
public SignDto Sign { get; set; } = new();
}
+#nullable disable
}
diff --git a/AsbCloudInfrastructure/Services/DailyReport/DailyReportService.cs b/AsbCloudInfrastructure/Services/DailyReport/DailyReportService.cs
index 1c30ba0b..ecdd7d15 100644
--- a/AsbCloudInfrastructure/Services/DailyReport/DailyReportService.cs
+++ b/AsbCloudInfrastructure/Services/DailyReport/DailyReportService.cs
@@ -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 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 MakeTimeBalanceAsync(int idWell, DateTime date, CancellationToken token)
{
var stat = await detectedOperationService.GetOperationsStatAsync(new DetectedOperationRequest