| | |
| | | return captureInfos, nil |
| | | } |
| | | |
| | | func QueryTimesByDocNumberDays(days int, docNumber string) (int, error) { |
| | | func QueryTimesByDocNumberDays(docNumber string, communityId string, cameraIds []string, days int) (int, error) { |
| | | cameraIdsStr := strings.Replace(strings.Trim(fmt.Sprint(cameraIds), "[]"), " ", "\",\"", -1) |
| | | esURL := "http://" + config.Elastic.Host + ":" + config.Elastic.Port + "/" + config.Elastic.Index + "/_search" |
| | | queryDSL := `{ |
| | | "query": { |
| | |
| | | { |
| | | "term": { |
| | | "documentNumber": "` + docNumber + `" |
| | | } |
| | | }, |
| | | { |
| | | "term": { |
| | | "communityId": "` + communityId + `" |
| | | } |
| | | }, |
| | | { |
| | | "terms": { |
| | | "cameraId": ["` + cameraIdsStr + `"] |
| | | } |
| | | } |
| | | ] |
| | |
| | | return total, nil |
| | | } |
| | | |
| | | func QueryLastIdByDayRange(dayGte, dayLt int) (map[string]string, error) { |
| | | func QueryLastIdByDayRange(communityId string, cameraIds []string, dayGte, dayLt int) (map[string]string, error) { |
| | | cameraIdsStr := strings.Replace(strings.Trim(fmt.Sprint(cameraIds), "[]"), " ", "\",\"", -1) |
| | | esURL := "http://" + config.Elastic.Host + ":" + config.Elastic.Port + "/" + config.Elastic.Index + "/_search" |
| | | queryDSL := `{ |
| | | "query": { |
| | |
| | | "gte": "now-` + strconv.Itoa(dayGte) + `d/d", |
| | | "lt": "now-` + strconv.Itoa(dayLt) + `d/d" |
| | | } |
| | | } |
| | | }, |
| | | { |
| | | "term": { |
| | | "communityId": "` + communityId + `" |
| | | } |
| | | }, |
| | | { |
| | | "terms": { |
| | | "cameraId": ["` + cameraIdsStr + `"] |
| | | } |
| | | } |
| | | ] |
| | |
| | | return false, nil |
| | | } |
| | | |
| | | func Query1MDataByCommunityId(communityId string, documentNumber []string, days int) ([]CaptureInfo, error) { |
| | | func QueryByTimeThresholdDataByCommunityId(communityId string, documentNumber []string, days int) ([]CaptureInfo, error) { |
| | | //fmt.Println(config.Elastic.DocumentSize) |
| | | //fmt.Println(config.Elastic.TopHitsSize) |
| | | documentNumberStr := strings.Replace(strings.Trim(fmt.Sprint(documentNumber), "[]"), " ", "\",\"", -1) |