首页>代码>SpringBoot整合activiti dmn规范极简入门实例 dms规范使用实例>/springboot-dmn/src/main/java/com/simon/springbootdmn/dmn/DmnDemo.java
package com.simon.springbootdmn.dmn; import org.activiti.dmn.api.*; import org.activiti.dmn.engine.DmnEngine; import org.activiti.dmn.engine.DmnEngineConfiguration; import java.util.HashMap; import java.util.Map; /** * @author Simon */ public class DmnDemo { public static void main(String[] args) { // 根据默认配置创建引擎的配置实例 DmnEngineConfiguration config = DmnEngineConfiguration .createDmnEngineConfigurationFromResourceDefault(); // 创建规则引擎 DmnEngine engine = config.buildDmnEngine(); // 获取规则的存储服务组件 DmnRepositoryService rService = engine.getDmnRepositoryService(); // 获取规则服务组件 DmnRuleService ruleService = engine.getDmnRuleService(); // 进行规则 部署 DmnDeployment dep = rService.createDeployment() .addClasspathResource("dmn/first.dmn").deploy(); // 进行数据查询 DmnDecisionTable dt = rService.createDecisionTableQuery() .deploymentId(dep.getId()).singleResult(); // 初始化参数 Map<String, Object> params = new HashMap<>(); params.put("personAge", 19); // 传入参数执行决策,并返回结果 RuleEngineExecutionResult result = ruleService.executeDecisionByKey( dt.getKey(), params); // 控制台输出结果 System.out.println(result.getResultVariables().get("myResult")); // 重新设置参数 params.put("personAge", 5); // 重新执行决策 result = ruleService.executeDecisionByKey(dt.getKey(), params); // 控制台重新输出结果 System.out.println(result.getResultVariables().get("myResult")); } }

a1677596408 LV23
2023年4月24日
最代码官方 LV168
2023年3月12日