mirror of
https://gitee.com/hhyykk/ipms-sjy.git
synced 2025-08-07 23:01:52 +08:00
【功能优化】工作流:流程详情的重构 70%:优化 getRunApproveNodeList 方法,处理加签子任务的计算
This commit is contained in:
@@ -30,7 +30,6 @@ public class BpmSimpleModelNodeVO {
|
||||
@Schema(description = "模型节点名称", example = "领导审批")
|
||||
private String name;
|
||||
|
||||
// TODO @jason:和 gpt 大模型对了下这个字段的命名,貌似叫 displayText 合适点。可以等最后我们全局替换下。(优先级:低)
|
||||
@Schema(description = "节点展示内容", example = "指定成员: 芋道源码")
|
||||
private String showText;
|
||||
|
||||
|
@@ -55,7 +55,7 @@ public class BpmTaskRespVO {
|
||||
@Schema(description = "父任务编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
private String parentTaskId;
|
||||
@Schema(description = "子任务列表(由加签生成)", requiredMode = Schema.RequiredMode.REQUIRED, example = "childrenTask")
|
||||
private List<BpmTaskRespVO> children;
|
||||
private List<BpmTaskRespVO> children; // 由加签生成,包含多层子任务
|
||||
|
||||
@Schema(description = "表单编号", example = "1024")
|
||||
private Long formId;
|
||||
|
@@ -30,7 +30,6 @@ import java.util.Map;
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.MapUtils.findAndThen;
|
||||
import static cn.iocoder.yudao.module.bpm.framework.flowable.core.util.FlowableUtils.isAddSignUserTask;
|
||||
import static cn.iocoder.yudao.module.bpm.framework.flowable.core.util.FlowableUtils.isAssignUserTask;
|
||||
|
||||
/**
|
||||
* Bpm 任务 Convert
|
||||
@@ -134,7 +133,8 @@ public interface BpmTaskConvert {
|
||||
Map<Long, DeptRespDTO> deptMap) {
|
||||
return convertList(todoTaskList, task -> {
|
||||
// 找到分配给当前用户,或者当前用户加签的任务(为了减签)
|
||||
if (!isAssignUserTask(userId, task) && !isAddSignUserTask(userId, task, childrenTaskMap)) {
|
||||
if (!FlowableUtils.isAssignUserTask(userId, task)
|
||||
&& !FlowableUtils.isAddSignUserTask(userId, task, childrenTaskMap)) {
|
||||
return null;
|
||||
}
|
||||
BpmTaskRespVO taskVO = BeanUtils.toBean(task, BpmTaskRespVO.class);
|
||||
|
@@ -104,10 +104,6 @@ public interface BpmnModelConstants {
|
||||
* BPMN Start Event Node Id
|
||||
*/
|
||||
String START_EVENT_NODE_ID = "StartEvent";
|
||||
/**
|
||||
* BPMN Start Event Node Name
|
||||
*/
|
||||
String START_EVENT_NODE_NAME = "开始";
|
||||
|
||||
/**
|
||||
* 发起人节点 ID
|
||||
|
@@ -201,7 +201,8 @@ public class FlowableUtils {
|
||||
* @return 是否
|
||||
*/
|
||||
public static boolean isAssignUserTask(Long userId, Task task) {
|
||||
return ObjectUtil.equal(userId, NumberUtil.parseLong(task.getAssignee(), null));
|
||||
Long assignee = NumberUtil.parseLong(task.getAssignee(), null);
|
||||
return ObjectUtil.equal(userId, assignee);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -212,11 +213,13 @@ public class FlowableUtils {
|
||||
* @return 是否
|
||||
*/
|
||||
public static boolean isOwnerUserTask(Long userId, Task task) {
|
||||
return ObjectUtil.equal(userId, NumberUtil.parseLong(task.getOwner(), null));
|
||||
Long assignee = NumberUtil.parseLong(task.getAssignee(), null);
|
||||
return ObjectUtil.equal(userId, assignee);
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断指定用户,是否是当前任务的加签人
|
||||
*
|
||||
* @param userId 用户 Id
|
||||
* @param task 任务
|
||||
* @param childrenTaskMap 子任务集合
|
||||
|
@@ -82,7 +82,8 @@ public class SimpleModelUtils {
|
||||
}
|
||||
|
||||
private static BpmSimpleModelNodeVO buildStartNode() {
|
||||
return new BpmSimpleModelNodeVO().setId(START_EVENT_NODE_ID).setName(START_EVENT_NODE_NAME)
|
||||
return new BpmSimpleModelNodeVO().setId(START_EVENT_NODE_ID)
|
||||
.setName(BpmSimpleModelNodeType.START_USER_NODE.getName())
|
||||
.setType(BpmSimpleModelNodeType.START_NODE.getType());
|
||||
}
|
||||
|
||||
|
File diff suppressed because one or more lines are too long
@@ -131,6 +131,15 @@ public interface BpmTaskService {
|
||||
*/
|
||||
List<UserTask> getUserTaskListByReturn(String id);
|
||||
|
||||
/**
|
||||
* 获取指定任务的子任务列表(多层)
|
||||
*
|
||||
* @param parentTaskId 父任务 ID
|
||||
* @param tasks 任务列表
|
||||
* @return 子任务列表
|
||||
*/
|
||||
List<HistoricTaskInstance> getAllChildrenTaskListByParentTaskId(String parentTaskId, List<HistoricTaskInstance> tasks);
|
||||
|
||||
/**
|
||||
* 获取指定任务的子任务列表
|
||||
*
|
||||
|
@@ -306,6 +306,38 @@ public class BpmTaskServiceImpl implements BpmTaskService {
|
||||
return previousUserList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<HistoricTaskInstance> getAllChildrenTaskListByParentTaskId(String parentTaskId, List<HistoricTaskInstance> tasks) {
|
||||
if (CollUtil.isEmpty(tasks)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
Map<String, List<HistoricTaskInstance>> parentTaskMap = convertMultiMap(
|
||||
filterList(tasks, task -> StrUtil.isNotEmpty(task.getParentTaskId())), HistoricTaskInstance::getParentTaskId);
|
||||
if (CollUtil.isEmpty(parentTaskMap)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
List<HistoricTaskInstance> result = new ArrayList<>();
|
||||
// 1. 递归获取子级
|
||||
Stack<String> stack = new Stack<>();
|
||||
stack.push(parentTaskId);
|
||||
// 2. 递归遍历
|
||||
for (int i = 0; i < Short.MAX_VALUE; i++) {
|
||||
if (stack.isEmpty()) {
|
||||
break;
|
||||
}
|
||||
// 2.1 获取子任务们
|
||||
String taskId = stack.pop();
|
||||
List<HistoricTaskInstance> childTaskList = filterList(tasks, task -> StrUtil.equals(task.getParentTaskId(), taskId));
|
||||
// 2.2 如果非空,则添加到 stack 进一步递归
|
||||
if (CollUtil.isNotEmpty(childTaskList)) {
|
||||
stack.addAll(convertList(childTaskList, HistoricTaskInstance::getId));
|
||||
result.addAll(childTaskList);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得所有子任务列表
|
||||
*
|
||||
|
Reference in New Issue
Block a user