| | |
| | | } |
| | | |
| | | type SubscribeTask struct { |
| | | ctx context.Context |
| | | conf *models.Subscribe |
| | | faceList []*vo.FaceObject |
| | | mutex sync.Mutex |
| | | ctx context.Context |
| | | conf *models.Subscribe |
| | | faceList []*vo.FaceObject |
| | | mutex sync.Mutex |
| | | lastExecTime int64 |
| | | } |
| | | |
| | | func (task *SubscribeTask) Start() { |
| | |
| | | |
| | | // 上报设备 |
| | | if subType == vo.SubscribeApe { |
| | | // 设备通知控制频率, 避免频繁, 上级一般会下发秒级的任务, 但设备不会频繁更新, |
| | | if time.Now().Unix()-task.lastExecTime < 60*10 { |
| | | continue |
| | | } |
| | | |
| | | var notification = vo.DeviceNotification{ |
| | | NotificationID: triggerTime + snowflake.GenerateIdStr(), |
| | | SubscribeID: task.conf.Id, |
| | |
| | | client.Notify(task.conf.Ext.ReceiveAddr, b) |
| | | } |
| | | } |
| | | |
| | | task.lastExecTime = time.Now().Unix() |
| | | } |