From 1d06cf290dcdfc17705516c651c7a4b87f66bf34 Mon Sep 17 00:00:00 2001
From: liuxiaolong <736321739@qq.com>
Date: 星期三, 07 八月 2019 14:16:56 +0800
Subject: [PATCH] add search this person
---
extend/esutil/EsClient.go | 2 +-
controllers/fileController.go | 44 ++++++++++++++++++--------------------------
2 files changed, 19 insertions(+), 27 deletions(-)
diff --git a/controllers/fileController.go b/controllers/fileController.go
index 6b8016f..6d3318f 100644
--- a/controllers/fileController.go
+++ b/controllers/fileController.go
@@ -203,7 +203,7 @@
dbPersonM := make(map[string]*protomsg.SdkCompareEach, 0)
captureM := make(map[string]*protomsg.SdkCompareEach, 0)
- personIds :=make([]string,0)
+ personIds := make([]string,0)
captureIds := make([]string,0)
for _,v :=range compResult.CompareResult{
if v.Tableid == service.CaptureTable {
@@ -321,12 +321,12 @@
func (controller FileController) SearchByPhoto(c *gin.Context) {
var searchBody models.EsSearch
err := c.BindJSON(&searchBody)
- if err !=nil || searchBody.PicUrl == "" || len(searchBody.DataBases) == 0 {
+ if err !=nil{
util.ResponseFormat(c, code.RequestParamError, "鍙傛暟鏈夎")
return
}
var faceB []byte
- if searchBody.CaptureId != "" {//鍋氭煡鎵炬浜�
+ if searchBody.CaptureId != "" {//鍋氭煡鎵炬浜�,鎼滄墍鏈夋姄鎷嶅拰搴曞簱
searchPeople, err := esApi.Dbpersoninfosbyid([]string{searchBody.CaptureId}, config.EsInfo.EsIndex.VideoPersons.IndexName, config.EsInfo.Masterip, config.EsInfo.Httpport)
if err !=nil {
util.ResponseFormat(c, code.ComError, "鎶撴媿鏁版嵁涓嶅瓨鍦紝璇锋鏌�")
@@ -340,22 +340,19 @@
}
faceB = decodeF
}
+ } else {//鍋氫互鍥炬悳鍥�
+ if searchBody.PicUrl == "" || len(searchBody.DataBases) == 0 {
+ util.ResponseFormat(c, code.RequestParamError, "鍙傛暟鏈夎")
+ return
+ }
+ if face,ok := faceExtractedMap[searchBody.PicUrl];!ok{
+ util.ResponseFormat(c, code.RequestParamError, "璇烽噸鏂颁笂浼犲浘鐗�")
+ return
+ } else {
+ faceB = face.FaceBytes
+ }
}
- //if searchBody.CompareNum !="" {
- // //浜屾鎼滅储锛屼笉闇�瑕佸啀姣斿浜�
- // co := service.GetCompResultByNum(searchBody.CompareNum)
- // if co != nil {
- // //浜屾鎼滅储鍜屾帓搴�
- // twiceM := GetCompareDataTwice(co,&searchBody)
- // util.ResponseFormat(c,code.Success,twiceM)
- // } else {
- // m :=make(map[string]interface{},0)
- // m["compareNum"] = searchBody.CompareNum
- // m["total"] = 0
- // m["totalList"] = []CompareResult{}
- // util.ResponseFormat(c,code.CompareResultGone,m)
- // }
- //}
+
var sysSetApi dbapi.SysSetApi
analyServerId := ""
flag, sysconf := sysSetApi.GetServerInfo()
@@ -365,14 +362,7 @@
util.ResponseFormat(c, code.ComError, "analyServerId涓虹┖锛岄厤缃湁璇�")
return
}
- if searchBody.CaptureId == ""{
- if face,ok := faceExtractedMap[searchBody.PicUrl];!ok{
- util.ResponseFormat(c, code.RequestParamError, "璇烽噸鏂颁笂浼犲浘鐗�")
- return
- } else {
- faceB = face.FaceBytes
- }
- }
+
if faceB == nil {
util.ResponseFormat(c, code.RequestParamError, "璇烽噸鏂颁笂浼犲浘鐗�")
return
@@ -391,6 +381,8 @@
}
}
arg.TableIds = searchBody.DataBases
+ } else {
+ arg.TableIds = []string{}
}
arg.Source = true // 鏍囪瘑鏉ユ簮鏄痺eb
arg.AlarmLevel = searchBody.AlarmLevel
diff --git a/extend/esutil/EsClient.go b/extend/esutil/EsClient.go
index e2e8a05..dab2e32 100644
--- a/extend/esutil/EsClient.go
+++ b/extend/esutil/EsClient.go
@@ -44,7 +44,7 @@
sources := []interface{}{}
for _, value := range dat["hits"].([]interface{}) {
source := value.(map[string]interface{})["_source"].(map[string]interface{})
- source["id"] = value.(map[string]interface{})["_id"]
+ source["id"] = value.(map[string]interface{})["id"]
/*sdkType := source["sdkType"]
if sdkType != nil {
sdk, _ := strconv.Atoi(sdkType.(string))
--
Gitblit v1.8.0