初始化前端目录
This commit is contained in:
@@ -39,7 +39,6 @@ public class DbService {
|
|||||||
|
|
||||||
|
|
||||||
private static final DateTimeFormatter DATE_FORMATTER = DateTimeFormatter.ofPattern("yyyyMMdd");
|
private static final DateTimeFormatter DATE_FORMATTER = DateTimeFormatter.ofPattern("yyyyMMdd");
|
||||||
private static final String dsValue = LocalDate.now().format(DATE_FORMATTER);
|
|
||||||
|
|
||||||
|
|
||||||
public ApiResult<List<TabResult>> listSourceTables(String dbId) {
|
public ApiResult<List<TabResult>> listSourceTables(String dbId) {
|
||||||
@@ -83,7 +82,6 @@ public class DbService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 运行全部任务
|
* 运行全部任务
|
||||||
*/
|
*/
|
||||||
@@ -103,7 +101,7 @@ public class DbService {
|
|||||||
/**
|
/**
|
||||||
* 运行单个任务
|
* 运行单个任务
|
||||||
*/
|
*/
|
||||||
public ApiResult<?> jobSyncOneTask( String taskId) {
|
public ApiResult<?> jobSyncOneTask(String taskId) {
|
||||||
try {
|
try {
|
||||||
SyncTask task = syncTaskService.getById(taskId);
|
SyncTask task = syncTaskService.getById(taskId);
|
||||||
// 记录是否有任务失败(仅用于后台日志,不影响接口返回)
|
// 记录是否有任务失败(仅用于后台日志,不影响接口返回)
|
||||||
@@ -143,6 +141,7 @@ public class DbService {
|
|||||||
* 同步表数据
|
* 同步表数据
|
||||||
*/
|
*/
|
||||||
public void syncTableData(SyncTask task, JdbcTemplate sourceJdbc, JdbcTemplate targetJdbc) {
|
public void syncTableData(SyncTask task, JdbcTemplate sourceJdbc, JdbcTemplate targetJdbc) {
|
||||||
|
String dsValue = LocalDate.now().format(DATE_FORMATTER);
|
||||||
try {
|
try {
|
||||||
// 确保源表和目标表名转为小写
|
// 确保源表和目标表名转为小写
|
||||||
String sourceTable = task.getSourceTable();
|
String sourceTable = task.getSourceTable();
|
||||||
@@ -152,9 +151,9 @@ public class DbService {
|
|||||||
createTargetTable(sourceJdbc, targetJdbc, sourceTable, targetTable);
|
createTargetTable(sourceJdbc, targetJdbc, sourceTable, targetTable);
|
||||||
}
|
}
|
||||||
// 2. 清空目标表当前ds值的数据
|
// 2. 清空目标表当前ds值的数据
|
||||||
clearTargetTableData(targetJdbc, targetTable);
|
clearTargetTableData(targetJdbc, targetTable, dsValue);
|
||||||
// 3. 全量同步数据
|
// 3. 全量同步数据
|
||||||
syncAllData(task, sourceJdbc, targetJdbc, sourceTable, targetTable);
|
syncAllData(task, sourceJdbc, targetJdbc, sourceTable, targetTable, dsValue);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
System.err.println("表同步失败: " + e.getMessage());
|
System.err.println("表同步失败: " + e.getMessage());
|
||||||
}
|
}
|
||||||
@@ -311,7 +310,7 @@ public class DbService {
|
|||||||
/**
|
/**
|
||||||
* 清空目标表中当前ds值的数据
|
* 清空目标表中当前ds值的数据
|
||||||
*/
|
*/
|
||||||
private void clearTargetTableData(JdbcTemplate targetJdbc, String targetTable) {
|
private void clearTargetTableData(JdbcTemplate targetJdbc, String targetTable, String dsValue) {
|
||||||
String sql = "DELETE FROM " + targetTable + " WHERE ds = ?";
|
String sql = "DELETE FROM " + targetTable + " WHERE ds = ?";
|
||||||
targetJdbc.update(sql, dsValue);
|
targetJdbc.update(sql, dsValue);
|
||||||
}
|
}
|
||||||
@@ -320,7 +319,8 @@ public class DbService {
|
|||||||
* 全量同步数据
|
* 全量同步数据
|
||||||
*/
|
*/
|
||||||
private void syncAllData(SyncTask task, JdbcTemplate sourceJdbc, JdbcTemplate targetJdbc,
|
private void syncAllData(SyncTask task, JdbcTemplate sourceJdbc, JdbcTemplate targetJdbc,
|
||||||
String sourceTable, String targetTable) {
|
String sourceTable, String targetTable, String dsValue) {
|
||||||
|
|
||||||
LocalDateTime startTime = LocalDateTime.now();
|
LocalDateTime startTime = LocalDateTime.now();
|
||||||
int totalRows = 0;
|
int totalRows = 0;
|
||||||
int successRows = 0;
|
int successRows = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user