瀏覽代碼

不同步 Channel 表

lamphua 4 週之前
父節點
當前提交
90e812e84a

+ 39
- 39
cmc-temperature-back/cmc-monitoring/src/main/java/com/ruoyi/monitoring/service/impl/AccessSyncServiceImpl.java 查看文件

@@ -32,45 +32,45 @@ public class AccessSyncServiceImpl implements IAccessSyncService {
32 32
 
33 33
         try (Connection conn = DriverManager.getConnection(
34 34
                 Solon.cfg().getProperty("mybatis-flex.datasource.access.jdbcUrl"), "", "")) {
35
-
36
-            // 直接同步 Channel 表
37
-            System.out.println("开始同步Channel表...");
38
-            Integer channelMaxId = sqliteChannelMapper.selectMaxId();
39
-            System.out.println("SQLite Channel表当前最大ID: " + channelMaxId);
40
-
41
-            List<CmcChannel> newChannels = new ArrayList<>();
42
-
43
-            String channelQuery = "SELECT ID, Sensor_No, Info, Ver, Sn, Ca, Cb, Units, LastDT " +
44
-                    "FROM Channel " +
45
-                    "WHERE ID > ? " +
46
-                    "ORDER BY ID ASC";
47
-
48
-            try (PreparedStatement pstmt = conn.prepareStatement(channelQuery)) {
49
-                pstmt.setInt(1, channelMaxId);
50
-                try (ResultSet rs = pstmt.executeQuery()) {
51
-                    while (rs.next()) {
52
-                        CmcChannel channel = new CmcChannel();
53
-                        channel.setId(rs.getInt("ID"));
54
-                        channel.setSensorNo(rs.getInt("Sensor_No"));
55
-                        channel.setInfo(rs.getString("Info"));
56
-                        channel.setVer(rs.getInt("Ver"));
57
-                        channel.setSn(rs.getString("Sn"));
58
-                        channel.setCa(rs.getInt("Ca"));
59
-                        channel.setCb(rs.getInt("Cb"));
60
-                        channel.setUnits(rs.getString("Units"));
61
-                        channel.setLastDT(rs.getString("LastDT"));
62
-                        newChannels.add(channel);
63
-                    }
64
-                }
65
-            }
66
-
67
-            if (!newChannels.isEmpty()) {
68
-                System.out.println("从Access读取到" + newChannels.size() + "条新Channel记录(ID > " + channelMaxId + ")");
69
-                batchInsertChannels(newChannels);
70
-                System.out.println("Channel表同步完成,共同步" + newChannels.size() + "条记录");
71
-            } else {
72
-                System.out.println("没有新的Channel记录需要同步(ID > " + channelMaxId + ")");
73
-            }
35
+//
36
+//            // 直接同步 Channel 表
37
+//            System.out.println("开始同步Channel表...");
38
+//            Integer channelMaxId = sqliteChannelMapper.selectMaxId();
39
+//            System.out.println("SQLite Channel表当前最大ID: " + channelMaxId);
40
+//
41
+//            List<CmcChannel> newChannels = new ArrayList<>();
42
+//
43
+//            String channelQuery = "SELECT ID, Sensor_No, Info, Ver, Sn, Ca, Cb, Units, LastDT " +
44
+//                    "FROM Channel " +
45
+//                    "WHERE ID > ? " +
46
+//                    "ORDER BY ID ASC";
47
+//
48
+//            try (PreparedStatement pstmt = conn.prepareStatement(channelQuery)) {
49
+//                pstmt.setInt(1, channelMaxId);
50
+//                try (ResultSet rs = pstmt.executeQuery()) {
51
+//                    while (rs.next()) {
52
+//                        CmcChannel channel = new CmcChannel();
53
+//                        channel.setId(rs.getInt("ID"));
54
+//                        channel.setSensorNo(rs.getInt("Sensor_No"));
55
+//                        channel.setInfo(rs.getString("Info"));
56
+//                        channel.setVer(rs.getInt("Ver"));
57
+//                        channel.setSn(rs.getString("Sn"));
58
+//                        channel.setCa(rs.getInt("Ca"));
59
+//                        channel.setCb(rs.getInt("Cb"));
60
+//                        channel.setUnits(rs.getString("Units"));
61
+//                        channel.setLastDT(rs.getString("LastDT"));
62
+//                        newChannels.add(channel);
63
+//                    }
64
+//                }
65
+//            }
66
+//
67
+//            if (!newChannels.isEmpty()) {
68
+//                System.out.println("从Access读取到" + newChannels.size() + "条新Channel记录(ID > " + channelMaxId + ")");
69
+//                batchInsertChannels(newChannels);
70
+//                System.out.println("Channel表同步完成,共同步" + newChannels.size() + "条记录");
71
+//            } else {
72
+//                System.out.println("没有新的Channel记录需要同步(ID > " + channelMaxId + ")");
73
+//            }
74 74
 
75 75
             // 同步 Data 表
76 76
             System.out.println("开始同步Data表...");

+ 1
- 1
cmc-temperature-back/ruoyi-schedule/src/main/java/com/ruoyi/schedule/task/AccessSyncTask.java 查看文件

@@ -14,7 +14,7 @@ public class AccessSyncTask {
14 14
     IAccessSyncService accessSyncService;
15 15
 
16 16
     // 每小时执行一次(cron格式:秒 分 时 日 月 周 年)
17
-    @Scheduled(cron = "0 20 0/1 * * ? *", zone = "Asia/Shanghai")
17
+    @Scheduled(cron = "0 0 0/1 * * ? *", zone = "Asia/Shanghai")
18 18
     public void sync() throws Exception {
19 19
         System.out.println("========== Access数据同步任务开始执行,当前时间: " + new Date() + "==========");
20 20
         try {

Loading…
取消
儲存