基于若依的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、效果图

相关推荐
李长渊哦14 分钟前
Java 虚拟机(JVM)方法区详解
java·开发语言·jvm
陌殇殇1 小时前
002 SpringCloudAlibaba整合 - Feign远程调用、Loadbalancer负载均衡
java·spring cloud·微服务
猎人everest2 小时前
SpringBoot应用开发入门
java·spring boot·后端
山猪打不过家猪4 小时前
ASP.NET Core Clean Architecture
java·数据库·asp.net
AllowM4 小时前
【LeetCode Hot100】除自身以外数组的乘积|左右乘积列表,Java实现!图解+代码,小白也能秒懂!
java·算法·leetcode
不会Hello World的小苗5 小时前
Java——列表(List)
java·python·list
二十七剑6 小时前
jvm中各个参数的理解
java·jvm
Pro_er6 小时前
Vue3响应式编程三剑客:计算属性、方法与侦听器深度实战指南
vue·前端开发
东阳马生架构7 小时前
JUC并发—9.并发安全集合四
java·juc并发·并发安全的集合
计算机小白一个8 小时前
蓝桥杯 Java B 组之岛屿数量、二叉树路径和(区分DFS与回溯)
java·数据结构·算法·蓝桥杯