From 412fb94f3c6dbb02ed72ad91a0c58cf58bdde4e3 Mon Sep 17 00:00:00 2001 From: panlei <2799247126@qq.com> Date: 星期六, 06 七月 2019 18:14:56 +0800 Subject: [PATCH] 更新cache --- ruleserver/ruleToformula.go | 54 +++++++++++++++++++++++++++++++++++++++++++++++------- 1 files changed, 47 insertions(+), 7 deletions(-) diff --git a/ruleserver/ruleToformula.go b/ruleserver/ruleToformula.go index b53af97..bb22dc5 100644 --- a/ruleserver/ruleToformula.go +++ b/ruleserver/ruleToformula.go @@ -2,6 +2,7 @@ import ( "encoding/json" + "github.com/gogo/protobuf/proto" "ruleprocess/cache" "ruleprocess/logger" "sort" @@ -9,6 +10,7 @@ "strings" "time" + bigCache "basic.com/pubsub/cache.git" "basic.com/pubsub/protomsg.git" "github.com/knetic/govaluate" ) @@ -62,6 +64,7 @@ IsYolo bool // 鏄惁鏄痽olo鏁版嵁 Location Rect // 璁颁笅姣忎釜鐩爣鐨勪綅缃弬鏁帮紝鏈�鍚庣粰缁撴灉瑁呴厤浜鸿劯鏁版嵁鐨勬椂鍊欑敤鐨勫埌 SdkName string + Feature []byte ThftRes protomsg.ThftResult Liker []*protomsg.Baseinfo } @@ -97,7 +100,7 @@ IsYolo bool // 鏄惁鏄痽olo鏁版嵁 SdkName string ThftRes protomsg.ThftResult - Liker []*protomsg.Baseinfo // 濡傛灉鏄汉鑴哥殑璇濆挨鍏舵槸姣斿锛屽簲瀛樹笅浠栬窡搴曞簱鐨勪汉鍛樼殑鐩镐技鎯呭喌 yolo鐨勮瘽缁檔il灏辫 + Feature []byte } // 姣忎釜绠楁硶瀵逛簬褰撳墠甯х敾闈㈣嚜宸辨彁鍙栫殑鏁版嵁 @@ -227,6 +230,42 @@ } } } +func Compare(args *SdkDatas, groupRule *protomsg.GroupRule) { + compareFlag := false + // 鐪嬬湅鏄惁鏈夊彧閰嶄汉鑴告瘮瀵圭畻娉曚絾娌℃湁閰嶅姣斿簱鐨勮鍒欙紝濡傛灉鏈夛紝鍒欐瘮瀵瑰璞′负鍏ㄩ儴搴曞簱 + for j := 0; j < len(groupRule.Rules); j++ { + if groupRule.Rules[j].SdkId == "812b674b-2375-4589-919a-5c1c3278a972"{ + if groupRule.Rules[j].SdkArgAlias == "瀵规瘮搴曞簱" { + compareFlag = true + } + } + } + if compareFlag { + logger.Info("閰嶇疆浜嗗姣斿簳搴撳弬鏁�") + }else { + logger.Info("娌℃湁閰嶇疆瀵规瘮搴曞簱鍙傛暟") + } + for j := 0; j < len(groupRule.Rules); j++ { + if groupRule.Rules[j].SdkId == "812b674b-2375-4589-919a-5c1c3278a972" && groupRule.Rules[j].SdkArgAlias == "瀵规瘮搴曞簱"{ + for _, sdkData := range args.Sdkdata { + if sdkData.SdkId == "812b674b-2375-4589-919a-5c1c3278a97e" { // 鎼滅储鍒颁汉鑴告娴嬬殑sdkdata 鐜板湪鍏充簬浜鸿劯鐨勫彧鏈変粬涓�涓猻dk锛屽叏鎵句粬 + for _, areaMap := range sdkData.AreaMapList { + // 鎷垮尯鍩熶腑姣忎釜浜鸿劯鐗瑰緛鍊煎幓瀵规瘮锛屽~鍏呭叾liker + if groupRule.Rules[j].PolygonId == areaMap.areaId { + for _,arg := range areaMap.args { + bytes := bigCache.Getdbpersonmsg(string(arg.Feature),true) + binfos := protomsg.Binfos{} + proto.Unmarshal(bytes,&binfos) + arg.Liker = binfos.Infos + logger.Info("-------------------鎴愬姛缁檒iker璧嬪�硷細",arg.Liker) + } + } + } + } + } + } + } +} func RunRule(args *SdkDatas, groupRule *protomsg.GroupRule, taskId string) bool { defer func() { if err := recover(); err != nil { @@ -234,6 +273,7 @@ } }() logger.Info("+++++++++++瑙勫垯寮�濮嬭繍琛�+++++++++++++++++褰撳墠瑙勫垯--锛�", *groupRule) + Compare(args,groupRule) resultSplice := []*LittleRuleResult{} // 鍏堣繃瀹屾潯浠惰鍒� for j := 0; j < len(groupRule.Rules); j++ { @@ -330,7 +370,7 @@ // 閰嶄簡浜鸿劯鐨勭畻娉曟墠鎶婁汉鑴哥殑鏁版嵁鐢╁嚭鏉ユ墦鏍囩 flag11 := false for j := 0; j < len(groupRule.Rules); j++ { - if groupRule.Rules[j].SdkId == "812b674b-2375-4589-919a-5c1c3278a97e" || groupRule.Rules[j].SdkId == "812b674b-2375-4589-919a-5c1c3278a971" { + if groupRule.Rules[j].SdkId == "812b674b-2375-4589-919a-5c1c3278a97e" || groupRule.Rules[j].SdkId == "812b674b-2375-4589-919a-5c1c3278a972" { flag11 = true } } @@ -396,7 +436,7 @@ func putFaceToResult(rule *protomsg.Rule, am *AreaMap) []Arg { faces := []Arg{} - if rule.SdkId == am.sdkId && rule.SdkId == "812b674b-2375-4589-919a-5c1c3278a97e" || rule.SdkId == "812b674b-2375-4589-919a-5c1c3278a971" { + if rule.SdkId == am.sdkId && rule.SdkId == "812b674b-2375-4589-919a-5c1c3278a97e" || rule.SdkId == "812b674b-2375-4589-919a-5c1c3278a972" { if len(am.filterData) > 0 { for _, data := range am.filterData { faces = append(faces, data) @@ -409,7 +449,7 @@ func putYolosToResult(rule *protomsg.Rule, am *AreaMap) []Rect { locations := []Rect{} - if rule.SdkId == am.sdkId && rule.SdkId != "812b674b-2375-4589-919a-5c1c3278a97e" && rule.SdkId != "812b674b-2375-4589-919a-5c1c3278a971" { + if rule.SdkId == am.sdkId && rule.SdkId != "812b674b-2375-4589-919a-5c1c3278a97e" && rule.SdkId != "812b674b-2375-4589-919a-5c1c3278a972" { if len(am.filterData) > 0 { for _, data := range am.filterData { locations = append(locations, data.Location) @@ -442,7 +482,7 @@ if threshold <= obj.Score && size <= float64(obj.Rects.Width*obj.Rects.Height) && intersectionper <= PgsInterPercent(areaPoints, obj.Rects, widthScale, heigthScale) { // 杩欐瑕佸榻愯〃杈惧紡閲屾墍闇�瑕佺殑鎵�鏈夊弬鏁� a.targetNum++ - arg1 := Arg{obj.Score, PgsInterPercent(areaPoints, obj.Rects, widthScale, heigthScale), float64(obj.Rects.Width * obj.Rects.Height), obj.IsYolo, obj.Rects, obj.SdkName, obj.ThftRes, obj.Liker} + arg1 := Arg{obj.Score, PgsInterPercent(areaPoints, obj.Rects, widthScale, heigthScale), float64(obj.Rects.Width * obj.Rects.Height), obj.IsYolo, obj.Rects, obj.SdkName, obj.Feature,obj.ThftRes,[]*protomsg.Baseinfo{}} //logger.Println("鏀捐繘鍘荤殑arg锛�-------", arg1) a.args = append(a.args, arg1) a.filterData = append(a.filterData, arg1) @@ -592,14 +632,14 @@ func filterRule(rule *protomsg.Rule, am *AreaMap) LittleRuleResult { if rule.SdkId == "812b674b-2375-4589-919a-5c1c3278a97e" || rule.SdkId == "812b674b-2375-4589-919a-5c1c3278a972" { // 澶勭悊鐨勬槸浜鸿劯绠楁硶 濡傛灉杩欐潯瑙勫垯閰嶇疆鐨勬槸浜鸿劯绠楁硶锛岃繃婊ゅ畬鏉′欢涔嬪悗鐩存帴寰楀嚭缁撴灉锛屽洜涓鸿偗瀹氭病鏈夋暟閲忔潯浠讹紝鑷繁鎷兼帴 - + logger.Error("瑙勫垯鐨勭畻娉昳d鍜屽尯鍩熺殑绠楁硶id锛�",rule.SdkId,"===",am.sdkId) if rule.SdkId == am.sdkId && rule.PolygonId == am.areaId { // 绠楁硶鍜屽尯鍩熼兘寰楀鐨勪笂 if rule.SdkId == "812b674b-2375-4589-919a-5c1c3278a972" && rule.SdkArgAlias != "time_rule"{ // 鍙渶瑕佽繃婊ら槇鍊硷紝杩囨护瀹屽悗鏁扮粍闀垮害澶т簬0鍗充负鎶ヨ锛屼絾瑕佽�冭檻濡備綍瀵规瘡涓�寮犻兘鎶ヨ鍛� argValue, err := strconv.ParseFloat(rule.SdkArgValue, 64) if err != nil { - logger.Info("瑙勫垯閰嶇疆鐨勯槇鍊奸潪娉�") + logger.Error("瑙勫垯閰嶇疆鐨勯槇鍊奸潪娉�") return LittleRuleResult{am.sdkName, rule.RuleWithPre + "" + "false", rule.Sort} } flag := "false" -- Gitblit v1.8.0