|
@@ -52,6 +52,7 @@ import java.io.FileInputStream;
|
|
|
import java.io.IOException;
|
|
|
import java.io.InputStream;
|
|
|
import java.util.*;
|
|
|
+import java.util.concurrent.atomic.AtomicInteger;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
@@ -1483,8 +1484,10 @@ public class ActivitiServiceImpl implements ActivitiService {
|
|
|
Map<CustomFlowTypeEnum, CustomFlowDto> customFlowTypeEnumCustomFlowDtoMap = new HashMap<>();
|
|
|
FlowTaskLink flowTaskLink = new FlowTaskLink();
|
|
|
Map<String, Object> flowProcessVarMap = new HashMap<>();
|
|
|
- String exclusiveGatewayId = null;
|
|
|
Map<String, Map<String, List<String>>> gatewayMap = new HashMap<>();
|
|
|
+ AtomicInteger gatewayId = new AtomicInteger(1);
|
|
|
+ AtomicInteger sequenceId = new AtomicInteger(1);
|
|
|
+ CustomFlowDto customFlowDefaultDto = null;
|
|
|
for (int i = 0; i < customFlowLists.size(); i++) {
|
|
|
CustomFlowDto customFlowDto = customFlowLists.get(i);
|
|
|
FlowTaskNode node = new FlowTaskNode(customFlowDto);
|
|
@@ -1499,7 +1502,7 @@ public class ActivitiServiceImpl implements ActivitiService {
|
|
|
customFlowDto.setFlowTaskId(CustomFlowDynamicBuildEnum.START.getId());
|
|
|
process.addFlowElement(createStartEvent());
|
|
|
//默认在开始节点后新增一个审批节点
|
|
|
- multiWorkFlow.createDefaultUserTask(customFlowDto, flowTaskLink, DefaultInstanceConvertToMultiInstance.DEFAULT_USER_TASK);
|
|
|
+ customFlowDefaultDto = multiWorkFlow.createDefaultUserTask(customFlowDto, flowTaskLink, DefaultInstanceConvertToMultiInstance.DEFAULT_USER_TASK);
|
|
|
flowProcessVarMap.computeIfAbsent(SystemConstant.APPROVE_ID, v -> "");
|
|
|
process.addFlowElement(createUserTask(CustomFlowDynamicBuildEnum.USER_TASK.getId() + DefaultInstanceConvertToMultiInstance.DEFAULT_USER_TASK, Objects.nonNull(flowTaskLink.getLast().getTask().getContent()) && !Objects.equals(flowTaskLink.getLast().getTask().getContent(), "") ? flowTaskLink.getLast().getTask().getContent() : DefaultInstanceConvertToMultiInstance.DEFAULT_USER_TASK_NAME, DefaultInstanceConvertToMultiInstance.APPROVE_ID_EXP));
|
|
|
break;
|
|
@@ -1534,34 +1537,63 @@ public class ActivitiServiceImpl implements ActivitiService {
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
- //驳回属性
|
|
|
- switch (customFlowPropertyDto.getRejectType()) {
|
|
|
- case PREV://上一节点
|
|
|
- exclusiveGatewayId = DefaultInstanceConvertToMultiInstance.GATEWAY_NAME + multiWorkFlow.getAndIncrement(DefaultInstanceConvertToMultiInstance.GATEWAY_ID);
|
|
|
- CustomFlowDto customFlowExclusiveGatewayDto = new CustomFlowDto(exclusiveGatewayId, CustomFlowTypeEnum.EXCLUSIVE_GATE_WAY, CustomFlowTypeEnum.EXCLUSIVE_GATE_WAY.getTitle(), CustomFlowDynamicBuildEnum.EXCLUSIVE_GATE_WAY.getId() + exclusiveGatewayId);
|
|
|
- FlowTaskNode exclusiveGatewayNode = new FlowTaskNode(customFlowExclusiveGatewayDto);
|
|
|
- flowTaskLink.add(exclusiveGatewayNode);
|
|
|
- Map<String, List<String>> sequenceFlowMap = new HashMap<>();
|
|
|
- sequenceFlowMap.put(CustomFlowElementEnum.REJECT.getId(), Arrays.asList(node.getBefore().getTask().getFlowTaskId()));
|
|
|
- sequenceFlowMap.put(CustomFlowTypeEnum.EXCLUSIVE_GATE_WAY.name(), Arrays.asList(customFlowExclusiveGatewayDto.getFlowTaskId()));
|
|
|
- gatewayMap.put(customFlowDto.getFlowTaskId(), sequenceFlowMap);
|
|
|
- process.addFlowElement(createExclusiveGateway(customFlowExclusiveGatewayDto.getFlowTaskId(), CustomFlowTypeEnum.EXCLUSIVE_GATE_WAY.getTitle()));
|
|
|
- break;
|
|
|
- case START://发起人节点
|
|
|
- break;
|
|
|
- case PREV_ALL://该节点前全部节点
|
|
|
- break;
|
|
|
- default:
|
|
|
- break;
|
|
|
- }
|
|
|
- //驳回再提交属性
|
|
|
- switch (customFlowPropertyDto.getRejectResubmitType()) {
|
|
|
- case NORMAL://按正常流程提交
|
|
|
- break;
|
|
|
- case PREV_STEP://提交到驳回节点
|
|
|
- break;
|
|
|
- default:
|
|
|
- break;
|
|
|
+ if (Objects.nonNull(customFlowPropertyDto.getRejectType()) && !Objects.equals(customFlowPropertyDto.getRejectType(), "")) {
|
|
|
+ //驳回属性
|
|
|
+ switch (customFlowPropertyDto.getRejectType()) {
|
|
|
+ case PREV://上一节点
|
|
|
+ FlowTaskNode flowTaskNode = node.getBefore();
|
|
|
+ List<String> flowTaskIds = new ArrayList<>();
|
|
|
+ boolean isProcess = false;
|
|
|
+ while (!isProcess) {
|
|
|
+ if (flowTaskNode.getTask().getType() == CustomFlowTypeEnum.PROCESS) {
|
|
|
+ isProcess = true;
|
|
|
+ flowTaskIds.add(flowTaskNode.getTask().getFlowTaskId());
|
|
|
+ }
|
|
|
+ flowTaskNode = flowTaskNode.getBefore();
|
|
|
+ }
|
|
|
+ createCustomFlowExclusiveGateway(flowTaskLink,
|
|
|
+ gatewayMap,
|
|
|
+ process,
|
|
|
+ gatewayId,
|
|
|
+ customFlowDto.getFlowTaskId(),
|
|
|
+ flowTaskIds);
|
|
|
+ break;
|
|
|
+ case START://发起人节点
|
|
|
+ createCustomFlowExclusiveGateway(flowTaskLink,
|
|
|
+ gatewayMap,
|
|
|
+ process,
|
|
|
+ gatewayId,
|
|
|
+ customFlowDto.getFlowTaskId(),
|
|
|
+ Arrays.asList(customFlowDefaultDto.getFlowTaskId()));
|
|
|
+ break;
|
|
|
+ case PREV_ALL://该节点前全部节点
|
|
|
+ flowTaskNode = node.getBefore();
|
|
|
+ flowTaskIds = new ArrayList<>();
|
|
|
+ while (Objects.nonNull(flowTaskNode)) {
|
|
|
+ if (flowTaskNode.getTask().getType() == CustomFlowTypeEnum.PROCESS) {
|
|
|
+ flowTaskIds.add(flowTaskNode.getTask().getFlowTaskId());
|
|
|
+ }
|
|
|
+ flowTaskNode = flowTaskNode.getBefore();
|
|
|
+ }
|
|
|
+ createCustomFlowExclusiveGateway(flowTaskLink,
|
|
|
+ gatewayMap,
|
|
|
+ process,
|
|
|
+ gatewayId,
|
|
|
+ customFlowDto.getFlowTaskId(),
|
|
|
+ flowTaskIds);
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ //驳回再提交属性
|
|
|
+ switch (customFlowPropertyDto.getRejectResubmitType()) {
|
|
|
+ case NORMAL://按正常流程提交
|
|
|
+ break;
|
|
|
+ case PREV_STEP://提交到驳回节点
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
//抄送用户
|
|
|
if (Objects.nonNull(customFlowPropertyDto.getCopyForUsers())) {
|
|
@@ -1587,8 +1619,8 @@ public class ActivitiServiceImpl implements ActivitiService {
|
|
|
String normalSequenceId = null;
|
|
|
for (int i = 1; i < flowTaskLink.size(); i++) {
|
|
|
FlowTaskNode flowTaskNode = flowTaskLink.get(i);
|
|
|
- normalSequenceId = DefaultInstanceConvertToMultiInstance.SEQUENCE_NAME + multiWorkFlow.getAndIncrement(DefaultInstanceConvertToMultiInstance.SEQUENCE_ID);
|
|
|
- log.info("start:{},end:{}", flowTaskNode.getBefore().getTask().getFlowTaskId(), flowTaskNode.getTask().getFlowTaskId());
|
|
|
+ normalSequenceId = DefaultInstanceConvertToMultiInstance.SEQUENCE_NAME + sequenceId.getAndIncrement();
|
|
|
+ log.info("1 start:{},end:{}", flowTaskNode.getBefore().getTask().getFlowTaskId(), flowTaskNode.getTask().getFlowTaskId());
|
|
|
process.addFlowElement(createSequenceFlow(flowTaskNode.getBefore().getTask().getFlowTaskId(), flowTaskNode.getTask().getFlowTaskId(), normalSequenceId, normalSequenceId, null));
|
|
|
if (Objects.nonNull(gatewayMap.get(flowTaskNode.getTask().getFlowTaskId()))) {
|
|
|
Map<String, List<String>> map = gatewayMap.get(flowTaskNode.getTask().getFlowTaskId());
|
|
@@ -1599,8 +1631,8 @@ public class ActivitiServiceImpl implements ActivitiService {
|
|
|
String gatewaySequenceId = null;
|
|
|
if (Objects.equals(k, CustomFlowElementEnum.REJECT.getId())) {
|
|
|
for (String s : v) {
|
|
|
- gatewaySequenceId = DefaultInstanceConvertToMultiInstance.SEQUENCE_NAME + multiWorkFlow.getAndIncrement(DefaultInstanceConvertToMultiInstance.SEQUENCE_ID);
|
|
|
- log.info("start:{},end:{}", gatewayList.get(0), s);
|
|
|
+ gatewaySequenceId = DefaultInstanceConvertToMultiInstance.SEQUENCE_NAME + sequenceId.getAndIncrement();
|
|
|
+ log.info("2 start:{},end:{}", gatewayList.get(0), s);
|
|
|
process.addFlowElement(createSequenceFlow(gatewayList.get(0), s, gatewaySequenceId, gatewaySequenceId, null));
|
|
|
}
|
|
|
}
|
|
@@ -1620,6 +1652,35 @@ public class ActivitiServiceImpl implements ActivitiService {
|
|
|
return map;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 创建自定义流程排他网关dto
|
|
|
+ *
|
|
|
+ * @param flowTaskLink
|
|
|
+ * @param gatewayMap
|
|
|
+ * @param process
|
|
|
+ * @param gatewayId
|
|
|
+ * @param currentFlowTaskId
|
|
|
+ * @param flowTaskIds
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ protected CustomFlowDto createCustomFlowExclusiveGateway(FlowTaskLink flowTaskLink,
|
|
|
+ Map<String, Map<String, List<String>>> gatewayMap,
|
|
|
+ Process process,
|
|
|
+ AtomicInteger gatewayId,
|
|
|
+ String currentFlowTaskId,
|
|
|
+ List<String> flowTaskIds) {
|
|
|
+ int exclusiveGatewayId = gatewayId.getAndIncrement();
|
|
|
+ CustomFlowDto customFlowExclusiveGatewayDto = new CustomFlowDto(DefaultInstanceConvertToMultiInstance.GATEWAY_NAME + exclusiveGatewayId, CustomFlowTypeEnum.EXCLUSIVE_GATE_WAY, CustomFlowTypeEnum.EXCLUSIVE_GATE_WAY.getTitle(), CustomFlowDynamicBuildEnum.EXCLUSIVE_GATE_WAY.getId() + exclusiveGatewayId);
|
|
|
+ FlowTaskNode exclusiveGatewayNode = new FlowTaskNode(customFlowExclusiveGatewayDto);
|
|
|
+ flowTaskLink.add(exclusiveGatewayNode);
|
|
|
+ Map<String, List<String>> sequenceFlowMap = new HashMap<>();
|
|
|
+ sequenceFlowMap.put(CustomFlowElementEnum.REJECT.getId(), flowTaskIds);
|
|
|
+ sequenceFlowMap.put(CustomFlowTypeEnum.EXCLUSIVE_GATE_WAY.name(), Arrays.asList(customFlowExclusiveGatewayDto.getFlowTaskId()));
|
|
|
+ gatewayMap.put(currentFlowTaskId, sequenceFlowMap);
|
|
|
+ process.addFlowElement(createExclusiveGateway(customFlowExclusiveGatewayDto.getFlowTaskId(), CustomFlowTypeEnum.EXCLUSIVE_GATE_WAY.getTitle()));
|
|
|
+ return customFlowExclusiveGatewayDto;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 修改启动流程候选人
|
|
|
*
|