fix:重构完成;重构点:表的数量较大,在遍历表用于查询的时候安排给线程异步执行,减少执行时间,完成同步
parent
b0f0c3afe5
commit
e69291cd38
|
@ -15,6 +15,7 @@ import com.muyu.etl.service.StructureService;
|
||||||
import com.muyu.etl.service.TableInfoService;
|
import com.muyu.etl.service.TableInfoService;
|
||||||
import lombok.SneakyThrows;
|
import lombok.SneakyThrows;
|
||||||
import lombok.extern.log4j.Log4j2;
|
import lombok.extern.log4j.Log4j2;
|
||||||
|
import org.apache.commons.lang3.exception.ExceptionUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@ -22,6 +23,10 @@ import javax.servlet.ServletException;
|
||||||
import java.sql.*;
|
import java.sql.*;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.concurrent.Callable;
|
||||||
|
import java.util.concurrent.ExecutionException;
|
||||||
|
import java.util.concurrent.ExecutorService;
|
||||||
|
import java.util.concurrent.Executors;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -311,7 +316,12 @@ public class BasicConfigInfoServiceImpl extends ServiceImpl<BasicConfigInfoMapp
|
||||||
List<TableInfoStructureResp> tableInfoStructureRespList = tableInfoService.selectTableInfoList(new TableInfo() {{
|
List<TableInfoStructureResp> tableInfoStructureRespList = tableInfoService.selectTableInfoList(new TableInfo() {{
|
||||||
setParentId(tableInfo.getId());
|
setParentId(tableInfo.getId());
|
||||||
}}).stream().map(info -> {
|
}}).stream().map(info -> {
|
||||||
List<Structure> structureList = structureService.list(new LambdaQueryWrapper<Structure>().eq(Structure::getTableId,info.getId()));
|
TableInfoStructureResp callable = null;
|
||||||
|
try {
|
||||||
|
callable = new Callable<>() {
|
||||||
|
@Override
|
||||||
|
public TableInfoStructureResp call() throws Exception {
|
||||||
|
List<Structure> structureList = structureService.list(new LambdaQueryWrapper<Structure>().eq(Structure::getTableId, info.getId()));
|
||||||
return TableInfoStructureResp.builder()
|
return TableInfoStructureResp.builder()
|
||||||
.id(info.getId())
|
.id(info.getId())
|
||||||
.tableName(info.getTableName())
|
.tableName(info.getTableName())
|
||||||
|
@ -323,6 +333,13 @@ public class BasicConfigInfoServiceImpl extends ServiceImpl<BasicConfigInfoMapp
|
||||||
.structureList(structureList)
|
.structureList(structureList)
|
||||||
.basicId(info.getBasicId())
|
.basicId(info.getBasicId())
|
||||||
.build();
|
.build();
|
||||||
|
};
|
||||||
|
}.call();
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
// ExecutorService threadPool = Executors.newCachedThreadPool();
|
||||||
|
return callable;
|
||||||
}).collect(Collectors.toList());
|
}).collect(Collectors.toList());
|
||||||
return TableTreeResp.builder()
|
return TableTreeResp.builder()
|
||||||
.tableInfo(tableInfo)
|
.tableInfo(tableInfo)
|
||||||
|
@ -333,4 +350,5 @@ public class BasicConfigInfoServiceImpl extends ServiceImpl<BasicConfigInfoMapp
|
||||||
return tableTreeRespList;
|
return tableTreeRespList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue