wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/conf/WVPTimerTask.java

30 lines
880 B
Java
Raw Normal View History

2021-07-14 16:06:31 +08:00
package com.genersoft.iot.vmp.conf;
2022-11-05 20:49:56 +08:00
import com.alibaba.fastjson2.JSONObject;
2021-07-14 16:06:31 +08:00
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
2021-07-14 16:06:31 +08:00
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
@Component
public class WVPTimerTask {
@Autowired
private IRedisCatchStorage redisCatchStorage;
@Value("${server.port}")
private int serverPort;
@Autowired
private SipConfig sipConfig;
2021-07-14 16:06:31 +08:00
@Scheduled(fixedRate = 2 * 1000) //每3秒执行一次
public void execute(){
JSONObject jsonObject = new JSONObject();
jsonObject.put("ip", sipConfig.getShowIp());
jsonObject.put("port", serverPort);
redisCatchStorage.updateWVPInfo(jsonObject, 3);
}
2021-07-14 16:06:31 +08:00
}