|
@@ -9,15 +9,15 @@ import com.ruoyi.framework.web.page.TableDataInfo;
|
|
|
import com.ruoyi.project.activiti.domain.*;
|
|
|
import com.ruoyi.project.activiti.service.LeaveNewService;
|
|
|
import com.ruoyi.project.system.domain.SysUser;
|
|
|
-import org.activiti.bpmn.model.BpmnModel;
|
|
|
-import org.activiti.bpmn.model.FlowNode;
|
|
|
-import org.activiti.bpmn.model.SequenceFlow;
|
|
|
+import org.activiti.bpmn.model.*;
|
|
|
+import org.activiti.bpmn.model.Process;
|
|
|
import org.activiti.engine.HistoryService;
|
|
|
import org.activiti.engine.ProcessEngine;
|
|
|
import org.activiti.engine.RepositoryService;
|
|
|
import org.activiti.engine.RuntimeService;
|
|
|
import org.activiti.engine.history.HistoricActivityInstance;
|
|
|
import org.activiti.engine.history.HistoricProcessInstance;
|
|
|
+import org.activiti.engine.history.HistoricTaskInstance;
|
|
|
import org.activiti.engine.impl.RepositoryServiceImpl;
|
|
|
import org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity;
|
|
|
import org.activiti.engine.repository.ProcessDefinition;
|
|
@@ -30,10 +30,10 @@ import javax.servlet.http.HttpServletResponse;
|
|
|
import java.io.IOException;
|
|
|
import java.io.InputStream;
|
|
|
import java.io.OutputStream;
|
|
|
+import java.lang.reflect.Array;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.List;
|
|
|
+import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
* 请假业务Controller
|
|
@@ -253,21 +253,16 @@ public class LeaveNewController extends BaseController {
|
|
|
.processInstanceId(processInstanceId).orderByHistoricActivityInstanceId().asc().list();
|
|
|
|
|
|
List<String> executedActivityIdList = new ArrayList<String>();
|
|
|
- int index = 1;
|
|
|
|
|
|
for (HistoricActivityInstance activityInstance : historicActivityInstanceList) {
|
|
|
executedActivityIdList.add(activityInstance.getActivityId());
|
|
|
-
|
|
|
- index++;
|
|
|
}
|
|
|
-
|
|
|
BpmnModel bpmnModel = repositoryService.getBpmnModel(historicProcessInstance.getProcessDefinitionId());
|
|
|
|
|
|
|
|
|
- List<String> flowIds = new ArrayList<String>();
|
|
|
+ List<String> flowIds = new ArrayList<>();
|
|
|
|
|
|
flowIds = executedFlowIdList(bpmnModel, processDefinition, historicActivityInstanceList);
|
|
|
-
|
|
|
|
|
|
ProcessDiagramGenarateExt pec = new ProcessDiagramGenarateExt();
|
|
|
|
|
@@ -278,6 +273,7 @@ public class LeaveNewController extends BaseController {
|
|
|
}
|
|
|
|
|
|
InputStream imageStream = pec.generateDiagram(end, bpmnModel, "png", executedActivityIdList, flowIds, "宋体", "宋体", "宋体", null, 2.0);
|
|
|
+
|
|
|
|
|
|
response.setContentType("image/png");
|
|
|
OutputStream os = response.getOutputStream();
|
|
@@ -291,34 +287,40 @@ public class LeaveNewController extends BaseController {
|
|
|
}
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
- System.out.println(e.getMessage());
|
|
|
-
|
|
|
-
|
|
|
+ e.printStackTrace();
|
|
|
+ logger.error("【异常】-获取流程图失败!" + e.getMessage());
|
|
|
+ throw new RuntimeException("获取流程图失败!" + e.getMessage());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
private static List<String> executedFlowIdList(BpmnModel bpmnModel, ProcessDefinitionEntity processDefinitionEntity,
|
|
|
List<HistoricActivityInstance> historicActivityInstanceList) {
|
|
|
|
|
|
List<String> executedFlowIdList = new ArrayList<>();
|
|
|
-
|
|
|
-
|
|
|
- for (int i = 0; i < historicActivityInstanceList.size() - 1; i++) {
|
|
|
+ Set<String> ids = new HashSet<>();
|
|
|
+ Map<String, SequenceFlow> flowHashMap = new HashMap<>();
|
|
|
+ List<String> activityIds = historicActivityInstanceList.stream().map(X -> X.getActivityId()).collect(Collectors.toList());
|
|
|
+ for (int i = 0; i < historicActivityInstanceList.size(); i++) {
|
|
|
HistoricActivityInstance hai = historicActivityInstanceList.get(i);
|
|
|
- FlowNode flowNode = (FlowNode) bpmnModel.getFlowElement(hai.getActivityId());
|
|
|
+ String activityId = hai.getActivityId();
|
|
|
+ FlowNode flowNode = (FlowNode) bpmnModel.getFlowElement(activityId);
|
|
|
List<SequenceFlow> sequenceFlows = flowNode.getOutgoingFlows();
|
|
|
- if (sequenceFlows.size() > 1) {
|
|
|
- HistoricActivityInstance nextHai = historicActivityInstanceList.get(i + 1);
|
|
|
- sequenceFlows.forEach(sequenceFlow -> {
|
|
|
- if (sequenceFlow.getTargetFlowElement().getId().equals(nextHai.getActivityId())) {
|
|
|
- executedFlowIdList.add(sequenceFlow.getId());
|
|
|
- }
|
|
|
- });
|
|
|
- } else {
|
|
|
- executedFlowIdList.add(sequenceFlows.get(0).getId());
|
|
|
+ for (SequenceFlow sequenceFlow : sequenceFlows) {
|
|
|
+ String sourceRef = sequenceFlow.getSourceRef();
|
|
|
+ String targetRef = sequenceFlow.getTargetRef();
|
|
|
+ flowHashMap.put(targetRef, sequenceFlow);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+ for (String activityId : activityIds) {
|
|
|
+ for (String s : flowHashMap.keySet()) {
|
|
|
+ if (s.contains(activityId)) {
|
|
|
+ SequenceFlow sequenceFlow = flowHashMap.get(s);
|
|
|
+ ids.add(sequenceFlow.getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ executedFlowIdList.addAll(ids);
|
|
|
return executedFlowIdList;
|
|
|
}
|
|
|
|