From 6cac72259c39fca0c81c3855f91e2c353cd33ca3 Mon Sep 17 00:00:00 2001 From: "ai.astrakhantsev" Date: Wed, 21 Sep 2022 12:56:18 +0500 Subject: [PATCH] =?UTF-8?q?#5908066=20=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=BB=D0=B5=D0=BD=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AsbCloudApp/Data/DailyReport/DailyReportDto.cs | 2 +- .../Services/DailyReport/DailyReportService.cs | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/AsbCloudApp/Data/DailyReport/DailyReportDto.cs b/AsbCloudApp/Data/DailyReport/DailyReportDto.cs index 781a6717..920aeb54 100644 --- a/AsbCloudApp/Data/DailyReport/DailyReportDto.cs +++ b/AsbCloudApp/Data/DailyReport/DailyReportDto.cs @@ -14,7 +14,7 @@ /// /// блок КНБК /// - public BhaDto? Bha { get; set; } = new(); + public BhaDto Bha { get; set; } = new(); /// /// блок безметражные работы diff --git a/AsbCloudInfrastructure/Services/DailyReport/DailyReportService.cs b/AsbCloudInfrastructure/Services/DailyReport/DailyReportService.cs index ecdd7d15..807b10ca 100644 --- a/AsbCloudInfrastructure/Services/DailyReport/DailyReportService.cs +++ b/AsbCloudInfrastructure/Services/DailyReport/DailyReportService.cs @@ -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 GetPrevBhaAsync(int idWell, DateTime date, CancellationToken token) + private async Task 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 MakeTimeBalanceAsync(int idWell, DateTime date, CancellationToken token)