https://juejin.cn/post/7033005110716448776

    1. list中的对象某个属性存在重复时将重复的对象去重
      //根据skuAttrValueName值去重

      1. List<SkuValue> uniqueSkuValues = skuValues.stream().collect(
      2. Collectors.collectingAndThen(Collectors.toCollection(
      3. () -> new TreeSet<>(Comparator.comparing(o -> o.getSkuAttrValueName()))), ArrayList::new)
      4. );
    2. java8获得对象集合中 某个属性的集合

      1. List patientIdList = relationDOList.stream().map(RelationDO::getPatientId).collect(Collectors.toList());
    3. 收集成实体本身map ```java public Map getIdAccountMap(List accounts) { return accounts.stream().collect(Collectors.toMap(Account::getId, account -> account)); }

    public Map getIdNameMap(List accounts) { return accounts.stream().collect(Collectors.toMap(Account::getId, Account::getUsername)); }

    1. 4. bigdecimal求和计算
    2. ```java
    3. BigDecimal openDyeAmount = CollUtil.def(sub == null ? null : sub.getDetails()).stream().filter(e -> e.getOpenDyeAmount() != null)
    4. .map(DyeSubOrderDetailDTO::getOpenDyeAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
    1. 根据字段属性去重

      1. List<DyeSubOrderDetailDTO> basFinishedGoodsColorList = CollUtil.def(sub == null ? CollUtil.emptyList() : sub.getDetails()).stream()
      2. .collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(DyeSubOrderDetailDTO::getBasFinishedGoodsColorId))), ArrayList::new));
    2. 分组

      1. warehouseAllocationReceiveDetailDTOList.stream().collect(Collectors.groupingBy(WarehouseAllocationReceiveDetailDTO::getDyeOrderId));

    6.排序

    1. List<StudentInfo> studentsSortName = studentList.stream().sorted(Comparator.comparing(StudentInfo::getAge)).collect(Collectors.toList());