From eccb58b31fa666d6117412c5f628f83e087f3df5 Mon Sep 17 00:00:00 2001 From: sunty <1172534965@qq.com> Date: 星期日, 29 九月 2019 15:22:52 +0800 Subject: [PATCH] fix EsApi --- EsClient.go | 96 ++++++++++-------------------------------------- 1 files changed, 20 insertions(+), 76 deletions(-) diff --git a/EsClient.go b/EsClient.go index 3f5740e..5425b87 100644 --- a/EsClient.go +++ b/EsClient.go @@ -58,9 +58,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 +109,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 +125,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,85 +209,16 @@ tmpinfo.BaseInfo = append(tmpinfo.BaseInfo, &bi) } - } //鏍规嵁 tableid 鑾峰彇 tablename //name, _:= Dbtablename(tmpinfo.TableId) //tmpinfo.TableName= name + fmt.Println(tmpinfos) tmpinfos = append(tmpinfos, tmpinfo) } return tmpinfos -} - -//瑙f瀽搴曞簱浜哄憳缁撴瀯 -func Dbpersonbyid(sources []map[string]interface{}) (tmpinfos []protomsg.Dbperson) { - var ok bool - - //var tmpinfo protomsg.Dbperson - for _, source := range sources{ - tmpinfo := protomsg.Dbperson{} - tmpinfo.FaceFeature, ok = source["faceFeature"].(string) - if !ok { - continue - } - - tmpinfo.Id, ok = source["id"].(string) - if !ok { - continue - } - - tmpinfo.TableId, ok = source["tableId"].(string) - if !ok { - continue - } - - tmpinfo.PersonName,ok = source["personName"].(string) - Isnil("personName", ok) - tmpinfo.PersonPicUrl,ok = source["personPicUrl"].(string) - Isnil("personPicUrl", ok) - tmpinfo.PhoneNum,ok = source["phoneNum"].(string) - Isnil("phoneNum", ok) - tmpinfo.Sex,ok = source["sex"].(string) - Isnil("sex", ok) - tmpinfo.IdCard,ok = source["idCard"].(string) - Isnil("idCard", ok) - tmpinfo.MonitorLevel,ok = source["monitorLevel"].(string) - Isnil("monitorLevel",ok) - tmpinfo.UpdateTime,ok = source["updateTime"].(string) - Isnil("updateTime",ok) - tmpinfo.Age,ok = source["age"].(string) - Isnil("age", ok) - - isDelete,ok := source["isDelete"].(float64) - if ok { - tmpinfo.IsDelete= int32(isDelete) - } - Isnil("isDelete", ok) - - enable,ok := source["enable"].(float64) - if ok { - tmpinfo.Enable= int32(enable) - } - Isnil("endTime", ok) - - tmpinfo.Reserved,ok = source["reserved"].(string) - Isnil("reserved",ok) - tmpinfo.PicDesc,ok = source["picDesc"].(string) - Isnil("picDesc",ok) - tmpinfo.CreateTime,ok = source["createTime"].(string) - Isnil("createTime",ok) - tmpinfo.CreateBy,ok = source["createBy"].(string) - Isnil("createBy",ok) - - //鏍规嵁 tableid 鑾峰彇 tablename - //name, _:= Dbtablename(tmpinfo.TableId) - //tmpinfo.TableName= name - tmpinfos = append(tmpinfos, tmpinfo) - } - - return tmpinfos } //瑙f瀽搴曞簱缁撴瀯 -- Gitblit v1.8.0