add cameraIds to AggregateTaskList
| | |
| | | } |
| | | |
| | | //聚合任务列表,taskId+taskName |
| | | func AggregateTaskList(serverIp string, serverPort string, indexName string, analyServerId string) (sources []map[string]interface{}, err error) { |
| | | func AggregateTaskList(serverIp string, serverPort string, indexName string, analyServerId string, cameraIds []string) (sources []map[string]interface{}, err error) { |
| | | url := "http://" + serverIp + ":" + serverPort + |
| | | "/" + indexName + "/_search" |
| | | serverFilterStr := "" |
| | | cameIdFilterStr := "" |
| | | if cameraIds != nil && len(cameraIds) > 0 { |
| | | cameIdsStr := strings.Replace(strings.Trim(fmt.Sprint(cameraIds), "[]"), " ", "\",\"", -1) |
| | | cameIdFilterStr = `,{ |
| | | "term": { |
| | | "cameraId": "` + cameIdsStr + `" |
| | | } |
| | | }` |
| | | } |
| | | if analyServerId != "" { |
| | | serverFilterStr = `, |
| | | "query": { |
| | |
| | | { |
| | | "term": { |
| | | "analyServerId": "` + analyServerId + `" |
| | | } |
| | | } |
| | | } |
| | | ` + cameIdFilterStr + ` |
| | | ] |
| | | } |
| | | }` |
| | |
| | | if !ok { |
| | | return -1, errors.New("first total change error!") |
| | | } |
| | | tmp := middle["total"].(float64) |
| | | total = int(tmp) |
| | | |
| | | tmp,b := middle["total"].(map[string]interface{}) |
| | | if b != true { |
| | | v := middle["total"].(float64) |
| | | t := int(v) |
| | | return t,nil |
| | | } |
| | | value := tmp["value"].(float64) |
| | | total = int(value) |
| | | return total, nil |
| | | } |
| | | |