【问题修复】 同一个人多个待办任务,获取待办任务,优先查询传递的 taskId
This commit is contained in:
parent
62a1fa8296
commit
ffa7c246cf
|
@ -207,9 +207,7 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService
|
|||
}
|
||||
|
||||
// 3.1 计算当前登录用户的待办任务
|
||||
// TODO @jason:有一个极端情况,如果一个用户有 2 个 task A 和 B,A 已经通过,B 需要审核。这个时,通过 A 进来,todo 拿到
|
||||
// B,会不会表单权限不一致哈。
|
||||
BpmTaskRespVO todoTask = taskService.getFirstTodoTask(loginUserId, reqVO.getProcessInstanceId());
|
||||
BpmTaskRespVO todoTask = taskService.getTodoTask(loginUserId, reqVO.getTaskId(), reqVO.getProcessInstanceId());
|
||||
// 3.2 预测未运行节点的审批信息
|
||||
List<ActivityNode> simulateActivityNodes = getSimulateApproveNodeList(startUserId, bpmnModel,
|
||||
processDefinitionInfo,
|
||||
|
|
|
@ -35,13 +35,16 @@ public interface BpmTaskService {
|
|||
PageResult<Task> getTaskTodoPage(Long userId, BpmTaskPageReqVO pageReqVO);
|
||||
|
||||
/**
|
||||
* 获得用户在指定流程下,首个需要处理(待办)的任务
|
||||
* 获得用户(待办)的任务。
|
||||
* 1、根据 id 查询待办任务
|
||||
* 2、如果任务不存在,获取指定流程下,首个需要处理任务
|
||||
*
|
||||
* @param userId 用户编号
|
||||
* @param id 任务编号
|
||||
* @param processInstanceId 流程实例编号
|
||||
* @return 待办任务
|
||||
*/
|
||||
BpmTaskRespVO getFirstTodoTask(Long userId, String processInstanceId);
|
||||
BpmTaskRespVO getTodoTask(Long userId, String id, String processInstanceId);
|
||||
|
||||
/**
|
||||
* 获得已办的流程任务分页
|
||||
|
|
|
@ -133,32 +133,19 @@ public class BpmTaskServiceImpl implements BpmTaskService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public BpmTaskRespVO getFirstTodoTask(Long userId, String processInstanceId) {
|
||||
if (processInstanceId == null) {
|
||||
return null;
|
||||
public BpmTaskRespVO getTodoTask(Long userId, String id, String processInstanceId) {
|
||||
// 1.1 获取指定的用户待办任务
|
||||
Task todoTask = getMyTodoTask(userId, id);
|
||||
if (todoTask == null) {
|
||||
// 1.2 获取不到,则获取该流程实例下,第一个用户的待办任务
|
||||
todoTask = getFirstMyTodoTask(userId, processInstanceId);
|
||||
}
|
||||
// 1. 查询所有任务
|
||||
List<Task> tasks = taskService.createTaskQuery()
|
||||
.active()
|
||||
.processInstanceId(processInstanceId)
|
||||
.includeTaskLocalVariables()
|
||||
.includeProcessVariables()
|
||||
.orderByTaskCreateTime().asc() // 按创建时间升序
|
||||
.list();
|
||||
if (CollUtil.isEmpty(tasks)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// 2.1 查询我的首个任务
|
||||
Task todoTask = CollUtil.findOne(tasks, task -> {
|
||||
return isAssignUserTask(userId, task) // 当前用户为审批人
|
||||
|| isAddSignUserTask(userId, task); // 当前用户为加签人(为了减签)
|
||||
});
|
||||
if (todoTask == null) {
|
||||
return null;
|
||||
}
|
||||
// 2.2 查询该任务的子任务
|
||||
List<Task> childrenTasks = getAllChildrenTaskListByParentTaskId(todoTask.getId(), tasks);
|
||||
|
||||
// 2.查询该任务的子任务
|
||||
List<Task> childrenTasks = getAllChildrenTaskListByParentTaskId(todoTask.getId(), CollUtil.newArrayList(todoTask));
|
||||
|
||||
// 3. 转换返回
|
||||
BpmnModel bpmnModel = bpmProcessDefinitionService.getProcessDefinitionBpmnModel(todoTask.getProcessDefinitionId());
|
||||
|
@ -178,6 +165,40 @@ public class BpmTaskServiceImpl implements BpmTaskService {
|
|||
.setNodeType(nodeType).setSignEnable(signEnable).setReasonRequire(reasonRequire);
|
||||
}
|
||||
|
||||
private Task getMyTodoTask(Long userId, String id) {
|
||||
if (StrUtil.isEmpty(id)) {
|
||||
return null;
|
||||
}
|
||||
Task task = getTask(id);
|
||||
if (task == null) {
|
||||
return null;
|
||||
}
|
||||
if (!isAssignUserTask(userId, task) && !isAddSignUserTask(userId, task)) {
|
||||
return null;
|
||||
}
|
||||
return task;
|
||||
}
|
||||
|
||||
private Task getFirstMyTodoTask(Long userId, String processInstanceId) {
|
||||
if (processInstanceId == null) {
|
||||
return null;
|
||||
}
|
||||
// 1. 查询所有任务
|
||||
List<Task> tasks = taskService.createTaskQuery()
|
||||
.active()
|
||||
.processInstanceId(processInstanceId)
|
||||
.includeTaskLocalVariables()
|
||||
.includeProcessVariables()
|
||||
.orderByTaskCreateTime().asc() // 按创建时间升序
|
||||
.list();
|
||||
|
||||
// 2. 查询我的首个任务
|
||||
return CollUtil.findOne(tasks, task -> {
|
||||
return isAssignUserTask(userId, task) // 当前用户为审批人
|
||||
|| isAddSignUserTask(userId, task); // 当前用户为加签人(为了减签)
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<HistoricTaskInstance> getTaskDonePage(Long userId, BpmTaskPageReqVO pageVO) {
|
||||
HistoricTaskInstanceQuery taskQuery = historyService.createHistoricTaskInstanceQuery()
|
||||
|
|
Loading…
Reference in New Issue