fix:() 优化任务调动方法
parent
70b0f5f0d9
commit
19b9a8ed69
|
@ -38,18 +38,18 @@ public class DataLinkController {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询表数据count
|
* 查询表数据count
|
||||||
* @param basicDataName 数据库名称
|
* @param databaseName 数据库名称
|
||||||
* @param targetTableName sql语句
|
* @param tableName sql语句
|
||||||
* @param listList sql语句
|
* @param listList sql语句
|
||||||
* @return 反护试图
|
* @return 反护试图
|
||||||
*/
|
*/
|
||||||
@PostMapping("/addProduct")
|
@PostMapping("/addProduct")
|
||||||
public Result addProduct(@RequestParam("targetDatabase") String targetDatabase,
|
public Result addProduct(@RequestParam("databaseName") String databaseName,
|
||||||
@RequestParam("targetTableName") String targetTableName,
|
@RequestParam("tableName") String tableName,
|
||||||
@RequestBody DataValue[][] listList){
|
@RequestBody DataValue[][] listList){
|
||||||
long begin = System.currentTimeMillis();
|
long begin = System.currentTimeMillis();
|
||||||
|
|
||||||
int i = dataLinkService.addProduct(targetDatabase,targetTableName,listList);
|
int i = dataLinkService.addProduct(databaseName,tableName,listList);
|
||||||
|
|
||||||
|
|
||||||
long end = System.currentTimeMillis();
|
long end = System.currentTimeMillis();
|
||||||
|
|
|
@ -61,10 +61,10 @@ public interface DataLinkService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询表数据count
|
* 查询表数据count
|
||||||
* @param basicDataName 数据库名称
|
* @param databaseName 数据库名称
|
||||||
* @param targetTableName sql语句
|
* @param tableName sql语句
|
||||||
* @param listList sql语句
|
* @param listList sql语句
|
||||||
* @return 反护试图
|
* @return 反护试图
|
||||||
*/
|
*/
|
||||||
int addProduct(String targetDatabase, String targetTableName, DataValue[]... listList);
|
int addProduct(String databaseName, String tableName, DataValue[]... listList);
|
||||||
}
|
}
|
||||||
|
|
|
@ -134,15 +134,15 @@ public class DataLinkServiceImpl implements DataLinkService {
|
||||||
/**
|
/**
|
||||||
* 添加方法
|
* 添加方法
|
||||||
* @param databaseName 数据库名称
|
* @param databaseName 数据库名称
|
||||||
* @param targetTableName sql语句
|
* @param tableName sql语句
|
||||||
* @param listList sql语句
|
* @param listList sql语句
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@Log(title = "添加产品数据库", businessType = BusinessType.INSERT)
|
@Log(title = "添加产品数据库", businessType = BusinessType.INSERT)
|
||||||
public int addProduct(String targetDatabase, String targetTableName, DataValue[]... listList) {
|
public int addProduct(String databaseName, String tableName, DataValue[]... listList) {
|
||||||
|
|
||||||
Connect connect = connectService.selectData(targetDatabase);
|
Connect connect = connectService.selectData(databaseName);
|
||||||
|
|
||||||
ConnectReq connectReq = new ConnectReq();
|
ConnectReq connectReq = new ConnectReq();
|
||||||
HikariConfig hikariConfig = new HikariConfig();
|
HikariConfig hikariConfig = new HikariConfig();
|
||||||
|
@ -169,7 +169,7 @@ public class DataLinkServiceImpl implements DataLinkService {
|
||||||
for (DataValue[][] batch : batches) {
|
for (DataValue[][] batch : batches) {
|
||||||
executorService.submit(() -> {
|
executorService.submit(() -> {
|
||||||
try (Statement stmt = conn.createStatement()) {
|
try (Statement stmt = conn.createStatement()) {
|
||||||
String sql = buildBatchInsertSQL(targetTableName, batch);
|
String sql = buildBatchInsertSQL(tableName, batch);
|
||||||
stmt.executeUpdate(sql);
|
stmt.executeUpdate(sql);
|
||||||
addCount.addAndGet(batch.length);
|
addCount.addAndGet(batch.length);
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
|
|
Loading…
Reference in New Issue