//情形1
Set<String> pickBillNos = zonePickBills.stream().map(ZonePickBill::getPickBillNo).collect(Collectors.toSet());
//情形2
String msg = areaNotSetLogicList.stream().map(SimpleWarehouseAreaDto::getAreaCode).limit(3).collect(Collectors.joining(","));
//情形3
Map<String, DeliveryPickInfo> deliveryPickInfoMap =
deliveryPickInfos.stream().collect(Collectors.toMap(DeliveryPickInfo::getPickBillNo, deliveryPickInfo -> deliveryPickInfo));
或
Map<String, DeliveryPickInfo> deliveryPickInfoMap =
deliveryPickInfos.stream().collect(Collectors.toMap(DeliveryPickInfo::getPickBillNo, Function.identity()));
Map<Long, Integer> regionIdPriorityLevelMap =
deliveryRegions.stream().collect(Collectors.toMap(DeliveryRegionResultDto::getRegionId,
n -> Optional.ofNullable(n.getPriorityLevel()).orElse(0), (key1, key2) -> key1));
//情形4
List<WarehouseGrayRecordResDto> recordResDtos;
Map<Long,List<WarehouseGrayRecordResDto>> map =
recordResDtos.stream().collect(Collectors.groupingBy(WarehouseGrayRecordResDto::getWarehouseId));
//情形5-1
Map<String, List<String>> map = deliveryInfoForPrintDtos.stream().collect(Collectors.groupingBy(DeliveryInfoForPrintDto::getRouteNo,
Collectors.mapping(dto -> {
String billno = dto.getOutBoundBillNo();
// 将出库单号添加到集合中
outboundNoList.add(billno); //返回map时同时提取所有的单号(其他地方需要)
return billno;
}, Collectors.toCollection(ArrayList::new))));
//情形5-2
Map<Integer, Set<String>> skuAreaCodeMap = pickBillDetailDtoList.stream()
.collect(Collectors.groupingBy(PickBillDetailDto::getOriginSkuCode,
Collectors.mapping(PickBillDetail::getAreaCode, Collectors.toSet())));
//情形6
List<String> areaCodeNotSetPickPolicyList = areaCodeList.stream().filter(e -> !areaCodeHavePolicySet.contains(e)).collect(Collectors.toList());
//情形7
List<HainaOutboundBillDto> sortOutboundDetailList = Lists.newArrayList();
List<HainaOutboundBillDetailDto> list = sortOutboundDetailList.stream().map(HainaOutboundBillDto::getDetailList)
.flatMap(Collection::stream).collect(Collectors.toList());
//情形8
List<PickBill> billList;
Map<OutboundTypeEnum, List<PickBill>> = billList.stream().collect(Collectors.groupingBy(bill -> {
if (isOrder(bill.getPickBillNo())) {
return OutboundTypeEnum.ORDER_OUTBOUND;
} else if (isSupplyReturn(bill.getPickBillNo())) {
return OutboundTypeEnum.RETURN_OUTBOUND;
} else {
return OutboundTypeEnum.ALLOT_OUTBOUND;
}
}));
//情形8
List<PickBillDetail> detailList;
Map<String, Set<String>> pickOutboundMap =
detailList.stream().collect(Collectors.groupingBy(PickBillDetail::getPickBillNo,
Collectors.mapping(PickBillDetail::getOutboundBillNo, Collectors.toSet())));
//情形9
int orderSkuTotalQty = pickBillDetailList.stream().map(PickBillDetailDto::getOriginSkuCode).distinct().count();
int orderUnitTotalQty = pickBillDetailList.stream().mapToInt(PickBillDetailDto::getOriginSkuQty).sum();
List<DeliveryRouteDetailInfoVo> deliveries = new ArrayList<>(orderNoList.size());
BigDecimal sumWeight = deliveries.stream().map(DeliveryRouteDetailInfoVo::getWeight).reduce(BigDecimal.ZERO, BigDecimal::add);