From 3e56eff0d0b61043165e8d4385f06493b2fa6fcf Mon Sep 17 00:00:00 2001 From: jianjun Date: Thu, 10 Jun 2021 15:02:07 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=BB=E8=BE=91=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/user/impl/UserServiceImpl.java | 41 +++++++++---------- 1 file changed, 19 insertions(+), 22 deletions(-) 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()); } - }); + } } /**