Browse Source

优化返回围栏日期格式

Simon 1 year ago
parent
commit
b77ad17f9f

+ 2 - 2
ruoyi-admin/src/main/resources/application.yml

@@ -56,9 +56,9 @@ spring:
     # 测试环境
     #    active: test
     # 开发环境
-    active: dev
+#    active: dev
     # 生产环境
-#    active: druid
+    active: druid
 
   # 文件上传
   servlet:

+ 5 - 3
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TElectronicFenceServiceImpl.java

@@ -176,11 +176,13 @@ public class TElectronicFenceServiceImpl implements ITElectronicFenceService {
         // 将时间戳转换为LocalDateTime对象
         LocalDateTime dateTime = LocalDateTime.ofEpochSecond(timestamp, 0, ZoneOffset.UTC);
         // 获取当前日期
-        LocalDateTime currentDate = LocalDateTime.now().withHour(dateTime.getHour())
+        LocalDateTime currentDate = LocalDateTime.now()
+                .withHour(dateTime.getHour())
                 .withMinute(dateTime.getMinute())
-                .withSecond(dateTime.getSecond());
+                .withSecond(0)
+                .withNano(0);
         // 将当前日期转换为时间戳
-        long currentTimestamp = currentDate.toEpochSecond(ZoneOffset.UTC);
+        long currentTimestamp = currentDate.toInstant(ZoneOffset.UTC).toEpochMilli();
         return currentTimestamp;
     }