using System.Collections.Generic;
using System.Threading.Tasks;
using NPP.SmartSchedue.Api.Contracts;
using NPP.SmartSchedue.Api.Contracts.Domain.Personnel;
using NPP.SmartSchedue.Api.Core.Repositories;
using ZhonTai.Admin.Core.Db.Transaction;

namespace NPP.SmartSchedue.Api.Repositories.Personnel;

/// <summary>
/// 人员资质绑定仓储
/// </summary>
public class PersonnelQualificationRepository : AppRepositoryBase<PersonnelQualificationEntity>, IPersonnelQualificationRepository
{
    public PersonnelQualificationRepository(UnitOfWorkManagerCloud uowm) : base(uowm)
    {
    }

    /// <summary>
    /// 根据工序ID获取符合资质要求的人员
    /// </summary>
    public async Task<List<PersonnelQualificationEntity>> GetQualifiedPersonnelByProcessAsync(long processId)
    {
        // TODO: 实现根据工序资质要求查询人员的逻辑
        // 这里需要关联工序表查询资质要求，然后匹配人员资质
        return await Select
            .Where(pq => pq.IsActive)
            .Where(pq => pq.ExpiryDate == null || pq.ExpiryDate > System.DateTime.Now)
            .ToListAsync();
    }
} 