Эх сурвалжийг харах

调整时间戳字段显示

Levi.u 4 жил өмнө
parent
commit
002b027e48

+ 2 - 2
src/main/java/com/ebei/screen/ScreenApplication.java

@@ -2,10 +2,10 @@ package com.ebei.screen;
 
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
-import org.springframework.scheduling.annotation.EnableAsync;
+import org.springframework.scheduling.annotation.EnableScheduling;
 
 @SpringBootApplication
-@EnableAsync
+@EnableScheduling
 public class ScreenApplication {
 
     public static void main(String[] args) {

+ 5 - 1
src/main/java/com/ebei/screen/common/task/EbaTask.java

@@ -19,7 +19,11 @@ public class EbaTask {
     @Autowired
     private EbaSystemService ebaSystemService;
 
-    @Scheduled(cron = "*/5 * * * * ?")
+    /**
+     * 每小时执行一次数据拉取
+     */
+    @Scheduled(cron = "0 0 */1 * * ?")
     public void execute() {
+        ebaSystemService.initData();
     }
 }

+ 11 - 0
src/main/java/com/ebei/screen/common/util/LeviUtils.java

@@ -1,6 +1,7 @@
 package com.ebei.screen.common.util;
 
 import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.date.DateUtil;
 import cn.hutool.core.date.LocalDateTimeUtil;
 import cn.hutool.core.util.ObjectUtil;
 import com.alibaba.fastjson.JSON;
@@ -154,4 +155,14 @@ public class LeviUtils {
         return null;
     }
 
+    /**
+     * 秒级时间戳转字符串
+     *
+     * @param time
+     * @return
+     */
+    public static String convertTime(Object time) {
+        return DateUtil.date(Long.parseLong(time + "000")).toString("yyyy-MM-dd HH:mm:ss");
+    }
+
 }

+ 12 - 0
src/main/java/com/ebei/screen/service/impl/EbaSystemServiceImpl.java

@@ -59,6 +59,7 @@ public class EbaSystemServiceImpl implements EbaSystemService {
         initRealDataDeviceList();
         initMobjectList();
         initIotList();
+        log.info("数据全部初始化完毕");
     }
 
     /**
@@ -79,6 +80,7 @@ public class EbaSystemServiceImpl implements EbaSystemService {
         update.set("expire", LocalDateTime.now());
         mongoTemplate.upsert(query, update, "ebaAuth");
         EbaUtils.token = token;
+        log.info("当前用户名token 初始化完毕!");
     }
 
     /**
@@ -99,6 +101,7 @@ public class EbaSystemServiceImpl implements EbaSystemService {
             update.set("data", data);
             mongoTemplate.upsert(query, update, "ebaAuth");
             EbaUtils.project = data;
+            log.info("当前用户名下项目列表 初始化完毕!");
         }
     }
 
@@ -120,6 +123,7 @@ public class EbaSystemServiceImpl implements EbaSystemService {
             update.set("data", data);
             mongoTemplate.upsert(query, update, "ebaAuth");
             EbaUtils.deviceSystem = data;
+            log.info("设备信息(deviceSys) 初始化完毕!");
         }
     }
 
@@ -141,6 +145,7 @@ public class EbaSystemServiceImpl implements EbaSystemService {
             update.set("data", data);
             mongoTemplate.upsert(query, update, "ebaAuth");
             EbaUtils.deviceType = data;
+            log.info("设备类型信息(deviceType) 初始化完毕!");
         }
     }
 
@@ -162,6 +167,7 @@ public class EbaSystemServiceImpl implements EbaSystemService {
             update.set("data", data);
             mongoTemplate.upsert(query, update, "ebaAuth");
             EbaUtils.deviceParam = data;
+            log.info("设备参数信息(deviceParam) 初始化完毕!");
         }
     }
 
@@ -183,6 +189,7 @@ public class EbaSystemServiceImpl implements EbaSystemService {
             update.set("data", data);
             mongoTemplate.upsert(query, update, "ebaAuth");
             EbaUtils.deviceAlarmType = data;
+            log.info("设备告警类型信息(alarmType) 初始化完毕!");
         }
     }
 
@@ -204,6 +211,7 @@ public class EbaSystemServiceImpl implements EbaSystemService {
             update.set("data", data);
             mongoTemplate.upsert(query, update, "ebaAuth");
             EbaUtils.fireDeviceType = data;
+            log.info("消防设备类型信息(fireDeviceType) 初始化完毕!");
         }
     }
 
@@ -238,6 +246,7 @@ public class EbaSystemServiceImpl implements EbaSystemService {
                 update2.set("data", data2);
                 mongoTemplate.upsert(query2, update2, "ebaAuth");
                 EbaUtils.realDataDevice = data2;
+                log.info("所有项目实时device 初始化完毕!");
             }
         });
     }
@@ -268,6 +277,7 @@ public class EbaSystemServiceImpl implements EbaSystemService {
                 data.put(key, map);
                 update.set("data", data);
                 mongoTemplate.upsert(query, update, "ebaAuth");
+                log.info("所有项目device信息 初始化完毕!");
             }
         });
     }
@@ -291,6 +301,7 @@ public class EbaSystemServiceImpl implements EbaSystemService {
                 List<Map> map = LeviUtils.getJsonFieldMany(str, "data.datas", Map.class);
                 update.set("data", Levi.by(key, map));
                 mongoTemplate.upsert(query, update, "ebaAuth");
+                log.info("所有项目iot信息 初始化完毕!");
             }
         });
     }
@@ -384,6 +395,7 @@ public class EbaSystemServiceImpl implements EbaSystemService {
             dataList.forEach(y -> {
                 Integer alarmType = (Integer) y.get("AlarmType");
                 Integer pid = (Integer) y.get("ProjectId");
+                y.put("AlarmTimeStr", LeviUtils.convertTime(y.get("AlarmTime")));
                 if ((pid.toString()).equals(projectId)) {
                     if (alarmType == 1) {
                         huojing.add(y);