Kaynağa Gözat

Merge branch 'mqy20260511' of http://114.215.146.132:3000/Mqy/Wisdom-Data into mqy20260511

mqy20260511
lenovo 2 hafta önce
ebeveyn
işleme
fd2961b2b3

+ 9
- 5
iot-platform/src/main/java/com/iot/platform/task/VehicleSyncTask.java Dosyayı Görüntüle

@@ -27,6 +27,7 @@ public class VehicleSyncTask {
27 27
 
28 28
     private final StringRedisTemplate stringRedisTemplate;
29 29
     private final SysRealtimeService sysrealtimeService;
30
+    private final Set<String> createdTables = new HashSet<>();
30 31
 
31 32
     public VehicleSyncTask(StringRedisTemplate stringRedisTemplate,
32 33
                            SysRealtimeService sysrealtimeService) {
@@ -93,11 +94,14 @@ public class VehicleSyncTask {
93 94
                 String dbPrefix = controllerId.length() >= 2 ? controllerId.substring(0, 2) : controllerId;
94 95
                 String tableName = "pe_iot_" + dbPrefix;
95 96
 
96
-                try {
97
-                    sysrealtimeService.createRealtime(tableName);
98
-                } catch (Exception e) {
99
-                    log.error("创建表失败: {} | {}", tableName, e.getMessage(), e);
100
-                    continue;
97
+                if (!createdTables.contains(tableName)) {
98
+                    try {
99
+                        sysrealtimeService.createRealtime(tableName);
100
+                        createdTables.add(tableName);
101
+                    } catch (Exception e) {
102
+                        log.error("创建表失败: {} | {}", tableName, e.getMessage(), e);
103
+                        continue;
104
+                    }
101 105
                 }
102 106
 
103 107
                 String createTime = getStringValue(dataMap, "createTime");

Loading…
İptal
Kaydet