From e7800f02cb0edb6ae0590c81b78ef68611dfd53b Mon Sep 17 00:00:00 2001 From: liuxiaolong <736321739@qq.com> Date: 星期一, 04 十一月 2019 10:23:25 +0800 Subject: [PATCH] 1 sec refresh --- esutil/EsClient.go | 22 +++++++++++----------- 1 files changed, 11 insertions(+), 11 deletions(-) diff --git a/esutil/EsClient.go b/esutil/EsClient.go index c7565ff..cc3c801 100644 --- a/esutil/EsClient.go +++ b/esutil/EsClient.go @@ -12,9 +12,9 @@ "strings" "sync" "time" - "tcpserver/config" + "andriodServer/extend/config" - log "tcpserver/log" + log "andriodServer/log" ) func GetEsDataReq(url string, parama string, picurl string, isSource bool) (error, map[string]interface{}) { @@ -258,6 +258,7 @@ } else { reqUrl = url } + log.Log.Infoln("reqUrl:",reqUrl) paramMap := make(map[string]interface{},0) paramMap["imgKey"] = imgKey @@ -283,6 +284,7 @@ } else { strArr := strings.Split(filePath, "/cut") ngxUrl := config.NgxMap[indeviceId] + log.Log.Infoln("ngxUrl:",ngxUrl) if ngxUrl !="" && len(strArr) >0 { videoUrl = ngxUrl + strArr[1] } @@ -358,15 +360,13 @@ return value[i-1] } -func PostAction(sec int, Eurl string, picurl string, ishub string, size int) []byte { +func PostAction(sec int, Eurl string, picurl string, ishub string, size int, lastT time.Time, curTime time.Time) []byte { + lastTimeStr := lastT.Format("2006-01-02 15:04:05") + curTimeStr := curTime.Format("2006-01-02 15:04:05") index := "videopersons,personaction" url := fmt.Sprintf("%s%s%s", Eurl, index, "/_search") startTime := time.Now() - seccond := strconv.Itoa(sec) - preSec := "" - if sec > 60 { - preSec = "-60s" - } + sizeStr :="" if size <=0 { sizeStr = "100" @@ -378,9 +378,9 @@ if ishub == "hub" { filterArr = append(filterArr,"{\"term\":{\"personIsHub\":\"1\"}}") } - if sec > 60 { - filterArr = append(filterArr, "{\"range\":{\"picDate\":{\"gte\":\"now+8h-" + seccond + "s\",\"lt\":\"now+8h"+preSec+"\"}}}") - } + + filterArr = append(filterArr, "{\"range\":{\"picDate\":{\"gte\":\""+lastTimeStr+"\",\"lt\":\""+curTimeStr+"\"}}}") + filterStr := "" if len(filterArr) >0 { filterStr = strings.Join(filterArr, ",") -- Gitblit v1.8.0