feat: 【工作流】--任务列表只返回顶级任务,拼装成父子关系并返回

This commit is contained in:
kehaiyou 2023-10-08 22:35:02 +08:00
parent d7ae944438
commit 10af05066c
3 changed files with 22 additions and 1 deletions

View File

@ -5,6 +5,8 @@ import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import lombok.ToString; import lombok.ToString;
import java.util.List;
@Schema(description = "管理后台 - 流程任务的 Response VO") @Schema(description = "管理后台 - 流程任务的 Response VO")
@Data @Data
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@ -24,6 +26,9 @@ public class BpmTaskRespVO extends BpmTaskDonePageItemRespVO {
*/ */
private String parentTaskId; private String parentTaskId;
@Schema(description = "子任务(由加签生成)", requiredMode = Schema.RequiredMode.REQUIRED, example = "childrenTask")
private List<BpmTaskRespVO> children;
@Schema(description = "用户信息") @Schema(description = "用户信息")
@Data @Data
public static class User { public static class User {

View File

@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.bpm.convert.task; package cn.iocoder.yudao.module.bpm.convert.task;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.LocalDateTimeUtil; import cn.hutool.core.date.LocalDateTimeUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
@ -178,4 +179,18 @@ public interface BpmTaskConvert {
return bpmTaskSubSignRespVO; return bpmTaskSubSignRespVO;
}); });
} }
/**
* 转换任务为父子级
* @param result
* @return
*/
default List<BpmTaskRespVO> convertChildrenList(List<BpmTaskRespVO> result){
List<BpmTaskRespVO> childrenTaskList = CollectionUtils.filterList(result, r -> StrUtil.isNotEmpty(r.getParentTaskId()));
Map<String, List<BpmTaskRespVO>> parentChildrenTaskListMap = CollectionUtils.convertMultiMap(childrenTaskList, BpmTaskRespVO::getParentTaskId);
for (BpmTaskRespVO bpmTaskRespVO : result) {
bpmTaskRespVO.setChildren(parentChildrenTaskListMap.get(bpmTaskRespVO.getId()));
}
return CollectionUtils.filterList(result, r -> StrUtil.isEmpty(r.getParentTaskId()));
}
} }

View File

@ -193,7 +193,8 @@ public class BpmTaskServiceImpl implements BpmTaskService {
Map<Long, DeptRespDTO> deptMap = deptApi.getDeptMap(convertSet(userMap.values(), AdminUserRespDTO::getDeptId)); Map<Long, DeptRespDTO> deptMap = deptApi.getDeptMap(convertSet(userMap.values(), AdminUserRespDTO::getDeptId));
// 拼接数据 // 拼接数据
return BpmTaskConvert.INSTANCE.convertList3(tasks, bpmTaskExtDOMap, processInstance, userMap, deptMap); List<BpmTaskRespVO> result = BpmTaskConvert.INSTANCE.convertList3(tasks, bpmTaskExtDOMap, processInstance, userMap, deptMap);
return BpmTaskConvert.INSTANCE.convertChildrenList(result);
} }
@Override @Override