基于若依的ruoyi-nbcio流程管理系统修正自定义业务表单的回写bug

更多ruoyi-nbcio功能请看演示系统

gitee源代码地址

前后端代码: https://gitee.com/nbacheng/ruoyi-nbcio

演示地址:RuoYi-Nbcio后台管理系统 http://218.75.87.38:9666/

更多nbcio-boot功能请看演示系统

gitee源代码地址

后端代码: https://gitee.com/nbacheng/nbcio-boot

前端代码:https://gitee.com/nbacheng/nbcio-vue.git

在线演示(包括H5) : http://218.75.87.38:9888

1、后端,在获取tod流程的时候加上dataId

java 复制代码
// 流程发起人信息
            HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery()
                .processInstanceId(task.getProcessInstanceId())
                .singleResult();
            String userId = historicProcessInstance.getStartUserId();
            String nickName = sysUserService.selectUserByUserName(userId).getNickName();
            flowTask.setStartUserId(userId);
            flowTask.setStartUserName(nickName);
            flowTask.setDataId(historicProcessInstance.getBusinessKey());

2、前端处理的时候加上dataId

javascript 复制代码
// 跳转到处理页面
    handleProcess(row) {
      this.$router.push({
        path: '/workflow/process/detail/' + row.procInsId,
        query: {
          taskId: row.taskId,
          dataId: row.dataId,
          processed: true
        }
      })
    },

已经detail.vue里增加获取这个dataId

javascript 复制代码
initData() {
      this.taskForm.procInsId = this.$route.params && this.$route.params.procInsId;
      this.taskForm.taskId  = this.$route.query && this.$route.query.taskId;
      this.taskForm.dataId  = this.$route.query && this.$route.query.dataId;
      this.processed = this.$route.query && eval(this.$route.query.processed || false);

3、后端对dataId的自自定义业务做回写处理

java 复制代码
//处理自定义业务表单回写状态,节点与处理人信息
        if (StringUtils.isNotBlank(taskBo.getDataId())) {
        	//业务数据id
            String dataId = taskBo.getDataId();
            //如果保存数据前未调用必调的FlowCommonService.initActBusiness方法,就会有问题
            WfMyBusiness business = wfMyBusinessService.getByDataId(dataId);
            //spring容器类名
            String serviceImplName = business.getServiceImplName();
            WfCallBackServiceI flowCallBackService = (WfCallBackServiceI) SpringContextUtils.getBean(serviceImplName);
            
            FlowNextDto flowNextDto = this.getNextFlowNode(taskBo.getTaskId(), taskBo.getVariables());
            if(flowNextDto != null) {
            	//**有下一个节点
                UserTask nextUserTask = flowNextDto.getUserTask();
                //能够处理下个节点的候选人
                List<SysUser> nextFlowNodeUserList = flowNextDto.getUserList();
                List<String> newusername = new ArrayList<String>();
                if(nextFlowNodeUserList != null &&  nextFlowNodeUserList.get(0) != null ) {
    	            List<String> collect_username = nextFlowNodeUserList.stream().filter(Objects::nonNull).filter(item->item.getUserName()!=null).map(SysUser::getUserName).collect(Collectors.toList());
    	            //collect_username转换成realname
    	            // 流程发起人
    	            ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(taskBo.getProcInsId()).singleResult();
    	            String startUserId = processInstance.getStartUserId();
    	            if(taskBo.getVariables() !=null && taskBo.getVariables().containsKey("approval")) {//前端传回的变量值
    	            	SysUser sysUser = commonService.getSysUserByUserName(taskBo.getVariables().get("approval").toString());
    	            	newusername.add(sysUser.getNickName());
    	            }
    	            else {
    	            	for (String oldUser : collect_username) {
    	                  if(StrUtil.equalsAnyIgnoreCase(oldUser,"${INITIATOR}")) {
    	                	  SysUser sysUser = commonService.getSysUserByUserName(startUserId);
    	                      newusername.add(sysUser.getNickName());
    	                  }
    	                  else {
    	                	 SysUser sysUser = commonService.getSysUserByUserName(oldUser);
    	                     newusername.add(sysUser.getNickName());
    	                  }
    	                }
    	            }
                }
                
                //下一个实例节点
                List<Task> listtask = taskService.createTaskQuery().processInstanceId(business.getProcessInstanceId()).active().list();
                Task nexttask = null;
                if(listtask.size()==1) {
                	nexttask = taskService.createTaskQuery().processInstanceId(business.getProcessInstanceId()).active().singleResult();
                }
                else {
                	nexttask = taskService.createTaskQuery().processInstanceId(business.getProcessInstanceId()).active().list().get(0);
                }

                if(nextFlowNodeUserList !=null) {
                	business.setActStatus(ActStatus.doing);
                	business.setTaskId(nexttask.getId());
                	business.setTaskNameId(nextUserTask.getId());
                	business.setTaskName(nextUserTask.getName());
                	business.setPriority(nextUserTask.getPriority());
                    business.setTodoUsers(JSON.toJSONString(newusername));
                }
                else {
                	business.setActStatus(ActStatus.doing);
                	business.setTaskId(nexttask.getId());
                	business.setTaskNameId("");
                	business.setTaskName("");
                	business.setPriority("");
                    business.setTodoUsers("");
                }
                if(ObjectUtil.isNotEmpty(taskBo.getNextApproval())) {
                	business.setActStatus(ActStatus.doing);
                	business.setTaskId(nexttask.getId());
                	business.setTaskNameId(nextUserTask.getId());
                	business.setTaskName(nextUserTask.getName());
                	business.setPriority(nextUserTask.getPriority());
                    business.setTodoUsers(taskBo.getNextApproval());
                }
            }
            else {//**没有下一个节点,流程已经结束了
            	business.setActStatus(ActStatus.pass);
            	business.setTaskId("");
            	business.setTaskNameId("");
            	business.setTaskName("");
                business.setTodoUsers("");
            }
            // 流程处理完后,进行回调业务层
            wfMyBusinessService.updateById(business);
            if (flowCallBackService!=null)flowCallBackService.afterFlowHandle(business);
        }

5、效果图

相关推荐
冰帝海岸5 分钟前
01-spring security认证笔记
java·笔记·spring
世间万物皆对象31 分钟前
Spring Boot核心概念:日志管理
java·spring boot·单元测试
程序视点32 分钟前
【Vue3新工具】Pinia.js:提升开发效率,更轻量、更高效的状态管理方案!
前端·javascript·vue.js·typescript·vue·ecmascript
没书读了1 小时前
ssm框架-spring-spring声明式事务
java·数据库·spring
小二·1 小时前
java基础面试题笔记(基础篇)
java·笔记·python
开心工作室_kaic2 小时前
ssm161基于web的资源共享平台的共享与开发+jsp(论文+源码)_kaic
java·开发语言·前端
刚刚好ā2 小时前
js作用域超全介绍--全局作用域、局部作用、块级作用域
前端·javascript·vue.js·vue
懒洋洋大魔王2 小时前
RocketMQ的使⽤
java·rocketmq·java-rocketmq
武子康2 小时前
Java-06 深入浅出 MyBatis - 一对一模型 SqlMapConfig 与 Mapper 详细讲解测试
java·开发语言·数据仓库·sql·mybatis·springboot·springcloud
转世成为计算机大神2 小时前
易考八股文之Java中的设计模式?
java·开发语言·设计模式