using System.Collections.Generic;

namespace CncModels.Dto.Alert
{
    /// <summary>
    /// 告警统计结果（未处理告警分类型统计）
    /// </summary>
    public class AlertStatisticsResponse
    {
        /// <summary>未处理告警总数（前端用 unresolved）</summary>
        public int UnresolvedCount { get; set; }

        /// <summary>按告警类型统计的未处理数量</summary>
        public Dictionary<string, int> UnresolvedByType { get; set; } = new Dictionary<string, int>();

        // 以下为前端 AlertStats 接口需要的扁平字段

        /// <summary>未处理总数（前端字段名 unresolved）</summary>
        public int Unresolved => UnresolvedCount;

        /// <summary>采集失败未处理数</summary>
        public int CollectFail => UnresolvedByType.TryGetValue("collect_fail", out var v) ? v : 0;

        /// <summary>设备离线未处理数</summary>
        public int DeviceOffline => UnresolvedByType.TryGetValue("device_offline", out var v) ? v : 0;

        /// <summary>产量异常未处理数</summary>
        public int ProductionAnomaly => UnresolvedByType.TryGetValue("production_anomaly", out var v) ? v : 0;

        /// <summary>未知设备未处理数</summary>
        public int UnknownDevice => UnresolvedByType.TryGetValue("unknown_device", out var v) ? v : 0;
    }
}
