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

相关推荐
装不满的克莱因瓶20 分钟前
【Redis经典面试题六】Redis的持久化机制是怎样的?
java·数据库·redis·持久化·aof·rdb
n北斗27 分钟前
常用类晨考day15
java
骇客野人30 分钟前
【JAVA】JAVA接口公共返回体ResponseData封装
java·开发语言
落魄实习生1 小时前
AI应用-本地模型实现AI生成PPT(简易版)
python·ai·vue·ppt
yuanbenshidiaos2 小时前
c++---------数据类型
java·jvm·c++
向宇it2 小时前
【从零开始入门unity游戏开发之——C#篇25】C#面向对象动态多态——virtual、override 和 base 关键字、抽象类和抽象方法
java·开发语言·unity·c#·游戏引擎
Lojarro2 小时前
【Spring】Spring框架之-AOP
java·mysql·spring
莫名其妙小饼干2 小时前
网上球鞋竞拍系统|Java|SSM|VUE| 前后端分离
java·开发语言·maven·mssql
isolusion2 小时前
Springboot的创建方式
java·spring boot·后端
zjw_rp3 小时前
Spring-AOP
java·后端·spring·spring-aop