|
|
@ -5,6 +5,7 @@ import com.dsideal.base.Util.LocalMysqlConnectUtil;
|
|
|
|
import com.jfinal.plugin.activerecord.Db;
|
|
|
|
import com.jfinal.plugin.activerecord.Db;
|
|
|
|
import com.jfinal.plugin.activerecord.Record;
|
|
|
|
import com.jfinal.plugin.activerecord.Record;
|
|
|
|
import com.dsideal.base.Util.CallDeepSeek;
|
|
|
|
import com.dsideal.base.Util.CallDeepSeek;
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Map;
|
|
|
|
import java.util.Map;
|
|
|
|
import java.util.Set;
|
|
|
|
import java.util.Set;
|
|
|
@ -13,7 +14,9 @@ import java.util.ArrayList;
|
|
|
|
import java.util.concurrent.CountDownLatch;
|
|
|
|
import java.util.concurrent.CountDownLatch;
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
import java.util.Date;
|
|
|
|
import java.util.Date;
|
|
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.io.FileUtil;
|
|
|
|
import cn.hutool.core.io.FileUtil;
|
|
|
|
|
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
import java.io.File;
|
|
|
|
|
|
|
|
|
|
|
|
public class TestMax32K {
|
|
|
|
public class TestMax32K {
|
|
|
@ -32,8 +35,8 @@ public class TestMax32K {
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 分割过大的单表数据
|
|
|
|
* 分割过大的单表数据
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
private static List<String> splitLargeTable(String tableName, Set<String> fieldNames,
|
|
|
|
private static List<String> splitLargeTable(Set<String> fieldNames,
|
|
|
|
List<Record> allTableData, int maxSize) {
|
|
|
|
List<Record> allTableData, int maxSize) {
|
|
|
|
List<String> chunks = new ArrayList<>();
|
|
|
|
List<String> chunks = new ArrayList<>();
|
|
|
|
StringBuilder currentTableChunk = new StringBuilder();
|
|
|
|
StringBuilder currentTableChunk = new StringBuilder();
|
|
|
|
|
|
|
|
|
|
|
@ -72,15 +75,6 @@ public class TestMax32K {
|
|
|
|
return chunks;
|
|
|
|
return chunks;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 获取分块数据的方法(可供其他类调用)
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
public static String[] getDataChunks() {
|
|
|
|
|
|
|
|
// 这里可以将main方法中的逻辑提取出来,返回分块数据
|
|
|
|
|
|
|
|
// 为了简化,这里只是示例
|
|
|
|
|
|
|
|
return new String[]{"示例数据块1", "示例数据块2"};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static String generateComprehensiveReport() {
|
|
|
|
public static String generateComprehensiveReport() {
|
|
|
|
|
|
|
|
|
|
|
|
String[] regions = {"文山州", "楚雄州"};
|
|
|
|
String[] regions = {"文山州", "楚雄州"};
|
|
|
@ -199,8 +193,8 @@ public class TestMax32K {
|
|
|
|
StringBuilder currentChunk = new StringBuilder();
|
|
|
|
StringBuilder currentChunk = new StringBuilder();
|
|
|
|
|
|
|
|
|
|
|
|
String header = "数据说明: 以下是云南省教育数据的压缩格式\n" +
|
|
|
|
String header = "数据说明: 以下是云南省教育数据的压缩格式\n" +
|
|
|
|
"格式: 表名 -> 字段列表 -> 数据行(数组格式)\n" +
|
|
|
|
"格式: 表名 -> 字段列表 -> 数据行(数组格式)\n" +
|
|
|
|
"地区范围: " + String.join(",", regions) + "\n\n";
|
|
|
|
"地区范围: " + String.join(",", regions) + "\n\n";
|
|
|
|
currentChunk.append(header);
|
|
|
|
currentChunk.append(header);
|
|
|
|
|
|
|
|
|
|
|
|
// 遍历所有相关数据表
|
|
|
|
// 遍历所有相关数据表
|
|
|
@ -263,7 +257,7 @@ public class TestMax32K {
|
|
|
|
|
|
|
|
|
|
|
|
// 如果单个表数据超过限制,需要进一步分割
|
|
|
|
// 如果单个表数据超过限制,需要进一步分割
|
|
|
|
if (tableDataStr.length() > MAX_CHUNK_SIZE - header.length()) {
|
|
|
|
if (tableDataStr.length() > MAX_CHUNK_SIZE - header.length()) {
|
|
|
|
List<String> tableChunks = splitLargeTable(tableName, fieldNames, allTableData, MAX_CHUNK_SIZE - header.length());
|
|
|
|
List<String> tableChunks = splitLargeTable(fieldNames, allTableData, MAX_CHUNK_SIZE - header.length());
|
|
|
|
for (int i = 0; i < tableChunks.size(); i++) {
|
|
|
|
for (int i = 0; i < tableChunks.size(); i++) {
|
|
|
|
StringBuilder chunkBuilder = new StringBuilder();
|
|
|
|
StringBuilder chunkBuilder = new StringBuilder();
|
|
|
|
chunkBuilder.append(header);
|
|
|
|
chunkBuilder.append(header);
|
|
|
|