|
@@ -98,6 +98,8 @@ type AlarmMessage struct {
|
|
|
|
|
|
func (t *TempAlarmNode) newAlarmMessage(message *protocol.Message) error {
|
|
|
dataMap := make(map[string]interface{})
|
|
|
+ j := gjson.New(message.Data)
|
|
|
+ dataMap = j.GetMap("status")
|
|
|
var err error
|
|
|
if t.config.FillUserInfo == "true" {
|
|
|
result, err := utils.NewRequest("GET", fmt.Sprintf("%s/%s", "https://app.yongxulvjian.com/iot/v1/devices/", message.MetaData["device_id"].(string)), nil)
|
|
@@ -115,14 +117,14 @@ func (t *TempAlarmNode) newAlarmMessage(message *protocol.Message) error {
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
- j := gjson.New(reqStr)
|
|
|
- if j.GetInt("code") == -1 {
|
|
|
+ r := gjson.New(reqStr)
|
|
|
+ if r.GetInt("code") == -1 {
|
|
|
return nil
|
|
|
}
|
|
|
- dataMap = j.GetMap("data")
|
|
|
- } else {
|
|
|
- j := gjson.New(message.Data)
|
|
|
- dataMap = j.GetMap("status")
|
|
|
+ dataMap["user_name"] = j.GetString("data.user_name")
|
|
|
+ dataMap["device_code"] = j.GetString("data.device_code")
|
|
|
+ dataMap["phone"] = j.GetString("data.phone")
|
|
|
+ dataMap["address"] = j.GetString("data.address")
|
|
|
}
|
|
|
|
|
|
message.AlarmMessage, err = fillTemplate(t.config.MessageTemplate, dataMap)
|
|
@@ -135,9 +137,7 @@ func (t *TempAlarmNode) newAlarmMessage(message *protocol.Message) error {
|
|
|
func (t *TempAlarmNode) evaluateConditions(message *protocol.Message) bool {
|
|
|
deviceId := message.MetaData["device_id"].(string)
|
|
|
// 判断设备类型
|
|
|
-
|
|
|
productKey := message.MetaData["product_key"].(string)
|
|
|
-
|
|
|
if productKey != t.config.ProductKey && productKey != mainCode {
|
|
|
return false
|
|
|
}
|