|
@@ -4,6 +4,7 @@ import cn.hutool.core.io.IoUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import com.alibaba.fastjson2.JSON;
|
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
|
+import com.alibaba.fastjson2.JSONReader;
|
|
|
import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder;
|
|
|
import com.fjhx.common.constant.SourceConstant;
|
|
|
import com.fjhx.iot.constants.RedisConstant;
|
|
@@ -108,7 +109,7 @@ public class DtaListener {
|
|
|
try {
|
|
|
|
|
|
String messageBodyStr = message.getBody(String.class);
|
|
|
- MessageBody messageBody = JSONObject.parseObject(messageBodyStr, MessageBody.class);
|
|
|
+ MessageBody messageBody = JSONObject.parseObject(messageBodyStr, MessageBody.class, JSONReader.Feature.SupportSmartMatch);
|
|
|
|
|
|
if (messageBody == null) {
|
|
|
log.error(" messageBody == null ");
|
|
@@ -199,12 +200,23 @@ public class DtaListener {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
+ JSONObject deviceData = properties.getJSONObject("DeviceData");
|
|
|
switch (deviceType) {
|
|
|
case "ebc":
|
|
|
- doEbc(productId, deviceId, eventTime, properties.getJSONObject("DeviceData").toJavaObject(EbcDto.class));
|
|
|
+ doEbc(productId, deviceId, eventTime, deviceData.toJavaObject(EbcDto.class));
|
|
|
break;
|
|
|
+
|
|
|
+ // 默认上位机
|
|
|
default:
|
|
|
- log.error("未知 deviceType:{}", deviceType);
|
|
|
+
|
|
|
+ // 设备编号
|
|
|
+ String equipmentNo = deviceData.getString("equipmentNo");
|
|
|
+
|
|
|
+ if (equipmentNo != null) {
|
|
|
+ deviceData.put("iot_productId", productId);
|
|
|
+ deviceData.put("iot_deviceId", deviceId);
|
|
|
+ redisCache.setCacheObject(RedisConstant.DEVICE_COMPUTER_PREFIX + ":" + equipmentNo, deviceData);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
DynamicDataSourceContextHolder.clear();
|