临时提交
This commit is contained in:
@@ -1,8 +1,11 @@
|
||||
package com.genersoft.iot.vmp.utils;
|
||||
|
||||
import com.genersoft.iot.vmp.common.CivilCodePo;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.Region;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
@@ -25,6 +28,10 @@ public enum CivilCodeUtil {
|
||||
}
|
||||
}
|
||||
|
||||
public void add(CivilCodePo civilCodePo) {
|
||||
civilCodeMap.put(civilCodePo.getCode(), civilCodePo);
|
||||
}
|
||||
|
||||
public CivilCodePo getParentCode(String code) {
|
||||
if (code.length() > 8) {
|
||||
return null;
|
||||
@@ -43,6 +50,50 @@ public enum CivilCodeUtil {
|
||||
}
|
||||
return civilCodeMap.get(parentCode);
|
||||
}
|
||||
}
|
||||
|
||||
public CivilCodePo getCivilCodePo(String code) {
|
||||
if (code.length() > 8) {
|
||||
return null;
|
||||
}else {
|
||||
return civilCodeMap.get(code);
|
||||
}
|
||||
}
|
||||
|
||||
public List<CivilCodePo> getAllParentCode(String civilCode) {
|
||||
List<CivilCodePo> civilCodePoList = new ArrayList<>();
|
||||
CivilCodePo parentCode = getParentCode(civilCode);
|
||||
if (parentCode != null) {
|
||||
civilCodePoList.add(parentCode);
|
||||
List<CivilCodePo> allParentCode = getAllParentCode(parentCode.getCode());
|
||||
if (!allParentCode.isEmpty()) {
|
||||
civilCodePoList.addAll(allParentCode);
|
||||
}else {
|
||||
return civilCodePoList;
|
||||
}
|
||||
}
|
||||
return civilCodePoList;
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
return civilCodeMap.isEmpty();
|
||||
}
|
||||
|
||||
public int size() {
|
||||
return civilCodeMap.size();
|
||||
}
|
||||
|
||||
public List<Region> getAllChild(String parent) {
|
||||
List<Region> result = new ArrayList<>();
|
||||
for (String key : civilCodeMap.keySet()) {
|
||||
if (parent == null) {
|
||||
if (ObjectUtils.isEmpty(civilCodeMap.get(key).getParentCode().trim())) {
|
||||
result.add(Region.getInstance(key, civilCodeMap.get(key).getName(), civilCodeMap.get(key).getParentCode()));
|
||||
}
|
||||
}else if (civilCodeMap.get(key).getParentCode().equals(parent)) {
|
||||
result.add(Region.getInstance(key, civilCodeMap.get(key).getName(), civilCodeMap.get(key).getParentCode()));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user