add Videopersonsinfosbyid
| | |
| | | return dbtable, nil |
| | | } |
| | | |
| | | // 根据抓拍人员id查询抓拍人员信息 |
| | | func Videopersonsinfosbyid (id []string, indexName string, serverIp string, serverPort string) ([]protomsg.Videopersons, error) { |
| | | var videopersonsInfo []protomsg.Videopersons |
| | | videopersonsPersonId := strings.Replace(strings.Trim(fmt.Sprint(id), "[]"), " ", "\",\"", -1) |
| | | var dbinfoRequest = ` |
| | | { |
| | | "query": { |
| | | "bool": { |
| | | "filter": [{ |
| | | "terms": { |
| | | "id": [ |
| | | "`+ videopersonsPersonId +`" |
| | | ] |
| | | } |
| | | }] |
| | | } |
| | | } |
| | | } |
| | | ` |
| | | buf, err := EsReq("POST", "http://"+serverIp+":"+serverPort+"/"+indexName+"/_search",[]byte(dbinfoRequest)) |
| | | if err != nil { |
| | | return videopersonsInfo, err |
| | | } |
| | | |
| | | sources, err := Sourcelist(buf) |
| | | if err != nil { |
| | | return videopersonsInfo , err |
| | | } |
| | | |
| | | videoperson := Videopersonsbyid(sources) |
| | | println(videoperson) |
| | | return videoperson,nil |
| | | } |
| | | |
| | | // 根据底库人员id查询底库人员信息 |
| | | func Dbpersoninfosbyid (id []string, indexName string, serverIp string, serverPort string) ([]protomsg.Dbperson, error) { |
| | | var dbinfo []protomsg.Dbperson |
| | |
| | | if err != nil { |
| | | return "",err |
| | | } |
| | | |
| | | for _, source := range sources { |
| | | if name, ok := source["tableName"].(string); ok { |
| | | tablename = name |
| | |
| | | } |
| | | return |
| | | } |
| | | |
| | | //解析抓拍库人员结构 |
| | | func Videopersonsbyid(sources []map[string]interface{}) (tmpinfos []protomsg.Videopersons) { |
| | | var ok bool |
| | | |
| | | var tmpinfo protomsg.Videopersons |
| | | for _, source := range sources{ |
| | | tmpinfo.Id, ok = source["id"].(string) |
| | | if !ok { |
| | | continue |
| | | } |
| | | |
| | | tmpinfo.CameraId, ok = source["cameraId"].(string) |
| | | if !ok { |
| | | continue |
| | | } |
| | | |
| | | tmpinfo.CameraAddr, ok = source["cameraAddr"].(string) |
| | | if !ok { |
| | | continue |
| | | } |
| | | |
| | | tmpinfo.PicDate,ok = source["picDate"].(string) |
| | | Isnil("picDate", ok) |
| | | tmpinfo.PicMaxUrl,ok = source["picMaxUrl"].(string) |
| | | Isnil("picMaxUrl", ok) |
| | | tmpinfo.TaskId,ok = source["taskId"].(string) |
| | | Isnil("taskId", ok) |
| | | tmpinfo.TaskName,ok = source["taskName"].(string) |
| | | Isnil("taskName", ok) |
| | | tmpinfo.SdkName,ok = source["sdkName"].(string) |
| | | Isnil("sdkName", ok) |
| | | tmpinfo.Content,ok = source["content"].(string) |
| | | Isnil("content",ok) |
| | | tmpinfo.LikeDate,ok = source["likeDate"].(string) |
| | | Isnil("likeDate",ok) |
| | | tmpinfo.DetectScore,ok = source["detectScore"].(string) |
| | | Isnil("detectScore", ok) |
| | | tmpinfo.Sex,ok = source["sex"].(string) |
| | | Isnil("sex",ok) |
| | | |
| | | age,ok := source["age"].(float64) |
| | | if ok { |
| | | tmpinfo.Age= int32(age) |
| | | } |
| | | Isnil("age", ok) |
| | | |
| | | tmpinfo.AgeDescription,ok = source["ageDescription"].(string) |
| | | Isnil("ageDescription",ok) |
| | | tmpinfo.Race,ok = source["race"].(string) |
| | | Isnil("race",ok) |
| | | tmpinfo.SmileLevel,ok = source["smileLevel"].(string) |
| | | Isnil("smileLevel",ok) |
| | | tmpinfo.BeautyLevel,ok = source["beautyLevel"].(string) |
| | | Isnil("beautyLevel",ok) |
| | | tmpinfo.PicSmUrl,ok = source["picSmUrl"].(string) |
| | | Isnil("picSmUrl",ok) |
| | | tmpinfo.VideoUrl,ok = source["videoUrl"].(string) |
| | | Isnil("videoUrl",ok) |
| | | tmpinfo.AnalyServerId,ok = source["analyServerId"].(string) |
| | | Isnil("analyServerId",ok) |
| | | tmpinfo.AnalyServerName,ok = source["analyServerName"].(string) |
| | | Isnil("analyServerName",ok) |
| | | tmpinfo.AnalyServerIp,ok = source["analyServerIp"].(string) |
| | | Isnil("analyServerIp",ok) |
| | | tmpinfo.ClusterId,ok = source["clusterId"].(string) |
| | | Isnil("clusterId",ok) |
| | | tmpinfo.IsAlarm,ok = source["isAlarm"].(string) |
| | | Isnil("isAlarm",ok) |
| | | tmpinfo.IsAckAlarm,ok = source["isAckAlarm"].(string) |
| | | Isnil("isAckAlarm",ok) |
| | | |
| | | isCollect,ok := source["isCollect"].(float64) |
| | | if ok { |
| | | tmpinfo.IsDelete= int32(isCollect) |
| | | } |
| | | Isnil("isDelete", 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{}) { |
| | | m := v.(map[string]interface{}) |
| | | ar := protomsg.AlarmRules{} |
| | | ar.GroupId,ok = m["groupId"].(string) |
| | | Isnil("groupId",ok) |
| | | ar.AlarmLevel,ok = m["alarmLevel"].(string) |
| | | Isnil("alarmLevel",ok) |
| | | ar.RuleText,ok = m["ruleText"].(string) |
| | | Isnil("ruleText",ok) |
| | | ar.DefenceState,ok = m["defenceState"].(bool) |
| | | Isnil("DefenceState",ok) |
| | | tmpinfo.AlarmRules = append( tmpinfo.AlarmRules, &ar) |
| | | } |
| | | |
| | | } |
| | | if source["baseInfo"] != nil { |
| | | fmt.Println(source["baseInfo"]) |
| | | for _,v := range source["baseInfo"].([]interface{}) { |
| | | m := v.(map[string]interface{}) |
| | | fmt.Println("m:",m) |
| | | bi := protomsg.BaseInfo{} |
| | | bi.TableId,ok = m["tableId"].(string) |
| | | Isnil("tableId",ok) |
| | | bi.TableName,ok = m["tableName"].(string) |
| | | Isnil("tableName",ok) |
| | | compareScore,ok := m["compareScore"].(float64) |
| | | if ok { |
| | | bi.CompareScore= float32(compareScore) |
| | | } |
| | | Isnil("compareScore", ok) |
| | | |
| | | bi.PersonId,ok = m["personId"].(string) |
| | | Isnil("personId",ok) |
| | | bi.PersonName,ok = m["personName"].(string) |
| | | Isnil("personName",ok) |
| | | bi.PersonPicUrl,ok = m["personPicUrl"].(string) |
| | | Isnil("personPicUrl",ok) |
| | | bi.PhoneNum,ok = m["phoneNum"].(string) |
| | | Isnil("phoneNum",ok) |
| | | bi.Sex,ok = m["sex"].(string) |
| | | Isnil("sex",ok) |
| | | bi.IdCard,ok = m["idCard"].(string) |
| | | Isnil("idCard",ok) |
| | | bi.MonitorLevel,ok = m["monitorLevel"].(string) |
| | | Isnil("monitorLevel",ok) |
| | | bi.Content,ok = m["content"].(string) |
| | | Isnil("content",ok) |
| | | bwType,ok := m["bwType"].(float64) |
| | | if ok { |
| | | bi.BwType= int32(bwType) |
| | | } |
| | | Isnil("bwType", ok) |
| | | |
| | | tmpinfo.BaseInfo = append(tmpinfo.BaseInfo, &bi) |
| | | } |
| | | |
| | | } |
| | | |
| | | //根据 tableid 获取 tablename |
| | | //name, _:= Dbtablename(tmpinfo.TableId) |
| | | //tmpinfo.TableName= name |
| | | tmpinfos = append(tmpinfos, tmpinfo) |
| | | } |
| | | |
| | | return tmpinfos |
| | | } |
| | | |
| | | //解析底库人员结构 |
| | | func Dbpersonbyid(sources []map[string]interface{}) (tmpinfos []protomsg.Dbperson) { |
| | | var ok bool |