zhangzengfei
2024-11-07 c06ac05c6e52dd5bf818c9add39db5eed557ccac
调整实名比对
1个文件已删除
3个文件已修改
116 ■■■■ 已修改文件
cache/cache.go 21 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
compare/compare.go 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
compare/keyPerson.go 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
db/realPersons.go 73 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
cache/cache.go
@@ -7,9 +7,6 @@
    "sdkCompare/cache/shardmap"
    "sdkCompare/db"
    "basic.com/pubsub/protomsg.git"
    "basic.com/valib/logger.git"
)
var peerSizeNum = flag.Int("peerSize", 3000, "the query number from database")
@@ -27,7 +24,6 @@
var CaptureDbMap *AreaMapItem
var RealNameDbMap = shardmap.New(uint8(*threadNum))
var KeyPersonDbMap = shardmap.New(uint8(*threadNum))
var doOnce sync.Once
@@ -45,7 +41,6 @@
    initDbTablePersonsCache()
    initRealNamePersonsCache()
    initKeyPersonsCache()
}
func ReInitDbTablePersonsCache() {
@@ -137,7 +132,7 @@
}
func initRealNamePersonsCache() {
    var dbApi db.Layouts
    var dbApi db.RealNamePerson
    dbPersons, err := dbApi.GetRealNamePersonList()
    if err != nil {
        logger.Error("init real-name persons error,", err.Error())
@@ -148,20 +143,6 @@
    }
    logger.Debugf("常住人口共有%d条记录", len(dbPersons))
}
func initKeyPersonsCache() {
    var dbApi db.Layouts
    dbPersons, err := dbApi.GetKeyPersonList()
    if err != nil {
        logger.Error("init real-name persons error,", err.Error())
    }
    for _, value := range dbPersons {
        KeyPersonDbMap.Set(value.Id, value)
    }
    logger.Debugf("重点人员共有%d条记录", len(dbPersons))
}
// UpdateDbPersonsCacheById 更新缓存中的全部人员信息
compare/compare.go
@@ -6,8 +6,6 @@
    "sdkCompare/util"
    "basic.com/pubsub/protomsg.git"
    "basic.com/valib/logger.git"
    "github.com/golang/protobuf/proto"
)
@@ -38,8 +36,6 @@
    switch args.CompareTarget {
    case "realName":
        response = realNamePersonsCompere(args, fFeature, baseScore)
    case "keyPerson":
        response = keyPersonsCompere(args, fFeature, baseScore)
    default:
        response = capturePersonsCompere(args, fFeature, baseScore)
    }
compare/keyPerson.go
File was deleted
db/realPersons.go
@@ -3,69 +3,52 @@
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),
            })
        }