From 8bd4b3ac2ad0848660d82d07a71d9de9fb80535d Mon Sep 17 00:00:00 2001
From: sunty <1172534965@qq.com>
Date: 星期五, 26 七月 2019 10:45:26 +0800
Subject: [PATCH] add GetAllLocalVideopersonsId

---
 EsApi.go |   84 ++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 84 insertions(+), 0 deletions(-)

diff --git a/EsApi.go b/EsApi.go
index 4aff237..850fdf5 100644
--- a/EsApi.go
+++ b/EsApi.go
@@ -216,4 +216,88 @@
         return
     }
     return statu
+}
+
+//鑾峰彇褰撳墠鑺傜偣鎶撴媿搴撴墍鏈変汉鍛業D
+func GetAllLocalVideopersonsId(compareArgs  protomsg.CompareArgs,indexName string, serverIp string, serverPort string) (capturetable []string) {
+    queryStr := ""
+    queryBody := compareArgs.InputValue
+    //妫�绱㈡
+    if queryBody != "" {
+        queryStr = "\"must\":[{\"multi_match\":{\"query\":\"" + queryBody + "\",\"fields\":[\"alarmRules.alarmLevel^1.5\",\"ageDescription^1.5\",\"taskName^1.5\",\"baseInfo.tableName^1.5\",\"sex^2.0\",\"race^2.0\",\"content^1.0\",\"baseInfo.idCard^1.8\",\"cameraAddr^1.0\"]," +
+            "\"type\":\"cross_fields\",\"operator\":\"OR\",\"slop\":0,\"prefix_length\":0,\"max_expansions\":50,\"zero_terms_query\":\"NONE\",\"auto_generate_synonyms_phrase_query\":true,\"fuzzy_transpositions\":true,\"boost\":1}}],"
+    }
+    gteDate := compareArgs.SearchTime[0]
+    lteDate := compareArgs.SearchTime[1]
+    //鍒ゆ柇浠诲姟ID
+    taskIdStr := ""
+    taskId := compareArgs.Tasks
+    if taskId != nil && len(taskId) > 0 {
+        esTaskId := strings.Replace(strings.Trim(fmt.Sprint(taskId), "[]"), " ", "\",\"", -1)
+        taskIdStr = "{\"terms\":{\"taskId\":[\"" + esTaskId + "\"]}},"
+    }
+    //鍒ゆ柇鎽勫儚鏈篒D
+    cameraIdStr := ""
+    cameraId := compareArgs.TreeNodes
+    if cameraId != nil && len(cameraId) > 0 {
+        esCameraId := strings.Replace(strings.Trim(fmt.Sprint(cameraId), "[]"), " ", "\",\"", -1)
+        cameraIdStr = "{\"terms\":{\"cameraId\":[\"" + esCameraId + "\"]}},"
+    }
+
+    //鍒ゆ柇搴撹〃ID
+    tableId := compareArgs.Tabs
+    esTableId := ""
+    esTableIdStr := ""
+    if tableId != nil && len(tableId) > 0 {
+        esTableId = strings.Replace(strings.Trim(fmt.Sprint(tableId), "[]"), " ", "\",\"", -1)
+        esTableIdStr = "{\"terms\":{\"baseInfo.tableId\":[\"" + esTableId + "\"]}},"
+    }
+    isCollectStr := ""
+    isCollect := compareArgs.Collection
+    if isCollect != "" {
+        isCollectStr = "{\"term\":{\"isCollect\":\"" + isCollect + "\"}},"
+    }
+
+    //浣跨敤es搴曞眰鏈哄埗澶勭悊鍒嗛〉
+
+
+    analyServerId := compareArgs.AnalyServerId
+    if analyServerId == "" {
+        fmt.Println("no analyServerId")
+        return
+    }
+    analyServerFilterStr := "{\"term\":{\"analyServerId\":\"" + analyServerId + "\"}},"
+
+    //璇锋眰澶�
+    url := "http://" + serverIp + ":" + serverPort +
+        "/" + indexName + "/_search?search_type=dfs_query_then_fetch"
+
+    //璇锋眰浣�
+    prama := "{" +
+        "\"size\":\"100000000\"," +
+        "\"query\":{\"bool\":{" + queryStr +
+        "\"filter\":[" +
+        cameraIdStr +
+        taskIdStr +
+        isCollectStr +
+        esTableIdStr +
+        analyServerFilterStr +
+        "{\"range\":{\"picDate\":{\"from\":\"" + gteDate + "\",\"to\":\"" + lteDate + "\",\"include_lower\":true,\"include_upper\":true,\"boost\":1}}}]}}," +
+        "\"_source\":[\"id\"]" +
+        "}"
+    fmt.Println(url)
+    fmt.Println(prama)
+    buf, err := EsReq("POST", url,[]byte(prama))
+    if err != nil {
+        fmt.Println("http request videoUrlInfo info is err!")
+        return
+    }
+    sources, err := Sourcelist(buf)
+    if err != nil {
+        return
+    }
+    for _, source := range  sources{
+        capturetable = append(capturetable, source["id"].(string))
+    }
+    return capturetable
 }
\ No newline at end of file

--
Gitblit v1.8.0