From 5ddd4f4ba6aaf1fe52f93c0966315d0424bd2a5f Mon Sep 17 00:00:00 2001
From: zhangzengfei <zhangzengfei@smartai.com>
Date: 星期日, 20 十月 2024 20:30:57 +0800
Subject: [PATCH] 调整楼层获取方式

---
 repository/captureRepo.go |   45 +++++++++++++++------------------------------
 1 files changed, 15 insertions(+), 30 deletions(-)

diff --git a/repository/captureRepo.go b/repository/captureRepo.go
index 9941a4a..73f0347 100644
--- a/repository/captureRepo.go
+++ b/repository/captureRepo.go
@@ -3,12 +3,12 @@
 import (
 	"encoding/base64"
 	"encoding/json"
-	"gat1400Exchange/nvcs"
 	"time"
 
 	"gat1400Exchange/client"
 	"gat1400Exchange/config"
 	"gat1400Exchange/models"
+	"gat1400Exchange/nvcs"
 	"gat1400Exchange/pkg"
 	"gat1400Exchange/pkg/logger"
 	"gat1400Exchange/util"
@@ -214,16 +214,12 @@
 
 	// 鍒ゆ柇鏄惁闇�瑕佸尮閰嶆ゼ灞�
 	if config.NVCSConf.Model != "" {
-		// 鍖归厤妤煎眰
-		var devPos models.Positions
-		_ = devPos.FindDevicePosition(deviceId, faceAppearTime.Unix()+5) // 鍔�5绉掔數姊叧闂ㄧ殑鏃堕棿
-
-		floor = devPos.Pos
+		runState := nvcs.FindPositionByTime(faceAppearTime.Unix() + 3) // 鍔�3绉掔數姊叧闂ㄧ殑鏃堕棿
+		floor = runState.Floor
 
 		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 {
+			if runState = nvcs.FindMovePosition(faceAppearTime.Unix()+3, floor); runState.Floor != "" {
+				switch runState.RunState {
 				case nvcs.RunUp:
 					runDir = "in"
 				case nvcs.RunDown:
@@ -268,6 +264,7 @@
 
 func (c CaptureRepository) VIIDFaceMsgForward(msg *vo.RequestFaceList) {
 	faceInfo := msg.FaceListObject.FaceObject[0]
+	var floor, runDir string
 
 	// 鍒ゆ柇鏄惁寮�鍚簡姊帶
 	if config.NVCSConf.Model != "" {
@@ -278,25 +275,18 @@
 			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
+		runState := nvcs.FindPositionByTime(faceAppearTime.Unix() + 3) // 鍔�3绉掔數姊叧闂ㄧ殑鏃堕棿
+		floor = runState.Floor
 
 		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 {
+			if runState = nvcs.FindMovePosition(faceAppearTime.Unix()+3, floor); runState.Floor != "" {
+				switch runState.RunState {
 				case nvcs.RunUp:
-					runDir = "1"
+					runDir = "in"
 				case nvcs.RunDown:
-					runDir = "2"
+					runDir = "out"
 				case nvcs.RunStop:
-					runDir = "0"
+					runDir = ""
 				}
 
 				break
@@ -311,7 +301,6 @@
 			//	msg.FaceListObject.FaceObject[idx].FaceID = pkg.GenerateFaceIdContainFloor(face.FaceID, devPos.Pos)
 			//}
 		}
-
 	}
 
 	b, _ := json.Marshal(msg)
@@ -333,14 +322,10 @@
 		appearTime = time.Now()
 	}
 
-	var devPos models.Positions
-	_ = devPos.FindPositionByTime(appearTime.Unix() + 5) // 鍔�5绉掔數姊叧闂ㄧ殑鏃堕棿
-	if devPos.Pos == "" {
-		devPos.Pos = "1F"
-	}
+	runState := nvcs.FindPositionByTime(appearTime.Unix() + 3) // 鍔�3绉掔數姊叧闂ㄧ殑鏃堕棿
 
 	for idx, _ := range msg.PersonListObject.PersonObject {
-		msg.PersonListObject.PersonObject[idx].BehaviorDescription = devPos.Pos
+		msg.PersonListObject.PersonObject[idx].BehaviorDescription = runState.Floor
 		//if config.ClientConf.AddFloorToFaceId {
 		//	msg.PersonListObject.PersonObject[idx].PersonID = pkg.GenerateFaceIdContainFloor(v.PersonID, devPos.Pos)
 		//}

--
Gitblit v1.8.0