flowable DMN规则引擎几种类型解释_04
文章目錄
- 單一命中
- 第一個(FIRST)
- 唯一(UNIQUE)
- 優先級(PRIORITY)
- 任何(ANY)
- 多重命中
- 輸出順序(OUTPUT ORDER)
- 規則順序(RULE ORDER)
- 采集(COLLECT)
項目地址:https://gitee.com/lwj/flowable.git 分支flowable-base
視頻地址:https://www.bilibili.com/video/av79774697/
*業務場景:
往往在我們實際業務中,規則異常重要,比方說輸入一批數據得到某些結果數據,從而來簡化我們的BPMN流程圖,
*
flowableDMN規則引擎幾種類型解釋
單一命中
第一個(FIRST)
可以匹配多個(重疊)具有不同輸出條目的規則。返回規則順序中的第一次命中(返回后停止評估)。
唯一(UNIQUE)
沒有重疊的可能,所有規則都是互斥的。只能匹配到一條規則。
如果多個會報錯
可以利用設置解決這個問題
dmnEngine.getDmnEngineConfiguration().setStrictMode(false);
優先級(PRIORITY)
具有不同的輸出條目的多個規則可以匹配。此策略返回具有最高輸出優先級的匹配規則。輸出優先級在輸出值的有序列表中按優先級遞減的順序指定。當禁用strict mode且未定義輸出值時,結果是最后一個有效規則。(違規將以驗證消息的形式出現)
任何(ANY)
可能會有重疊,但如果所有匹配規則顯示每個輸出的輸出條目相等,就可以使用任何匹配。如果輸出條目不相等,則命中策略不正確,結果將為空并標記為failed。當禁用strict mode時,結果是最后一個有效規則。(違規將以驗證消息的形式出現)
多重命中
輸出順序(OUTPUT ORDER)
按輸出優先級遞減的順序返回所有命中規則。輸出優先級在輸出值的有序列表中按優先級遞減的順序指定。
規則順序(RULE ORDER)
按規則順序返回所有命中
1、疊加變量 ${output1 + 10} 2、包含 任意都在 輸入: List inputVariable1 = Arrays.asList("test1", "test2", "test3"); processVariablesInput.put("collection1", inputVariable1); 輸出: test2 or test5 in collection1 ${collection:containsAny(collection1, '"test2", "test5"')} 3、傳入對象 輸入: Person customerOne = new Person(); customerOne.setName("test1"); customerOne.setAge(10L); processVariablesInput.put("customerOne", customerOne); 輸出:${collection:contains("test1", customerOne.name)} 4、json傳入匹配 IN 兩個并且都在 輸入: ArrayNode arrayNode1 = objectMapper.createArrayNode().add("test1").add("test2").add("test3"); processVariablesInput.put("arrayNode1", arrayNode1); 輸出:"test1 and test2 in arrayNode1" ${collection:contains(arrayNode1, '"test1", "test2"')} 5、不包含 任意都不在 傳入: List inputVariable1 = Arrays.asList("test1", "test2", "test3"); processVariablesInput.put("collection1", inputVariable1); 表達式:test3 and / or test6 not in collection1 ${collection:notContainsAny(collection1, '"test3", "test6"')} 6、不包含 not in 兩個并且都不在 輸入: List inputVariable1 = Arrays.asList("test1", "test2", "test3"); processVariablesInput.put("collection1", inputVariable1); 輸出: test3 and test5 not in collection1 ${collection:notContains(collection1, '"test3", "test5"')}1、疊加變量
${output1 + 10}
2、包含 任意都在
輸入:
List inputVariable1 = Arrays.asList(“test1”, “test2”, “test3”);
processVariablesInput.put(“collection1”, inputVariable1);
輸出:
test2 or test5 in collection1
collection:containsAny(collection1,′“test2”,“test5”′)3、傳入對象輸入:PersoncustomerOne=newPerson();customerOne.setName(“test1”);customerOne.setAge(10L);processVariablesInput.put(“customerOne”,customerOne);輸出:collection:containsAny(collection1,
′
“test2”,“test5”
′
)3、傳入對象輸入:PersoncustomerOne=newPerson();customerOne.setName(“test1”);customerOne.setAge(10L);processVariablesInput.put(“customerOne”,customerOne);輸出:{collection:contains(“test1”, customerOne.name)}
4、json傳入匹配 IN 兩個并且都在
輸入:
ArrayNode arrayNode1 = objectMapper.createArrayNode().add(“test1”).add(“test2”).add(“test3”);
processVariablesInput.put(“arrayNode1”, arrayNode1);
輸出:“test1 and test2 in arrayNode1”
${collection:contains(arrayNode1, ‘“test1”, “test2”’)}
5、不包含 任意都不在
傳入:
List inputVariable1 = Arrays.asList(“test1”, “test2”, “test3”);
processVariablesInput.put(“collection1”, inputVariable1);
表達式:test3 and / or test6 not in collection1
${collection:notContainsAny(collection1, ‘“test3”, “test6”’)}
6、不包含 not in 兩個并且都不在
輸入:
List inputVariable1 = Arrays.asList(“test1”, “test2”, “test3”);
processVariablesInput.put(“collection1”, inputVariable1);
輸出:
test3 and test5 not in collection1
${collection:notContains(collection1, ‘“test3”, “test5”’)}
1、疊加變量
${output1 + 10}
2、包含 任意都在
輸入:
List inputVariable1 = Arrays.asList(“test1”, “test2”, “test3”);
processVariablesInput.put(“collection1”, inputVariable1);
輸出:
test2 or test5 in collection1
collection:containsAny(collection1,′“test2”,“test5”′)3、傳入對象輸入:PersoncustomerOne=newPerson();customerOne.setName(“test1”);customerOne.setAge(10L);processVariablesInput.put(“customerOne”,customerOne);輸出:collection:containsAny(collection1,
′
“test2”,“test5”
′
)3、傳入對象輸入:PersoncustomerOne=newPerson();customerOne.setName(“test1”);customerOne.setAge(10L);processVariablesInput.put(“customerOne”,customerOne);輸出:{collection:contains(“test1”, customerOne.name)}
4、json傳入匹配 IN 兩個并且都在
輸入:
ArrayNode arrayNode1 = objectMapper.createArrayNode().add(“test1”).add(“test2”).add(“test3”);
processVariablesInput.put(“arrayNode1”, arrayNode1);
輸出:“test1 and test2 in arrayNode1”
${collection:contains(arrayNode1, ‘“test1”, “test2”’)}
5、不包含 任意都不在
傳入:
List inputVariable1 = Arrays.asList(“test1”, “test2”, “test3”);
processVariablesInput.put(“collection1”, inputVariable1);
表達式:test3 and / or test6 not in collection1
${collection:notContainsAny(collection1, ‘“test3”, “test6”’)}
6、不包含 not in 兩個并且都不在
輸入:
List inputVariable1 = Arrays.asList(“test1”, “test2”, “test3”);
processVariablesInput.put(“collection1”, inputVariable1);
輸出:
test3 and test5 not in collection1
${collection:notContains(collection1, ‘“test3”, “test5”’)}
采集(COLLECT)
以任意順序返回所有命中。我們可以添加運算符(+,<,>,#)來將一個簡單函數應用于輸出。如果沒有運算符,則結果是所有輸出條目的列表。
+(總和):決策表的結果是所有不同輸出的總和。
<(最小值):決策表的結果是所有輸出中的最小值。
‘>(最大值):決策表的結果是所有輸出中的最大值。
#(計數):決策表的結果是不同輸出的數量。
總結
以上是生活随笔為你收集整理的flowable DMN规则引擎几种类型解释_04的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 调整eclipse、SpringTool
- 下一篇: 在线安装docker