| | |
| | | if len(temp) > 0 { |
| | | if ruleList[i].SetType == "linkTask" { |
| | | // groupId中含有link则为联动任务 |
| | | //LinkTask(args, ruleList[i], taskId) |
| | | LinkTask(args, ruleList[i], taskId) |
| | | } else { |
| | | // 独立任务的处理 |
| | | RunRule(args, ruleList[i], taskId) |
| | |
| | | } |
| | | } |
| | | } |
| | | // 过完条件数据后把符合条件的人脸数据塞进结果标签里 |
| | | faces := []Arg{} |
| | | for _, sdkData := range args.Sdkdata { |
| | | for _, areaMap := range sdkData.AreaMapList { |
| | | for j := 0; j < len(groupRule.Rules); j++ { |
| | | faces = append(faces, putFaceToResult(groupRule.Rules[j], &areaMap)...) |
| | | } |
| | | } |
| | | } |
| | | // 配了人脸的算法才把人脸的数据甩出来打标签 |
| | | flag := 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" { |
| | | flag = true |
| | | } |
| | | } |
| | | if flag { |
| | | args.RuleResult["face"] = faces |
| | | } |
| | | |
| | | // 再过其他数据 这步直接得到结果(真或假) 过目标数量 |
| | | for j := 0; j < len(groupRule.Rules); j++ { |
| | | for _, sdkData := range args.Sdkdata { |
| | |
| | | for _, va := range resultSplice { |
| | | completeFormula = completeFormula + va.Result |
| | | } |
| | | if strings.HasPrefix(completeFormula,"&&") || strings.HasPrefix(completeFormula,"||") || strings.HasPrefix(completeFormula,">=") || strings.HasPrefix(completeFormula,"<=") || strings.HasPrefix(completeFormula,"==") || strings.HasPrefix(completeFormula,"!=") ||strings.HasPrefix(completeFormula,">") || strings.HasPrefix(completeFormula,"<") { |
| | | // 以这些开头的基本是联动任务 |
| | | if strings.HasPrefix(completeFormula,"&&") || strings.HasPrefix(completeFormula,"||") || strings.HasPrefix(completeFormula,">=") || strings.HasPrefix(completeFormula,"<=") || strings.HasPrefix(completeFormula,"==") || strings.HasPrefix(completeFormula,"!=") { |
| | | completeFormula = completeFormula[2:len(completeFormula)-1] |
| | | } |
| | | if strings.HasPrefix(completeFormula,">") || strings.HasPrefix(completeFormula,"<") { |
| | | completeFormula = completeFormula[1:len(completeFormula)-1] |
| | | } |
| | | expression, _ := govaluate.NewEvaluableExpression(completeFormula) |
| | | if strings.HasPrefix(completeFormula, "&&") || strings.HasPrefix(completeFormula, "||") { |
| | | panic("规则有误,得到的数学公式不可解析") |
| | | } |
| | | result, _ := expression.Evaluate(nil) // 得到数学公式的结果 |
| | | return result.(bool) |
| | | } |
| | | if completeFormula != "" { |
| | | log.Println("结果公式-----------:", completeFormula) |
| | | expression, _ := govaluate.NewEvaluableExpression(completeFormula) |
| | |
| | | timeEle.N = timeEle.InitN // 重置定时器 |
| | | } |
| | | } |
| | | log.Println("--------------------走这里了吗---------------") |
| | | return false |
| | | } else { |
| | | // 最后成功报警才把符合条件的人脸数据塞进结果标签里 |
| | | faces := []Arg{} |
| | | for _, sdkData := range args.Sdkdata { |
| | | for _, areaMap := range sdkData.AreaMapList { |
| | | for j := 0; j < len(groupRule.Rules); j++ { |
| | | faces = append(faces, putFaceToResult(groupRule.Rules[j], &areaMap)...) |
| | | } |
| | | } |
| | | } |
| | | // 配了人脸的算法才把人脸的数据甩出来打标签 |
| | | 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" { |
| | | flag11 = true |
| | | } |
| | | } |
| | | if flag11 { |
| | | args.RuleResult["face"] = faces |
| | | } |
| | | // 去看池子里是否有与本帧数据有关的定时器,如果有,看此时是否走到0,没有此定时器或有定时器走到0的话返回成功报警 |
| | | var flag bool = true |
| | | for k, timeEle := range TimeEleList { |
| | |
| | | for _, va := range timeEle.RuleResults { |
| | | if va.CameraId == args.CameraId { |
| | | va.Result = strconv.FormatBool(isOk) |
| | | log.Println("这个摄像机--",args.CameraId,"--被赋予了result",va.Result) |
| | | } |
| | | } |
| | | // 判断结果数组是否完满(即被赋值完毕)可得出报警结果 |
| | | var isPerfect = true |
| | | for _, va := range timeEle.RuleResults { |
| | | log.Println("---------------------瞅瞅当前数组________________:",*va) |
| | | if va.Result == "" && va.RuleWithPre != "||" { |
| | | isPerfect = false |
| | | } |