资讯详情

04 flowable DMN规则引擎几种类型解释

*业务场景: 规则在我们的实际业务中往往非常重要,比如输入一批数据来获取一些结果数据,从而简化我们BPMN流程图, *

flowableDMN规则引擎的类型解释

  • 单一命中
    • 第一个(FIRST)
    • 唯一(UNIQUE)
    • 优先级(PRIORITY)
    • 任何(ANY)
  • 多重命中
    • 输出顺序(OUTPUT ORDER)
    • 规则顺序(RULE ORDER)
    • 采集(COLLECT)

单一命中

第一个(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 c o l l e c t i o n : c o n t a i n s A n y ( c o l l e c t i o n 1 , ′ " t e s t 2 " , " t e s t 5 " ′ ) 3 、 传 入 对 象 输 入 : P e r s o n c u s t o m e r O n e = n e w P e r s o n ( ) ; c u s t o m e r O n e . s e t N a m e ( " t e s t 1 " ) ; c u s t o m e r O n e . s e t A g e ( 10 L ) ; p r o c e s s V a r i a b l e s I n p u t . p u t ( " c u s t o m e r O n e " , c u s t o m e r O n e ) ; 输 出 : {collection:containsAny(collection1, '"test2", "test5"')} 3、传入对象 输入: Person customerOne = new Person(); 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 c o l l e c t i o n : c o n t a i n s A n y ( c o l l e c t i o n 1 , ′ " t e s t 2 " , " t e s t 5 " ′ ) 3 、 传 入 对 象 输 入 : P e r s o n c u s t o m e r O n e = n e w P e r s o n ( ) ; c u s t o m e r O n e . s e t N a m e ( " t e s t 1 " ) ; c u s t o m e r O n e . s e t A g e ( 10 L ) ; p r o c e s s V a r i a b l e s I n p u t . p u t ( " c u s t o m e r O n e " , c u s t o m e r O n e ) ; 输 出 : {collection:containsAny(collection1, '"test2", "test5"')} 3、传入对象 输入: Person customerOne = new Person(); 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)

以任意顺序返回所有命中。我们可以添加运算符(+,<,>,#)来将一个简单函数应用于输出。如果没有运算符,则结果是所有输出条目的列表。

+(总和):决策表的结果是所有不同输出的总和。

<(最小值):决策表的结果是所有输出中的最小值。

‘>(最大值):决策表的结果是所有输出中的最大值。

#(计数):决策表的结果是不同输出的数量。

标签: 二极管dmn26d0udj

锐单商城拥有海量元器件数据手册IC替代型号,打造 电子元器件IC百科大全!

锐单商城 - 一站式电子元器件采购平台