Merge branch '2.6.8' into wvp-28181-2.0
# Conflicts: # src/main/java/com/genersoft/iot/vmp/conf/UserSetting.java # src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommanderFroPlatform.java # src/main/java/com/genersoft/iot/vmp/gb28181/utils/XmlUtil.java # src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java # src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceChannelMapper.java # src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java # src/main/resources/all-application.yml # web_src/package-lock.json
This commit is contained in:
101
src/main/java/com/genersoft/iot/vmp/conf/CivilCodeFileConf.java
Normal file
101
src/main/java/com/genersoft/iot/vmp/conf/CivilCodeFileConf.java
Normal file
@@ -0,0 +1,101 @@
|
||||
package com.genersoft.iot.vmp.conf;
|
||||
|
||||
import com.genersoft.iot.vmp.common.CivilCodePo;
|
||||
import org.ehcache.impl.internal.concurrent.ConcurrentHashMap;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.CommandLineRunner;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.file.Files;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 启动时读取行政区划表
|
||||
*/
|
||||
@Configuration
|
||||
@Order(value=14)
|
||||
public class CivilCodeFileConf implements CommandLineRunner {
|
||||
|
||||
private final static Logger logger = LoggerFactory.getLogger(CivilCodeFileConf.class);
|
||||
|
||||
private final Map<String, CivilCodePo> civilCodeMap= new ConcurrentHashMap<>();
|
||||
|
||||
@Autowired
|
||||
@Lazy
|
||||
private UserSetting userSetting;
|
||||
|
||||
@Override
|
||||
public void run(String... args) throws Exception {
|
||||
if (ObjectUtils.isEmpty(userSetting.getCivilCodeFile())) {
|
||||
logger.warn("[行政区划] 文件未设置,可能造成目录刷新结果不完整");
|
||||
return;
|
||||
}
|
||||
InputStream inputStream;
|
||||
if (userSetting.getCivilCodeFile().startsWith("classpath:")){
|
||||
String filePath = userSetting.getCivilCodeFile().substring("classpath:".length());
|
||||
ClassPathResource civilCodeFile = new ClassPathResource(filePath);
|
||||
if (!civilCodeFile.exists()) {
|
||||
logger.warn("[行政区划] 文件<{}>不存在,可能造成目录刷新结果不完整", userSetting.getCivilCodeFile());
|
||||
return;
|
||||
}
|
||||
inputStream = civilCodeFile.getInputStream();
|
||||
|
||||
}else {
|
||||
File civilCodeFile = new File(userSetting.getCivilCodeFile());
|
||||
if (!civilCodeFile.exists()) {
|
||||
logger.warn("[行政区划] 文件<{}>不存在,可能造成目录刷新结果不完整", userSetting.getCivilCodeFile());
|
||||
return;
|
||||
}
|
||||
inputStream = Files.newInputStream(civilCodeFile.toPath());
|
||||
}
|
||||
|
||||
BufferedReader inputStreamReader = new BufferedReader(new InputStreamReader(inputStream));
|
||||
int index = -1;
|
||||
String line;
|
||||
while ((line = inputStreamReader.readLine()) != null) {
|
||||
index ++;
|
||||
if (index == 0) {
|
||||
continue;
|
||||
}
|
||||
String[] infoArray = line.split(",");
|
||||
CivilCodePo civilCodePo = CivilCodePo.getInstance(infoArray);
|
||||
civilCodeMap.put(civilCodePo.getCode(), civilCodePo);
|
||||
}
|
||||
inputStreamReader.close();
|
||||
inputStream.close();
|
||||
if (civilCodeMap.size() == 0) {
|
||||
logger.warn("[行政区划] 文件内容为空,可能造成目录刷新结果不完整");
|
||||
}else {
|
||||
logger.info("[行政区划] 加载成功,共加载数据{}条", civilCodeMap.size());
|
||||
}
|
||||
}
|
||||
|
||||
public CivilCodePo getParentCode(String code) {
|
||||
if (code.length() > 8) {
|
||||
return null;
|
||||
}
|
||||
if (code.length() == 8) {
|
||||
String parentCode = code.substring(0, 6);
|
||||
return civilCodeMap.get(parentCode);
|
||||
}else {
|
||||
CivilCodePo civilCodePo = civilCodeMap.get(code);
|
||||
if (civilCodePo == null){
|
||||
return null;
|
||||
}
|
||||
String parentCode = civilCodePo.getParentCode();
|
||||
if (parentCode == null) {
|
||||
return null;
|
||||
}
|
||||
return civilCodeMap.get(parentCode);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -45,6 +45,7 @@ public class DynamicTask {
|
||||
* @return
|
||||
*/
|
||||
public void startCron(String key, Runnable task, int cycleForCatalog) {
|
||||
System.out.println(cycleForCatalog);
|
||||
ScheduledFuture<?> future = futureMap.get(key);
|
||||
if (future != null) {
|
||||
if (future.isCancelled()) {
|
||||
|
||||
@@ -56,7 +56,7 @@ public class SipPlatformRunner implements CommandLineRunner {
|
||||
}
|
||||
|
||||
// 设置所有平台离线
|
||||
platformService.offline(parentPlatform, true);
|
||||
platformService.offline(parentPlatform, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,12 +62,18 @@ public class UserSetting {
|
||||
|
||||
private String thirdPartyGBIdReg = "[\\s\\S]*";
|
||||
|
||||
private String civilCodeFile = "classpath:civilCode.csv";
|
||||
|
||||
private List<String> interfaceAuthenticationExcludes = new ArrayList<>();
|
||||
|
||||
private List<String> allowedOrigins = new ArrayList<>();
|
||||
|
||||
private int maxNotifyCountQueue = 10000;
|
||||
|
||||
private int registerAgainAfterTime = 60;
|
||||
|
||||
private boolean registerKeepIntDialog = false;
|
||||
|
||||
public Boolean getSavePositionHistory() {
|
||||
return savePositionHistory;
|
||||
}
|
||||
@@ -295,4 +301,28 @@ public class UserSetting {
|
||||
public void setSqlLog(Boolean sqlLog) {
|
||||
this.sqlLog = sqlLog;
|
||||
}
|
||||
|
||||
public String getCivilCodeFile() {
|
||||
return civilCodeFile;
|
||||
}
|
||||
|
||||
public void setCivilCodeFile(String civilCodeFile) {
|
||||
this.civilCodeFile = civilCodeFile;
|
||||
}
|
||||
|
||||
public int getRegisterAgainAfterTime() {
|
||||
return registerAgainAfterTime;
|
||||
}
|
||||
|
||||
public void setRegisterAgainAfterTime(int registerAgainAfterTime) {
|
||||
this.registerAgainAfterTime = registerAgainAfterTime;
|
||||
}
|
||||
|
||||
public boolean isRegisterKeepIntDialog() {
|
||||
return registerKeepIntDialog;
|
||||
}
|
||||
|
||||
public void setRegisterKeepIntDialog(boolean registerKeepIntDialog) {
|
||||
this.registerKeepIntDialog = registerKeepIntDialog;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user