zhangzengfei
2024-05-27 4fa01e289643bc1b91878e28976b494ebaa148f0
修改更新订阅的模块
3个文件已修改
20 ■■■■■ 已修改文件
controller/subscribeCtl.go 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
repository/captureRepo.go 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
service/subscribe.go 16 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
controller/subscribeCtl.go
@@ -80,6 +80,8 @@
                Id:           sub.SubscribeID,
                LocalTime:    time.Now().Format("20060102150405"),
            })
        } else {
            logger.Error("Update receive subscribe failure, %s", err.Error())
        }
    }
repository/captureRepo.go
@@ -33,7 +33,6 @@
            logger.Warn("SubImageInfoObject is nil")
            continue
        }
        var deviceId = face.DeviceID
        var faceId = face.FaceID
        var bgImageStr, imageType string
@@ -95,6 +94,7 @@
            if face.OtherFeature != "" {
                pd.CameraFloor = face.OtherFeature
            }
            //logger.Debug("device %s, CameraFloor:%s", deviceId, pd.CameraFloor)
            payload, err := json.Marshal(pd)
            if err != nil {
service/subscribe.go
@@ -109,11 +109,11 @@
}
type SubscribeTask struct {
    ctx          context.Context
    conf         *models.Subscribe
    faceList     []*vo.FaceObject
    mutex        sync.Mutex
    lastExecTime int64
    ctx             context.Context
    conf            *models.Subscribe
    faceList        []*vo.FaceObject
    mutex           sync.Mutex
    lastApeExecTime int64
}
func (task *SubscribeTask) Start() {
@@ -150,7 +150,9 @@
        triggerTime := time.Now().Format("20060102150405")
        // 上报设备 控制设备通知控制频率, 避免频繁, 上级一般会下发秒级的任务, 但设备不会频繁更新,
        if subType == vo.SubscribeApe && time.Now().Unix()-task.lastExecTime > 60*10 {
        if subType == vo.SubscribeApe && time.Now().Unix()-task.lastApeExecTime > 60*10 {
            task.lastApeExecTime = time.Now().Unix()
            var notification = vo.DeviceNotification{
                NotificationID:   triggerTime + snowflake.GenerateIdStr(),
                SubscribeID:      task.conf.Id,
@@ -219,6 +221,4 @@
            client.Notify(task.conf.Ext.ReceiveAddr, b)
        }
    }
    task.lastExecTime = time.Now().Unix()
}