| | |
| | | import ( |
| | | esApi "basic.com/pubsub/esutil.git" |
| | | "basic.com/pubsub/protomsg.git" |
| | | "basic.com/valib/deliver.git" |
| | | "encoding/json" |
| | | "github.com/gogo/protobuf/proto" |
| | | "github.com/satori/go.uuid" |
| | | "nanomsg.org/go-mangos" |
| | | "nanomsg.org/go-mangos/protocol/req" |
| | | "nanomsg.org/go-mangos/transport/ipc" |
| | | "nanomsg.org/go-mangos/transport/tcp" |
| | | "sort" |
| | | "strconv" |
| | | "sync" |
| | | "time" |
| | | "webserver/extend/config" |
| | | "webserver/extend/logger" |
| | | "webserver/extend/util" |
| | |
| | | Content string `json:"content"` |
| | | IsAlarm int `json:"isAlarm"` |
| | | PicMaxUrl string `json:"picMaxUrl"` |
| | | PicSmUrl string `json:"picSmUrl"` |
| | | PicSmUrl []string `json:"picSmUrl"` |
| | | Sex string `json:"sex"` |
| | | AgeDescription string `json:"ageDescription"` |
| | | Race string `json:"race"` |
| | |
| | | TaskName string `json:"taskName"` |
| | | BaseInfo []DbPersonVo `json:"baseInfo"` |
| | | VideoUrl string `json:"videoUrl"` |
| | | SdkName string `json:"sdkName"` |
| | | } |
| | | type DbPersonVo struct { |
| | | BwType string `json:"bwType"` |
| | |
| | | resultList :=make([]CompareResult,0) |
| | | for _,str :=range compServerList{ |
| | | reqUrl := "tcp://"+str |
| | | reqClient := deliver.NewClient(deliver.ReqRep, reqUrl) |
| | | err = reqClient.Send(b) |
| | | if err !=nil{ |
| | | logger.Debug("reqClient.Send err:",err) |
| | | continue |
| | | } |
| | | resultB, err := reqClient.Recv() |
| | | if err !=nil{ |
| | | logger.Debug("reqClient.Recv err:",err) |
| | | resultB := doCompareRequest(reqUrl,b) |
| | | if resultB == nil || len(*resultB) ==0 { |
| | | continue |
| | | } |
| | | rList :=make([]protomsg.Esinfo,0) |
| | | err = json.Unmarshal(resultB, &rList) |
| | | err = json.Unmarshal(*resultB, &rList) |
| | | if err !=nil{ |
| | | logger.Debug("recv result Unmarshal err:", err) |
| | | continue |
| | |
| | | SetCompResultByNum(co) |
| | | |
| | | return co |
| | | } |
| | | |
| | | func doCompareRequest(url string,args []byte) *[]byte{ |
| | | reqUrl := "tcp://"+url |
| | | logger.Debug("reqUrl:",reqUrl) |
| | | var sock mangos.Socket |
| | | var err error |
| | | var msg []byte |
| | | |
| | | if sock,err = req.NewSocket();err !=nil { |
| | | logger.Debug("can't new req socket:%s",err.Error()) |
| | | return nil |
| | | } |
| | | sock.AddTransport(ipc.NewTransport()) |
| | | sock.AddTransport(tcp.NewTransport()) |
| | | sock.SetOption(mangos.OptionRecvDeadline, time.Second*10) |
| | | if err = sock.Dial(url);err !=nil { |
| | | logger.Debug("can't dial on req socket:%s",err.Error()) |
| | | return nil |
| | | } |
| | | if err = sock.Send(args);err !=nil { |
| | | logger.Debug("can't send message on push socket:%s",err.Error()) |
| | | return nil |
| | | } |
| | | if msg,err = sock.Recv();err !=nil { |
| | | logger.Debug("sock.Recv receive err:%s",err.Error()) |
| | | return nil |
| | | } |
| | | sock.Close() |
| | | return &msg |
| | | } |
| | | |
| | | //填充向前端返回的数据 |
| | |
| | | logger.Debug("videoPersons.len:",len(videopersons)) |
| | | for _,vp :=range videopersons { |
| | | isAlarmInt, _ := strconv.Atoi(vp.IsAlarm) |
| | | var bi []DbPersonVo |
| | | bi := make([]DbPersonVo,0) |
| | | for _,p :=range vp.BaseInfo { |
| | | bi = append(bi, DbPersonVo{ |
| | | PersonId: p.PersonId, |
| | | IdCard: p.IdCard, |
| | | CompareScore: util.ParseScore(p.CompareScore), |
| | | MonitorLevel: p.MonitorLevel, |
| | | MonitorLevel: parseMonitorLevel(p.MonitorLevel), |
| | | PersonName: p.PersonName, |
| | | PersonPicUrl: p.PersonPicUrl, |
| | | PhoneNum: p.PhoneNum, |
| | |
| | | CameraAddr: vp.CameraAddr, |
| | | PicDate: vp.PicDate, |
| | | PicMaxUrl: vp.PicMaxUrl, |
| | | PicSmUrl: vp.PicSmUrl, |
| | | PicSmUrl: []string{ vp.PicSmUrl }, |
| | | IsAlarm: isAlarmInt, |
| | | Sex: vp.Sex, |
| | | AgeDescription: vp.AgeDescription, |
| | |
| | | TaskId: vp.TaskId, |
| | | VideoUrl: vp.VideoUrl, |
| | | BaseInfo: bi, |
| | | SdkName: "人脸", |
| | | } |
| | | resultList = append(resultList,vpE) |
| | | } |
| | | } |
| | | return resultList |
| | | } |
| | | |
| | | func parseMonitorLevel(level string) string { |
| | | if level == "1" { |
| | | return "一级" |
| | | } |
| | | if level == "2" { |
| | | return "二级" |
| | | } |
| | | if level == "3" { |
| | | return "三级" |
| | | } |
| | | return level |
| | | } |