list 分组
1.多字段联合,分组
list.stream().collect(Collectors.groupingBy(o -> o.getSkuName() + "_" + o.getOeCode(), Collectors.toList()));
2.求和计算
Integer num =list.stream().mapToInt(n -> n.getNum()).sum();
3.分组-排序
list.stream().collect(Collectors.groupingBy(EnquiryDetail::getQualityId)) .values().stream().map(enquiryDetails -> { List<EnquiryDetail> rspDetails = enquiryDetails.stream().sorted(Comparator.comparing(EnquiryDetail::getQuotePrice)).collect(Collectors.toList()); rspDetails.get(0).setCheck(true); return rspDetails; }).flatMap(Collection::stream).collect(Collectors.toList());//按价格排序
// List<SupplierEnquiryDetail> details = busGroup.entrySet().stream().map(detail -> {
// SupplierEnquiryDetail supplyEnquiryCompareResp = BeanUtil.copyProperties(detail, SupplierEnquiryDetail.class);
// return supplyEnquiryCompareResp;
// }).sorted(Comparator.comparing(SupplierEnquiryDetail::getTaxQuotePrice) ).collect(Collectors.toList());
标签:toList,lamda,Collectors,stream,SupplierEnquiryDetail,list,collect,java8,表达式 From: https://www.cnblogs.com/molity88/p/17407571.html