forked from ddrilling/AsbCloudServer
#5908066 Исправления
This commit is contained in:
parent
67e4913c84
commit
6cac72259c
@ -14,7 +14,7 @@
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// блок КНБК
|
/// блок КНБК
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public BhaDto? Bha { get; set; } = new();
|
public BhaDto Bha { get; set; } = new();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// блок безметражные работы
|
/// блок безметражные работы
|
||||||
|
@ -124,24 +124,24 @@ namespace AsbCloudInfrastructure.Services.DailyReport
|
|||||||
ClusterName = well?.Cluster ?? "",
|
ClusterName = well?.Cluster ?? "",
|
||||||
},
|
},
|
||||||
TimeBalance = await MakeTimeBalanceAsync(idWell, date, token),
|
TimeBalance = await MakeTimeBalanceAsync(idWell, date, token),
|
||||||
Bha = await GetPrevBhaAsync(idWell, date, token)
|
Bha = await GetPrevOrNewBhaAsync(idWell, date, token)
|
||||||
};
|
};
|
||||||
return dto;
|
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 dateOffset = date.Date;
|
||||||
var entity = await db.DailyReports
|
var entity = await db.DailyReports
|
||||||
|
.Where(x => x.IdWell == idWell)
|
||||||
.OrderByDescending(x => x.StartDate)
|
.OrderByDescending(x => x.StartDate)
|
||||||
.FirstOrDefaultAsync(r => r.IdWell == idWell &&
|
.FirstOrDefaultAsync(r => r.StartDate <= dateOffset, token);
|
||||||
r.StartDate.Year <= dateOffset.Year &&
|
|
||||||
r.StartDate.DayOfYear <= dateOffset.DayOfYear, token);
|
|
||||||
|
|
||||||
if (entity is null)
|
if (entity is null)
|
||||||
return null;
|
return new BhaDto();
|
||||||
|
|
||||||
var dto = Convert(entity);
|
var dto = Convert(entity);
|
||||||
return dto?.Bha;
|
return dto.Bha;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<TimeBalanceDto> MakeTimeBalanceAsync(int idWell, DateTime date, CancellationToken token)
|
private async Task<TimeBalanceDto> MakeTimeBalanceAsync(int idWell, DateTime date, CancellationToken token)
|
||||||
|
Loading…
Reference in New Issue
Block a user