From df6649907dbd82b2aeb4e0e676185920241506ae Mon Sep 17 00:00:00 2001
From: 疯狂的狮子Li <15040126243@163.com>
Date: 星期六, 14 十二月 2024 23:05:15 +0800
Subject: [PATCH] update justauth 1.16.6 => 1.16.7 支持多种登录方式 不限于三方登录
---
ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/utils/ModelUtils.java | 85 ++++++++++++++++++++++++++++++++++++++----
1 files changed, 77 insertions(+), 8 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..7c5377e 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) {
@@ -152,10 +156,47 @@
if (!(targetFlowElement instanceof UserTask) && !subtask) {
throw new ServerException("寮�濮嬭妭鐐瑰悗绗竴涓妭鐐瑰繀椤绘槸鐢ㄦ埛浠诲姟锛�");
}
-
+ //寮�濮嬭妭鐐瑰悗绗竴涓妭鐐圭敵璇蜂汉鑺傜偣
+ if ((targetFlowElement instanceof UserTask) && !subtask) {
+ UserTask userTask = (UserTask) targetFlowElement;
+ if (StringUtils.isBlank(userTask.getFormKey())) {
+ throw new ServerException("鐢宠浜鸿妭鐐瑰繀椤婚�夋嫨琛ㄥ崟锛�");
+ }
+ }
List<EndEvent> endEventList = flowElements.stream().filter(EndEvent.class::isInstance).map(EndEvent.class::cast).collect(Collectors.toList());
if (CollUtil.isEmpty(endEventList)) {
throw new ServerException(subtask ? "瀛愭祦绋嬪繀椤诲瓨鍦ㄧ粨鏉熻妭鐐癸紒" : "蹇呴』瀛樺湪缁撴潫鑺傜偣锛�");
+ }
+ }
+
+ /**
+ * 鑾峰彇娴佺▼鍏ㄩ儴鐢ㄦ埛鑺傜偣
+ *
+ * @param processDefinitionId 娴佺▼瀹氫箟id
+ */
+ public static List<UserTask> getUserTaskFlowElements(String processDefinitionId) {
+ BpmnModel bpmnModel = PROCESS_ENGINE.getRepositoryService().getBpmnModel(processDefinitionId);
+ List<UserTask> list = new ArrayList<>();
+ List<Process> processes = bpmnModel.getProcesses();
+ Collection<FlowElement> flowElements = processes.get(0).getFlowElements();
+ buildUserTaskFlowElements(flowElements, list);
+ return list;
+ }
+
+ /**
+ * 閫掑綊鑾峰彇鎵�鏈夎妭鐐�
+ *
+ * @param flowElements 鑺傜偣淇℃伅
+ * @param list 闆嗗悎
+ */
+ private static void buildUserTaskFlowElements(Collection<FlowElement> flowElements, List<UserTask> list) {
+ for (FlowElement flowElement : flowElements) {
+ if (flowElement instanceof SubProcess) {
+ Collection<FlowElement> subFlowElements = ((SubProcess) flowElement).getFlowElements();
+ buildUserTaskFlowElements(subFlowElements, list);
+ } else if (flowElement instanceof UserTask) {
+ list.add((UserTask) flowElement);
+ }
}
}
@@ -165,7 +206,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 +235,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 +252,38 @@
* @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;
+ }
+
+ /**
+ * 鑾峰彇鐢宠浜鸿妭鐐�
+ *
+ * @param processDefinitionId 娴佺▼瀹氫箟id
+ * @return 缁撴灉
+ */
+ public static UserTask getApplyUserTask(String processDefinitionId) {
+ BpmnModel bpmnModel = PROCESS_ENGINE.getRepositoryService().getBpmnModel(processDefinitionId);
+ Collection<FlowElement> flowElements = bpmnModel.getMainProcess().getFlowElements();
+ List<StartEvent> startEventList = flowElements.stream().filter(StartEvent.class::isInstance).map(StartEvent.class::cast).collect(Collectors.toList());
+ StartEvent startEvent = startEventList.get(0);
+ List<SequenceFlow> outgoingFlows = startEvent.getOutgoingFlows();
+ FlowElement targetFlowElement = outgoingFlows.get(0).getTargetFlowElement();
+ return (UserTask) targetFlowElement;
+ }
}
--
Gitblit v1.9.3