tcp server 用于给andriod 客户端定时发送消息
liuxiaolong
2019-11-04 e7800f02cb0edb6ae0590c81b78ef68611dfd53b
esutil/EsClient.go
@@ -12,9 +12,9 @@
   "strings"
   "sync"
   "time"
   "androidAlarmServer/config"
   "andriodServer/extend/config"
   log "androidAlarmServer/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,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,9 +378,9 @@
   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, ",")