【问题修复】 同一个人多个待办任务,获取待办任务,优先查询传递的 taskId
This commit is contained in:
parent
62a1fa8296
commit
ffa7c246cf
|
@ -207,9 +207,7 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3.1 计算当前登录用户的待办任务
|
// 3.1 计算当前登录用户的待办任务
|
||||||
// TODO @jason:有一个极端情况,如果一个用户有 2 个 task A 和 B,A 已经通过,B 需要审核。这个时,通过 A 进来,todo 拿到
|
BpmTaskRespVO todoTask = taskService.getTodoTask(loginUserId, reqVO.getTaskId(), reqVO.getProcessInstanceId());
|
||||||
// B,会不会表单权限不一致哈。
|
|
||||||
BpmTaskRespVO todoTask = taskService.getFirstTodoTask(loginUserId, reqVO.getProcessInstanceId());
|
|
||||||
// 3.2 预测未运行节点的审批信息
|
// 3.2 预测未运行节点的审批信息
|
||||||
List<ActivityNode> simulateActivityNodes = getSimulateApproveNodeList(startUserId, bpmnModel,
|
List<ActivityNode> simulateActivityNodes = getSimulateApproveNodeList(startUserId, bpmnModel,
|
||||||
processDefinitionInfo,
|
processDefinitionInfo,
|
||||||
|
|
|
@ -35,13 +35,16 @@ public interface BpmTaskService {
|
||||||
PageResult<Task> getTaskTodoPage(Long userId, BpmTaskPageReqVO pageReqVO);
|
PageResult<Task> getTaskTodoPage(Long userId, BpmTaskPageReqVO pageReqVO);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获得用户在指定流程下,首个需要处理(待办)的任务
|
* 获得用户(待办)的任务。
|
||||||
|
* 1、根据 id 查询待办任务
|
||||||
|
* 2、如果任务不存在,获取指定流程下,首个需要处理任务
|
||||||
*
|
*
|
||||||
* @param userId 用户编号
|
* @param userId 用户编号
|
||||||
|
* @param id 任务编号
|
||||||
* @param processInstanceId 流程实例编号
|
* @param processInstanceId 流程实例编号
|
||||||
* @return 待办任务
|
* @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
|
@Override
|
||||||
public BpmTaskRespVO getFirstTodoTask(Long userId, String processInstanceId) {
|
public BpmTaskRespVO getTodoTask(Long userId, String id, String processInstanceId) {
|
||||||
if (processInstanceId == null) {
|
// 1.1 获取指定的用户待办任务
|
||||||
return null;
|
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) {
|
if (todoTask == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
// 2.2 查询该任务的子任务
|
|
||||||
List<Task> childrenTasks = getAllChildrenTaskListByParentTaskId(todoTask.getId(), tasks);
|
// 2.查询该任务的子任务
|
||||||
|
List<Task> childrenTasks = getAllChildrenTaskListByParentTaskId(todoTask.getId(), CollUtil.newArrayList(todoTask));
|
||||||
|
|
||||||
// 3. 转换返回
|
// 3. 转换返回
|
||||||
BpmnModel bpmnModel = bpmProcessDefinitionService.getProcessDefinitionBpmnModel(todoTask.getProcessDefinitionId());
|
BpmnModel bpmnModel = bpmProcessDefinitionService.getProcessDefinitionBpmnModel(todoTask.getProcessDefinitionId());
|
||||||
|
@ -178,6 +165,40 @@ public class BpmTaskServiceImpl implements BpmTaskService {
|
||||||
.setNodeType(nodeType).setSignEnable(signEnable).setReasonRequire(reasonRequire);
|
.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
|
@Override
|
||||||
public PageResult<HistoricTaskInstance> getTaskDonePage(Long userId, BpmTaskPageReqVO pageVO) {
|
public PageResult<HistoricTaskInstance> getTaskDonePage(Long userId, BpmTaskPageReqVO pageVO) {
|
||||||
HistoricTaskInstanceQuery taskQuery = historyService.createHistoricTaskInstanceQuery()
|
HistoricTaskInstanceQuery taskQuery = historyService.createHistoricTaskInstanceQuery()
|
||||||
|
@ -1230,7 +1251,7 @@ public class BpmTaskServiceImpl implements BpmTaskService {
|
||||||
PROCESS_INSTANCE_VARIABLE_SKIP_START_USER_NODE, String.class));
|
PROCESS_INSTANCE_VARIABLE_SKIP_START_USER_NODE, String.class));
|
||||||
if (userTaskElement.getId().equals(START_USER_NODE_ID)
|
if (userTaskElement.getId().equals(START_USER_NODE_ID)
|
||||||
&& (skipStartUserNodeFlag == null // 目的:一般是“主流程”,发起人节点,自动通过审核
|
&& (skipStartUserNodeFlag == null // 目的:一般是“主流程”,发起人节点,自动通过审核
|
||||||
|| Boolean.TRUE.equals(skipStartUserNodeFlag)) // 目的:一般是“子流程”,发起人节点,按配置自动通过审核
|
|| Boolean.TRUE.equals(skipStartUserNodeFlag)) // 目的:一般是“子流程”,发起人节点,按配置自动通过审核
|
||||||
&& ObjUtil.notEqual(returnTaskFlag, Boolean.TRUE)) {
|
&& ObjUtil.notEqual(returnTaskFlag, Boolean.TRUE)) {
|
||||||
getSelf().approveTask(Long.valueOf(task.getAssignee()), new BpmTaskApproveReqVO().setId(task.getId())
|
getSelf().approveTask(Long.valueOf(task.getAssignee()), new BpmTaskApproveReqVO().setId(task.getId())
|
||||||
.setReason(BpmReasonEnum.ASSIGN_START_USER_APPROVE_WHEN_SKIP_START_USER_NODE.getReason()));
|
.setReason(BpmReasonEnum.ASSIGN_START_USER_APPROVE_WHEN_SKIP_START_USER_NODE.getReason()));
|
||||||
|
|
Loading…
Reference in New Issue