我需要将窗口规则链接到窗口规则。我的用例是:
如果在5分钟的窗口中出现温度> 50大于10,则在该窗口框架或该窗口数据上的任何其他链规则中找到温度的最大值(平均值)。
我尝试了以下方法:
query getFactFromMemory(long time)
$fact : Fact(timepoing < (drools.getWorkingMemory().getSessionClock().getCurrentTime() + time))
end
rule "window rule"
when
//condition
then
//action
end
rule "chain rule"
when
//condition
then
getFactFromMemory(1000L)
//loop over facts and then perform some action
end
调用查询时出现错误。我尝试在部分时间调用查询并将其分配给变量,但同时也会出现错误(Query's must use positional or bindings, not field constraints:1000L
和Query binding is not supported by non-abductive queries : $variable
)。
有人可以帮助我解决此错误或建议其他解决方法吗?
我们可以通过调用drools.getKieRuntime()
在drl中获取drools运行时对象。因此,该问题的工作规则是:
query getFactFromMemory(long time)
$fact : Fact(timepoing < (drools.getWorkingMemory().getSessionClock().getCurrentTime() + time))
end
rule "window rule"
when
//condition
then
//action
end
rule "chain rule"
when
//condition
then
getFactFromMemory(1000L)
//loop over facts and then perform some action
end