在评估流口水条件时无法访问同一议程组中修改的事实

Cannot access the modified fact in the same agenda-group while evaluating when condition in drools

我有一个具有相同议程组的规则列表。这些规则是相互依存的。规则月度 PI 取决于规则年度 PI,年度 PI 的值也是 drools 工作记忆的一个事实。它仅在我更改议程组名称或删除 lock-on-active true 时有效(但即使我使用无循环也会进入循环)。在每月 PI 规则的 when 条件内,我正在检查年度 PI 是否不为空然后触发规则,但它不起作用,因为它没有为其获取更新的值。请建议我该怎么做?

rule "Annual P&I one"
@attribute("interestRate,originalLoanAmount")
agenda-group "loaneconomics"
salience 500
lock-on-active true
when 
$loanFact:LoanFact30Yr(loan.loanEcon.interestRate!=null)
then
System.out.println("::::Annual P&I Working ::::: ");

modify($loanFact){
$loanFact.getLoanRuleResult().getLoanEconomics().setAnnualPI( /*FORMULA*/  );
}
end

rule "Monthly P&I one"
@attribute("AnnualPI")
agenda-group "loaneconomics"
salience 400
lock-on-active true
when 
$loanFact:LoanFact30Yr( $loanFact.getLoanRuleResult().getLoanEconomics().getAnnualPI() != null )
then
System.out.println(":::: Monthly P&I Working ::::: ");
System.out.println("Monthly Payments ::: " + $loanFact.getLoanRuleResult().getLoanEconomics().getAnnualPI()/12f);
modify($loanFact){
getLoanRuleResult().getLoanEconomics().setToorakMonthlyPI( $loanFact.getLoanRuleResult().getLoanEconomics().getAnnualPI()/12f );
}
end

lock-on-active 基本上会阻止当前 fireAllRules() 调用期间的任何新激活。查看此答案以了解您的问题的可能解决方案:what is the difference between no-loop and lock-on-active in drools