Browse Source

youhua

master
4670101279 2 years ago
parent
commit
063d606f45
  1. 2
      ruoyi-admin/src/main/resources/application.yml
  2. 10
      ruoyi-code/src/main/java/com/ruoyi/code/camera/scheduled/RegisterServer.java

2
ruoyi-admin/src/main/resources/application.yml

@ -133,3 +133,5 @@ xss: @@ -133,3 +133,5 @@ xss:
localip: 192.168.1.7
#公网ip,用于判断视频播放
serverip: 121.40.203.197
#接入方式 0-主动注册 1-网络
accessmode: 0

10
ruoyi-code/src/main/java/com/ruoyi/code/camera/scheduled/RegisterServer.java

@ -28,14 +28,16 @@ import java.util.List; @@ -28,14 +28,16 @@ import java.util.List;
@Configuration
@EnableScheduling
public class RegisterServer {
private static String sercer_ip = "";
private static String localip = "";
private static String accessmode = "";
@Autowired
private Environment env;
@PostConstruct
public void config() {
sercer_ip = env.getProperty("localip");
localip = env.getProperty("localip");
accessmode = env.getProperty("accessmode");
}
@Autowired
private ICameraService cameraService;
@ -48,8 +50,8 @@ public class RegisterServer { @@ -48,8 +50,8 @@ public class RegisterServer {
private void start(){
String ip = IPUtils.getLocalIpAddress();
System.out.println(ip);
if(sercer_ip.equals(ip)){
R result = cameraService.register(sercer_ip);
if(localip.equals(ip) && "0".equals(accessmode)){
R result = cameraService.register(localip);
if("0".equals(result.get("code").toString())){
System.out.println("主动注册服务已启动");
}else{

Loading…
Cancel
Save