1.演示
2.代码
public Object changeState(ReqManager reqManager) {
RetBean retbean = new RetBean();
try {
if (reqManager.getState().equals(FlowEngineConstant.ACTIVE)) {
repositoryService.activateProcessDefinitionById(reqManager.getProcessId(), true, null);
retbean.setMsg(String.format("激活ID为 '%s' 的流程成功", reqManager.getProcessId()));
} else if (reqManager.getState().equals(FlowEngineConstant.SUSPEND)) {
repositoryService.suspendProcessDefinitionById(reqManager.getProcessId(), true, null);
retbean.setMsg(String.format("挂起ID为 '%s' 的流程成功", reqManager.getProcessId()));
} else {
retbean.setMsg("暂无流程变更");
}
} catch (Exception e) {
if (e.getMessage().contains("already in state")) {
retbean.setMsg(String.format("ID为 '%s' 的流程已是此状态,无需操作", reqManager.getProcessId()));
}
}
return retbean;
}