zhangzengfei
2024-05-25 8ba0a125eb7302d8c51d3c85cf8ea8a4de5413db
service/subscribe.go
@@ -109,10 +109,11 @@
}
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() {
@@ -148,8 +149,8 @@
   for _, subType := range subDetails {
      triggerTime := time.Now().Format("20060102150405")
      // 上报设备
      if subType == vo.SubscribeApe {
      // 上报设备 控制设备通知控制频率, 避免频繁, 上级一般会下发秒级的任务, 但设备不会频繁更新,
      if subType == vo.SubscribeApe && time.Now().Unix()-task.lastExecTime > 60*10 {
         var notification = vo.DeviceNotification{
            NotificationID:   triggerTime + snowflake.GenerateIdStr(),
            SubscribeID:      task.conf.Id,
@@ -218,4 +219,6 @@
         client.Notify(task.conf.Ext.ReceiveAddr, b)
      }
   }
   task.lastExecTime = time.Now().Unix()
}