list操作

list中有重复数据 进行合并,并且合并的时候 判断属性是否是null 如果null则取list中的另外一笔不为null数据

 

List<IncentiveDataHowScoreExport> list3 = list.stream()
        .collect(Collectors.toMap(IncentiveDataHowScoreExport::getWwid,a ->a,(v1,v2) ->{
            v1.setManagerRecommendStr(ObjectUtils.isNotEmpty(v1.getManagerRecommendStr()) ? v1.getManagerRecommendStr() : v2.getManagerRecommendStr());
            v1.setManagerRecommendRemark(ObjectUtils.isNotEmpty(v1.getManagerRecommendRemark())  ? v1.getManagerRecommendRemark() : v2.getManagerRecommendRemark());
            return v1;
        })).values().stream().collect(Collectors.toList());

  

 

posted @ 2021-12-14 20:22  IT-Jack  阅读(26)  评论(0编辑  收藏  举报