优化注销判定,主动注销不再确定状态

This commit is contained in:
lin
2026-01-13 16:25:36 +08:00
parent 8c54895c47
commit bca77f79cc
3 changed files with 8 additions and 8 deletions

View File

@@ -26,7 +26,7 @@ public interface IDeviceService {
* 设备下线
* @param deviceId 设备编号
*/
void offline(String deviceId, String reason);
void offline(String deviceId, String reason, boolean check);
/**
* 添加目录订阅

View File

@@ -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);

View File

@@ -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);