fix(device): 添加空值检查避免空指针异常- 在设置设备在线状态时添加对 lastActiveTime 和 clientIP 的空值检查
All checks were successful
ZhenTu-BE/pipeline/head This commit looks good

- 在判断设备是否在线时,增加对 keepaliveAt 时间的空值判断
- 防止因空值导致的 NullPointerException 异常- 提高代码健壮性和稳定性
This commit is contained in:
2025-09-25 15:52:16 +08:00
parent 3c700a42f9
commit 4a05773860
2 changed files with 10 additions and 3 deletions

View File

@@ -294,7 +294,9 @@ public class AppScenicServiceImpl implements AppScenicService {
if (onlineStatus != null) {
deviceRespVO.setUpdateAt(onlineStatus.getKeepaliveAt());
deviceRespVO.setKeepaliveAt(onlineStatus.getKeepaliveAt());
if (new Date().getTime() - onlineStatus.getKeepaliveAt().getTime() > 300000) {
if (onlineStatus.getKeepaliveAt() == null) {
deviceRespVO.setOnline(0);
} else if (new Date().getTime() - onlineStatus.getKeepaliveAt().getTime() > 300000) {
deviceRespVO.setOnline(0);
} else {
deviceRespVO.setOnline(onlineStatus.getOnline());