简体   繁体   English

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

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

I have a list of rules with same agenda-group.我有一个具有相同议程组的规则列表。 These rules are interdependent.这些规则是相互依存的。 The rule monthly PI is dependent upon rule annual PI and the value of annual PI is also a fact for drools working memory.规则每月 PI 取决于规则年度 PI,并且年度 PI 的值对于工作 memory 的流口水也是一个事实。 It works only when I change the agenda-group name or remove lock-on-active true (but goes into a loop even if i use no-loop).它仅在我更改议程组名称或删除 lock-on-active true 时才有效(但即使我使用 no-loop 也会进入循环)。 Inside when condition for monthly PI rule I'm checking if annual PI is not null then trigger the rule but it doesnt work as it doesnt fetch the updated value for it.在每月 PI 规则的 when 条件中,我正在检查年度 PI 是否不是 null 然后触发该规则,但它不起作用,因为它没有获取更新的值。 Kindly suggest me what to do?请建议我该怎么做?

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 will basically prevent any new activation during the current fireAllRules() invocation. lock-on-active将基本上阻止当前fireAllRules()调用期间的任何新激活。 Take a look at this answer to see possible solutions for your problem: what is the difference between no-loop and lock-on-active in drools看看这个答案,看看你的问题可能的解决方案: 什么是 no-loop 和 lock-on-active in drools 的区别

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM