This commit is contained in:
2025-03-06 15:51:05 +08:00
parent 0ae46edcd3
commit daf5d12c23
3 changed files with 23 additions and 2 deletions

View File

@@ -90,7 +90,7 @@ public class WorkGridScheduleService : IWorkGridScheduleService
/// <inheritdoc />
public async Task<List<WorkGridScheduleResponse>> GetListAsync(Guid workGridCode, DateOnly date, WorkGridTimePeriodEnumType? periodType)
{
return await _dbContext.Queryable<WorkGridScheduleEntity>()
var data = await _dbContext.Queryable<WorkGridScheduleEntity>()
.LeftJoin<GainfoEntity>((x, ga) => x.UserCode == ga.Code)
.Where(x => x.WorkGridCode == workGridCode && x.Date == date)
.WhereIF(periodType.HasValue, x => x.PeriodType == periodType)
@@ -102,6 +102,16 @@ public class WorkGridScheduleService : IWorkGridScheduleService
UserName = ga.Name
})
.ToListAsync();
var userCodes = data.Select(x => x.UserCode).ToList();
var maximumConsecutiveUserCodes = await MaximumConsecutiveUserCodesAsync(userCodes, 1, date);
foreach (var item in data)
{
item.MaximumConsecutiveSchedules = maximumConsecutiveUserCodes.FirstOrDefault(x => x.UserCode == item.UserCode);
}
return data;
}
/// <inheritdoc />