elecCompanyElecEnergy.parallelStream().collect(Collectors.groupingBy(d -> d.getElecUserNo(), Collectors.toList()))
.forEach((id, groupList) -> {
groupList.stream().reduce(
(a, b) -> new ElecCompanyElecEnergy()
.setUseYear(a.getUseYear())
.setElecOutNum(a.getElecOutNum())
.setCompanyName(a.getCompanyName())
.setRegionId(a.getRegionId())
.setIndustryId(a.getIndustryId())
.setElecNum(a.getElecNum().add(b.getElecNum()))
).ifPresent(resultList::add);
});
list中的对象,按照某一个属性分组,并且按照另外一个属性将其值相加
最新推荐文章于 2024-05-26 17:13:51 发布