Merge branch 'wvp-28181-2.0' into main-dev
# Conflicts: # src/main/java/com/genersoft/iot/vmp/conf/UserSetting.java # src/main/java/com/genersoft/iot/vmp/gb28181/bean/Device.java # src/main/java/com/genersoft/iot/vmp/gb28181/transmit/callback/DeferredResultHolder.java # src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/ISIPCommanderForPlatform.java # src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java # src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/response/impl/InviteResponseProcessor.java # src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRTPServerFactory.java # src/main/java/com/genersoft/iot/vmp/service/IPlayService.java # src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java # src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/play/PlayController.java # src/main/resources/all-application.yml # web_src/config/index.js # web_src/src/components/dialog/devicePlayer.vue
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,11 +2,11 @@ package com.genersoft.iot.vmp.conf;
|
||||
|
||||
import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
|
||||
import com.genersoft.iot.vmp.utils.DateUtil;
|
||||
import org.junit.jupiter.api.Order;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
import java.net.InetAddress;
|
||||
|
||||
36
src/main/java/com/genersoft/iot/vmp/conf/MybatisConfig.java
Normal file
36
src/main/java/com/genersoft/iot/vmp/conf/MybatisConfig.java
Normal file
@@ -0,0 +1,36 @@
|
||||
package com.genersoft.iot.vmp.conf;
|
||||
|
||||
import org.apache.ibatis.logging.stdout.StdOutImpl;
|
||||
import org.apache.ibatis.session.SqlSessionFactory;
|
||||
import org.mybatis.spring.SqlSessionFactoryBean;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.annotation.Order;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
/**
|
||||
* 配置mybatis
|
||||
*/
|
||||
@Configuration
|
||||
@Order(value=1)
|
||||
public class MybatisConfig {
|
||||
|
||||
@Autowired
|
||||
private UserSetting userSetting;
|
||||
|
||||
@Bean
|
||||
public SqlSessionFactory sqlSessionFactory(DataSource dataSource) throws Exception {
|
||||
final SqlSessionFactoryBean sqlSessionFactory = new SqlSessionFactoryBean();
|
||||
sqlSessionFactory.setDataSource(dataSource);
|
||||
org.apache.ibatis.session.Configuration config = new org.apache.ibatis.session.Configuration();
|
||||
if (userSetting.getSqlLog()){
|
||||
config.setLogImpl(StdOutImpl.class);
|
||||
}
|
||||
config.setMapUnderscoreToCamelCase(true);
|
||||
sqlSessionFactory.setConfiguration(config);
|
||||
return sqlSessionFactory.getObject();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -5,7 +5,7 @@ import com.genersoft.iot.vmp.service.IMediaServerService;
|
||||
import org.apache.http.HttpHost;
|
||||
import org.apache.http.HttpRequest;
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.junit.jupiter.api.Order;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.mitre.dsmiley.httpproxy.ProxyServlet;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.genersoft.iot.vmp.conf;
|
||||
|
||||
|
||||
import org.junit.jupiter.api.Order;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ public class SipPlatformRunner implements CommandLineRunner {
|
||||
}
|
||||
|
||||
// 设置所有平台离线
|
||||
platformService.offline(parentPlatform, true);
|
||||
platformService.offline(parentPlatform, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import io.swagger.v3.oas.models.OpenAPI;
|
||||
import io.swagger.v3.oas.models.info.Contact;
|
||||
import io.swagger.v3.oas.models.info.Info;
|
||||
import io.swagger.v3.oas.models.info.License;
|
||||
import org.junit.jupiter.api.Order;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springdoc.core.GroupedOpenApi;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.genersoft.iot.vmp.conf;
|
||||
|
||||
import org.junit.jupiter.api.Order;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.scheduling.annotation.EnableAsync;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.genersoft.iot.vmp.conf;
|
||||
|
||||
import org.junit.jupiter.api.Order;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -50,6 +50,7 @@ public class UserSetting {
|
||||
private Boolean pushStreamAfterAck = Boolean.FALSE;
|
||||
|
||||
private Boolean sipLog = Boolean.FALSE;
|
||||
private Boolean sqlLog = Boolean.FALSE;
|
||||
private Boolean sendToPlatformsWhenIdLost = Boolean.FALSE;
|
||||
|
||||
private Boolean refuseChannelStatusChannelFormNotify = Boolean.FALSE;
|
||||
@@ -65,12 +66,18 @@ public class UserSetting {
|
||||
|
||||
private String broadcastForPlatform = "UDP";
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -306,4 +313,36 @@ public class UserSetting {
|
||||
public void setUseCustomSsrcForParentInvite(Boolean useCustomSsrcForParentInvite) {
|
||||
this.useCustomSsrcForParentInvite = useCustomSsrcForParentInvite;
|
||||
}
|
||||
|
||||
public Boolean getSqlLog() {
|
||||
return sqlLog;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.genersoft.iot.vmp.conf;
|
||||
|
||||
import org.junit.jupiter.api.Order;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
||||
@@ -43,6 +43,9 @@ public class RedisMsgListenConfig {
|
||||
@Autowired
|
||||
private RedisPushStreamResponseListener redisPushStreamResponseListener;
|
||||
|
||||
@Autowired
|
||||
private RedisCloseStreamMsgListener redisCloseStreamMsgListener;
|
||||
|
||||
|
||||
/**
|
||||
* redis消息监听器容器 可以添加多个监听不同话题的redis监听器,只需要把消息监听器和相应的消息订阅处理器绑定,该消息监听器
|
||||
@@ -63,6 +66,7 @@ public class RedisMsgListenConfig {
|
||||
container.addMessageListener(redisPushStreamStatusMsgListener, new PatternTopic(VideoManagerConstants.VM_MSG_PUSH_STREAM_STATUS_CHANGE));
|
||||
container.addMessageListener(redisPushStreamListMsgListener, new PatternTopic(VideoManagerConstants.VM_MSG_PUSH_STREAM_LIST_CHANGE));
|
||||
container.addMessageListener(redisPushStreamResponseListener, new PatternTopic(VideoManagerConstants.VM_MSG_STREAM_PUSH_RESPONSE));
|
||||
container.addMessageListener(redisCloseStreamMsgListener, new PatternTopic(VideoManagerConstants.VM_MSG_STREAM_PUSH_CLOSE));
|
||||
return container;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.genersoft.iot.vmp.conf.security;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.genersoft.iot.vmp.conf.security.dto.JwtUser;
|
||||
import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
||||
import org.springframework.security.core.AuthenticationException;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
@@ -12,6 +13,7 @@ import org.springframework.stereotype.Component;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
/**
|
||||
* 处理匿名用户访问逻辑
|
||||
@@ -35,6 +37,8 @@ public class AnonymousAuthenticationEntryPoint implements AuthenticationEntry
|
||||
jsonObject.put("msg", e.getMessage());
|
||||
}
|
||||
response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
|
||||
response.setContentType(MediaType.APPLICATION_JSON_VALUE);
|
||||
response.setCharacterEncoding(StandardCharsets.UTF_8.name());
|
||||
try {
|
||||
response.getWriter().print(jsonObject.toJSONString());
|
||||
} catch (IOException ioException) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.genersoft.iot.vmp.conf.security;
|
||||
|
||||
import com.genersoft.iot.vmp.conf.UserSetting;
|
||||
import org.junit.jupiter.api.Order;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
Reference in New Issue
Block a user