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;
///
/// 班次规则仓储
///
public class ShiftRuleRepository : AppRepositoryBase, IShiftRuleRepository
{
public ShiftRuleRepository(UnitOfWorkManagerCloud uowm) : base(uowm)
{
}
///
/// 获取适用于特定人员、日期和班次的排班规则
///
public async Task> 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();
}
}