sunty
2019-09-29 b7a57cd830201952d76b5df4c7e10097317d4f10
EsClient.go
@@ -7,7 +7,8 @@
    "fmt"
    "io/ioutil"
    "net/http"
    "time"
   "strconv"
   "time"
    "basic.com/pubsub/protomsg.git"
)
@@ -16,7 +17,7 @@
func Parsesources(sources []map[string]interface{}) (esinfos []*protomsg.Esinfo) {
    var ok bool
    for _, source := range sources {
        tmpinfo := protomsg.Esinfo{}
       var tmpinfo protomsg.Esinfo
        tmpinfo.FaceFeature, ok =   source["faceFeature"].(string)
        if !ok {
            continue
@@ -58,9 +59,8 @@
func Videopersonsbyid(sources []map[string]interface{}) (tmpinfos []protomsg.Videopersons) {
    var ok bool
    //var tmpinfo protomsg.Videopersons
    var tmpinfo protomsg.Videopersons
    for _, source := range  sources{
        tmpinfo := protomsg.Videopersons{}
        tmpinfo.Id, ok =   source["id"].(string)
        if !ok {
            continue
@@ -110,9 +110,11 @@
        tmpinfo.BeautyLevel,ok = source["beautyLevel"].(string)
        Isnil("beautyLevel",ok)
        if source["picSmUrl"] != nil {
            //fmt.Println(source["picSmUrl"])
            for _,v := range source["picSmUrl"].([]interface{}) {
                tmpinfo.PicSmUrl = append(tmpinfo.PicSmUrl, v.(string))
            }
            fmt.Println(tmpinfo.PicSmUrl)
        }
        tmpinfo.VideoUrl,ok = source["videoUrl"].(string)
        Isnil("videoUrl",ok)
@@ -124,21 +126,33 @@
        Isnil("analyServerIp",ok)
        tmpinfo.ClusterId,ok = source["clusterId"].(string)
        Isnil("clusterId",ok)
        tmpinfo.IsAlarm,ok = source["isAlarm"].(string)
        isAlarm,ok := source["isAlarm"].(float64)
        fmt.Println(ok)
      if ok {
         tmpinfo.IsAlarm= strconv.FormatFloat(isAlarm, 'E', -1, 64)//float64
      }
        Isnil("isAlarm",ok)
        tmpinfo.IsAckAlarm,ok = source["isAckAlarm"].(string)
        Isnil("isAckAlarm",ok)
      isAckAlarm,ok := source["isAckAlarm"].(float64)
      fmt.Println(ok)
      if ok {
         tmpinfo.IsAckAlarm= strconv.FormatFloat(isAckAlarm, 'E', -1, 64)//float64
      }
      Isnil("isAckAlarm",ok)
        isCollect,ok  :=   source["isCollect"].(float64)
        if ok {
            tmpinfo.IsDelete= int32(isCollect)
        }
        Isnil("isDelete", ok)
        Isnil("isCollect", ok)
        isDelete,ok  :=   source["isDelete"].(float64)
        if ok {
            tmpinfo.IsDelete= int32(isDelete)
        }
        Isnil("isDelete", ok)
        if source["alarmRules"] != nil {
            fmt.Println(source["alarmRules"])
            for _,v := range source["alarmRules"].([]interface{}) {
@@ -196,12 +210,12 @@
                tmpinfo.BaseInfo = append(tmpinfo.BaseInfo, &bi)
            }
        }
        //根据 tableid 获取 tablename
        //name, _:= Dbtablename(tmpinfo.TableId)
        //tmpinfo.TableName= name
        fmt.Println(tmpinfos)
        tmpinfos = append(tmpinfos, tmpinfo)
    }
@@ -212,9 +226,8 @@
func Dbpersonbyid(sources []map[string]interface{}) (tmpinfos []protomsg.Dbperson) {
        var ok bool
        //var tmpinfo protomsg.Dbperson
        var tmpinfo protomsg.Dbperson
        for _, source := range  sources{
            tmpinfo := protomsg.Dbperson{}
            tmpinfo.FaceFeature, ok =   source["faceFeature"].(string)
            if !ok {
                continue
@@ -281,9 +294,9 @@
func Dbtablebyid(sources []map[string]interface{}) (tmpinfos []protomsg.Dbtable) {
    var ok bool
    //var tmpinfo protomsg.Dbtable
    var tmpinfo protomsg.Dbtable
    for _, source := range  sources{
        tmpinfo := protomsg.Dbtable{}
        tmpinfo.Id, ok    =   source["id"].(string)
        if !ok {
            continue
@@ -359,7 +372,7 @@
    }
    return sources,nil
}
//slice scroll 解析工具函数
func Sourcelistforscroll(buf []byte)(datasource map[string]interface{}, err error){
   var data = make(map[string]interface{})
   var info interface{}
@@ -400,7 +413,7 @@
}
func EsReq(method string, url string, parama []byte) (buf []byte, err error) {
    defer elapsed("page")()
    //defer elapsed("page")()
    timeout := time.Duration(10 * time.Second) 
    client := http.Client{
        Timeout: timeout,