Skip to content
This repository has been archived by the owner on Nov 8, 2023. It is now read-only.

Commit

Permalink
Merge pull request ThingsPanel#222 from November-12/main
Browse files Browse the repository at this point in the history
场景支持告警
  • Loading branch information
November-12 authored Sep 27, 2023
2 parents 3ae2ce9 + f1ab1f2 commit 821be04
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion services/tp_scenario_action_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,36 @@ func (*TpScenarioActionService) ExecuteScenarioAction(scenarioStrategyId string,
scenarioLog.ProcessResult = "2"
}
} else if scenarioAction.ActionType == "3" {
// 触发告警
scenarioLogDetail.ActionType = "3"
instructMap := make(map[string]string)
err := json.Unmarshal([]byte(scenarioAction.Instruct), &instructMap)
if err != nil {
scenarioLogDetail.ProcessDescription = "instruct:" + err.Error()
scenarioLogDetail.ProcessResult = "2"
} else {
if _, ok := instructMap["warning_strategy_id"]; ok {
var notification TpNotificationService
notification.ExecuteNotification(instructMap["warning_strategy_id"], "", "执行激活", "执行激活")
if err != nil {
scenarioLogDetail.ProcessDescription = "instruct:" + err.Error()
scenarioLogDetail.ProcessResult = "2"
}
} else {
scenarioLogDetail.ProcessDescription = "instruct:参数错误"
scenarioLogDetail.ProcessResult = "2"
}
}
//记录日志
scenarioLogDetail.ScenarioLogId = scenarioLog.Id
_, err = scenarioLogDetailService.AddTpScenarioLogDetail(scenarioLogDetail)
if err != nil {
logs.Error(result.Error)
}
if scenarioLogDetail.ProcessResult == "2" {
scenarioLog.ProcessDescription = "执行中有失败,请查看日志详情"
scenarioLog.ProcessResult = "2"
}

}
}
_, err = scenarioLogService.UpdateTpScenarioLog(scenarioLog)
Expand Down

0 comments on commit 821be04

Please sign in to comment.