From 7d8e50439017463aa2821d9eddd41070c0027c87 Mon Sep 17 00:00:00 2001 From: "1437892690@qq.com" <1437892690@qq.com> Date: Tue, 2 Jul 2024 12:16:12 +0800 Subject: [PATCH] =?UTF-8?q?[=E4=BF=AE=E5=A4=8D]=20=E6=B5=81=E7=A8=8B?= =?UTF-8?q?=E5=88=A0=E9=99=A4=E8=8A=82=E7=82=B9=EF=BC=8C=E4=BF=9D=E5=AD=98?= =?UTF-8?q?=E7=9A=84=E6=95=B0=E6=8D=AE=E8=BF=99=E4=B8=AA=E8=8A=82=E7=82=B9?= =?UTF-8?q?=E8=BF=98=E6=98=AF=E5=AD=98=E5=9C=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 关联 #[1166498725330944]流程删除节点,保存的数据这个节点还是存在 http://192.168.0.96:8090/demo/rdm.html#/bug-detail/939050947543040/939050947543057/1166498725330944 --- .../core/ProcessMessageContext.java | 27 +++++++++-- .../core/ProcessMessageManager.java | 46 +++++++++++-------- .../process/util/ProcessConfigUtil.java | 7 +-- 3 files changed, 54 insertions(+), 26 deletions(-) diff --git a/src/main/java/neatlogic/framework/process/stephandler/core/ProcessMessageContext.java b/src/main/java/neatlogic/framework/process/stephandler/core/ProcessMessageContext.java index cabc3917..88c736fc 100644 --- a/src/main/java/neatlogic/framework/process/stephandler/core/ProcessMessageContext.java +++ b/src/main/java/neatlogic/framework/process/stephandler/core/ProcessMessageContext.java @@ -19,26 +19,35 @@ package neatlogic.framework.process.stephandler.core; import com.alibaba.fastjson.JSONObject; import neatlogic.framework.process.dto.ProcessStepRelVo; +import neatlogic.framework.restful.constvalue.OperationTypeEnum; +import org.apache.commons.lang3.StringUtils; import java.util.List; public class ProcessMessageContext { - private final JSONObject config; + private JSONObject config; + + private String stepName = StringUtils.EMPTY; + + private OperationTypeEnum operationType; - private String stepName; private List effectiveStepUuidList; private List connectionList; - public ProcessMessageContext(JSONObject config) { - this.config = config; - } +// public ProcessMessageContext(JSONObject config) { +// this.config = config; +// } public JSONObject getConfig() { return config; } + public void setConfig(JSONObject config) { + this.config = config; + } + public String getStepName() { return stepName; } @@ -62,4 +71,12 @@ public class ProcessMessageContext { public void setConnectionList(List connectionList) { this.connectionList = connectionList; } + + public OperationTypeEnum getOperationType() { + return operationType; + } + + public void setOperationType(OperationTypeEnum operationType) { + this.operationType = operationType; + } } diff --git a/src/main/java/neatlogic/framework/process/stephandler/core/ProcessMessageManager.java b/src/main/java/neatlogic/framework/process/stephandler/core/ProcessMessageManager.java index 46d5234a..e272a262 100644 --- a/src/main/java/neatlogic/framework/process/stephandler/core/ProcessMessageManager.java +++ b/src/main/java/neatlogic/framework/process/stephandler/core/ProcessMessageManager.java @@ -22,6 +22,7 @@ import com.alibaba.fastjson.JSONObject; import neatlogic.framework.process.constvalue.ProcessFlowDirection; import neatlogic.framework.process.constvalue.ProcessStepHandlerType; import neatlogic.framework.process.dto.ProcessStepRelVo; +import neatlogic.framework.restful.constvalue.OperationTypeEnum; import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.StringUtils; @@ -32,23 +33,32 @@ import java.util.Objects; public class ProcessMessageManager { private static final ThreadLocal context = new ThreadLocal<>(); + private static ProcessMessageContext getProcessMessageContext() { + ProcessMessageContext processMessageContext = context.get(); + if (processMessageContext == null) { + processMessageContext = new ProcessMessageContext(); + context.set(processMessageContext); + } + return context.get(); + } public static void setConfig(JSONObject config) { - context.set(new ProcessMessageContext(config)); + getProcessMessageContext().setConfig(config); } public static void setStepName(String stepName) { - ProcessMessageContext processMessageContext = context.get(); - if (processMessageContext != null) { - processMessageContext.setStepName(stepName); - } + getProcessMessageContext().setStepName(stepName); } public static String getStepName() { - ProcessMessageContext processMessageContext = context.get(); - if (processMessageContext != null) { - return processMessageContext.getStepName(); - } - return StringUtils.EMPTY; + return getProcessMessageContext().getStepName(); + } + + public static OperationTypeEnum getOperationType() { + return getProcessMessageContext().getOperationType(); + } + + public static void setOperationType(OperationTypeEnum operationType) { + getProcessMessageContext().setOperationType(operationType); } public static void release() { @@ -56,16 +66,16 @@ public class ProcessMessageManager { } public static List getEffectiveStepUuidList() { - ProcessMessageContext processMessageContext = context.get(); - if (processMessageContext == null) { - return new ArrayList<>(); - } + ProcessMessageContext processMessageContext = getProcessMessageContext(); List effectiveStepUuidList = processMessageContext.getEffectiveStepUuidList(); if (effectiveStepUuidList == null) { List allProcessStepRelList = getProcessStepRelList(); String startStepUuid = null; String endStepUuid = null; JSONObject process = processMessageContext.getConfig(); + if (MapUtils.isEmpty(process)) { + return new ArrayList<>(); + } JSONArray stepList = process.getJSONArray("stepList"); for (int i = 0; i < stepList.size(); i++) { JSONObject step = stepList.getJSONObject(i); @@ -105,13 +115,13 @@ public class ProcessMessageManager { } public static List getProcessStepRelList() { - ProcessMessageContext processMessageContext = context.get(); - if (processMessageContext == null) { - return new ArrayList<>(); - } + ProcessMessageContext processMessageContext = getProcessMessageContext(); List processStepRelList = processMessageContext.getConnectionList(); if (processStepRelList == null) { JSONObject process = processMessageContext.getConfig(); + if (MapUtils.isEmpty(process)) { + return new ArrayList<>(); + } JSONArray connectionList = process.getJSONArray("connectionList"); if (connectionList == null) { connectionList = new JSONArray(); diff --git a/src/main/java/neatlogic/framework/process/util/ProcessConfigUtil.java b/src/main/java/neatlogic/framework/process/util/ProcessConfigUtil.java index d4e8f614..0430dc46 100644 --- a/src/main/java/neatlogic/framework/process/util/ProcessConfigUtil.java +++ b/src/main/java/neatlogic/framework/process/util/ProcessConfigUtil.java @@ -27,6 +27,7 @@ import neatlogic.framework.process.exception.process.ProcessStepUtilHandlerNotFo import neatlogic.framework.process.stephandler.core.IProcessStepInternalHandler; import neatlogic.framework.process.stephandler.core.ProcessMessageManager; import neatlogic.framework.process.stephandler.core.ProcessStepInternalHandlerFactory; +import neatlogic.framework.restful.constvalue.OperationTypeEnum; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.ListUtils; import org.apache.commons.collections4.MapUtils; @@ -414,14 +415,14 @@ public class ProcessConfigUtil { if (StringUtils.isBlank(uuid)) { continue; } - if (!effectiveStepUuidList.contains(uuid)) { + if (!effectiveStepUuidList.contains(uuid) && ProcessMessageManager.getOperationType() == OperationTypeEnum.UPDATE) { throw new ProcessConfigException(ProcessConfigException.Type.PRE_STEP_ASSIGN, ProcessMessageManager.getStepName()); } JSONArray conditionUuidArray = processStepObj.getJSONArray("condition"); if (CollectionUtils.isNotEmpty(conditionUuidArray)) { List conditionUuidList = conditionUuidArray.toJavaList(String.class); List list = ListUtils.removeAll(conditionUuidList, effectiveStepUuidList); - if (CollectionUtils.isNotEmpty(list)) { + if (CollectionUtils.isNotEmpty(list) && ProcessMessageManager.getOperationType() == OperationTypeEnum.UPDATE) { throw new ProcessConfigException(ProcessConfigException.Type.PRE_STEP_ASSIGN_CONDITION_STEP, ProcessMessageManager.getStepName()); } } @@ -441,7 +442,7 @@ public class ProcessConfigUtil { case COPY: String processStepUuid = configObj.getString("processStepUuid"); if (StringUtils.isNotBlank(processStepUuid)) { - if (!effectiveStepUuidList.contains(processStepUuid)) { + if (!effectiveStepUuidList.contains(processStepUuid) && ProcessMessageManager.getOperationType() == OperationTypeEnum.UPDATE) { throw new ProcessConfigException(ProcessConfigException.Type.COPY, ProcessMessageManager.getStepName()); } configObject.put("processStepUuid", processStepUuid); -- Gitee