using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using NPP.SmartSchedue.Api.Contracts.Domain.Work;
using NPP.SmartSchedue.Api.Contracts.Core.Enums;
using ZhonTai.Admin.Core.Repositories;

namespace NPP.SmartSchedue.Api.Contracts.Domain.Work;

/// <summary>
/// 工作任务仓储接口
/// </summary>
public interface IWorkOrderRepository : IRepositoryBase<WorkOrderEntity>
{
    /// <summary>
    /// 根据日期获取工作任务列表
    /// </summary>
    /// <param name="date">日期</param>
    /// <returns>工作任务列表</returns>
    Task<List<WorkOrderEntity>> GetByDateAsync(DateTime date);

    /// <summary>
    /// 根据人员ID和日期范围获取工作任务列表
    /// </summary>
    /// <param name="personnelId">人员ID</param>
    /// <param name="startDate">开始日期</param>
    /// <param name="endDate">结束日期</param>
    /// <returns>工作任务列表</returns>
    Task<List<WorkOrderEntity>> GetByPersonnelAndDateRangeAsync(long personnelId, DateTime startDate, DateTime endDate);

    /// <summary>
    /// 根据状态获取工作任务列表
    /// </summary>
    /// <param name="status">任务状态</param>
    /// <returns>工作任务列表</returns>
    Task<List<WorkOrderEntity>> GetByStatusAsync(WorkOrderStatusEnum status);

    /// <summary>
    /// 根据班次ID获取工作任务列表
    /// </summary>
    /// <param name="shiftId">班次ID</param>
    /// <param name="date">日期</param>
    /// <returns>工作任务列表</returns>
    Task<List<WorkOrderEntity>> GetByShiftAndDateAsync(long shiftId, DateTime date);

    /// <summary>
    /// 根据工序ID获取工作任务列表
    /// </summary>
    /// <param name="processId">工序ID</param>
    /// <param name="startDate">开始日期</param>
    /// <param name="endDate">结束日期</param>
    /// <returns>工作任务列表</returns>
    Task<List<WorkOrderEntity>> GetByProcessAndDateRangeAsync(long processId, DateTime startDate, DateTime endDate);

    /// <summary>
    /// 检查任务代码是否存在
    /// </summary>
    /// <param name="workOrderCode">任务代码</param>
    /// <param name="excludeId">排除的ID</param>
    /// <returns>是否存在</returns>
    Task<bool> ExistsWorkOrderCodeAsync(string workOrderCode, long? excludeId = null);

    /// <summary>
    /// 生成任务代码
    /// </summary>
    /// <param name="projectNumber">项目号</param>
    /// <param name="shiftCode">班次代码</param>
    /// <param name="processCode">工序代码</param>
    /// <returns>任务代码</returns>
    string GenerateWorkOrderCode(string projectNumber, string shiftCode, string processCode);

    /// <summary>
    /// 获取人员在指定日期范围内的任务数量
    /// </summary>
    /// <param name="personnelId">人员ID</param>
    /// <param name="startDate">开始日期</param>
    /// <param name="endDate">结束日期</param>
    /// <returns>任务数量</returns>
    Task<int> GetPersonnelTaskCountByDateRangeAsync(long personnelId, DateTime startDate, DateTime endDate);
} 