From c69f721df41c9c7c1e2e9a5f167c881c04536986 Mon Sep 17 00:00:00 2001
From: zhangzengfei <zhangzengfei@smartai.com>
Date: 星期一, 03 六月 2024 19:44:30 +0800
Subject: [PATCH] 添加人员订阅

---
 config/config.go           |    1 +
 vo/subscribe.go            |   11 +++++++++++
 service/notification.go    |   41 +++++++++++++++++++++++++++++++++++++++--
 controller/subscribeCtl.go |    4 ++++
 4 files changed, 55 insertions(+), 2 deletions(-)

diff --git a/config/config.go b/config/config.go
index 9e6034b..7515d62 100644
--- a/config/config.go
+++ b/config/config.go
@@ -77,6 +77,7 @@
 	v := viper.New()
 	v.SetConfigType("yaml")
 	v.SetConfigName("gat1400")
+	v.AddConfigPath("./")
 	v.AddConfigPath("./config/")
 	v.AddConfigPath("../config/")
 	err = v.ReadInConfig()
diff --git a/controller/subscribeCtl.go b/controller/subscribeCtl.go
index 99058f0..cf4fe73 100644
--- a/controller/subscribeCtl.go
+++ b/controller/subscribeCtl.go
@@ -133,6 +133,10 @@
 			go s.Capture.FaceForward(msg.FaceObjectList.FaceObject)
 		}
 
+		if config.ForwardConf.SyncServer != "" && len(msg.PersonObjectList.PersonObject) > 0 {
+			go s.Capture.PersonForward(msg.PersonObjectList.PersonObject)
+		}
+
 		if len(msg.DeviceList.APEObject) > 0 {
 			fromId := c.GetHeader("User-Identify")
 			go s.Ape.HandleNotification(fromId, msg.DeviceList.APEObject)
diff --git a/service/notification.go b/service/notification.go
index 1605025..32b67a1 100644
--- a/service/notification.go
+++ b/service/notification.go
@@ -115,7 +115,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.faceList) == 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 +191,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
 }
diff --git a/vo/subscribe.go b/vo/subscribe.go
index 322dfe7..7fd2300 100644
--- a/vo/subscribe.go
+++ b/vo/subscribe.go
@@ -89,6 +89,16 @@
 	FaceObjectList   NotificationFaceList
 }
 
+type PersonNotification struct {
+	NotificationID   string
+	SubscribeID      string
+	Title            string
+	TriggerTime      string
+	InfoIDs          string
+	ExecuteOperation int
+	PersonObjectList NotificationPersonList
+}
+
 type Notification struct {
 	NotificationID   string
 	SubscribeID      string
@@ -98,4 +108,5 @@
 	ExecuteOperation int
 	DeviceList       NotificationApeList
 	FaceObjectList   NotificationFaceList
+	PersonObjectList NotificationPersonList
 }

--
Gitblit v1.8.0