|
@@ -0,0 +1,40 @@
|
|
|
+package com.winhc.bigdata.bean;
|
|
|
+
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+import static org.junit.Assert.*;
|
|
|
+
|
|
|
+public class CategoryTest {
|
|
|
+
|
|
|
+
|
|
|
+ public static void main(String[] args) {
|
|
|
+
|
|
|
+ Map<String, List<Category>> collect = Category.CATEGORY_MAP.values().stream().collect(Collectors.groupingBy(r -> r.getCateFirstCode() + "|" + r.getCateSecondCode() + " " + r.getCateFirst() + " " + r.getCateSecond()));
|
|
|
+
|
|
|
+
|
|
|
+ List<AreaCodeTreeVo> collect2 = collect.entrySet().stream()
|
|
|
+ .map(r -> {
|
|
|
+ String[] s = r.getKey().split(" ");
|
|
|
+ List<AreaCodeTreeVo> treeVos = r.getValue().stream().map(rr -> new AreaCodeTreeVo(rr.getCateThird(), rr.getAllCateCode())).collect(Collectors.toList());
|
|
|
+ return new EntryVo<String, AreaCodeTreeVo>(s[0].split("\\|")[0] + " " + s[1], new AreaCodeTreeVo(s[2], s[0], treeVos));
|
|
|
+ }).collect(Collectors.groupingBy(EntryVo::getKey))
|
|
|
+ .entrySet()
|
|
|
+ .stream()
|
|
|
+ .map(r -> {
|
|
|
+ String[] s = r.getKey().split(" ");
|
|
|
+ List<EntryVo<String, AreaCodeTreeVo>> value = r.getValue();
|
|
|
+ List<AreaCodeTreeVo> collect1 = value.stream().map(EntryVo::getValue).collect(Collectors.toList());
|
|
|
+ return new AreaCodeTreeVo(s[1], s[0], collect1);
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+
|
|
|
+
|
|
|
+ System.out.println(collect2);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+}
|