zhangzengfei
2024-09-29 3737ab3dd0cc753be986638316c96cb3114601e4
db/elastic.go
@@ -34,7 +34,8 @@
   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": {
@@ -50,6 +51,16 @@
                {
                    "term": {
                        "documentNumber": "` + docNumber + `"
                    }
                },
                {
                    "term": {
                        "communityId": "` + communityId + `"
                    }
                },
                {
                    "terms": {
                        "cameraId": ["` + cameraIdsStr + `"]
                    }
                }
            ]
@@ -68,7 +79,8 @@
   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": {
@@ -80,6 +92,16 @@
                            "gte": "now-` + strconv.Itoa(dayGte) + `d/d",
                            "lt": "now-` + strconv.Itoa(dayLt) + `d/d"
                        }
                    }
                },
                {
                    "term": {
                        "communityId": "` + communityId + `"
                    }
                },
                {
                    "terms": {
                        "cameraId": ["` + cameraIdsStr + `"]
                    }
                }
            ]
@@ -316,7 +338,7 @@
   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)