From 4b4491588c7c28576da9a56e9736584aebe1bf5d Mon Sep 17 00:00:00 2001 From: wangchao Date: Fri, 19 Jun 2020 15:54:01 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9F=A5=E8=AF=A2agency=E7=9A=84=E6=89=80?= =?UTF-8?q?=E6=9C=89=E4=B8=8B=E7=BA=A7=E7=BD=91=E6=A0=BCId=E9=80=BB?= =?UTF-8?q?=E8=BE=91=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/user/impl/UserServiceImpl.java | 27 ++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/user/impl/UserServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/user/impl/UserServiceImpl.java index 6ac8e6294b..cef6dbe508 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/user/impl/UserServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/user/impl/UserServiceImpl.java @@ -35,22 +35,22 @@ public class UserServiceImpl implements UserService { /** * @Description 遍历所有机关(它的下级机关)统计注册用户和参与用户的数据,使用level控制 - * @param topAgencies - List + * @param agencies - List * @return * @author wangc * @date 2020.06.18 10:03 **/ @Override - public void traverseAgencyUser(List topAgencies, Date targetDate) { - if(null == topAgencies || topAgencies.size() == NumConstant.ZERO){ + public void traverseAgencyUser(List agencies, Date targetDate) { + if(null == agencies || agencies.size() == NumConstant.ZERO){ logger.warn("没有相应的机关集合"); return ; } //自上向下检索 //Map> agencyMap = agencies.stream().collect(Collectors.groupingBy(AgencySubTreeDto::getAgencyId)); Map> subGridOfAgency = new HashMap<>(); - topAgencies.forEach(agency -> { - initAgencyGridMap(agency,subGridOfAgency); + agencies.forEach(agency -> { + initAgencyGridMap(agency.getAgencyId(),agency,subGridOfAgency); }); //对每一个机关进行数据统计 @@ -86,6 +86,7 @@ public class UserServiceImpl implements UserService { } } + /** * @Description 初始化机关-所有下级网格Map * @param agency - AgencySubTreeDto @@ -93,15 +94,16 @@ public class UserServiceImpl implements UserService { * @return * @author wangc * @date 2020.06.18 15:54 - **/ - void initAgencyGridMap(AgencySubTreeDto agency, Map> subGridOfAgency){ + **/ + void initAgencyGridMap(String pid, AgencySubTreeDto agency, Map> subGridOfAgency){ + //向map中放入数据 - if(subGridOfAgency.containsKey(agency.getAgencyId())){ + if(subGridOfAgency.containsKey(pid)){ //包含key - Set grids = subGridOfAgency.get(agency.getAgencyId()); + Set grids = subGridOfAgency.get(pid); if(null == grids){ grids = new HashSet<>(); - subGridOfAgency.put(agency.getAgencyId(),grids); + subGridOfAgency.put(pid,grids); } if(null != agency.getGridIds() && agency.getGridIds().size() > NumConstant.ZERO){ grids.addAll(agency.getGridIds()); @@ -109,7 +111,7 @@ public class UserServiceImpl implements UserService { }else{ //不包含key Set grids = new HashSet<>(agency.getGridIds()); - subGridOfAgency.put(agency.getAgencyId(),grids); + subGridOfAgency.put(pid,grids); } //定义递归出口 @@ -117,9 +119,10 @@ public class UserServiceImpl implements UserService { return ; } + //定义递归入口 agency.getSubAgencies().forEach(obj -> { - initAgencyGridMap(obj,subGridOfAgency); + initAgencyGridMap(pid,obj,subGridOfAgency); }); }