Browse Source

优化流程状态变更返回信息

test
smallchill 4 years ago
parent
commit
2aa56500c5
  1. 24
      blade-ops/blade-flow/src/main/java/org/springblade/flow/engine/service/impl/FlowEngineServiceImpl.java

24
blade-ops/blade-flow/src/main/java/org/springblade/flow/engine/service/impl/FlowEngineServiceImpl.java

@ -75,6 +75,7 @@ import java.util.*;
@Service @Service
@AllArgsConstructor @AllArgsConstructor
public class FlowEngineServiceImpl extends ServiceImpl<FlowMapper, FlowModel> implements FlowEngineService { public class FlowEngineServiceImpl extends ServiceImpl<FlowMapper, FlowModel> implements FlowEngineService {
private static final String ALREADY_IN_STATE = "already in state";
private static final BpmnJsonConverter BPMN_JSON_CONVERTER = new BpmnJsonConverter(); private static final BpmnJsonConverter BPMN_JSON_CONVERTER = new BpmnJsonConverter();
private static final BpmnXMLConverter BPMN_XML_CONVERTER = new BpmnXMLConverter(); private static final BpmnXMLConverter BPMN_XML_CONVERTER = new BpmnXMLConverter();
private final ObjectMapper objectMapper; private final ObjectMapper objectMapper;
@ -239,14 +240,21 @@ public class FlowEngineServiceImpl extends ServiceImpl<FlowMapper, FlowModel> im
@Override @Override
public String changeState(String state, String processId) { public String changeState(String state, String processId) {
if (state.equals(FlowEngineConstant.ACTIVE)) { try {
repositoryService.activateProcessDefinitionById(processId, true, null); if (state.equals(FlowEngineConstant.ACTIVE)) {
return StringUtil.format("激活ID为 [{}] 的流程成功", processId); repositoryService.activateProcessDefinitionById(processId, true, null);
} else if (state.equals(FlowEngineConstant.SUSPEND)) { return StringUtil.format("激活ID为 [{}] 的流程成功", processId);
repositoryService.suspendProcessDefinitionById(processId, true, null); } else if (state.equals(FlowEngineConstant.SUSPEND)) {
return StringUtil.format("挂起ID为 [{}] 的流程成功", processId); repositoryService.suspendProcessDefinitionById(processId, true, null);
} else { return StringUtil.format("挂起ID为 [{}] 的流程成功", processId);
return "暂无流程变更"; } else {
return "暂无流程变更";
}
} catch (Exception e) {
if (e.getMessage().contains(ALREADY_IN_STATE)) {
return StringUtil.format("ID为 [{}] 的流程已是此状态,无需操作", processId);
}
return e.getMessage();
} }
} }

Loading…
Cancel
Save