如何使用 accumulate 进行多次操作和收集

how to use accumulate for multiple operation and collection

我正在使用以下规则获取两个集合列表。

rule "base"
    when
        $priceLineItem : PriceLineItem( $grade : grade , $style : style  ,$prefix : prefix , basePrice == null  )
    then
end

rule "check-multiple instance-on-cover-type" extends "base"
    when
        accumulate (
                    $basePriceUpchargeConfig : BasePriceUpchargeConfig( 
                                                prefix contains $prefix,
                                                style contains $style,
                                                $baseCoverType : baseCoverType 
                                            )
                     and
                     $c : CoverUpChargeConfig( 
                                                baseCoverType contains $baseCoverType.get(0),
                                                gradeOrder contains $grade,
                                                prefix  contains $prefix,
                                                style  contains $style
                                           );
                     $collectList : collectList($c) )
            accumulate (
                    $basePriceUpchargeConfig : BasePriceUpchargeConfig( 
                                                prefix contains $prefix,
                                                style contains $style,
                                                $baseCoverType : baseCoverType 
                                            )
                     and
                     $c : CoverUpChargeConfig( 
                                                baseCoverType contains $baseCoverType.get(0),
                                                gradeOrder contains $grade,
                                                prefix  contains $prefix,
                                                style  contains $style
                                           );
                     $collectList1 : collectList($basePriceUpchargeConfig) )

    then
        System.out.println($collectList);
        System.out.println($collectList1);
end

我想要 CoverUpChargeConfig 的列表以及结果中的 BasePriceUpchargeConfig 对象。

  1. 对于每个 BasePriceUpchargeConfig;会有多个或只有一个 CoverUpChargeConfig 对象。如果两个对象之间恰好是一对一的;我想在规则的 THEN 部分使用它。

  2. 如果BasePriceUpchargeConfig 一对多匹配 --> CoverUpChargeConfig ;我想知道 CoverUpChargeConfig 对象的数量。

我可以通过上面的方式得到它,但是我使用的是两个accumulate。

请帮忙。 谢谢

您可以在同一个 accumulate CE 中收集两个列表 - 我没有看到配对 BasePriceUpchargeConfig 和 CoverUpChargeConfig 的两个 accumulate 有任何区别。

rule "check-multiple instance-on-cover-type" extends "base"
when
accumulate ( $b: BasePriceUpchargeConfig( 
             prefix contains $prefix,
             style contains $style,
             $baseCoverType : baseCoverType  )
             and
             $c : CoverUpChargeConfig( 
             baseCoverType contains $baseCoverType.get(0),
             gradeOrder contains $grade,
             prefix  contains $prefix,
             style  contains $style );
            $collectList1 : collectList($b)
            $collectList : collectList($c) )