CreateDeviceThresholdAlarm
UpdateDeviceThresholdAlarm CreateAreaThresholdAlarm UpdateAreaThresholdAlarm
This commit is contained in:
@@ -14,11 +14,12 @@ import (
|
||||
|
||||
// AreaThresholdCheckParams 定义了区域阈值检查任务的参数
|
||||
type AreaThresholdCheckParams struct {
|
||||
AreaControllerID uint `json:"area_controller_id"` // 区域主控ID
|
||||
SensorType models.SensorType `json:"sensor_type"` // 传感器类型
|
||||
Thresholds float64 `json:"thresholds"` // 阈值
|
||||
Operator models.Operator `json:"operator"` // 操作符
|
||||
ExcludeDeviceIDs []uint `json:"exclude_device_ids"` // 排除的传感器ID
|
||||
AreaControllerID uint `json:"area_controller_id"` // 区域主控ID
|
||||
SensorType models.SensorType `json:"sensor_type"` // 传感器类型
|
||||
Thresholds float64 `json:"thresholds"` // 阈值
|
||||
Operator models.Operator `json:"operator"` // 操作符
|
||||
Level models.SeverityLevel `json:"level"` // 告警级别
|
||||
ExcludeDeviceIDs []uint `json:"exclude_device_ids"` // 排除的传感器ID
|
||||
}
|
||||
|
||||
// AreaThresholdCheckTask 是一个任务,用于检查区域阈值并触发告警, 区域主控下的所有没有独立校验任务的设备都会受到此任务的检查
|
||||
@@ -78,6 +79,7 @@ func (a *AreaThresholdCheckTask) Execute(ctx context.Context) error {
|
||||
DeviceID: device.ID,
|
||||
SensorType: a.params.SensorType,
|
||||
Thresholds: a.params.Thresholds,
|
||||
Level: a.params.Level,
|
||||
Operator: a.params.Operator,
|
||||
})
|
||||
if err != nil {
|
||||
@@ -150,6 +152,9 @@ func (a *AreaThresholdCheckTask) parseParameters(ctx context.Context) error {
|
||||
if params.AreaControllerID == 0 {
|
||||
err = fmt.Errorf("任务 %v: 未配置区域主控ID", a.taskLog.TaskID)
|
||||
}
|
||||
if params.Level == "" {
|
||||
params.Level = models.WarnLevel
|
||||
}
|
||||
if params.ExcludeDeviceIDs == nil {
|
||||
params.ExcludeDeviceIDs = []uint{}
|
||||
}
|
||||
|
||||
@@ -14,10 +14,11 @@ import (
|
||||
)
|
||||
|
||||
type DeviceThresholdCheckParams struct {
|
||||
DeviceID uint `json:"device_id"` // 设备ID
|
||||
SensorType models.SensorType `json:"sensor_type"` // 传感器类型
|
||||
Thresholds float64 `json:"thresholds"` // 阈值
|
||||
Operator models.Operator `json:"operator"` // 操作符
|
||||
DeviceID uint `json:"device_id"` // 设备ID
|
||||
SensorType models.SensorType `json:"sensor_type"` // 传感器类型
|
||||
Thresholds float64 `json:"thresholds"` // 阈值
|
||||
Operator models.Operator `json:"operator"` // 操作符
|
||||
Level models.SeverityLevel `json:"level"` // 告警等级
|
||||
}
|
||||
|
||||
// DeviceThresholdCheckTask 是一个任务,用于检查设备传感器数据是否满足阈值条件。
|
||||
@@ -99,7 +100,7 @@ func (d *DeviceThresholdCheckTask) Execute(ctx context.Context) error {
|
||||
AlarmCode: alarmCode,
|
||||
AlarmSummary: summary,
|
||||
AlarmDetails: details,
|
||||
Level: models.WarnLevel, // 默认告警等级,可后续根据需求调整
|
||||
Level: d.params.Level,
|
||||
TriggerTime: time.Now(),
|
||||
}
|
||||
|
||||
@@ -172,6 +173,9 @@ func (d *DeviceThresholdCheckTask) parseParameters(ctx context.Context) error {
|
||||
if params.DeviceID == 0 {
|
||||
err = fmt.Errorf("任务 %v: 未配置设备ID", d.taskLog.TaskID)
|
||||
}
|
||||
if params.Level == "" {
|
||||
params.Level = models.WarnLevel
|
||||
}
|
||||
|
||||
d.params = params
|
||||
|
||||
|
||||
Reference in New Issue
Block a user