From 7103f6d893102ab3da77347817841517bdde00d6 Mon Sep 17 00:00:00 2001 From: caihaohan Date: Thu, 26 Oct 2023 17:22:09 +0800 Subject: [PATCH 1/2] =?UTF-8?q?perf:=20=E6=B8=85=E6=B5=81=E6=89=80?= =?UTF-8?q?=E6=9C=89=E6=B5=81=E7=A8=8B=E6=8E=A5=E5=8F=A3=E6=80=A7=E8=83=BD?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/ModelerController.java | 32 +++++++++++-------- 1 file changed, 18 insertions(+), 14 deletions(-) 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); } } + } From b2732e45c25c0a3732eff75c4748924bc444f4bc Mon Sep 17 00:00:00 2001 From: caihaohan Date: Thu, 26 Oct 2023 18:04:17 +0800 Subject: [PATCH 2/2] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E7=AB=8B=E9=A1=B9?= =?UTF-8?q?=E5=8F=98=E6=9B=B4=E6=B5=81=E7=A8=8B=E7=BC=BA=E5=B0=91=E5=88=9B?= =?UTF-8?q?=E5=BB=BA=E4=BA=BA=E7=9A=84Bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../entity/vo/InitChangeDataVO.java | 3 +- ...rInfoVO.java => InitChangeFlowUserVO.java} | 2 +- .../impl/ProcessEsInitChangeServiceImpl.java | 48 ++++++++++--------- 3 files changed, 27 insertions(+), 26 deletions(-) rename laws-modules/src/main/java/com/jero/modules/activiti/process/esInitChange/entity/vo/{FlowUserInfoVO.java => InitChangeFlowUserVO.java} (97%) 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());