From 4151389fb92c3f1444d033c1eed0a76165799eea Mon Sep 17 00:00:00 2001
From: zhangzengfei <zhangzengfei@smartai.com>
Date: 星期四, 13 六月 2024 00:37:37 +0800
Subject: [PATCH] 修改otherfature的数据格式
---
pkg/floor.go | 12 ++++++------
service/resend.go | 6 +++++-
repository/captureRepo.go | 39 ++++++++++++++++++++++-----------------
3 files changed, 33 insertions(+), 24 deletions(-)
diff --git a/pkg/floor.go b/pkg/floor.go
index 1e2ff9a..379d22b 100644
--- a/pkg/floor.go
+++ b/pkg/floor.go
@@ -9,7 +9,7 @@
// 鐢熸垚涓�涓寘鍚ゼ灞傜殑浜鸿劯id,瑙f瀽妤煎眰
// 浣跨敤48浣嶆簮id, 鍏朵腑鍓�41浣嶆槸imageid, 涓嶅彲浠ヤ慨鏀� 41-43浣嶅~ 06 浠h〃鍥惧儚, +99 + 3浣嶆ゼ灞�(绗竴浣�0琛ㄧず姝�,1琛ㄧず璐�)
func GenerateFaceIdContainFloor(srcId, floorStr string) string {
- floorNum, _ := parseFloor(floorStr)
+ floorNum, _ := ParseFloor(floorStr)
newId := srcId[0:43] + "99" + floorNum
//newId := srcId[0:43] + "99" + floorNum + snowflake.CreateRandomNumber(1)
@@ -25,11 +25,11 @@
return "", fmt.Errorf("invalid flag %s", srcId[43:45])
}
- return restoreFloor(srcId[45:48])
+ return RestoreFloor(srcId[45:48])
}
-// parseFloor parses the floor string and returns a three-character string
-func parseFloor(floor string) (string, error) {
+// ParseFloor parses the floor string and returns a three-character string
+func ParseFloor(floor string) (string, error) {
var sign string
var number string
@@ -53,8 +53,8 @@
return sign + formattedNumber, nil
}
-// restoreFloor restores the three-character string back to the original floor string
-func restoreFloor(encoded string) (string, error) {
+// RestoreFloor restores the three-character string back to the original floor string
+func RestoreFloor(encoded string) (string, error) {
if len(encoded) != 3 {
return "", fmt.Errorf("encoded string must be 3 characters long")
}
diff --git a/repository/captureRepo.go b/repository/captureRepo.go
index e05a343..7943cc6 100644
--- a/repository/captureRepo.go
+++ b/repository/captureRepo.go
@@ -93,7 +93,7 @@
// 澶勭悊姊帶濉啓鐨勬ゼ灞備俊鎭� 鏆傛椂浣跨敤otherFeature瀛楁
if face.OtherFeature != "" {
- pd.CameraFloor = face.OtherFeature
+ pd.CameraFloor, _ = pkg.RestoreFloor(face.OtherFeature)
}
// 灏濊瘯浠巉aceId鎻愬彇妤煎眰
@@ -252,24 +252,29 @@
func (c CaptureRepository) VIIDFaceMsgForward(msg *vo.RequestFaceList) {
faceInfo := msg.FaceListObject.FaceObject[0]
- // 鍖归厤妤煎眰
- faceAppearTime, err := time.ParseInLocation("20060102150405", faceInfo.FaceAppearTime, time.Local)
- if err != nil {
- logger.Warn("Parse face appear time error, %s", err.Error())
- faceAppearTime = time.Now()
- }
- var devPos models.Positions
- _ = devPos.FindPositionByTime(faceAppearTime.Unix() + 5) // 鍔�5绉掔數姊叧闂ㄧ殑鏃堕棿
- if devPos.Pos == "" {
- devPos.Pos = "1F"
- }
-
- for idx, face := range msg.FaceListObject.FaceObject {
- msg.FaceListObject.FaceObject[idx].OtherFeature = devPos.Pos
- if config.ClientConf.AddFloorToFaceId {
- msg.FaceListObject.FaceObject[idx].FaceID = pkg.GenerateFaceIdContainFloor(face.FaceID, devPos.Pos)
+ // 鍒ゆ柇鏄惁寮�鍚簡姊帶
+ if config.NVCSConf.Model != "" {
+ // 鍖归厤妤煎眰
+ faceAppearTime, err := time.ParseInLocation("20060102150405", faceInfo.FaceAppearTime, time.Local)
+ if err != nil {
+ logger.Warn("Parse face appear time error, %s", err.Error())
+ faceAppearTime = time.Now()
}
+
+ var devPos models.Positions
+ _ = devPos.FindPositionByTime(faceAppearTime.Unix() + 5) // 鍔�5绉掔數姊叧闂ㄧ殑鏃堕棿
+ if devPos.Pos == "" {
+ devPos.Pos = "1F"
+ }
+
+ for idx, face := range msg.FaceListObject.FaceObject {
+ msg.FaceListObject.FaceObject[idx].OtherFeature, _ = pkg.ParseFloor(devPos.Pos)
+ if config.ClientConf.AddFloorToFaceId {
+ msg.FaceListObject.FaceObject[idx].FaceID = pkg.GenerateFaceIdContainFloor(face.FaceID, devPos.Pos)
+ }
+ }
+
}
b, _ := json.Marshal(msg)
diff --git a/service/resend.go b/service/resend.go
index 667b237..6961f45 100644
--- a/service/resend.go
+++ b/service/resend.go
@@ -20,7 +20,11 @@
var cacheMod models.Cache
total, _ := cacheMod.Count()
- logger.Debug("Start resend task. cache len:%d", total)
+ if total == 0 {
+ return
+ }
+
+ logger.Info("Start resend task. cache len:%d", total)
for i := 0; i < int(total); i++ {
var c models.Cache
--
Gitblit v1.8.0