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 | 21 ++++++++++++++++++--- 1 files changed, 18 insertions(+), 3 deletions(-) diff --git a/esutil/EsClient.go b/esutil/EsClient.go index be98319..ddadef7 100644 --- a/esutil/EsClient.go +++ b/esutil/EsClient.go @@ -98,9 +98,19 @@ if !exist { continue } - alarmLevel, exist := source["alarmLevel"] + alarmRules, exist := source["alarmRules"] if exist { - d["alarmLevel"] = alarmLevel + 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"] = "" } @@ -166,6 +176,11 @@ } else { return nil, dat } +} + +type AlarmRule struct { + GroupId string `json:"groupId"` + AlarmLevel string `json:"alarmLevel"` } type TargetInfo struct { @@ -286,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