分片: List<List<Long>> shopIDPartition = ListUtils.partition(dataScopeShopIDList.getShopIDs(), HjdApolloConfig.partitionShopIDSize);
list转Map:
Map<String, String> itemkeyAndFoodNumMap = setFoodHeadList.stream().collect(Collectors.toMap(OrderFood::getItemKey, s -> s.getFoodNumber().toPlainString() + "@" + s.getUnit()));
Map<String, TblAgentUserMenuRights> menuRightsMap = rightList.stream().collect(Collectors.toMap(r -> r.getMenuCode() + r.getRightCode(), Function.identity()));
Map<String, ShopServiceDeliverRpc.AuthorizedShop> bindPlatformCodeShopMap = authorizedShops.stream()
.collect(Collectors.toMap(ShopServiceDeliverRpc.AuthorizedShop::getPlatformCode, a -> a, (v1, v2) -> v1));
Map<Integer, ThirdPlatformAndShopPlatformInfo> shopPlatformInfoMap = thirdPlatformAndShopPlatformInfos.stream()
.collect(Collectors.toMap(ThirdPlatformAndShopPlatformInfo::getPlatformCode, Function.identity()));
Map<Integer, CloudPrinterStatusAndTemplateDto> printerStatusDtoMap = printerStatusResponse.getPrinterList().stream().collect(Collectors.toMap(CloudPrinterStatusAndTemplateDto::getPrinterID, key -> key));
//获取所有的平台 先按时间排序、在通过code排序 string 需要转Long才能比较
List<DcOrderData.PlatformStatusInfo> platformStatusInfoList = platformStatusListList.stream()
.sorted(Comparator.comparing(DcOrderData.PlatformStatusInfo::getCreateTime, Comparator.comparingLong(Long::parseLong))
.thenComparingInt(DcOrderData.PlatformStatusInfo::getPlatformCode)).collect(Collectors.toList());
List 排序、分组、求和 :
TreeMap<Long, Long> chartShopDateAndNumberMap = chartShopDateAndNumber.stream()
.sorted(Comparator.comparing(ShopIDAndName::getDateTime).reversed())
.collect(Collectors.groupingBy(ShopIDAndName::getDateTime, TreeMap::new, Collectors.summingLong(ShopIDAndName::getShopNumDay)));
获取指定字段: List<String> orderKeys = rspOrderLst.stream().map(OrderAttachItem::getOrderKey).collect(Collectors.toList());