项目地址 | 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<String> complete(CompleteTaskVo params) {ReturnVo<String> returnVo = new ReturnVo<>(ReturnCode.SUCCESS, "审批成功");if (StringUtils.isNotBlank(params.getProcessInstanceId())&& StringUtils.isNotBlank(params.getTaskId())) {String type = params.getType() == null ? CommentTypeEnum.SP.toString() : params.getType();TaskEntity taskEntity = (TaskEntity) taskService.createTaskQuery().taskId(params.getTaskId()).singleResult();if (taskEntity != null) {//2.委派处理if (DelegationState.PENDING.equals(taskEntity.getDelegationState())) {//2.1生成历史记录TaskEntity task = this.createSubTask(taskEntity, params.getUserCode());taskService.saveTask(task);taskService.complete(task.getId());//2.2生成审批意见this.addComment(task.getId(), params.getUserCode(), params.getProcessInstanceId(),CommentTypeEnum.SP.toString(), params.getMessage());//2.3执行委派taskService.resolveTask(params.getTaskId(), params.getVariables());} else {//3.1修改执行人 其实我这里就相当于签收了taskService.setAssignee(params.getTaskId(), params.getUserCode());//3.2执行任务taskService.complete(params.getTaskId(), params.getVariables());//3.3生成审批记录this.addComment(params.getTaskId(), params.getUserCode(), params.getProcessInstanceId(),CommentTypeEnum.SP.toString(), params.getMessage());//4.处理加签父任务String parentTaskId = taskEntity.getParentTaskId();if (StringUtils.isNotBlank(parentTaskId)) {String tableName = managementService.getTableName(TaskEntity.class);String sql = "select count(1) from " + tableName + " where PARENT_TASK_ID_=#{parentTaskId}";long subTaskCount = taskService.createNativeTaskQuery().sql(sql).parameter("parentTaskId", parentTaskId).count();if (subTaskCount == 0) {Task task = taskService.createTaskQuery().taskId(parentTaskId).singleResult();//处理前后加签的任务taskService.resolveTask(parentTaskId);if (FlowConstant.AFTER_ADDSIGN.equals(task.getScopeType())) {taskService.complete(parentTaskId);}}}}} else {returnVo = new ReturnVo<>(ReturnCode.FAIL, "没有此任务,请确认!");}} else {returnVo = new ReturnVo<>(ReturnCode.FAIL, "请输入正确的参数!");}return returnVo;}