| | |
| | | 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 { |
| | | var pd = new(vo.PushDataInfo) |
| | | var device models.Device |
| | |
| | | return pd |
| | | } |
| | | |
| | | 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秒电梯关门的时间 |
| | | if devPos.Pos == "" { |
| | | devPos.Pos = device.Pos |
| | | } |
| | | |
| | | 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) CacheData(payload []byte) { |
| | | var cacheItem = models.Cache{ |
| | | Data: string(payload), |