TRX hai 1 ano
pai
achega
fbfebdc61d

+ 3 - 0
OneCardIotServer/src/main/java/com/zhongshu/iot/server/core/domain/iot/IotDeviceData.java

@@ -55,6 +55,9 @@ public class IotDeviceData extends SuperEntity {
     @Schema(description = "数据类型,如:当前数据,历史数据")
     private IotDeviceDataType dataType = IotDeviceDataType.Current;
 
+    @Schema(description = "整个推送的值")
+    private Object mqttParam;
+
     //------------------------------时间信息 start--------------------
     @Schema(description = "年份,如:2024")
     private Integer year;

+ 2 - 1
OneCardIotServer/src/main/java/com/zhongshu/iot/server/core/service/iot/IotDeviceDataService.java

@@ -44,7 +44,7 @@ public class IotDeviceDataService {
      * @param value
      * @return
      */
-    public ResultContent saveProperty(String deviceId, String property, Object value) {
+    public ResultContent saveProperty(String deviceId, String property, Object value, Object mqttParam) {
         List<IotMain> iotMains = iotMainDao.findByDeviceIdAndIdentifierAndIotDataType(deviceId, property, IotDataType.Device);
         if (ObjectUtils.isNotEmpty(iotMains)) {
 
@@ -72,6 +72,7 @@ public class IotDeviceDataService {
             temp.setDataType(IotDeviceDataType.Current);
             temp.setTimes();
             temp.setTimeStr(DateUtils.paresTime(System.currentTimeMillis(), DateUtils.FORMAT_LONG));
+            temp.setMqttParam(mqttParam);
             iotDeviceDataDao.save(temp);
 
             return ResultContent.buildSuccess();

+ 8 - 5
OneCardIotServer/src/main/java/com/zhongshu/iot/server/core/service/iot/IotPropertyService.java

@@ -57,14 +57,14 @@ public class IotPropertyService extends SuperService {
         List<DevicePropertyParam> list = param.getList();
         if (ObjectUtils.isNotEmpty(list)) {
             for (DevicePropertyParam devicePropertyParam : list) {
-                saveProperties(devicePropertyParam, result);
+                saveProperties(devicePropertyParam, result, param);
             }
         }
         result.setSuccess("成功");
         return ResultContent.buildSuccess(result);
     }
 
-    private void saveProperties(DevicePropertyParam param, PropertyResult result) {
+    private void saveProperties(DevicePropertyParam param, PropertyResult result, Object mqttParam) {
         String deviceId = param.getDeviceId();
         PropertyResult.DeviceAttrs deviceAttrs = result.create(deviceId);
         DeviceInfo deviceInfo = deviceInfoDao.findTopByDeviceId(deviceId);
@@ -77,13 +77,16 @@ public class IotPropertyService extends SuperService {
         if (ObjectUtils.isNotEmpty(params)) {
             for (String key : params.keySet()) {
                 Object value = params.get(key);
-                saveProperty(deviceId, key, value, deviceAttrs);
+                saveProperty(deviceId, key, value, deviceAttrs, mqttParam);
             }
         }
     }
 
-    private void saveProperty(String deviceId, String property, Object value, PropertyResult.DeviceAttrs deviceAttrs) {
-        ResultContent resultContent = iotDeviceDataService.saveProperty(deviceId, property, value);
+    private void saveProperty(String deviceId, String property,
+            Object value, PropertyResult.DeviceAttrs deviceAttrs,
+            Object mqttParam
+    ) {
+        ResultContent resultContent = iotDeviceDataService.saveProperty(deviceId, property, value, mqttParam);
         if (resultContent.isSuccess()) {
             deviceAttrs.setSuccess();
         } else {