在流口水中,当我执行具有事实的无状态会话时,我们可以选择找到规则中所有条件元组都满足的条件。
ex:如果规则RUL1中有规则条件, car.schi =='A'|| car.carKind str [startsWith]'A'
如果RUL1因car.schi而感到满意,那么我们是否有任何API可以获取此信息(car.schi)。
我给出的示例比较简单,但是我们的实际业务规则非常复杂,如下所示,
(car.carKind!= \“ EZZ \” && car.carKind!= \“ ENG \” && car.carKind!= \“ ETD \”)&&((car.schi包含\“ N1 \” | | | car.schi包含\“ N2 \”)||(((car.schi包含\“ IH \” || car.schi包含\“ N4 \” || car.schi包含\“ OM \” ||汽车。 schi包含\“ DA \” || car.schi包含\“ N5 \” || car.schi包含\“ PA \” || car.schi包含\“ FG \” || car.schi包含\“ PL \ “ || car.schi包含\” PC \“ || car.schi包含\” PO \“ || car.schi包含\” NG \“ || car.schi包含\” OX \“ || car.schi包含\“ OP \” || car.schi包含\“ NS \” || car.schi包含\“ FS \” || car.schi包含\“ FL \” || car.schi包含\“ N3 \” || car.schi包含\“ CM \” || car.schi包含\“ DW \” || car.schi包含\“ PB \”)&&(validateElementRule($ trainrulesRequestDTO.getElementRuleMap(),\“ 1_N \” ,true,$ trainrulesRequestDTO.getCar()。getCarNumb()))))&&(((car.prevSchi不包含\“ N2 \” && car.prevSchi不包含\“ N1 \”)&&(car.prevLoadEmpty == \“ L \”)&&((car.prevCarKind str [startsWith] \“ F \” || car.prevCarKind s tr [startsWith] \“ YF \”)&&(car.prevCarKind not str [startsWith] \“ FI \” && car.prevCarKind not str [startsWith] \“ FA \” && car.prevCarKind not str [startsWith] \“ FW \“ && car.prevCarKind not str [startsWith] \” FB \“)&&(car.prevCarKind!= \” YFB \“)))|| (((car.nextSchi不包含\“ N2 \” && car.nextSchi不包含\“ N1 \”)&&(car.nextLoadEmpty == \“ L \”)&&(((car.nextCarKind str [startsWith] \“ F \“ || car.nextCarKind str [startsWith] \” YF \“)&&(car.nextCarKind not str [startsWith] \” FA \“ && car.nextCarKind not str [startsWith] \” FB \“ && car.nextCarKind不是str [startsWith] \“ FI \” && car.nextCarKind不是str [startsWith] \“ FW \”)&&(car.nextCarKind!= \“ Y \” || car.nextCarKind!= \“ YFB \”) )))
如果我们要将其拆分为不同的规则,以查找由于(prevCarKind,prevSchi,prevLoadEmpty)或(nextCarKind,nextSchi,nextLoadEmpty)是否满足该规则,将很难拆分复杂的规则。
我还给出了规则条件,就像从我们的UI应用程序中获取的图像一样。 Pictorial view of above rule condition string 如果有人可以让我们知道如何根据上述条件满足以上条件,这将是有帮助的。
关于, Madhankumar。 B
谢谢, 玛丹
答案 0 :(得分:0)
不,你不能。但是您可以将规则分成多个规则,如下所示:
rule "RUL1A"
when
car.schi == 'A'
then
...
end
rule "RUL1B"
when
car.carKind[0] == 'A'
then
...
end
答案 1 :(得分:0)
您可以将条件分为几个功能(并在drl中定义它们):
function boolean isKindEzzEngEtd(Car car) {
return car.carKind in ["EZZ", "ENG", "ETD"];
}
function boolean isSchiContainsN1N2(Car car) {
return (car.schi contains "N1" || car.schi contains "N2");
}
...
then use the functions inside your rules (it also improves readablility and re-use):
rule "RUL1"
when
$car: Car()
!isKindEzzEngEtd($car) || isSchiContainsN1N2($car) && ...
then
-- call the functions one by one to find out which one returned true:
System.out.println("NOT isKindEzzEngEtd: " + !isKindEzzEngEtd($car));
System.out.println("isSchiContainsN1N2: " + isSchiContainsN1N2($car));
end