!16 优化WfTaskService方法
* fix: 修改接口返回类型 * feat: 增加代办、已办流程变量参数,从而可以实现参数形式关联业务表单 * fix: 优化IService两个方法的返回
This commit is contained in:
@@ -3,6 +3,7 @@ package com.ruoyi.web.controller.workflow;
|
||||
import com.ruoyi.common.core.domain.PageQuery;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.workflow.domain.dto.WfNextDto;
|
||||
import com.ruoyi.workflow.domain.vo.WfTaskVo;
|
||||
import com.ruoyi.workflow.domain.bo.WfTaskBo;
|
||||
import com.ruoyi.workflow.service.IWfTaskService;
|
||||
@@ -77,7 +78,7 @@ public class WfTaskController {
|
||||
@ApiOperation(value = "获取流程变量", response = WfTaskVo.class)
|
||||
@GetMapping(value = "/processVariables/{taskId}")
|
||||
public R processVariables(@ApiParam(value = "流程任务Id") @PathVariable(value = "taskId") String taskId) {
|
||||
return flowTaskService.processVariables(taskId);
|
||||
return R.ok(flowTaskService.getProcessVariables(taskId));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "审批任务")
|
||||
@@ -146,7 +147,8 @@ public class WfTaskController {
|
||||
@ApiOperation(value = "获取下一节点")
|
||||
@PostMapping(value = "/nextFlowNode")
|
||||
public R getNextFlowNode(@RequestBody WfTaskBo bo) {
|
||||
return flowTaskService.getNextFlowNode(bo);
|
||||
WfNextDto wfNextDto = flowTaskService.getNextFlowNode(bo);
|
||||
return wfNextDto != null ? R.ok(wfNextDto) : R.ok("流程已完结", null);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.ruoyi.workflow.service;
|
||||
|
||||
import com.ruoyi.common.core.domain.PageQuery;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.workflow.domain.dto.WfNextDto;
|
||||
import com.ruoyi.workflow.domain.vo.WfTaskVo;
|
||||
import com.ruoyi.workflow.domain.bo.WfTaskBo;
|
||||
import com.ruoyi.workflow.domain.vo.WfViewerVo;
|
||||
@@ -154,15 +154,15 @@ public interface IWfTaskService {
|
||||
|
||||
/**
|
||||
* 获取流程变量
|
||||
* @param taskId
|
||||
* @return
|
||||
* @param taskId 任务ID
|
||||
* @return 流程变量
|
||||
*/
|
||||
R processVariables(String taskId);
|
||||
Map<String, Object> getProcessVariables(String taskId);
|
||||
|
||||
/**
|
||||
* 获取下一节点
|
||||
* @param bo 任务
|
||||
* @return
|
||||
*/
|
||||
R getNextFlowNode(WfTaskBo bo);
|
||||
WfNextDto getNextFlowNode(WfTaskBo bo);
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.ruoyi.common.core.domain.PageQuery;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.common.core.domain.entity.SysRole;
|
||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
@@ -596,6 +595,10 @@ public class WfTaskServiceImpl extends FlowServiceFactory implements IWfTaskServ
|
||||
flowTask.setStartUserId(startUser.getNickName());
|
||||
flowTask.setStartUserName(startUser.getNickName());
|
||||
flowTask.setStartDeptName(startUser.getDept().getDeptName());
|
||||
|
||||
// 流程变量
|
||||
flowTask.setProcVars(this.getProcessVariables(task.getId()));
|
||||
|
||||
flowList.add(flowTask);
|
||||
}
|
||||
|
||||
@@ -652,6 +655,10 @@ public class WfTaskServiceImpl extends FlowServiceFactory implements IWfTaskServ
|
||||
flowTask.setStartUserId(startUser.getNickName());
|
||||
flowTask.setStartUserName(startUser.getNickName());
|
||||
flowTask.setStartDeptName(startUser.getDept().getDeptName());
|
||||
|
||||
// 流程变量
|
||||
flowTask.setProcVars(this.getProcessVariables(histTask.getId()));
|
||||
|
||||
hisTaskList.add(flowTask);
|
||||
}
|
||||
page.setTotal(taskInstanceQuery.count());
|
||||
@@ -893,19 +900,20 @@ public class WfTaskServiceImpl extends FlowServiceFactory implements IWfTaskServ
|
||||
/**
|
||||
* 获取流程变量
|
||||
*
|
||||
* @param taskId
|
||||
* @return
|
||||
* @param taskId 任务ID
|
||||
* @return 流程变量
|
||||
*/
|
||||
@Override
|
||||
public R processVariables(String taskId) {
|
||||
// 流程变量
|
||||
HistoricTaskInstance historicTaskInstance = historyService.createHistoricTaskInstanceQuery().includeProcessVariables().finished().taskId(taskId).singleResult();
|
||||
public Map<String, Object> getProcessVariables(String taskId) {
|
||||
HistoricTaskInstance historicTaskInstance = historyService.createHistoricTaskInstanceQuery()
|
||||
.includeProcessVariables()
|
||||
.finished()
|
||||
.taskId(taskId)
|
||||
.singleResult();
|
||||
if (Objects.nonNull(historicTaskInstance)) {
|
||||
return R.ok(historicTaskInstance.getProcessVariables());
|
||||
} else {
|
||||
Map<String, Object> variables = taskService.getVariables(taskId);
|
||||
return R.ok(variables);
|
||||
return historicTaskInstance.getProcessVariables();
|
||||
}
|
||||
return taskService.getVariables(taskId);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -915,7 +923,7 @@ public class WfTaskServiceImpl extends FlowServiceFactory implements IWfTaskServ
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public R getNextFlowNode(WfTaskBo bo) {
|
||||
public WfNextDto getNextFlowNode(WfTaskBo bo) {
|
||||
Task task = taskService.createTaskQuery().taskId(bo.getTaskId()).singleResult();
|
||||
WfNextDto nextDto = new WfNextDto();
|
||||
if (Objects.nonNull(task)) {
|
||||
@@ -965,10 +973,10 @@ public class WfTaskServiceImpl extends FlowServiceFactory implements IWfTaskServ
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return R.ok("流程已完结", null);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return R.ok(nextDto);
|
||||
return nextDto;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user