From d8f69259ec1bc280328be8329dc016c408b16e91 Mon Sep 17 00:00:00 2001 From: syruan <321359594@qq.com> Date: Wed, 16 Oct 2024 16:12:03 +0800 Subject: [PATCH] =?UTF-8?q?=E7=89=A9=E8=B5=84=E9=85=8D=E7=BD=AE=E7=AE=A1?= =?UTF-8?q?=E7=90=86--=E4=BC=98=E5=8C=96=E4=B8=89=E5=9B=9B=E7=BA=A7?= =?UTF-8?q?=E8=8A=82=E7=82=B9=E5=86=85=E5=BE=AA=E7=8E=AF=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ma/controller/MaTypeConfigController.java | 25 +++++++++++-------- .../ma/service/impl/TypeServiceImpl.java | 14 ++++++----- 2 files changed, 22 insertions(+), 17 deletions(-) diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/controller/MaTypeConfigController.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/controller/MaTypeConfigController.java index c7a92273..72fdd1b4 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/controller/MaTypeConfigController.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/controller/MaTypeConfigController.java @@ -96,24 +96,27 @@ public class MaTypeConfigController extends BaseController { } // ------------------- 数据过滤开始 --------------------- - if (maTypeConfigDto != null) { - // 1.根据库管员或维修员用户id过滤数据 - if (maTypeConfigDto.getUserId() != null && maTypeConfigDto.getUserId() != 0L) { - List filterCollected = list.stream(). - filter(maTypeConfigVo -> maTypeConfigVo.getKeeperUserId().equals(maTypeConfigDto.getUserId()) - || - maTypeConfigVo.getRepairUserId().equals(maTypeConfigDto.getUserId() - )) - .collect(Collectors.toList()); - return success(filterCollected); + if (maTypeConfigDto == null || maTypeConfigDto.getUserId() == null || maTypeConfigDto.getUserId() == 0L) { + // 如果参数无效,则返回原始列表 + return success(list); + } + + List filteredList = new ArrayList<>(); + + for (MaTypeConfigVo maTypeConfigVo : list) { + if (maTypeConfigVo.getKeeperUserId().equals(maTypeConfigDto.getUserId()) || + maTypeConfigVo.getRepairUserId().equals(maTypeConfigDto.getUserId()) + ) { + filteredList.add(maTypeConfigVo); } } + + return success(filteredList); // ------------------- 数据过滤结束 --------------------- // -------------------- 数据处理结束 --------------------- - return success(list); } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/impl/TypeServiceImpl.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/impl/TypeServiceImpl.java index a4537a97..0a6b5728 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/impl/TypeServiceImpl.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/impl/TypeServiceImpl.java @@ -164,17 +164,19 @@ public class TypeServiceImpl implements ITypeService { */ @Override public List selectThreeFourLevelTypeListAndParent(Type type) { + // 查询四级节点列表 List fourLevelTypeList = typeMapper.selectFourLevelTypeListAndParent(type); if (fourLevelTypeList != null && !fourLevelTypeList.isEmpty()) { + // 查询三级节点列表 List threeLevelTypeList = typeMapper.selectThreeLevelTypeListAndParent(type); if (threeLevelTypeList != null && !threeLevelTypeList.isEmpty()) { // 循环,把三级节点放入fourLevelTypeList集合中 - for (MaTypeConfigVo threeLevelType : threeLevelTypeList) { - // 循环,把三级节点放入fourLevelTypeList集合中 - for (MaTypeConfigVo fourLevelType : fourLevelTypeList) { - // 如果三级节点的父级id和四级节点的id相同,则把三级节点放入四级节点的children集合中 - if (threeLevelType.getParentId().equals(fourLevelType.getTypeId())) { - fourLevelType.getChildren().add(threeLevelType); + for (MaTypeConfigVo fourLevelType : fourLevelTypeList) { + // 内循环四级节点 + for (MaTypeConfigVo threeLevelType : threeLevelTypeList) { + // 如果四级节点的父级id和三级节点的id相同,则把四级节点放入三级节点的children集合中 + if (fourLevelType.getParentId().equals(threeLevelType.getTypeId())) { + threeLevelType.getChildren().add(fourLevelType); } } }