using SqlSugar;
using System;
namespace Model.Entity.Inspection
{
///
/// 告警消息(消息告警模块核心表:所有模块的告警统一汇聚于此,支持确认/处理/关闭闭环)
///
public class AlertMessageEntity : BaseEntity
{
#region 溯源信息
///
/// 告警来源(规则引擎/自动巡检/看板/数采/手动等)
///
[SugarColumn(ColumnDescription = "告警来源")]
public AlertSourceEnum Source { get; set; } = AlertSourceEnum.Manual;
///
/// 关联告警规则Id(来源为规则引擎时填写,0表示无)
///
[SugarColumn(ColumnDescription = "关联告警规则Id")]
public long RuleId { get; set; }
///
/// 设备编号
///
[SugarColumn(ColumnDescription = "设备编号", Length = 64, IsNullable = true)]
public string DeviceCode { get; set; }
///
/// 设备名称
///
[SugarColumn(ColumnDescription = "设备名称", Length = 128, IsNullable = true)]
public string DeviceName { get; set; }
///
/// 设备类型(如 TemperatureBox,与规则引擎 DeviceType 对齐)
///
[SugarColumn(ColumnDescription = "设备类型", Length = 64, IsNullable = true)]
public string DeviceType { get; set; }
///
/// 测点/监测指标(如 Temperature、Humidity)
///
[SugarColumn(ColumnDescription = "测点指标", Length = 64, IsNullable = true)]
public string Metric { get; set; }
///
/// 告警类型(超限/离线/通讯故障/巡检异常/自定义)
///
[SugarColumn(ColumnDescription = "告警类型")]
public AlertTypeEnum AlertType { get; set; } = AlertTypeEnum.ThresholdExceed;
#endregion
#region 告警内容
///
/// 告警级别(信息/警告/紧急,与规则引擎三级一致)
///
[SugarColumn(ColumnDescription = "告警级别")]
public AlertLevelEnum AlertLevel { get; set; } = AlertLevelEnum.Info;
///
/// 当前值(触发告警时的实际值)
///
[SugarColumn(ColumnDescription = "当前值", IsNullable = true)]
public double? CurrentValue { get; set; }
///
/// 阈值(规则阈值,可空)
///
[SugarColumn(ColumnDescription = "阈值", IsNullable = true)]
public double? ThresholdValue { get; set; }
///
/// 告警内容描述
///
[SugarColumn(ColumnDescription = "告警内容", Length = 500, IsNullable = true)]
public string Content { get; set; }
///
/// 通知模板编码(预留:对接通知模板模块,空表示使用内置模板)
///
[SugarColumn(ColumnDescription = "通知模板编码", Length = 64, IsNullable = true)]
public string TemplateCode { get; set; }
#endregion
#region 聚合信息(去重合并窗口内累加)
///
/// 触发次数(合并窗口内同设备同测点同类型告警的累计次数)
///
[SugarColumn(ColumnDescription = "触发次数")]
public int TriggerCount { get; set; } = 1;
///
/// 首次告警时间
///
[SugarColumn(ColumnDescription = "首次告警时间")]
public DateTime FirstAlertTime { get; set; }
///
/// 最近告警时间
///
[SugarColumn(ColumnDescription = "最近告警时间")]
public DateTime LastAlertTime { get; set; }
#endregion
#region 闭环信息
///
/// 告警状态(未确认/已确认/已处理/已关闭/已忽略/已转工单)
///
[SugarColumn(ColumnDescription = "告警状态")]
public AlertStatusEnum AlertStatus { get; set; } = AlertStatusEnum.Unacknowledged;
///
/// 确认人
///
[SugarColumn(ColumnDescription = "确认人", Length = 50, IsNullable = true)]
public string AckBy { get; set; }
///
/// 确认时间
///
[SugarColumn(ColumnDescription = "确认时间", IsNullable = true)]
public DateTime? AckTime { get; set; }
///
/// 处理人
///
[SugarColumn(ColumnDescription = "处理人", Length = 50, IsNullable = true)]
public string HandleBy { get; set; }
///
/// 处理时间
///
[SugarColumn(ColumnDescription = "处理时间", IsNullable = true)]
public DateTime? HandleTime { get; set; }
///
/// 处理备注
///
[SugarColumn(ColumnDescription = "处理备注", Length = 500, IsNullable = true)]
public string HandleRemark { get; set; }
///
/// 关联工单Id(预留二期运维工单模块,0表示未转工单)
///
[SugarColumn(ColumnDescription = "关联工单Id")]
public long WorkOrderId { get; set; }
#endregion
}
}