perf(bpm): 优化流程 CC 列表接口性能

- 在处理流程 CC 列表时,增加了对结果列表的非空判断
- 只有在列表非空的情况下,才进行部门和用户组信息的查询和设置
- 这样可以减少不必要的 API调用,提高接口性能
This commit is contained in:
furongxin 2025-03-10 21:11:01 +08:00
parent 2ffd3ffadb
commit e401eef546

View File

@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.bpm.controller.admin.definition; package cn.iocoder.yudao.module.bpm.controller.admin.definition;
import cn.hutool.core.collection.CollUtil;
import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils; import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
@ -85,27 +86,31 @@ public class BpmProcessCcController {
PageResult<BpmProcessCcDO> pageResult = processCcService.getProcessCcPage(pageReqVO); PageResult<BpmProcessCcDO> pageResult = processCcService.getProcessCcPage(pageReqVO);
PageResult<BpmProcessCcRespVO> respVOPageResult = BeanUtils.toBean(pageResult, BpmProcessCcRespVO.class); PageResult<BpmProcessCcRespVO> respVOPageResult = BeanUtils.toBean(pageResult, BpmProcessCcRespVO.class);
// 获取公司部门Map if (CollUtil.isNotEmpty(respVOPageResult.getList())) {
Map<Long, DeptRespDTO> deptMap = convertMap(deptApi.getCompanyDept().getCheckedData(), DeptRespDTO::getId);
// 获取列表中所有用户组详情
List<BpmUserGroupDO> groupDOS = groupService.getUserGroupList(
respVOPageResult.getList().stream()
.flatMap(item -> item.getUserGroupId().stream())
.collect(Collectors.toSet()));
// 转换Map
Map<Long, String> groupNameMap = convertMap(groupDOS, BpmUserGroupDO::getId, BpmUserGroupDO::getName);
respVOPageResult.getList().forEach(data -> { // 获取公司部门Map
Map<Long, DeptRespDTO> deptMap = convertMap(deptApi.getCompanyDept().getCheckedData(), DeptRespDTO::getId);
// 获取列表中所有用户组详情
List<BpmUserGroupDO> groupDOS = groupService.getUserGroupList(
respVOPageResult.getList().stream()
.flatMap(item -> item.getUserGroupId().stream())
.collect(Collectors.toSet()));
// 转换Map
Map<Long, String> groupNameMap = convertMap(groupDOS, BpmUserGroupDO::getId, BpmUserGroupDO::getName);
respVOPageResult.getList().forEach(data -> {
// 设置用户组名称
data.setGroupName(data.getUserGroupId().stream()
.map(groupNameMap::get)
.collect(Collectors.joining("")));
// 设置公司名称
data.setCompanyName(data.getCompanyDeptId().stream()
.map(item -> deptMap.get(item) != null ? deptMap.get(item).getName() : "")
.collect(Collectors.joining("")));
});
}
// 设置用户组名称
data.setGroupName(data.getUserGroupId().stream()
.map(groupNameMap::get)
.collect(Collectors.joining("")));
// 设置公司名称
data.setCompanyName(data.getCompanyDeptId().stream()
.map(item -> deptMap.get(item) != null ? deptMap.get(item).getName() : "")
.collect(Collectors.joining("")));
});
return success(respVOPageResult); return success(respVOPageResult);
} }
} }