Преглед изворни кода

Merge branch '同步订单和交货单方法更改' of http://git.dgtis.com/qxp/suishenbang-oneportal into uat

njs пре 5 месеци
родитељ
комит
5ead751d47

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

@@ -1392,6 +1392,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");
@@ -1407,19 +1416,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);
@@ -1524,6 +1520,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");
@@ -1540,19 +1545,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) {
@@ -1612,6 +1604,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");
@@ -1628,19 +1630,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);