package compare
|
|
import (
|
"fmt"
|
"sdkCompare/cache"
|
|
"basic.com/pubsub/protomsg.git"
|
)
|
|
func capturePersonsCompere(args protomsg.CompareArgs, fFeature []float32, baseScore float32) protomsg.SdkCompareResult {
|
var scr protomsg.SdkCompareResult
|
var walkedArea = make(map[string]struct{}, 0)
|
|
// 比对传入的小区id
|
if args.TreeNodes != nil && len(args.TreeNodes) > 0 {
|
for _, id := range args.TreeNodes {
|
if _, ok := cache.CaptureDbMap.Area[id]; !ok {
|
continue
|
}
|
|
targets := cache.CaptureDbMap.Area[id].Walk(DoSdkCompare, fFeature, baseScore)
|
if len(targets) > 0 {
|
// 比对结果去重, 同一个人到访过多个小区, 缓存数据内会有多条记录
|
for idx, t := range targets {
|
var isRepeat bool
|
for _, r := range scr.CompareResult {
|
if t.Id == r.Id {
|
isRepeat = true
|
break
|
}
|
}
|
if !isRepeat {
|
scr.CompareResult = append(scr.CompareResult, targets[idx])
|
}
|
}
|
}
|
|
walkedArea[id] = struct{}{}
|
}
|
|
if len(scr.CompareResult) > 0 || !args.IsCompareAll {
|
return scr
|
}
|
}
|
|
// 比对全部小区
|
if !args.IsCompareAll && len(args.TreeNodes) > 0 {
|
baseScore += 20
|
}
|
|
for key, val := range cache.CaptureDbMap.Area {
|
if _, ok := walkedArea[key]; ok {
|
continue
|
}
|
|
fmt.Printf("Walk area %s, cache len %d\n", key, val.GetLen())
|
targets := val.Walk(DoSdkCompare, fFeature, baseScore)
|
if len(targets) > 0 {
|
// 比对结果去重, 同一个人到访过多个小区, 缓存数据内会有多条记录
|
for idx, t := range targets {
|
var isRepeat bool
|
for _, r := range scr.CompareResult {
|
if t.Id == r.Id {
|
isRepeat = true
|
break
|
}
|
}
|
if !isRepeat {
|
scr.CompareResult = append(scr.CompareResult, targets[idx])
|
}
|
}
|
}
|
// todo 添加小区外的关联关系, 下次优先比对
|
}
|
|
return scr
|
}
|