java stream的使用–分组
/finished是list,根据getSafetyPotentialRiskClass(),getProcessFlag()分类
Map<String, Map<String,Long>> map = finished
.stream()
.filter(e-> StringUtils.isNotBlank(e.getSafetyPotentialRiskClass())&&StringUtils.isNotEmpty(e.getSafetyPotentialRiskClass()))
.collect(Collectors.groupingBy(ConstructionSafety::getSafetyPotentialRiskClass,Collectors.groupingBy(ConstructionSafety::getProcessFlag,Collectors.counting())));
list.parallelStream().collect(Collectors.groupingBy(ScheduleQuantityWeek::getUid,Collectors.toList()))
.forEach((k,v)->{
ScheduleQuantityWeek temp=v.get(0);
for(ScheduleQuantityWeek item:v){
temp.setAssignComplete(temp.getAssignComplete()+item.getAssignComplete());
temp.setFinish(item.getFinish());
}
res.add(temp);
});