2 Коммиты 0e069ff25f ... 78d8ac5239

Автор SHA1 Сообщение Дата
  hexiao 78d8ac5239 区域信息修改为数据库 1 год назад
  hexiao 6d1a63e017 区域信息修改为数据库 1 год назад

+ 19 - 4
application-webadmin/src/main/java/com/ankaibei/workFlow/webadmin/api/AreaApiService.java

@@ -15,6 +15,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
 import java.util.stream.Collectors;
 
@@ -28,7 +29,22 @@ public class AreaApiService implements AreaApi {
     @Override
     @RequestMapping("/getInfoLikeKeywordsAndSubdistrict")
     public List<AreaInfo> getInfoLikeKeywordsAndSubdistrict(String keywords, Integer subdistrict) {
-        return GaoDeWebUtil.getInfoLikeKeywordsAndSubdistrict(keywords, subdistrict);
+        List<SysRegion> list = sysRegionService.list();
+        if (!Collections.isEmpty(list)) {
+            List<AreaInfo> collect = list.stream().filter(o->o.getAdcode().equals(keywords) || o.getName().contains(keywords)).map(o -> {
+                AreaInfo areaInfo = new AreaInfo();
+                BeanUtils.copyProperties(o, areaInfo);
+                return areaInfo;
+            }).collect(Collectors.toList());
+            for (AreaInfo areaInfo : collect) {
+                List<AreaInfo> areaInfos = buildData(Arrays.asList(areaInfo), list);
+                // 构建树
+                areaInfo.setDistricts(buildTree(areaInfos, list));
+            }
+            return collect;
+        }
+        return new ArrayList<>();
+//        return GaoDeWebUtil.getInfoLikeKeywordsAndSubdistrict(keywords, subdistrict);
     }
 
     /**
@@ -46,10 +62,9 @@ public class AreaApiService implements AreaApi {
                 BeanUtils.copyProperties(o, areaInfo);
                 return areaInfo;
             }).collect(Collectors.toList());
-            List<SysRegion> listAll = sysRegionService.list();
-            List<AreaInfo> areaInfos = buildData(collect, listAll);
+            List<AreaInfo> areaInfos = buildData(collect, list);
             // 构建树
-            return buildTree(areaInfos, listAll);
+            return buildTree(areaInfos, list);
         }
         return new ArrayList<>();
 //        return GaoDeWebUtil.getProvinces();