jdk8使用stream对指定值去重以及其他stream用法
// 分组统计
final Map<Integer, Long> gunCountMap = infoDTOS
.stream()
.filter(dto -> BooleanStatusEnum.NO.getCode() == x.getSuspend())
.collect(Collectors.groupingBy(ConnectorEquipmentInfoDTO::getConnectorStatus, Collectors.counting()));
long hangOnCount = infoDTOS.stream().filter(x -> BooleanStatusEnum.YES.getCode() == x.getSuspend()).count();
final long allGunCount = gunCountMap.values().stream().collect(Collectors.summarizingLong(Long::longValue)).getSum() + hangOnCount;
setGunInfo(allGunCount, hangOnCount, gunCountMap, dto);
// 指定值去重
final ArrayList<ConnectorEquipmentInfoDTO> distinctList = infoDTOS
.stream()
.filter(Objects::nonNull)
.collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(ConnectorEquipmentInfoDTO::getEquipmentId))), ArrayList::new));
三分热血值得你十二分努力。