From d848ebc0bd707f53b47b3fedda49296b7fac6717 Mon Sep 17 00:00:00 2001
From: liuxiaolong <736321739@qq.com>
Date: 星期二, 29 十月 2019 15:46:45 +0800
Subject: [PATCH] add JoinDbTable
---
go.sum | 4 +-
controllers/esSearch.go | 30 +++++++-------
go.mod | 2
controllers/dbtableperson.go | 54 +++++++++++++++++++++++++++
controllers/task.go | 4 +
router/router.go | 2 +
6 files changed, 77 insertions(+), 19 deletions(-)
diff --git a/controllers/dbtableperson.go b/controllers/dbtableperson.go
index 048427c..a9a7123 100644
--- a/controllers/dbtableperson.go
+++ b/controllers/dbtableperson.go
@@ -21,6 +21,8 @@
"webserver/extend/esutil"
"webserver/extend/util"
"webserver/models"
+
+ esApi "basic.com/pubsub/esutil.git"
)
type DbPersonController struct {
@@ -484,6 +486,58 @@
}
}
+type JoinDbTVo struct {
+ CaptureId string `json:"captureId"`
+ TableIds []string `json:"tableIds"`
+}
+
+// @Summary 鎶撴媿浜哄憳鍔犲叆搴曞簱
+// @Description 鎶撴媿浜哄憳鍔犲叆搴曞簱
+// @Accept json
+// @Produce json
+// @Tags es
+// @Param obj body controllers.JoinDbTVo true "搴曞簱鏁版嵁"
+// @Success 200 {string} json "{"code":200, msg:"鐩綍缁撴瀯鏁版嵁", success:true}"
+// @Failure 500 {string} json "{"code":500, msg:"杩斿洖閿欒淇℃伅", success:false}"
+// @Router /data/api-v/dbperson/joinDbTable [POST]
+func (sc *DbPersonController) JoinDbTable(c *gin.Context) {
+ var reqBody JoinDbTVo
+ c.BindJSON(&reqBody)
+ if reqBody.CaptureId == "" || len(reqBody.TableIds) ==0 {
+ util.ResponseFormat(c,code.RequestParamError, "鍙傛暟鏈夎")
+ return
+ }
+ localConf, err := cache.GetServerInfo()
+ if err !=nil || localConf.AlarmIp == "" || localConf.AlarmPort <=0 {
+ 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{
+ var personPicUrl = ""//浜鸿劯鍥剧墖
+ var feature = ""//鐗瑰緛
+ if videopersons[0].PicSmUrl !=nil && len(videopersons[0].PicSmUrl) >0 {
+ personPicUrl = videopersons[0].PicSmUrl[0]
+ }
+ fea, e2 := esApi.GetVideoPersonFaceFeatureById(reqBody.CaptureId, config.EsInfo.EsIndex.VideoPersons.IndexName, localConf.AlarmIp, strconv.Itoa(int(localConf.AlarmPort)))
+ if e2 == nil && fea !="" {
+ feature = fea
+ }
+ if personPicUrl != "" && feature != "" {
+ var dbpApi dbapi.DbPersonApi
+ b,d := dbpApi.JoinDbTable(reqBody.TableIds, feature, personPicUrl)
+ if b {
+ util.ResponseFormat(c,code.Success,d)
+ return
+ } else {
+ util.ResponseFormat(c,code.ComError,"鍔犲叆澶辫触")
+ return
+ }
+ }
+ }
+ util.ResponseFormat(c,code.ComError,"鍔犲叆澶辫触")
+}
+
type DbtSearch struct {
TableId string `json:"tableId"`
OrderName string `json:"orderName"`
diff --git a/controllers/esSearch.go b/controllers/esSearch.go
index 84e2ef0..9fd0f95 100644
--- a/controllers/esSearch.go
+++ b/controllers/esSearch.go
@@ -1,19 +1,19 @@
- package controllers
+package controllers
- import (
- "basic.com/dbapi.git"
- "fmt"
- "github.com/gin-gonic/gin"
- "strconv"
- "strings"
- "webserver/cache"
- "webserver/extend/code"
- "webserver/extend/config"
- "webserver/extend/esutil"
- "basic.com/valib/logger.git"
- "webserver/extend/util"
- "webserver/models"
- )
+import (
+ "basic.com/dbapi.git"
+ "basic.com/valib/logger.git"
+ "fmt"
+ "github.com/gin-gonic/gin"
+ "strconv"
+ "strings"
+ "webserver/cache"
+ "webserver/extend/code"
+ "webserver/extend/config"
+ "webserver/extend/esutil"
+ "webserver/extend/util"
+ "webserver/models"
+)
type EsSearchController struct{}
diff --git a/controllers/task.go b/controllers/task.go
index 1bd5e75..dbb8761 100644
--- a/controllers/task.go
+++ b/controllers/task.go
@@ -105,9 +105,11 @@
if e==nil && esTaskM !=nil {
for _,tM :=range esTaskM {
if _,ok := m[tM["taskId"].(string)];!ok {//琛ㄧず姝や换鍔″凡琚垹闄�
+ taskId := tM["taskId"].(string)
+ m[taskId] = taskId
tasks = append(tasks, TaskSdkVo{
Task:TaskVo{
- Taskid: tM["taskId"].(string),
+ Taskid: taskId,
Taskname: tM["taskName"].(string),
DelFlag: true,
},
diff --git a/go.mod b/go.mod
index b812c80..d6feba4 100644
--- a/go.mod
+++ b/go.mod
@@ -3,7 +3,7 @@
go 1.12
require (
- basic.com/dbapi.git v0.0.0-20191028130548-872f0d29a2d3 // indirect
+ basic.com/dbapi.git v0.0.0-20191029073251-acc3826d096d // indirect
basic.com/fileServer/WeedFSClient.git v0.0.0-20190919054037-0182b6c3f5cb // indirect
basic.com/pubsub/cache.git v0.0.0-20190718093725-6a413e1d7d48 // indirect
basic.com/pubsub/esutil.git v0.0.0-20191029031958-4ab66414c6d1 // indirect
diff --git a/go.sum b/go.sum
index f275f8c..79b82c4 100644
--- a/go.sum
+++ b/go.sum
@@ -1,5 +1,5 @@
-basic.com/dbapi.git v0.0.0-20191028130548-872f0d29a2d3 h1:oM/P/GEUMXGX6Ig1Why0rdkbm82cG5BWWb0DQNrw760=
-basic.com/dbapi.git v0.0.0-20191028130548-872f0d29a2d3/go.mod h1:eDXPnxaz6jZPDvBSk7ya7oSASWPCuUEgRTJCjsfKt/Q=
+basic.com/dbapi.git v0.0.0-20191029073251-acc3826d096d h1:DhbWFpg4/KLeYbMpaLJUlY/z5mSyCx+kPh9JY7OMd2k=
+basic.com/dbapi.git v0.0.0-20191029073251-acc3826d096d/go.mod h1:eDXPnxaz6jZPDvBSk7ya7oSASWPCuUEgRTJCjsfKt/Q=
basic.com/fileServer/WeedFSClient.git v0.0.0-20190919054037-0182b6c3f5cb h1:fM6DojeInFSCFO+wkba1jtyPiSDqw0jYKi4Tk+e+ka4=
basic.com/fileServer/WeedFSClient.git v0.0.0-20190919054037-0182b6c3f5cb/go.mod h1:FTryK8BsVLfUplx8a3+l8hJWub6VbAWZCUH7sPRZaso=
basic.com/pubsub/cache.git v0.0.0-20190718093725-6a413e1d7d48 h1:BBA30Rgljn6MRieC4gUncETJDyna3ObyubTo9HEQ2M0=
diff --git a/router/router.go b/router/router.go
index 6479e41..440edef 100644
--- a/router/router.go
+++ b/router/router.go
@@ -184,6 +184,8 @@
vdbperson.POST("/faceExtract", fileController.FaceExtract)
vdbperson.POST("/searchByPhoto", fileController.SearchByPhoto)
vdbperson.POST("/updateFace", dbPersonCont.UpdateFace)
+
+ vdbperson.POST("/joinDbTable", dbPersonCont.JoinDbTable)
}
// 绯荤粺璁剧疆 鎿嶄綔
--
Gitblit v1.8.0