From 4fa01e289643bc1b91878e28976b494ebaa148f0 Mon Sep 17 00:00:00 2001 From: zhangzengfei <zhangzengfei@smartai.com> Date: 星期一, 27 五月 2024 17:46:31 +0800 Subject: [PATCH] 修改更新订阅的模块 --- service/subscribe.go | 16 ++++++++-------- repository/captureRepo.go | 2 +- controller/subscribeCtl.go | 2 ++ 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/controller/subscribeCtl.go b/controller/subscribeCtl.go index 3e470e2..99058f0 100644 --- a/controller/subscribeCtl.go +++ b/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()) } } diff --git a/repository/captureRepo.go b/repository/captureRepo.go index 1c33540..541578e 100644 --- a/repository/captureRepo.go +++ b/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 { diff --git a/service/subscribe.go b/service/subscribe.go index a2f0192..70853cf 100644 --- a/service/subscribe.go +++ b/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() } -- Gitblit v1.8.0