tcp server 用于给andriod 客户端定时发送消息
liuxiaolong
2020-06-17 af0877776f959a40d997cca10f5f8ef1233fec78
esutil/EsClient.go
@@ -68,7 +68,7 @@
         if !exist {
            continue
         }
         pmArr := pmax.([]string)
         pmArr := pmax.([]interface{})
         if len(pmArr) > 0 {
            d["picMaxUrl"] = pmArr[0]
         }
@@ -78,30 +78,33 @@
            continue
         }
         ti := TargetInfo{}
         err = json.Unmarshal(tB, &ti)
         tiArr := []TargetInfo{}
         err = json.Unmarshal(tB, &tiArr)
         if err !=nil {
            continue
         }
         if len(tiArr) > 0 {
            ti := tiArr[0]
            d["picSmUrl"] = ti.PicSmUrl
            if ti.TargetType == "face" {
               sLabelStr, ok := source["showLabels"]
               if ok {
                  labelArr := strings.Split(sLabelStr.(string), "/")
                  if len(labelArr) == 3 {
                     d["gender"] = labelArr[0]
                     d["ageDescription"] = labelArr[1]
                     d["race"] = labelArr[2]
                  }
               }
         d["picSmUrl"] = ti.PicSmUrl
         if ti.TargetType == "face" {
            sLabelStr, ok := source["showLabels"]
            if ok {
               labelArr := strings.Split(sLabelStr.(string), "/")
               if len(labelArr) == 3 {
                  d["gender"] = labelArr[0]
                  d["ageDescription"] = labelArr[1]
                  d["race"] = labelArr[2]
               if bInfos,ok := source["baseInfo"]; ok && bInfos != nil {
                  d["baseInfo"] = getSourceBaseInfo(bInfos)
               } else {
                  d["baseInfo"] = []interface{}{}
               }
            }
            if bInfos,ok := source["baseInfo"]; ok && bInfos != nil {
               d["baseInfo"] = getSourceBaseInfo(bInfos)
            } else {
               d["baseInfo"] = []interface{}{}
            }
         }
         d["videoNum"] = source["videoUrl"]
@@ -226,25 +229,13 @@
   if len(filterArr) >0 {
      filterStr = strings.Join(filterArr, ",")
   }
   sourceArr := []string{
      "baseInfo",
      "targetInfo",
      "content",
      "id",
      "picMaxUrl",
      "picDate",
      "showLabels",
      "taskName",
   }
   sourceStr := strings.Join(sourceArr, ",")
   log.Log.Infoln("filterArr:", filterStr)
   param := "{\"query\":{\"bool\":{\"filter\":["+filterStr+"]}},\"size\":\""+sizeStr+"\",\"sort\":[{\"picDate\":{\"order\":\"desc\"}}]," +
      "\"_source\":{\"includes\":["+sourceStr+"],\"excludes\":[\"*.feature\",\"*.attachTarget\",\"*.targetLocation\",\"alarmRules\"]}" +
      "\"_source\":{\"includes\":[\"baseInfo\",\"targetInfo\",\"content\",\"id\",\"picMaxUrl\",\"picDate\",\"showLabels\",\"taskName\"],\"excludes\":[\"*.feature\",\"*.attachTarget\",\"*.targetLocation\",\"alarmRules\"]}" +
      "}"
   err, tokenRes := GetEsDataReq(url, param, true)
   if err != nil {
      log.Log.Errorln(err)
      log.Log.Errorln("GetEsDataReq err:", err)
      return nil
   }
   jsonstring, _ := json.Marshal(tokenRes)