yxk-20260409-集成流程引擎bpm代码
This commit is contained in:
+28
@@ -0,0 +1,28 @@
|
||||
//package org.jeecg;
|
||||
//
|
||||
//import java.util.HashMap;
|
||||
//import java.util.Map;
|
||||
//
|
||||
//import org.flowable.engine.RuntimeService;
|
||||
//import org.junit.jupiter.api.Test;
|
||||
//import org.springframework.beans.factory.annotation.Autowired;
|
||||
//import org.springframework.boot.test.context.SpringBootTest;
|
||||
//
|
||||
//@SpringBootTest(classes = JeecgBpmApplication.class)
|
||||
//public class ActivitiTest {
|
||||
//
|
||||
// @Autowired
|
||||
// RuntimeService runtimeService;
|
||||
//
|
||||
// /**
|
||||
// * 发起流程
|
||||
// */
|
||||
// @Test
|
||||
// public void TestStartProcess() {
|
||||
// Map<String, Object> variables = new HashMap<>();
|
||||
// variables.put("applyUserId", "admin");
|
||||
// variables.put("email", "john.doe@activiti.com");
|
||||
// variables.put("phoneNumber", "123456789");
|
||||
// runtimeService.startProcessInstanceByKey("jeecgboot-bpm01", variables);
|
||||
// }
|
||||
//}
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
package org.jeecg.test;
|
||||
|
||||
import org.flowable.common.engine.impl.de.odysseus.el.ExpressionFactoryImpl;
|
||||
import org.flowable.common.engine.impl.de.odysseus.el.util.SimpleContext;
|
||||
import org.flowable.common.engine.impl.javax.el.ExpressionFactory;
|
||||
import org.flowable.common.engine.impl.javax.el.ValueExpression;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @Description: 测试流程表达式
|
||||
* @author: scott
|
||||
* @date: 2023年09月15日 10:24
|
||||
*/
|
||||
public class TestExpression {
|
||||
|
||||
public Boolean checkFormDataByRuleEl(String el, Map<String, Object> formData) throws Exception {
|
||||
ExpressionFactory factory = new ExpressionFactoryImpl();
|
||||
SimpleContext context = new SimpleContext();
|
||||
for (Object k : formData.keySet()) {
|
||||
if (formData.get(k) != null) {
|
||||
context.setVariable(k.toString(), factory.createValueExpression(formData.get(k), formData.get(k).getClass()));
|
||||
}
|
||||
}
|
||||
|
||||
ValueExpression e = factory.createValueExpression(context, el, Boolean.class);
|
||||
return (Boolean) e.getValue(context);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBooleanExpression() {
|
||||
String el = "${请假天数>3 && 部门 == '产品部'}";
|
||||
Map<String, Object> formData = new HashMap<>();
|
||||
formData.put("请假天数", 4);
|
||||
formData.put("部门", "产品部");
|
||||
formData.put("test", "123");
|
||||
try {
|
||||
System.out.println(checkFormDataByRuleEl(el, formData));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user