Browse Source

放弃工作流

dev
yujintao 6 years ago
parent
commit
12c493846d
  1. 69
      esua-epdc/epdc-module/epdc-activiti/epdc-activiti-server/processon/demo1.bpmn
  2. 89
      esua-epdc/epdc-module/epdc-activiti/epdc-activiti-server/processon/yishi.bpmn
  3. 24
      esua-epdc/epdc-module/epdc-activiti/epdc-activiti-server/src/main/java/com/elink/esua/epdc/service/ActWorkflowCommonService.java
  4. 50
      esua-epdc/epdc-module/epdc-activiti/epdc-activiti-server/src/main/java/com/elink/esua/epdc/service/impl/ActWorkflowCommonServiceImpl.java
  5. 110
      esua-epdc/epdc-module/epdc-activiti/epdc-activiti-server/src/test/java/com/elink/esua/epdc/ActivitiTest.java

69
esua-epdc/epdc-module/epdc-activiti/epdc-activiti-server/processon/demo1.bpmn

@ -0,0 +1,69 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" expressionLanguage="http://www.w3.org/1999/XPath" id="m1567478636229" name="" targetNamespace="http://www.activiti.org/testm1567478636229" typeLanguage="http://www.w3.org/2001/XMLSchema">
<process id="demoTask" isClosed="false" isExecutable="true" name="测试任务流程" processType="None">
<startEvent id="_2" name="StartEvent"/>
<endEvent id="_3" name="EndEvent"/>
<userTask activiti:assignee="${deptId}" activiti:exclusive="true" id="_4" name="初次审核">
<extensionElements>
<activiti:executionListener event="end" expression="审核完成"/>
</extensionElements>
</userTask>
<userTask activiti:assignee="${deptId}" activiti:exclusive="true" id="_5" name="二次审核">
<extensionElements>
<activiti:executionListener event="end" expression="审核完成"/>
</extensionElements>
</userTask>
<sequenceFlow id="_6" sourceRef="_2" targetRef="_4"/>
<sequenceFlow id="_7" sourceRef="_4" targetRef="_5"/>
<sequenceFlow id="_8" sourceRef="_5" targetRef="_3"/>
</process>
<bpmndi:BPMNDiagram documentation="background=#FFFFFF;count=1;horizontalcount=1;orientation=0;width=842.4;height=1195.2;imageableWidth=832.4;imageableHeight=1185.2;imageableX=5.0;imageableY=5.0" id="Diagram-_1" name="New Diagram">
<bpmndi:BPMNPlane bpmnElement="demoTask">
<bpmndi:BPMNShape bpmnElement="_2" id="Shape-_2">
<dc:Bounds height="32.0" width="32.0" x="370.0" y="60.0"/>
<bpmndi:BPMNLabel>
<dc:Bounds height="32.0" width="32.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="_3" id="Shape-_3">
<dc:Bounds height="32.0" width="32.0" x="375.0" y="640.0"/>
<bpmndi:BPMNLabel>
<dc:Bounds height="32.0" width="32.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="_4" id="Shape-_4">
<dc:Bounds height="55.0" width="85.0" x="350.0" y="225.0"/>
<bpmndi:BPMNLabel>
<dc:Bounds height="55.0" width="85.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="_5" id="Shape-_5">
<dc:Bounds height="55.0" width="85.0" x="355.0" y="415.0"/>
<bpmndi:BPMNLabel>
<dc:Bounds height="55.0" width="85.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge bpmnElement="_6" id="BPMNEdge__6" sourceElement="_2" targetElement="_4">
<di:waypoint x="386.0" y="92.0"/>
<di:waypoint x="386.0" y="225.0"/>
<bpmndi:BPMNLabel>
<dc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="_7" id="BPMNEdge__7" sourceElement="_4" targetElement="_5">
<di:waypoint x="395.0" y="280.0"/>
<di:waypoint x="395.0" y="415.0"/>
<bpmndi:BPMNLabel>
<dc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="_8" id="BPMNEdge__8" sourceElement="_5" targetElement="_3">
<di:waypoint x="391.0" y="470.0"/>
<di:waypoint x="391.0" y="640.0"/>
<bpmndi:BPMNLabel>
<dc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</definitions>

89
esua-epdc/epdc-module/epdc-activiti/epdc-activiti-server/processon/yishi.bpmn

@ -1,43 +1,50 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL"
xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI"
xmlns:activiti="http://activiti.org/bpmn"
xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC"
xmlns:tns="http://www.activiti.org/test"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
expressionLanguage="http://www.w3.org/1999/XPath"
id="m1566628843418"
name=""
targetNamespace="http://www.activiti.org/test"
typeLanguage="http://www.w3.org/2001/XMLSchema">
<process xmlns="" id="myProcess_1" isClosed="false" isExecutable="true"
processType="None">
<startEvent id="_2" name="开始"/>
<userTask activiti:exclusive="true" id="_3" name="UserTask">
<extensionElements>
<activiti:taskListener event="create"/>
</extensionElements>
</userTask>
</process>
<bpmndi:BPMNDiagram xmlns=""
documentation="background=#3C3F41;count=1;horizontalcount=1;orientation=0;width=842.4;height=1195.2;imageableWidth=832.4;imageableHeight=1185.2;imageableX=5.0;imageableY=5.0"
id="Diagram-_1"
name="New Diagram">
<bpmndi:BPMNPlane bpmnElement="myProcess_1">
<bpmndi:BPMNShape bpmnElement="_2" id="Shape-_2">
<omgdc:Bounds height="32.0" width="32.0" x="245.0" y="100.0"/>
<bpmndi:BPMNLabel>
<omgdc:Bounds height="32.0" width="32.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="_3" id="Shape-_3">
<omgdc:Bounds height="55.0" width="85.0" x="255.0" y="200.0"/>
<bpmndi:BPMNLabel>
<omgdc:Bounds height="55.0" width="85.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" xmlns:tns="http://www.activiti.org/test" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" expressionLanguage="http://www.w3.org/1999/XPath" id="m1566628843418" name="" targetNamespace="http://www.activiti.org/test" typeLanguage="http://www.w3.org/2001/XMLSchema">
<process id="myProcess_1" isClosed="false" isExecutable="true" processType="None">
<startEvent id="_2" name="testTaskStart"/>
<endEvent id="_6" name="testTaskEnd"/>
<userTask activiti:exclusive="true" id="_11" name="UserTask">
<extensionElements>
<activiti:executionListener event="start" expression="test"/>
</extensionElements>
</userTask>
<sequenceFlow id="_13" sourceRef="_2" targetRef="_11"/>
<sequenceFlow id="_14" sourceRef="_11" targetRef="_6"/>
</process>
<bpmndi:BPMNDiagram documentation="background=#3C3F41;count=1;horizontalcount=1;orientation=0;width=842.4;height=1195.2;imageableWidth=832.4;imageableHeight=1185.2;imageableX=5.0;imageableY=5.0" id="Diagram-_1" name="New Diagram">
<bpmndi:BPMNPlane bpmnElement="myProcess_1">
<bpmndi:BPMNShape bpmnElement="_2" id="Shape-_2">
<omgdc:Bounds height="32.0" width="32.0" x="290.0" y="55.0"/>
<bpmndi:BPMNLabel>
<omgdc:Bounds height="32.0" width="32.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="_6" id="Shape-_6">
<omgdc:Bounds height="32.0" width="32.0" x="285.0" y="515.0"/>
<bpmndi:BPMNLabel>
<omgdc:Bounds height="32.0" width="32.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="_11" id="Shape-_11">
<omgdc:Bounds height="55.0" width="85.0" x="530.0" y="240.0"/>
<bpmndi:BPMNLabel>
<omgdc:Bounds height="55.0" width="85.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge bpmnElement="_13" id="BPMNEdge__13" sourceElement="_2" targetElement="_11">
<omgdi:waypoint x="322.0" y="71.0"/>
<omgdi:waypoint x="530.0" y="267.5"/>
<bpmndi:BPMNLabel>
<omgdc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="_14" id="BPMNEdge__14" sourceElement="_11" targetElement="_6">
<omgdi:waypoint x="530.0" y="267.5"/>
<omgdi:waypoint x="317.0" y="531.0"/>
<bpmndi:BPMNLabel>
<omgdc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</definitions>

24
esua-epdc/epdc-module/epdc-activiti/epdc-activiti-server/src/main/java/com/elink/esua/epdc/service/ActWorkflowCommonService.java

@ -0,0 +1,24 @@
package com.elink.esua.epdc.service;
/**
* activiti工作流
*
* @author yujintao
* @email yujintao@elink-cn.com
* @date 2019/9/3 11:18
*/
public interface ActWorkflowCommonService {
/**
* 启动流程并绑定任务
*
* @param processKey 流程ID
* @param businessKey 任务ID
* @param deptId 部门ID通过部门ID判断是否有权限审核任务
* @return boolean
* @author yujintao
* @date 2019/9/3 13:58
*/
boolean startProcess(String processKey, String businessKey, String deptId);
}

50
esua-epdc/epdc-module/epdc-activiti/epdc-activiti-server/src/main/java/com/elink/esua/epdc/service/impl/ActWorkflowCommonServiceImpl.java

@ -0,0 +1,50 @@
package com.elink.esua.epdc.service.impl;
import com.elink.esua.epdc.service.ActWorkflowCommonService;
import com.google.common.collect.Maps;
import org.activiti.engine.HistoryService;
import org.activiti.engine.RepositoryService;
import org.activiti.engine.RuntimeService;
import org.activiti.engine.TaskService;
import org.activiti.engine.runtime.ProcessInstance;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.context.ContextLoader;
import org.springframework.web.context.WebApplicationContext;
import java.util.HashMap;
import java.util.Map;
/**
* @author yujintao
* @email yujintao@elink-cn.com
* @date 2019/9/3 11:19
*/
@Service
public class ActWorkflowCommonServiceImpl implements ActWorkflowCommonService {
@Autowired
private RepositoryService repositoryService;
@Autowired
private RuntimeService runtimeService;
@Autowired
private TaskService taskService;
@Autowired
private HistoryService historyService;
@Override
public boolean startProcess(String processKey, String businessKey, String deptId) {
Map<String, Object> map = Maps.newHashMap();
map.put("deptId", deptId);
map.put("activityId", "_2");
//使用正在执行对象表中的一个字段BUSINESS_KEY(Activiti提供的一个字段),让启动的流程(流程实例)关联业务
runtimeService.startProcessInstanceByKey(processKey, businessKey, map);
return true;
}
}

110
esua-epdc/epdc-module/epdc-activiti/epdc-activiti-server/src/test/java/com/elink/esua/epdc/ActivitiTest.java

@ -0,0 +1,110 @@
package com.elink.esua.epdc;
import com.elink.esua.epdc.service.ActWorkflowCommonService;
import com.google.common.collect.Maps;
import org.activiti.engine.RuntimeService;
import org.activiti.engine.TaskService;
import org.activiti.engine.runtime.ProcessInstance;
import org.activiti.engine.task.Task;
import org.activiti.engine.task.TaskQuery;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import java.util.List;
import java.util.Map;
/**
* @author yujintao
* @email yujintao@elink-cn.com
* @date 2019/9/3 10:06
*/
@RunWith(SpringRunner.class)
@SpringBootTest
public class ActivitiTest {
@Autowired
private ActWorkflowCommonService actWorkflowCommonService;
@Autowired
private TaskService taskService;
@Autowired
private RuntimeService runtimeService;
@Test
public void test() {
String processId = "demoTask";
// 启动一个任务流程
actWorkflowCommonService.startProcess(processId, "testBusinessKey3", "testDeptId");
}
@Test
public void test2() {
String processId = "demoTask";
String deptId = "testDeptId";
this.queryTask(processId, deptId);
/*
关联业务idtestBusinessKey
流程实例id5001
任务id5006
任务标识_4
任务负责人testDeptId
任务名称初次审核
任务创建时间Tue Sep 03 14:26:50 CST 2019
*/
}
@Test
public void test3() {
Map<String, Object> map = Maps.newHashMap();
map.put("deptId", "testDeptId2");
taskService.complete("5006", map);
}
@Test
public void test4() {
String processId = "demoTask";
String deptId = "testDeptId2";
this.queryTask(processId, deptId);
/*
关联业务idtestBusinessKey
流程实例id5001
任务id7502
任务标识_5
任务负责人testDeptId2
任务名称二次审核
任务创建时间Tue Sep 03 14:49:29 CST 2019
*/
}
private void queryTask(String processId, String deptId) {
//创建查询对象
TaskQuery taskQuery = taskService.createTaskQuery().taskAssignee(deptId).processDefinitionKey(processId);
//获取查询列表
List<Task> list = taskQuery.list();
for (Task task : list) {
//流程实例id
String processInstanceId = task.getProcessInstanceId();
//根据流程实例id找到流程实例对象
ProcessInstance processInstance = runtimeService
.createProcessInstanceQuery()
.processInstanceId(processInstanceId)
.singleResult();
//从流程实例对象获取bussinesskey
String businessKey = processInstance.getBusinessKey();
//根据businessKey查询业务系统,获取相关的业务信息
System.out.println("关联业务id:" + businessKey);
System.out.println("流程实例id:" + task.getProcessInstanceId());
System.out.println("任务id:" + task.getId());
System.out.println("任务标识:" + task.getTaskDefinitionKey());
System.out.println("任务负责人:" + task.getAssignee());
System.out.println("任务名称:" + task.getName());
System.out.println("任务创建时间:" + task.getCreateTime());
}
}
}
Loading…
Cancel
Save