Procházet zdrojové kódy

删除旧表下一次更名前删

njs před 5 měsíci
rodič
revize
1e6319c743

+ 29 - 39
suishenbang-sync/suishenbang-sync-common/src/main/java/com/dgtly/sync/service/HanaOrderComponent.java

@@ -1393,6 +1393,15 @@ public class HanaOrderComponent {
                     log.info("importing salesOrder := {} rows data into mysql from {} and cost {} ms!", rows, filePath, (endTime - beginTime));
                 }
 
+                //删除旧表
+                try (Connection tempConn = getMysqlConnection();
+                     Statement tempStmt = tempConn.createStatement()) {
+                    tempStmt.execute("DROP TABLE IF EXISTS meta_hana_sales_order_old");
+                    log.info("成功删除旧表: meta_hana_sales_order_old");
+                } catch (Exception e) {
+                    log.error("删除旧表失败,表名: meta_hana_sales_order_old", e);
+                }
+
                 // 1. 先设置会话级锁等待超时为3秒
                 try (Statement timeOut = conn.createStatement()) {
                     timeOut.execute("SET SESSION innodb_lock_wait_timeout = 3");
@@ -1408,19 +1417,6 @@ public class HanaOrderComponent {
                 // 提交事务
                 conn.commit();
 
-                // 4. 异步删除旧表
-                CompletableFuture.runAsync(() -> {
-                    try (Connection tempConn = getMysqlConnection();
-                         Statement tempStmt = tempConn.createStatement()) {
-                        tempStmt.execute("DROP TABLE IF EXISTS meta_hana_sales_order_old");
-                        log.info("成功删除旧表: meta_hana_sales_order_old");
-                    } catch (Exception e) {
-                        log.error("删除旧表失败,表名: meta_hana_sales_order_old", e);
-                    }
-                }).exceptionally(ex -> {
-                    log.error("异步删除旧表操作异常", ex);
-                    return null;
-                });
 
                 // 清空缓存
                 String result = HttpUtils.sendGet(orderGetDataHook);
@@ -1525,6 +1521,15 @@ public class HanaOrderComponent {
                     log.info("importing selfDeliverOrder := {} rows data into mysql from {} and cost {} ms!", rows, filePath, (endTime - beginTime));
                 }
 
+                //删除旧表
+                try (Connection tempConn = getMysqlConnection();
+                     Statement tempStmt = tempConn.createStatement()) {
+                    tempStmt.execute("DROP TABLE IF EXISTS meta_hana_self_deliver_order_old");
+                    log.info("成功删除旧表: meta_hana_self_deliver_order_old");
+                } catch (Exception e) {
+                    log.error("删除旧表失败,表名: meta_hana_self_deliver_order_old", e);
+                }
+
                 // 1. 先设置会话级锁等待超时为3秒
                 try (Statement timeOut = conn.createStatement()) {
                     timeOut.execute("SET SESSION innodb_lock_wait_timeout = 3");
@@ -1541,19 +1546,6 @@ public class HanaOrderComponent {
                 // 提交事务
                 conn.commit();
 
-                // 4. 异步删除旧表
-                CompletableFuture.runAsync(() -> {
-                    try (Connection tempConn = getMysqlConnection();
-                         Statement tempStmt = tempConn.createStatement()) {
-                        tempStmt.execute("DROP TABLE IF EXISTS meta_hana_self_deliver_order_old");
-                        log.info("成功删除旧表: meta_hana_self_deliver_order_old");
-                    } catch (Exception e) {
-                        log.error("删除旧表失败,表名: meta_hana_self_deliver_order_old", e);
-                    }
-                }).exceptionally(ex -> {
-                    log.error("异步删除旧表操作异常", ex);
-                    return null;
-                });
 
 
             } catch (Exception e) {
@@ -1613,6 +1605,16 @@ public class HanaOrderComponent {
                     log.info("importing deliverOrder := {} rows data into mysql from {} and cost {} ms!", rows, filePath, (endTime - beginTime));
                 }
 
+                //删除旧表
+                try (Connection tempConn = getMysqlConnection();
+                     Statement tempStmt = tempConn.createStatement()) {
+                    tempStmt.execute("DROP TABLE IF EXISTS meta_hana_deliver_order_old");
+                    log.info("成功删除旧表: meta_hana_deliver_order_old");
+                } catch (Exception e) {
+                    log.error("删除旧表失败,表名: meta_hana_deliver_order_old", e);
+                }
+
+
                 // 1. 先设置会话级锁等待超时为3秒
                 try (Statement timeOut = conn.createStatement()) {
                     timeOut.execute("SET SESSION innodb_lock_wait_timeout = 3");
@@ -1629,19 +1631,7 @@ public class HanaOrderComponent {
                 // 提交事务
                 conn.commit();
 
-                // 4. 异步删除旧表
-                CompletableFuture.runAsync(() -> {
-                    try (Connection tempConn = getMysqlConnection();
-                         Statement tempStmt = tempConn.createStatement()) {
-                        tempStmt.execute("DROP TABLE IF EXISTS meta_hana_deliver_order_old");
-                        log.info("成功删除旧表: meta_hana_deliver_order_old");
-                    } catch (Exception e) {
-                        log.error("删除旧表失败,表名: meta_hana_deliver_order_old", e);
-                    }
-                }).exceptionally(ex -> {
-                    log.error("异步删除旧表操作异常", ex);
-                    return null;
-                });
+
 
                 // 清空缓存
                 String result = HttpUtils.sendGet(orderGetDataHook);