| | |
| | | import ( |
| | | "encoding/base64" |
| | | "sdkCompare/util" |
| | | "time" |
| | | ) |
| | | |
| | | type Layouts struct { |
| | | Id string `gorm:"column:id"` |
| | | TableId string `gorm:"column:tableId"` |
| | | Name string `gorm:"column:name"` |
| | | Phone string `gorm:"column:phone"` |
| | | Address string `gorm:"column:address"` |
| | | Age string `gorm:"column:age"` |
| | | Gender string `gorm:"column:gender"` |
| | | IdCard string `gorm:"column:id_card"` |
| | | PersonType string `gorm:"column:person_type"` //'1:常驻人口,2:前科人员,3:涉毒人员,4:涉稳人员;5:在逃人员,6:流动人口,7:寄住人口,', |
| | | Feature string `gorm:"column:feature"` |
| | | type RealNamePerson struct { |
| | | Id string `gorm:"column:id;type:varchar(191);primary_key;"` |
| | | PersonId string `gorm:"column:person_id;type:varchar(191)"` // 第三方名单库人员id |
| | | Name string `gorm:"column:name;type:varchar(32)"` // 姓名 |
| | | Gender string `gorm:"column:gender; type:varchar(16)"` // 注册性别(male-男, female-女,unknown-未知 |
| | | CertType int `gorm:"column:cert_type;"` // 证件类型 证件类型(111-居民身份证,113-户口簿,114-中国人民解放军军官证,131-工作证,123警官证,133-学生证,335-机动车驾驶证,,337-机动车行驶证,414-护照,782-市名卡,990-其他证件。取值参考数据字典 |
| | | CertName string `gorm:"column:cert_name;type:varchar(32)"` // 证件类型名称 |
| | | CertNumber string `gorm:"column:cert_number;type:varchar(32);index"` // 证件号码 |
| | | FacePicUrl string `gorm:"column:face_pic_url"` // 人脸图 |
| | | FacePicBase64 string `gorm:"column:face_pic_base64"` // 人脸图 |
| | | FaceFeature string `gorm:"column:face_feature"` // 人脸特征值 |
| | | BornTime string `gorm:"column:born_time;type:varchar(32)"` // 出生年月日 |
| | | NativeCountyCode string `gorm:"column:native_county_code;type:varchar(32)"` // 籍贯区县编号 |
| | | ResidenceCountyCode string `gorm:"column:residence_county_code;type:varchar(32)"` // 居住地区县编号 |
| | | Vendor string `gorm:"column:vendor;type:varchar(32)"` // 数据来源 |
| | | PersonLibId string `gorm:"column:person_lib_id;type:varchar(191)"` // 名单库id |
| | | PersonLibName string `gorm:"column:person_lib_name;type:varchar(191)"` // 名单库名称 |
| | | CreatedAt time.Time `gorm:"column:created_at;autoCreateTime"` |
| | | UpdatedAt time.Time `gorm:"column:updated_at;autoUpdateTime"` |
| | | } |
| | | |
| | | func (l *Layouts) TableName() string { |
| | | return "layouts" |
| | | func (l *RealNamePerson) TableName() string { |
| | | return "real_name_persons" |
| | | } |
| | | |
| | | func (l *Layouts) GetRealNamePersonList() (arr []*FeatureCacheBase, err error) { |
| | | var persons []Layouts |
| | | sql := "select id, tableId, person_type, feature from layouts" |
| | | func (l *RealNamePerson) GetRealNamePersonList() (arr []*FeatureCacheBase, err error) { |
| | | var persons []RealNamePerson |
| | | sql := "select id, cert_number, face_feature from real_name_persons where face_feature != ''" |
| | | err = db.Raw(sql).Find(&persons).Error |
| | | if err != nil { |
| | | return nil, nil |
| | | } |
| | | |
| | | for _, p := range persons { |
| | | if p.Feature != "" { |
| | | byteFeat, err := base64.StdEncoding.DecodeString(p.Feature) |
| | | if p.FaceFeature != "" { |
| | | byteFeat, err := base64.StdEncoding.DecodeString(p.FaceFeature) |
| | | if err != nil { |
| | | continue |
| | | } |
| | | |
| | | arr = append(arr, &FeatureCacheBase{ |
| | | Id: p.Id, |
| | | TableId: p.TableId, |
| | | FaceFeature: util.ByteSlice2float32Slice(byteFeat), |
| | | }) |
| | | } |
| | | } |
| | | |
| | | return |
| | | } |
| | | |
| | | func (l *Layouts) GetKeyPersonList() (arr []*FeatureCacheBase, err error) { |
| | | var persons []Layouts |
| | | sql := "select id, id_card, person_type, feature from layouts where person_type != '1'" |
| | | err = db.Raw(sql).Find(&persons).Error |
| | | if err != nil { |
| | | return nil, nil |
| | | } |
| | | |
| | | for _, p := range persons { |
| | | if p.Feature != "" { |
| | | byteFeat, err := base64.StdEncoding.DecodeString(p.Feature) |
| | | if err != nil { |
| | | continue |
| | | } |
| | | |
| | | arr = append(arr, &FeatureCacheBase{ |
| | | Id: p.Id, |
| | | TableId: p.IdCard, |
| | | TableId: p.CertNumber, |
| | | FaceFeature: util.ByteSlice2float32Slice(byteFeat), |
| | | }) |
| | | } |