规则链结构优化

This commit is contained in:
XM-GO
2023-08-25 17:41:59 +08:00
parent fac575ac7b
commit e436f3b7ad
37 changed files with 254 additions and 157 deletions

View File

@@ -29,16 +29,16 @@ func (f clearAlarmNodeFactory) Create(id string, meta Metadata) (Node, error) {
return decodePath(meta, node)
}
func (n *clearAlarmNode) Handle(msg message.Message) error {
logrus.Infof("%s handle message '%s'", n.Name(), msg.GetType())
func (n *clearAlarmNode) Handle(msg *message.Message) error {
logrus.Infof("%s handle message '%s'", n.Name(), msg.MsgType)
cleared := n.GetLinkedNode("Cleared")
failure := n.GetLinkedNode("Failure")
alarm := services.DeviceAlarmModelDao.FindOneByType(msg.GetMetadata().GetKeyValue("deviceId").(string), n.AlarmType, "0")
alarm := services.DeviceAlarmModelDao.FindOneByType(msg.Metadata.GetValue("deviceId").(string), n.AlarmType, "0")
if alarm.DeviceId != "" {
log.Println("清除告警")
alarm.State = global.CLEARED
marshal, _ := json.Marshal(msg.GetMsg())
marshal, _ := json.Marshal(msg.Msg)
alarm.Details = string(marshal)
err := services.DeviceAlarmModelDao.Update(*alarm)
if err != nil {