tcp server 用于给andriod 客户端定时发送消息
liuxiaolong
2019-05-29 fe064f3a5eab46db764717a97441d33b5612490c
esutil/EsClient.go
@@ -99,12 +99,13 @@
         if exist {
            source["race"] = prace
         }
         fmt.Println("race: ", source["race"])
         source["ageDescription"] = getAgeDesc(source["Age"])
         source["videoNum"] = getVideoUrl(source)
         timeFormat := "2019-05-28 15:04:05"
         picDateStr, err := time.Parse(timeFormat, source["picDate"].(string))
         picDate := source["picDate"].(string)
         lastIdx := strings.LastIndex(picDate,":")
         picDateStr := picDate[:lastIdx]
         fmt.Println("picDate: ", picDateStr)
         if err == nil {
            source["picDate"] = picDateStr
@@ -124,7 +125,7 @@
func getAgeDesc(age interface{})(ageDesc string) {
   if age !=nil {
      ageInt := age.(int32)
      ageInt := age.(float64)
      if ageInt >0 && ageInt<7 {
         ageDesc = "童年"
      } else if ageInt >=7 && ageInt<18 {
@@ -139,7 +140,6 @@
         ageDesc = ""
      }
   }
   fmt.Println("ageDescription: ", ageDesc)
   return ageDesc
}
@@ -159,7 +159,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 == "人脸" {
@@ -202,13 +202,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){
@@ -318,7 +317,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\",\"personId\",\"personPicUrl\",\"indeviceName\",\"imgKey\",\"sdkType\",\"ageDescription\",\"indeviceid\",\"content\",\"Id\",\"picAddress\",\"picMaxUrl\",\"picDate\",\"Race\",\"videoNum\",\"picSmUrl\",\"taskName\",\"personIsHub\",\"idcard\",\"videoIp\",\"videoReqNum\"]" +
      "\"_source\":[\"baseInfo\",\"Gender\",\"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)