fix:1.修改数据同步策略配置接口,配合前端对接

This commit is contained in:
panbaolin 2026-08-10 10:28:00 +08:00
parent e3fe064509
commit 99262e667f
2 changed files with 12 additions and 20 deletions

View File

@ -49,30 +49,20 @@ public class StasTaskConfigServiceImpl extends ServiceImpl<StasTaskConfigMapper,
*/
@Override
public MindMapVO getMindMap(String taskId) {
// 1. 使用多线程并行查询数据库
CompletableFuture<StasTaskConfig> taskConfigFuture = CompletableFuture.supplyAsync(() ->
stasTaskConfigMapper.selectById(taskId));
StasTaskConfig stasTaskConfig = stasTaskConfigMapper.selectById(taskId);
if(Objects.isNull(stasTaskConfig)) {
throw new RuntimeException("此任务不存在");
}
LambdaQueryWrapper<StasSyncStrategy> strategyQueryWrapper = new LambdaQueryWrapper<>();
strategyQueryWrapper.eq(StasSyncStrategy::getTaskId, taskId);
List<StasSyncStrategy> syncStrategies = stasSyncStrategyMapper.selectList(strategyQueryWrapper);
CompletableFuture<List<StasSyncStrategy>> strategiesFuture = taskConfigFuture.thenApplyAsync(config ->
stasSyncStrategyMapper.selectList(
new LambdaQueryWrapper<StasSyncStrategy>()
.eq(StasSyncStrategy::getTaskId, taskId)));
CompletableFuture<StasDataSource> dataSourceFuture = taskConfigFuture.thenApplyAsync(config ->
stasDataSourceMapper.selectById(config.getSourceId()));
// 2. 等待所有查询完成
CompletableFuture.allOf(taskConfigFuture, strategiesFuture, dataSourceFuture).join();
// 3. 构建响应对象
StasDataSource sourceInfo = dataSourceFuture.join();
List<StasSyncStrategy> stasSyncStrategies = strategiesFuture.join();
StasDataSource stasDataSource = stasDataSourceMapper.selectById(stasTaskConfig.getSourceId());
MindMapVO mindMapVO = new MindMapVO();
mindMapVO.setDatabaseName(sourceInfo.getInstanceName());
mindMapVO.setDatabaseName(stasDataSource.getInstanceName());
// 4. 使用流式处理简化代码
List<UserInfoVO> userInfos = stasSyncStrategies.stream()
List<UserInfoVO> userInfos = syncStrategies.stream()
.collect(Collectors.groupingBy(StasSyncStrategy::getSourceOwner))
.entrySet().stream()
.map(entry -> {
@ -84,6 +74,7 @@ public class StasTaskConfigServiceImpl extends ServiceImpl<StasTaskConfigMapper,
TableInfoVO tableInfoVO = new TableInfoVO();
tableInfoVO.setTableName(strategy.getTableName());
tableInfoVO.setColumnName(strategy.getColumnName());
tableInfoVO.setSyncCount(strategy.getSyncCount());
return tableInfoVO;
})
.collect(Collectors.toList());

View File

@ -6,4 +6,5 @@ import lombok.Data;
public class TableInfoVO {
private String tableName;
private String columnName;
private Integer syncCount;
}