main
HuangHai 4 months ago
parent 29bab5972d
commit 04139a1a7d

@ -1,83 +1,85 @@
{
"小学": {
"schoolName": {
"index": 1,
"name": "学校名称",
"type": "String"
"2019": {
"小学": {
"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"
}
},
"schoolType": {
"index": 3,
"name": "学校类型",
"type": "String"
"初中": {
"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"
}
},
"schoolCount": {
"index": 5,
"name": "学校数量",
"type": "Integer"
},
"city": {
"index": 350,
"name": "市",
"type": "String"
},
"district": {
"index": 351,
"name": "区",
"type": "String"
}
},
"初中": {
"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"
}
},
"高中": {
"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"
"高中": {
"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"
}
}
}
}

@ -28,44 +28,50 @@ public class SchoolCountSummary {
LocalMysqlConnectUtil.Init();
// 读取配置文件
String configPath = "D:/dsWork/YunNanDsBase/src/main/java/com/dsideal/base/Tools/Excel/Data/SchoolCount.json";
String configPath = "D:/dsWork/YunNanDsBase/src/main/java/com/dsideal/base/Tools/JkyNewData/Data/SchoolCount.json";
String excelPath = "D:/dsWork/2025年收集的人口与教育数据库20250328/2015-2020年的数据/基础教育";
JSONObject config = JSON.parseObject(new FileReader(configPath));
String filePath = "D:/dsWork/2025年收集的人口与教育数据库20250328/2015-2020年的数据/基础教育/2019.xlsx";
// 创建一个Map来存储所有处理结果
Map<String, Map<String, Map<String, Integer>>> allResults = new HashMap<>();
// 循环处理每种学校类型
for (String schoolType : config.keySet()) {
// 获取当前学校类型的配置
JSONObject typeConfig = config.getJSONObject(schoolType);
Map<String, ColumnConfig> columnConfigs = new HashMap<>();
// 转换配置为ColumnConfig对象
for (String key : typeConfig.keySet()) {
JSONObject colConfig = typeConfig.getJSONObject(key);
columnConfigs.put(key, new ColumnConfig(
colConfig.getIntValue("index"),
colConfig.getString("name"),
colConfig.getString("type")
));
// 遍历年份
for (String year : config.keySet()) {
JSONObject yearConfig = config.getJSONObject(year);
String filePath = String.format(excelPath + "/%s.xlsx", year);
// 创建一个Map来存储所有处理结果
Map<String, Map<String, Map<String, Integer>>> allResults = new HashMap<>();
// 循环处理每种学校类型
for (String schoolType : yearConfig.keySet()) {
// 获取当前学校类型的配置
JSONObject typeConfig = yearConfig.getJSONObject(schoolType);
Map<String, ColumnConfig> columnConfigs = new HashMap<>();
// 转换配置为ColumnConfig对象
for (String key : typeConfig.keySet()) {
JSONObject colConfig = typeConfig.getJSONObject(key);
columnConfigs.put(key, new ColumnConfig(
colConfig.getIntValue("index"),
colConfig.getString("name"),
colConfig.getString("type")
));
}
// 处理当前学校类型的数据
String sheetName = "基教" + schoolType;
allResults.put(schoolType, processSheet(filePath, sheetName, 7, columnConfigs));
}
// 处理当前学校类型的数据
String sheetName = "基教" + schoolType;
allResults.put(schoolType, processSheet(filePath, sheetName, 7, columnConfigs));
// 保存统计结果到数据库
saveToDatabase(allResults, Integer.parseInt(year));
}
// 保存统计结果到数据库
saveToDatabase(allResults, 2019);
}
/**
* Sheet
*
* @param filePath
* @param sheetName Sheet
* @param skipRows
* @param filePath
* @param sheetName Sheet
* @param skipRows
* @param columnConfigs
* @return Map
*/
@ -107,7 +113,7 @@ public class SchoolCountSummary {
*
*
* @param allResults
* @param year
* @param year
*/
private static void saveToDatabase(Map<String, Map<String, Map<String, Integer>>> allResults, int year) {
// 先删除该年份的旧数据

Loading…
Cancel
Save