From f7646b2f4dab0ac25d64934b0c4a7d4c5be33e34 Mon Sep 17 00:00:00 2001 From: liuxiaolong <736321739@qq.com> Date: 星期一, 04 十一月 2019 14:12:26 +0800 Subject: [PATCH] add log --- esutil/EsClient.go | 21 +++++++++++---------- 1 files changed, 11 insertions(+), 10 deletions(-) diff --git a/esutil/EsClient.go b/esutil/EsClient.go index 7d46d06..de71523 100644 --- a/esutil/EsClient.go +++ b/esutil/EsClient.go @@ -12,7 +12,7 @@ "strings" "sync" "time" - "andriodServer/config" + "andriodServer/extend/config" log "andriodServer/log" ) @@ -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,13 +378,14 @@ 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, ",") } + log.Log.Infoln("filterArr:", filterStr) prama := "{\"query\":{\"bool\":{\"filter\":["+filterStr+"]}},\"size\":\""+sizeStr+"\",\"sort\":[{\"picDate\":{\"order\":\"desc\"}}]," + "\"_source\":[\"baseInfo\",\"Gender\",\"BaseName\",\"Age\",\"personId\",\"personPicUrl\",\"indeviceName\",\"imgKey\",\"sdkType\",\"ageDescription\",\"indeviceid\",\"content\",\"Id\",\"picAddress\",\"picMaxUrl\",\"picDate\",\"Race\",\"videoNum\",\"picSmUrl\",\"taskName\",\"personIsHub\",\"idcard\",\"videoIp\",\"videoReqNum\"]" + "}" -- Gitblit v1.8.0