mirror of
https://gitee.com/pan648540858/wvp-GB28181-pro.git
synced 2026-05-23 13:37:49 +08:00
优化注销判定,主动注销不再确定状态
This commit is contained in:
parent
8c54895c47
commit
bca77f79cc
@ -26,7 +26,7 @@ public interface IDeviceService {
|
|||||||
* 设备下线
|
* 设备下线
|
||||||
* @param deviceId 设备编号
|
* @param deviceId 设备编号
|
||||||
*/
|
*/
|
||||||
void offline(String deviceId, String reason);
|
void offline(String deviceId, String reason, boolean check);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 添加目录订阅
|
* 添加目录订阅
|
||||||
|
|||||||
@ -274,7 +274,7 @@ public class DeviceServiceImpl implements IDeviceService, CommandLineRunner {
|
|||||||
|
|
||||||
private void deviceStatusExpire(String deviceId, SipTransactionInfo transactionInfo) {
|
private void deviceStatusExpire(String deviceId, SipTransactionInfo transactionInfo) {
|
||||||
log.info("[设备状态] 到期, 编号: {}", deviceId);
|
log.info("[设备状态] 到期, 编号: {}", deviceId);
|
||||||
offline(deviceId, "保活到期");
|
offline(deviceId, "保活到期", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -383,7 +383,7 @@ public class DeviceServiceImpl implements IDeviceService, CommandLineRunner {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public void offline(String deviceId, String reason) {
|
public void offline(String deviceId, String reason, boolean check) {
|
||||||
Device device = getDeviceByDeviceIdFromDb(deviceId);
|
Device device = getDeviceByDeviceIdFromDb(deviceId);
|
||||||
if (device == null) {
|
if (device == null) {
|
||||||
log.warn("[设备不存在] device:{}", deviceId);
|
log.warn("[设备不存在] device:{}", deviceId);
|
||||||
@ -391,7 +391,7 @@ public class DeviceServiceImpl implements IDeviceService, CommandLineRunner {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 主动查询设备状态, 没有HostAddress无法发送请求,可能是手动添加的设备
|
// 主动查询设备状态, 没有HostAddress无法发送请求,可能是手动添加的设备
|
||||||
if (device.getHostAddress() != null) {
|
if (check && device.getHostAddress() != null) {
|
||||||
Boolean deviceStatus = getDeviceStatus(device);
|
Boolean deviceStatus = getDeviceStatus(device);
|
||||||
if (deviceStatus != null && deviceStatus) {
|
if (deviceStatus != null && deviceStatus) {
|
||||||
log.info("[设备离线] 主动探测发现设备在线,暂不处理 device:{}", deviceId);
|
log.info("[设备离线] 主动探测发现设备在线,暂不处理 device:{}", deviceId);
|
||||||
@ -471,7 +471,7 @@ public class DeviceServiceImpl implements IDeviceService, CommandLineRunner {
|
|||||||
}
|
}
|
||||||
if (!deviceStatusTaskRunner.containsKey(device.getDeviceId())) {
|
if (!deviceStatusTaskRunner.containsKey(device.getDeviceId())) {
|
||||||
log.debug("[状态丢失] 执行设备离线, 编号: {},", device.getDeviceId());
|
log.debug("[状态丢失] 执行设备离线, 编号: {},", device.getDeviceId());
|
||||||
offline(device.getDeviceId(), "");
|
offline(device.getDeviceId(), "", true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1202,7 +1202,7 @@ public class DeviceServiceImpl implements IDeviceService, CommandLineRunner {
|
|||||||
if ("ONLINE".equalsIgnoreCase(data.trim())) {
|
if ("ONLINE".equalsIgnoreCase(data.trim())) {
|
||||||
online(device, null);
|
online(device, null);
|
||||||
}else {
|
}else {
|
||||||
offline(device.getDeviceId(), "设备状态查询结果:" + data.trim());
|
offline(device.getDeviceId(), "设备状态查询结果:" + data.trim(), true);
|
||||||
}
|
}
|
||||||
if (callback != null) {
|
if (callback != null) {
|
||||||
callback.run(code, msg, data);
|
callback.run(code, msg, data);
|
||||||
|
|||||||
@ -117,7 +117,7 @@ public class RegisterRequestProcessor extends SIPRequestProcessorParent implemen
|
|||||||
device.setRegisterTime(DateUtil.getNow());
|
device.setRegisterTime(DateUtil.getNow());
|
||||||
deviceService.online(device, null);
|
deviceService.online(device, null);
|
||||||
} else {
|
} else {
|
||||||
deviceService.offline(deviceId, "主动注销");
|
deviceService.offline(deviceId, "主动注销", false);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}else {
|
}else {
|
||||||
@ -228,7 +228,7 @@ public class RegisterRequestProcessor extends SIPRequestProcessorParent implemen
|
|||||||
deviceService.online(device, sipTransactionInfo);
|
deviceService.online(device, sipTransactionInfo);
|
||||||
} else {
|
} else {
|
||||||
log.info("[注销成功] deviceId: {}->{}", deviceId, requestAddress);
|
log.info("[注销成功] deviceId: {}->{}", deviceId, requestAddress);
|
||||||
deviceService.offline(deviceId, "主动注销");
|
deviceService.offline(deviceId, "主动注销", false);
|
||||||
}
|
}
|
||||||
} catch (SipException | NoSuchAlgorithmException | ParseException e) {
|
} catch (SipException | NoSuchAlgorithmException | ParseException e) {
|
||||||
log.error("未处理的异常 ", e);
|
log.error("未处理的异常 ", e);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user