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 e38656d2b7..987c9a1167 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 @@ -749,37 +749,34 @@ public class UserServiceImpl implements UserService { public void fillScreenProjectData(List list) { List topicUserIdList = list.stream().filter(o -> ProjectConstant.PROJECT_ORIGIN_ISSUE.equals(o.getOrigin())) .map(ScreenProjectDataDTO::getLinkName).distinct().collect(Collectors.toList()); - if (CollectionUtils.isEmpty(topicUserIdList)){ - return; + Map topicUserMap = new HashMap<>(); + if (!CollectionUtils.isEmpty(topicUserIdList)){ + List collection = userDao.selectScreenProjectData(topicUserIdList); + logger.info("fillScreenProjectData staff list:{},param:{}", JSON.toJSONString(collection),topicUserIdList); + topicUserMap = collection.stream().collect(Collectors.toMap(ScreenProjectDataDTO::getTopicId,o->o,(o1,o2)->o1)); } - List collection = userDao.selectScreenProjectData(topicUserIdList); - logger.info("fillScreenProjectData staff list:{},param:{}", JSON.toJSONString(collection),topicUserIdList); - Map topicUserMap = collection.stream().collect(Collectors.toMap(ScreenProjectDataDTO::getTopicId,o->o,(o1,o2)->o1)); - /* if(!CollectionUtils.isEmpty(collection)){ - list.stream().flatMap(target -> collection.stream().filter(res -> StringUtils.equals(target.getLinkName(),res.getTopicId())) - .map(merge -> { - target.setLinkName(merge.getLinkName()); - target.setLinkMobile(merge.getLinkMobile()); - return target;})); - }*/ + + List staffUserIdList = list.stream().filter(o -> ProjectConstant.PROJECT_ORIGIN_AGENCY.equals(o.getOrigin())) .map(ScreenProjectDataDTO::getLinkName).distinct().collect(Collectors.toList()); - if (CollectionUtils.isEmpty(topicUserIdList)){ - return; + + Map staffMap = new HashMap<>(); + if (!CollectionUtils.isEmpty(topicUserIdList)){ + List staffList = userDao.selectStaffInfo(staffUserIdList); + logger.info("fillScreenProjectData staff list:{},param:{}", JSON.toJSONString(staffList),staffUserIdList); + staffMap = staffList.stream().collect(Collectors.toMap(ScreenProjectDataDTO::getId,o->o,(o1,o2)->o1)); } - List staffList = userDao.selectStaffInfo(staffUserIdList); - logger.info("fillScreenProjectData staff list:{},param:{}", JSON.toJSONString(staffList),staffUserIdList); - Map collect = staffList.stream().collect(Collectors.toMap(ScreenProjectDataDTO::getId,o->o,(o1,o2)->o1)); - list.forEach(project->{ - ScreenProjectDataDTO userDTO = collect.get(project.getLinkName()); - if (userDTO == null){ + + for (ScreenProjectDataDTO project : list) { + ScreenProjectDataDTO userDTO = staffMap.get(project.getLinkName()); + if (userDTO == null) { userDTO = topicUserMap.get(project.getLinkName()); } - if (userDTO != null){ + if (userDTO != null) { project.setLinkName(userDTO.getLinkName()); project.setLinkMobile(userDTO.getLinkMobile()); } - }); + } } /**