标签:set plist ping col entryset array 对象 val obj
//对数据做分组(分组条件:组织+对象)
List<Map<String,Object>> list2 = new ArrayList<>();
Map<String,Object> map1 = new HashMap<>();
map1.put("organization", "北京");
map1.put("object", "故宫");
map1.put("score", "90");
list2.add(map1);
Map<String,Object> map2 = new HashMap<>();
map2.put("organization", "北京");
map2.put("object", "故宫");
map2.put("personQty", "8万");
list2.add(map2);
Map<String,Object> map3 = new HashMap<>();
map3.put("organization", "南京");
map3.put("object", "博物院");
map3.put("score", "80");
list2.add(map3);
Map<String,Object> map4 = new HashMap<>();
map4.put("organization", "南京");
map4.put("object", "博物院");
map4.put("personQty", "3万");
list2.add(map4);
List<Map<String, Object>> groupList = list2.stream().collect(Collectors.groupingBy(d -> d.get("organization")
+ "||" + d.get("object"))).entrySet()
.stream().map(d -> {
Map<String, Object> map = new HashMap<>();
map.put("entrustList", d.getValue());
map.put("groupKey", d.getKey());
return map;
}).collect(Collectors.toList());
标签:set plist ping col entryset array 对象 val obj
原文地址:https://www.cnblogs.com/sikuaiwu/p/11387466.html