sunty
2021-01-14 c6ae506a28e9ce6463822bfea5369856acf980e0
add cameraIds to AggregateTaskList
2个文件已修改
25 ■■■■ 已修改文件
EsApi.go 14 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
EsClient.go 11 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
EsApi.go
@@ -1276,10 +1276,19 @@
}
//聚合任务列表,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": {
@@ -1288,8 +1297,9 @@
                {
                "term": {
                "analyServerId": "` + analyServerId + `"
                    }
                }
                }
                 ` + cameIdFilterStr + `
            ]
            }
        }`
EsClient.go
@@ -1033,8 +1033,15 @@
    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
}