From ec3cdd20b8221caa6093d0a44984ee3098504b52 Mon Sep 17 00:00:00 2001 From: liuxiaolong <736321739@qq.com> Date: 星期三, 20 十一月 2019 10:40:02 +0800 Subject: [PATCH] update protomsg and use aiocean index --- controllers/dbtableperson.go | 63 ++++--------------------------- 1 files changed, 8 insertions(+), 55 deletions(-) diff --git a/controllers/dbtableperson.go b/controllers/dbtableperson.go index 06ab88b..dbc6149 100644 --- a/controllers/dbtableperson.go +++ b/controllers/dbtableperson.go @@ -4,13 +4,12 @@ "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" @@ -18,7 +17,6 @@ "github.com/satori/go.uuid" "webserver/extend/code" "webserver/extend/config" - "webserver/extend/esutil" "webserver/extend/util" "webserver/models" @@ -197,7 +195,7 @@ for idx,v :=range compResult.CompareResult{ dbPersonM[v.Id] = ScoreIndex{ Index: idx, - CompareScore: v.CompareScore, + CompareScore: float64(v.CompareScore), } personIds = append(personIds,v.Id) } @@ -230,7 +228,7 @@ 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 @@ -323,51 +321,6 @@ //} 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 @@ -520,14 +473,14 @@ 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 } -- Gitblit v1.8.0