| | |
| | | |
| | | //获取当前节点抓拍库所有人员ID |
| | | func GetAllLocalVideopersonsId(compareArgs protomsg.CompareArgs,indexName string, serverIp string, serverPort string) (capturetable []string) { |
| | | ts := time.Now() |
| | | queryStr := "" |
| | | queryBody := compareArgs.InputValue |
| | | //检索框 |
| | |
| | | |
| | | //使用es底层机制处理分页 |
| | | |
| | | |
| | | analyServerId := compareArgs.AnalyServerId |
| | | if analyServerId == "" { |
| | | fmt.Println("no analyServerId") |
| | |
| | | } |
| | | analyServerFilterStr := "{\"term\":{\"analyServerId\":\"" + analyServerId + "\"}}," |
| | | |
| | | //请求头 |
| | | //首次请求头 |
| | | url := "http://" + serverIp + ":" + serverPort + |
| | | "/" + indexName + "/_search?search_type=dfs_query_then_fetch" |
| | | "/" + indexName + "/_search?search_type=dfs_query_then_fetch;scroll=1m" |
| | | |
| | | var lock sync.RWMutex |
| | | var wg sync.WaitGroup |
| | | |
| | | for i := 0; i < 32; i++ { |
| | | //请求体 |
| | | prama := "{" + |
| | | "\"size\":\"100000000\"," + |
| | | "\"slice\":{\"id\":" + strconv.Itoa(i) + ",\"max\":48}," + |
| | | "\"size\":\"1000\"," + |
| | | "\"query\":{\"bool\":{" + queryStr + |
| | | "\"filter\":[" + |
| | | cameraIdStr + |
| | |
| | | "{\"range\":{\"picDate\":{\"from\":\"" + gteDate + "\",\"to\":\"" + lteDate + "\",\"include_lower\":true,\"include_upper\":true,\"boost\":1}}}]}}," + |
| | | "\"_source\":[\"id\"]" + |
| | | "}" |
| | | fmt.Println(url) |
| | | fmt.Println(prama) |
| | | wg.Add(1) |
| | | go func() { |
| | | defer wg.Done() |
| | | |
| | | //fmt.Println(url) |
| | | //fmt.Println(prama) |
| | | buf, err := EsReq("POST", url,[]byte(prama)) |
| | | |
| | | if err != nil { |
| | | fmt.Println("http request videoUrlInfo info is err!") |
| | | fmt.Println(len(capturetable)) |
| | | return |
| | | } |
| | | sources, err := Sourcelist(buf) |
| | | |
| | | sources, err := Sourcelistforscroll(buf) |
| | | |
| | | if err != nil { |
| | | fmt.Println(len(capturetable)) |
| | | return |
| | | } |
| | | for _, source := range sources{ |
| | | for _, source := range sources["sourcelist"].([]map[string]interface{}) { |
| | | capturetable = append(capturetable, source["id"].(string)) |
| | | } |
| | | |
| | | scroll_id := sources["scroll_id"].(string) |
| | | |
| | | //scroll请求头 |
| | | scroll_url := "http://" + serverIp + ":" + serverPort + "/_search/scroll" |
| | | |
| | | for { |
| | | var tmpList []string |
| | | next_scroll_id := "" |
| | | if next_scroll_id != "" { |
| | | scroll_id = next_scroll_id |
| | | } |
| | | jsonDSL := `{ |
| | | "scroll": "1m", |
| | | "scroll_id" : "` + scroll_id + `" |
| | | }` |
| | | //fmt.Println(scroll_url) |
| | | //fmt.Println(jsonDSL) |
| | | buf, err := EsReq("POST", scroll_url, []byte(jsonDSL)) |
| | | |
| | | if err != nil { |
| | | fmt.Println("lenth1: ", len(capturetable)) |
| | | return |
| | | } |
| | | nextSources, err := Sourcelistforscroll(buf) |
| | | |
| | | if nextSources == nil { |
| | | return |
| | | } |
| | | |
| | | nextM := nextSources["sourcelist"].([]map[string]interface{}) |
| | | //fmt.Println("id",nextSources) |
| | | if nextM == nil || len(nextM) == 0 { |
| | | //fmt.Println("lenth: ", len(capturetable)) |
| | | return |
| | | } |
| | | //fmt.Println("id") |
| | | for _, source := range nextM { |
| | | tmpList = append(tmpList, source["id"].(string)) |
| | | } |
| | | //fmt.Println("tmpList: ", len(tmpList)) |
| | | lock.Lock() |
| | | capturetable = append(capturetable, tmpList...) |
| | | lock.Unlock() |
| | | |
| | | next_scroll_id = nextSources["scroll_id"].(string) |
| | | } |
| | | |
| | | |
| | | fmt.Println(len(capturetable)) |
| | | |
| | | }() |
| | | } |
| | | wg.Wait() |
| | | |
| | | //fmt.Println("lenth_all: ", len(capturetable)) |
| | | //fmt.Println("耗时:", time.Since(ts)) |
| | | return capturetable |
| | | } |
| | | |