| | |
| | | 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] |
| | |
| | | } else { |
| | | return nil, dat |
| | | } |
| | | } |
| | | |
| | | type AlarmRule struct { |
| | | GroupId string `json:"groupId"` |
| | | AlarmLevel string `json:"alarmLevel"` |
| | | } |
| | | |
| | | type TargetInfo struct { |
| | |
| | | preSec = strconv.Itoa(sec) |
| | | } |
| | | var filterArr []string |
| | | var mustNotArr []string |
| | | //是否查报警数据 |
| | | if ishub == "hub" { |
| | | filterArr = append(filterArr,"{\"term\":{\"alarmRules.alarmLevel.raw\":\"二级\"}}") |
| | | mustNotArr = append(mustNotArr,"{\"term\":{\"alarmRules.alarmLevel.raw\":\"五级\"}}") |
| | | } |
| | | |
| | | filterArr = append(filterArr, "{\"range\":{\"picDate\":{\"gte\":\"now+8h-"+preSec+"s\",\"lt\":\"now+8h\"}}}") |
| | | |
| | | filterStr := "" |
| | | mustNotStr := "" |
| | | if len(filterArr) >0 { |
| | | filterStr = strings.Join(filterArr, ",") |
| | | } |
| | | param := "{\"query\":{\"bool\":{\"filter\":["+filterStr+"]}},\"size\":\""+sizeStr+"\",\"sort\":[{\"picDate\":{\"order\":\"desc\"}}]," + |
| | | "\"_source\":{\"includes\":[\"cameraAddr\",\"baseInfo\",\"targetInfo\",\"content\",\"id\",\"picMaxUrl\",\"picDate\",\"showLabels\",\"taskName\",\"sdkName\",\"videoUrl\"],\"excludes\":[\"*.feature\",\"*.attachTarget\",\"*.targetLocation\",\"alarmRules\"]}" + |
| | | if len(mustNotArr) > 0 { |
| | | 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\",\"alarmRules\"],\"excludes\":[\"*.feature\",\"*.attachTarget\",\"*.targetLocation\",\"alarmRules\"]}" + |
| | | "}" |
| | | err, tokenRes := GetEsDataReq(url, param, true) |
| | | |