修改流程实例图中流转顺序问题

This commit is contained in:
wanggeng 2021-09-26 15:16:21 +08:00
parent 7c624e7482
commit 5d3ea2f478

View File

@ -188,8 +188,7 @@ public class ActivitiModelServiceImpl extends DefaultBaseService implements IAct
List<String> highLightedActivitiIds = new ArrayList<>(); List<String> highLightedActivitiIds = new ArrayList<>();
if (processInstance != null) { if (processInstance != null) {
List<String> activeActivityIds = runtimeService.getActiveActivityIds(processInstance.getId()); List<String> activeActivityIds = runtimeService.getActiveActivityIds(processInstance.getId());
highLightedActivitiIds.addAll(activeActivityIds); // 先添加历史节点
// 获取历史节点
List<HistoricActivityInstance> historicActivityInstances = historyService.createHistoricActivityInstanceQuery().processInstanceId(processInstanceId).list(); List<HistoricActivityInstance> historicActivityInstances = historyService.createHistoricActivityInstanceQuery().processInstanceId(processInstanceId).list();
if (!historicActivityInstances.isEmpty()) { if (!historicActivityInstances.isEmpty()) {
for (HistoricActivityInstance historicActivityInstance : historicActivityInstances) { for (HistoricActivityInstance historicActivityInstance : historicActivityInstances) {
@ -199,6 +198,8 @@ public class ActivitiModelServiceImpl extends DefaultBaseService implements IAct
highLightedActivitiIds.add("#" + historicActivityInstance.getActivityId()); highLightedActivitiIds.add("#" + historicActivityInstance.getActivityId());
} }
} }
// 添加现有节点
highLightedActivitiIds.addAll(activeActivityIds);
} }
List<String> listSequenceFlows = listSequenceFlows(bpmnModel, highLightedActivitiIds); List<String> listSequenceFlows = listSequenceFlows(bpmnModel, highLightedActivitiIds);
CustomProcessDiagramGenerator customProcessDiagramGenerator = new CustomProcessDiagramGenerator(); CustomProcessDiagramGenerator customProcessDiagramGenerator = new CustomProcessDiagramGenerator();
@ -238,12 +239,12 @@ public class ActivitiModelServiceImpl extends DefaultBaseService implements IAct
List<FlowNode> flowElementsOfType = bpmnModel.getProcesses().get(0).findFlowElementsOfType(FlowNode.class); List<FlowNode> flowElementsOfType = bpmnModel.getProcesses().get(0).findFlowElementsOfType(FlowNode.class);
List<FlowNode> activitiFlowNode = new ArrayList<>(); List<FlowNode> activitiFlowNode = new ArrayList<>();
// 加载高亮的节点 // 加载高亮的节点
for (FlowNode flowNode : flowElementsOfType) {
for (String highLightedActivitiId : highLightedActivitiIds) { for (String highLightedActivitiId : highLightedActivitiIds) {
String activitiId = highLightedActivitiId; String activitiId = highLightedActivitiId;
if (activitiId.startsWith("#")) { if (activitiId.startsWith("#")) {
activitiId = highLightedActivitiId.substring(1); activitiId = highLightedActivitiId.substring(1);
} }
for (FlowNode flowNode : flowElementsOfType) {
if (StringUtils.equals(flowNode.getId(), activitiId)) { if (StringUtils.equals(flowNode.getId(), activitiId)) {
activitiFlowNode.add(flowNode); activitiFlowNode.add(flowNode);
break; break;
@ -253,12 +254,10 @@ public class ActivitiModelServiceImpl extends DefaultBaseService implements IAct
// 找出高亮节点之间的连线 // 找出高亮节点之间的连线
for (int i = 0; i < activitiFlowNode.size() - 1; i++) { for (int i = 0; i < activitiFlowNode.size() - 1; i++) {
FlowNode flowNode = activitiFlowNode.get(i); FlowNode flowNode = activitiFlowNode.get(i);
List<SequenceFlow> incomingFlows = flowNode.getIncomingFlows();
List<SequenceFlow> outgoingFlows = flowNode.getOutgoingFlows(); List<SequenceFlow> outgoingFlows = flowNode.getOutgoingFlows();
for (int j = 0; j < activitiFlowNode.size(); j++) {
FlowNode nextFlowNode = activitiFlowNode.get(j); FlowNode nextFlowNode = activitiFlowNode.get(i + 1);
List<SequenceFlow> nextIncomingFlows = nextFlowNode.getIncomingFlows(); List<SequenceFlow> nextIncomingFlows = nextFlowNode.getIncomingFlows();
List<SequenceFlow> nextOutgoingFlows = nextFlowNode.getOutgoingFlows();
// 前节点的出与后节点的入相同则有关系 // 前节点的出与后节点的入相同则有关系
for (SequenceFlow outgoingFlow : outgoingFlows) { for (SequenceFlow outgoingFlow : outgoingFlows) {
for (SequenceFlow nextIncomingFlow : nextIncomingFlows) { for (SequenceFlow nextIncomingFlow : nextIncomingFlows) {
@ -267,15 +266,6 @@ public class ActivitiModelServiceImpl extends DefaultBaseService implements IAct
} }
} }
} }
// 前节点的入与后节点的出相同则有关系
for (SequenceFlow incomingFlow : incomingFlows) {
for (SequenceFlow nextOutgoingFlow : nextOutgoingFlows) {
if (StringUtils.equals(incomingFlow.getId(), nextOutgoingFlow.getId())) {
flowSet.add(incomingFlow.getId());
}
}
}
}
} }
return new ArrayList<>(flowSet); return new ArrayList<>(flowSet);
} }