当前位置:   article > 正文

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

基于若依的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

  1. // 流程发起人信息
  2. HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery()
  3. .processInstanceId(task.getProcessInstanceId())
  4. .singleResult();
  5. String userId = historicProcessInstance.getStartUserId();
  6. String nickName = sysUserService.selectUserByUserName(userId).getNickName();
  7. flowTask.setStartUserId(userId);
  8. flowTask.setStartUserName(nickName);
  9. flowTask.setDataId(historicProcessInstance.getBusinessKey());

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

  1. // 跳转到处理页面
  2. handleProcess(row) {
  3. this.$router.push({
  4. path: '/workflow/process/detail/' + row.procInsId,
  5. query: {
  6. taskId: row.taskId,
  7. dataId: row.dataId,
  8. processed: true
  9. }
  10. })
  11. },

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

  1. initData() {
  2. this.taskForm.procInsId = this.$route.params && this.$route.params.procInsId;
  3. this.taskForm.taskId = this.$route.query && this.$route.query.taskId;
  4. this.taskForm.dataId = this.$route.query && this.$route.query.dataId;
  5. this.processed = this.$route.query && eval(this.$route.query.processed || false);

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

  1. //处理自定义业务表单回写状态,节点与处理人信息
  2. if (StringUtils.isNotBlank(taskBo.getDataId())) {
  3. //业务数据id
  4. String dataId = taskBo.getDataId();
  5. //如果保存数据前未调用必调的FlowCommonService.initActBusiness方法,就会有问题
  6. WfMyBusiness business = wfMyBusinessService.getByDataId(dataId);
  7. //spring容器类名
  8. String serviceImplName = business.getServiceImplName();
  9. WfCallBackServiceI flowCallBackService = (WfCallBackServiceI) SpringContextUtils.getBean(serviceImplName);
  10. FlowNextDto flowNextDto = this.getNextFlowNode(taskBo.getTaskId(), taskBo.getVariables());
  11. if(flowNextDto != null) {
  12. //**有下一个节点
  13. UserTask nextUserTask = flowNextDto.getUserTask();
  14. //能够处理下个节点的候选人
  15. List<SysUser> nextFlowNodeUserList = flowNextDto.getUserList();
  16. List<String> newusername = new ArrayList<String>();
  17. if(nextFlowNodeUserList != null && nextFlowNodeUserList.get(0) != null ) {
  18. List<String> collect_username = nextFlowNodeUserList.stream().filter(Objects::nonNull).filter(item->item.getUserName()!=null).map(SysUser::getUserName).collect(Collectors.toList());
  19. //collect_username转换成realname
  20. // 流程发起人
  21. ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(taskBo.getProcInsId()).singleResult();
  22. String startUserId = processInstance.getStartUserId();
  23. if(taskBo.getVariables() !=null && taskBo.getVariables().containsKey("approval")) {//前端传回的变量值
  24. SysUser sysUser = commonService.getSysUserByUserName(taskBo.getVariables().get("approval").toString());
  25. newusername.add(sysUser.getNickName());
  26. }
  27. else {
  28. for (String oldUser : collect_username) {
  29. if(StrUtil.equalsAnyIgnoreCase(oldUser,"${INITIATOR}")) {
  30. SysUser sysUser = commonService.getSysUserByUserName(startUserId);
  31. newusername.add(sysUser.getNickName());
  32. }
  33. else {
  34. SysUser sysUser = commonService.getSysUserByUserName(oldUser);
  35. newusername.add(sysUser.getNickName());
  36. }
  37. }
  38. }
  39. }
  40. //下一个实例节点
  41. List<Task> listtask = taskService.createTaskQuery().processInstanceId(business.getProcessInstanceId()).active().list();
  42. Task nexttask = null;
  43. if(listtask.size()==1) {
  44. nexttask = taskService.createTaskQuery().processInstanceId(business.getProcessInstanceId()).active().singleResult();
  45. }
  46. else {
  47. nexttask = taskService.createTaskQuery().processInstanceId(business.getProcessInstanceId()).active().list().get(0);
  48. }
  49. if(nextFlowNodeUserList !=null) {
  50. business.setActStatus(ActStatus.doing);
  51. business.setTaskId(nexttask.getId());
  52. business.setTaskNameId(nextUserTask.getId());
  53. business.setTaskName(nextUserTask.getName());
  54. business.setPriority(nextUserTask.getPriority());
  55. business.setTodoUsers(JSON.toJSONString(newusername));
  56. }
  57. else {
  58. business.setActStatus(ActStatus.doing);
  59. business.setTaskId(nexttask.getId());
  60. business.setTaskNameId("");
  61. business.setTaskName("");
  62. business.setPriority("");
  63. business.setTodoUsers("");
  64. }
  65. if(ObjectUtil.isNotEmpty(taskBo.getNextApproval())) {
  66. business.setActStatus(ActStatus.doing);
  67. business.setTaskId(nexttask.getId());
  68. business.setTaskNameId(nextUserTask.getId());
  69. business.setTaskName(nextUserTask.getName());
  70. business.setPriority(nextUserTask.getPriority());
  71. business.setTodoUsers(taskBo.getNextApproval());
  72. }
  73. }
  74. else {//**没有下一个节点,流程已经结束了
  75. business.setActStatus(ActStatus.pass);
  76. business.setTaskId("");
  77. business.setTaskNameId("");
  78. business.setTaskName("");
  79. business.setTodoUsers("");
  80. }
  81. // 流程处理完后,进行回调业务层
  82. wfMyBusinessService.updateById(business);
  83. if (flowCallBackService!=null)flowCallBackService.afterFlowHandle(business);
  84. }

5、效果图

声明:本文内容由网友自发贡献,转载请注明出处:【wpsshop博客】
推荐阅读
相关标签
  

闽ICP备14008679号