项目地址 | https://gitee.com/lwj/flowable.git |
---|
代码分支 | flowable-base |
视频讲解地址 | https://space.bilibili.com/485524575/channel/detail?cid=94579 |
用户名 | 密码 |
---|
0000001 | test |
0000002 | test |
0000003 | test |
0000004 | test |
1. 演示
### 2. 代码
public ReturnVo<ProcessInstance> startProcessInstanceByKey(StartProcessInstanceVo params) {ReturnVo<ProcessInstance> returnVo = new ReturnVo<>(ReturnCode.SUCCESS, "启动成功");if (StringUtils.isNotBlank(params.getProcessDefinitionKey())&& StringUtils.isNotBlank(params.getBusinessKey())&& StringUtils.isNotBlank(params.getSystemSn())) {ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionKey(params.getProcessDefinitionKey()).latestVersion().singleResult();if (processDefinition != null && processDefinition.isSuspended()) {returnVo = new ReturnVo<>(ReturnCode.FAIL, "此流程已经挂起,请联系系统管理员!");return returnVo;}/*** 1、设置变量* 1.1、设置提交人字段为空字符串让其自动跳过* 1.2、设置可以自动跳过* 1.3、汇报线的参数设置*///1.1、设置提交人字段为空字符串让其自动跳过params.getVariables().put(FlowConstant.FLOW_SUBMITTER_VAR, "");//1.2、设置可以自动跳过params.getVariables().put(FlowConstant.FLOWABLE_SKIP_EXPRESSION_ENABLED, true);// TODO 1.3、汇报线的参数设置//2、当我们流程创建人和发起人String creator = params.getCreator();if (StringUtils.isBlank(creator)) {creator = params.getCurrentUserCode();params.setCreator(creator);}//3.启动流程identityService.setAuthenticatedUserId(creator);ProcessInstance processInstance = runtimeService.createProcessInstanceBuilder().processDefinitionKey(params.getProcessDefinitionKey().trim()).name(params.getFormName().trim()).businessKey(params.getBusinessKey().trim()).variables(params.getVariables()).tenantId(params.getSystemSn().trim()).start();returnVo.setData(processInstance);//4.添加审批记录this.addComment(params.getCurrentUserCode(), processInstance.getProcessInstanceId(),CommentTypeEnum.TJ.toString(), params.getFormName() + "提交");//5.TODO 推送消息数据} else {returnVo = new ReturnVo<>(ReturnCode.FAIL, "请填写 这三个字段 ProcessDefinitionKey,BusinessKey,SystemSn");}return returnVo;}