diff --git a/src/main/java/com/cm/systemcity/service/grid/impl/GridUserServiceImpl.java b/src/main/java/com/cm/systemcity/service/grid/impl/GridUserServiceImpl.java index 2055cc1..ed4edb5 100644 --- a/src/main/java/com/cm/systemcity/service/grid/impl/GridUserServiceImpl.java +++ b/src/main/java/com/cm/systemcity/service/grid/impl/GridUserServiceImpl.java @@ -90,7 +90,7 @@ public class GridUserServiceImpl extends BaseService implements IGridUserService public List list(String gridId, Map params) { List gridRelationDTOs = gridRelationService.listByGridId(gridId); if (gridRelationDTOs.isEmpty()) { - return new ArrayList(); + return new ArrayList<>(); } Set userIdSet = new HashSet<>(); for (GridRelationDTO gridRelationDTO : gridRelationDTOs) { @@ -102,6 +102,40 @@ public class GridUserServiceImpl extends BaseService implements IGridUserService if (maps.isEmpty()) { return new ArrayList<>(); } + return listUserMap2GridUser(maps, gridId, gridRelationDTOs); + } + + @Override + public SuccessResultList> listPage(String gridId, ListPage page) { + List gridRelationDTOs = gridRelationService.listByGridId(gridId); + if (gridRelationDTOs.isEmpty()) { + return new SuccessResultList<>(new ArrayList<>(), 1, 0L); + } + Set userIdSet = new HashSet<>(); + for (GridRelationDTO gridRelationDTO : gridRelationDTOs) { + userIdSet.add(gridRelationDTO.getRelationId()); + } + PageHelper.startPage(page.getPage(), page.getRows()); + Map query = getHashMap(2); + query.put("userIds", new ArrayList<>(userIdSet)); + List> maps = bindingDepartmentDao.listAllSysUser(query); + PageInfo> pageInfo = new PageInfo<>(maps); + if (maps.isEmpty()) { + return new SuccessResultList<>(new ArrayList<>(), 1, 0L); + } + List gridUserDTOs = listUserMap2GridUser(maps, gridId, gridRelationDTOs); + return new SuccessResultList<>(gridUserDTOs, pageInfo.getPageNum(), pageInfo.getTotal()); + } + + /** + * 用户列表转网格用户 + * + * @param maps + * @param gridId + * @param gridRelationDTOs + * @return + */ + private List listUserMap2GridUser(List> maps, String gridId, List gridRelationDTOs) { List userDTOs = maps.stream().map(kv -> { UserDTO userDTO = new UserDTO(); userDTO.setUserId(kv.get("user_id").toString()); @@ -110,7 +144,6 @@ public class GridUserServiceImpl extends BaseService implements IGridUserService userDTO.setPhone(kv.get("user_phone") == null ? "-" : kv.get("user_phone").toString()); return userDTO; }).collect(Collectors.toList()); - List gridUserDTOs = new ArrayList<>(); for (UserDTO userDTO : userDTOs) { GridUserDTO gridUserDTO = new GridUserDTO(); @@ -127,12 +160,4 @@ public class GridUserServiceImpl extends BaseService implements IGridUserService return gridUserDTOs; } - @Override - public SuccessResultList> listPage(String gridId, ListPage page) { - PageHelper.startPage(page.getPage(), page.getRows()); - List gridUserDTOs = list(gridId, page.getParams()); - PageInfo pageInfo = new PageInfo<>(gridUserDTOs); - return new SuccessResultList<>(gridUserDTOs, pageInfo.getPageNum(), pageInfo.getTotal()); - } - }