From b5166ec34cea995536384391712373f1d0d69e28 Mon Sep 17 00:00:00 2001
From: zhangzengfei <zhangzengfei@smartai.com>
Date: 星期二, 28 五月 2024 17:53:25 +0800
Subject: [PATCH] 修改新 face id 格式
---
repository/captureRepo.go | 79 +++++----------------------------------
1 files changed, 10 insertions(+), 69 deletions(-)
diff --git a/repository/captureRepo.go b/repository/captureRepo.go
index 505d6dc..57f5e23 100644
--- a/repository/captureRepo.go
+++ b/repository/captureRepo.go
@@ -3,6 +3,7 @@
import (
"encoding/base64"
"encoding/json"
+ "gat1400Exchange/pkg"
"time"
"gat1400Exchange/client"
@@ -11,8 +12,6 @@
"gat1400Exchange/pkg/logger"
"gat1400Exchange/util"
"gat1400Exchange/vo"
-
- uuid "github.com/satori/go.uuid"
)
type CaptureRepository struct {
@@ -35,7 +34,6 @@
logger.Warn("SubImageInfoObject is nil")
continue
}
-
var deviceId = face.DeviceID
var faceId = face.FaceID
var bgImageStr, imageType string
@@ -43,7 +41,7 @@
// 鑾峰彇澶у浘, 鐩墠娴峰悍鐨勫皬鍥惧垎杈ㄧ巼澶綆
for _, image := range face.SubImageList.SubImageInfoObject {
- if imageType != "14" {
+ if image.Type != "14" {
continue
}
@@ -98,6 +96,12 @@
pd.CameraFloor = face.OtherFeature
}
+ // 灏濊瘯浠巉aceId鎻愬彇妤煎眰
+ if pd.CameraFloor == "" {
+ pd.CameraFloor, _ = pkg.ParseFloorFromId(face.FaceID)
+ }
+ //logger.Debug("device %s, CameraFloor:%s", deviceId, pd.CameraFloor)
+
payload, err := json.Marshal(pd)
if err != nil {
logger.Warn("Marshal error, %s", err.Error())
@@ -117,60 +121,6 @@
return
}
-func (c CaptureRepository) PackPushData(deviceId, faceId, faceImage, appearTime string) *vo.PushDataInfo {
- var pd = new(vo.PushDataInfo)
- var device models.Device
-
- if err := device.FindById(deviceId); err != nil {
- logger.Warn("Can't find device in database, device:%s, %s", deviceId, err.Error())
- return pd
- }
-
- // 鍖归厤妤煎眰
- faceAppearTime, err := time.ParseInLocation("20060102150405", appearTime, time.Local)
- if err != nil {
- logger.Warn("Parse face appear time error, %s", err.Error())
- faceAppearTime = time.Now()
- }
-
- // 鐢垫鍋滄鐨勬椂闂�
- devStopTime := time.Now().Format("2006-01-02 15:04:05")
- var devPos models.Positions
- _ = devPos.FindDevicePosition(deviceId, faceAppearTime.Unix()+5) // 鍔�5绉掔數姊叧闂ㄧ殑鏃堕棿
- if devPos.TimeString != "" {
- devStopTime = devPos.TimeString
- }
-
- imageBytes, err := base64.StdEncoding.DecodeString(faceImage)
- if err != nil {
- logger.Warn("Decode Image Base64 String failure, %s", err.Error())
- return pd
- }
-
- pd.PicMaxImages = append(pd.PicMaxImages, imageBytes)
-
- tr := vo.TaskResultInfo{
- Id: uuid.NewV4().String(),
- CameraId: deviceId,
- CameraAddr: device.Addr + devPos.Pos,
- CameraName: device.Name,
- PicMaxUrl: []string{""},
- PicDate: faceAppearTime.Format("2006-01-02 15:04:05"),
- LikeDate: devStopTime,
- AnalyServerId: deviceId,
- DataSource: "camera",
- TargetInfo: []vo.TargetInfo{{TargetId: faceId}},
- }
-
- pd.SourceData = vo.ESInfo{
- TaskResultInfo: tr,
- Version: "3.3",
- UpdateTime: time.Now().Format("2006-01-02 15:04:05"),
- }
-
- return pd
-}
-
func (c CaptureRepository) PackPushDataV2(deviceId, faceId, appearTime string, bgImgBytes, faceImgBytes []byte) *vo.PushDataInfoV2 {
var pd = new(vo.PushDataInfoV2)
var floor string
@@ -182,19 +132,9 @@
}
if config.ServeConf.Role == "server" {
- var device models.Device
-
- if err := device.FindById(deviceId); err != nil {
- logger.Warn("Can't find device in database, device:%s, %s", deviceId, err.Error())
- return pd
- }
-
// 鍖归厤妤煎眰
var devPos models.Positions
_ = devPos.FindDevicePosition(deviceId, faceAppearTime.Unix()+5) // 鍔�5绉掔數姊叧闂ㄧ殑鏃堕棿
- if devPos.Pos == "" {
- devPos.Pos = device.Floor
- }
floor = devPos.Pos
}
@@ -240,8 +180,9 @@
devPos.Pos = "1F"
}
- for idx, _ := range msg.FaceListObject.FaceObject {
+ for idx, face := range msg.FaceListObject.FaceObject {
msg.FaceListObject.FaceObject[idx].OtherFeature = devPos.Pos
+ msg.FaceListObject.FaceObject[idx].FaceID = pkg.GenerateFaceIdContainFloor(face.FaceID, devPos.Pos)
}
b, _ := json.Marshal(msg)
--
Gitblit v1.8.0