fix: 盐度补偿设定值同步到设备表中。
This commit is contained in:
@@ -295,7 +295,12 @@ public class DeviceDataHandler {
|
|||||||
log.error("保存数据失败[{}]: {}", deviceName, e.getMessage());
|
log.error("保存数据失败[{}]: {}", deviceName, e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//
|
|
||||||
|
// 处理 salinitySet(盐度补偿设定值):同步到设备表,不入 TDengine
|
||||||
|
if (params != null) {
|
||||||
|
handleSalinitySet(deviceName, params);
|
||||||
|
}
|
||||||
|
|
||||||
// 检查是否触发报警
|
// 检查是否触发报警
|
||||||
if (params != null && sensorData != null) {
|
if (params != null && sensorData != null) {
|
||||||
checkAndTriggerAlarm(productKey, deviceName, sensorData);
|
checkAndTriggerAlarm(productKey, deviceName, sensorData);
|
||||||
@@ -2601,6 +2606,44 @@ public class DeviceDataHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 处理 salinitySet(盐度补偿设定值)
|
||||||
|
* 设备上报的盐度补偿设定值同步更新到设备表(Device.salinityCompensation),不入 TDengine。
|
||||||
|
* 通过遍历 keySet 做精确字符串比较,避免 Hutool ignoreCase 下 salinitySet 误匹配为 salinity。
|
||||||
|
*
|
||||||
|
* @param deviceName 设备名称(serialNum)
|
||||||
|
* @param params 上报参数
|
||||||
|
*/
|
||||||
|
private void handleSalinitySet(String deviceName, JSONObject params) {
|
||||||
|
for (String k : params.keySet()) {
|
||||||
|
if ("salinitySet".equals(k)) {
|
||||||
|
Double salinitySet = params.getDouble(k);
|
||||||
|
if (salinitySet != null) {
|
||||||
|
try {
|
||||||
|
Device device = deviceMapper.selectOne(
|
||||||
|
new com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper<Device>()
|
||||||
|
.eq(Device::getSerialNum, deviceName)
|
||||||
|
.select(Device::getId)
|
||||||
|
.last("LIMIT 1")
|
||||||
|
);
|
||||||
|
if (device == null) {
|
||||||
|
log.debug("设备不存在,无法更新盐度补偿设定值: {}", deviceName);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Device updateDevice = new Device();
|
||||||
|
updateDevice.setId(device.getId());
|
||||||
|
updateDevice.setSalinityCompensation(salinitySet);
|
||||||
|
deviceMapper.updateById(updateDevice);
|
||||||
|
log.debug("盐度补偿设定值已同步到设备表: {} = {}", deviceName, salinitySet);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("更新盐度补偿设定值失败[{}]: {}", deviceName, e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新设备表的实时数据
|
* 更新设备表的实时数据
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user