| | |
| | | return |
| | | } |
| | | return statu |
| | | } |
| | | |
| | | //获取当前节点抓拍库所有人员ID |
| | | 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 + "\"]}}," |
| | | } |
| | | //判断摄像机ID |
| | | 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 |
| | | } |