From a07cb9faca7bd4232a4230399eccb23d4b2acc0d Mon Sep 17 00:00:00 2001
From: liuxiaolong <736321739@qq.com>
Date: 星期一, 04 十一月 2019 16:03:46 +0800
Subject: [PATCH] fix get data
---
esutil/EsClient.go | 32 ++++++++++++++++++--------------
1 files changed, 18 insertions(+), 14 deletions(-)
diff --git a/esutil/EsClient.go b/esutil/EsClient.go
index 15487b2..509cbc3 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,38 +360,40 @@
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"
+ sizeStr = "1000"
} else {
sizeStr = strconv.Itoa(size)
}
-
+ preSec := "10"
+ if sec <=0 {
+ preSec = "10"
+ }
var filterArr []string
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\":\"now+8h-"+preSec+"s\",\"lt\":\"now+8h\"}}}")
+
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\"]" +
"}"
err, tokenRes := GetEsDataReq(url, prama, picurl, true)
- log.Log.InfoInfoln("鏉℃暟:",size,"鑰楁椂锛�",time.Since(startTime))
+ log.Log.Infoln("鏉℃暟:",size,"鑰楁椂锛�",time.Since(startTime))
if err != nil {
log.Log.Errorln(err)
return nil
--
Gitblit v1.8.0