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:
localip: 192.168.1.7 localip: 192.168.1.7
#公网ip,用于判断视频播放 #公网ip,用于判断视频播放
serverip: 121.40.203.197 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;
@Configuration @Configuration
@EnableScheduling @EnableScheduling
public class RegisterServer { public class RegisterServer {
private static String sercer_ip = ""; private static String localip = "";
private static String accessmode = "";
@Autowired @Autowired
private Environment env; private Environment env;
@PostConstruct @PostConstruct
public void config() { public void config() {
sercer_ip = env.getProperty("localip"); localip = env.getProperty("localip");
accessmode = env.getProperty("accessmode");
} }
@Autowired @Autowired
private ICameraService cameraService; private ICameraService cameraService;
@ -48,8 +50,8 @@ public class RegisterServer {
private void start(){ private void start(){
String ip = IPUtils.getLocalIpAddress(); String ip = IPUtils.getLocalIpAddress();
System.out.println(ip); System.out.println(ip);
if(sercer_ip.equals(ip)){ if(localip.equals(ip) && "0".equals(accessmode)){
R result = cameraService.register(sercer_ip); R result = cameraService.register(localip);
if("0".equals(result.get("code").toString())){ if("0".equals(result.get("code").toString())){
System.out.println("主动注册服务已启动"); System.out.println("主动注册服务已启动");
}else{ }else{

Loading…
Cancel
Save