From 2aa56500c5363d54e671608974c6b826da540a84 Mon Sep 17 00:00:00 2001 From: smallchill Date: Sat, 8 Aug 2020 14:48:19 +0800 Subject: [PATCH] =?UTF-8?q?:zap:=20=E4=BC=98=E5=8C=96=E6=B5=81=E7=A8=8B?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E5=8F=98=E6=9B=B4=E8=BF=94=E5=9B=9E=E4=BF=A1?= =?UTF-8?q?=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/FlowEngineServiceImpl.java | 24 ++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/blade-ops/blade-flow/src/main/java/org/springblade/flow/engine/service/impl/FlowEngineServiceImpl.java b/blade-ops/blade-flow/src/main/java/org/springblade/flow/engine/service/impl/FlowEngineServiceImpl.java index 5585aafe..4feee519 100644 --- a/blade-ops/blade-flow/src/main/java/org/springblade/flow/engine/service/impl/FlowEngineServiceImpl.java +++ b/blade-ops/blade-flow/src/main/java/org/springblade/flow/engine/service/impl/FlowEngineServiceImpl.java @@ -75,6 +75,7 @@ import java.util.*; @Service @AllArgsConstructor public class FlowEngineServiceImpl extends ServiceImpl implements FlowEngineService { + private static final String ALREADY_IN_STATE = "already in state"; private static final BpmnJsonConverter BPMN_JSON_CONVERTER = new BpmnJsonConverter(); private static final BpmnXMLConverter BPMN_XML_CONVERTER = new BpmnXMLConverter(); private final ObjectMapper objectMapper; @@ -239,14 +240,21 @@ public class FlowEngineServiceImpl extends ServiceImpl im @Override public String changeState(String state, String processId) { - if (state.equals(FlowEngineConstant.ACTIVE)) { - repositoryService.activateProcessDefinitionById(processId, true, null); - return StringUtil.format("激活ID为 [{}] 的流程成功", processId); - } else if (state.equals(FlowEngineConstant.SUSPEND)) { - repositoryService.suspendProcessDefinitionById(processId, true, null); - return StringUtil.format("挂起ID为 [{}] 的流程成功", processId); - } else { - return "暂无流程变更"; + try { + if (state.equals(FlowEngineConstant.ACTIVE)) { + repositoryService.activateProcessDefinitionById(processId, true, null); + return StringUtil.format("激活ID为 [{}] 的流程成功", processId); + } else if (state.equals(FlowEngineConstant.SUSPEND)) { + repositoryService.suspendProcessDefinitionById(processId, true, null); + return StringUtil.format("挂起ID为 [{}] 的流程成功", processId); + } else { + return "暂无流程变更"; + } + } catch (Exception e) { + if (e.getMessage().contains(ALREADY_IN_STATE)) { + return StringUtil.format("ID为 [{}] 的流程已是此状态,无需操作", processId); + } + return e.getMessage(); } }