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 | 19 +++++++++---------- 1 files changed, 9 insertions(+), 10 deletions(-) diff --git a/esutil/EsClient.go b/esutil/EsClient.go index 6bb4c56..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" ) @@ -360,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" @@ -380,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