zhangzengfei
2024-09-26 88b1f1d1d14a8fe9e3dde2f363a89d821fc0e641
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
package db
 
import (
    "encoding/base64"
    "sdkCompare/util"
)
 
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"`
}
 
func (l *Layouts) TableName() string {
    return "layouts"
}
 
func (l *Layouts) GetRealNamePersonList() (arr []*FeatureCacheBase, err error) {
    var persons []Layouts
    sql := "select id, tableId, person_type, feature from layouts"
    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.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,
                FaceFeature: util.ByteSlice2float32Slice(byteFeat),
            })
        }
    }
 
    return
}