|
|
@ -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{ |
|
|
|