优化注销判定,主动注销不再确定状态
This commit is contained in:
@@ -26,7 +26,7 @@ public interface IDeviceService {
|
||||
* 设备下线
|
||||
* @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) {
|
||||
log.info("[设备状态] 到期, 编号: {}", deviceId);
|
||||
offline(deviceId, "保活到期");
|
||||
offline(deviceId, "保活到期", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -383,7 +383,7 @@ public class DeviceServiceImpl implements IDeviceService, CommandLineRunner {
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void offline(String deviceId, String reason) {
|
||||
public void offline(String deviceId, String reason, boolean check) {
|
||||
Device device = getDeviceByDeviceIdFromDb(deviceId);
|
||||
if (device == null) {
|
||||
log.warn("[设备不存在] device:{}", deviceId);
|
||||
@@ -391,7 +391,7 @@ public class DeviceServiceImpl implements IDeviceService, CommandLineRunner {
|
||||
}
|
||||
|
||||
// 主动查询设备状态, 没有HostAddress无法发送请求,可能是手动添加的设备
|
||||
if (device.getHostAddress() != null) {
|
||||
if (check && device.getHostAddress() != null) {
|
||||
Boolean deviceStatus = getDeviceStatus(device);
|
||||
if (deviceStatus != null && deviceStatus) {
|
||||
log.info("[设备离线] 主动探测发现设备在线,暂不处理 device:{}", deviceId);
|
||||
@@ -471,7 +471,7 @@ public class DeviceServiceImpl implements IDeviceService, CommandLineRunner {
|
||||
}
|
||||
if (!deviceStatusTaskRunner.containsKey(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())) {
|
||||
online(device, null);
|
||||
}else {
|
||||
offline(device.getDeviceId(), "设备状态查询结果:" + data.trim());
|
||||
offline(device.getDeviceId(), "设备状态查询结果:" + data.trim(), true);
|
||||
}
|
||||
if (callback != null) {
|
||||
callback.run(code, msg, data);
|
||||
|
||||
@@ -117,7 +117,7 @@ public class RegisterRequestProcessor extends SIPRequestProcessorParent implemen
|
||||
device.setRegisterTime(DateUtil.getNow());
|
||||
deviceService.online(device, null);
|
||||
} else {
|
||||
deviceService.offline(deviceId, "主动注销");
|
||||
deviceService.offline(deviceId, "主动注销", false);
|
||||
}
|
||||
return;
|
||||
}else {
|
||||
@@ -228,7 +228,7 @@ public class RegisterRequestProcessor extends SIPRequestProcessorParent implemen
|
||||
deviceService.online(device, sipTransactionInfo);
|
||||
} else {
|
||||
log.info("[注销成功] deviceId: {}->{}", deviceId, requestAddress);
|
||||
deviceService.offline(deviceId, "主动注销");
|
||||
deviceService.offline(deviceId, "主动注销", false);
|
||||
}
|
||||
} catch (SipException | NoSuchAlgorithmException | ParseException e) {
|
||||
log.error("未处理的异常 ", e);
|
||||
|
||||
Reference in New Issue
Block a user