根据属性A分组,然后取分组里属性B最大的值, 最后合并成list
Map<String, IWLS_EnDepotEntry> collect = endepot.stream().collect(
Collectors.groupingBy(IWLS_EnDepotEntry::getPurBCode,
Collectors.collectingAndThen(Collectors.reducing((c1, c2) -> c1.getNum().intValue() > c2.getNum().intValue() ? c1 : c2),
Optional::get)));
endepot = new ArrayList<>(collect.values());
Map<String, IWLS_EnDepotEntry> collect1 = enDepotEntryList.stream().collect(
Collectors.groupingBy(IWLS_EnDepotEntry::getPurBCode,
Collectors.collectingAndThen(Collectors.reducing((c1, c2) -> c1.getNum().intValue() > c2.getNum().intValue() ? c1 : c2),
Optional::get)));
enDepotEntryList = new ArrayList<>(collect1.values());
根据时间排序,倒叙
List endepot = endepot.stream().sorted(Comparator.comparing(DoctorTimeEntity::getCreateTime).reversed()).collect(Collectors.toList());
参考地址;https://www.cnblogs.com/caolixiang/p/11969042.html