我在决策表中有这样的规则
rule "Tips 2_525"
salience 65011
when
ub:User(ub.getDrinksCount() > 0, ub.getMissedDrink() >= 2)
then
ub.getTip("Attract waiter in "+ub.getAvgTime()+ " minutes")==null?ub.putTip("Attract waiter in "+ub.getAvgTime()+ " minutes",20):ub.putTip("Attract waiter in "+ub.getAvgTime()+ " minutes",(ub.getTip("Attract waiter in "+ub.getAvgTime()+ " minutes").getValue()+2));
end
“==”导致此处出现问题“分配的左侧必须是变量”和“令牌上的语法错误”==“,AssignmentOperator无效”
我要做的是检查这个特定的提示在增加分钟计数之前在地图中有一个条目,如果没有那么我将初始值放在Map中。有没有办法满足drools的句法约束?
答案 0 :(得分:0)
条件表达式(!)不是Java中的语句,因此在Drools RHS上无效。重写:
ub.putTip("Attract waiter in "+ub.getAvgTime()+ " minutes",
ub.getTip("Attract waiter in "+ub.getAvgTime()+ " minutes")==null
? 20
: ub.getTip("Attract waiter in "+ub.getAvgTime()+ " minutes").getValue()+2));