|
@@ -3,7 +3,6 @@ package com.qmth.distributed.print.business.service.impl;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
import com.google.gson.Gson;
|
|
|
-import com.google.gson.reflect.TypeToken;
|
|
|
import com.qmth.boot.api.exception.ApiException;
|
|
|
import com.qmth.distributed.print.business.activiti.custom.service.DefaultInstanceConvertToMultiInstance;
|
|
|
import com.qmth.distributed.print.business.activiti.custom.service.MultiWorkFlow;
|
|
@@ -34,7 +33,6 @@ import org.activiti.engine.RepositoryService;
|
|
|
import org.activiti.engine.RuntimeService;
|
|
|
import org.activiti.engine.TaskService;
|
|
|
import org.activiti.engine.impl.RepositoryServiceImpl;
|
|
|
-import org.activiti.engine.impl.bpmn.behavior.MultiInstanceActivityBehavior;
|
|
|
import org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity;
|
|
|
import org.activiti.engine.repository.Deployment;
|
|
|
import org.activiti.engine.repository.DeploymentBuilder;
|
|
@@ -45,6 +43,7 @@ import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
+import org.springframework.util.LinkedMultiValueMap;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
@@ -418,50 +417,51 @@ public class ActivitiServiceImpl implements ActivitiService {
|
|
|
Gson gson = new Gson();
|
|
|
String usertaskId = null;
|
|
|
Map<String, CustomFlowVarDto> agginessMap = (Map<String, CustomFlowVarDto>) flowProcessVarMap.get(SystemConstant.AGGINESS_MAP);
|
|
|
- if (approvePass == FlowApprovePassEnum.PASS) {
|
|
|
- Map<String, List<CustomFlowGatewayDto>> approvePassMap = (Map<String, List<CustomFlowGatewayDto>>) flowProcessVarMap.get(SystemConstant.APPROVE_PASS_MAP);
|
|
|
- if (Objects.nonNull(approvePassMap.get(userTask.getId())) && !Objects.equals(approvePassMap.get(userTask.getId()), "")) {
|
|
|
- List<CustomFlowGatewayDto> customFlowGatewayDtoList = gson.fromJson(gson.toJson(approvePassMap.get(userTask.getId())), new TypeToken<List<CustomFlowGatewayDto>>() {
|
|
|
- }.getType());
|
|
|
- boolean pass = false;
|
|
|
- for (CustomFlowGatewayDto c : customFlowGatewayDtoList) {
|
|
|
- if (Objects.equals(c.getFlowTaskId(), userTask.getId())) {
|
|
|
- usertaskId = c.getConditionExp().substring(c.getConditionExp().indexOf("'") + 1, c.getConditionExp().lastIndexOf("'"));
|
|
|
- pass = true;
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- if (!pass) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("该节点不能通过");
|
|
|
- }
|
|
|
- map.put(SystemConstant.APPROVE, usertaskId);
|
|
|
- if (currFlow.getBehavior() instanceof MultiInstanceActivityBehavior) {
|
|
|
- map.computeIfAbsent(CustomFlowElementEnum.REJECT.getId() + id, v -> 0);
|
|
|
- }
|
|
|
- }
|
|
|
- } else if (approvePass == FlowApprovePassEnum.REJECT) {
|
|
|
- if (Objects.isNull(map.get(SystemConstant.USER_TASK_ID)) || Objects.equals(map.get(SystemConstant.USER_TASK_ID), "")) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("流转节点不能为空");
|
|
|
- }
|
|
|
- usertaskId = (String) map.get(SystemConstant.USER_TASK_ID);
|
|
|
- Map<String, List<CustomFlowGatewayDto>> approveRejectMap = (Map<String, List<CustomFlowGatewayDto>>) flowProcessVarMap.get(SystemConstant.APPROVE_REJECT_MAP);
|
|
|
- List<CustomFlowGatewayDto> customFlowGatewayDtoList = gson.fromJson(gson.toJson(approveRejectMap.get(userTask.getId())), new TypeToken<List<CustomFlowGatewayDto>>() {
|
|
|
- }.getType());
|
|
|
- boolean reject = false;
|
|
|
- for (CustomFlowGatewayDto c : customFlowGatewayDtoList) {
|
|
|
- if (Objects.equals(c.getFlowTaskId(), usertaskId)) {
|
|
|
- reject = true;
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- if (!reject) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("该节点不能驳回");
|
|
|
- }
|
|
|
- map.put(SystemConstant.APPROVE, usertaskId);
|
|
|
- if (currFlow.getBehavior() instanceof MultiInstanceActivityBehavior) {
|
|
|
- map.computeIfAbsent(CustomFlowElementEnum.REJECT.getId() + id, v -> 1);
|
|
|
- }
|
|
|
- }
|
|
|
+// Map<String, CustomFlowGatewayDto> approveDataMap = (Map<String, CustomFlowGatewayDto>) flowProcessVarMap.get(SystemConstant.APPROVE_DATA_MAP);
|
|
|
+// if (approvePass == FlowApprovePassEnum.PASS) {
|
|
|
+// Map<String, List<CustomFlowGatewayDto>> approvePassMap = (Map<String, List<CustomFlowGatewayDto>>) flowProcessVarMap.get(SystemConstant.APPROVE_PASS_MAP);
|
|
|
+// if (Objects.nonNull(approvePassMap.get(userTask.getId())) && !Objects.equals(approvePassMap.get(userTask.getId()), "")) {
|
|
|
+// List<CustomFlowGatewayDto> customFlowGatewayDtoList = gson.fromJson(gson.toJson(approvePassMap.get(userTask.getId())), new TypeToken<List<CustomFlowGatewayDto>>() {
|
|
|
+// }.getType());
|
|
|
+//// boolean pass = false;
|
|
|
+//// for (CustomFlowGatewayDto c : customFlowGatewayDtoList) {
|
|
|
+//// if (Objects.equals(c.getFlowTaskId(), userTask.getId())) {
|
|
|
+//// usertaskId = c.getConditionExp().substring(c.getConditionExp().indexOf("'") + 1, c.getConditionExp().lastIndexOf("'"));
|
|
|
+//// pass = true;
|
|
|
+//// break;
|
|
|
+//// }
|
|
|
+//// }
|
|
|
+//// if (!pass) {
|
|
|
+//// throw ExceptionResultEnum.ERROR.exception("该节点不能通过");
|
|
|
+//// }
|
|
|
+// map.put(SystemConstant.APPROVE, usertaskId);
|
|
|
+// if (currFlow.getBehavior() instanceof MultiInstanceActivityBehavior) {
|
|
|
+// map.computeIfAbsent(CustomFlowElementEnum.REJECT.getId() + id, v -> 0);
|
|
|
+// }
|
|
|
+// }
|
|
|
+// } else if (approvePass == FlowApprovePassEnum.REJECT) {
|
|
|
+// if (Objects.isNull(map.get(SystemConstant.USER_TASK_ID)) || Objects.equals(map.get(SystemConstant.USER_TASK_ID), "")) {
|
|
|
+// throw ExceptionResultEnum.ERROR.exception("流转节点不能为空");
|
|
|
+// }
|
|
|
+// usertaskId = (String) map.get(SystemConstant.USER_TASK_ID);
|
|
|
+// Map<String, List<CustomFlowGatewayDto>> approveRejectMap = (Map<String, List<CustomFlowGatewayDto>>) flowProcessVarMap.get(SystemConstant.APPROVE_REJECT_MAP);
|
|
|
+// List<CustomFlowGatewayDto> customFlowGatewayDtoList = gson.fromJson(gson.toJson(approveRejectMap.get(userTask.getId())), new TypeToken<List<CustomFlowGatewayDto>>() {
|
|
|
+// }.getType());
|
|
|
+//// boolean reject = false;
|
|
|
+//// for (CustomFlowGatewayDto c : customFlowGatewayDtoList) {
|
|
|
+//// if (Objects.equals(c.getFlowTaskId(), usertaskId)) {
|
|
|
+//// reject = true;
|
|
|
+//// break;
|
|
|
+//// }
|
|
|
+//// }
|
|
|
+//// if (!reject) {
|
|
|
+//// throw ExceptionResultEnum.ERROR.exception("该节点不能驳回");
|
|
|
+//// }
|
|
|
+// map.put(SystemConstant.APPROVE, usertaskId);
|
|
|
+// if (currFlow.getBehavior() instanceof MultiInstanceActivityBehavior) {
|
|
|
+// map.computeIfAbsent(CustomFlowElementEnum.REJECT.getId() + id, v -> 1);
|
|
|
+// }
|
|
|
+// }
|
|
|
//获取流程变量
|
|
|
if (Objects.nonNull(agginessMap.get(usertaskId))) {
|
|
|
CustomFlowVarDto customFlowVarDto = gson.fromJson(gson.toJson(agginessMap.get(usertaskId)), CustomFlowVarDto.class);
|
|
@@ -477,6 +477,7 @@ public class ActivitiServiceImpl implements ActivitiService {
|
|
|
tfFlowApproveLog.updateInfo(sysUser.getId());
|
|
|
tfFlowApprove.setApproveId(sysUser.getId());
|
|
|
map.put(SystemConstant.APPROVE_TF_FLOW_LOG, tfFlowLog);
|
|
|
+ int i = 1 / 0;
|
|
|
//当前实例的执行到哪个节点
|
|
|
taskService.complete(String.valueOf(flowTaskId), map);
|
|
|
tfFlowApproveService.saveOrUpdate(tfFlowApprove);
|
|
@@ -709,7 +710,7 @@ public class ActivitiServiceImpl implements ActivitiService {
|
|
|
SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
|
|
|
if (Objects.nonNull(sysUser.getOrgId())) {
|
|
|
//获取院长审批人
|
|
|
- List<ApproveUserResult> sysUserPresidentList = sysUserService.findByPresidentApprove(Arrays.asList(sysUser.getOrgId()), null);
|
|
|
+ List<ApproveUserResult> sysUserPresidentList = sysUserService.findByPresidentApprove(new ArrayList(Arrays.asList(sysUser.getOrgId())), null);
|
|
|
flowTaskApprovePeopleResultList.add(new FlowTaskApprovePeopleResult(FlowApproveSetupEnum.SECOND_APPROVE.getSetup(), false, sysUserPresidentList));
|
|
|
}
|
|
|
if (Objects.nonNull(taskTaskAll) && taskTaskAll.size() > 3) {
|
|
@@ -947,7 +948,7 @@ public class ActivitiServiceImpl implements ActivitiService {
|
|
|
if (tfFlowApprove.getModel() == FlowModelEnum.SYSTEM) {
|
|
|
//获取院长审批人
|
|
|
if (Objects.nonNull(sysUser.getOrgId())) {
|
|
|
- sysUserPresidentList = sysUserService.findByPresidentApprove(Arrays.asList(sysUser.getOrgId()), realName);
|
|
|
+ sysUserPresidentList = sysUserService.findByPresidentApprove(new ArrayList(Arrays.asList(sysUser.getOrgId())), realName);
|
|
|
}
|
|
|
} else {
|
|
|
//获取院长审批人
|
|
@@ -1530,13 +1531,14 @@ public class ActivitiServiceImpl implements ActivitiService {
|
|
|
Map<CustomFlowTypeEnum, CustomFlowDto> customFlowTypeEnumCustomFlowDtoMap = new HashMap<>();
|
|
|
FlowTaskLink flowTaskLink = new FlowTaskLink();
|
|
|
Map<String, Object> flowProcessVarMap = new HashMap<>();
|
|
|
- Map<String, Map<String, List<CustomFlowGatewayDto>>> gatewayMap = new HashMap<>();
|
|
|
Map<String, CustomFlowVarDto> agginessMap = new HashMap<>();
|
|
|
- Map<String, List<CustomFlowGatewayDto>> approvePassMap = new HashMap<>();
|
|
|
- Map<String, List<CustomFlowGatewayDto>> approveRejectMap = new HashMap<>();
|
|
|
+ Map<String, CustomFlowGatewayDto> approveDataMap = new HashMap<>();
|
|
|
+ LinkedMultiValueMap<String, CustomFlowSequenceDto> approvePassMap = new LinkedMultiValueMap<>();
|
|
|
+ LinkedMultiValueMap<String, CustomFlowSequenceDto> approveRejectMap = new LinkedMultiValueMap<>();
|
|
|
flowProcessVarMap.computeIfAbsent(SystemConstant.AGGINESS_MAP, v -> agginessMap);
|
|
|
- flowProcessVarMap.computeIfAbsent(SystemConstant.APPROVE_PASS_MAP, v -> approvePassMap);
|
|
|
- flowProcessVarMap.computeIfAbsent(SystemConstant.APPROVE_REJECT_MAP, v -> approveRejectMap);
|
|
|
+// flowProcessVarMap.computeIfAbsent(SystemConstant.APPROVE_DATA_MAP, v -> approveDataMap);
|
|
|
+ flowProcessVarMap.computeIfAbsent(SystemConstant.AGGINESS_PASS_MAP, v -> approvePassMap);
|
|
|
+ flowProcessVarMap.computeIfAbsent(SystemConstant.AGGINESS_REJECT_MAP, v -> approveRejectMap);
|
|
|
AtomicInteger gatewayId = new AtomicInteger(1);
|
|
|
AtomicInteger sequenceId = new AtomicInteger(1);
|
|
|
CustomFlowDto customFlowDefaultDto = null;
|
|
@@ -1555,7 +1557,7 @@ public class ActivitiServiceImpl implements ActivitiService {
|
|
|
process.addFlowElement(createStartEvent());
|
|
|
//默认在开始节点后新增一个审批节点
|
|
|
customFlowDefaultDto = multiWorkFlow.createDefaultUserTask(customFlowDto, flowTaskLink, DefaultInstanceConvertToMultiInstance.DEFAULT_USER_TASK);
|
|
|
- agginessMap.computeIfAbsent(customFlowDefaultDto.getFlowTaskId(), v -> new CustomFlowVarDto(SystemConstant.APPROVE_ID, Arrays.asList("")));
|
|
|
+ agginessMap.computeIfAbsent(customFlowDefaultDto.getFlowTaskId(), v -> new CustomFlowVarDto(SystemConstant.APPROVE_ID, new ArrayList(Arrays.asList(""))));
|
|
|
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;
|
|
|
case PROCESS://过程节点
|
|
@@ -1584,67 +1586,95 @@ public class ActivitiServiceImpl implements ActivitiService {
|
|
|
switch (customFlowPropertyDto.getMultipleUserApproveType()) {
|
|
|
case ORDER://依次审批
|
|
|
case ALL://会签审批
|
|
|
- int finalI = i;
|
|
|
- agginessMap.computeIfAbsent(node.getTask().getFlowTaskId(), v -> new CustomFlowVarDto(DefaultInstanceConvertToMultiInstance.DEFAULT_ASSIGNEE_LIST + finalI, approveUserIds));
|
|
|
+ agginessMap.put(node.getTask().getFlowTaskId(), new CustomFlowVarDto(DefaultInstanceConvertToMultiInstance.DEFAULT_ASSIGNEE_LIST + i, approveUserIds));
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
if (Objects.nonNull(customFlowPropertyDto.getRejectType()) && !Objects.equals(customFlowPropertyDto.getRejectType(), "")) {
|
|
|
- List<CustomFlowGatewayDto> flowTaskIds = new ArrayList<>();
|
|
|
- approveRejectMap.put(node.getTask().getFlowTaskId(), flowTaskIds);
|
|
|
//驳回属性
|
|
|
switch (customFlowPropertyDto.getRejectType()) {
|
|
|
case PREV://上一节点
|
|
|
+ String flowTaskId = null;
|
|
|
FlowTaskNode flowTaskNode = node.getBefore();
|
|
|
boolean isProcess = false;
|
|
|
while (!isProcess) {
|
|
|
if (flowTaskNode.getTask().getType() == CustomFlowTypeEnum.PROCESS) {
|
|
|
isProcess = true;
|
|
|
- flowTaskIds.add(new CustomFlowGatewayDto(flowTaskNode.getTask().getFlowTaskId(), DefaultInstanceConvertToMultiInstance.EXP_PREFIX + SystemConstant.APPROVE + DefaultInstanceConvertToMultiInstance.EXP_EQUAL + "'" + flowTaskNode.getTask().getFlowTaskId() + "'" + DefaultInstanceConvertToMultiInstance.EXP_SUFFIX));
|
|
|
+ flowTaskId = flowTaskNode.getTask().getFlowTaskId();
|
|
|
}
|
|
|
flowTaskNode = flowTaskNode.getBefore();
|
|
|
}
|
|
|
- createCustomFlowExclusiveGateway(flowTaskLink,
|
|
|
- gatewayMap,
|
|
|
+ this.createCustomFlowExclusiveGatewayAfter(node,
|
|
|
+ flowTaskLink,
|
|
|
+ approveDataMap,
|
|
|
process,
|
|
|
gatewayId,
|
|
|
- customFlowDto.getFlowTaskId(),
|
|
|
- flowTaskIds);
|
|
|
+ flowTaskId,
|
|
|
+ false);
|
|
|
break;
|
|
|
case START://发起人节点
|
|
|
- flowTaskIds.add(new CustomFlowGatewayDto(customFlowDefaultDto.getFlowTaskId(), DefaultInstanceConvertToMultiInstance.EXP_PREFIX + SystemConstant.APPROVE + DefaultInstanceConvertToMultiInstance.EXP_EQUAL + "'" + customFlowDefaultDto.getFlowTaskId() + "'" + DefaultInstanceConvertToMultiInstance.EXP_SUFFIX));
|
|
|
- createCustomFlowExclusiveGateway(flowTaskLink,
|
|
|
- gatewayMap,
|
|
|
+ this.createCustomFlowExclusiveGatewayAfter(node,
|
|
|
+ flowTaskLink,
|
|
|
+ approveDataMap,
|
|
|
process,
|
|
|
gatewayId,
|
|
|
- customFlowDto.getFlowTaskId(),
|
|
|
- flowTaskIds);
|
|
|
+ customFlowDefaultDto.getFlowTaskId(),
|
|
|
+ false);
|
|
|
break;
|
|
|
case PREV_ALL://该节点前全部节点
|
|
|
flowTaskNode = node.getBefore();
|
|
|
while (Objects.nonNull(flowTaskNode)) {
|
|
|
if (flowTaskNode.getTask().getType() == CustomFlowTypeEnum.PROCESS) {
|
|
|
- flowTaskIds.add(new CustomFlowGatewayDto(flowTaskNode.getTask().getFlowTaskId(), DefaultInstanceConvertToMultiInstance.EXP_PREFIX + SystemConstant.APPROVE + DefaultInstanceConvertToMultiInstance.EXP_EQUAL + "'" + flowTaskNode.getTask().getFlowTaskId() + "'" + DefaultInstanceConvertToMultiInstance.EXP_SUFFIX));
|
|
|
+ flowTaskId = flowTaskNode.getTask().getFlowTaskId();
|
|
|
+ this.createCustomFlowExclusiveGatewayAfter(node,
|
|
|
+ flowTaskLink,
|
|
|
+ approveDataMap,
|
|
|
+ process,
|
|
|
+ gatewayId,
|
|
|
+ flowTaskId,
|
|
|
+ false);
|
|
|
}
|
|
|
flowTaskNode = flowTaskNode.getBefore();
|
|
|
}
|
|
|
- createCustomFlowExclusiveGateway(flowTaskLink,
|
|
|
- gatewayMap,
|
|
|
- process,
|
|
|
- gatewayId,
|
|
|
- customFlowDto.getFlowTaskId(),
|
|
|
- flowTaskIds);
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
-
|
|
|
//驳回再提交属性
|
|
|
switch (customFlowPropertyDto.getRejectResubmitType()) {
|
|
|
- case NORMAL://按正常流程提交
|
|
|
- break;
|
|
|
case PREV_STEP://提交到驳回节点
|
|
|
+ CustomFlowGatewayDto customFlowGatewayDto = approveDataMap.get(node.getTask().getFlowTaskId());
|
|
|
+ Map<String, List<CustomFlowSequenceDto>> flowTaskIds = customFlowGatewayDto.getFlowTaskIds();
|
|
|
+ List<CustomFlowSequenceDto> customFlowSequenceDtoList = flowTaskIds.get(customFlowGatewayDto.getAfterExclusiveGatewayId());
|
|
|
+ for (int y = 1; y < flowTaskLink.size(); y++) {
|
|
|
+ FlowTaskNode nodeTemp = flowTaskLink.get(y);
|
|
|
+ for (CustomFlowSequenceDto c : customFlowSequenceDtoList) {
|
|
|
+ if (Objects.equals(nodeTemp.getTask().getFlowTaskId(), c.getAfterFlowTaskId())) {
|
|
|
+ if (nodeTemp.getNext().getTask().getType() == CustomFlowTypeEnum.EXCLUSIVE_GATE_WAY) {
|
|
|
+ this.createCustomFlowExclusiveGatewayBefore(node,
|
|
|
+ flowTaskLink,
|
|
|
+ y + 1,
|
|
|
+ approveDataMap,
|
|
|
+ process,
|
|
|
+ gatewayId,
|
|
|
+ node.getTask().getFlowTaskId(),
|
|
|
+ true,
|
|
|
+ nodeTemp.getNext());
|
|
|
+ } else {
|
|
|
+ this.createCustomFlowExclusiveGatewayBefore(node,
|
|
|
+ flowTaskLink,
|
|
|
+ y + 1,
|
|
|
+ approveDataMap,
|
|
|
+ process,
|
|
|
+ gatewayId,
|
|
|
+ node.getTask().getFlowTaskId(),
|
|
|
+ true,
|
|
|
+ null);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
@@ -1671,42 +1701,58 @@ public class ActivitiServiceImpl implements ActivitiService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- String normalSequenceId = null;
|
|
|
+ Map<String, String> flowExecMap = new HashMap<>();
|
|
|
for (int i = 1; i < flowTaskLink.size(); i++) {
|
|
|
FlowTaskNode flowTaskNode = flowTaskLink.get(i);
|
|
|
- normalSequenceId = DefaultInstanceConvertToMultiInstance.SEQUENCE_NAME + sequenceId.getAndIncrement();
|
|
|
log.info("1 start:{},end:{}", flowTaskNode.getBefore().getTask().getFlowTaskId(), flowTaskNode.getTask().getFlowTaskId());
|
|
|
+ String normalSequenceId = DefaultInstanceConvertToMultiInstance.SEQUENCE_NAME + sequenceId.getAndIncrement();
|
|
|
if (flowTaskNode.getBefore().getTask().getType() == CustomFlowTypeEnum.EXCLUSIVE_GATE_WAY) {
|
|
|
- FlowTaskNode flowTaskNodeTemp = flowTaskNode.getBefore();
|
|
|
- boolean isProcess = false;
|
|
|
- CustomFlowGatewayDto customFlowGatewayDto = null;
|
|
|
- while (!isProcess) {
|
|
|
- if (flowTaskNodeTemp.getTask().getType() == CustomFlowTypeEnum.PROCESS) {
|
|
|
- isProcess = true;
|
|
|
- customFlowGatewayDto = new CustomFlowGatewayDto(flowTaskNodeTemp.getTask().getFlowTaskId(), DefaultInstanceConvertToMultiInstance.EXP_PREFIX + SystemConstant.APPROVE + DefaultInstanceConvertToMultiInstance.EXP_EQUAL + "'" + flowTaskNode.getTask().getFlowTaskId() + "'" + DefaultInstanceConvertToMultiInstance.EXP_SUFFIX);
|
|
|
+ SequenceFlow sequenceFlow = createSequenceFlow(flowTaskNode.getBefore().getTask().getFlowTaskId(), flowTaskNode.getTask().getFlowTaskId(), normalSequenceId, FlowApprovePassEnum.PASS.getTitle(), DefaultInstanceConvertToMultiInstance.EXP_PREFIX + SystemConstant.APPROVE + DefaultInstanceConvertToMultiInstance.EXP_EQUAL + "'" + flowTaskNode.getTask().getFlowTaskId() + "'" + DefaultInstanceConvertToMultiInstance.EXP_SUFFIX, flowExecMap);
|
|
|
+ if (Objects.nonNull(sequenceFlow)) {
|
|
|
+ if (flowTaskNode.getBefore().getTask().getType() == CustomFlowTypeEnum.EXCLUSIVE_GATE_WAY) {
|
|
|
+ approvePassMap.add(flowTaskNode.getBefore().getBefore().getTask().getFlowTaskId(), new CustomFlowSequenceDto(flowTaskNode.getTask().getFlowTaskId(), sequenceFlow.getConditionExpression(), true));
|
|
|
+ } else {
|
|
|
+ approvePassMap.add(flowTaskNode.getBefore().getTask().getFlowTaskId(), new CustomFlowSequenceDto(flowTaskNode.getTask().getFlowTaskId(), sequenceFlow.getConditionExpression(), true));
|
|
|
}
|
|
|
- flowTaskNodeTemp = flowTaskNodeTemp.getBefore();
|
|
|
+ process.addFlowElement(sequenceFlow);
|
|
|
}
|
|
|
- approvePassMap.put(customFlowGatewayDto.getFlowTaskId(), Arrays.asList(customFlowGatewayDto));
|
|
|
- process.addFlowElement(createSequenceFlow(flowTaskNode.getBefore().getTask().getFlowTaskId(), flowTaskNode.getTask().getFlowTaskId(), normalSequenceId, FlowApprovePassEnum.PASS.getTitle(), customFlowGatewayDto.getConditionExp()));
|
|
|
} else {
|
|
|
- process.addFlowElement(createSequenceFlow(flowTaskNode.getBefore().getTask().getFlowTaskId(), flowTaskNode.getTask().getFlowTaskId(), normalSequenceId, FlowApprovePassEnum.PASS.getTitle(), null));
|
|
|
+ SequenceFlow sequenceFlow = createSequenceFlow(flowTaskNode.getBefore().getTask().getFlowTaskId(), flowTaskNode.getTask().getFlowTaskId(), normalSequenceId, FlowApprovePassEnum.PASS.getTitle(), null, flowExecMap);
|
|
|
+ if (Objects.nonNull(sequenceFlow)) {
|
|
|
+ if (flowTaskNode.getBefore().getTask().getType() == CustomFlowTypeEnum.EXCLUSIVE_GATE_WAY) {
|
|
|
+ approvePassMap.add(flowTaskNode.getBefore().getBefore().getTask().getFlowTaskId(), new CustomFlowSequenceDto(flowTaskNode.getTask().getFlowTaskId(), true));
|
|
|
+ } else {
|
|
|
+ approvePassMap.add(flowTaskNode.getBefore().getTask().getFlowTaskId(), new CustomFlowSequenceDto(flowTaskNode.getTask().getFlowTaskId(), true));
|
|
|
+ }
|
|
|
+ process.addFlowElement(sequenceFlow);
|
|
|
+ }
|
|
|
}
|
|
|
- if (Objects.nonNull(gatewayMap.get(flowTaskNode.getTask().getFlowTaskId()))) {
|
|
|
- Map<String, List<CustomFlowGatewayDto>> map = gatewayMap.get(flowTaskNode.getTask().getFlowTaskId());
|
|
|
- List<CustomFlowGatewayDto> gatewayList = map.get(CustomFlowTypeEnum.EXCLUSIVE_GATE_WAY.name());
|
|
|
- map.remove(CustomFlowTypeEnum.EXCLUSIVE_GATE_WAY.name());
|
|
|
- if (Objects.nonNull(map) && map.size() > 0) {
|
|
|
- map.forEach((k, v) -> {
|
|
|
- String gatewaySequenceId = null;
|
|
|
- if (Objects.equals(k, CustomFlowElementEnum.REJECT.getId())) {
|
|
|
- for (CustomFlowGatewayDto c : v) {
|
|
|
- gatewaySequenceId = DefaultInstanceConvertToMultiInstance.SEQUENCE_NAME + sequenceId.getAndIncrement();
|
|
|
- log.info("2 start:{},end:{}", gatewayList.get(0).getFlowTaskId(), c.getFlowTaskId());
|
|
|
- process.addFlowElement(createSequenceFlow(gatewayList.get(0).getFlowTaskId(), c.getFlowTaskId(), gatewaySequenceId, FlowApprovePassEnum.REJECT.getTitle(), c.getConditionExp()));
|
|
|
- }
|
|
|
+ List<CustomFlowSequenceDto> beforeFlowTaskIdsList = flowTaskNode.getTask().getBeforeFlowTaskIds();
|
|
|
+ if (Objects.nonNull(beforeFlowTaskIdsList)) {
|
|
|
+ for (CustomFlowSequenceDto c : beforeFlowTaskIdsList) {
|
|
|
+ String gatewaySequenceId = DefaultInstanceConvertToMultiInstance.SEQUENCE_NAME + sequenceId.getAndIncrement();
|
|
|
+ if (Objects.nonNull(c.getBeforeFlowTaskId())) {
|
|
|
+ log.info("2 start:{},end:{}", flowTaskNode.getTask().getFlowTaskId(), c.getBeforeFlowTaskId());
|
|
|
+ SequenceFlow sequenceFlow = createSequenceFlow(flowTaskNode.getTask().getFlowTaskId(), c.getBeforeFlowTaskId(), gatewaySequenceId, FlowApprovePassEnum.PASS.getTitle(), c.getConditionExp(), flowExecMap);
|
|
|
+ if (Objects.nonNull(sequenceFlow)) {
|
|
|
+ approvePassMap.add(flowTaskNode.getBefore().getTask().getFlowTaskId(), c);
|
|
|
+ process.addFlowElement(sequenceFlow);
|
|
|
}
|
|
|
- });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<CustomFlowSequenceDto> afterFlowTaskIdsList = flowTaskNode.getTask().getAfterFlowTaskIds();
|
|
|
+ if (Objects.nonNull(afterFlowTaskIdsList)) {
|
|
|
+ for (CustomFlowSequenceDto c : afterFlowTaskIdsList) {
|
|
|
+ String gatewaySequenceId = DefaultInstanceConvertToMultiInstance.SEQUENCE_NAME + sequenceId.getAndIncrement();
|
|
|
+ if (Objects.nonNull(c.getAfterFlowTaskId())) {
|
|
|
+ log.info("3 start:{},end:{}", flowTaskNode.getTask().getFlowTaskId(), c.getAfterFlowTaskId());
|
|
|
+ SequenceFlow sequenceFlow = createSequenceFlow(flowTaskNode.getTask().getFlowTaskId(), c.getAfterFlowTaskId(), gatewaySequenceId, FlowApprovePassEnum.REJECT.getTitle(), c.getConditionExp(), flowExecMap);
|
|
|
+ if (Objects.nonNull(sequenceFlow)) {
|
|
|
+ approveRejectMap.add(flowTaskNode.getBefore().getTask().getFlowTaskId(), c);
|
|
|
+ process.addFlowElement(sequenceFlow);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -1722,33 +1768,128 @@ public class ActivitiServiceImpl implements ActivitiService {
|
|
|
return map;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 创建当前节点驳回网关
|
|
|
+ *
|
|
|
+ * @param node
|
|
|
+ * @param flowTaskLink
|
|
|
+ * @param approveVarMap
|
|
|
+ * @param process
|
|
|
+ * @param gatewayId
|
|
|
+ * @param flowTaskId
|
|
|
+ * @param pass
|
|
|
+ */
|
|
|
+ protected void createCustomFlowExclusiveGatewayAfter(FlowTaskNode node,
|
|
|
+ FlowTaskLink flowTaskLink,
|
|
|
+ Map<String, CustomFlowGatewayDto> approveVarMap,
|
|
|
+ Process process,
|
|
|
+ AtomicInteger gatewayId,
|
|
|
+ String flowTaskId,
|
|
|
+ boolean pass) {
|
|
|
+ CustomFlowGatewayDto customFlowGatewayDto = null;
|
|
|
+ FlowTaskNode customFlowExclusiveGatewayTaskNode = null;
|
|
|
+ List<CustomFlowSequenceDto> customFlowSequenceDtoList = null;
|
|
|
+ if (approveVarMap.containsKey(node.getTask().getFlowTaskId())) {
|
|
|
+ customFlowGatewayDto = approveVarMap.get(node.getTask().getFlowTaskId());
|
|
|
+ } else {
|
|
|
+ customFlowGatewayDto = new CustomFlowGatewayDto();
|
|
|
+ }
|
|
|
+ //是否存在驳回网关
|
|
|
+ if (Objects.isNull(customFlowGatewayDto.getAfterExclusiveGatewayId())) {
|
|
|
+ customFlowExclusiveGatewayTaskNode = createCustomFlowExclusiveGateway(flowTaskLink, -1, process, gatewayId);
|
|
|
+ customFlowGatewayDto.setAfterExclusiveGatewayId(customFlowExclusiveGatewayTaskNode.getTask().getFlowTaskId());
|
|
|
+ } else {
|
|
|
+ customFlowExclusiveGatewayTaskNode = node.getNext();
|
|
|
+ }
|
|
|
+ CustomFlowSequenceDto customFlowSequenceRejectDto = new CustomFlowSequenceDto(flowTaskId, DefaultInstanceConvertToMultiInstance.EXP_PREFIX + SystemConstant.APPROVE + DefaultInstanceConvertToMultiInstance.EXP_EQUAL + "'" + flowTaskId + "'" + DefaultInstanceConvertToMultiInstance.EXP_SUFFIX, pass);
|
|
|
+ Map<String, List<CustomFlowSequenceDto>> flowTaskIds = customFlowGatewayDto.getFlowTaskIds();
|
|
|
+ flowTaskIds = Objects.isNull(flowTaskIds) ? new HashMap<>() : flowTaskIds;
|
|
|
+ if (flowTaskIds.containsKey(customFlowGatewayDto.getAfterExclusiveGatewayId())) {
|
|
|
+ customFlowSequenceDtoList = flowTaskIds.get(customFlowGatewayDto.getAfterExclusiveGatewayId());
|
|
|
+ } else {
|
|
|
+ customFlowSequenceDtoList = new ArrayList<>();
|
|
|
+ }
|
|
|
+ customFlowSequenceDtoList.add(customFlowSequenceRejectDto);
|
|
|
+ flowTaskIds.put(customFlowGatewayDto.getAfterExclusiveGatewayId(), customFlowSequenceDtoList);
|
|
|
+ customFlowGatewayDto.setFlowTaskIds(flowTaskIds);
|
|
|
+ approveVarMap.put(node.getTask().getFlowTaskId(), customFlowGatewayDto);
|
|
|
+ customFlowExclusiveGatewayTaskNode.getTask().setAfterFlowTaskIds(flowTaskIds.get(customFlowExclusiveGatewayTaskNode.getTask().getFlowTaskId()));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 创建当前节点审批网关
|
|
|
+ *
|
|
|
+ * @param node
|
|
|
+ * @param flowTaskLink
|
|
|
+ * @param index
|
|
|
+ * @param approveDataMap
|
|
|
+ * @param process
|
|
|
+ * @param gatewayId
|
|
|
+ * @param flowTaskId
|
|
|
+ * @param pass
|
|
|
+ * @param exclusiveGatewayTaskNode
|
|
|
+ */
|
|
|
+ protected void createCustomFlowExclusiveGatewayBefore(FlowTaskNode node,
|
|
|
+ FlowTaskLink flowTaskLink,
|
|
|
+ int index,
|
|
|
+ Map<String, CustomFlowGatewayDto> approveDataMap,
|
|
|
+ Process process,
|
|
|
+ AtomicInteger gatewayId,
|
|
|
+ String flowTaskId,
|
|
|
+ boolean pass,
|
|
|
+ FlowTaskNode exclusiveGatewayTaskNode) {
|
|
|
+ CustomFlowGatewayDto customFlowGatewayDto = null;
|
|
|
+ FlowTaskNode customFlowExclusiveGatewayTaskNode = exclusiveGatewayTaskNode;
|
|
|
+ List<CustomFlowSequenceDto> customFlowSequenceDtoList = null;
|
|
|
+ if (approveDataMap.containsKey(node.getTask().getFlowTaskId())) {
|
|
|
+ customFlowGatewayDto = approveDataMap.get(node.getTask().getFlowTaskId());
|
|
|
+ } else {
|
|
|
+ customFlowGatewayDto = new CustomFlowGatewayDto();
|
|
|
+ }
|
|
|
+ //是否存在审批网关
|
|
|
+ if (Objects.isNull(customFlowExclusiveGatewayTaskNode) && Objects.isNull(customFlowGatewayDto.getBeforeExclusiveGatewayId())) {
|
|
|
+ customFlowExclusiveGatewayTaskNode = createCustomFlowExclusiveGateway(flowTaskLink, index, process, gatewayId);
|
|
|
+ }
|
|
|
+ customFlowGatewayDto.setBeforeExclusiveGatewayId(customFlowExclusiveGatewayTaskNode.getTask().getFlowTaskId());
|
|
|
+
|
|
|
+ CustomFlowSequenceDto customFlowSequenceRejectDto = new CustomFlowSequenceDto(flowTaskId, DefaultInstanceConvertToMultiInstance.EXP_PREFIX + SystemConstant.APPROVE + DefaultInstanceConvertToMultiInstance.EXP_EQUAL + "'" + flowTaskId + "'" + DefaultInstanceConvertToMultiInstance.EXP_SUFFIX, pass);
|
|
|
+ Map<String, List<CustomFlowSequenceDto>> flowTaskIds = customFlowGatewayDto.getFlowTaskIds();
|
|
|
+ flowTaskIds = Objects.isNull(flowTaskIds) ? new HashMap<>() : flowTaskIds;
|
|
|
+ if (flowTaskIds.containsKey(customFlowGatewayDto.getBeforeExclusiveGatewayId())) {
|
|
|
+ customFlowSequenceDtoList = flowTaskIds.get(customFlowGatewayDto.getBeforeExclusiveGatewayId());
|
|
|
+ } else {
|
|
|
+ customFlowSequenceDtoList = new ArrayList<>();
|
|
|
+ }
|
|
|
+ customFlowSequenceDtoList.add(customFlowSequenceRejectDto);
|
|
|
+ flowTaskIds.put(customFlowGatewayDto.getBeforeExclusiveGatewayId(), customFlowSequenceDtoList);
|
|
|
+ customFlowGatewayDto.setFlowTaskIds(flowTaskIds);
|
|
|
+ approveDataMap.put(node.getTask().getFlowTaskId(), customFlowGatewayDto);
|
|
|
+ customFlowExclusiveGatewayTaskNode.getTask().setBeforeFlowTaskIds(flowTaskIds.get(customFlowExclusiveGatewayTaskNode.getTask().getFlowTaskId()));
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 创建自定义流程排他网关dto
|
|
|
*
|
|
|
* @param flowTaskLink
|
|
|
- * @param gatewayMap
|
|
|
+ * @param index
|
|
|
* @param process
|
|
|
* @param gatewayId
|
|
|
- * @param currentFlowTaskId
|
|
|
- * @param flowTaskIds
|
|
|
* @return
|
|
|
*/
|
|
|
- protected CustomFlowDto createCustomFlowExclusiveGateway(FlowTaskLink flowTaskLink,
|
|
|
- Map<String, Map<String, List<CustomFlowGatewayDto>>> gatewayMap,
|
|
|
- Process process,
|
|
|
- AtomicInteger gatewayId,
|
|
|
- String currentFlowTaskId,
|
|
|
- List<CustomFlowGatewayDto> flowTaskIds) {
|
|
|
+ protected FlowTaskNode createCustomFlowExclusiveGateway(FlowTaskLink flowTaskLink,
|
|
|
+ int index,
|
|
|
+ Process process,
|
|
|
+ AtomicInteger gatewayId) {
|
|
|
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<CustomFlowGatewayDto>> sequenceFlowMap = new HashMap<>();
|
|
|
- sequenceFlowMap.put(CustomFlowElementEnum.REJECT.getId(), flowTaskIds);
|
|
|
- sequenceFlowMap.put(CustomFlowTypeEnum.EXCLUSIVE_GATE_WAY.name(), Arrays.asList(new CustomFlowGatewayDto(customFlowExclusiveGatewayDto.getFlowTaskId())));
|
|
|
- gatewayMap.put(currentFlowTaskId, sequenceFlowMap);
|
|
|
+ if (index <= -1) {
|
|
|
+ flowTaskLink.add(exclusiveGatewayNode);
|
|
|
+ } else {
|
|
|
+ flowTaskLink.add(index, exclusiveGatewayNode);
|
|
|
+ }
|
|
|
process.addFlowElement(createExclusiveGateway(customFlowExclusiveGatewayDto.getFlowTaskId(), CustomFlowTypeEnum.EXCLUSIVE_GATE_WAY.getTitle()));
|
|
|
- return customFlowExclusiveGatewayDto;
|
|
|
+ return exclusiveGatewayNode;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -1767,7 +1908,7 @@ public class ActivitiServiceImpl implements ActivitiService {
|
|
|
taskService.saveTask(task);
|
|
|
Map<String, Object> map = JacksonUtil.readJson(tfCustomFlow.getFlowProcessVar(), Map.class);
|
|
|
Map<String, CustomFlowVarDto> agginessMap = (Map<String, CustomFlowVarDto>) flowProcessVarMap.get(SystemConstant.AGGINESS_MAP);
|
|
|
- agginessMap.put(CustomFlowDynamicBuildEnum.USER_TASK.getId() + DefaultInstanceConvertToMultiInstance.DEFAULT_USER_TASK, new CustomFlowVarDto(SystemConstant.APPROVE_ID, Arrays.asList(String.valueOf(approveId))));
|
|
|
+ agginessMap.put(CustomFlowDynamicBuildEnum.USER_TASK.getId() + DefaultInstanceConvertToMultiInstance.DEFAULT_USER_TASK, new CustomFlowVarDto(SystemConstant.APPROVE_ID, new ArrayList(Arrays.asList(String.valueOf(approveId)))));
|
|
|
flowProcessVarMap.put(SystemConstant.AGGINESS_MAP, agginessMap);
|
|
|
map.put(SystemConstant.FLOW_PROCESS_VAR_MAP, flowProcessVarMap);
|
|
|
tfCustomFlow.setFlowProcessVar(JacksonUtil.parseJson(map));
|
|
@@ -1834,7 +1975,8 @@ public class ActivitiServiceImpl implements ActivitiService {
|
|
|
* @param customFlowMultipleUserApproveTypeEnum
|
|
|
* @return
|
|
|
*/
|
|
|
- protected UserTask createUserTask(String id, String name, List<String> assignees, CustomFlowMultipleUserApproveTypeEnum customFlowMultipleUserApproveTypeEnum) {
|
|
|
+ protected UserTask createUserTask(String id, String
|
|
|
+ name, List<String> assignees, CustomFlowMultipleUserApproveTypeEnum customFlowMultipleUserApproveTypeEnum) {
|
|
|
UserTask userTask = new UserTask();
|
|
|
userTask.setName(name);
|
|
|
userTask.setId(id);
|
|
@@ -1884,17 +2026,23 @@ public class ActivitiServiceImpl implements ActivitiService {
|
|
|
* @param id
|
|
|
* @param name 连线名称(可不填)
|
|
|
* @param conditionExpression 网关每一种线路走向的条件表达式
|
|
|
+ * @param map
|
|
|
* @return
|
|
|
*/
|
|
|
- protected SequenceFlow createSequenceFlow(String from, String to, String id, String name, String conditionExpression) {
|
|
|
- SequenceFlow flow = new SequenceFlow();
|
|
|
- flow.setSourceRef(from);
|
|
|
- flow.setTargetRef(to);
|
|
|
- flow.setId(id);
|
|
|
- flow.setName(name);
|
|
|
- if (Objects.nonNull(conditionExpression)) {
|
|
|
- flow.setConditionExpression(conditionExpression);
|
|
|
+ protected SequenceFlow createSequenceFlow(String from, String to, String id, String name, String conditionExpression, Map<String, String> map) {
|
|
|
+ if (!map.containsKey(from + "_" + to)) {
|
|
|
+ SequenceFlow flow = new SequenceFlow();
|
|
|
+ flow.setSourceRef(from);
|
|
|
+ flow.setTargetRef(to);
|
|
|
+ flow.setId(id);
|
|
|
+ flow.setName(name);
|
|
|
+ if (Objects.nonNull(conditionExpression)) {
|
|
|
+ flow.setConditionExpression(conditionExpression);
|
|
|
+ }
|
|
|
+ map.put(from + "_" + to, from + "_" + to);
|
|
|
+ return flow;
|
|
|
+ } else {
|
|
|
+ return null;
|
|
|
}
|
|
|
- return flow;
|
|
|
}
|
|
|
}
|