From 6954fdec0a01ec0e359cd878cc5af644299a3ed9 Mon Sep 17 00:00:00 2001 From: songgaoshuai <1742057357@qq.com> Date: Wed, 27 Mar 2024 14:19:34 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E4=BF=AE=E5=A4=8D=E5=B7=A5=E5=85=B7?= =?UTF-8?q?=E7=B1=BB=E5=8F=AF=E8=83=BD=E5=87=BA=E7=8E=B0=E7=A9=BA=E6=8C=87?= =?UTF-8?q?=E9=92=88=E6=83=85=E5=86=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/org/dromara/workflow/utils/ModelUtils.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/utils/ModelUtils.java b/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/utils/ModelUtils.java index 0d59b851b..7906287d4 100644 --- a/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/utils/ModelUtils.java +++ b/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/utils/ModelUtils.java @@ -9,6 +9,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import lombok.AccessLevel; import lombok.NoArgsConstructor; +import org.dromara.common.core.utils.SpringUtils; import org.dromara.common.core.utils.StreamUtils; import org.dromara.common.core.utils.StringUtils; import org.dromara.common.json.utils.JsonUtils; @@ -17,7 +18,7 @@ import org.flowable.bpmn.converter.BpmnXMLConverter; import org.flowable.bpmn.model.*; import org.flowable.bpmn.model.Process; import org.flowable.editor.language.json.converter.BpmnJsonConverter; -import org.flowable.engine.impl.util.ProcessDefinitionUtil; +import org.flowable.engine.ProcessEngine; import javax.xml.stream.XMLInputFactory; import javax.xml.stream.XMLStreamException; @@ -37,6 +38,8 @@ import java.util.stream.Collectors; @NoArgsConstructor(access = AccessLevel.PRIVATE) public class ModelUtils { + private static final ProcessEngine PROCESS_ENGINE = SpringUtils.getBean(ProcessEngine.class); + public static BpmnModel xmlToBpmnModel(String xml) throws IOException { if (xml == null) { throw new ServerException("xml不能为空"); @@ -166,7 +169,7 @@ public class ModelUtils { * @param processDefinitionId 流程定义id */ public static List getFlowElements(String processDefinitionId) { - BpmnModel bpmnModel = ProcessDefinitionUtil.getBpmnModel(processDefinitionId); + BpmnModel bpmnModel = PROCESS_ENGINE.getRepositoryService().getBpmnModel(processDefinitionId); List list = new ArrayList<>(); List processes = bpmnModel.getProcesses(); Collection flowElements = processes.get(0).getFlowElements(); @@ -213,7 +216,7 @@ public class ModelUtils { * @param flowElementId 节点id */ public static Map> getExtensionElement(String processDefinitionId, String flowElementId) { - BpmnModel bpmnModel = ProcessDefinitionUtil.getBpmnModel(processDefinitionId); + BpmnModel bpmnModel = PROCESS_ENGINE.getRepositoryService().getBpmnModel(processDefinitionId); Process process = bpmnModel.getMainProcess(); FlowElement flowElement = process.getFlowElement(flowElementId); return flowElement.getExtensionElements(); @@ -226,7 +229,7 @@ public class ModelUtils { * @param taskDefinitionKey 流程定义id */ public static boolean isUserTask(String processDefinitionId, String taskDefinitionKey) { - BpmnModel bpmnModel = ProcessDefinitionUtil.getBpmnModel(processDefinitionId); + BpmnModel bpmnModel = PROCESS_ENGINE.getRepositoryService().getBpmnModel(processDefinitionId); FlowNode flowNode = (FlowNode) bpmnModel.getFlowElement(taskDefinitionKey); return flowNode instanceof UserTask; }