| | |
| | | "fmt" |
| | | "github.com/go-yaml/yaml" |
| | | "io/ioutil" |
| | | "math" |
| | | "ruleprocess/cache" |
| | | "ruleprocess/logger" |
| | | "strconv" |
| | |
| | | TableId string `json:"tableId"` |
| | | TableName string `json:"tableName"` |
| | | BwType string `json:"bwType"` |
| | | CompareScore float32 `json:"compareScore"` |
| | | CompareScore float64 `json:"compareScore"` |
| | | PersonId string `json:"personId"` |
| | | PersonName string `json:"personName"` |
| | | PersonPicUrl string `json:"personPicUrl"` |
| | |
| | | |
| | | // 保留四位小数 |
| | | func Retain(f float32) (float64) { |
| | | s := strconv.FormatFloat(float64(f), 'f', 4, 64) |
| | | v, err := strconv.ParseFloat(s, 64) |
| | | if err != nil { |
| | | logger.Error("保留四位小数转换错误") |
| | | } |
| | | // float32与float64互转会有位数保留不准的问题 |
| | | return v |
| | | value1, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", float64(f)), 64) |
| | | return value1 |
| | | } |
| | | func Decimal(value float32) float32 { |
| | | value1, _ := strconv.ParseFloat(fmt.Sprintf("%.4f", value), 32) |
| | | return float32(value1) |
| | | func Decimal(value float32) float64 { |
| | | value1, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", float64(value)), 64) |
| | | logger.Info("初步保留两位成str:",value1) |
| | | n10 := math.Pow10(4) |
| | | value2 := math.Trunc((value1+0.5/n10)*n10) / n10 |
| | | logger.Info("初步保留两位成str::::",value2) |
| | | return value2 |
| | | } |
| | | // 取出某个时间规则的第几天的规则段集合 |
| | | func GetTimeById(id string, index int) []TimeRange { |
| | |
| | | for _, baseinfo := range baseinfos { |
| | | // 根据tableId查询底库信息给liker赋值 |
| | | //logger.Info("---------看看每个底库人员的信息:",baseinfo.Id,baseinfo.PersonName) |
| | | var tableIds []string |
| | | tableIds := []string{} |
| | | tableIds = append(tableIds, baseinfo.TableId) // 虽然是传入数组返回数组的接口,但我按单个的使用了 |
| | | table, err := esutil.Dbtablefosbyid(tableIds, "dbtables", serverIp, serverPort) |
| | | if err != nil || len(table) == 0 { |
| | | logger.Error("根据id查询底库信息出错!", err, "--返回值长度为:", len(table)) |
| | | } |
| | | logger.Debug("看看这个base的对比值是多少:", Decimal(m[baseinfo.Id]) * 100) |
| | | base := BaseInfo{TableId: baseinfo.TableId, TableName: table[0].TableName, BwType: table[0].BwType, CompareScore: Decimal(m[baseinfo.Id]) * 100, PersonId: baseinfo.Id, PersonName: baseinfo.PersonName, PersonPicUrl: baseinfo.PersonPicUrl, PhoneNum: baseinfo.PhoneNum, Sex: baseinfo.Sex, IdCard: baseinfo.IdCard, MonitorLevel: baseinfo.MonitorLevel, Content: baseinfo.Reserved} |
| | | logger.Debug("看看这个base的对比值是多少:", Decimal(m[baseinfo.Id] * 100)) |
| | | base := BaseInfo{TableId: baseinfo.TableId, TableName: table[0].TableName, BwType: table[0].BwType, CompareScore: Decimal(m[baseinfo.Id] * 100), PersonId: baseinfo.Id, PersonName: baseinfo.PersonName, PersonPicUrl: baseinfo.PersonPicUrl, PhoneNum: baseinfo.PhoneNum, Sex: baseinfo.Sex, IdCard: baseinfo.IdCard, MonitorLevel: baseinfo.MonitorLevel, Content: baseinfo.Reserved} |
| | | //os.Exit(1) |
| | | arg.Liker = append(arg.Liker, &base) |
| | | } |
| | |
| | | if groupRule.Rules[j].PolygonId == areaMap.areaId { |
| | | //logger.Info("--------------看看compareFlag的值和tableId和areaMap.args的长度:",compareFlag,tableIds,len(areaMap.args)) |
| | | for _, arg := range areaMap.args { |
| | | arg.Liker = arg.Liker[0:0] |
| | | logger.Info("清空之后看看之前打的人脸标签变了没:") |
| | | if args.RuleResult["face"] != nil && len(args.RuleResult["face"].([]FaceResult)) > 0 { |
| | | for _, faceResult := range args.RuleResult["face"].([]FaceResult) { |
| | | for _,arg := range faceResult.Args { |
| | | logger.Info("人员分值是:",arg.Score,"liker的数量为",arg.Liker) |
| | | } |
| | | } |
| | | } |
| | | if compareFlag == 1 { |
| | | arg.fillLiker(nil, threshold) |
| | | } |
| | |
| | | a.filterData = append(a.filterData, &arg1) |
| | | } |
| | | } |
| | | logger.Info("区域是:",areaPoints,"区域内目标数量为:",a.targetNum,"---",len(a.filterData)) |
| | | a.time = time.Unix(time.Now().Unix(), 0).String()[11:16] |
| | | a.keepRight = arg.KeepRight |
| | | a.isStatic = arg.IsStatic |