| | |
| | | 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) |
| | |
| | | completeFormula = completeFormula + va.Result |
| | | } |
| | | if completeFormula != "" { |
| | | log.Println("看看公式-----------:", completeFormula) |
| | | log.Println("结果公式-----------:", completeFormula) |
| | | expression, _ := govaluate.NewEvaluableExpression(completeFormula) |
| | | if strings.HasPrefix(completeFormula,"&&") || strings.HasPrefix(completeFormula,"||"){ |
| | | panic("规则有误,得到的数学公式不可解析") |
| | |
| | | for _, va := range timeEle.RuleResults { |
| | | completeFormula = completeFormula + va.RuleWithPre + "" + va.Result |
| | | } |
| | | log.Println("---------------------------联动任务的公式",completeFormula) |
| | | if completeFormula != "" { |
| | | expression, _ := govaluate.NewEvaluableExpression(completeFormula) |
| | | result, _ := expression.Evaluate(nil) // 得到数学公式的结果 |
| | |
| | | var formula string |
| | | if rule.SdkArgAlias == "score" { |
| | | formula = strconv.FormatFloat(arg.Score, 'f', -1, 64) + " " + rule.Operator + " " + rule.SdkArgValue // 得到字符串公式 |
| | | log.Println("当前相似度小公式:",formula) |
| | | } else if rule.SdkArgAlias == "proportion" { |
| | | formula = strconv.FormatFloat(arg.Proportion, 'f', -1, 64) + " " + rule.Operator + " " + rule.SdkArgValue // 得到字符串公式 |
| | | log.Println("当前占比小公式:",formula) |
| | | } else { |
| | | formula = strconv.FormatFloat(arg.Size, 'f', -1, 64) + " " + rule.Operator + " " + rule.SdkArgValue // 得到字符串公式 |
| | | log.Println("当前尺寸小公式:",formula) |
| | | } |
| | | expression, _ := govaluate.NewEvaluableExpression(formula) // 得到数学公式 |
| | | result, _ := expression.Evaluate(nil) // 得到数学公式的结果 |
| | |
| | | } |
| | | } |
| | | if rule.Operator == "unsatisfy" || rule.Operator == "!="{ // 不满足所选的时间规则 |
| | | formula := timeSlot.Start + "<" + am.time |
| | | formula := "'"+timeSlot.Start + "'" + " < " + "'" + am.time + "'" |
| | | log.Println("-----------------时间规则不满足的公式start:",formula) |
| | | expression, _ := govaluate.NewEvaluableExpression(formula) // 得到数学公式 |
| | | result, _ := expression.Evaluate(nil) // 得到数学公式的结果 |
| | | |
| | | formula1 := timeSlot.End + ">" + am.time |
| | | formula1 := "'"+timeSlot.End +"'"+ " > " +"'" + am.time+ "'" |
| | | log.Println("-----------------时间规则不满足的公式end:",formula1) |
| | | expression1, _ := govaluate.NewEvaluableExpression(formula1) // 得到数学公式 |
| | | result1, _ := expression1.Evaluate(nil) // 得到数学公式的结果 |
| | | if result.(bool) && result1.(bool) { |