paiban/NPP.SmartSchedue.Api/Repositories/Time/ShiftRuleRepository.cs
Asoka.Wang 21f044712c 1
2025-08-27 18:39:19 +08:00

31 lines
1.0 KiB
C#

using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using NPP.SmartSchedue.Api.Contracts;
using NPP.SmartSchedue.Api.Contracts.Domain.Time;
using NPP.SmartSchedue.Api.Core.Repositories;
using ZhonTai.Admin.Core.Db.Transaction;
namespace NPP.SmartSchedue.Api.Repositories.Time;
/// <summary>
/// 班次规则仓储
/// </summary>
public class ShiftRuleRepository : AppRepositoryBase<ShiftRuleEntity>, IShiftRuleRepository
{
public ShiftRuleRepository(UnitOfWorkManagerCloud uowm) : base(uowm)
{
}
/// <summary>
/// 获取适用于特定人员、日期和班次的排班规则
/// </summary>
public async Task<List<ShiftRuleEntity>> GetApplicableRulesAsync(long personnelId, DateTime targetDate, long? shiftId)
{
return await Select
.Where(r => r.IsEnabled)
.Where(r => r.EffectiveStartTime == null || r.EffectiveStartTime <= targetDate)
.Where(r => r.EffectiveEndTime == null || r.EffectiveEndTime >= targetDate)
.ToListAsync();
}
}