313 lines
9.2 KiB
Plaintext
313 lines
9.2 KiB
Plaintext
package com.sercurityControl.proteam.util;
|
|
|
|
import com.securityControl.common.core.utils.aes.StringHelper;
|
|
import com.securityControl.common.redis.service.RedisService;
|
|
import com.sercurityControl.proteam.domain.vo.SysVideoConfigVo;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.stereotype.Component;
|
|
|
|
import javax.annotation.Resource;
|
|
import java.util.HashMap;
|
|
import java.util.Map;
|
|
|
|
@Component
|
|
@Slf4j
|
|
public class VideoConfigUtil {
|
|
/**
|
|
* 登录平台地址
|
|
*/
|
|
public static String IPADDRESS;
|
|
/**
|
|
* 平台端口
|
|
*/
|
|
public static String PORT;
|
|
/**
|
|
* 账号
|
|
*/
|
|
public static String USER;
|
|
/**
|
|
* 账号
|
|
*/
|
|
public static String PASSWORD;
|
|
/**
|
|
* 请求地址
|
|
*/
|
|
public static String Q2HTTPURL;
|
|
/**
|
|
* 前端连接url
|
|
*/
|
|
public static String webUrl;
|
|
/**
|
|
* 前端连接url-信息外网
|
|
*/
|
|
public static String webUrlN;
|
|
/**
|
|
* 前端视频-websocket
|
|
*/
|
|
public static String wsUrl;
|
|
/**
|
|
* 前端视频-websocket -信息外网
|
|
*/
|
|
public static String wsUrlN;
|
|
|
|
|
|
public static String EPID ;// 登录平台企业ID
|
|
|
|
public static int BFIX ;// 登录平台是否通过网闸模式
|
|
|
|
@Resource
|
|
private RedisService redisService;
|
|
|
|
@Value("${video.ip}")
|
|
public void setIPADDRESS(String IPADDRESS) {
|
|
VideoConfigUtil.IPADDRESS = IPADDRESS;
|
|
}
|
|
|
|
@Value("${video.port}")
|
|
public void setPORT(String PORT) {
|
|
VideoConfigUtil.PORT = PORT;
|
|
}
|
|
|
|
@Value("${video.name}")
|
|
public void setUSER(String USER) {
|
|
VideoConfigUtil.USER = USER;
|
|
}
|
|
|
|
@Value("${video.key}")
|
|
public void setPASSWORD(String PASSWORD) {
|
|
VideoConfigUtil.PASSWORD = PASSWORD;
|
|
}
|
|
|
|
@Value("${video.url}")
|
|
public void setQ2HTTPURL(String q2HTTPURL) {
|
|
Q2HTTPURL = q2HTTPURL;
|
|
}
|
|
@Value("${video.webUrl}")
|
|
public void setWebUrl(String webUrl) {
|
|
VideoConfigUtil.webUrl = webUrl;
|
|
}
|
|
@Value("${video.webUrlN}")
|
|
public void setWebUrlN(String webUrlN) {
|
|
VideoConfigUtil.webUrlN = webUrlN;
|
|
}
|
|
@Value("${video.wsUrl}")
|
|
public void setWsUrl(String wsUrl) {
|
|
VideoConfigUtil.wsUrl = wsUrl;
|
|
}
|
|
@Value("${video.wsUrlN}")
|
|
public void setWsUrlN(String wsUrlN) {
|
|
VideoConfigUtil.wsUrlN = wsUrlN;
|
|
}
|
|
|
|
@Value("${video.epid}")
|
|
public void setEPID(String EPID) {
|
|
VideoConfigUtil.EPID = EPID;
|
|
}
|
|
@Value("${video.bfix}")
|
|
public void setBFIX(int BFIX) {
|
|
VideoConfigUtil.BFIX = BFIX;
|
|
}
|
|
|
|
|
|
public Map<String, Object> getMaps(){
|
|
Map<String, Object> params = new HashMap<>(16);
|
|
Map<String, Object> map = new HashMap<>(16);
|
|
try{
|
|
String ip= redisService.get("video","ip");
|
|
String port= redisService.get("video","port");
|
|
String user=redisService.get("video","user");
|
|
String key=redisService.get("video","pwd");
|
|
String bfix=redisService.get("video","bfix");
|
|
String epid=redisService.get("video","epid");
|
|
if(StringHelper.isEmpty(ip)){
|
|
map.put("address", VideoConfigUtil.IPADDRESS);
|
|
}else{
|
|
map.put("address",ip);
|
|
}
|
|
|
|
if(StringHelper.isEmpty(port)){
|
|
map.put("port", VideoConfigUtil.PORT);
|
|
}else{
|
|
map.put("port",port);
|
|
}
|
|
|
|
if(StringHelper.isEmpty(user)){
|
|
map.put("user", VideoConfigUtil.USER);
|
|
}else{
|
|
map.put("user",user);
|
|
}
|
|
|
|
if(StringHelper.isEmpty(key)){
|
|
map.put("password", VideoConfigUtil.PASSWORD);
|
|
}else{
|
|
map.put("password",key);
|
|
}
|
|
|
|
if(StringHelper.isEmpty(epid)){
|
|
map.put("epid", VideoConfigUtil.EPID);
|
|
}else{
|
|
map.put("epid",epid);
|
|
}
|
|
if(StringHelper.isEmpty(bfix)){
|
|
map.put("fixaddr", VideoConfigUtil.BFIX);
|
|
}else{
|
|
map.put("fixaddr",Integer.parseInt(bfix));
|
|
}
|
|
|
|
String rucan="address="+map.get("address").toString()+"&port="+map.get("port").toString()+
|
|
"&user="+map.get("user").toString()+"&epid="+map.get("epid").toString()+
|
|
"&password="+map.get("password").toString()+"&fixaddr="+map.get("fixaddr").toString();
|
|
String data= AesEncryptUtils.encrypt(rucan, AesEncryptUtils.VIDEO_KEY);
|
|
params.put("params",data);
|
|
}catch (Exception e){
|
|
map.put("address", VideoConfigUtil.IPADDRESS);
|
|
map.put("port", VideoConfigUtil.PORT);
|
|
map.put("user", VideoConfigUtil.USER);
|
|
map.put("password", VideoConfigUtil.PASSWORD);
|
|
map.put("epid", VideoConfigUtil.EPID);
|
|
map.put("fixaddr", VideoConfigUtil.BFIX);
|
|
|
|
String rucan="address="+map.get("address").toString()+"&port="+map.get("port").toString()+
|
|
"&user="+map.get("user").toString()+"&epid="+map.get("epid").toString()+
|
|
"&password="+map.get("password").toString()+"&fixaddr="+map.get("fixaddr").toString();
|
|
String data= AesEncryptUtils.encrypt(rucan, AesEncryptUtils.VIDEO_KEY);
|
|
params.put("params",data);
|
|
log.error(e.toString(),e);
|
|
}
|
|
return params;
|
|
}
|
|
|
|
/**
|
|
* 获取
|
|
* @return
|
|
*/
|
|
public SysVideoConfigVo getConfigData(){
|
|
SysVideoConfigVo configVo=new SysVideoConfigVo();
|
|
try{
|
|
String webIp= redisService.get("video","webIp");
|
|
String webPort= redisService.get("video","webPort");
|
|
String webUser= redisService.get("video","webUser");
|
|
String webPwd= redisService.get("video","webPwd");
|
|
String webEpid= redisService.get("video","webEpid");
|
|
String webBfix= redisService.get("video","webBfix");
|
|
String Url= redisService.get("video", "webUrl");
|
|
String UrlN= redisService.get("video","webUrlN");
|
|
String webWsUrl= redisService.get("video","webWsUrl" );
|
|
String webWsUrlN= redisService.get("video","webWsUrlN" );
|
|
|
|
if(StringHelper.isNotEmpty(webIp)){
|
|
configVo.setVideoIp(webIp);
|
|
}else{
|
|
configVo.setVideoIp(IPADDRESS);
|
|
}
|
|
|
|
if(StringHelper.isNotEmpty(webPort)){
|
|
configVo.setVideoPort(webPort);
|
|
}else{
|
|
configVo.setVideoPort(PORT);
|
|
}
|
|
|
|
if(StringHelper.isNotEmpty(webUser)){
|
|
configVo.setVideoUser(webUser);
|
|
}else{
|
|
configVo.setVideoUser(USER);
|
|
}
|
|
if(StringHelper.isNotEmpty(webPwd)){
|
|
configVo.setVideoPassword(webPwd);
|
|
}else{
|
|
configVo.setVideoPassword(PASSWORD);
|
|
}
|
|
if(StringHelper.isNotEmpty(webEpid)){
|
|
configVo.setEpid(webEpid);
|
|
}else{
|
|
configVo.setEpid(EPID);
|
|
}
|
|
|
|
if(StringHelper.isNotEmpty(webBfix)){
|
|
configVo.setBfix(webBfix);
|
|
}else{
|
|
configVo.setBfix(BFIX+"");
|
|
}
|
|
|
|
if(StringHelper.isNotEmpty(Url)){
|
|
configVo.setQ2httpUrl(Url);
|
|
}else{
|
|
configVo.setQ2httpUrl(webUrl);
|
|
}
|
|
|
|
if(StringHelper.isNotEmpty(UrlN)){
|
|
configVo.setQ2httpUrlN(UrlN);
|
|
}else{
|
|
configVo.setQ2httpUrlN(webUrlN);
|
|
}
|
|
|
|
if(StringHelper.isNotEmpty(webWsUrl)){
|
|
configVo.setWebsocketUrl(webWsUrl);
|
|
}else{
|
|
configVo.setWebsocketUrl(wsUrl);
|
|
}
|
|
|
|
if(StringHelper.isNotEmpty(webWsUrlN)){
|
|
configVo.setWebsocketUrlN(webWsUrlN);
|
|
}else{
|
|
configVo.setWebsocketUrlN(wsUrlN);
|
|
}
|
|
}catch (Exception e){
|
|
configVo.setVideoIp(IPADDRESS);
|
|
configVo.setVideoPort(PORT);
|
|
configVo.setVideoUser(USER);
|
|
configVo.setWebsocketUrl(wsUrl);
|
|
configVo.setWebsocketUrlN(wsUrlN);
|
|
configVo.setVideoPassword(PASSWORD);
|
|
configVo.setEpid(EPID);
|
|
configVo.setBfix(BFIX+"");
|
|
configVo.setQ2httpUrl(webUrl);
|
|
configVo.setQ2httpUrlN(webUrlN);
|
|
log.error(e.toString(),e);
|
|
}
|
|
return configVo;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
* 获取url
|
|
* @return
|
|
*/
|
|
public String getUrl(){
|
|
try{
|
|
String url=redisService.get("video","url");
|
|
if(StringHelper.isEmpty(url)){
|
|
return VideoConfigUtil.Q2HTTPURL;
|
|
}
|
|
return url;
|
|
}catch (Exception e){
|
|
log.error(e.toString(),e);
|
|
return VideoConfigUtil.Q2HTTPURL;
|
|
}
|
|
|
|
}
|
|
|
|
public String getConfig(){
|
|
try{
|
|
String config=redisService.get("video","config");
|
|
if(StringHelper.isNotEmpty(config)){
|
|
return config;
|
|
}
|
|
}catch (Exception e){
|
|
log.error(e.toString(),e);
|
|
}
|
|
|
|
return "bns";
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|