From 73c8f1816ed61da4d944dd5e11c09138523389ae Mon Sep 17 00:00:00 2001 From: panshuling321 Date: Thu, 24 Mar 2022 16:25:07 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E7=A4=BE=E5=8C=BA=E4=BA=BA?= =?UTF-8?q?=E5=91=98=E5=92=8CB=E7=AB=AF=E7=94=A8=E6=88=B7=E5=88=97?= =?UTF-8?q?=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/XhpcCommunityServiceImpl.java | 19 ++++++++++--------- .../impl/XhpcCustomersServiceImpl.java | 11 +++++++---- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/XhpcCommunityServiceImpl.java b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/XhpcCommunityServiceImpl.java index a597d37d..97839c8a 100644 --- a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/XhpcCommunityServiceImpl.java +++ b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/XhpcCommunityServiceImpl.java @@ -22,10 +22,7 @@ import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import java.math.BigDecimal; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Map; +import java.util.*; /** * @author yuyang @@ -62,11 +59,15 @@ public class XhpcCommunityServiceImpl extends BaseService implements IXhpcCommun } } - for (Map commMap: list){ - List> userMapList = xhpcCommunityMapper.communityPersonnelTree(commMap.get("id").toString().replaceAll("COMM_", "")); - if(userMapList.size() > 0){ - commMap.put("children", userMapList); - } + Iterator> iterator = list.iterator(); + while (iterator.hasNext()){ + Map commMap = iterator.next(); + List> userMapList = xhpcCommunityMapper.communityPersonnelTree(commMap.get("id").toString().replaceAll("COMM_", "")); + if (userMapList.size() < 1){ + iterator.remove(); + } else { + commMap.put("children", userMapList); + } } return list; } diff --git a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/XhpcCustomersServiceImpl.java b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/XhpcCustomersServiceImpl.java index 918406a7..86f73756 100644 --- a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/XhpcCustomersServiceImpl.java +++ b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/XhpcCustomersServiceImpl.java @@ -38,7 +38,7 @@ public class XhpcCustomersServiceImpl extends BaseService implements IXhpcCustom @Override public List> userList(HttpServletRequest request,String name){ - List> list =new ArrayList<>(); + List> list = new ArrayList<>(); LoginUser loginUser = tokenService.getLoginUser(request); String userType = loginUser.getSysUser().getUserType(); if(UserTypeUtil.SYS_USER_TYPE_ZERO.equals(userType)){ @@ -47,13 +47,16 @@ public class XhpcCustomersServiceImpl extends BaseService implements IXhpcCustom list = xhpcCustomersMapper.tree(name,loginUser.getSysUser().getOperatorId(),loginUser.getTenantId()); } - for(Map cusMap: list){ + Iterator> iterator = list.iterator(); + while (iterator.hasNext()){ + Map cusMap = iterator.next(); List> userList = xhpcCustomersMapper.customersPersonnelTree(cusMap.get("id").toString().replaceAll("CUS_", "")); - if (userList.size() > 0){ + if (userList.size() < 1){ + iterator.remove(); + } else { cusMap.put("children", userList); } } - return list; }