using System;
using System.Collections.Generic;

namespace NPP.SmartSchedue.Api.Contracts.Services.Integration.Output
{
    /// <summary>
    /// 全局分配可行性分析结果
    /// </summary>
    public class GlobalAllocationAnalysisResult
    {
        /// <summary>
        /// 是否可行
        /// </summary>
        public bool IsFeasible { get; set; }

        /// <summary>
        /// 可行性分数（0-100）
        /// </summary>
        public double FeasibilityScore { get; set; }

        /// <summary>
        /// 预估执行时间（秒）
        /// </summary>
        public int EstimatedExecutionTimeSeconds { get; set; }

        /// <summary>
        /// 潜在冲突分析
        /// </summary>
        public List<GlobalPotentialConflictAnalysis> PotentialConflicts { get; set; } = new();

        /// <summary>
        /// 人员资源分析
        /// </summary>
        public GlobalPersonnelResourceAnalysis ResourceAnalysis { get; set; } = new();

        /// <summary>
        /// 约束满足度预估
        /// </summary>
        public GlobalConstraintSatisfactionEstimate ConstraintEstimate { get; set; } = new();

        /// <summary>
        /// 负载均衡预测
        /// </summary>
        public GlobalLoadBalancePrediction LoadBalancePrediction { get; set; } = new();

        /// <summary>
        /// 推荐优化参数
        /// </summary>
        public GlobalRecommendedOptimizationParams RecommendedParams { get; set; } = new();

        /// <summary>
        /// 风险评估
        /// </summary>
        public List<GlobalAllocationRiskFactor> RiskFactors { get; set; } = new();

        /// <summary>
        /// 分配摘要
        /// </summary>
        public string AllocationSummary { get; set; } = string.Empty;
    }

    /// <summary>
    /// 全局潜在冲突分析
    /// </summary>
    public class GlobalPotentialConflictAnalysis
    {
        /// <summary>
        /// 冲突类型
        /// </summary>
        public GlobalConflictType ConflictType { get; set; }

        /// <summary>
        /// 影响的任务数量
        /// </summary>
        public int AffectedTaskCount { get; set; }

        /// <summary>
        /// 影响的人员数量
        /// </summary>
        public int AffectedPersonnelCount { get; set; }

        /// <summary>
        /// 冲突概率（0-1）
        /// </summary>
        public double ConflictProbability { get; set; }

        /// <summary>
        /// 解决难度等级
        /// </summary>
        public GlobalResolutionDifficulty ResolutionDifficulty { get; set; }

        /// <summary>
        /// 建议解决方案
        /// </summary>
        public List<string> SuggestedSolutions { get; set; } = new();
    }

    /// <summary>
    /// 全局人员资源分析
    /// </summary>
    public class GlobalPersonnelResourceAnalysis
    {
        /// <summary>
        /// 总可用人员数
        /// </summary>
        public int TotalAvailablePersonnel { get; set; }

        /// <summary>
        /// 符合资质的人员数
        /// </summary>
        public int QualifiedPersonnelCount { get; set; }

        /// <summary>
        /// 人员-任务匹配度分布
        /// </summary>
        public Dictionary<string, int> MatchQualityDistribution { get; set; } = new();

        /// <summary>
        /// 资源紧张度（0-1）
        /// </summary>
        public double ResourceTension { get; set; }

        /// <summary>
        /// 关键技能瓶颈
        /// </summary>
        public List<GlobalSkillBottleneck> SkillBottlenecks { get; set; } = new();
    }

    /// <summary>
    /// 全局约束满足度预估
    /// </summary>
    public class GlobalConstraintSatisfactionEstimate
    {
        /// <summary>
        /// 硬约束满足率预估
        /// </summary>
        public double HardConstraintSatisfactionRate { get; set; }

        /// <summary>
        /// 班次规则满足率预估
        /// </summary>
        public double ShiftRuleSatisfactionRate { get; set; }

        /// <summary>
        /// 时间冲突风险等级
        /// </summary>
        public GlobalRiskLevel TimeConflictRisk { get; set; }

        /// <summary>
        /// 工作限制违规风险
        /// </summary>
        public GlobalRiskLevel WorkLimitViolationRisk { get; set; }

        /// <summary>
        /// 约束违规详情预测
        /// </summary>
        public List<GlobalConstraintViolationPrediction> ViolationPredictions { get; set; } = new();
    }

    /// <summary>
    /// 全局负载均衡预测
    /// </summary>
    public class GlobalLoadBalancePrediction
    {
        /// <summary>
        /// 预测基尼系数
        /// </summary>
        public double PredictedGiniCoefficient { get; set; }

        /// <summary>
        /// 预测公平性等级
        /// </summary>
        public GlobalFairnessLevel PredictedFairnessLevel { get; set; }

        /// <summary>
        /// 最大负载差异预测
        /// </summary>
        public decimal PredictedMaxLoadDifference { get; set; }

        /// <summary>
        /// 负载分布预测
        /// </summary>
        public Dictionary<long, decimal> PredictedWorkloadDistribution { get; set; } = new();

        /// <summary>
        /// 均衡化难度
        /// </summary>
        public GlobalBalancingDifficulty BalancingDifficulty { get; set; }
    }

    /// <summary>
    /// 全局推荐优化参数
    /// </summary>
    public class GlobalRecommendedOptimizationParams
    {
        /// <summary>
        /// 推荐种群大小
        /// </summary>
        public int RecommendedPopulationSize { get; set; }

        /// <summary>
        /// 推荐迭代次数
        /// </summary>
        public int RecommendedGenerations { get; set; }

        /// <summary>
        /// 推荐权重配置
        /// </summary>
        public Dictionary<string, double> RecommendedWeights { get; set; } = new();

        /// <summary>
        /// 预期执行时间
        /// </summary>
        public int ExpectedExecutionTimeSeconds { get; set; }

        /// <summary>
        /// 参数调整原因
        /// </summary>
        public string RecommendationReason { get; set; } = string.Empty;
    }

    /// <summary>
    /// 全局分配风险因子
    /// </summary>
    public class GlobalAllocationRiskFactor
    {
        /// <summary>
        /// 风险类型
        /// </summary>
        public string RiskType { get; set; } = string.Empty;

        /// <summary>
        /// 风险等级
        /// </summary>
        public GlobalRiskLevel RiskLevel { get; set; }

        /// <summary>
        /// 影响评估
        /// </summary>
        public string ImpactAssessment { get; set; } = string.Empty;

        /// <summary>
        /// 缓解建议
        /// </summary>
        public List<string> MitigationSuggestions { get; set; } = new();

        /// <summary>
        /// 风险概率（0-1）
        /// </summary>
        public double RiskProbability { get; set; }
    }

    /// <summary>
    /// 全局技能瓶颈
    /// </summary>
    public class GlobalSkillBottleneck
    {
        /// <summary>
        /// 技能/资质名称
        /// </summary>
        public string SkillName { get; set; } = string.Empty;

        /// <summary>
        /// 需求任务数
        /// </summary>
        public int RequiredTaskCount { get; set; }

        /// <summary>
        /// 可用人员数
        /// </summary>
        public int AvailablePersonnelCount { get; set; }

        /// <summary>
        /// 供需比率
        /// </summary>
        public double SupplyDemandRatio { get; set; }

        /// <summary>
        /// 瓶颈严重程度
        /// </summary>
        public GlobalBottleneckSeverity Severity { get; set; }
    }

    /// <summary>
    /// 全局约束违规预测
    /// </summary>
    public class GlobalConstraintViolationPrediction
    {
        /// <summary>
        /// 约束类型
        /// </summary>
        public string ConstraintType { get; set; } = string.Empty;

        /// <summary>
        /// 预测违规概率
        /// </summary>
        public double ViolationProbability { get; set; }

        /// <summary>
        /// 影响的任务数
        /// </summary>
        public int AffectedTaskCount { get; set; }

        /// <summary>
        /// 预防措施建议
        /// </summary>
        public List<string> PreventionSuggestions { get; set; } = new();
    }

    /// <summary>
    /// 全局解决难度枚举
    /// </summary>
    public enum GlobalResolutionDifficulty
    {
        /// <summary>
        /// 容易解决
        /// </summary>
        Easy = 1,

        /// <summary>
        /// 中等难度
        /// </summary>
        Medium = 2,

        /// <summary>
        /// 困难
        /// </summary>
        Hard = 3,

        /// <summary>
        /// 极难解决
        /// </summary>
        VeryHard = 4
    }

    /// <summary>
    /// 全局风险等级枚举
    /// </summary>
    public enum GlobalRiskLevel
    {
        /// <summary>
        /// 低风险
        /// </summary>
        Low = 1,

        /// <summary>
        /// 中等风险
        /// </summary>
        Medium = 2,

        /// <summary>
        /// 高风险
        /// </summary>
        High = 3,

        /// <summary>
        /// 极高风险
        /// </summary>
        Critical = 4
    }

    /// <summary>
    /// 全局均衡化难度枚举
    /// </summary>
    public enum GlobalBalancingDifficulty
    {
        /// <summary>
        /// 容易均衡
        /// </summary>
        Easy = 1,

        /// <summary>
        /// 中等难度
        /// </summary>
        Medium = 2,

        /// <summary>
        /// 困难
        /// </summary>
        Hard = 3,

        /// <summary>
        /// 无法均衡
        /// </summary>
        Impossible = 4
    }

    /// <summary>
    /// 全局瓶颈严重程度枚举
    /// </summary>
    public enum GlobalBottleneckSeverity
    {
        /// <summary>
        /// 轻微瓶颈
        /// </summary>
        Minor = 1,

        /// <summary>
        /// 中等瓶颈
        /// </summary>
        Moderate = 2,

        /// <summary>
        /// 严重瓶颈
        /// </summary>
        Severe = 3,

        /// <summary>
        /// 关键瓶颈
        /// </summary>
        Critical = 4
    }
}