From 89a3b406aabf07ba6faf0b6eb2a0c147d62b75d5 Mon Sep 17 00:00:00 2001 From: liuxiaolong <liuxiaolong@aiotlink.com> Date: 星期二, 28 七月 2020 19:08:22 +0800 Subject: [PATCH] add log --- esutil/EsClient.go | 23 ++++++++++++++++++++++- 1 files changed, 22 insertions(+), 1 deletions(-) diff --git a/esutil/EsClient.go b/esutil/EsClient.go index 13dba91..ddadef7 100644 --- a/esutil/EsClient.go +++ b/esutil/EsClient.go @@ -98,6 +98,22 @@ if !exist { continue } + alarmRules, exist := source["alarmRules"] + if exist { + fmt.Println("exist alarmRules") + if alarmB,ae := json.Marshal(alarmRules);ae ==nil { + var alarmRArr []AlarmRule + if ae = json.Unmarshal(alarmB, &alarmRArr);ae ==nil && len(alarmRArr) >0 { + d["alarmLevel"] = alarmRArr[0].AlarmLevel + } else { + fmt.Println("unmarshal ae:", ae) + } + } else { + fmt.Println("ae:", ae) + } + } else { + d["alarmLevel"] = "" + } pmArr := pmax.([]interface{}) if len(pmArr) > 0 { d["picMaxUrl"] = pmArr[0] @@ -160,6 +176,11 @@ } else { return nil, dat } +} + +type AlarmRule struct { + GroupId string `json:"groupId"` + AlarmLevel string `json:"alarmLevel"` } type TargetInfo struct { @@ -280,7 +301,7 @@ mustNotStr = strings.Join(mustNotArr, ",") } param := "{\"query\":{\"bool\":{\"filter\":["+filterStr+"],\"must_not\":["+mustNotStr+"]}},\"size\":\""+sizeStr+"\",\"sort\":[{\"picDate\":{\"order\":\"desc\"}}]," + - "\"_source\":{\"includes\":[\"cameraAddr\",\"baseInfo\",\"targetInfo\",\"content\",\"id\",\"picMaxUrl\",\"picDate\",\"showLabels\",\"taskName\",\"sdkName\",\"videoUrl\"],\"excludes\":[\"*.feature\",\"*.attachTarget\",\"*.targetLocation\",\"alarmRules\"]}" + + "\"_source\":{\"includes\":[\"cameraAddr\",\"baseInfo\",\"targetInfo\",\"content\",\"id\",\"picMaxUrl\",\"picDate\",\"showLabels\",\"taskName\",\"sdkName\",\"videoUrl\",\"alarmRules\"],\"excludes\":[\"*.feature\",\"*.attachTarget\",\"*.targetLocation\",\"alarmRules\"]}" + "}" err, tokenRes := GetEsDataReq(url, param, true) -- Gitblit v1.8.0