如何在Drools中根据条件和组类积累

时间:2013-10-18 13:10:36

标签: drools

rule "STANDARD - set available application"
salience(2)
when
    accumulate ( Application( $priority : priority, running == false), $highestPriority :         min( $priority ) )
then
    System.out.println("set app: "+$highestPriority );
end

我的代码在上面。我的目标是找到运行== false的应用程序并获得这些应用程序的最高优先级(最高值是最低值),但此规则会触发所有应用程序并忽略我的条件。思考???

1 个答案:

答案 0 :(得分:2)

此处无需使用和累积模式。您可以将规则重写为以下内容:

rule "STANDARD - set available application"
salience(2)
when
    $highestPriorityApp: Application(running == false, $highestPriority : priority)
    not Application(running == false, priority < $highestPriority)
then
    System.out.println("set app: "+$highestPriorityApp );
end

希望它有所帮助,