|
|
@ -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; |
|
|
|
} |
|
|
|