我必须在列表上写一个drool函数,它必须做以下事情
是我创建的流口水规则
rule "001"
when
$charge : MainClass(subList.size() > 0)
$item : SubListClass(number < 0) from $charge.subOrderROList
$total : Number() from accumulate(SubListClass( $p : number ),sum( $p )
then
int index = $charge.SubListClass.indexOf($item)+1;
violations.error(kcontext, "ad", "ad.message", new String[]{String.valueOf(index),$item.getNumber().toString()},index);
end`
我无法检查$ total是否大于100
感谢
答案 0 :(得分:2)
如果可以获得总和&gt;这将是正确的 100加上负数。我保留了Q中的约束,因此请根据需要进行更改。也许number > 0
?
rule "001"
when
$charge: MainClass(subList.size() > 0)
$total: Number( intValue > 100 )
from accumulate( SubListClass($p: number < 0)
from $charge.subOrderROList,
sum( $p ) )
then