tcp server 用于给andriod 客户端定时发送消息
liuxiaolong
2019-05-29 01a2fca7cf04babd139c6fad97c1e937fb1130f6
esutil/EsClient.go
@@ -100,14 +100,20 @@
            source["race"] = prace
         }
         pGender, exist := source["Gender"]
         if exist {
            source["gender"] = pGender
         }
         source["ageDescription"] = getAgeDesc(source["Age"])
         source["videoNum"] = getVideoUrl(source)
         picDateStr, err := time.Parse("2006-01-02 15:04:05", source["picDate"].(string))
         fmt.Println("picDate: ", picDateStr.Format("2006-01-02 15:04:05"))
         fmt.Println("BaseName: ", source["BaseName"])
         picDate := source["picDate"].(string)
         lastIdx := strings.LastIndex(picDate,":")
         picDateStr := picDate[:lastIdx]
         if err == nil {
            source["picDate"] = picDateStr.Format("2006-01-02 15:04:05")
            source["picDate"] = picDateStr
         }
         baseInfo := getSourceBaseInfo(source)
@@ -123,7 +129,6 @@
}
func getAgeDesc(age interface{})(ageDesc string) {
   fmt.Println("ageInterface: ", age)
   if age !=nil {
      ageInt := age.(float64)
      if ageInt >0 && ageInt<7 {
@@ -140,7 +145,6 @@
         ageDesc = ""
      }
   }
   fmt.Println("ageDescription: ", ageDesc)
   return ageDesc
}
@@ -160,7 +164,7 @@
   Content string `json:"content"`
}
func getSourceBaseInfo(source map[string]interface{}) (baseInfoJson string) {
func getSourceBaseInfo(source map[string]interface{}) []BaseInfo {
   sdkType := source["sdkType"].(string)
   baseInfoArr := make([]BaseInfo,0)
   if sdkType == "人脸" {
@@ -203,13 +207,12 @@
      }
      baseInfoArr = append(baseInfoArr, baseInfo)
      bytes, err := json.Marshal(baseInfoArr)
      if err !=nil {
         return ""
      }
      return string(bytes)
      //bytes, err := json.Marshal(baseInfoArr)
      //if err !=nil {
      //   return ""
      //}
   }
   return ""
   return baseInfoArr
}
func getVideoUrl(source map[string]interface{}) (videoUrl string){
@@ -246,18 +249,19 @@
      return ""
   }
   filePath := resp.FilePath
   videoUrl = ""
   if !strings.Contains(filePath, "/cut"){
      return ""
      videoUrl = ""
   } else {
      strArr := strings.Split(filePath, "/cut")
      ngxUrl := ngxMap[indeviceId]
      if ngxUrl !="" && len(strArr) >0 {
         return ngxUrl + strArr[1]
         videoUrl = ngxUrl + strArr[1]
      }
   }
   return ""
   fmt.Println("videoReqUrl: ",reqUrl)
   fmt.Println("video: ",videoUrl)
   return videoUrl
}
type RespVideo struct{
@@ -319,7 +323,7 @@
   seccond := strconv.Itoa(sec)
   prama := "{\"query\":{\"bool\":{\"filter\":[{\"range\":{\"picDate\":{\"gte\":\"now+8h-" + seccond + "s\",\"lt\":\"now+8h\"}}}]}},\"size\":\"1000\",\"sort\":[{\"picDate\":{\"order\":\"desc\"}}]," +
      "\"_source\":[\"baseInfo\",\"Gender\",\"Age\",\"personId\",\"personPicUrl\",\"indeviceName\",\"imgKey\",\"sdkType\",\"ageDescription\",\"indeviceid\",\"content\",\"Id\",\"picAddress\",\"picMaxUrl\",\"picDate\",\"Race\",\"videoNum\",\"picSmUrl\",\"taskName\",\"personIsHub\",\"idcard\",\"videoIp\",\"videoReqNum\"]" +
      "\"_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)