Commit 56ea9d2381e6aa837ce54bc841cc018a14b562cc
1 parent
64ea9906
【代码优化】BPM:修复停用状态下的流程删除报错问题
Showing
3 changed files
with
12 additions
and
9 deletions
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmModelServiceImpl.java
| @@ -304,7 +304,7 @@ public class BpmModelServiceImpl implements BpmModelService { | @@ -304,7 +304,7 @@ public class BpmModelServiceImpl implements BpmModelService { | ||
| 304 | } | 304 | } |
| 305 | 305 | ||
| 306 | // 2. 更新状态 | 306 | // 2. 更新状态 |
| 307 | - processDefinitionService.updateProcessDefinitionState(definition.getId(), state,definition.isSuspended()); | 307 | + processDefinitionService.updateProcessDefinitionState(definition.getId(), state); |
| 308 | } | 308 | } |
| 309 | 309 | ||
| 310 | @Override | 310 | @Override |
| @@ -403,7 +403,7 @@ public class BpmModelServiceImpl implements BpmModelService { | @@ -403,7 +403,7 @@ public class BpmModelServiceImpl implements BpmModelService { | ||
| 403 | return; | 403 | return; |
| 404 | } | 404 | } |
| 405 | processDefinitionService.updateProcessDefinitionState(oldDefinition.getId(), | 405 | processDefinitionService.updateProcessDefinitionState(oldDefinition.getId(), |
| 406 | - SuspensionState.SUSPENDED.getStateCode(),oldDefinition.isSuspended()); | 406 | + SuspensionState.SUSPENDED.getStateCode()); |
| 407 | } | 407 | } |
| 408 | 408 | ||
| 409 | private Model getModelByKey(String key) { | 409 | private Model getModelByKey(String key) { |
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmProcessDefinitionService.java
| @@ -60,9 +60,8 @@ public interface BpmProcessDefinitionService { | @@ -60,9 +60,8 @@ public interface BpmProcessDefinitionService { | ||
| 60 | * | 60 | * |
| 61 | * @param id 流程定义的编号 | 61 | * @param id 流程定义的编号 |
| 62 | * @param state 状态 | 62 | * @param state 状态 |
| 63 | - * @param isSuspended 是否处于激活或挂起状态 | ||
| 64 | */ | 63 | */ |
| 65 | - void updateProcessDefinitionState(String id, Integer state, boolean isSuspended); | 64 | + void updateProcessDefinitionState(String id, Integer state); |
| 66 | 65 | ||
| 67 | /** | 66 | /** |
| 68 | * 更新模型编号 | 67 | * 更新模型编号 |
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmProcessDefinitionServiceImpl.java
| @@ -28,8 +28,7 @@ import java.util.*; | @@ -28,8 +28,7 @@ import java.util.*; | ||
| 28 | 28 | ||
| 29 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | 29 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| 30 | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.addIfNotNull; | 30 | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.addIfNotNull; |
| 31 | -import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.PROCESS_DEFINITION_KEY_NOT_MATCH; | ||
| 32 | -import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.PROCESS_DEFINITION_NAME_NOT_MATCH; | 31 | +import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.*; |
| 33 | import static java.util.Collections.emptyList; | 32 | import static java.util.Collections.emptyList; |
| 34 | 33 | ||
| 35 | /** | 34 | /** |
| @@ -155,10 +154,15 @@ public class BpmProcessDefinitionServiceImpl implements BpmProcessDefinitionServ | @@ -155,10 +154,15 @@ public class BpmProcessDefinitionServiceImpl implements BpmProcessDefinitionServ | ||
| 155 | } | 154 | } |
| 156 | 155 | ||
| 157 | @Override | 156 | @Override |
| 158 | - public void updateProcessDefinitionState(String id, Integer state,boolean isSuspended) { | 157 | + public void updateProcessDefinitionState(String id, Integer state) { |
| 158 | + ProcessDefinition processDefinition = repositoryService.getProcessDefinition(id); | ||
| 159 | + if (processDefinition == null) { | ||
| 160 | + throw exception(PROCESS_DEFINITION_NOT_EXISTS); | ||
| 161 | + } | ||
| 162 | + | ||
| 159 | // 激活 | 163 | // 激活 |
| 160 | if (Objects.equals(SuspensionState.ACTIVE.getStateCode(), state)) { | 164 | if (Objects.equals(SuspensionState.ACTIVE.getStateCode(), state)) { |
| 161 | - if (isSuspended) { | 165 | + if (processDefinition.isSuspended()) { |
| 162 | repositoryService.activateProcessDefinitionById(id, false, null); | 166 | repositoryService.activateProcessDefinitionById(id, false, null); |
| 163 | } | 167 | } |
| 164 | return; | 168 | return; |
| @@ -167,7 +171,7 @@ public class BpmProcessDefinitionServiceImpl implements BpmProcessDefinitionServ | @@ -167,7 +171,7 @@ public class BpmProcessDefinitionServiceImpl implements BpmProcessDefinitionServ | ||
| 167 | if (Objects.equals(SuspensionState.SUSPENDED.getStateCode(), state)) { | 171 | if (Objects.equals(SuspensionState.SUSPENDED.getStateCode(), state)) { |
| 168 | // suspendProcessInstances = false,进行中的任务,不进行挂起。 | 172 | // suspendProcessInstances = false,进行中的任务,不进行挂起。 |
| 169 | // 原因:只要新的流程不允许发起即可,老流程继续可以执行。 | 173 | // 原因:只要新的流程不允许发起即可,老流程继续可以执行。 |
| 170 | - if (!isSuspended) { | 174 | + if (!processDefinition.isSuspended()) { |
| 171 | repositoryService.suspendProcessDefinitionById(id, false, null); | 175 | repositoryService.suspendProcessDefinitionById(id, false, null); |
| 172 | } | 176 | } |
| 173 | return; | 177 | return; |