| 
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -62,8 +62,8 @@ public class UserServiceImpl implements UserService { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        dataPacket.setDateId(timeDimension.getDateId()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        dataPacket.setMonthId(timeDimension.getMonthId()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        //自上向下检索
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        Map<String, List<AgencySubTreeDto>> agencyMap = agencies.stream().collect(Collectors.groupingBy(AgencySubTreeDto::getAgencyId)); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        //subGridOfAgency key:agencyId ,value:当前组织下的所有网格(即直属网格+下级组织下的所有网格)
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        Map<String,Set<String>> subGridOfAgency = new HashMap<>(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        agencies.forEach(agency -> { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            initAgencyGridMap(agency.getAgencyId(),agency,subGridOfAgency); | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -71,12 +71,13 @@ public class UserServiceImpl implements UserService { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        //对每一个机关进行数据统计
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        if(subGridOfAgency.size() > NumConstant.ZERO){ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            subGridOfAgency.forEach((k,v) -> { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            //如果当前客户存在组织
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            subGridOfAgency.forEach((agencyId,subGridIds) -> { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                queryUserData(ModuleConstant.DIM_SUB_AGENCY, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                        k, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                        (null == agencyMap.get(k) || agencyMap.get(k).isEmpty()) ? NumConstant.ZERO_STR : agencyMap.get(k).get(NumConstant.ZERO).getPid(), | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                        (null == agencyMap.get(k) || agencyMap.get(k).isEmpty()) ? null : agencyMap.get(k).get(NumConstant.ZERO).getCustomerId(), | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                        v, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                        agencyId, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                        // (null == agencyMap.get(agencyId) || agencyMap.get(agencyId).isEmpty()) ? NumConstant.ZERO_STR : agencyMap.get(agencyId).get(NumConstant.ZERO).getPid(),
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                        (null == agencyMap.get(agencyId) || agencyMap.get(agencyId).isEmpty()) ? null : agencyMap.get(agencyId).get(NumConstant.ZERO).getCustomerId(), | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                        subGridIds, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                        targetDate, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                        dataPacket, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                        timeDimension); | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -111,7 +112,7 @@ public class UserServiceImpl implements UserService { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                if(null != v && v.size() > NumConstant.ZERO){ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    queryUserData(ModuleConstant.DIM_BELONGING_GRID, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                            k, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                            v.get(NumConstant.ZERO).getPid(), | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                            // v.get(NumConstant.ZERO).getPid(),
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                            v.get(NumConstant.ZERO).getCustomerId(), | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                            new HashSet<>(v.get(NumConstant.ZERO).getGridIds()), | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                            targetDate, | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -181,22 +182,22 @@ public class UserServiceImpl implements UserService { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    /** | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					     * @Description 初始化机关-所有下级网格Map | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					     * @param pid - 固定一个机关Id | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					     * @param agencyId - 当前组织id | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					     * @param agency - AgencySubTreeDto | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					     * @param subGridOfAgency - Map<String,Set<String>> | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					     * @return | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					     * @author wangc | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					     * @date 2020.06.18 15:54 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					     **/ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    void initAgencyGridMap(String pid, AgencySubTreeDto agency, Map<String,Set<String>> subGridOfAgency){ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    void initAgencyGridMap(String agencyId, AgencySubTreeDto agency, Map<String,Set<String>> subGridOfAgency){ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        //向map中放入数据
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        if(subGridOfAgency.containsKey(pid)){ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        if(subGridOfAgency.containsKey(agencyId)){ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            //包含key
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            Set<String> grids = subGridOfAgency.get(pid); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            Set<String> grids = subGridOfAgency.get(agencyId); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            if(null == grids){ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                grids = new HashSet<>(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                subGridOfAgency.put(pid,grids); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                subGridOfAgency.put(agencyId,grids); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            if(null != agency.getGridIds() && agency.getGridIds().size() > NumConstant.ZERO){ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                grids.addAll(agency.getGridIds()); | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -204,18 +205,20 @@ public class UserServiceImpl implements UserService { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        }else{ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            //不包含key
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            Set<String> grids = new HashSet<>(agency.getGridIds()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            subGridOfAgency.put(pid,grids); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            subGridOfAgency.put(agencyId,grids); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        //外层是从顶级组织向下循环,所以循环到社区时跳出
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        //定义递归出口
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        if(StringUtils.equals(ModuleConstant.AGENCY_LEVEL_COMMUNITY,agency.getLevel()) || null == agency.getSubAgencies() || agency.getSubAgencies().size() == NumConstant.ZERO){ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            return ; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        if (StringUtils.equals(ModuleConstant.AGENCY_LEVEL_COMMUNITY, agency.getLevel()) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                || null == agency.getSubAgencies() | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                || agency.getSubAgencies().size() == NumConstant.ZERO) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            return; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        //定义递归入口
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        agency.getSubAgencies().forEach(obj -> { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            initAgencyGridMap(pid,obj,subGridOfAgency); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            initAgencyGridMap(agencyId,obj,subGridOfAgency); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        }); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -223,7 +226,7 @@ public class UserServiceImpl implements UserService { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					     * @Description 执行查询用户数据统计的逻辑 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					     * @param relation - agency(下级机关加网格) | grid(直属网格) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					     * @param agencyId | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					     * @param pid | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					     * @param //pid 当前agency的父级组织id
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					     * @param customerId | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					     * @param gridIds  -  机关下所有网格集合/机关下直属网格集合 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					     * @param targetDate | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -233,10 +236,12 @@ public class UserServiceImpl implements UserService { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					     * @author wangc | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					     * @date 2020.06.19 10:01 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    **/ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    void queryUserData(String relation, String agencyId, String pid, String customerId, Set<String> gridIds, Date targetDate, UserStatisticalData dataPacket, DimIdGenerator.DimIdBean timeDimension){ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        if(StringUtils.isBlank(pid)) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            pid = NumConstant.ZERO_STR; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    void queryUserData(String relation, String agencyId, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                       // String pid,
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                       String customerId, Set<String> gridIds, Date targetDate, UserStatisticalData dataPacket, DimIdGenerator.DimIdBean timeDimension){ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        //pid没用到还传过来干啥-- 注释掉
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        // if(StringUtils.isBlank(pid))
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        //     pid = NumConstant.ZERO_STR;
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        dataPacket.setCustomerId(customerId); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
				
				 | 
				
					
  |