|  |  | @ -41,11 +41,13 @@ import com.epmet.dto.form.GroupPointFormDTO; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.feign.GovOrgOpenFeignClient; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.resi.group.dto.group.form.GroupFormDTO; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.resi.group.dto.group.form.GroupPointDetailFormDTO; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.resi.group.dto.group.form.GroupsByMemberFormDTO; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.resi.group.dto.group.result.GroupDetailResultDTO; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.resi.group.dto.group.result.GroupPointDetailResultDTO; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.dto.result.GroupPointRankingResultDTO; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.entity.BizPointTotalDetailEntity; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.resi.group.dto.group.ResiGroupDTO; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.resi.group.dto.group.result.RankingResultDTO; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.resi.group.enums.SearchScopeTypeEnum; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.resi.group.feign.ResiGroupOpenFeignClient; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.service.BizPointTotalDetailService; | 
			
		
	
	
		
			
				
					|  |  | @ -261,7 +263,7 @@ public class BizPointTotalDetailServiceImpl extends BaseServiceImpl<BizPointTota | 
			
		
	
		
			
				
					|  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |     @Override | 
			
		
	
		
			
				
					|  |  |  |     public PageData<GroupPointRankingResultDTO> listGroupPointRandingInGridScope(SearchScopeTypeEnum searchScopeType, String searchScopeId, Integer pageNo, Integer pageSize) { | 
			
		
	
		
			
				
					|  |  |  |     public List<GroupPointRankingResultDTO> listGroupPointRandingInPercificScope(SearchScopeTypeEnum searchScopeType, String searchScopeId, Integer pageNo, Integer pageSize) { | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |         // 1.查询有积分的小组得分排名
 | 
			
		
	
		
			
				
					|  |  |  |         PageInfo<BizPointTotalDetailEntity> entityPageInfo = PageHelper.startPage(pageNo, pageSize).doSelectPageInfo(() -> { | 
			
		
	
	
		
			
				
					|  |  | @ -306,17 +308,23 @@ public class BizPointTotalDetailServiceImpl extends BaseServiceImpl<BizPointTota | 
			
		
	
		
			
				
					|  |  |  |             rankingInfoDTOs.addAll(gap); | 
			
		
	
		
			
				
					|  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |         // 4.排名填充
 | 
			
		
	
		
			
				
					|  |  |  |         // 4.排名填充。有积分的按照积分排序,分数一样的名次一样
 | 
			
		
	
		
			
				
					|  |  |  |         Integer ranking = page.getStartRow() + 1; | 
			
		
	
		
			
				
					|  |  |  |         Integer prevPoint = null; | 
			
		
	
		
			
				
					|  |  |  |         for (GroupPointRankingResultDTO g : rankingInfoDTOs) { | 
			
		
	
		
			
				
					|  |  |  |             Integer point = Integer.valueOf(g.getPoint()); | 
			
		
	
		
			
				
					|  |  |  |             if (prevPoint != null && prevPoint > point) { | 
			
		
	
		
			
				
					|  |  |  |                 // 此举是为了在积分一样的情况下,给与相同的排名
 | 
			
		
	
		
			
				
					|  |  |  |                 ranking ++; | 
			
		
	
		
			
				
					|  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |             GridInfoCache gridInfo = getGridInfo(g.getGridId()); | 
			
		
	
		
			
				
					|  |  |  |             g.setRanking(String.valueOf(ranking)); | 
			
		
	
		
			
				
					|  |  |  |             g.setGridId(g.getGridId()); | 
			
		
	
		
			
				
					|  |  |  |             g.setGridNamePath(gridInfo.getGridNamePath()); | 
			
		
	
		
			
				
					|  |  |  |             ranking ++; | 
			
		
	
		
			
				
					|  |  |  |             g.setRanking(String.valueOf(ranking)); | 
			
		
	
		
			
				
					|  |  |  |             prevPoint = point; | 
			
		
	
		
			
				
					|  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |         PageData<GroupPointRankingResultDTO> pageData = new PageData<>(rankingInfoDTOs, entityPageInfo.getTotal()); | 
			
		
	
		
			
				
					|  |  |  |         return pageData; | 
			
		
	
		
			
				
					|  |  |  |         return rankingInfoDTOs; | 
			
		
	
		
			
				
					|  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |     /** | 
			
		
	
	
		
			
				
					|  |  | @ -422,4 +430,61 @@ public class BizPointTotalDetailServiceImpl extends BaseServiceImpl<BizPointTota | 
			
		
	
		
			
				
					|  |  |  |         ope.putAll(RedisKeys.getGridInfoKey(gridId), BeanUtil.beanToMap(cache)); | 
			
		
	
		
			
				
					|  |  |  |         return cache; | 
			
		
	
		
			
				
					|  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |     @Override | 
			
		
	
		
			
				
					|  |  |  |     public List<GroupPointRankingResultDTO> listMyGroupPointRanding(String userId, String gridId) { | 
			
		
	
		
			
				
					|  |  |  |         // 1.查询网格内我所在的小组
 | 
			
		
	
		
			
				
					|  |  |  |         GroupsByMemberFormDTO form = new GroupsByMemberFormDTO(); | 
			
		
	
		
			
				
					|  |  |  |         form.setGridId(gridId); | 
			
		
	
		
			
				
					|  |  |  |         form.setUserId(userId); | 
			
		
	
		
			
				
					|  |  |  |         List<GroupDetailResultDTO> groupList = getResultDataOrThrowsException(resiGroupOpenFeignClient.listGroupsByMember(form), | 
			
		
	
		
			
				
					|  |  |  |                 ServiceConstant.RESI_GROUP_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), "【我所在的小组排名】查询组列表失败"); | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |         if (CollectionUtils.isEmpty(groupList)) { | 
			
		
	
		
			
				
					|  |  |  |             return new ArrayList(); | 
			
		
	
		
			
				
					|  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |         // 2.填充分数和排名
 | 
			
		
	
		
			
				
					|  |  |  |         GroupDetailResultDTO firstGroup = groupList.get(0); | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |         // 网格和客户下,分别有多少个有积分的小组,后面用于给哪些没有任何积分记录的小组排名
 | 
			
		
	
		
			
				
					|  |  |  |         Integer gridMinRanking = baseDao.getMinRanking("group", "grid", gridId); | 
			
		
	
		
			
				
					|  |  |  |         Integer customerMinRanking = baseDao.getMinRanking("group", "customer", firstGroup.getCustomerId()); | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |         List<GroupPointRankingResultDTO> groupDtoList = groupList.stream().map(g -> { | 
			
		
	
		
			
				
					|  |  |  |             // 积分
 | 
			
		
	
		
			
				
					|  |  |  |             Integer point = 0; | 
			
		
	
		
			
				
					|  |  |  |             // 网格内的排名
 | 
			
		
	
		
			
				
					|  |  |  |             Integer gridRanking = null; | 
			
		
	
		
			
				
					|  |  |  |             // 客户下的排名
 | 
			
		
	
		
			
				
					|  |  |  |             Integer customerRanking = null; | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |             LambdaQueryWrapper<BizPointTotalDetailEntity> query = new LambdaQueryWrapper<>(); | 
			
		
	
		
			
				
					|  |  |  |             query.eq(BizPointTotalDetailEntity::getBizType, "group"); | 
			
		
	
		
			
				
					|  |  |  |             query.eq(BizPointTotalDetailEntity::getObjectId, g.getGroupId()); | 
			
		
	
		
			
				
					|  |  |  |             BizPointTotalDetailEntity groupPoint = baseDao.selectOne(query); | 
			
		
	
		
			
				
					|  |  |  |             if (groupPoint == null) { | 
			
		
	
		
			
				
					|  |  |  |                 // 该小组没有积分
 | 
			
		
	
		
			
				
					|  |  |  |                 gridRanking = gridMinRanking + 1; | 
			
		
	
		
			
				
					|  |  |  |                 customerRanking = customerMinRanking + 1; | 
			
		
	
		
			
				
					|  |  |  |             } else { | 
			
		
	
		
			
				
					|  |  |  |                 // 该小组有积分
 | 
			
		
	
		
			
				
					|  |  |  |                 point = groupPoint.getTotalPoint(); | 
			
		
	
		
			
				
					|  |  |  |                 gridRanking = baseDao.getRanking("group", g.getGroupId(), "grid"); | 
			
		
	
		
			
				
					|  |  |  |                 customerRanking = baseDao.getRanking("group", g.getGroupId(), "customer"); | 
			
		
	
		
			
				
					|  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |             GroupPointRankingResultDTO dto = new GroupPointRankingResultDTO(); | 
			
		
	
		
			
				
					|  |  |  |             dto.setGridId(g.getGridId()); | 
			
		
	
		
			
				
					|  |  |  |             dto.setGroupHeadPhoto(g.getGroupHeadPhoto()); | 
			
		
	
		
			
				
					|  |  |  |             dto.setGroupType(g.getGroupType()); | 
			
		
	
		
			
				
					|  |  |  |             dto.setGroupId(g.getGroupId()); | 
			
		
	
		
			
				
					|  |  |  |             dto.setGroupName(g.getGroupName()); | 
			
		
	
		
			
				
					|  |  |  |             dto.setPoint(point.toString()); | 
			
		
	
		
			
				
					|  |  |  |             dto.setGridRanking(gridRanking); | 
			
		
	
		
			
				
					|  |  |  |             dto.setCustomerRanking(customerRanking); | 
			
		
	
		
			
				
					|  |  |  |             return dto; | 
			
		
	
		
			
				
					|  |  |  |         }).collect(Collectors.toList()); | 
			
		
	
		
			
				
					|  |  |  |         return groupDtoList; | 
			
		
	
		
			
				
					|  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  | } |