From ed43774129f2278aa6248242c6ff145bde1a625d Mon Sep 17 00:00:00 2001 From: gssong <1742057357@qq.com> Date: 星期三, 27 三月 2024 22:23:02 +0800 Subject: [PATCH] add 添加任务过期自动审批 --- ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/utils/ModelUtils.java | 30 +++++++++++++++++++++++------- 1 files changed, 23 insertions(+), 7 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 18969b1..7906287 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 @@ -7,6 +7,9 @@ import cn.hutool.core.util.StrUtil; 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; @@ -15,7 +18,7 @@ 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; @@ -32,9 +35,10 @@ * * @author may */ +@NoArgsConstructor(access = AccessLevel.PRIVATE) public class ModelUtils { - public ModelUtils() { - } + + private static final ProcessEngine PROCESS_ENGINE = SpringUtils.getBean(ProcessEngine.class); public static BpmnModel xmlToBpmnModel(String xml) throws IOException { if (xml == null) { @@ -165,7 +169,7 @@ * @param processDefinitionId 娴佺▼瀹氫箟id */ public static List<FlowElement> getFlowElements(String processDefinitionId) { - BpmnModel bpmnModel = ProcessDefinitionUtil.getBpmnModel(processDefinitionId); + BpmnModel bpmnModel = PROCESS_ENGINE.getRepositoryService().getBpmnModel(processDefinitionId); List<FlowElement> list = new ArrayList<>(); List<Process> processes = bpmnModel.getProcesses(); Collection<FlowElement> flowElements = processes.get(0).getFlowElements(); @@ -194,7 +198,7 @@ * * @param processDefinitionId 娴佺▼瀹氫箟id */ - public Map<String, List<ExtensionElement>> getExtensionElements(String processDefinitionId) { + public static Map<String, List<ExtensionElement>> getExtensionElements(String processDefinitionId) { Map<String, List<ExtensionElement>> map = new HashMap<>(); List<FlowElement> flowElements = getFlowElements(processDefinitionId); for (FlowElement flowElement : flowElements) { @@ -211,10 +215,22 @@ * @param processDefinitionId 娴佺▼瀹氫箟id * @param flowElementId 鑺傜偣id */ - public Map<String, List<ExtensionElement>> getExtensionElement(String processDefinitionId, String flowElementId) { - BpmnModel bpmnModel = ProcessDefinitionUtil.getBpmnModel(processDefinitionId); + public static Map<String, List<ExtensionElement>> getExtensionElement(String processDefinitionId, String flowElementId) { + BpmnModel bpmnModel = PROCESS_ENGINE.getRepositoryService().getBpmnModel(processDefinitionId); Process process = bpmnModel.getMainProcess(); FlowElement flowElement = process.getFlowElement(flowElementId); return flowElement.getExtensionElements(); } + + /** + * 鍒ゆ柇褰撳墠鑺傜偣鏄惁涓虹敤鎴蜂换鍔� + * + * @param processDefinitionId 娴佺▼瀹氫箟id + * @param taskDefinitionKey 娴佺▼瀹氫箟id + */ + public static boolean isUserTask(String processDefinitionId, String taskDefinitionKey) { + BpmnModel bpmnModel = PROCESS_ENGINE.getRepositoryService().getBpmnModel(processDefinitionId); + FlowNode flowNode = (FlowNode) bpmnModel.getFlowElement(taskDefinitionKey); + return flowNode instanceof UserTask; + } } -- Gitblit v1.9.3