修改消防数据查询报错问题

This commit is contained in:
zq
2026-01-26 16:46:31 +08:00
parent 1531af2969
commit 619c05e965
3 changed files with 12 additions and 6 deletions

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()) { if (status != null && !status.trim().isEmpty() && status.contains("null")) {
// 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()) { if (status != null && !status.trim().isEmpty() && status.contains("null")) {
// 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()) { if (status != null && !status.trim().isEmpty() && status.contains("null")) {
// 1.0 -> 1, 2.0 -> 2 // 1.0 -> 1, 2.0 -> 2
result = (int) Double.parseDouble(status.trim()); result = (int) Double.parseDouble(status.trim());
} }

View File

@ -220,6 +220,8 @@ public class EmsDeviceSettingServiceImpl implements IEmsDeviceSettingService
} }
String deviceFromMqtt = mqttJson.get("Device").toString(); String deviceFromMqtt = mqttJson.get("Device").toString();
String jsonData = mqttJson.get("Data").toString(); String jsonData = mqttJson.get("Data").toString();
Long updateTime = mqttJson.getLong("timestamp");
Date latestUpdateTime = DateUtils.convertUpdateTime(updateTime);
if (StringUtils.isEmpty(jsonData) || !deviceId.equals(deviceFromMqtt)) { if (StringUtils.isEmpty(jsonData) || !deviceId.equals(deviceFromMqtt)) {
return response; return response;
} }
@ -233,8 +235,6 @@ public class EmsDeviceSettingServiceImpl implements IEmsDeviceSettingService
pointInfo.setDataPoint(dataKey); pointInfo.setDataPoint(dataKey);
} }
pointInfo.setPointValue(obj.get(dataKey)); pointInfo.setPointValue(obj.get(dataKey));
Long updateTime = Long.valueOf(mqttJson.get("timestamp").toString());
Date latestUpdateTime = convertUpdateTime(updateTime);
pointInfo.setUpdateTime(latestUpdateTime); pointInfo.setUpdateTime(latestUpdateTime);
} }
} }
@ -274,7 +274,8 @@ public class EmsDeviceSettingServiceImpl implements IEmsDeviceSettingService
PointQueryResponse::getPointValue, PointQueryResponse::getPointValue,
EmsDeviceSettingServiceImpl::compareMultiType); EmsDeviceSettingServiceImpl::compareMultiType);
} else {// 默认按updateTime排序 } else {// 默认按updateTime排序
comparator = Comparator.comparing(PointQueryResponse::getUpdateTime); comparator = Comparator.comparing(PointQueryResponse::getUpdateTime,
Comparator.nullsLast(Comparator.naturalOrder()));
} }
// 排序方式 // 排序方式
String sortMethod = request.getSortMethod(); String sortMethod = request.getSortMethod();

View File

@ -52,6 +52,8 @@ import java.util.Objects;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -63,6 +65,8 @@ import org.springframework.util.CollectionUtils;
@Service @Service
public class SingleSiteServiceImpl implements ISingleSiteService { public class SingleSiteServiceImpl implements ISingleSiteService {
private static final Logger log = LoggerFactory.getLogger(SingleSiteServiceImpl.class);
private static final String CLUSTER_DATA_TEP = "温度"; private static final String CLUSTER_DATA_TEP = "温度";
private static final String CLUSTER_DATA_VOLTAGE = "电压"; private static final String CLUSTER_DATA_VOLTAGE = "电压";
@ -877,6 +881,7 @@ public class SingleSiteServiceImpl implements ISingleSiteService {
// 从redis取堆单个详细数据 // 从redis取堆单个详细数据
String xfDeviceId = xfDevice.get("id").toString(); String xfDeviceId = xfDevice.get("id").toString();
EmsXfData xfData = redisCache.getCacheObject(RedisKeyConstants.XF + siteId + "_" + xfDeviceId); EmsXfData xfData = redisCache.getCacheObject(RedisKeyConstants.XF + siteId + "_" + xfDeviceId);
log.info("查询消防数据xfDataVo:{}", xfDataVo);
if (xfData != null) { if (xfData != null) {
BeanUtils.copyProperties(xfData, xfDataVo); BeanUtils.copyProperties(xfData, xfDataVo);
xfDataVo.setDataUpdateTime(xfData.getDataTimestamp()); xfDataVo.setDataUpdateTime(xfData.getDataTimestamp());