Browse Source

行政地区编码查询

dev_shibei_match
zxc 5 years ago
parent
commit
64ef3715d6
  1. 35
      epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/AreaCodeServiceImpl.java

35
epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/AreaCodeServiceImpl.java

@ -232,33 +232,32 @@ public class AreaCodeServiceImpl extends BaseServiceImpl<AreaCodeDao, AreaCodeEn
*/
public List<AreaCodeDictResultDTO> getTreeByRootAreaCode(List<AreaCodeDictResultDTO> tree , String rootAreaCode){
List<AreaCodeDictResultDTO> result = new ArrayList<>();
AtomicReference<Boolean> flag = new AtomicReference<>(false);
if (!CollectionUtils.isEmpty(tree)){
// 省级获取
tree.forEach(t -> {
if (rootAreaCode.equals(t.getCode())){
result.add(t);
flag.set(true);
for (AreaCodeDictResultDTO dto : tree) {
if (rootAreaCode.equals(dto.getCode())){
result.add(dto);
return result;
}
// 市级获取
if (!CollectionUtils.isEmpty(t.getChildren()) && flag.get() == false){
t.getChildren().forEach(c -> {
if (rootAreaCode.equals(c.getCode())){
result.add(c);
flag.set(true);
if (!CollectionUtils.isEmpty(dto.getChildren())){
for (AreaCodeDictResultDTO child : dto.getChildren()) {
if (rootAreaCode.equals(child.getCode())){
result.add(child);
return result;
}
// 区级获取
if (!CollectionUtils.isEmpty(c.getChildren()) && flag.get() == false){
c.getChildren().forEach(three -> {
if (rootAreaCode.equals(three.getCode()) && flag.get() == false){
result.add(three);
flag.set(true);
if (!CollectionUtils.isEmpty(child.getChildren())){
for (AreaCodeDictResultDTO threeChild : child.getChildren()) {
if (rootAreaCode.equals(threeChild.getCode())){
result.add(threeChild);
return result;
}
});
}
}
});
}
}
});
}
}
return result;
}

Loading…
Cancel
Save