| | |
| | | |
| | | func (c CaptureRepository) FaceForward(faceList []vo.FaceObject) { |
| | | if faceList == nil || len(faceList) == 0 { |
| | | logger.Warn("faceList is nil") |
| | | logger.Warn("FaceList is nil") |
| | | return |
| | | } |
| | | |
| | |
| | | return |
| | | } |
| | | |
| | | if !c.SendData(payload, config.ForwardConf.SyncServer) { |
| | | c.CacheData(payload) |
| | | logger.Warn("数据转发失败, 添加缓存") |
| | | if !util.SendData(payload, config.ForwardConf.SyncServer) { |
| | | cacheItem, _ := json.Marshal(pd) |
| | | c.CacheData(cacheItem) |
| | | logger.Warn("The data forwarding failed, adding to local cache.") |
| | | } else { |
| | | logger.Debug("数据转发成功") |
| | | logger.Debug("The data forwarding successful. deviceId:%s", deviceId) |
| | | } |
| | | } |
| | | } |
| | |
| | | } |
| | | |
| | | return pd |
| | | } |
| | | |
| | | func (c CaptureRepository) SendData(payload []byte, url string) bool { |
| | | body, err := util.HttpPost(url, nil, payload) |
| | | if err != nil { |
| | | logger.Error("Post request failure, url:%s, err:%s", err.Error()) |
| | | return false |
| | | } |
| | | |
| | | var rsp vo.SyncServerResponse |
| | | err = json.Unmarshal(body, &rsp) |
| | | if err != nil { |
| | | logger.Error("Can't parse response, url:%s, rsp: %v", url, body) |
| | | return false |
| | | } |
| | | |
| | | return rsp.Success |
| | | } |
| | | |
| | | func (c CaptureRepository) CacheData(payload []byte) { |