| | |
| | | // 转发图像 |
| | | logger.Debug("准备转发,deviceId:%s, image len:%d, server:%s", deviceId, len(faceImageStr), config.ForwardConf.SyncServer) |
| | | if deviceId != "" && faceImageStr != "" && config.ForwardConf.SyncServer != "" { |
| | | pd := c.PackPushData(deviceId, faceId, faceImageStr, face.FaceAppearTime) |
| | | pd := c.PackPushDataV2(deviceId, faceId, faceImageStr, face.FaceAppearTime) |
| | | if pd == nil { |
| | | return |
| | | } |
| | |
| | | } |
| | | |
| | | return |
| | | } |
| | | |
| | | func (c CaptureRepository) PackPushDataV2(deviceId, faceId, faceImage, appearTime string) *vo.PushDataInfoV2 { |
| | | var pd = new(vo.PushDataInfoV2) |
| | | var device models.Device |
| | | |
| | | if err := device.FindById(deviceId); err != nil { |
| | | logger.Warn("Can't find device in database, device:%s, %s", deviceId, err.Error()) |
| | | return pd |
| | | } |
| | | |
| | | // 匹配楼层 |
| | | faceAppearTime, err := time.ParseInLocation("20060102150405", appearTime, time.Local) |
| | | if err != nil { |
| | | logger.Warn("Parse face appear time error,%s", err.Error()) |
| | | faceAppearTime = time.Now() |
| | | } |
| | | |
| | | var devPos models.Positions |
| | | _ = devPos.FindDevicePosition(deviceId, faceAppearTime.Unix()+5) // 加5秒电梯关门的时间 |
| | | |
| | | imageBytes, err := base64.StdEncoding.DecodeString(faceImage) |
| | | if err != nil { |
| | | logger.Warn("Decode Image Base64 String failure,%s", err.Error()) |
| | | return pd |
| | | } |
| | | |
| | | pd.PicMaxImages = append(pd.PicMaxImages, imageBytes) |
| | | pd.PicId = faceId |
| | | pd.PicDate = faceAppearTime.Format("2006-01-02 15:04:05") |
| | | pd.DataSource = "camera" |
| | | pd.CameraFloor = devPos.Pos |
| | | pd.CameraId = deviceId |
| | | |
| | | return pd |
| | | } |
| | | |
| | | func (c CaptureRepository) PackPushData(deviceId, faceId, faceImage, appearTime string) *vo.PushDataInfo { |
| | |
| | | return pd |
| | | } |
| | | |
| | | func (c CaptureRepository) SendData(pushDataInfo *vo.PushDataInfo, url string) (id string, err error) { |
| | | func (c CaptureRepository) SendData(pushDataInfo interface{}, url string) (id string, err error) { |
| | | id = "" |
| | | payload, err := json.Marshal(pushDataInfo) |
| | | if err != nil { |