using System;
using System.Collections.Generic;

namespace NPP.SmartSchedue.Api.Contracts.Services.Integration.Models
{
    /// <summary>
    /// 人员工作负载分析
    /// 用于智能分配算法中的人员工作量评估和负载均衡
    /// </summary>
    public class PersonnelWorkloadAnalysis
    {
        /// <summary>
        /// 人员ID
        /// </summary>
        public long PersonnelId { get; set; }

        /// <summary>
        /// 人员姓名
        /// </summary>
        public string PersonnelName { get; set; } = string.Empty;

        /// <summary>
        /// 已分配任务数量
        /// </summary>
        public int AssignedTaskCount { get; set; }

        /// <summary>
        /// 计划工作小时数
        /// </summary>
        public decimal ScheduledWorkHours { get; set; }

        /// <summary>
        /// 工作负载百分比 (0-100)
        /// 相对于标准工作量的百分比
        /// </summary>
        public double WorkloadPercentage { get; set; }

        /// <summary>
        /// 负载状态描述
        /// </summary>
        public string WorkloadStatus { get; set; } = string.Empty;

        /// <summary>
        /// 是否超负荷
        /// </summary>
        public bool IsOverloaded => WorkloadPercentage > 100;

        /// <summary>
        /// 剩余可分配容量
        /// </summary>
        public decimal RemainingCapacity { get; set; }

        /// <summary>
        /// 技能匹配度平均分
        /// </summary>
        public decimal AverageSkillMatchScore { get; set; }

        /// <summary>
        /// 分配的任务列表
        /// </summary>
        public List<AssignedTaskInfo> AssignedTasks { get; set; } = new();

        /// <summary>
        /// 工作时间段分布
        /// Key: 日期, Value: 工作小时数
        /// </summary>
        public Dictionary<DateTime, decimal> DailyWorkHoursDistribution { get; set; } = new();

        /// <summary>
        /// 负载均衡评分 (0-100)
        /// 评估当前负载是否合理均衡
        /// </summary>
        public int LoadBalanceScore { get; set; }

        /// <summary>
        /// 最后更新时间
        /// </summary>
        public DateTime LastUpdated { get; set; } = DateTime.Now;

        public List<DateTime> WorkDates { get; set; }

        /// <summary>
        /// 计算连续工作天数
        /// </summary>
        public int ContinuousWorkDays { get; set; }

        /// <summary>
        /// 总工时
        /// </summary>
        public decimal? TotalEstimatedHours { get; set; }
    }

    /// <summary>
    /// 已分配任务信息
    /// </summary>
    public class AssignedTaskInfo
    {
        /// <summary>
        /// 任务ID
        /// </summary>
        public long TaskId { get; set; }

        /// <summary>
        /// 任务编码
        /// </summary>
        public string TaskCode { get; set; } = string.Empty;

        /// <summary>
        /// 预计工作小时数
        /// </summary>
        public decimal EstimatedWorkHours { get; set; }

        /// <summary>
        /// 任务优先级
        /// </summary>
        public int Priority { get; set; }

        /// <summary>
        /// 计划开始时间
        /// </summary>
        public DateTime ScheduledStartTime { get; set; }

        /// <summary>
        /// 计划结束时间
        /// </summary>
        public DateTime ScheduledEndTime { get; set; }

        /// <summary>
        /// 技能匹配度
        /// </summary>
        public decimal SkillMatchScore { get; set; }
    }
}