Drools Spreadsheet 语法生成 OOPATH 格式的 drl 文件

问题描述 投票:0回答:1

是否可以从电子表格生成 OOPATH 格式的 drl 文件? 有切换标志吗?

我没有找到任何例子。

此电子表格

spreadsheet

生成传统语法drl:

package com....;
unit OrderUnit;

import com....OrderRequest;

rule "LOYAL_cusomer_v001"
    when
        OrderRequest(customerType.getValue1 == "LOYAL")
    then
        orderDiscount.setDiscount(orderDiscount.getDiscount() + 5);
end

当我运行unitInstance.fire()时,该规则无法识别。

当我按如下方式修改 drl 并直接针对此文件进行测试时,它就可以工作了:

    when
        /orderRequest[ customerType.getValue1 == "LOYAL" ]
excel spreadsheet drools rules
1个回答
0
投票

这是一个有效的示例:

电子表格:

enter image description here

它会生成以下 drl 文件:

package com.abcdef.ruleunit.order;
unit OrderUnit;
//generated from Decision Table
import com.abcdef.model.order.OrderRequest;
import com.abcdef.model.order.CustomerType;
import com.abcdef.model.order.OrderDiscount;
query getDiscount $orderRequest: /orderRequest[$customerNumber: customerNumber, $age: age, $amount: amount, $customerType: customerType.getValue ] end
// rule values at A11, header at A6
rule "LOYAL_cusomer_v001"
    when
        $orderRequest: /orderRequest[customerType.getValue == "LOYAL"]
    then
        orderDiscount.setDiscount(orderDiscount.getDiscount() + 5);
end

// rule values at A12, header at A6
rule "New_or_Dissatisfied_customer_v001"
    when
        $orderRequest: /orderRequest[customerType.getValue != "LOYAL"]
    then
        orderDiscount.setDiscount(orderDiscount.getDiscount() + 3);
end

// rule values at A13, header at A6
rule "Customer_order_amount_v001"
    when
        $orderRequest: /orderRequest[amount == 10000]
    then
        orderDiscount.setDiscount(orderDiscount.getDiscount() + 5);
end

// rule values at A14, header at A6
rule "Customer_age_v001"
    when
        $orderRequest: /orderRequest[age < 20 || age > 50]
    then
        orderDiscount.setDiscount(orderDiscount.getDiscount() + 10);
end
© www.soinside.com 2019 - 2024. All rights reserved.