| | |
| | | "basic.com/dbapi.git" |
| | | "basic.com/fileServer/WeedFSClient.git" |
| | | "basic.com/pubsub/protomsg.git" |
| | | "basic.com/valib/logger.git" |
| | | "encoding/base64" |
| | | "encoding/json" |
| | | "io/ioutil" |
| | | "sort" |
| | | "strconv" |
| | | "time" |
| | | "basic.com/valib/logger.git" |
| | | "webserver/cache" |
| | | "webserver/service" |
| | | |
| | |
| | | "github.com/satori/go.uuid" |
| | | "webserver/extend/code" |
| | | "webserver/extend/config" |
| | | "webserver/extend/esutil" |
| | | "webserver/extend/util" |
| | | "webserver/models" |
| | | |
| | |
| | | for idx,v :=range compResult.CompareResult{ |
| | | dbPersonM[v.Id] = ScoreIndex{ |
| | | Index: idx, |
| | | CompareScore: v.CompareScore, |
| | | CompareScore: float64(v.CompareScore), |
| | | } |
| | | personIds = append(personIds,v.Id) |
| | | } |
| | |
| | | dbP.CreateTime = p.CreateTime |
| | | dbP.UpdateTime = p.UpdateTime |
| | | dbP.CreateBy = p.CreateBy |
| | | dbP.CompareScore = util.ParseScore(dbPersonM[p.Id].CompareScore) |
| | | dbP.CompareScore = dbPersonM[p.Id].CompareScore |
| | | //dbTableInfos, _ := dtApi.DbtablesById([]string{ p.TableId }) |
| | | //if dbTableInfos !=nil{ |
| | | // dbP.BwType = dbTableInfos[0].BwType |
| | |
| | | //} else { |
| | | // util.ResponseFormat(c,code.UpdateFail,"更新人脸失败") |
| | | //} |
| | | } |
| | | |
| | | func UpdateDbPersonsOfDbTable(id string) (message string) { |
| | | localConf, err2 := cache.GetServerInfo() |
| | | if err2 !=nil || localConf.AlarmIp == "" || localConf.ServerId == "" { |
| | | logger.Debug("localConfig is wrong!!!") |
| | | return "修改失败" |
| | | } |
| | | url := "http://" + localConf.AlarmIp + ":" + strconv.Itoa(int(localConf.AlarmPort)) + |
| | | "/" + config.EsInfo.EsIndex.Dbtablepersons.IndexName + "/_update_by_query?refresh" |
| | | jsonDSL := ` |
| | | { |
| | | "script": { |
| | | "lang": "painless", |
| | | "inline": "ctx._source.enable = 0" |
| | | }, |
| | | "query": { |
| | | "term": { |
| | | "tableId": "` + id + `" |
| | | } |
| | | } |
| | | } |
| | | ` |
| | | buf, err := esutil.EsReq("POST", url, []byte(jsonDSL)) |
| | | if err != nil { |
| | | logger.Debug("http request info is err!") |
| | | message = "修改失败" |
| | | } |
| | | var info interface{} |
| | | json.Unmarshal(buf, &info) |
| | | out, ok := info.(map[string]interface{}) |
| | | if !ok { |
| | | logger.Debug("http response interface can not change map[string]interface{}") |
| | | message = "修改失败" |
| | | } |
| | | middle, ok := out["updated"].(float64) |
| | | if !ok { |
| | | logger.Debug("first result change error!") |
| | | message = "修改失败" |
| | | } |
| | | if middle >= 0 { |
| | | logger.Debug("修改成功") |
| | | message = "修改成功,更新状态条数为" + strconv.Itoa(int(middle)) |
| | | } |
| | | return message |
| | | } |
| | | |
| | | // @Security ApiKeyAuth |
| | |
| | | util.ResponseFormat(c,code.ComError,"报警设置有误") |
| | | return |
| | | } |
| | | videopersons, e := esApi.Videopersonsinfosbyid([]string{reqBody.CaptureId}, config.EsInfo.EsIndex.VideoPersons.IndexName, localConf.AlarmIp, strconv.Itoa(int(localConf.AlarmPort))) |
| | | if e ==nil && videopersons !=nil && len(videopersons) == 1{ |
| | | aiOceans, e := esApi.AIOceaninfosbyid([]string{reqBody.CaptureId}, config.EsInfo.EsIndex.AiOcean.IndexName, localConf.AlarmIp, strconv.Itoa(int(localConf.AlarmPort))) |
| | | if e ==nil && aiOceans !=nil && len(aiOceans) == 1{ |
| | | var personPicUrl = ""//人脸图片 |
| | | var feature = ""//特征 |
| | | if videopersons[0].PicSmUrl !=nil && len(videopersons[0].PicSmUrl) >0 { |
| | | personPicUrl = videopersons[0].PicSmUrl[0] |
| | | if aiOceans[0].TargetInfo !=nil && len(aiOceans[0].TargetInfo) >0 { |
| | | personPicUrl = aiOceans[0].TargetInfo[0].PicSmUrl |
| | | } |
| | | fea, e2 := esApi.GetVideoPersonFaceFeatureById(reqBody.CaptureId, config.EsInfo.EsIndex.VideoPersons.IndexName, localConf.AlarmIp, strconv.Itoa(int(localConf.AlarmPort))) |
| | | fea, e2 := esApi.GetVideoPersonFaceFeatureById(reqBody.CaptureId, config.EsInfo.EsIndex.AiOcean.IndexName, localConf.AlarmIp, strconv.Itoa(int(localConf.AlarmPort))) |
| | | if e2 == nil && fea !="" { |
| | | feature = fea |
| | | } |