| | |
| | | "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{}) { |
| | |
| | | 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 |
| | |
| | | } else { |
| | | reqUrl = url |
| | | } |
| | | log.Log.Infoln("reqUrl:",reqUrl) |
| | | |
| | | paramMap := make(map[string]interface{},0) |
| | | paramMap["imgKey"] = imgKey |
| | |
| | | } else { |
| | | strArr := strings.Split(filePath, "/cut") |
| | | ngxUrl := config.NgxMap[indeviceId] |
| | | log.Log.Infoln("ngxUrl:",ngxUrl) |
| | | if ngxUrl !="" && len(strArr) >0 { |
| | | videoUrl = ngxUrl + strArr[1] |
| | | } |
| | |
| | | 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.Infoln("条数:",size,"耗时:",time.Since(startTime)) |
| | | |
| | | if err != nil { |
| | | log.Log.Errorln(err) |
| | | return nil |