zhangzengfei
2019-10-31 2bd2068c999cda5bda8c0787ed0dcaac6cb7afdb
controllers/dbtableperson.go
@@ -21,11 +21,14 @@
   "webserver/extend/esutil"
   "webserver/extend/util"
   "webserver/models"
   esApi "basic.com/pubsub/esutil.git"
)
type DbPersonController struct {
}
// @Security ApiKeyAuth
// @Summary 添加底库人员
// @Description 添加底库人员
// @Accept  json
@@ -79,6 +82,7 @@
   return result
}
// @Security ApiKeyAuth
// @Summary 修改底库人员
// @Description 修改底库人员
// @Accept  json
@@ -106,6 +110,7 @@
   }
}
// @Security ApiKeyAuth
// @Summary 底库人员以图搜图
// @Description 底库人员以图搜图
// @Accept  json
@@ -238,11 +243,12 @@
   return  resultList
}
// @Security ApiKeyAuth
// @Summary 更新底库人脸照片
// @Description 更新底库人脸照片
// @Accept  json
// @Produce json
// @Tags 底库人员
// @Tags dbperson 底库人员
// @Param id formData string true "人员id"
// @Param file formData file true "人脸图片"
// @Success 200 {string} json "{"code":200, msg:"", success:true}"
@@ -364,6 +370,7 @@
   return message
}
// @Security ApiKeyAuth
// @Summary 删除底库人员
// @Description 删除库人员
// @Accept  x-www-form-urlencoded
@@ -391,6 +398,7 @@
type DelMultiPerson []string
// @Security ApiKeyAuth
// @Summary 删除底库人员
// @Description 删除库人员
// @Accept  json
@@ -420,6 +428,7 @@
   }
}
// @Security ApiKeyAuth
// @Summary 查询底库人员列表
// @Description 查询库人员列表
// @Accept  json
@@ -484,6 +493,59 @@
   }
}
type JoinDbTVo struct {
   CaptureId string       `json:"captureId"`
   TableIds  []string       `json:"tableIds"`
}
// @Security ApiKeyAuth
// @Summary 抓拍人员加入底库
// @Description 抓拍人员加入底库
// @Accept  json
// @Produce json
// @Tags dbperson 底库人员
// @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"`