From 7a19301f6972e0b81490e57200a634e4e3731a4c Mon Sep 17 00:00:00 2001
From: zhangzengfei <zhangzengfei@smartai.com>
Date: 星期四, 17 十月 2024 01:42:23 +0800
Subject: [PATCH] 完善rfid读取楼层
---
repository/captureRepo.go | 123 ++++++++++++++++++++++++++++++-----------
1 files changed, 90 insertions(+), 33 deletions(-)
diff --git a/repository/captureRepo.go b/repository/captureRepo.go
index e05a343..bb82cf5 100644
--- a/repository/captureRepo.go
+++ b/repository/captureRepo.go
@@ -10,6 +10,7 @@
"gat1400Exchange/models"
"gat1400Exchange/pkg"
"gat1400Exchange/pkg/logger"
+ "gat1400Exchange/service"
"gat1400Exchange/util"
"gat1400Exchange/vo"
)
@@ -92,15 +93,9 @@
}
// 澶勭悊姊帶濉啓鐨勬ゼ灞備俊鎭� 鏆傛椂浣跨敤otherFeature瀛楁
- if face.OtherFeature != "" {
- pd.CameraFloor = face.OtherFeature
+ if face.OtherFeature != "" && pd.CameraFloor == "" {
+ pd.Direction, pd.CameraFloor, _ = pkg.RestoreFloor(face.OtherFeature)
}
-
- // 灏濊瘯浠巉aceId鎻愬彇妤煎眰
- if pd.CameraFloor == "" && config.ClientConf.AddFloorToFaceId {
- pd.CameraFloor, _ = pkg.ParseFloorFromId(face.FaceID)
- }
- //logger.Debug("device %s, CameraFloor:%s", deviceId, pd.CameraFloor)
payload, err := json.Marshal(pd)
if err != nil {
@@ -181,10 +176,10 @@
pd.CameraFloor = v.BehaviorDescription
}
- // 灏濊瘯浠巉aceId鎻愬彇妤煎眰
- if pd.CameraFloor == "" && config.ClientConf.AddFloorToFaceId {
- pd.CameraFloor, _ = pkg.ParseFloorFromId(v.PersonID)
- }
+ //// 灏濊瘯浠巉aceId鎻愬彇妤煎眰
+ //if pd.CameraFloor == "" && config.ClientConf.AddFloorToFaceId {
+ // pd.CameraFloor, _ = pkg.ParseFloorFromId(v.PersonID)
+ //}
//logger.Debug("device %s, CameraFloor:%s", deviceId, pd.CameraFloor)
payload, err := json.Marshal(pd)
@@ -209,6 +204,7 @@
func (c CaptureRepository) PackPushDataV2(deviceId, faceId, appearTime string, bgImgBytes, faceImgBytes []byte) *vo.PushDataInfoV2 {
var pd = new(vo.PushDataInfoV2)
var floor string
+ var runDir string
faceAppearTime, err := time.ParseInLocation("20060102150405", appearTime, time.Local)
if err != nil {
@@ -216,12 +212,31 @@
faceAppearTime = time.Now()
}
- if config.ServeConf.Role == "server" {
+ // 鍒ゆ柇鏄惁闇�瑕佸尮閰嶆ゼ灞�
+ if config.NVCSConf.Model != "" {
// 鍖归厤妤煎眰
var devPos models.Positions
_ = devPos.FindDevicePosition(deviceId, faceAppearTime.Unix()+5) // 鍔�5绉掔數姊叧闂ㄧ殑鏃堕棿
floor = devPos.Pos
+
+ for i := 0; i < config.NVCSConf.WaitRunTime; i++ {
+ var dbPos models.Positions
+ if err := dbPos.FindMovePosition(faceAppearTime.Unix()+5, floor); err == nil {
+ switch dbPos.RunDir {
+ case service.RunUp:
+ runDir = "in"
+ case service.RunDown:
+ runDir = "out"
+ case service.RunStop:
+ runDir = ""
+ }
+
+ break
+ }
+
+ time.Sleep(1 * time.Second)
+ }
}
pd.PicMaxImages = append(pd.PicMaxImages, bgImgBytes)
@@ -235,6 +250,7 @@
pd.DataSource = "camera"
pd.CameraFloor = floor
pd.CameraId = deviceId
+ pd.Direction = runDir
return pd
}
@@ -252,24 +268,50 @@
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 floor, runDir string
+ var devPos models.Positions
+ _ = devPos.FindPositionByTime(faceAppearTime.Unix() + 5) // 鍔�5绉掔數姊叧闂ㄧ殑鏃堕棿
+ if devPos.Pos == "" {
+ devPos.Pos = "1F"
+ }
+
+ floor = devPos.Pos
+
+ for i := 0; i < config.NVCSConf.WaitRunTime; i++ {
+ var dbPos models.Positions
+ if err := dbPos.FindMovePosition(faceAppearTime.Unix()+5, floor); err == nil {
+ switch dbPos.RunDir {
+ case service.RunUp:
+ runDir = "1"
+ case service.RunDown:
+ runDir = "2"
+ case service.RunStop:
+ runDir = "0"
+ }
+
+ break
+ }
+
+ time.Sleep(1 * time.Second)
+ }
+
+ for idx, _ := range msg.FaceListObject.FaceObject {
+ msg.FaceListObject.FaceObject[idx].OtherFeature, _ = pkg.ParseFloor(runDir, floor)
+ //if config.ClientConf.AddFloorToFaceId {
+ // msg.FaceListObject.FaceObject[idx].FaceID = pkg.GenerateFaceIdContainFloor(face.FaceID, devPos.Pos)
+ //}
+ }
+
}
b, _ := json.Marshal(msg)
@@ -297,11 +339,11 @@
devPos.Pos = "1F"
}
- for idx, v := range msg.PersonListObject.PersonObject {
+ for idx, _ := range msg.PersonListObject.PersonObject {
msg.PersonListObject.PersonObject[idx].BehaviorDescription = devPos.Pos
- if config.ClientConf.AddFloorToFaceId {
- msg.PersonListObject.PersonObject[idx].PersonID = pkg.GenerateFaceIdContainFloor(v.PersonID, devPos.Pos)
- }
+ //if config.ClientConf.AddFloorToFaceId {
+ // msg.PersonListObject.PersonObject[idx].PersonID = pkg.GenerateFaceIdContainFloor(v.PersonID, devPos.Pos)
+ //}
}
b, _ := json.Marshal(msg)
@@ -313,3 +355,18 @@
return
}
+
+func (c CaptureRepository) PubRecordMessage(deviceId, msgId string) {
+ var msg = vo.RecordMsg{
+ CamId: deviceId,
+ MsgId: msgId,
+ }
+
+ logger.Debug("Pub record message %s, %s", deviceId, msgId)
+ body, _ := json.Marshal(&msg)
+
+ _, err := util.HttpPost(config.ForwardConf.RecordServer, nil, body)
+ if err != nil {
+ logger.Warn(err.Error())
+ }
+}
--
Gitblit v1.8.0