From 6f26cb4297ebaab4394e05e1a498e347ce290bb5 Mon Sep 17 00:00:00 2001
From: zhangzengfei <zhangzengfei@smartai.com>
Date: 星期四, 22 八月 2024 19:36:28 +0800
Subject: [PATCH] 修复运行方向的bug
---
controller/captureCtl.go | 70 ++++++++++++++++++++++++++++++++++-
1 files changed, 68 insertions(+), 2 deletions(-)
diff --git a/controller/captureCtl.go b/controller/captureCtl.go
index 8f3d784..79efc0f 100644
--- a/controller/captureCtl.go
+++ b/controller/captureCtl.go
@@ -5,6 +5,7 @@
"fmt"
"math/rand"
"net/http"
+ "path"
"strconv"
"time"
@@ -13,6 +14,7 @@
"gat1400Exchange/pkg/logger"
"gat1400Exchange/repository"
"gat1400Exchange/service"
+ "gat1400Exchange/util"
"gat1400Exchange/vo"
"github.com/gin-gonic/gin"
@@ -44,7 +46,30 @@
}
face := req.FaceListObject.FaceObject[0]
- logger.Debug("Receive new message, Id:%s Ip:%s faceId:%s, LeftTopX:%d, appearTime:%s", c.RemoteIP(), face.DeviceID, face.FaceID, face.LeftTopX, face.FaceAppearTime)
+ logger.Debug("Receive new face message, ip:%s, device id:%s faceId:%s, LeftTopX:%d, appearTime:%s", c.RemoteIP(), face.DeviceID, face.FaceID, face.LeftTopX, face.FaceAppearTime)
+
+ if config.ClientConf.UploadType == "url" {
+ for idx, img := range face.SubImageList.SubImageInfoObject {
+ if img.Type != "14" {
+ continue
+ }
+
+ imageBytes, err := base64.StdEncoding.DecodeString(img.Data)
+ if err != nil {
+ logger.Warn("Decode Small Image Base64 String failure, %s", err.Error())
+ c.AbortWithStatus(http.StatusBadRequest)
+ return
+ }
+
+ today := time.Now().Format("2006-01-02")
+ imagePath := path.Join(config.LogConf.Path, "gat1400_face_images", today, img.ImageID+".jpeg")
+ err = util.WriteToFile(imagePath, imageBytes)
+ if err == nil {
+ face.SubImageList.SubImageInfoObject[idx].Data = ""
+ face.SubImageList.SubImageInfoObject[idx].StoragePath = config.ImageConf.ImageUriPrefix + "/" + today + "/" + img.ImageID + ".jpeg"
+ }
+ }
+ }
// 濡傛灉寮�鍚簡涓嬬骇, 韬唤搴旇鏄秷鎭唬鐞�, 涓嶅啀杞彂鍒版湇鍔″櫒
if config.ClientConf.Enable && config.ServeConf.Role == "agent" {
@@ -55,6 +80,10 @@
if config.ForwardConf.SyncServer != "" {
go a.Repository.FaceForward(req.FaceListObject.FaceObject)
+ }
+
+ if config.ForwardConf.RecordServer != "" {
+ go a.Repository.PubRecordMessage(face.DeviceID, face.FaceID)
}
rspMsg := vo.ResponseStatus{
@@ -81,7 +110,7 @@
}
videoLabel := req.VideoLabelListObject.VideoLabelObject[0]
- logger.Debug("Receive new message, Id:%s Ip:%s ", videoLabel.VideoLabelID, c.RemoteIP())
+ logger.Debug("Receive new videoLabel message, Id:%s Ip:%s ", videoLabel.VideoLabelID, c.RemoteIP())
// 杞汉鍛樻秷鎭�
var person vo.PersonObject
@@ -182,3 +211,40 @@
c.JSON(http.StatusOK, gin.H{"ResponseStatusObject": rspMsg})
}
+
+func (a CaptureController) Persons(c *gin.Context) {
+ var req vo.RequestPersonList
+ if err := c.BindJSON(&req); err != nil {
+ c.AbortWithStatus(http.StatusBadRequest)
+ return
+ }
+
+ if len(req.PersonListObject.PersonObject) == 0 {
+ c.AbortWithStatus(http.StatusBadRequest)
+ return
+ }
+
+ person := req.PersonListObject.PersonObject[0]
+ logger.Debug("Receive new person message, ip:%s, device Id:%s personId:%s, appearTime:%s", c.RemoteIP(), person.DeviceID, person.PersonID, person.PersonAppearTime)
+
+ // 濡傛灉寮�鍚簡涓嬬骇, 韬唤搴旇鏄秷鎭唬鐞�, 涓嶅啀杞彂鍒版湇鍔″櫒
+ if config.ClientConf.Enable && config.ServeConf.Role == "agent" {
+ go a.Repository.VIIDPersonMsgForward(&req)
+ } else if config.ServeConf.Role == "cascade" {
+ go service.AddPersonNotification(&person)
+ }
+
+ if config.ForwardConf.SyncServer != "" {
+ go a.Repository.PersonForward(req.PersonListObject.PersonObject)
+ }
+
+ rspMsg := vo.ResponseStatus{
+ RequestURL: c.FullPath(),
+ StatusCode: vo.StatusSuccess,
+ StatusString: vo.StatusString[vo.StatusSuccess],
+ Id: person.PersonID,
+ LocalTime: time.Now().Format("20060102150405"),
+ }
+
+ c.JSON(http.StatusOK, gin.H{"ResponseStatusObject": rspMsg})
+}
--
Gitblit v1.8.0