演示:
public List<Map<String,Object>> getSum(List<Map<String,Object>> nowData,List<Map<String,Object>> hisData,String name){
nowData.addAll(hisData);
List<Map<String,Object>> datas = new ArrayList<>();
Map<String, List<Map<String, Object>>> glist = nowData.stream()
.collect(Collectors.groupingBy(e -> e.get(name).toString()));
glist.forEach((k,slist)->{
Map<String,Object> nmap=new HashMap<>();
IntSummaryStatistics sumcc = slist.stream().collect(Collectors.
summarizingInt(e->Integer.valueOf(e.get("countorder").toString())));
nmap.put("name", slist.get(0).get(name));
nmap.put("value", sumcc.getSum());//求和
datas.add(nmap);
});
return datas;
}
网友评论