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