|
|
|
@ -33,7 +33,7 @@ public class DataUpdateTask {
|
|
|
|
|
|
|
|
|
|
// 获取远程数据库所有表名
|
|
|
|
|
List<String> tableNames = masterJdbcTemplate.queryForList(
|
|
|
|
|
"SELECT table_name FROM information_schema.tables WHERE table_schema = 'ying_ji'",
|
|
|
|
|
"SELECT table_name FROM information_schema.tables WHERE table_schema = 'lt_send_db'",
|
|
|
|
|
String.class);
|
|
|
|
|
// 更新每个表的数据到另一个数据库
|
|
|
|
|
for (String tableName : tableNames) {
|
|
|
|
@ -42,7 +42,7 @@ public class DataUpdateTask {
|
|
|
|
|
slaveJdbcTemplate.execute("delete FROM ying_ji." + tableName);
|
|
|
|
|
// ... 以此类推,根据实际表的数量进行删除操作
|
|
|
|
|
slaveJdbcTemplate.execute("SET FOREIGN_KEY_CHECKS = 1"); // 启用外键检查
|
|
|
|
|
String selectQuery = "SELECT * FROM ying_ji." + tableName;
|
|
|
|
|
String selectQuery = "SELECT * FROM lt_send_db." + tableName;
|
|
|
|
|
List<Map<String, Object>> tableData = masterJdbcTemplate.queryForList(selectQuery);
|
|
|
|
|
for (Map<String, Object> row : tableData) {
|
|
|
|
|
StringBuilder insertQuery = new StringBuilder("INSERT INTO ying_ji.")
|
|
|
|
@ -69,8 +69,9 @@ public class DataUpdateTask {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 不再执行
|
|
|
|
|
// 每周一早上5点执行一次任务 更新企业原表
|
|
|
|
|
@Scheduled(cron = "0 0 5 ? * MON")
|
|
|
|
|
// @Scheduled(cron = "0 0 5 ? * MON")
|
|
|
|
|
public void updateInformationData() {
|
|
|
|
|
// 获取远程数据库所有表名
|
|
|
|
|
List<String> tableNames = masterJdbcTemplate.queryForList(
|
|
|
|
|