没有使用变量引用就不会激活Drools规则

时间:2018-11-26 11:24:06

标签: drools fact

我有3条规则来设置和检查“ skfdfs”字段。 “ rule1”用于设置默认值(如果为空),“ rule2”用于将字符串键转换为值,“ rule3”用于检查“ rule2”的结果。问题是(请参阅“ rule3”),尽管字段“ skfdfs”为空并且LHS为true,但RHS永远不会激活。 如果将“ bgb:GsdkdjBgb(skfdfs == null)”更改为“ GsdkdjBgb(skfdfs == null)”,则“ rule3”将正常执行。有人可以解释为什么...吗?

rule "rule1"
    lock-on-active
    ruleflow-group "pre-calculation"
    activation-group "set_skfdfs"
    salience 2
    when
        bgb : GsdkdjBgb(null == skfdfs || skfdfs.empty)
    then
        modify(bgb){
            setSkfdfs("0")
        }
end

rule "rule2"
    lock-on-active
    ruleflow-group "pre-calculation"
    activation-group "set_skfdfs"
    salience 2
    when
       bgb : GsdkdjBgb(null != skfdfs && !skfdfs.empty && "0" != skfdfs && 
          "1" != skfdfs, $skfdfs : skfdfs)
    then
        modify(bgb){
            setSkfdfs(Constants.SKFDFS.get($skfdfs))
        }
end

rule "rule3"
    ruleflow-group "pre-calculation"
    salience 1
    no-loop
    when
        bgb : GsdkdjBgb(skfdfs == null)
        message : Message()
    then
        message.getMessages().add("Invalid tax-burden type");
        message.setIsFlowEnded(true);
        update(message);
end

0 个答案:

没有答案