|
@@ -85,6 +85,44 @@ public class AreaService {
|
|
|
public List<GeoJsonBean> zhwgPolygonList = new ArrayList<>();
|
|
|
public StringBuffer geojsonStr = new StringBuffer();
|
|
|
|
|
|
+ /**
|
|
|
+ * 读取最新的村居geojson文件
|
|
|
+ * 读取数据并生成新的xlsx文件
|
|
|
+ */
|
|
|
+ public static void putNewXlsxCunju(){
|
|
|
+ String filePath = "C:\\Users\\Liumouren\\Desktop\\上海市_村居边界.geojson";
|
|
|
+ String outFilePath = "C:\\Users\\Liumouren\\Desktop\\上海市_村居边界.xlsx";
|
|
|
+ // 创建ObjectMapper实例
|
|
|
+ ObjectMapper objectMapper = new ObjectMapper();
|
|
|
+ List<Map<String,Object>> outFileDatas = new ArrayList<>();
|
|
|
+ try {
|
|
|
+ // 读取JSON文件并转换为String
|
|
|
+ String appendJsonContent = objectMapper.readTree(new File(filePath)).toString();
|
|
|
+// 暂存所有新松江数据
|
|
|
+ JSONArray appendFeatures = JSONObject.parseObject(appendJsonContent).getJSONArray("features");
|
|
|
+ for (int i = 0; i < appendFeatures.size(); i++) {
|
|
|
+ JSONObject featureItem = appendFeatures.getJSONObject(i);
|
|
|
+// 替换属性中的key,不影响旧代码使用
|
|
|
+ JSONObject properties = featureItem.getJSONObject("properties");
|
|
|
+ Map<String,Object> dataItem = new HashMap<>();
|
|
|
+ dataItem.put("区",properties.getString("所属区"));
|
|
|
+ dataItem.put("镇",properties.getString("所属街"));
|
|
|
+ dataItem.put("居委",properties.getString("居委_1"));
|
|
|
+ dataItem.put("居委编码",properties.getString("code"));
|
|
|
+ outFileDatas.add(dataItem);
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ ExcelReaderUtils.writeToExcel(outFileDatas,outFilePath);
|
|
|
+ System.out.println("文件保存成功!路径:" + outFilePath);
|
|
|
+ } catch (IOException e) {
|
|
|
+ System.err.println("文件保存失败:" + e.getMessage());
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 加载村居边界geojson文件获取所有的居委并进行统计
|
|
|
* 找出所有有问题(xx公司、xx工作站、xx区)的居委,并列出
|
|
@@ -92,7 +130,8 @@ public class AreaService {
|
|
|
* @param args
|
|
|
*/
|
|
|
public static void main(String[] args) {
|
|
|
- // JSON文件路径
|
|
|
+ putNewXlsxCunju();
|
|
|
+ /*// JSON文件路径
|
|
|
String appendFilePath = "C:\\Users\\Liumouren\\Desktop\\GWS84(国际通用)sj_jw_0416.json";
|
|
|
String filePath = "C:\\Users\\Liumouren\\Desktop\\上海市_村居边界.geojson";
|
|
|
// 创建ObjectMapper实例
|
|
@@ -138,7 +177,7 @@ public class AreaService {
|
|
|
}
|
|
|
} catch (IOException e) {
|
|
|
e.printStackTrace();
|
|
|
- }
|
|
|
+ }*/
|
|
|
}
|
|
|
|
|
|
@PostConstruct
|