master
parent
19e80ad9b6
commit
3fdc279d0e
|
@ -158,7 +158,7 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task>
|
|||
// 总条数 最大线程数/分配条数 >100W 5/100000 >10W 8/10000 <10W 8/1000
|
||||
int pageSize = 10000;
|
||||
int taskNum = 8;
|
||||
if (count > 100000000){
|
||||
if (count > 80000000){
|
||||
pageSize = 100000;
|
||||
taskNum = 5;
|
||||
}else if (count < 100000){
|
||||
|
|
|
@ -272,7 +272,7 @@ public class NodeUtils {
|
|||
if (data == null){
|
||||
throw new TaskException("查询数据为空");
|
||||
}
|
||||
return nodeDispExportation(DispUtils.getDispMap(dispList), data);
|
||||
return nodeDispExportation(DispUtils.getDispMap(dispList), listToArray(data));
|
||||
}
|
||||
|
||||
|
||||
|
@ -283,7 +283,8 @@ public class NodeUtils {
|
|||
* @param data 查询到的数据
|
||||
* @return 新增sql
|
||||
*/
|
||||
private static String nodeDispExportation(Map<String, List<NodeDisposition>> dispMap, List<List<DataModel>> data) {
|
||||
private static String nodeDispExportation(Map<String, List<NodeDisposition>> dispMap, DataModel[][] data) {
|
||||
|
||||
// 拼接新增表
|
||||
NodeDisposition db = dispMap.get("toDb").get(0);
|
||||
StringBuilder insSql = new StringBuilder("INSERT INTO ");
|
||||
|
@ -295,18 +296,13 @@ public class NodeUtils {
|
|||
insSql.append("( ").append(join).append(" ) VALUES ");
|
||||
// 整理需新增数据
|
||||
List<HashMap<String, String>> dataList1 = new ArrayList<>();
|
||||
for (List<DataModel> datum : data) {
|
||||
for (DataModel[] datum : data) {
|
||||
HashMap<String, String> dataMap = new HashMap<>();
|
||||
datum.forEach(dataModel -> {
|
||||
// 检查 getValue 是否为空
|
||||
rowRule(datum);
|
||||
for (DataModel dataModel : datum) {
|
||||
String value = dataModel.getValue() != null ? dataModel.getValue().toString() : null;
|
||||
// 规则执行 非法字符转换 单引号'和` => ‘
|
||||
if (value!=null){
|
||||
value = StringUtils.replace(value, "'", "‘");
|
||||
value = StringUtils.replace(value, "`", "‘");
|
||||
}
|
||||
dataMap.put(dataModel.getKey(), value);
|
||||
});
|
||||
}
|
||||
dataList1.add(dataMap);
|
||||
}
|
||||
// 拼接新增语句的值
|
||||
|
@ -321,5 +317,38 @@ public class NodeUtils {
|
|||
return insSql.deleteCharAt(insSql.length() - 1).toString();
|
||||
}
|
||||
|
||||
public static DataModel[][] listToArray(List<List<DataModel>> data) {
|
||||
DataModel[][] dataModels = new DataModel[data.size()][];
|
||||
for (int i = 0; i < data.size(); i++) {
|
||||
List<DataModel> innerList = data.get(i);
|
||||
if (innerList != null) {
|
||||
int innerSize = innerList.size();
|
||||
dataModels[i] = new DataModel[innerSize];
|
||||
for (int j = 0; j < innerSize; j++) {
|
||||
dataModels[i][j] = innerList.get(j);
|
||||
}
|
||||
}
|
||||
}
|
||||
return dataModels;
|
||||
}
|
||||
|
||||
// 行级规则
|
||||
private static DataModel[] rowRule(DataModel[] data) {
|
||||
// 规则 非法字符清除
|
||||
for (DataModel datum : data) {
|
||||
if (datum.getValue() == null){
|
||||
continue;
|
||||
}
|
||||
datum.setValue(datum
|
||||
.getValue()
|
||||
.toString()
|
||||
.replace("'","")
|
||||
.replace("`","")
|
||||
.replace(" ","")
|
||||
.replace("\\",""));
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue