From 1095c312c7cb3c49534f3bdf43daadc42f0f749a Mon Sep 17 00:00:00 2001
From: zhangzengfei <zhangzengfei@smartai.com>
Date: 星期四, 07 十一月 2024 17:07:36 +0800
Subject: [PATCH] fix build
---
db/person.go | 76 +++++++++++++++-----------------------
1 files changed, 30 insertions(+), 46 deletions(-)
diff --git a/db/person.go b/db/person.go
index 3224daa..959862d 100644
--- a/db/person.go
+++ b/db/person.go
@@ -1,55 +1,34 @@
package db
import (
+ "basic.com/valib/logger.git"
"encoding/base64"
- "sdkCompare/compare"
+ "sdkCompare/util"
"strconv"
)
type DbPersons struct {
BaseEntity
- TableId string `gorm:"column:tableId" json:"tableId" example:"搴撹〃id"`
- FaceFeature string `gorm:"column:faceFeature" json:"faceFeature" example:"浜鸿劯鐗瑰緛鍊硷紙杞︿富鐗瑰緛锛�"`
- PersonPicUrl string `gorm:"column:personPicUrl" json:"personPicUrl" example:"鍥剧墖璺緞,锛堣溅涓荤収鐗囷級"`
- PersonName string `gorm:"column:personName" json:"personName" example:"浜哄憳濮撳悕锛岋紙杞︿富濮撳悕锛�"`
- Age string `gorm:"column:age" json:"age" example:"骞撮緞"`
- Sex string `gorm:"column:sex" json:"sex" example:"鎬у埆 鐢� 濂筹紙杞︿富鎬у埆锛�"`
- IdCard string `gorm:"column:idCard" json:"idCard" example:"韬唤璇侊紙杞︿富韬唤璇侊級"`
- PhoneNum string `gorm:"column:phoneNum" json:"phoneNum" example:"鎵嬫満鍙风爜"`
- MonitorLevel string `gorm:"column:monitorLevel" json:"monitorLevel" example:"绛夌骇"`
- PicDesc string `gorm:"column:picDesc" json:"picDesc" example:"鐓х墖鏍囪瘑"`
- Reserved string `gorm:"column:reserved" json:"reserved" example:"鍏朵粬"`
- FromServerId string `gorm:"column:fromServerId" json:"fromServerId,omitempty" example:"鍏ュ簱serverId"`
- ResidentialArea string `gorm:"column:residential_area;type:varchar(255)" json:"residentialArea" example:"灏忓尯"`
- Community string `gorm:"column:community;type:varchar(255)" json:"community" example:"绀惧尯"`
- LastAppearanceTime int64 `gorm:"column:last_appearance_time;type:int;not null;default:0" json:"lastAppearanceTime" example:"123456789"`
- SnapshotCount int `gorm:"column:snapshot_count;type:varchar(255)" json:"snapshotCount" example:"10" comment:"鎶撴媿娆℃暟"`
- DaysAppeared int `gorm:"column:days_appeared;type:int(11);not null;default:0" json:"daysAppeared" example:"5" comment:"鍑虹幇澶╂暟"`
- Location string `gorm:"column:location;type:varchar(255)" json:"location" example:"寤烘。鍦扮偣" comment:"寤烘。鍦扮偣"`
- LastLocation string `gorm:"column:last_location;type:varchar(255)" json:"lastLocation" example:"鏈�鍚庡嚭鐜板湴鐐�" comment:"鏈�鍚庡嚭鐜板湴鐐�"`
- FaceAngleYaw int `gorm:"column:face_angle_yaw;type:int(11)" json:"faceAngleYaw" example:"15" comment:"浜鸿劯瑙掑害鍋忚埅瑙�"`
- FaceAngleRoll int `gorm:"column:face_angle_roll;type:int(11)" json:"faceAngleRoll" example:"16" comment:"浜鸿劯瑙掑害婊氳浆瑙�"`
- FaceAnglePitch int `gorm:"column:face_angle_pitch;type:int(11)" json:"faceAnglePitch" example:"15" comment:"浜鸿劯瑙掑害淇话瑙�"`
- PersonalStatusName string `gorm:"column:personal_status;type:varchar(31);comment:AI鏍囩" json:"-"` //AI鏍囩
- PersonalStatus string `gorm:"-" json:"personalStatus"` //AI鏍囩瀵瑰簲鍚嶇О
- Labels []string `gorm:"-" json:"labels"` //鎵嬪姩娣诲姞鐨勬爣绛惧搴斿悕绉�
- AreaID string `json:"areaID" gorm:"index;column:communityID;type:varchar(299);"` //甯搁┗灏忓尯 domain unit ID
- OrgID string `json:"orgID" gorm:"index;column:org_id;type:varchar(299);"` //甯搁┗娲惧嚭鎵� domain unit ID
+ TableId string `gorm:"column:table_id"`
+ FaceFeature string `gorm:"column:face_feature"`
+ CommunityID string `gorm:"column:community_id"` // 甯镐綇灏忓尯 domain unit ID
+ OrgID string `gorm:"column:org_id"` // 甯镐綇娲惧嚭鎵� domain unit ID
+ OrgName string `gorm:"column:community"`
}
-func (dbp *DbPersons) GetPersonTotal(tableId string) (total int64, err error) {
- sql := "select count(1) as total from dbtablepersons where isDelete=0 and tableId in (select id from dbtables where isDelete=0)"
- if tableId != "" {
- sql += " and tableId='" + tableId + "'"
- }
+func (dbp *DbPersons) GetPersonTotal() (total int64, err error) {
+ sql := "select id from person where is_delete = 0 and table_id = 'system'"
+
err = db.Raw(sql).Count(&total).Error
+
return
}
-func (dbp *DbPersons) GetPersonsCompareCacheBase(from int, size int) (arr []*FeatureCacheBase, err error) {
+func (dbp *DbPersons) GetPersonsCacheBase(from int, size int) (arr []*FeatureCacheBase, err error) {
var persons []DbPersons
- sql := "select id, tableId, faceFeature, communityID, enable from dbtablepersons where isDelete=0 and tableId in (select id from dbtables where isDelete=0)"
+ sql := "select id, table_id, face_feature, community_id from person where is_delete = 0 and table_id = 'system'"
sql += " order by id asc limit " + strconv.Itoa(from) + "," + strconv.Itoa(size)
+
err = db.Raw(sql).Find(&persons).Error
if err != nil {
return nil, err
@@ -59,25 +38,30 @@
if p.FaceFeature != "" {
byteFeat, err := base64.StdEncoding.DecodeString(p.FaceFeature)
if err != nil {
+ logger.Errorf("Person %s feature is invalid", p.ID)
continue
}
arr = append(arr, &FeatureCacheBase{
- Id: p.Id,
+ Id: p.ID,
TableId: p.TableId,
- AreaId: p.AreaID,
- FaceFeature: compare.ByteSlice2float32Slice(byteFeat),
- Enable: int32(p.Enable),
+ AreaId: p.CommunityID,
+ FaceFeature: util.ByteSlice2float32Slice(byteFeat),
})
+ } else {
+ logger.Warnf("Person %s feature is empty %s", p.ID)
}
}
+
return
}
-func (dbp *DbPersons) GetPersonsCompareCacheById(id string) (info *FeatureCacheBase, err error) {
- sql := "select id, tableId, faceFeature, communityID, enable from dbtablepersons where id = \"" + id + "\""
+func (dbp *DbPersons) GetPersonsById(id string) (info *FeatureCacheBase, err error) {
var p DbPersons
- err = db.Raw(sql).First(&p).Error
+
+ err = db.Table("person").
+ Select("id", "table_id", "face_feature", "community_id").
+ First(&p, "id = ?", id).Error
if err != nil {
return nil, err
}
@@ -88,12 +72,12 @@
return nil, err
}
info = &FeatureCacheBase{
- Id: p.Id,
+ Id: p.ID,
TableId: p.TableId,
- AreaId: p.AreaID,
- FaceFeature: compare.ByteSlice2float32Slice(byteFeat),
- Enable: int32(p.Enable),
+ AreaId: p.CommunityID,
+ FaceFeature: util.ByteSlice2float32Slice(byteFeat),
}
}
+
return
}
--
Gitblit v1.8.0