Explorar o código

时间戳按分钟截断

欧阳劲驰 hai 1 mes
pai
achega
574473c421

+ 2 - 0
iot-server/iot-server-data/src/main/java/com/shkpr/iot/server/data/service/impl/DataServiceImpl.java

@@ -11,6 +11,7 @@ import org.influxdb.dto.Point;
 import org.springframework.stereotype.Service;
 
 import java.time.ZoneId;
+import java.time.temporal.ChronoUnit;
 import java.util.concurrent.TimeUnit;
 import java.util.stream.Collectors;
 
@@ -41,6 +42,7 @@ public class DataServiceImpl implements DataService {
         if (CollectionUtils.isEmpty(data.getDataValues())) return false;
         //获取时间戳
         long timestamp = data.getDateTime()
+                .truncatedTo(ChronoUnit.MINUTES)
                 .atZone(ZoneId.systemDefault())
                 .toInstant()
                 .toEpochMilli();