我一直在寻找一段时间,但我无法在任何地方找到我的问题的确切答案,或者如果我找到类似的东西,它就不起作用。
我想在规则的 when 部分调用一个简单的 java 方法。
我的代码如下所示:
rule "Ret Rule"
when
Map(this["LOYAL"] == "true")
Map(this["LOYALTYPROMORETENTION"] == "true")
PromotionValidityPeriod(promotionName == "VIVACLUB Loyalty Promo 2013 25 percent")
$customer: Customer( segment == "Residential" , $assets : assets )
$o: Order( ( (DPOrderType == 17 && retentionReason == "RET") || (DPOrderType == 2 && reason == "557") ) , $ct: contractTerms == 24, $olis: orderLineItems )
$tariff: OrderLI( part in ("DT2319", "DT2320"), actionCode not in ("Delete", "INVALID"), $parentId : parentId) from $olis
OrderLI( part == "DT2316", nodeId == $parentId, actionCode not in ("Delete", "INVALID"), $assetId : assetId ) from $olis
/*Asset( assetId == $assetId,
( (contractTerms != null && contractEndDate != null && eval(CalculationsHelper.getFullMonthDifference(new Date(), contractEndDate) < 3 ))
|| (contractTerms == null) ) ) from $assets*/
$li : OrderLI( $newTariff : part in ("DT2319", "DT2320"), parentId == $parentnodeid, actionCode == "Add") from $olis
$del : OrderLI( $oldTariff : part, parentId == $parentnodeid, actionCode == "Delete", productType == "Calling Plan") from $olis
eval(OrderDwrController.setTransitionCondition(fromTariff == $oldTariff, toTariff == $newTariff) == true
then
Offer of = new Offer("DT2331", $parentId, 7);
System.out.println($tariffOld);
of.getOrderLineItemAttributes().add(new OrderLIAttribute("DURATION", "" + $ct));
of.getOrderLineItemAttributes().add(new OrderLIAttribute("Discount of MRC", "25%"));
of.getOrderLineItemAttributes().add(new OrderLIAttribute("VIVACOM TV Package", $tariff.getProductNameENU()));
of.setProductNameENU("VIVACLUB Loyalty Promo 2013 25 percent");
$o.addOffer(of);
of.setLoyaltyPromo(true);
$o.addTextForOffer(of, new Integer[]{173});
end
我遇到问题的特定行是该when
部分的最后一行:
eval(OrderDwrController.setTransitionCondition(
fromTariff == $oldTariff, toTariff == $newTariff) == true
我只想调用一个简单的函数
(OrderDwrController.setTransitionCondition(
fromTariff == $oldTariff, toTariff == $newTariff))
就像我上面的那个
(eval(CalculationsHelper.getFullMonthDifference(
new Date(), contractEndDate) < 3 ))
该函数是静态的,返回一个布尔值。我已经在文件的开头导入了这个类。
我究竟做错了什么?