使用MID压缩输入的DMN决策模型 [英] DMN decision model that zip inputs with MID

查看:85
本文介绍了使用MID压缩输入的DMN决策模型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在下面的DMN模型中压缩输入并计算折扣。我可以通过信号模拟器运行它。

I have below DMN model that zips input and calculate discount. I am able to run it thru simulator in signavio.

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<definitions namespace="http://www.signavio.com/dmn/1.1/diagram/8462cb232d98419493d4ef846516a070.xml" exporterVersion="13.3.2" name="MID Example" id="id-f1fe73d348e342d2a6f0435b38ce14e6" sigExt:revisionId="9f563b074ba844d4b9d1fcd6bead7580" sigExt:revisionNumber="1" xmlns="http://www.omg.org/spec/DMN/20151101/dmn.xsd" xmlns:sig="http://www.signavio.com/dmn/1.1/diagram/8462cb232d98419493d4ef846516a070.xml" xmlns:sigExt="http://www.signavio.com/schema/dmn/1.1/" xmlns:feel="http://www.omg.org/spec/FEEL/20140401">
<extensionElements/>
<itemDefinition isCollection="false" name="calculatePriceAfterDiscount" id="id-f8c81ba73d98a8a51216f4583ed31dc9" label="Calculate Price After Discount">
    <typeRef>feel:number</typeRef>
</itemDefinition>
<itemDefinition isCollection="false" name="calculatePrice" id="id-e13d8570789c69dec9515bd8b9159f2d" label="Calculate Price ">
    <typeRef>feel:number</typeRef>
</itemDefinition>
<itemDefinition isCollection="false" name="determineDiscount" id="id-99dded75dc910f4c4b3e2f1d3471cd10" label="Determine Discount %">
    <typeRef>feel:number</typeRef>
</itemDefinition>
<itemDefinition isCollection="false" name="discount" id="id-e41b37d9d6d86919af6290e062ee6bbe" label="Discount">
    <typeRef>feel:number</typeRef>
</itemDefinition>
<itemDefinition isCollection="false" name="collateOrder2" id="id-a4abe03e2f888a7830f15614f50bc45a" label="Collate Order">
    <itemComponent isCollection="false" name="itemName" id="id-a4abe03e2f888a7830f15614f50bc45a-relation-ItemName" label="Item Name" sigExt:slotId="Item Name">
        <typeRef>feel:string</typeRef>
    </itemComponent>
    <itemComponent isCollection="false" name="itemPrice" id="id-a4abe03e2f888a7830f15614f50bc45a-relation-ItemPrice" label="Item Price" sigExt:slotId="Item Price">
        <typeRef>feel:number</typeRef>
    </itemComponent>
    <itemComponent isCollection="false" name="itemQuantity" id="id-a4abe03e2f888a7830f15614f50bc45a-relation-ItemQuantity" label="Item Quantity" sigExt:slotId="Item Quantity">
        <typeRef>feel:number</typeRef>
    </itemComponent>
</itemDefinition>
<itemDefinition isCollection="false" name="calculateTotalPrice" id="id-753285786a1cec905c139529a673b0fe" label="Calculate Total Price">
    <typeRef>feel:number</typeRef>
</itemDefinition>
<itemDefinition isCollection="false" name="itemPrice" id="id-1a281dc9cb860f8ffd0c4cef9485f6a0" label="Item Price ">
    <typeRef>feel:number</typeRef>
</itemDefinition>
<itemDefinition isCollection="true" name="collateOrder" id="id-8cbabc9f5673d5e84b524b68155dcb45" label="Collate Order">
    <itemComponent isCollection="false" name="itemName" id="id-8cbabc9f5673d5e84b524b68155dcb45-relation-ItemName" label="Item Name" sigExt:slotId="Item Name">
        <typeRef>feel:string</typeRef>
    </itemComponent>
    <itemComponent isCollection="false" name="itemPrice" id="id-8cbabc9f5673d5e84b524b68155dcb45-relation-ItemPrice" label="Item Price" sigExt:slotId="Item Price">
        <typeRef>feel:number</typeRef>
    </itemComponent>
    <itemComponent isCollection="false" name="itemQuantity" id="id-8cbabc9f5673d5e84b524b68155dcb45-relation-ItemQuantity" label="Item Quantity" sigExt:slotId="Item Quantity">
        <typeRef>feel:number</typeRef>
    </itemComponent>
</itemDefinition>
<itemDefinition isCollection="false" name="order" id="id-4cc8046b78214ad11657d5b06436db21" label="Order ">
    <itemComponent isCollection="true" name="price" id="id-4cc8046b78214ad11657d5b06436db21-relation-0" label="Price" sigExt:slotId="0">
        <typeRef>feel:number</typeRef>
    </itemComponent>
    <itemComponent isCollection="true" name="quantity" id="id-4cc8046b78214ad11657d5b06436db21-relation-1" label="Quantity" sigExt:slotId="1">
        <typeRef>feel:number</typeRef>
    </itemComponent>
    <itemComponent isCollection="true" name="itemName" id="id-4cc8046b78214ad11657d5b06436db21-relation-2" label="Item Name" sigExt:slotId="2">
        <typeRef>feel:string</typeRef>
    </itemComponent>
</itemDefinition>
<inputData name="collateOrder_iterator" id="id-4835f35ebd354e9d65c600afb02d9d3c" label="Collate Order" sigExt:shapeId="sid-139D76F2-2029-4058-B488-9472C5BBEBC6" sigExt:diagramId="8462cb232d98419493d4ef846516a070">
    <extensionElements/>
    <variable typeRef="sig:collateOrder2" name="collateOrder_iterator" id="id-4835f35ebd354e9d65c600afb02d9d3c_variable"/>
</inputData>
<inputData name="order" id="id-a47f651b80111a121d93cf07939b20dc" label="Order " sigExt:shapeId="sid-8352CBF9-98EA-4018-9EAC-F17A5F936551" sigExt:diagramId="8462cb232d98419493d4ef846516a070">
    <extensionElements/>
    <variable typeRef="sig:order" name="order" id="id-a47f651b80111a121d93cf07939b20dc_variable"/>
</inputData>
<decision name="calculatePriceAfterDiscount" id="id-567eb0877fe31a6d84a53c3917e4eee0" label="Calculate Price After Discount" sigExt:shapeId="sid-5F8D6179-84FD-47B9-BA88-0E3CB4305014" sigExt:diagramId="8462cb232d98419493d4ef846516a070">
    <extensionElements/>
    <variable typeRef="sig:calculatePriceAfterDiscount" name="calculatePriceAfterDiscount" id="id-567eb0877fe31a6d84a53c3917e4eee0_variable"/>
    <informationRequirement>
        <requiredDecision href="#id-bc493858d94a5f245b95febc081cb0c7"/>
    </informationRequirement>
    <informationRequirement>
        <requiredDecision href="#id-d045696f950f3769011d375f7a1afd78"/>
    </informationRequirement>
    <literalExpression expressionLanguage="http://www.omg.org/spec/FEEL/20140401">
        <text>(calculatePrice-((determineDiscount/100)*calculatePrice))</text>
    </literalExpression>
</decision>
<decision name="calculateTotalPrice" id="id-be5d8465feb66b570cf75aeee595bf21" label="Calculate Total Price" sigExt:shapeId="sid-EA841422-3493-491C-9CE6-59F5EA9CE261" sigExt:diagramId="8462cb232d98419493d4ef846516a070">
    <extensionElements/>
    <variable typeRef="sig:calculateTotalPrice" name="calculateTotalPrice" id="id-be5d8465feb66b570cf75aeee595bf21_variable"/>
    <informationRequirement>
        <requiredInput href="#id-4835f35ebd354e9d65c600afb02d9d3c"/>
    </informationRequirement>
    <decisionTable hitPolicy="UNIQUE">
        <input id="id-137491756d969eac658224df41ae34d3" label="Price">
            <inputExpression>
                <text>collateOrder_iterator.itemPrice</text>
            </inputExpression>
        </input>
        <input id="id-cad45b775d319f14f2cc11d5d3b758fd" label="Quantity">
            <inputExpression>
                <text>collateOrder_iterator.itemQuantity</text>
            </inputExpression>
        </input>
        <output name="calculateTotalPrice" typeRef="sig:itemPrice" id="id-99e0fdb7f0d56dbc7bb88ae025be147c" label="Calculate Total Price"/>
        <rule id="id-2fff85d2331aa1e369d698392addb0a8">
            <description>string(-)</description>
            <inputEntry>
                <text>not(null)</text>
            </inputEntry>
            <inputEntry>
                <text>not(null)</text>
            </inputEntry>
            <outputEntry>
                <text>(collateOrder_iterator.itemPrice*collateOrder_iterator.itemQuantity)</text>
            </outputEntry>
        </rule>
    </decisionTable>
</decision>
<decision name="determineDiscount" id="id-bc493858d94a5f245b95febc081cb0c7" label="Determine Discount %" sigExt:shapeId="sid-6824DDAF-771A-4773-973E-1477F70EC90B" sigExt:diagramId="8462cb232d98419493d4ef846516a070">
    <extensionElements/>
    <variable typeRef="sig:determineDiscount" name="determineDiscount" id="id-bc493858d94a5f245b95febc081cb0c7_variable"/>
    <informationRequirement>
        <requiredDecision href="#id-d045696f950f3769011d375f7a1afd78"/>
    </informationRequirement>
    <decisionTable hitPolicy="UNIQUE">
        <input id="id-8a61ecb31c82e81d0b067a63f8a10b25" label="Calculate Price ">
            <inputExpression>
                <text>calculatePrice</text>
            </inputExpression>
        </input>
        <output name="determineDiscount" typeRef="sig:discount" id="id-cd2468e782346733c82b544eae541110" label="Determine Discount %"/>
        <rule id="id-8ce83be6aaf7113a136fadb09f2de83b">
            <description>string(-)</description>
            <inputEntry>
                <text>[0..500)</text>
            </inputEntry>
            <outputEntry>
                <text>1</text>
            </outputEntry>
        </rule>
        <rule id="id-ba19200060db4a933658db98400f5019">
            <description>string(-)</description>
            <inputEntry>
                <text>[500..1000)</text>
            </inputEntry>
            <outputEntry>
                <text>5</text>
            </outputEntry>
        </rule>
        <rule id="id-23a4b91a413530151413d2230f41e010">
            <description>string(-)</description>
            <inputEntry>
                <text>[1000..5000)</text>
            </inputEntry>
            <outputEntry>
                <text>10</text>
            </outputEntry>
        </rule>
        <rule id="id-9b4dbf30626d219d5e7937c1322b33fe">
            <description>string(-)</description>
            <inputEntry>
                <text>[5000..10000]</text>
            </inputEntry>
            <outputEntry>
                <text>20</text>
            </outputEntry>
        </rule>
        <rule id="id-37139385183b4a6ee481738ccccc02f4">
            <description>string(-)</description>
            <inputEntry>
                <text>&gt; 10000</text>
            </inputEntry>
            <outputEntry>
                <text>25</text>
            </outputEntry>
        </rule>
        <rule id="id-7d86977d4be287545686b09f982b55a9">
            <description>string(-)</description>
            <inputEntry>
                <text>&lt; 0</text>
            </inputEntry>
            <outputEntry>
                <text>0</text>
            </outputEntry>
        </rule>
    </decisionTable>
</decision>
<decision name="calculatePrice" id="id-d045696f950f3769011d375f7a1afd78" label="Calculate Price " sigExt:shapeId="sid-E3A6C7E0-BEE6-47C9-97EC-1C5A95EE2DB4" sigExt:diagramId="8462cb232d98419493d4ef846516a070">
    <extensionElements>
        <sigExt:MultiInstanceDecisionLogic>
            <sigExt:iterationExpression>collateOrder</sigExt:iterationExpression>
            <sigExt:iteratorShapeId>id-4835f35ebd354e9d65c600afb02d9d3c</sigExt:iteratorShapeId>
            <sigExt:aggregationFunction>SUM</sigExt:aggregationFunction>
            <sigExt:topLevelDecisionId>id-be5d8465feb66b570cf75aeee595bf21</sigExt:topLevelDecisionId>
        </sigExt:MultiInstanceDecisionLogic>
    </extensionElements>
    <variable typeRef="sig:calculatePrice" name="calculatePrice" id="id-d045696f950f3769011d375f7a1afd78_variable"/>
    <informationRequirement>
        <requiredDecision href="#id-85c7398c9bc186c1e2396c4625ebbcc1"/>
    </informationRequirement>
</decision>
<decision name="collateOrder" id="id-85c7398c9bc186c1e2396c4625ebbcc1" label="Collate Order" sigExt:shapeId="sid-C47674E0-8CDE-4A4A-84E8-3DD179DCF72C" sigExt:diagramId="8462cb232d98419493d4ef846516a070">
    <extensionElements/>
    <variable typeRef="sig:collateOrder" name="collateOrder" id="id-85c7398c9bc186c1e2396c4625ebbcc1_variable"/>
    <informationRequirement>
        <requiredInput href="#id-a47f651b80111a121d93cf07939b20dc"/>
    </informationRequirement>
    <literalExpression expressionLanguage="http://www.omg.org/spec/FEEL/20140401">
        <text>zip(["Item Name", "Item Price", "Item Quantity"], [order.itemName, order.price, order.quantity])</text>
    </literalExpression>
</decision>

我试图更改zip如下

zip([[商品名称,商品价格,商品数量],order.itemName,order.price,order.quantity)

zip(["Item Name", "Item Price", "Item Quantity"],order.itemName, order.price, order.quantity)

当我通过Java代码运行它时,出现以下错误消息

When i run it thru my java code, i am getting below error message

19:40:43.251 [ main]错误org.kie.dmn.feel.runtime.functions.DTInvokerFunction-调用决策表'determineDiscount'时出错:ClassCastException
java.lang.ClassCastException:类java.util.ArrayList无法转换为类java.math .BigDecimal(java.util.ArrayList和java.math.BigDecimal在加载程序 bootstrap的模块java.base中)

19:40:43.251 [main] ERROR org.kie.dmn.feel.runtime.functions.DTInvokerFunction - Error invoking decision table 'determineDiscount': ClassCastException java.lang.ClassCastException: class java.util.ArrayList cannot be cast to class java.math.BigDecimal (java.util.ArrayList and java.math.BigDecimal are in module java.base of loader 'bootstrap')

我的Java代码将是这样

My java code will be like this

    final KieServices ks = KieServices.Factory.get();
    final KieFileSystem kfs = ks.newKieFileSystem();
    KieModuleModel kmm = ks.newKieModuleModel();
    kmm.setConfigurationProperty("org.kie.dmn.profiles.signavio", "org.kie.dmn.signavio.KieDMNSignavioProfile");
    kfs.writeKModuleXML(kmm.toXML());
    kfs.write(ks.getResources().newClassPathResource("MID Example (2).dmn", this.getClass()));
    KieBuilder kieBuilder = ks.newKieBuilder(kfs).buildAll();
    Results results = kieBuilder.getResults();
    logger.info("buildAll() completed.");
    results.getMessages(Message.Level.WARNING).forEach(e -> logger.warn("{}", e));
    final KieContainer kieContainer = ks.newKieContainer(ks.getRepository().getDefaultReleaseId());
    DMNRuntime runtime = kieContainer.newKieSession().getKieRuntime(DMNRuntime.class);
    DMNModel model0 = runtime.getModels().get(0);
    DMNContext context = runtime.newContext();
    Map<String, Object> item1 = new HashMap<>();
    item1.put("itemName", "item1");
    item1.put("price", 1000);
    item1.put("quantity", 100);
    Map<String, Object> item2 = new HashMap<>();
    item2.put("itemName", "item2");
    item2.put("price", 200);
    item2.put("quantity", 20);
    Map<String, Object> item3 = new HashMap<>();
    item3.put("itemName", "item3");
    item3.put("price", 3000);
    item3.put("quantity", 300);
    context.set("order", Arrays.asList(item1, item2, item3));
    DMNResult evaluateAll = runtime.evaluateAll(model0, context);
    evaluateAll.getMessages().forEach(System.out::println);
    List<DMNDecisionResult> decResutls = evaluateAll.getDecisionResults();
    printDecisionResults(decResutls);

赞赏任何指针。

推荐答案

感谢您提供所有必需的资产/代码,以完整地重现此问题。
我相信下面将描述一些问题,并在下面提供一个完整的固定/工作示例。

Thank you for providing all required assets/code to reproduce the issue in full. I believe there are several problems which I will describe below, and provide a complete fixed/working example bottom.

根据您完整的DMN模型定义,订单(输入数据节点值)必须是 itemName, price, quantity 属性;

Based on your full DMN model definition, the Order (input data node value) must be a singleton composite object of "itemName", "price", "quantity" properties; each of this property is a collection.

因此,输入内容应类似于:

So the input should be something like:

    order: {
        itemName: [item1, item2, item3]
        quantity: [100, 20, 300]
        price: [1000, 200, 3000]
    }


问题:尊重与订单类型定义一致的zip函数


根据您完整的DMN模型定义, zip函数的正确定义应为:

Problem: respecting the zip function consistent with Order type definition

Based on your full DMN model definition, the correct definition for the zip function shall be:

zip(["Item Name", "Item Price", "Item Quantity"], order.itemName, order.price, order.quantity)

我假设您要执行的操作基于完整的DMN模型定义将数据转换为以下结构

as I assume what you want to do, based on the full DMN model definition, is transform the data into the following structure

collateOrder: [
   {
      Item Name=item1,
      Item Quantity=100,
      Item Price=1000
   },
   {
      Item Name=item2,
      Item Quantity=20,
      Item Price=200
   },
   {
      Item Name=item3,
      Item Quantity=300,
      Item Price=3000
   }
]


问题:MID聚合功能


我相信我在Signavio扩展实现中发现了一个错误;

Problem: MID aggregation function

I believe I found a bug in the Signavio extension implementation; thank you for reporting this will be investigated further.

但是,您可以使用简单得多的标准DMN文字表达式来执行所需的业务逻辑,而不必依赖仅定义以外的任何扩展在DMN规范本身中:

However you can do the required business logic by using the much simpler standard DMN literal expression, without having to rely on any extension beyond what defined only in the DMN specification itself:

sum( for order in collateOrder return ( order.Item Price * order.Item Quantity ) )

这不需要任何(Signavio)扩展名,并且它是有效的DMN。

this does not require any (Signavio) extension, and it's valid DMN.

回顾一下。

Java测试代码段:

Java test code snippet:

        DMNContext context = runtime.newContext();
        List<String> itemList = Arrays.asList("item1", "item2", "item3");
        List<BigDecimal> priceList = Arrays.asList(new BigDecimal(1000), new BigDecimal(200), new BigDecimal(3000));
        List<Integer> qtyList = Arrays.asList(100, 20, 300);
        Map<String, Object> order = new HashMap<>();
        order.put("itemName", itemList);
        order.put("price", priceList);
        order.put("quantity", qtyList);
        context.set("order", order);
        DMNResult evaluateAll = runtime.evaluateAll(model0, context);

固定的DMN模型,无需任何特殊扩展:

fixed DMN model, without requiring any special extension:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<definitions namespace="http://www.signavio.com/dmn/1.1/diagram/8462cb232d98419493d4ef846516a070.xml" exporterVersion="13.3.2" name="MID Example" id="id-f1fe73d348e342d2a6f0435b38ce14e6" sigExt:revisionId="9f563b074ba844d4b9d1fcd6bead7580" sigExt:revisionNumber="1" xmlns="http://www.omg.org/spec/DMN/20151101/dmn.xsd" xmlns:sig="http://www.signavio.com/dmn/1.1/diagram/8462cb232d98419493d4ef846516a070.xml" xmlns:sigExt="http://www.signavio.com/schema/dmn/1.1/" xmlns:feel="http://www.omg.org/spec/FEEL/20140401">
<extensionElements/>
<itemDefinition isCollection="false" name="calculatePriceAfterDiscount" id="id-f8c81ba73d98a8a51216f4583ed31dc9" label="Calculate Price After Discount">
    <typeRef>feel:number</typeRef>
</itemDefinition>
<itemDefinition isCollection="false" name="calculatePrice" id="id-e13d8570789c69dec9515bd8b9159f2d" label="Calculate Price ">
    <typeRef>feel:number</typeRef>
</itemDefinition>
<itemDefinition isCollection="false" name="determineDiscount" id="id-99dded75dc910f4c4b3e2f1d3471cd10" label="Determine Discount %">
    <typeRef>feel:number</typeRef>
</itemDefinition>
<itemDefinition isCollection="false" name="discount" id="id-e41b37d9d6d86919af6290e062ee6bbe" label="Discount">
    <typeRef>feel:number</typeRef>
</itemDefinition>
<itemDefinition isCollection="false" name="collateOrder2" id="id-a4abe03e2f888a7830f15614f50bc45a" label="Collate Order">
    <itemComponent isCollection="false" name="itemName" id="id-a4abe03e2f888a7830f15614f50bc45a-relation-ItemName" label="Item Name" sigExt:slotId="Item Name">
        <typeRef>feel:string</typeRef>
    </itemComponent>
    <itemComponent isCollection="false" name="itemPrice" id="id-a4abe03e2f888a7830f15614f50bc45a-relation-ItemPrice" label="Item Price" sigExt:slotId="Item Price">
        <typeRef>feel:number</typeRef>
    </itemComponent>
    <itemComponent isCollection="false" name="itemQuantity" id="id-a4abe03e2f888a7830f15614f50bc45a-relation-ItemQuantity" label="Item Quantity" sigExt:slotId="Item Quantity">
        <typeRef>feel:number</typeRef>
    </itemComponent>
</itemDefinition>
<itemDefinition isCollection="false" name="calculateTotalPrice" id="id-753285786a1cec905c139529a673b0fe" label="Calculate Total Price">
    <typeRef>feel:number</typeRef>
</itemDefinition>
<itemDefinition isCollection="false" name="itemPrice" id="id-1a281dc9cb860f8ffd0c4cef9485f6a0" label="Item Price ">
    <typeRef>feel:number</typeRef>
</itemDefinition>
<itemDefinition isCollection="true" name="collateOrder" id="id-8cbabc9f5673d5e84b524b68155dcb45" label="Collate Order">
    <itemComponent isCollection="false" name="itemName" id="id-8cbabc9f5673d5e84b524b68155dcb45-relation-ItemName" label="Item Name" sigExt:slotId="Item Name">
        <typeRef>feel:string</typeRef>
    </itemComponent>
    <itemComponent isCollection="false" name="itemPrice" id="id-8cbabc9f5673d5e84b524b68155dcb45-relation-ItemPrice" label="Item Price" sigExt:slotId="Item Price">
        <typeRef>feel:number</typeRef>
    </itemComponent>
    <itemComponent isCollection="false" name="itemQuantity" id="id-8cbabc9f5673d5e84b524b68155dcb45-relation-ItemQuantity" label="Item Quantity" sigExt:slotId="Item Quantity">
        <typeRef>feel:number</typeRef>
    </itemComponent>
</itemDefinition>
<itemDefinition isCollection="false" name="order" id="id-4cc8046b78214ad11657d5b06436db21" label="Order ">
    <itemComponent isCollection="true" name="price" id="id-4cc8046b78214ad11657d5b06436db21-relation-0" label="Price" sigExt:slotId="0">
        <typeRef>feel:number</typeRef>
    </itemComponent>
    <itemComponent isCollection="true" name="quantity" id="id-4cc8046b78214ad11657d5b06436db21-relation-1" label="Quantity" sigExt:slotId="1">
        <typeRef>feel:number</typeRef>
    </itemComponent>
    <itemComponent isCollection="true" name="itemName" id="id-4cc8046b78214ad11657d5b06436db21-relation-2" label="Item Name" sigExt:slotId="2">
        <typeRef>feel:string</typeRef>
    </itemComponent>
</itemDefinition>
<inputData name="order" id="id-a47f651b80111a121d93cf07939b20dc" label="Order " sigExt:shapeId="sid-8352CBF9-98EA-4018-9EAC-F17A5F936551" sigExt:diagramId="8462cb232d98419493d4ef846516a070">
    <extensionElements/>
    <variable typeRef="sig:order" name="order" id="id-a47f651b80111a121d93cf07939b20dc_variable"/>
</inputData>
<decision name="calculatePriceAfterDiscount" id="id-567eb0877fe31a6d84a53c3917e4eee0" label="Calculate Price After Discount" sigExt:shapeId="sid-5F8D6179-84FD-47B9-BA88-0E3CB4305014" sigExt:diagramId="8462cb232d98419493d4ef846516a070">
    <extensionElements/>
    <variable typeRef="sig:calculatePriceAfterDiscount" name="calculatePriceAfterDiscount" id="id-567eb0877fe31a6d84a53c3917e4eee0_variable"/>
    <informationRequirement>
        <requiredDecision href="#id-bc493858d94a5f245b95febc081cb0c7"/>
    </informationRequirement>
    <informationRequirement>
        <requiredDecision href="#id-d045696f950f3769011d375f7a1afd78"/>
    </informationRequirement>
    <literalExpression expressionLanguage="http://www.omg.org/spec/FEEL/20140401">
        <text>(calculatePrice-((determineDiscount/100)*calculatePrice))</text>
    </literalExpression>
</decision>
<decision name="determineDiscount" id="id-bc493858d94a5f245b95febc081cb0c7" label="Determine Discount %" sigExt:shapeId="sid-6824DDAF-771A-4773-973E-1477F70EC90B" sigExt:diagramId="8462cb232d98419493d4ef846516a070">
    <extensionElements/>
    <variable typeRef="sig:determineDiscount" name="determineDiscount" id="id-bc493858d94a5f245b95febc081cb0c7_variable"/>
    <informationRequirement>
        <requiredDecision href="#id-d045696f950f3769011d375f7a1afd78"/>
    </informationRequirement>
    <decisionTable hitPolicy="UNIQUE">
        <input id="id-8a61ecb31c82e81d0b067a63f8a10b25" label="Calculate Price ">
            <inputExpression>
                <text>calculatePrice</text>
            </inputExpression>
        </input>
        <output name="determineDiscount" typeRef="sig:discount" id="id-cd2468e782346733c82b544eae541110" label="Determine Discount %"/>
        <rule id="id-8ce83be6aaf7113a136fadb09f2de83b">
            <description>string(-)</description>
            <inputEntry>
                <text>[0..500)</text>
            </inputEntry>
            <outputEntry>
                <text>1</text>
            </outputEntry>
        </rule>
        <rule id="id-ba19200060db4a933658db98400f5019">
            <description>string(-)</description>
            <inputEntry>
                <text>[500..1000)</text>
            </inputEntry>
            <outputEntry>
                <text>5</text>
            </outputEntry>
        </rule>
        <rule id="id-23a4b91a413530151413d2230f41e010">
            <description>string(-)</description>
            <inputEntry>
                <text>[1000..5000)</text>
            </inputEntry>
            <outputEntry>
                <text>10</text>
            </outputEntry>
        </rule>
        <rule id="id-9b4dbf30626d219d5e7937c1322b33fe">
            <description>string(-)</description>
            <inputEntry>
                <text>[5000..10000]</text>
            </inputEntry>
            <outputEntry>
                <text>20</text>
            </outputEntry>
        </rule>
        <rule id="id-37139385183b4a6ee481738ccccc02f4">
            <description>string(-)</description>
            <inputEntry>
                <text>&gt; 10000</text>
            </inputEntry>
            <outputEntry>
                <text>25</text>
            </outputEntry>
        </rule>
        <rule id="id-7d86977d4be287545686b09f982b55a9">
            <description>string(-)</description>
            <inputEntry>
                <text>&lt; 0</text>
            </inputEntry>
            <outputEntry>
                <text>0</text>
            </outputEntry>
        </rule>
    </decisionTable>
</decision>
<decision name="calculatePrice" id="id-d045696f950f3769011d375f7a1afd78" label="Calculate Price " sigExt:shapeId="sid-E3A6C7E0-BEE6-47C9-97EC-1C5A95EE2DB4" sigExt:diagramId="8462cb232d98419493d4ef846516a070">
    <literalExpression expressionLanguage="http://www.omg.org/spec/FEEL/20140401">
        <text>sum( for order in collateOrder return ( order.Item Price * order.Item Quantity ) )</text>
    </literalExpression>
    <variable typeRef="sig:calculatePrice" name="calculatePrice" id="id-d045696f950f3769011d375f7a1afd78_variable"/>
    <informationRequirement>
        <requiredDecision href="#id-85c7398c9bc186c1e2396c4625ebbcc1"/>
    </informationRequirement>
</decision>
<decision name="collateOrder" id="id-85c7398c9bc186c1e2396c4625ebbcc1" label="Collate Order" sigExt:shapeId="sid-C47674E0-8CDE-4A4A-84E8-3DD179DCF72C" sigExt:diagramId="8462cb232d98419493d4ef846516a070">
    <extensionElements/>
    <variable typeRef="sig:collateOrder" name="collateOrder" id="id-85c7398c9bc186c1e2396c4625ebbcc1_variable"/>
    <informationRequirement>
        <requiredInput href="#id-a47f651b80111a121d93cf07939b20dc"/>
    </informationRequirement>
    <literalExpression expressionLanguage="http://www.omg.org/spec/FEEL/20140401">
        <text>zip(["Item Name", "Item Price", "Item Quantity"], order.itemName, order.price, order.quantity)</text>
    </literalExpression>
</decision>
</definitions>

Results:

    order: {
        itemName: [item1, item2, item3]
        quantity: [100, 20, 300]
        price: [1000, 200, 3000]
    }
    collateOrder: [{Item Name=item1, Item Quantity=100, Item Price=1000}, {Item Name=item2, Item Quantity=20, Item Price=200}, {Item Name=item3, Item Quantity=300, Item Price=3000}]
    calculatePrice: 1004000
    determineDiscount: 25
    calculatePriceAfterDiscount: 753000.00

Thanks again for reporting the issue with the MID, we will investigate the issue within the Signavio extension.

Thanks again for reporting the issue with the MID, we will investigate the issue within the Signavio extension.

这篇关于使用MID压缩输入的DMN决策模型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆