添加通道编号构建页面
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
package com.genersoft.iot.vmp.conf;
|
||||
|
||||
import com.genersoft.iot.vmp.common.CivilCodePo;
|
||||
import com.genersoft.iot.vmp.utils.CivilCodeUtil;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.Region;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.ehcache.impl.internal.concurrent.ConcurrentHashMap;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.CommandLineRunner;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
@@ -18,6 +19,7 @@ import java.io.InputStreamReader;
|
||||
import java.nio.file.Files;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 启动时读取行政区划表
|
||||
@@ -31,6 +33,8 @@ public class CivilCodeFileConf implements CommandLineRunner {
|
||||
@Lazy
|
||||
private UserSetting userSetting;
|
||||
|
||||
private final Map<String, CivilCodePo> civilCodeMap= new ConcurrentHashMap<>();
|
||||
|
||||
@Override
|
||||
public void run(String... args) throws Exception {
|
||||
if (ObjectUtils.isEmpty(userSetting.getCivilCodeFile())) {
|
||||
@@ -59,7 +63,6 @@ public class CivilCodeFileConf implements CommandLineRunner {
|
||||
BufferedReader inputStreamReader = new BufferedReader(new InputStreamReader(inputStream));
|
||||
int index = -1;
|
||||
String line;
|
||||
List<CivilCodePo> civilCodePoList = new ArrayList<>();
|
||||
while ((line = inputStreamReader.readLine()) != null) {
|
||||
index ++;
|
||||
if (index == 0) {
|
||||
@@ -67,15 +70,28 @@ public class CivilCodeFileConf implements CommandLineRunner {
|
||||
}
|
||||
String[] infoArray = line.split(",");
|
||||
CivilCodePo civilCodePo = CivilCodePo.getInstance(infoArray);
|
||||
civilCodePoList.add(civilCodePo);
|
||||
civilCodeMap.put(civilCodePo.getCode(), civilCodePo);
|
||||
}
|
||||
CivilCodeUtil.INSTANCE.add(civilCodePoList);
|
||||
inputStreamReader.close();
|
||||
inputStream.close();
|
||||
if (civilCodePoList.isEmpty()) {
|
||||
if (civilCodeMap.isEmpty()) {
|
||||
log.warn("[行政区划] 文件内容为空,可能造成目录刷新结果不完整");
|
||||
}else {
|
||||
log.info("[行政区划] 加载成功,共加载数据{}条", civilCodePoList.size());
|
||||
log.info("[行政区划] 加载成功,共加载数据{}条", 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