mirror of
https://gitee.com/pan648540858/wvp-GB28181-pro.git
synced 2026-05-06 14:07:49 +08:00
优化心跳时间的写入
This commit is contained in:
parent
b2772a0a1b
commit
2c774ae155
@ -216,4 +216,18 @@ public class Device {
|
||||
public boolean checkWgs84() {
|
||||
return geoCoordSys.equalsIgnoreCase("WGS84");
|
||||
}
|
||||
|
||||
public Integer getHeartBeatCount() {
|
||||
if (heartBeatCount == null) {
|
||||
return 3;
|
||||
}
|
||||
return heartBeatCount;
|
||||
}
|
||||
|
||||
public Integer getHeartBeatInterval() {
|
||||
if (heartBeatCount == null) {
|
||||
return 60;
|
||||
}
|
||||
return heartBeatInterval;
|
||||
}
|
||||
}
|
||||
|
||||
@ -465,7 +465,7 @@ public interface DeviceMapper {
|
||||
" UPDATE" +
|
||||
" wvp_device" +
|
||||
" SET keepalive_time=#{item.keepaliveTime}" +
|
||||
" WHERE device_id=#{item.deviceId}"+
|
||||
" WHERE id=#{item.id}"+
|
||||
"</foreach>" +
|
||||
"</script>"})
|
||||
void batchUpdateForKeepalive(List<Device> devices);
|
||||
|
||||
@ -26,6 +26,7 @@ import javax.sip.RequestEvent;
|
||||
import javax.sip.SipException;
|
||||
import javax.sip.message.Response;
|
||||
import java.text.ParseException;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.BlockingQueue;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@ -49,7 +50,7 @@ public class KeepaliveNotifyMessageHandler extends SIPRequestProcessorParent imp
|
||||
private IDeviceService deviceService;
|
||||
|
||||
@Autowired
|
||||
private DeviceStatusManager statusTaskRunner;
|
||||
private DeviceStatusManager deviceStatusManager;
|
||||
|
||||
@Autowired
|
||||
private UserSetting userSetting;
|
||||
@ -83,7 +84,7 @@ public class KeepaliveNotifyMessageHandler extends SIPRequestProcessorParent imp
|
||||
if (device.isOnLine()) {
|
||||
taskQueue.add(device);
|
||||
long expiresTime = Math.min(device.getExpires(), device.getHeartBeatInterval() * device.getHeartBeatCount()) * 1000L;
|
||||
statusTaskRunner.add(device.getDeviceId(), expiresTime + System.currentTimeMillis());
|
||||
deviceStatusManager.add(device.getDeviceId(), expiresTime + System.currentTimeMillis());
|
||||
} else {
|
||||
if (userSetting.getGbDeviceOnline() == 1) {
|
||||
// 对于已经离线的设备判断他的注册是否已经过期
|
||||
@ -91,8 +92,7 @@ public class KeepaliveNotifyMessageHandler extends SIPRequestProcessorParent imp
|
||||
}
|
||||
}
|
||||
}
|
||||
@Scheduled(fixedDelay = 1000, timeUnit = TimeUnit.MILLISECONDS)
|
||||
@Async
|
||||
@Scheduled(fixedDelay = 1, timeUnit = TimeUnit.SECONDS)
|
||||
public void executeUpdateDeviceList() {
|
||||
if (!taskQueue.isEmpty()) {
|
||||
deviceService.updateDeviceListForKeepalive(taskQueue.stream().toList());
|
||||
|
||||
Loading…
Reference in New Issue
Block a user