diff --git a/Doc/待处理/区/【2】学前幼儿在园总量预测/学前幼儿在园总量预测.xlsx b/Doc/待处理/区/【2】学前幼儿在园总量预测/学前幼儿在园总量预测.xlsx index b80faa38..fc99a82a 100644 Binary files a/Doc/待处理/区/【2】学前幼儿在园总量预测/学前幼儿在园总量预测.xlsx and b/Doc/待处理/区/【2】学前幼儿在园总量预测/学前幼儿在园总量预测.xlsx differ diff --git a/Doc/待处理/区/【2】学前幼儿在园总量预测/学前幼儿在园总量预测【成果】.xlsx b/Doc/待处理/区/【2】学前幼儿在园总量预测/学前幼儿在园总量预测【成果】.xlsx index bd59ef2a..9d230420 100644 Binary files a/Doc/待处理/区/【2】学前幼儿在园总量预测/学前幼儿在园总量预测【成果】.xlsx and b/Doc/待处理/区/【2】学前幼儿在园总量预测/学前幼儿在园总量预测【成果】.xlsx differ diff --git a/Doc/待处理/区/【3】义务教育招生总量预测/【鲁甸县】义务教育招生总量预测.xlsx b/Doc/待处理/区/【3】义务教育招生总量预测/义务教育招生总量预测.xlsx similarity index 100% rename from Doc/待处理/区/【3】义务教育招生总量预测/【鲁甸县】义务教育招生总量预测.xlsx rename to Doc/待处理/区/【3】义务教育招生总量预测/义务教育招生总量预测.xlsx diff --git a/Doc/替换链接.sql b/Doc/替换链接.sql index 15cbb7fc..37452d09 100644 --- a/Doc/替换链接.sql +++ b/Doc/替换链接.sql @@ -3,7 +3,9 @@ update visualization_link_jump_info set content=replace(content,'http://10.10.21 update data_visualization_info set component_data=replace(component_data,'http://10.10.21.20:9000/dsBase/','http://10.10.14.14:9000/dsBase/') ; update data_visualization_info set component_data=replace(component_data,'http://10.10.14.203/','http://10.10.14.203/') ; +select * from data_visualization_info where component_data like '%10.10.21.20%' + http://10.10.21.20:9000/dsBase -- 上线 update visualization_link_jump_info set content=replace(content,'http://10.10.14.14:9000/dsBase/','https://www.edusoa.com/dsBase/') ; update data_visualization_info set component_data=replace(component_data,'http://10.10.14.14:9000/dsBase/','https://www.edusoa.com/dsBase/') ; diff --git a/src/main/java/com/dsideal/base/Tools/FillData/Area/A3.java b/src/main/java/com/dsideal/base/Tools/FillData/Area/A3.java new file mode 100644 index 00000000..3b5a7f9b --- /dev/null +++ b/src/main/java/com/dsideal/base/Tools/FillData/Area/A3.java @@ -0,0 +1,199 @@ +package com.dsideal.base.Tools.FillData.Area; + +import cn.hutool.core.io.FileUtil; +import com.dsideal.base.Tools.FillData.ExcelKit.ExcelKit; +import com.dsideal.base.Tools.Util.LocalMysqlConnectUtil; +import com.dsideal.base.Tools.Util.ReadDocxUtil; +import com.jfinal.kit.StrKit; +import org.apache.poi.openxml4j.exceptions.InvalidFormatException; +import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.xssf.usermodel.XSSFCellStyle; +import org.apache.poi.xssf.usermodel.XSSFSheet; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + +import java.io.File; +import java.io.IOException; +import java.util.Arrays; +import java.util.List; + +public class A3 { + + //示例Excel + static String sampleExcelPath = "D:\\dsWork\\YunNanDsBase\\Doc\\待处理\\区\\【2】学前幼儿在园总量预测\\学前幼儿在园总量预测.xlsx"; + + //源文件 + static String parentPath = "D:\\dsWork\\YunNanDsBase\\Doc\\全省及州市县区人口与教育报告集20241023\\133个县区报告2022\\县区研究报告"; + + //哪些是处理不了的,就不处理了~ + static String[] excludeCityList = {"~$", "磨憨-磨丁", "经开区", "阳宗海"}; + + //有好多EXCEL,啥样的有用?必须带有关键字字样的才有用! + static String fileNameKey = "发展规模数据"; + + //第二个表格的表头信息 + static String tableKeyword = "自动计算招生数、在校生数"; + //第二个表格的表头有几行 + static int tableHeadRows = 2; + //第二个表格的最后一列的列名 + static String tableLetterIndex = "K"; + + public static void main(String[] args) throws IOException, InvalidFormatException { + //初始化数据库连接 + LocalMysqlConnectUtil.Init(); + //实例化 + ReadDocxUtil ru = new ReadDocxUtil(); + + //结果Excel + XSSFWorkbook outWorkbook = new XSSFWorkbook(); + //结果Sheet + XSSFSheet outSheet = ExcelKit.CreateSheet(outWorkbook); + //样式 + XSSFCellStyle headerStyle = ExcelKit.getHeaderStyle(outWorkbook); + XSSFCellStyle dataStyle = ExcelKit.getDataStyle(outWorkbook); + //如果样例文件是xls格式,则转化为xlsx格式 + sampleExcelPath = ExcelKit.ConvertXlsToXlsx(sampleExcelPath); + //拷贝文件头 + ExcelKit.CopyHead(sampleExcelPath, outSheet, headerStyle); + + //目标Excel,就是把文件名解析出来后,后面添加上【成果】,需要动态计算获取,不能写死 + String excelPath = sampleExcelPath.replace(".xlsx", "【成果】.xlsx"); + ExcelKit.delExcel(excelPath); + + //找到parentPath下一级目录中所有文件 + List files = FileUtil.loopFiles(parentPath, file -> true); + int rowIndex = 0; + + //处理这个目录 + if (files != null) { + for (File file : files) { + //判断file是不是目录,是目录的需要跳过 + if (file.isDirectory()) continue; + if (!file.getName().endsWith(".xlsx") && !file.getName().endsWith(".xls")) + continue; + boolean flag = false; + for (String s : excludeCityList) { + if (file.getName().contains(s)) { + flag = true; + break; + } + } + if (flag) continue; + //只关心发展规模数据的表格 + if (!file.getName().contains(fileNameKey)) continue; + //县区名称 + String areaName = ru.getCityOrAreaName(file.getName()); + //市州名称 + //此文件的路径中最后一层的目录名称,应该是带着市州名称 ,把最后一层子目录的名称提出 + String parentPathName = file.getParentFile().getName(); + String cityName = ru.getCityOrAreaName(parentPathName); + if (StrKit.isBlank(cityName) || cityName.equals(areaName)) { + parentPathName = file.getParentFile().getParentFile().getName(); + cityName = ru.getCityOrAreaName(parentPathName); + } + if (StrKit.isBlank(cityName) || StrKit.isBlank(areaName)) { + System.out.println("发现异常数据,请人工处理:" + file.getName()); + System.exit(0); + } + + //县区名称 + System.out.println("正在进行" + cityName + "-" + areaName + "的数据填充~"); + String sourceExcel = file.getAbsolutePath(); + + String[] stageList = {"小学", "初中"}; + int[] sheetIndexList = {1, 2}; + + for (int K = 0; K < 2; K++) { + int sheetIndex = sheetIndexList[K]; + String stageName = stageList[K]; + + List> dataList = ExcelKit.readSecondTable(sourceExcel, sheetIndex, tableKeyword, + tableHeadRows, tableLetterIndex); + //取出第一行 + if (dataList.isEmpty()) continue; + List x = dataList.getFirst(); + int cnt = 0; + for (String s : x) if (s == null) cnt++; + int colsCount = x.size() - cnt; + + //义务教育招生数量 + for (List stringList : dataList) { + //年份 + int year = Integer.parseInt(stringList.getFirst()); + int v = 0; + if (colsCount == 11) { + v = Integer.parseInt(stringList.get(ExcelKit.transLetter2Num("D")).split("\\.")[0]); + } else if (colsCount == 9) { + v = Integer.parseInt(stringList.get(ExcelKit.transLetter2Num("D")).split("\\.")[0]); + } + Row outRow = outSheet.createRow(++rowIndex); + ExcelKit.putData(outRow, Arrays.asList(String.valueOf(year),"", "总招生数",stageName,"", String.valueOf(v), areaName, cityName), dataStyle); + } + + //2022入园基数 + for (List ignored : dataList) { + //年份 + int year = 2022; + //H预测总招生数 + int v = 0; + if (colsCount == 11) { + v = Integer.parseInt(dataList.getFirst().get(ExcelKit.transLetter2Num("D")).split("\\.")[0]); + } else if (colsCount == 9) { + v = Integer.parseInt(dataList.getFirst().get(ExcelKit.transLetter2Num("D")).split("\\.")[0]); + } + Row outRow = outSheet.createRow(++rowIndex); + ExcelKit.putData(outRow, Arrays.asList(String.valueOf(year),"", "2022年基数",stageName, "", String.valueOf(v), areaName, cityName), dataStyle); + } + + //城区 + for (List stringList : dataList) { + //年份 + int year = Integer.parseInt(stringList.getFirst()); + //I:修正城区招生A 修正县城内招生 + int v = 0; + if (colsCount == 11) { + v = Integer.parseInt(stringList.get(ExcelKit.transLetter2Num("E")).split("\\.")[0]); + } else if (colsCount == 9) { + v = Integer.parseInt(stringList.get(ExcelKit.transLetter2Num("E")).split("\\.")[0]); + } + Row outRow = outSheet.createRow(++rowIndex); + ExcelKit.putData(outRow, Arrays.asList(String.valueOf(year), + "城区", "",stageName, String.valueOf(v),"", areaName, cityName), dataStyle); + } + + //预测镇区在校生数 修正县城外在校生数*30% + for (List stringList : dataList) { + //年份 + int year = Integer.parseInt(stringList.getFirst()); + int v = 0; + if (colsCount == 11) { + v = Integer.parseInt(stringList.get(ExcelKit.transLetter2Num("F")).split("\\.")[0]); + } else if (colsCount == 9) { + v = Integer.parseInt(stringList.get(ExcelKit.transLetter2Num("F")).split("\\.")[0]); + v = (int) (v * 0.3);//乘以0.3 + } + Row outRow = outSheet.createRow(++rowIndex); + ExcelKit.putData(outRow, Arrays.asList(String.valueOf(year), "镇区", "",stageName, String.valueOf(v),"", areaName, cityName), dataStyle); + } + + for (List stringList : dataList) { + //年份 + int year = Integer.parseInt(stringList.getFirst()); + int v = 0; + if (colsCount == 11) { + v = Integer.parseInt(stringList.get(ExcelKit.transLetter2Num("G")).split("\\.")[0]); + } else if (colsCount == 9) { + v = Integer.parseInt(stringList.get(ExcelKit.transLetter2Num("F")).split("\\.")[0]); + int d = (int) (v * 0.3);//乘以0.3 + v = v - d;//剩下70% + } + Row outRow = outSheet.createRow(++rowIndex); + ExcelKit.putData(outRow, Arrays.asList(String.valueOf(year), "乡村", "",stageName, String.valueOf(v),"", areaName, cityName), dataStyle); + } + } + } + } + //保存文件 + ExcelKit.saveExcel(excelPath, outWorkbook); + System.out.println("县区所有文件处理完成!"); + } +}