| 
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -67,11 +67,12 @@ public class DemandServiceImpl implements DemandService { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    /** | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					     * 清理旧数据 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					     * @param yestoday | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					     * @param targetDate 要清理哪天的数据 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					     * @param customerIds 要清理哪些客户的 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					     */ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    private void clearOldDatas(List<String> customerIds, Date yestoday) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    private void clearOldDatas(List<String> customerIds, Date targetDate) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        String dateDimId = DimIdGenerator.getDateDimId(yestoday); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        String dateDimId = DimIdGenerator.getDateDimId(targetDate); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        demandStatsService.clearVolunteerDemandServiceDailyStats(customerIds, dateDimId); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -90,50 +91,40 @@ public class DemandServiceImpl implements DemandService { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        // 居民志愿者数量
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        Integer resiVolunteerCount = 0; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        // 党员志愿者用户id列表
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        List<String> partymemberVolunteerUserIds = new ArrayList<>(16); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        int pageNum = 1; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        int volunteerPageSize = 5; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        List<VolunteerInfoEntity> volunteers = heartVolunteerService.listVolunteers(customerId, endTime); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        while (true) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            int shardingStartIndex = 0; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            int shardingSize = 2; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        volunteerTotalCount = volunteers.size(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            List<VolunteerInfoEntity> volunteersPage = heartVolunteerService.listVolunteersPage(customerId, endTime, pageNum, volunteerPageSize); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        // 分片开始下标
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        int shardingStartIndex = 0; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        // 分片大小(条数)
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        int shardingSize = 2; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					         | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        // 分片去确定党员身份,防止in条件过大
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        while (true) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            int realShardingSize = Math.min(shardingSize, volunteerTotalCount - shardingStartIndex); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            // 如果查询结果为0,说明没有更多的志愿者了
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            if (volunteersPage.size() == 0) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            if (realShardingSize <= 0) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                break; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            volunteerTotalCount += volunteersPage.size(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            // 分片去确定党员身份
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            while (true) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                int realShardingSize = Math.min(shardingSize, volunteersPage.size() - shardingStartIndex); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            int shardingEndIndex = shardingStartIndex + realShardingSize; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            List<String> volunteerUserIds = volunteers.subList(shardingStartIndex, shardingEndIndex) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    .stream() | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    .map((volunteerInfoEntity) -> volunteerInfoEntity.getUserId()) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    .collect(Collectors.toList()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                if (realShardingSize == 0) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    break; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                int shardingEndIndex = shardingStartIndex + realShardingSize; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                List<String> volunteerUserIds = volunteersPage.subList(shardingStartIndex, shardingEndIndex) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                        .stream() | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                        .map((volunteerInfoEntity) -> volunteerInfoEntity.getUserId()) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                        .collect(Collectors.toList()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                List<String> tempPartymemberUserIds = userService.filterUserIds(volunteerUserIds, EpmetRoleKeyConstant.PARTYMEMBER); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            List<String> tempPartymemberUserIds = userService.filterUserIds(volunteerUserIds, EpmetRoleKeyConstant.PARTYMEMBER); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                partymemberVolunteerUserIds.addAll(tempPartymemberUserIds); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                shardingStartIndex = shardingEndIndex; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            partymemberVolunteerUserIds.addAll(tempPartymemberUserIds); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            pageNum++; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            shardingStartIndex = shardingEndIndex; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        partymemberVolunteerCount += partymemberVolunteerUserIds.size(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        partymemberVolunteerCount = partymemberVolunteerUserIds.size(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        resiVolunteerCount = volunteerTotalCount - partymemberVolunteerCount; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        //2. 查询志愿者服务次数
 | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
				
				 | 
				
					
  |