nbcio-boot基于jeecg的flowable支持部门经理的单个或多实例支持(后端部分)

简介: nbcio-boot基于jeecg的flowable支持部门经理的单个或多实例支持(后端部分)

更多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、getNextFlowNode方法修改如下:

/**  modify by nbacheng
     * 获取下一个节点信息,流程定义上的节点信息
     * @param taskId 当前节点id
     * @param values 流程变量
     * @return 如果返回null,表示没有下一个节点,流程结束
     */
    public FlowNextDto getNextFlowNode(String taskId, Map<String, Object> values) {
      //当前节点
        Task task = taskService.createTaskQuery().taskId(taskId).singleResult();
        FlowNextDto flowNextDto = new FlowNextDto();
      if (Objects.nonNull(task)) {
          // 下个任务节点
        if (DelegationState.PENDING.equals(task.getDelegationState())) { //对于委派的处理
            List<UserTask> nextUserTask = FindNextNodeUtil.getNextUserTasks(repositoryService, task, values);
              if (CollectionUtils.isNotEmpty(nextUserTask)) {
                flowNextDto.setType(ProcessConstants.FIXED);//委派是按原来流程执行,所以直接赋值返回
                return flowNextDto;
              }
              else {
                return null;
              }
             }
            List<UserTask> nextUserTask = FindNextNodeUtil.getNextUserTasks(repositoryService, task, values);
            List<SysUser> list = new ArrayList<SysUser>();
            if (CollectionUtils.isNotEmpty(nextUserTask)) {
                for (UserTask userTask : nextUserTask) {
                    MultiInstanceLoopCharacteristics multiInstance = userTask.getLoopCharacteristics();
                    // 会签节点
                    if (ObjectUtils.isNotEmpty(multiInstance)) {
                      List<String> rolelist = new ArrayList<>();
                        rolelist = userTask.getCandidateGroups();
                      List<String> userlist = new ArrayList<>();
                        userlist = userTask.getCandidateUsers();
                        UserTask newUserTask = userTask;
                        if(rolelist.size() != 0 && StringUtils.contains(rolelist.get(0), "${flowExp.getDynamic")) {//对表达式多个动态角色做特殊处理
                          String methodname = StringUtils.substringBetween(rolelist.get(0), ".", "(");
                          Object[] argsPara=new Object[]{};
                          setMultiFlowExp(flowNextDto,newUserTask,multiInstance,methodname,argsPara);
                        }
                        else if(rolelist.size() != 0 && StringUtils.contains(rolelist.get(0), "DepManagerHandler")) {//对部门经理做特殊处理
                          String methodname = "getInitiatorDepManagers";
                          // 获取流程发起人
                        ProcessInstance processInstance = runtimeService
                                     .createProcessInstanceQuery()
                                     .processInstanceId(task.getProcessInstanceId())
                                     .singleResult();
                          String startUserId = processInstance.getStartUserId();
                          Object[] argsPara=new Object[]{};
                          argsPara=new Object[]{startUserId};
                          setMultiFlowExp(flowNextDto,newUserTask,multiInstance,methodname,argsPara);
                        }
                        else if(userlist.size() != 0 && StringUtils.contains(userlist.get(0), "${flowExp.getDynamic")) {//对表达式多个动态用户做特殊处理
                          String methodname = StringUtils.substringBetween(userlist.get(0), ".", "(");
                          Object[] argsPara=new Object[]{};
                          setMultiFlowExp(flowNextDto,newUserTask,multiInstance,methodname,argsPara);
                        }         
                        else if(rolelist.size() > 0) {
              for(String roleId : rolelist ){
                            List<SysUser> templist = iFlowThirdService.getUsersByRoleId(roleId);
                            for(SysUser sysuser : templist) {
                              SysUser sysUserTemp = iFlowThirdService.getUserByUsername(sysuser.getUsername());
                              List<String> listdepname = iFlowThirdService.getDepartNamesByUsername(sysuser.getUsername());
                              if(listdepname.size()>0){
                                sysUserTemp.setOrgCodeTxt(listdepname.get(0).toString());
                              }
                              if(sysUserTemp!= null) {
                                list.add(sysUserTemp);
                              }
                              }
                          }
              setMultiFlowNetDto(flowNextDto,list,userTask,multiInstance);
                        }    
                        else if(userlist.size() > 0) {
                          for(String username : userlist) {
                            SysUser sysUser =  iFlowThirdService.getUserByUsername(username);
                            List<String> listdepname = iFlowThirdService.getDepartNamesByUsername(username);
                            if(listdepname.size()>0){
                              sysUser.setOrgCodeTxt(listdepname.get(0).toString());
                            }
                            if(sysUser != null) {
                              list.add(sysUser);
                            }
                          }
                          setMultiFlowNetDto(flowNextDto,list,userTask,multiInstance);
                        }
                        else {
                          flowNextDto.setType(ProcessConstants.FIXED);
                        }
                  
                    } else {
                        // 读取自定义节点属性 判断是否是否需要动态指定任务接收人员、组,目前只支持用户角色或多用户,还不支持子流程和变量
                        //String dataType = userTask.getAttributeValue(ProcessConstants.NAMASPASE, ProcessConstants.PROCESS_CUSTOM_DATA_TYPE);
                        //String userType = userTask.getAttributeValue(ProcessConstants.NAMASPASE, ProcessConstants.PROCESS_CUSTOM_USER_TYPE);
                        List<String> rolelist = new ArrayList<>();
                        rolelist = userTask.getCandidateGroups();
                        List<String> userlist = new ArrayList<>();
                        userlist = userTask.getCandidateUsers();
                        String assignee = userTask.getAssignee();
                        // 处理加载动态指定下一节点接收人员信息
                        if(assignee !=null) {
                          if(StringUtils.equalsAnyIgnoreCase(assignee, "${INITIATOR}")) {//对发起人做特殊处理
                            SysUser sysUser = new SysUser();
                            sysUser.setUsername("${INITIATOR}");
                            list.add(sysUser);
                            setAssigneeFlowNetDto(flowNextDto,list,userTask);
                          }          
                          else if(StringUtils.contains(assignee, "${flowExp.getDynamicAssignee")) {//对表达式单个动态用户做特殊处理
                            String methodname = StringUtils.substringBetween(assignee, ".", "(");
                            SysUser sysUser = new SysUser();
                            flowExp flowexp = SpringContextUtils.getBean(flowExp.class);
                            Object[] argsPara=new Object[]{};
                            String username = null;
                            try {
                  username = (String) flowexp.invokeMethod(flowexp, methodname,argsPara);
                } catch (Exception e) {
                  e.printStackTrace();
                }
                            sysUser.setUsername(username);
                            list.add(sysUser);
                            setAssigneeFlowNetDto(flowNextDto,list,userTask);
                          }
                          else if(StringUtils.contains(assignee, "${flowExp.getDynamicList")) {//对表达式多个动态用户做特殊处理
                            String methodname = StringUtils.substringBetween(assignee, ".", "(");
                            flowExp flowexp = SpringContextUtils.getBean(flowExp.class);
                            Object[] argsPara=new Object[]{};
                            try {
                              list = (List<SysUser>) flowexp.invokeMethod(flowexp, methodname,argsPara);
                } catch (Exception e) {
                  e.printStackTrace();
                }
                            setUsersFlowNetDto(flowNextDto,list,userTask);
                             
                          }
                          //else if(StringUtils.contains(assignee, "${DepManagerHandler")) {//对部门经理多用户做特殊处理
                          else if(StringUtils.contains(rolelist.get(0), "${DepManagerHandler")) {//对部门经理多用户做特殊处理
                            String methodname = "getInitiatorDepManagers";
                            // 获取流程发起人
                            ProcessInstance processInstance = runtimeService
                                         .createProcessInstanceQuery()
                                         .processInstanceId(task.getProcessInstanceId())
                                         .singleResult();
                              String startUserId = processInstance.getStartUserId();
                            flowExp flowexp = SpringContextUtils.getBean(flowExp.class);
                            Object[] argsPara=new Object[]{};
                            argsPara=new Object[]{startUserId};
                            List<String> strList = new ArrayList<String>();
                            List<SysUser> userList = new ArrayList<SysUser>();
                            try {
                              strList = (List<String>) flowexp.invokeMethod(flowexp, methodname,argsPara);
                } catch (Exception e) {
                  e.printStackTrace();
                }
                            for(String username : strList) {
                                SysUser sysUser =  iFlowThirdService.getUserByUsername(username);
                                List<String> listdepname = iFlowThirdService.getDepartNamesByUsername(username);
                                if(listdepname.size()>0){
                                  sysUser.setOrgCodeTxt(listdepname.get(0).toString());
                                }
                                if(sysUser != null) {
                                  userList.add(sysUser);
                                }
                              }
                            String strAssignee = String.join(",", strList);
                            userTask.setAssignee(strAssignee);
                            
                            setUsersFlowNetDto(flowNextDto,userList,userTask);
                             
                          }
                          else {
                              SysUser sysUser =  iFlowThirdService.getUserByUsername(assignee);
                            List<String> listdepname = iFlowThirdService.getDepartNamesByUsername(assignee);
                            if(listdepname.size()>0){
                               sysUser.setOrgCodeTxt(listdepname.get(0).toString());
                            }
                            if(sysUser != null) {
                              list.add(sysUser);
                            }
                            setAssigneeFlowNetDto(flowNextDto,list,userTask);
                          }
                          
                        }
                        else if(userlist.size()>0 && StringUtils.equalsAnyIgnoreCase(userlist.get(0), "${DepManagerHandler.getUsers(execution)}")) {//对部门经理做特殊处理
                        // 获取流程发起人
                        ProcessInstance processInstance = runtimeService
                                     .createProcessInstanceQuery()
                                     .processInstanceId(task.getProcessInstanceId())
                                     .singleResult();
                             String startUserId = processInstance.getStartUserId();
                        list = getInitiatorDepManagers(startUserId);
                        if(list.size()> 1) {
                          setUsersFlowNetDto(flowNextDto,list,userTask);
                            setMultiFinishFlag(task,flowNextDto,list);
                        }
                        else {
                          setUsersFlowNetDto(flowNextDto,list,userTask);
                        }
                        }
                        else if(userlist.size() > 0) {
                          for(String username : userlist) {
                            SysUser sysUser =  iFlowThirdService.getUserByUsername(username);
                            List<String> listdepname = iFlowThirdService.getDepartNamesByUsername(username);
                            if(listdepname.size()>0){
                              sysUser.setOrgCodeTxt(listdepname.get(0).toString());
                            }
                            if(sysUser != null) {
                              list.add(sysUser);
                            }
                            
                          }
                          setUsersFlowNetDto(flowNextDto,list,userTask);
                          setMultiFinishFlag(task,flowNextDto,list);
                          
                        }
                        else if(rolelist.size() > 0) {
                          if(StringUtils.contains(rolelist.get(0), "${DepManagerHandler")) {//对部门经理多用户做特殊处理
                            String methodname = "getInitiatorDepManagers";
                            // 获取流程发起人
                            ProcessInstance processInstance = runtimeService
                                         .createProcessInstanceQuery()
                                         .processInstanceId(task.getProcessInstanceId())
                                         .singleResult();
                              String startUserId = processInstance.getStartUserId();
                            flowExp flowexp = SpringContextUtils.getBean(flowExp.class);
                            Object[] argsPara=new Object[]{};
                            argsPara=new Object[]{startUserId};
                            List<String> strList = new ArrayList<String>();
                            List<SysUser> userList = new ArrayList<SysUser>();
                            try {
                              strList = (List<String>) flowexp.invokeMethod(flowexp, methodname,argsPara);
                } catch (Exception e) {
                  e.printStackTrace();
                }
                            for(String username : strList) {
                                SysUser sysUser =  iFlowThirdService.getUserByUsername(username);
                                List<String> listdepname = iFlowThirdService.getDepartNamesByUsername(username);
                                if(listdepname.size()>0){
                                  sysUser.setOrgCodeTxt(listdepname.get(0).toString());
                                }
                                if( sysUser != null) {
                                  userList.add(sysUser);
                                }
                                
                              }
                            setUsersFlowNetDto(flowNextDto,userList,userTask);
                             
                          }
                          else {
                            for(String roleId : rolelist ){
                              List<SysUser> templist = iFlowThirdService.getUsersByRoleId(roleId);
                              for(SysUser sysuser : templist) {
                                SysUser sysUserTemp = iFlowThirdService.getUserByUsername(sysuser.getUsername());
                                List<String> listdepname = iFlowThirdService.getDepartNamesByUsername(sysuser.getUsername());
                                if(listdepname.size()>0){
                                  sysUserTemp.setOrgCodeTxt(listdepname.get(0).toString());
                                }
                                if(sysUserTemp != null) {
                                  list.add(sysUserTemp);
                                }
                                
                                }
                            }
                setUsersFlowNetDto(flowNextDto,list,userTask);
                setMultiFinishFlag(task,flowNextDto,list);
                          }
              
                        }
                        else {
                          flowNextDto.setType(ProcessConstants.FIXED);
                        }
                    }
                }
                return flowNextDto;
            } else {
                return null;
          }
       }
       return null;
    }

2、flowRecord方法里的下面代码修改如下

// 展示审批人员
                    List<HistoricIdentityLink> linksForTask = historyService.getHistoricIdentityLinksForTask(histIns.getTaskId());
                    StringBuilder stringBuilder = new StringBuilder();
                    for (HistoricIdentityLink identityLink : linksForTask) {
                        if ("candidate".equals(identityLink.getType())) {
                            if (StringUtils.isNotBlank(identityLink.getUserId())) {
                                SysUser sysUser = iFlowThirdService.getUserByUsername(identityLink.getUserId());
                                if(ObjectUtil.isNotEmpty(sysUser.getRealname())) {
                                  stringBuilder.append(sysUser.getRealname()).append(",");
                                }
                            }
                            if (StringUtils.isNotBlank(identityLink.getGroupId())) {
                               List<SysRole> allRole = iFlowThirdService.getAllRole();
                                 SysRole sysRole = allRole.stream().filter(o -> StringUtils.equals(identityLink.getGroupId(), o.getId())).findAny().orElse(new SysRole());
                                 if(ObjectUtil.isNotEmpty(sysRole.getRoleName())) {
                                   stringBuilder.append(sysRole.getRoleName()).append(",");
                                 }
                            }
                        }
                    }

3、效果图如下:


相关文章
|
1月前
|
弹性计算 监控 负载均衡
|
7月前
|
Web App开发 前端开发 JavaScript
Spring Boot整合 mybatisplus(后端) Vue+echarts+Element UI+axios(前端)---前后端项目实例demo
Spring Boot整合 mybatisplus(后端) Vue+echarts+Element UI+axios(前端)---前后端项目实例demo
153 1
|
SQL XML JSON
Spring之路(25)–Spring Restful+jQuery+Bootstrap开发博客系统实例(API后端开发篇)
本文目录 1. 背景 2. 新建项目 3. 导入jar包 4. 修改web.xml加载spring配置 5. 新建springmvc-config.xml,配置容器信息 6. 添加数据库操作类DbHelper 7. 添加博客服务类BlogService与数据对象BlogBo 8. BlogController实现Restful API 9. 浏览器简单测试 10.总结
142 0
Spring之路(25)–Spring Restful+jQuery+Bootstrap开发博客系统实例(API后端开发篇)
|
关系型数据库 RDS
PolarDB-X 1.0-常见问题-连接调整问题-PolarDB-X实例与RDS实例的后端连接数是如何计算的?
关于PolarDB-X后端连接数的计算方法,请参见实例中的连接。
346 0
|
移动开发 前端开发
使用 layui 后端分页的实例
前端代码 写文章 搜索 ...
4731 0
|
JavaScript 前端开发 Java
Javascript前端和JAVA后端对加密库的处理实例
前端加密 Javascript的加解密有开源的库,http://www.oschina.net/p/crypto-js/ 如下是具体的使用例子 //引入的js文件在该链接中:https://github.
1422 0
|
Java 关系型数据库 MySQL
spring学习笔记(19)mysql读写分离后端AOP控制实例
<div class="markdown_views"> <p>在这里,我们接上一篇文章,利用JNDI访问应用服务器配置的两个数据源来模拟同时操作不同的数据库如同时操作mysql和oracle等。实际上,上个例子可能用来模拟mysql数据库主从配置读写分离更贴切些。既然如此,在本例中,我们就完成读写分离的模拟在web端的配置实例。</p> <p>续上次的例子,关于JNDI数据
2479 0
|
Java API 数据安全/隐私保护
Web后端语言模拟http请求(带用户名和密码)实例代码大全
RESTful API是目前比较成熟的一套互联网应用程序的API设计理论。而随着RESTful API的成熟和流行,应用开发方面就需要以模拟http请求的方式来调用RESTful API接口;经过一段时间的IBM的云平台Blumemix的学习及语言翻译服务的应用,积累了Java、ASP.NET、Nodejs、Go、PHP、Python、Ruby等语言调用Rest API的方法,这里整理到一起,和大家分享一下。
1795 0
|
16天前
|
存储 缓存 负载均衡
后端开发中的性能优化策略
本文将探讨几种常见的后端性能优化策略,包括代码层面的优化、数据库查询优化、缓存机制的应用以及负载均衡的实现。通过这些方法,开发者可以显著提升系统的响应速度和处理能力,从而提供更好的用户体验。
43 4

热门文章

最新文章