liuxiaolong
2019-10-29 d848ebc0bd707f53b47b3fedda49296b7fac6717
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"`