main
HuangHai 4 months ago
parent 5eaa3eaf69
commit 54a7a7e47a

@ -1,88 +0,0 @@
{
"2019": {
"基教小学": {
"skipRows": 7,
"schoolName": {
"index": 1,
"name": "学校名称",
"type": "String"
},
"schoolType": {
"index": 3,
"name": "学校类型",
"type": "String"
},
"schoolCount": {
"index": 5,
"name": "学校数量",
"type": "Integer"
},
"city": {
"index": 350,
"name": "市",
"type": "String"
},
"district": {
"index": 351,
"name": "区",
"type": "String"
}
},
"初中": {
"skipRows": 7,
"schoolName": {
"index": 1,
"name": "学校名称",
"type": "String"
},
"schoolType": {
"index": 3,
"name": "学校类型",
"type": "String"
},
"schoolCount": {
"index": 5,
"name": "学校数量",
"type": "Integer"
},
"city": {
"index": 374,
"name": "市",
"type": "String"
},
"district": {
"index": 375,
"name": "区",
"type": "String"
}
},
"高中": {
"skipRows": 7,
"schoolName": {
"index": 1,
"name": "学校名称",
"type": "String"
},
"schoolType": {
"index": 3,
"name": "学校类型",
"type": "String"
},
"schoolCount": {
"index": 5,
"name": "学校数量",
"type": "Integer"
},
"city": {
"index": 320,
"name": "市",
"type": "String"
},
"district": {
"index": 321,
"name": "区",
"type": "String"
}
}
}
}

@ -0,0 +1,114 @@
{
"基教幼儿园": {
"skipRows": 7,
"schoolName": {
"index": 1,
"name": "学校名称",
"type": "String"
},
"schoolType": {
"index": 3,
"name": "学校类型",
"type": "String"
},
"schoolCount": {
"index": 5,
"name": "学校数量",
"type": "Integer"
},
"city": {
"index": 208,
"name": "市",
"type": "String"
},
"district": {
"index": 209,
"name": "区",
"type": "String"
}
},
"基教小学": {
"skipRows": 7,
"schoolName": {
"index": 1,
"name": "学校名称",
"type": "String"
},
"schoolType": {
"index": 3,
"name": "学校类型",
"type": "String"
},
"schoolCount": {
"index": 5,
"name": "学校数量",
"type": "Integer"
},
"city": {
"index": 350,
"name": "市",
"type": "String"
},
"district": {
"index": 351,
"name": "区",
"type": "String"
}
},
"基教初中": {
"skipRows": 7,
"schoolName": {
"index": 1,
"name": "学校名称",
"type": "String"
},
"schoolType": {
"index": 3,
"name": "学校类型",
"type": "String"
},
"schoolCount": {
"index": 5,
"name": "学校数量",
"type": "Integer"
},
"city": {
"index": 374,
"name": "市",
"type": "String"
},
"district": {
"index": 375,
"name": "区",
"type": "String"
}
},
"基教高中": {
"skipRows": 7,
"schoolName": {
"index": 1,
"name": "学校名称",
"type": "String"
},
"schoolType": {
"index": 3,
"name": "学校类型",
"type": "String"
},
"schoolCount": {
"index": 5,
"name": "学校数量",
"type": "Integer"
},
"city": {
"index": 320,
"name": "市",
"type": "String"
},
"district": {
"index": 321,
"name": "区",
"type": "String"
}
}
}

@ -4,6 +4,7 @@ import cn.idev.excel.*;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
@ -22,11 +23,10 @@ import static com.dsideal.base.Tools.JkyNewData.Util.CommonUtil.log;
public class SchoolCountSummary {
// 配置文件
public static final String configPath = "D:/dsWork/YunNanDsBase/src/main/java/com/dsideal/base/Tools/JkyNewData/Data/SchoolCount.json";
public static final String configDir = "D:/dsWork/YunNanDsBase/src/main/java/com/dsideal/base/Tools/JkyNewData/Data/";
public static final String excelPath = "D:/dsWork/2025年收集的人口与教育数据库20250328/2015-2020年的数据/基础教育";
public static void main(String[] args) throws FileNotFoundException {
// 一、关闭日志输出
CloseLogUtil.Init();
@ -35,25 +35,32 @@ public class SchoolCountSummary {
LocalMysqlConnectUtil.Init();
// 三、清空数据表
String sql="truncate table t_yn_school_count";
String sql = "truncate table t_yn_school_count";
Db.update(sql);
// 四、开始读取数据
JSONObject config = JSON.parseObject(new FileReader(configPath));
// 遍历年份
for (String year : config.keySet()) {
// 四、获取所有配置文件
File dir = new File(configDir);
File[] configFiles = dir.listFiles((d, name) -> name.matches("SchoolCount_\\d{4}\\.json"));
if (configFiles != null) {
for (File configFile : configFiles) {
// 从文件名中提取年份
String fileName = configFile.getName();
String year = fileName.substring("SchoolCount_".length(), fileName.length() - 5);
log(String.format("开始处理年份:%s", year));
JSONObject yearConfig = config.getJSONObject(year);
// 读取配置文件
JSONObject config = JSON.parseObject(new FileReader(configFile));
String filePath = String.format(excelPath + "/%s.xlsx", year);
// 创建一个Map来存储所有处理结果
Map<String, Map<String, Map<String, Integer>>> allResults = new HashMap<>();
// 循环处理每种学校类型
for (String schoolType : yearConfig.keySet()) {
for (String schoolType : config.keySet()) {
log(String.format("开始处理学校类型:%s", schoolType));
// 获取当前学校类型的配置
JSONObject typeConfig = yearConfig.getJSONObject(schoolType);
JSONObject typeConfig = config.getJSONObject(schoolType);
Map<String, ColumnConfig> columnConfigs = new HashMap<>();
//表头的行数
@ -81,9 +88,11 @@ public class SchoolCountSummary {
saveToDatabase(allResults, Integer.parseInt(year));
log(String.format("保存年份:%s到数据库完成", year));
}
}
log("所有年份处理完成");
}
/**
* Sheet
*

@ -53,4 +53,8 @@ public class ExcelUtil {
return 0;
}
}
public static void main(String[] args) {
System.out.println(columnLetterToIndex("HA"));
}
}

Loading…
Cancel
Save