zhangzengfei
2024-08-22 b93d95a77ae3681a8c97859f446644190e84170e
repository/captureRepo.go
@@ -10,6 +10,7 @@
   "gat1400Exchange/models"
   "gat1400Exchange/pkg"
   "gat1400Exchange/pkg/logger"
   "gat1400Exchange/service"
   "gat1400Exchange/util"
   "gat1400Exchange/vo"
)
@@ -209,6 +210,7 @@
func (c CaptureRepository) PackPushDataV2(deviceId, faceId, appearTime string, bgImgBytes, faceImgBytes []byte) *vo.PushDataInfoV2 {
   var pd = new(vo.PushDataInfoV2)
   var floor string
   var runDir string
   faceAppearTime, err := time.ParseInLocation("20060102150405", appearTime, time.Local)
   if err != nil {
@@ -216,12 +218,31 @@
      faceAppearTime = time.Now()
   }
   if config.ServeConf.Role == "server" {
   // 判断是否需要匹配楼层
   if config.NVCSConf.Model != "" {
      // 匹配楼层
      var devPos models.Positions
      _ = devPos.FindDevicePosition(deviceId, faceAppearTime.Unix()+5) // 加5秒电梯关门的时间
      floor = devPos.Pos
      stopFloorId := devPos.Id
      for i := 0; i < 30; i++ {
         if err := devPos.FindMovePosition(stopFloorId, floor); err == nil {
            switch devPos.RunDir {
            case service.RunUp:
               runDir = "in"
            case service.RunDown:
               runDir = "out"
            case service.RunStop:
               runDir = ""
            }
            break
         }
         time.Sleep(1 * time.Second)
      }
   }
   pd.PicMaxImages = append(pd.PicMaxImages, bgImgBytes)
@@ -235,6 +256,7 @@
   pd.DataSource = "camera"
   pd.CameraFloor = floor
   pd.CameraId = deviceId
   pd.Direction = runDir
   return pd
}
@@ -325,10 +347,10 @@
      MsgId: msgId,
   }
   logger.Debug("Pub record message %s, %s", deviceId,msgId)
   logger.Debug("Pub record message %s, %s", deviceId, msgId)
   body, _ := json.Marshal(&msg)
   _,err := util.HttpPost(config.ForwardConf.RecordServer, nil, body)
   _, err := util.HttpPost(config.ForwardConf.RecordServer, nil, body)
   if err != nil {
      logger.Warn(err.Error())
   }