更多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、效果图如下: