整理了下最近在项目中使用drools出现的问题,幸好都在开发与测试阶段解决了,未波及到prod。
首先看这样两条规则
/** * 规则1_set默认利率 */ rule "rate_default" no-loop true when $request:AmountRateRequest(calculateEnum == CalculateEnum.INTEREST || calculateEnum == CalculateEnum.AMOUNT_INTEREST) $response:AmountRateResponse(rateMap not contains LoanTermEnum.LOANTERM3) $data:DroolsData() then DroolsClient.logger.debug("{}执行规则{}", $response.getUserId(), drools.getRule().getName()); $response.getRateMap().put(LoanTermEnum.LOANTERM3, RateFactory.DEFAULT_RATE); update($response); end /** * 规则2_set默认利率+万1 */ rule "rate_up1" no-loop true when $request:AmountRateRequest(calculateEnum == CalculateEnum.INTEREST || calculateEnum == CalculateEnum.AMOUNT_INTEREST) $response:AmountRateResponse(rateMap not contains LoanTermEnum.LOANTERM3) then DroolsClient.logger.debug("{}执行规则{}", $response.getUserId(), drools.getRule().getName()); $response.getRateMap().put(LoanTermEnum.LOANTERM3, Rate); update($response); end
原文地址:https://www.cnblogs.com/loveCheery/p/8544115.html
时间: 2024-10-12 07:39:06