CreateDeviceThresholdAlarm
UpdateDeviceThresholdAlarm CreateAreaThresholdAlarm UpdateAreaThresholdAlarm
This commit is contained in:
@@ -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