fix(info-query): 修复查询已跨天表接口调用未跨天接口

This commit is contained in:
2023-06-28 14:56:01 +08:00
parent a15fb1857f
commit 1ed1b8105a
4 changed files with 23 additions and 69 deletions

View File

@@ -122,7 +122,7 @@ public class InfoController {
@GetMapping("/updated_version_tables")
public ImmutableList<String> updatedVersionTables() {
return infoService.nonUpdatedVersionTables();
return infoService.updatedVersionTables();
}
@GetMapping("/un_receive_version_normal_table")

View File

@@ -199,16 +199,30 @@ public class InfoService {
return databaseService.getTableMeta(flinkJobId, alias);
}
private static String generateVersionTableIdCriteria(Boolean scheduled) {
return SqlBuilder.select(StrUtil.format("concat({}, '-', {})", TABLE_VERSION_FLINK_JOB_ID, TABLE_VERSION_ALIAS))
.from(TABLE_VERSION)
.whereEq(TABLE_VERSION_SCHEDULED, scheduled)
.andEq(TABLE_VERSION_VERSION, Column.as("date_format(subdate(current_date(), 1), '%Y%m%d')"))
.build();
}
@Cacheable("un-updated-version-table")
@Retryable(Throwable.class)
public ImmutableList<String> nonUpdatedVersionTables() {
return databaseService.findAllUnScheduledTable();
return mysqlTransactionTemplate.execute(status -> {
List<String> ids = mysqlJdbcTemplate.queryForList(generateVersionTableIdCriteria(false), String.class);
return Lists.immutable.ofAll(ids);
});
}
@Cacheable("updated-version-table")
@Retryable(Throwable.class)
public ImmutableList<String> updatedVersionTables() {
return databaseService.findAllScheduledTable();
return mysqlTransactionTemplate.execute(status -> {
List<String> ids = mysqlJdbcTemplate.queryForList(generateVersionTableIdCriteria(true), String.class);
return Lists.immutable.ofAll(ids);
});
}
private static String column(Alias table, String column) {