From d671ea8ec8658da21990d5418c981d74f6015045 Mon Sep 17 00:00:00 2001 From: liuxiaolong <736321739@qq.com> Date: 星期三, 11 十二月 2019 11:50:43 +0800 Subject: [PATCH] add conf path --- esutil/EsClient.go | 47 ++++++++++++++++++++++++++--------------------- 1 files changed, 26 insertions(+), 21 deletions(-) diff --git a/esutil/EsClient.go b/esutil/EsClient.go index 15487b2..bc1e81f 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{}) { @@ -115,12 +115,12 @@ source["ageDescription"] = getAgeDesc(source["Age"]) source["videoNum"] = getVideoUrl(source) - picDate := source["picDate"].(string) - lastIdx := strings.LastIndex(picDate,":") - picDateStr := picDate[:lastIdx] - if err == nil { - source["picDate"] = picDateStr - } + //picDate := source["picDate"].(string) + //lastIdx := strings.LastIndex(picDate,":") + //picDateStr := picDate[:lastIdx] + //if err == nil { + // source["picDate"] = picDateStr + //} baseInfo := getSourceBaseInfo(source) source["baseInfo"] = baseInfo @@ -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,41 @@ 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" + } else { + preSec = strconv.Itoa(sec) + } 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)) + if err != nil { log.Log.Errorln(err) return nil -- Gitblit v1.8.0