diff --git a/laws-modules/src/main/java/com/jero/modules/activiti/controller/ModelerController.java b/laws-modules/src/main/java/com/jero/modules/activiti/controller/ModelerController.java index 2ba48d76..ff406f33 100644 --- a/laws-modules/src/main/java/com/jero/modules/activiti/controller/ModelerController.java +++ b/laws-modules/src/main/java/com/jero/modules/activiti/controller/ModelerController.java @@ -30,6 +30,7 @@ import org.activiti.editor.language.json.converter.BpmnJsonConverter; import org.activiti.engine.ProcessEngine; import org.activiti.engine.ProcessEngines; import org.activiti.engine.RepositoryService; +import org.activiti.engine.RuntimeService; import org.activiti.engine.delegate.BaseExecutionListener; import org.activiti.engine.delegate.TaskListener; import org.activiti.engine.repository.*; @@ -446,25 +447,28 @@ public class ModelerController { // 获取流程引擎 ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine(); - // 获取RuntimeService并删除所有流程实例 - List instances = processEngine.getRuntimeService() - .createProcessInstanceQuery() - .list(); - for (ProcessInstance instance : instances) { - processEngine.getRuntimeService() - .deleteProcessInstance(instance.getId(), "Cleanup all instances"); + // 获取RuntimeService并批量删除所有流程实例 + RuntimeService runtimeService = processEngine.getRuntimeService(); + List instanceIds = runtimeService.createProcessInstanceQuery().list() + .stream() + .map(ProcessInstance::getId) + .collect(Collectors.toList()); + for (String id : instanceIds) { + runtimeService.deleteProcessInstance(id, "Cleanup all instances"); } - // 获取RepositoryService并删除所有流程 - List definitions = processEngine.getRepositoryService() - .createProcessDefinitionQuery() - .list(); - for (ProcessDefinition definition : definitions) { - processEngine.getRepositoryService() - .deleteDeployment(definition.getDeploymentId(), true); + // 获取RepositoryService并批量删除所有流程 + RepositoryService repositoryService = processEngine.getRepositoryService(); + List deploymentIds = repositoryService.createProcessDefinitionQuery().list() + .stream() + .map(ProcessDefinition::getDeploymentId) + .collect(Collectors.toList()); + for (String id : deploymentIds) { + repositoryService.deleteDeployment(id, true); } } + } diff --git a/laws-modules/src/main/java/com/jero/modules/activiti/process/esInitChange/entity/vo/InitChangeDataVO.java b/laws-modules/src/main/java/com/jero/modules/activiti/process/esInitChange/entity/vo/InitChangeDataVO.java index 4de7b4e9..200ee078 100644 --- a/laws-modules/src/main/java/com/jero/modules/activiti/process/esInitChange/entity/vo/InitChangeDataVO.java +++ b/laws-modules/src/main/java/com/jero/modules/activiti/process/esInitChange/entity/vo/InitChangeDataVO.java @@ -3,7 +3,6 @@ package com.jero.modules.activiti.process.esInitChange.entity.vo; import com.jero.modules.activiti.process.common.entity.CommonVO; import com.jero.modules.activiti.process.esInitChange.entity.ProcessEsInitChange; import lombok.Data; -import lombok.EqualsAndHashCode; import java.util.List; @@ -18,5 +17,5 @@ public class InitChangeDataVO { List dataList; - FlowUserInfoVO flowUserInfoVO; + InitChangeFlowUserVO initChangeFlowUserVO; } diff --git a/laws-modules/src/main/java/com/jero/modules/activiti/process/esInitChange/entity/vo/FlowUserInfoVO.java b/laws-modules/src/main/java/com/jero/modules/activiti/process/esInitChange/entity/vo/InitChangeFlowUserVO.java similarity index 97% rename from laws-modules/src/main/java/com/jero/modules/activiti/process/esInitChange/entity/vo/FlowUserInfoVO.java rename to laws-modules/src/main/java/com/jero/modules/activiti/process/esInitChange/entity/vo/InitChangeFlowUserVO.java index 07755b38..9216051c 100644 --- a/laws-modules/src/main/java/com/jero/modules/activiti/process/esInitChange/entity/vo/FlowUserInfoVO.java +++ b/laws-modules/src/main/java/com/jero/modules/activiti/process/esInitChange/entity/vo/InitChangeFlowUserVO.java @@ -8,7 +8,7 @@ import lombok.Data; * @Date: 2023/10/9 16:57 */ @Data -public class FlowUserInfoVO { +public class InitChangeFlowUserVO { @ApiModelProperty("主起草人") private String mainDraftUser; diff --git a/laws-modules/src/main/java/com/jero/modules/activiti/process/esInitChange/service/impl/ProcessEsInitChangeServiceImpl.java b/laws-modules/src/main/java/com/jero/modules/activiti/process/esInitChange/service/impl/ProcessEsInitChangeServiceImpl.java index c13755b5..5ba89f8b 100644 --- a/laws-modules/src/main/java/com/jero/modules/activiti/process/esInitChange/service/impl/ProcessEsInitChangeServiceImpl.java +++ b/laws-modules/src/main/java/com/jero/modules/activiti/process/esInitChange/service/impl/ProcessEsInitChangeServiceImpl.java @@ -18,7 +18,7 @@ import com.jero.modules.activiti.process.common.enums.ProcessType; import com.jero.modules.activiti.process.common.service.ActFlowCommonService; import com.jero.modules.activiti.process.common.service.ProcessDraftService; import com.jero.modules.activiti.process.esInitChange.entity.ProcessEsInitChange; -import com.jero.modules.activiti.process.esInitChange.entity.vo.FlowUserInfoVO; +import com.jero.modules.activiti.process.esInitChange.entity.vo.InitChangeFlowUserVO; import com.jero.modules.activiti.process.esInitChange.entity.vo.InitChangeDataVO; import com.jero.modules.activiti.process.esInitChange.service.ProcessEsInitChangeService; import com.jero.modules.activiti.process.esInitChange.mapper.ProcessEsInitChangeMapper; @@ -30,7 +30,6 @@ import com.jero.modules.laws.enterprise.service.ESSequenceNumberProvider; import com.jero.modules.laws.enterprise.util.EnterpriseStandardUtil; import com.jero.modules.sys.utils.UserUtils; import lombok.extern.slf4j.Slf4j; -import org.activiti.engine.TaskService; import org.activiti.engine.runtime.ProcessInstance; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -96,17 +95,17 @@ public class ProcessEsInitChangeServiceImpl extends ServiceImpl nodeList = processNodeService.getNodeList(processDefinitionId, processInstanceId); - FlowUserInfoVO flowUserInfoVO = new FlowUserInfoVO(); + InitChangeFlowUserVO initChangeFlowUserVO = new InitChangeFlowUserVO(); Map userMap = nodeList.stream().collect(Collectors.toMap(ProcessNode::getVariableName, node -> node)); - flowUserInfoVO.setCreateUser(userMap.get("createUser").getLinkUserIds()); - flowUserInfoVO.setContactUser(userMap.get("contactUser").getLinkUserIds()); - flowUserInfoVO.setMainDraftUserLeader(userMap.get("mainDraftUserLeader").getLinkUserIds()); - flowUserInfoVO.setMainDraftUserLeaderLeader(userMap.get("mainDraftUserLeaderLeader").getLinkUserIds()); - flowUserInfoVO.setStandardizationApprovalUser(userMap.get("standardizationApprovalUser").getLinkUserIds()); - flowUserInfoVO.setNewMainDraftUserLeaderLeader(userMap.get("newMainDraftUserLeaderLeader").getLinkUserIds()); - flowUserInfoVO.setNewMainDraftUserLeader(userMap.get("newMainDraftUserLeader").getLinkUserIds()); - flowUserInfoVO.setCopyUser(userMap.get("copyUser").getLinkUserIds()); - initChangeDataVO.setFlowUserInfoVO(flowUserInfoVO); + initChangeFlowUserVO.setCreateUser(userMap.get("createUser").getLinkUserIds()); + initChangeFlowUserVO.setContactUser(userMap.get("contactUser").getLinkUserIds()); + initChangeFlowUserVO.setMainDraftUserLeader(userMap.get("mainDraftUserLeader").getLinkUserIds()); + initChangeFlowUserVO.setMainDraftUserLeaderLeader(userMap.get("mainDraftUserLeaderLeader").getLinkUserIds()); + initChangeFlowUserVO.setStandardizationApprovalUser(userMap.get("standardizationApprovalUser").getLinkUserIds()); + initChangeFlowUserVO.setNewMainDraftUserLeaderLeader(userMap.get("newMainDraftUserLeaderLeader").getLinkUserIds()); + initChangeFlowUserVO.setNewMainDraftUserLeader(userMap.get("newMainDraftUserLeader").getLinkUserIds()); + initChangeFlowUserVO.setCopyUser(userMap.get("copyUser").getLinkUserIds()); + initChangeDataVO.setInitChangeFlowUserVO(initChangeFlowUserVO); return initChangeDataVO; } @@ -159,6 +158,9 @@ public class ProcessEsInitChangeServiceImpl extends ServiceImpl esInitChangeList = initChangeDataVO.getDataList(); Map variables = new HashMap<>(); String processInstanceId = actFlowCommonService.getProcessInstanceIdByTaskId(taskId); @@ -236,20 +238,20 @@ public class ProcessEsInitChangeServiceImpl extends ServiceImpl setVariables(InitChangeDataVO initChangeData) { - FlowUserInfoVO flowUserInfoVO = initChangeData.getFlowUserInfoVO(); + InitChangeFlowUserVO initChangeFlowUserVO = initChangeData.getInitChangeFlowUserVO(); ProcessEsInitChange initChange = initChangeData.getDataList().get(0); Map map = new HashMap<>(); // 设置流程中各个节点的人 - map.put("createUser", UserUtils.getUserIdByUserName(flowUserInfoVO.getCreateUser())); - map.put("contactUser", flowUserInfoVO.getContactUser()); - map.put("standardExpertList", Optional.ofNullable(flowUserInfoVO.getStandardExpert()).map(s -> Arrays.asList(s.split(","))).orElse(Collections.emptyList())); - map.put("mainDraftUserLeader", flowUserInfoVO.getMainDraftUserLeader()); - map.put("mainDraftUserLeaderLeader", flowUserInfoVO.getMainDraftUserLeaderLeader()); - map.put("standardizationApprovalUser", flowUserInfoVO.getStandardizationApprovalUser()); - map.put("newMainDraftUserLeaderLeader", flowUserInfoVO.getNewMainDraftUserLeaderLeader()); - map.put("newMainDraftUserLeader", flowUserInfoVO.getNewMainDraftUserLeader()); - map.put("relatedUserList", Optional.ofNullable(flowUserInfoVO.getRelatedUser()).map(s -> Arrays.asList(s.split(","))).orElse(Collections.emptyList())); - map.put("copyUser", flowUserInfoVO.getCopyUser()); + map.put("createUser", initChangeFlowUserVO.getMainDraftUser()); + map.put("contactUser", initChangeFlowUserVO.getContactUser()); + map.put("standardExpertList", Optional.ofNullable(initChangeFlowUserVO.getStandardExpert()).map(s -> Arrays.asList(s.split(","))).orElse(Collections.emptyList())); + map.put("mainDraftUserLeader", initChangeFlowUserVO.getMainDraftUserLeader()); + map.put("mainDraftUserLeaderLeader", initChangeFlowUserVO.getMainDraftUserLeaderLeader()); + map.put("standardizationApprovalUser", initChangeFlowUserVO.getStandardizationApprovalUser()); + map.put("newMainDraftUserLeaderLeader", initChangeFlowUserVO.getNewMainDraftUserLeaderLeader()); + map.put("newMainDraftUserLeader", initChangeFlowUserVO.getNewMainDraftUserLeader()); + map.put("relatedUserList", Optional.ofNullable(initChangeFlowUserVO.getRelatedUser()).map(s -> Arrays.asList(s.split(","))).orElse(Collections.emptyList())); + map.put("copyUser", initChangeFlowUserVO.getCopyUser()); // 设置流程分支判断变量 map.put("applicationCategory", initChange.getApplicationCategory()); map.put("projectType", initChange.getProjectType());