Browse Source

设备历史数据切换mysql

lin 4 years ago
parent
commit
cc3c687c7d

+ 2 - 1
smart-city-platform/src/main/java/com/bz/smart_city/dto/DeviceMeasuringDataDTO.java

@@ -4,11 +4,12 @@ import com.fasterxml.jackson.annotation.JsonFormat;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
+import java.io.Serializable;
 import java.util.Date;
 import java.util.Map;
 
 @Data
-public class DeviceMeasuringDataDTO {
+public class DeviceMeasuringDataDTO implements Serializable {
     @ApiModelProperty(value = "值",position = 1)
     private Map<String,String> measuringData;
 

+ 5 - 0
smart-city-platform/src/main/java/com/bz/smart_city/service/impl/DeviceDataDimServiceImpl.java

@@ -128,6 +128,11 @@ public class DeviceDataDimServiceImpl implements DeviceDataDimService {
             deviceMeasuringDataDTO.setMeasuringData(mapTemp);
             dateList.add(deviceMeasuringDataDTO);
         }
+        Collections.sort(dateList, new Comparator<DeviceMeasuringDataDTO>() {
+            public int compare(DeviceMeasuringDataDTO d1, DeviceMeasuringDataDTO d2) {
+                return d2.getDateTime().compareTo(d1.getDateTime()); //降序
+            }
+        });
         return dateList;
     }