From b4a86051e9bf4888fd5d01c12232a26f3874e03b Mon Sep 17 00:00:00 2001
From: zhangzengfei <zhangzengfei@smartai.com>
Date: 星期四, 17 十月 2024 21:30:18 +0800
Subject: [PATCH] 完善epc读取楼层

---
 service/notification.go |   44 ++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 42 insertions(+), 2 deletions(-)

diff --git a/service/notification.go b/service/notification.go
index 1605025..060fe51 100644
--- a/service/notification.go
+++ b/service/notification.go
@@ -48,6 +48,7 @@
 	task.mutex.Lock()
 	defer task.mutex.Unlock()
 
+	logger.Debug("Add Face Notification %s. faceId: %s", task.conf.Ext.Title, face.FaceID)
 	task.faceList = append(task.faceList, face)
 }
 
@@ -59,6 +60,7 @@
 	task.mutex.Lock()
 	defer task.mutex.Unlock()
 
+	logger.Debug("Add Person Notification  %s. personId: %s", task.conf.Ext.Title, person.PersonID)
 	task.personList = append(task.personList, person)
 }
 
@@ -72,6 +74,7 @@
 		case vo.SubscribeFace:
 			msg = task.packFaceNotificationMsg()
 		case vo.SubscribePerson:
+			msg = task.packPersonNotificationMsg()
 		}
 
 		if msg != nil {
@@ -115,7 +118,44 @@
 	task.mutex.Unlock()
 
 	var req vo.RequestSubscribeNotification
-	req.SubscribeNotificationListObject.SubscribeNotificationObject[0] = notification
+	req.SubscribeNotificationListObject.SubscribeNotificationObject = append(req.SubscribeNotificationListObject.SubscribeNotificationObject, notification)
+
+	return &req
+}
+
+func (task *NotificationTask) packPersonNotificationMsg() *vo.RequestSubscribeNotification {
+	triggerTime := time.Now().Format("20060102150405")
+	if len(task.personList) == 0 {
+		return nil
+	}
+
+	var notification = vo.PersonNotification{
+		NotificationID:   triggerTime + snowflake.GenerateIdStr(),
+		SubscribeID:      task.conf.Id,
+		Title:            task.conf.Ext.Title,
+		TriggerTime:      triggerTime,
+		ExecuteOperation: 1,
+	}
+
+	var ids []string
+	for idx, _ := range task.personList {
+		// 鎸夋捣搴风ず渚嬪~鍏呬慨鏀瑰瓧娈�
+		for i, _ := range task.personList[idx].SubImageList.SubImageInfoObject {
+			task.personList[idx].SubImageList.SubImageInfoObject[i].EventSort = 2
+		}
+
+		ids = append(ids, task.personList[idx].PersonID)
+		notification.PersonObjectList.PersonObject = append(notification.PersonObjectList.PersonObject, *task.personList[idx])
+	}
+
+	notification.InfoIDs = strings.Join(ids, ";")
+
+	task.mutex.Lock()
+	task.personList = []*vo.PersonObject{}
+	task.mutex.Unlock()
+
+	var req vo.RequestSubscribeNotification
+	req.SubscribeNotificationListObject.SubscribeNotificationObject = append(req.SubscribeNotificationListObject.SubscribeNotificationObject, notification)
 
 	return &req
 }
@@ -154,7 +194,7 @@
 	notification.InfoIDs = strings.Join(ids, ";")
 
 	var req vo.RequestSubscribeNotification
-	req.SubscribeNotificationListObject.SubscribeNotificationObject[0] = notification
+	req.SubscribeNotificationListObject.SubscribeNotificationObject = append(req.SubscribeNotificationListObject.SubscribeNotificationObject, notification)
 
 	return &req
 }

--
Gitblit v1.8.0