修复数据为空时无法执行的问题
parent
ea4585909a
commit
de0e7d69af
|
@ -137,7 +137,7 @@ public final class TaskManager {
|
|||
synchronized (taskQueue) {
|
||||
while (isRunning && taskQueue.isEmpty()) {// 队列为空
|
||||
try {
|
||||
taskQueue.wait(1000);
|
||||
taskQueue.wait(50);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
|
|
@ -137,7 +137,7 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task>
|
|||
}
|
||||
|
||||
/**
|
||||
* 执行任务
|
||||
* //TODO 执行任务
|
||||
* 获取任务所有节点配置信息 拼接sql语句
|
||||
* @param taskCode 任务编码
|
||||
* @return 成功与否
|
||||
|
@ -156,10 +156,10 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task>
|
|||
// 划分线程 每次查询1000条
|
||||
int threadNum = count / 1000 + 1;
|
||||
log.info("任务 {} 总共需要 {} 条数据, 划分为线程{}条",taskCode,count,threadNum);
|
||||
Runnable[] tasks = new Runnable[threadNum];
|
||||
for (int i = 0; i < threadNum; i++) {
|
||||
int index = i+1;
|
||||
tasks[i] = () -> {
|
||||
// 添加进入任务队列
|
||||
taskManager.execute(() -> {
|
||||
// 获取新SQL 并执行
|
||||
String sql = findSql + " LIMIT 1000 OFFSET "+(index-1)*1000;
|
||||
log.info("任务 {} 开始执行第 {} 线程,查询SQL: {}",taskCode,index, sql);
|
||||
|
@ -169,10 +169,9 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task>
|
|||
if (addResult.getCode() != 200){
|
||||
throw new TaskException(addResult.getMsg());
|
||||
}
|
||||
};
|
||||
});
|
||||
}
|
||||
// 添加进入任务队列
|
||||
taskManager.execute(tasks);
|
||||
|
||||
return "执行成功";
|
||||
}
|
||||
|
||||
|
|
|
@ -304,9 +304,14 @@ public class NodeUtils {
|
|||
List<HashMap<String, String>> dataList1 = new ArrayList<>();
|
||||
for (List<DataModel> datum : data) {
|
||||
HashMap<String, String> dataMap = new HashMap<>();
|
||||
datum.forEach(dataModel -> dataMap.put(dataModel.getKey(), dataModel.getValue().toString()));
|
||||
datum.forEach(dataModel -> {
|
||||
// 检查 getValue 是否为空
|
||||
String value = dataModel.getValue() != null ? dataModel.getValue().toString() : null;
|
||||
dataMap.put(dataModel.getKey(), value);
|
||||
});
|
||||
dataList1.add(dataMap);
|
||||
}
|
||||
System.out.println(dataList1);
|
||||
// 拼接新增语句的值
|
||||
dataList1.forEach(map -> insSql.append("( ").
|
||||
append(StringUtils.join(
|
||||
|
|
Loading…
Reference in New Issue