List<CrmAuthorizedInfo> crmAuthorizedInfos =
flowPlanInfoMapper.findAllByEncode(stationForm.getOperatorId(), stationIds);
crmAuthorizedInfos.parallelStream()
.collect(Collectors.groupingBy(CrmAuthorizedInfo::getStationId, Collectors.toList()))
.forEach((k, v) -> {
AuthorizedStationInfo authorizedStationInfo = new AuthorizedStationInfo();
authorizedStationInfo.setStationId(k);
List<AuthorizedPileInfo> authorizedPileInfos = new ArrayList<>();
v.parallelStream().collect(Collectors.groupingBy(CrmAuthorizedInfo::getPileId, Collectors.toList())).forEach((k1, v1) -> {
AuthorizedPileInfo authorizedPileInfo = new AuthorizedPileInfo();
authorizedPileInfo.setPileId(k1);
authorizedPileInfo.setGunIds(v1.stream().map(CrmAuthorizedInfo::getGunId).collect(Collectors.toList()));
authorizedPileInfos.add(authorizedPileInfo);
});
authorizedStationInfo.setPileIds(authorizedPileInfos);
authorizedStationInfos.add(authorizedStationInfo);
});
原文:https://www.cnblogs.com/lisongyu/p/10790365.html