Browse Source

用map 获取用户里的信息

master
jianjun 4 years ago
parent
commit
7163c1b0e0
  1. 2
      epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/feign/DataStatisticalOpenFeignClient.java
  2. 27
      epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/impl/UserPointStatisticalDailyServiceImpl.java

2
epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/feign/DataStatisticalOpenFeignClient.java

@ -335,7 +335,7 @@ public interface DataStatisticalOpenFeignClient {
/**
* 事件上报
* @Param formDTO
* @Return {@link Result<List<BaseDisputeProcessDTO>>}
* @Return {@link Result<List<EventInfoResultDTO>>}
* @Author zhaoqifeng
* @Date 2021/10/15 16:50
*/

27
epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/impl/UserPointStatisticalDailyServiceImpl.java

@ -55,6 +55,7 @@ import org.springframework.transaction.annotation.Transactional;
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
@ -202,18 +203,22 @@ public class UserPointStatisticalDailyServiceImpl extends BaseServiceImpl<UserPo
}
List<String> userIds = rankList.stream().map(ResiPointRankResultDTO::getUserId).collect(Collectors.toList());
//查询用户昵称
Result<List<UserBaseInfoResultDTO>> userInfo =
epmetUserOpenFeignClient.queryUserBaseInfo(userIds);
boolean userRequestCallback = userInfo.success() && null != userInfo.getData() && !userInfo.getData().isEmpty();
for (int i = NumConstant.ZERO; i < rankList.size(); i++) {
ResiPointRankListResultDTO resultObj = ConvertUtils.sourceToTarget(o,ResiPointRankListResultDTO.class);
Result<List<UserBaseInfoResultDTO>> userInfo = epmetUserOpenFeignClient.queryUserBaseInfo(userIds);
Map<String,UserBaseInfoResultDTO> userInfoMap = new HashMap<>();
if (userInfo.success() && CollectionUtils.isNotEmpty(userInfo.getData())){
userInfoMap = userInfo.getData().stream().collect(Collectors.toMap(UserBaseInfoResultDTO::getUserId, Function.identity(),(o1,o2)->o1));
}
for (ResiPointRankResultDTO resiPointRankResultDTO : rankList) {
ResiPointRankListResultDTO resultObj = ConvertUtils.sourceToTarget(o, ResiPointRankListResultDTO.class);
ResiPointRankingResultDTO target = new ResiPointRankingResultDTO();
target.setRanking(rankList.get(i).getRank());
target.setPoint(rankList.get(i).getTotalPoint());
if(userRequestCallback) {
target.setNickname(null == userInfo.getData().get(i) ? "" : userInfo.getData().get(i).getNickname());
target.setHeadImgUrl(null == userInfo.getData().get(i) ? "" : userInfo.getData().get(i).getHeadImgUrl());
target.setRanking(resiPointRankResultDTO.getRank());
target.setPoint(resiPointRankResultDTO.getTotalPoint());
target.setNickname(StrConstant.EPMETY_STR);
target.setHeadImgUrl(StrConstant.EPMETY_STR);
UserBaseInfoResultDTO infoResultDTO = userInfoMap.get(resiPointRankResultDTO.getUserId());
if (infoResultDTO != null) {
target.setNickname(infoResultDTO.getNickname());
target.setHeadImgUrl(infoResultDTO.getHeadImgUrl());
}
resultObj.setRankList(target);
result.add(resultObj);

Loading…
Cancel
Save