解决null值转换为字符串 "null"问题

This commit is contained in:
zq
2026-01-27 16:55:04 +08:00
parent 14904ea6b2
commit 4b58838d5d

View File

@ -407,7 +407,7 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i
String status = dataStack.getWorkStatus(); String status = dataStack.getWorkStatus();
int result = 5; int result = 5;
if (status != null && !status.trim().isEmpty() && status.contains("null")) { if (status != null && !status.trim().isEmpty()) {
// 1.0 -> 1, 2.0 -> 2 // 1.0 -> 1, 2.0 -> 2
result = (int) Double.parseDouble(status.trim()); result = (int) Double.parseDouble(status.trim());
} }
@ -863,7 +863,7 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i
//TODO 临时解决上送数据为浮点的问题 start //TODO 临时解决上送数据为浮点的问题 start
String status = pcsData.getWorkStatus(); String status = pcsData.getWorkStatus();
int result = 0; int result = 0;
if (status != null && !status.trim().isEmpty() && status.contains("null")) { if (status != null && !status.trim().isEmpty()) {
// 1.0 -> 1, 2.0 -> 2 // 1.0 -> 1, 2.0 -> 2
result = (int) Double.parseDouble(status.trim()); result = (int) Double.parseDouble(status.trim());
} }
@ -1003,7 +1003,7 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i
log.info("临时解决上送数据为浮点的问题"); log.info("临时解决上送数据为浮点的问题");
String status = data.getWorkStatus(); String status = data.getWorkStatus();
int result = 5; int result = 5;
if (status != null && !status.trim().isEmpty() && status.contains("null")) { if (status != null && !status.trim().isEmpty()) {
// 1.0 -> 1, 2.0 -> 2 // 1.0 -> 1, 2.0 -> 2
result = (int) Double.parseDouble(status.trim()); result = (int) Double.parseDouble(status.trim());
} }