zhangzengfei
2024-06-03 7eb122e20a75ed800cc96b1565522951286e4081
controller/captureCtl.go
@@ -44,7 +44,7 @@
   }
   face := req.FaceListObject.FaceObject[0]
   logger.Debug("Receive new message, Id:%s Ip:%s faceId:%s, LeftTopX:%d, appearTime:%s", c.RemoteIP(), face.DeviceID, face.FaceID, face.LeftTopX, face.FaceAppearTime)
   logger.Debug("Receive new face message, ip:%s, device id:%s faceId:%s, LeftTopX:%d, appearTime:%s", c.RemoteIP(), face.DeviceID, face.FaceID, face.LeftTopX, face.FaceAppearTime)
   // 如果开启了下级, 身份应该是消息代理, 不再转发到服务器
   if config.ClientConf.Enable && config.ServeConf.Role == "agent" {
@@ -81,7 +81,7 @@
   }
   videoLabel := req.VideoLabelListObject.VideoLabelObject[0]
   logger.Debug("Receive new message, Id:%s Ip:%s ", videoLabel.VideoLabelID, c.RemoteIP())
   logger.Debug("Receive new videoLabel message, Id:%s Ip:%s ", videoLabel.VideoLabelID, c.RemoteIP())
   // 转人员消息
   var person vo.PersonObject
@@ -182,3 +182,40 @@
   c.JSON(http.StatusOK, gin.H{"ResponseStatusObject": rspMsg})
}
func (a CaptureController) Persons(c *gin.Context) {
   var req vo.RequestPersonList
   if err := c.BindJSON(&req); err != nil {
      c.AbortWithStatus(http.StatusBadRequest)
      return
   }
   if len(req.PersonListObject.PersonObject) == 0 {
      c.AbortWithStatus(http.StatusBadRequest)
      return
   }
   person := req.PersonListObject.PersonObject[0]
   logger.Debug("Receive new person message, ip:%s, device Id:%s personId:%s, appearTime:%s", c.RemoteIP(), person.DeviceID, person.PersonID, person.PersonAppearTime)
   // 如果开启了下级, 身份应该是消息代理, 不再转发到服务器
   if config.ClientConf.Enable && config.ServeConf.Role == "agent" {
      go a.Repository.VIIDPersonMsgForward(&req)
   } else if config.ServeConf.Role == "cascade" {
      go service.AddPersonNotification(&person)
   }
   if config.ForwardConf.SyncServer != "" {
      go a.Repository.PersonForward(req.PersonListObject.PersonObject)
   }
   rspMsg := vo.ResponseStatus{
      RequestURL:   c.FullPath(),
      StatusCode:   vo.StatusSuccess,
      StatusString: vo.StatusString[vo.StatusSuccess],
      Id:           person.PersonID,
      LocalTime:    time.Now().Format("20060102150405"),
   }
   c.JSON(http.StatusOK, gin.H{"ResponseStatusObject": rspMsg})
}