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