搭建消息告警模块以及跨网推送服务,支持企微,飞书,钉钉通知

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