CreateDeviceThresholdAlarm
UpdateDeviceThresholdAlarm CreateAreaThresholdAlarm UpdateAreaThresholdAlarm
This commit is contained in:
@@ -10,13 +10,6 @@ import (
|
||||
"git.huangwc.com/pig/pig-farm-controller/internal/infra/repository"
|
||||
)
|
||||
|
||||
const (
|
||||
// PlanNamePeriodicSystemHealthCheck 是周期性系统健康检查计划的名称
|
||||
PlanNamePeriodicSystemHealthCheck = "周期性系统健康检查"
|
||||
// PlanNameAlarmNotification 是告警通知发送计划的名称
|
||||
PlanNameAlarmNotification = "告警通知发送"
|
||||
)
|
||||
|
||||
// initializeState 在应用启动时准备其初始数据状态。
|
||||
// 它遵循一个严格的顺序:清理 -> 更新 -> 刷新,以确保数据的一致性和正确性。
|
||||
func (app *Application) initializeState(ctx context.Context) error {
|
||||
@@ -121,7 +114,7 @@ func (app *Application) initializePeriodicSystemHealthCheckPlan(ctx context.Cont
|
||||
newTasks = append(newTasks, fullCollectionTask, delayTask)
|
||||
|
||||
// 如果计划已存在,则获取其现有任务并追加到新任务列表后(排除预设任务)
|
||||
if foundExistingPlan, ok := existingPlanMap[PlanNamePeriodicSystemHealthCheck]; ok {
|
||||
if foundExistingPlan, ok := existingPlanMap[models.PlanNamePeriodicSystemHealthCheck]; ok {
|
||||
for _, existingTask := range foundExistingPlan.Tasks {
|
||||
// 排除已预设的全量采集和延时任务
|
||||
if existingTask.Type != models.TaskTypeFullCollection && existingTask.Type != models.TaskTypeWaiting {
|
||||
@@ -136,7 +129,7 @@ func (app *Application) initializePeriodicSystemHealthCheckPlan(ctx context.Cont
|
||||
}
|
||||
|
||||
predefinedPlan := &models.Plan{
|
||||
Name: PlanNamePeriodicSystemHealthCheck,
|
||||
Name: models.PlanNamePeriodicSystemHealthCheck,
|
||||
Description: fmt.Sprintf("这是一个系统预定义的计划, 每 %d 分钟自动触发一次全量数据采集, 并进行阈值校验告警。", app.Config.Collection.Interval),
|
||||
PlanType: models.PlanTypeSystem,
|
||||
ExecutionType: models.PlanExecutionTypeAutomatic,
|
||||
@@ -186,7 +179,7 @@ func (app *Application) initializeAlarmNotificationPlan(ctx context.Context, exi
|
||||
appCtx, logger := logs.Trace(ctx, app.Ctx, "initializeAlarmNotificationPlan")
|
||||
|
||||
predefinedPlan := &models.Plan{
|
||||
Name: PlanNameAlarmNotification,
|
||||
Name: models.PlanNameAlarmNotification,
|
||||
Description: "这是一个系统预定义的计划, 每分钟自动触发一次告警通知发送。",
|
||||
PlanType: models.PlanTypeSystem,
|
||||
ExecutionType: models.PlanExecutionTypeAutomatic,
|
||||
|
||||
Reference in New Issue
Block a user