|
@ -737,6 +737,7 @@ public class DcSdhsEventServiceImpl implements IDcSdhsEventService { |
|
|
public void exportAccidentModelAnalysis(XWPFDocument doc, DcSdhsEventQuery dcSdhsEventQuery) { |
|
|
public void exportAccidentModelAnalysis(XWPFDocument doc, DcSdhsEventQuery dcSdhsEventQuery) { |
|
|
// 初始化一个空的结果映射
|
|
|
// 初始化一个空的结果映射
|
|
|
Map<String, Map<String, Integer>> result = accidentModelAnalysis(dcSdhsEventQuery); |
|
|
Map<String, Map<String, Integer>> result = accidentModelAnalysis(dcSdhsEventQuery); |
|
|
|
|
|
if (result != null && result.size() != UniversalEnum.ZERO.getNumber()) { |
|
|
|
|
|
|
|
|
// 计算最大车辆类型数量
|
|
|
// 计算最大车辆类型数量
|
|
|
int maxVehicleTypes = 5; |
|
|
int maxVehicleTypes = 5; |
|
@ -839,7 +840,7 @@ public class DcSdhsEventServiceImpl implements IDcSdhsEventService { |
|
|
// 换行
|
|
|
// 换行
|
|
|
createLineBreak(doc); |
|
|
createLineBreak(doc); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
@ -944,7 +945,9 @@ public class DcSdhsEventServiceImpl implements IDcSdhsEventService { |
|
|
String hourString = String.format("%02d", hour); |
|
|
String hourString = String.format("%02d", hour); |
|
|
hourlyCounts.merge(hourString, 0L, Long::sum); |
|
|
hourlyCounts.merge(hourString, 0L, Long::sum); |
|
|
} |
|
|
} |
|
|
return hourlyCounts; |
|
|
Map<String, Long> hourlyCountsTreeMap = new TreeMap<>(hourlyCounts); |
|
|
|
|
|
|
|
|
|
|
|
return hourlyCountsTreeMap; |
|
|
} else if (dcSdhsEventQuery.getType().equals("1")) { |
|
|
} else if (dcSdhsEventQuery.getType().equals("1")) { |
|
|
// 将查询开始时间和结束时间转换为 LocalDateTime
|
|
|
// 将查询开始时间和结束时间转换为 LocalDateTime
|
|
|
LocalDateTime queryStart = dcSdhsEventQuery.getStartTime().toInstant().atZone(zoneId).toLocalDateTime(); |
|
|
LocalDateTime queryStart = dcSdhsEventQuery.getStartTime().toInstant().atZone(zoneId).toLocalDateTime(); |
|
@ -972,7 +975,9 @@ public class DcSdhsEventServiceImpl implements IDcSdhsEventService { |
|
|
String dateString = date.format(formatter); |
|
|
String dateString = date.format(formatter); |
|
|
dailyCounts.merge(dateString, 0L, Long::sum); |
|
|
dailyCounts.merge(dateString, 0L, Long::sum); |
|
|
} |
|
|
} |
|
|
return dailyCounts; |
|
|
// 将键值对放入TreeMap中,TreeMap会自动按键排序
|
|
|
|
|
|
Map<String, Long> dailyCountsTreeMap = new TreeMap<>(dailyCounts); |
|
|
|
|
|
return dailyCountsTreeMap; |
|
|
} else { |
|
|
} else { |
|
|
// 将查询开始时间和结束时间转换为 LocalDateTime
|
|
|
// 将查询开始时间和结束时间转换为 LocalDateTime
|
|
|
LocalDateTime queryStart = dcSdhsEventQuery.getStartTime().toInstant().atZone(zoneId).toLocalDateTime(); |
|
|
LocalDateTime queryStart = dcSdhsEventQuery.getStartTime().toInstant().atZone(zoneId).toLocalDateTime(); |
|
@ -1000,7 +1005,9 @@ public class DcSdhsEventServiceImpl implements IDcSdhsEventService { |
|
|
monthlyCounts.merge(monthString, 0L, Long::sum); |
|
|
monthlyCounts.merge(monthString, 0L, Long::sum); |
|
|
currentMonth = currentMonth.plusMonths(1); |
|
|
currentMonth = currentMonth.plusMonths(1); |
|
|
} |
|
|
} |
|
|
return monthlyCounts; |
|
|
// 将键值对放入TreeMap中,TreeMap会自动按键排序
|
|
|
|
|
|
Map<String, Long> monthlyCountsTreeMap = new TreeMap<>(monthlyCounts); |
|
|
|
|
|
return monthlyCountsTreeMap; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
@ -1074,118 +1081,119 @@ public class DcSdhsEventServiceImpl implements IDcSdhsEventService { |
|
|
name = "wordTemplate/accidentTimeMonthAnalysis.docx"; |
|
|
name = "wordTemplate/accidentTimeMonthAnalysis.docx"; |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
if (currentYearData != null && currentYearData.size() != UniversalEnum.ZERO.getNumber()) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 创建表格
|
|
|
// 创建表格
|
|
|
XWPFTable table = doc.createTable(rows, 3); |
|
|
XWPFTable table = doc.createTable(rows, 3); |
|
|
CTTblWidth infoTableWidth = table.getCTTbl().addNewTblPr().addNewTblW(); |
|
|
CTTblWidth infoTableWidth = table.getCTTbl().addNewTblPr().addNewTblW(); |
|
|
infoTableWidth.setType(STTblWidth.DXA); |
|
|
infoTableWidth.setType(STTblWidth.DXA); |
|
|
infoTableWidth.setW(BigInteger.valueOf(UniversalEnum.NINE_THOUSAND_AND_SEVENTY_TWO.getNumber())); |
|
|
infoTableWidth.setW(BigInteger.valueOf(UniversalEnum.NINE_THOUSAND_AND_SEVENTY_TWO.getNumber())); |
|
|
|
|
|
|
|
|
// 表头
|
|
|
// 表头
|
|
|
setTableFonts(table.getRow(0).getCell(0), "时段"); |
|
|
setTableFonts(table.getRow(0).getCell(0), "时段"); |
|
|
setTableFonts(table.getRow(0).getCell(1), "今年同期"); |
|
|
setTableFonts(table.getRow(0).getCell(1), "今年同期"); |
|
|
setTableFonts(table.getRow(0).getCell(2), "去年同期"); |
|
|
setTableFonts(table.getRow(0).getCell(2), "去年同期"); |
|
|
// 定义一个从数字到日期字符串的映射
|
|
|
// 定义一个从数字到日期字符串的映射
|
|
|
Map<Integer, String> indexToDateMap = new HashMap<>(); |
|
|
Map<Integer, String> indexToDateMap = new HashMap<>(); |
|
|
for (int i = 0; i <= 32; i++) { |
|
|
for (int i = 0; i <= 32; i++) { |
|
|
String dateString = String.format("%02d", i); |
|
|
String dateString = String.format("%02d", i); |
|
|
indexToDateMap.put(i, dateString); |
|
|
indexToDateMap.put(i, dateString); |
|
|
} |
|
|
} |
|
|
String dayString = ""; |
|
|
String dayString = ""; |
|
|
// 填充表格数据
|
|
|
// 填充表格数据
|
|
|
for (int i = 0; i < rows - 1; i++) { |
|
|
for (int i = 0; i < rows - 1; i++) { |
|
|
|
|
|
|
|
|
if (type.equals("2")) { |
|
|
if (type.equals("2")) { |
|
|
dayString = indexToDateMap.get(i); // 获取 i 对应的日期字符串
|
|
|
dayString = indexToDateMap.get(i); // 获取 i 对应的日期字符串
|
|
|
} else { |
|
|
} else { |
|
|
dayString = indexToDateMap.get(i + 1); // 获取 i 对应的日期字符串
|
|
|
dayString = indexToDateMap.get(i + 1); // 获取 i 对应的日期字符串
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
setTableFonts(table.getRow(i + 1).getCell(0), (dayString) + stingType); |
|
|
setTableFonts(table.getRow(i + 1).getCell(0), (dayString) + stingType); |
|
|
Long currentYearValue = currentYearData.getOrDefault(dayString, 0L); |
|
|
Long currentYearValue = currentYearData.getOrDefault(dayString, 0L); |
|
|
setTableFonts(table.getRow(i + 1).getCell(1), String.valueOf(currentYearValue)); |
|
|
setTableFonts(table.getRow(i + 1).getCell(1), String.valueOf(currentYearValue)); |
|
|
Long lastYearValue = lastYearData.getOrDefault(dayString, 0L); |
|
|
Long lastYearValue = lastYearData.getOrDefault(dayString, 0L); |
|
|
setTableFonts(table.getRow(i + 1).getCell(2), String.valueOf(lastYearValue)); |
|
|
setTableFonts(table.getRow(i + 1).getCell(2), String.valueOf(lastYearValue)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 图表部分
|
|
|
// 图表部分
|
|
|
try { |
|
|
try { |
|
|
|
|
|
|
|
|
InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream(name); |
|
|
InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream(name); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
XWPFDocument copiedTemplate = new XWPFDocument(inputStream); |
|
|
XWPFDocument copiedTemplate = new XWPFDocument(inputStream); |
|
|
|
|
|
|
|
|
List<XWPFChart> charts = copiedTemplate.getCharts(); |
|
|
List<XWPFChart> charts = copiedTemplate.getCharts(); |
|
|
XWPFChart chart = charts.get(0); |
|
|
XWPFChart chart = charts.get(0); |
|
|
XSSFWorkbook workbook = chart.getWorkbook(); |
|
|
XSSFWorkbook workbook = chart.getWorkbook(); |
|
|
XSSFSheet sheet = workbook.getSheetAt(UniversalEnum.ZERO.getNumber()); |
|
|
XSSFSheet sheet = workbook.getSheetAt(UniversalEnum.ZERO.getNumber()); |
|
|
// 更新图表数据
|
|
|
// 更新图表数据
|
|
|
for (int i = UniversalEnum.ZERO.getNumber(); i < rows - 1; i++) { |
|
|
for (int i = UniversalEnum.ZERO.getNumber(); i < rows - 1; i++) { |
|
|
if (type.equals("2")) { |
|
|
if (type.equals("2")) { |
|
|
dayString = indexToDateMap.get(i); // 获取 i 对应的日期字符串
|
|
|
dayString = indexToDateMap.get(i); // 获取 i 对应的日期字符串
|
|
|
} else { |
|
|
} else { |
|
|
dayString = indexToDateMap.get(i + 1); // 获取 i 对应的日期字符串
|
|
|
dayString = indexToDateMap.get(i + 1); // 获取 i 对应的日期字符串
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
sheet.getRow(i + 1).getCell(0).setCellValue((dayString) + stingType); |
|
|
sheet.getRow(i + 1).getCell(0).setCellValue((dayString) + stingType); |
|
|
int rowIndex = i + UniversalEnum.ONE.getNumber(); // 计算行索引
|
|
|
int rowIndex = i + UniversalEnum.ONE.getNumber(); // 计算行索引
|
|
|
Row row = sheet.getRow(rowIndex); |
|
|
Row row = sheet.getRow(rowIndex); |
|
|
if (row == null) { |
|
|
if (row == null) { |
|
|
// 如果行不存在,则创建新行
|
|
|
// 如果行不存在,则创建新行
|
|
|
row = sheet.createRow(rowIndex); |
|
|
row = sheet.createRow(rowIndex); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 现在可以安全地访问或创建单元格了
|
|
|
// 现在可以安全地访问或创建单元格了
|
|
|
Cell cell = row.getCell(UniversalEnum.ONE.getNumber()); |
|
|
Cell cell = row.getCell(UniversalEnum.ONE.getNumber()); |
|
|
if (cell == null) { |
|
|
if (cell == null) { |
|
|
// 通常情况下,getCell 会创建新的单元格,但这里我们显式地检查以防万一
|
|
|
// 通常情况下,getCell 会创建新的单元格,但这里我们显式地检查以防万一
|
|
|
cell = row.createCell(UniversalEnum.ONE.getNumber(), CellType.NUMERIC); |
|
|
cell = row.createCell(UniversalEnum.ONE.getNumber(), CellType.NUMERIC); |
|
|
} |
|
|
} |
|
|
// 设置单元格的值
|
|
|
// 设置单元格的值
|
|
|
sheet.getRow(i + 1).getCell(1).setCellValue(currentYearData.get(dayString)); |
|
|
sheet.getRow(i + 1).getCell(1).setCellValue(currentYearData.get(dayString)); |
|
|
int rowIndexTwo = i + 1 + UniversalEnum.ONE.getNumber(); // 计算行索引
|
|
|
int rowIndexTwo = i + 1 + UniversalEnum.ONE.getNumber(); // 计算行索引
|
|
|
Row rowTwo = sheet.getRow(rowIndexTwo); |
|
|
Row rowTwo = sheet.getRow(rowIndexTwo); |
|
|
if (rowTwo == null) { |
|
|
if (rowTwo == null) { |
|
|
// 如果行不存在,则创建新行
|
|
|
// 如果行不存在,则创建新行
|
|
|
rowTwo = sheet.createRow(rowIndexTwo); |
|
|
rowTwo = sheet.createRow(rowIndexTwo); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 现在可以安全地访问或创建单元格了
|
|
|
// 现在可以安全地访问或创建单元格了
|
|
|
Cell cellTwo = row.getCell(UniversalEnum.TWO.getNumber()); |
|
|
Cell cellTwo = row.getCell(UniversalEnum.TWO.getNumber()); |
|
|
if (cellTwo == null) { |
|
|
if (cellTwo == null) { |
|
|
// 通常情况下,getCell 会创建新的单元格,但这里我们显式地检查以防万一
|
|
|
// 通常情况下,getCell 会创建新的单元格,但这里我们显式地检查以防万一
|
|
|
cell = row.createCell(UniversalEnum.TWO.getNumber(), CellType.NUMERIC); |
|
|
cell = row.createCell(UniversalEnum.TWO.getNumber(), CellType.NUMERIC); |
|
|
|
|
|
} |
|
|
|
|
|
sheet.getRow(i + 1).getCell(2).setCellValue(lastYearData.get(dayString)); |
|
|
|
|
|
//sheet.getRow(i+UniversalEnum.ONE.getNumber()).getCell(UniversalEnum.ONE.getNumber()).setCellValue(Long.parseLong(entries.get(i).getValue().toString()));
|
|
|
} |
|
|
} |
|
|
sheet.getRow(i + 1).getCell(2).setCellValue(lastYearData.get(dayString)); |
|
|
|
|
|
//sheet.getRow(i+UniversalEnum.ONE.getNumber()).getCell(UniversalEnum.ONE.getNumber()).setCellValue(Long.parseLong(entries.get(i).getValue().toString()));
|
|
|
|
|
|
} |
|
|
|
|
|
/* for (int i = 0; i < 24; i++) { |
|
|
/* for (int i = 0; i < 24; i++) { |
|
|
|
|
|
|
|
|
sheet.getRow(i + 1).getCell(0).setCellValue((i) + "点"); |
|
|
sheet.getRow(i + 1).getCell(0).setCellValue((i) + "点"); |
|
|
sheet.getRow(i + 1).getCell(1).setCellValue(currentYearData.get(i)); |
|
|
sheet.getRow(i + 1).getCell(1).setCellValue(currentYearData.get(i)); |
|
|
sheet.getRow(i + 1).getCell(2).setCellValue(lastYearData.get(i)); |
|
|
sheet.getRow(i + 1).getCell(2).setCellValue(lastYearData.get(i)); |
|
|
}*/ |
|
|
}*/ |
|
|
for (int i = sheet.getLastRowNum(); i > currentYearData.size(); i--) { |
|
|
for (int i = sheet.getLastRowNum(); i > currentYearData.size(); i--) { |
|
|
sheet.removeRow(sheet.getRow(i)); |
|
|
sheet.removeRow(sheet.getRow(i)); |
|
|
} |
|
|
} |
|
|
// 更新图表
|
|
|
// 更新图表
|
|
|
PoiUtil.wordExportChar(chart, "事故时间分析", new String[]{"今年同期", "去年同期"}, sheet); |
|
|
PoiUtil.wordExportChar(chart, "事故时间分析", new String[]{"今年同期", "去年同期"}, sheet); |
|
|
|
|
|
|
|
|
// 合并图表到Word文档
|
|
|
|
|
|
mergeChart(chart, doc); |
|
|
|
|
|
|
|
|
|
|
|
// 关闭模板文档
|
|
|
// 合并图表到Word文档
|
|
|
copiedTemplate.close(); |
|
|
mergeChart(chart, doc); |
|
|
} catch (Exception e) { |
|
|
|
|
|
e.printStackTrace(); |
|
|
|
|
|
} |
|
|
|
|
|
//换行
|
|
|
|
|
|
createLineBreak(doc); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 关闭模板文档
|
|
|
|
|
|
copiedTemplate.close(); |
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
e.printStackTrace(); |
|
|
|
|
|
} |
|
|
|
|
|
//换行
|
|
|
|
|
|
createLineBreak(doc); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -1871,97 +1879,100 @@ public class DcSdhsEventServiceImpl implements IDcSdhsEventService { |
|
|
List<DcTollStationStatisticsDataMap> exit = map.get("exit"); |
|
|
List<DcTollStationStatisticsDataMap> exit = map.get("exit"); |
|
|
int rows = entrance.size(); |
|
|
int rows = entrance.size(); |
|
|
String name = "wordTemplate/tollGateEntrance.docx"; |
|
|
String name = "wordTemplate/tollGateEntrance.docx"; |
|
|
|
|
|
if (map != null && map.size() != UniversalEnum.ZERO.getNumber()) { |
|
|
|
|
|
|
|
|
|
|
|
PoiUtil.createHeading2(doc, "收费站出入口车流量"); |
|
|
|
|
|
|
|
|
// 创建表格
|
|
|
// 创建表格
|
|
|
XWPFTable table = doc.createTable(rows+1, 3); |
|
|
XWPFTable table = doc.createTable(rows + 1, 3); |
|
|
CTTblWidth infoTableWidth = table.getCTTbl().addNewTblPr().addNewTblW(); |
|
|
CTTblWidth infoTableWidth = table.getCTTbl().addNewTblPr().addNewTblW(); |
|
|
infoTableWidth.setType(STTblWidth.DXA); |
|
|
infoTableWidth.setType(STTblWidth.DXA); |
|
|
infoTableWidth.setW(BigInteger.valueOf(UniversalEnum.NINE_THOUSAND_AND_SEVENTY_TWO.getNumber())); |
|
|
infoTableWidth.setW(BigInteger.valueOf(UniversalEnum.NINE_THOUSAND_AND_SEVENTY_TWO.getNumber())); |
|
|
|
|
|
|
|
|
// 表头
|
|
|
// 表头
|
|
|
setTableFonts(table.getRow(0).getCell(0), "收费站"); |
|
|
setTableFonts(table.getRow(0).getCell(0), "收费站"); |
|
|
setTableFonts(table.getRow(0).getCell(1), "入口"); |
|
|
setTableFonts(table.getRow(0).getCell(1), "入口"); |
|
|
setTableFonts(table.getRow(0).getCell(2), "出口"); |
|
|
setTableFonts(table.getRow(0).getCell(2), "出口"); |
|
|
// 填充表格数据
|
|
|
// 填充表格数据
|
|
|
for (int i = 0; i < rows ; i++) { |
|
|
for (int i = 0; i < rows; i++) { |
|
|
|
|
|
|
|
|
setTableFonts(table.getRow(i + 1).getCell(0), (entrance.get(i).getFacilityName())); |
|
|
setTableFonts(table.getRow(i + 1).getCell(0), (entrance.get(i).getFacilityName())); |
|
|
Integer entranceValue = entrance.get(i).getTrafficVolume(); |
|
|
Integer entranceValue = entrance.get(i).getTrafficVolume(); |
|
|
setTableFonts(table.getRow(i + 1).getCell(1), String.valueOf(entranceValue)); |
|
|
setTableFonts(table.getRow(i + 1).getCell(1), String.valueOf(entranceValue)); |
|
|
Integer exitValue = exit.get(i).getTrafficVolume(); |
|
|
Integer exitValue = exit.get(i).getTrafficVolume(); |
|
|
setTableFonts(table.getRow(i + 1).getCell(2), String.valueOf(exitValue)); |
|
|
setTableFonts(table.getRow(i + 1).getCell(2), String.valueOf(exitValue)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 图表部分
|
|
|
// 图表部分
|
|
|
try { |
|
|
try { |
|
|
|
|
|
|
|
|
InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream(name); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream(name); |
|
|
|
|
|
|
|
|
XWPFDocument copiedTemplate = new XWPFDocument(inputStream); |
|
|
|
|
|
|
|
|
|
|
|
List<XWPFChart> charts = copiedTemplate.getCharts(); |
|
|
XWPFDocument copiedTemplate = new XWPFDocument(inputStream); |
|
|
XWPFChart chart = charts.get(0); |
|
|
|
|
|
XSSFWorkbook workbook = chart.getWorkbook(); |
|
|
|
|
|
XSSFSheet sheet = workbook.getSheetAt(UniversalEnum.ZERO.getNumber()); |
|
|
|
|
|
// 更新图表数据
|
|
|
|
|
|
for (int i = UniversalEnum.ZERO.getNumber(); i < rows; i++) { |
|
|
|
|
|
|
|
|
|
|
|
sheet.getRow(i + 1).getCell(0).setCellValue(entrance.get(i).getFacilityName()); |
|
|
List<XWPFChart> charts = copiedTemplate.getCharts(); |
|
|
int rowIndex = i + UniversalEnum.ONE.getNumber(); // 计算行索引
|
|
|
XWPFChart chart = charts.get(0); |
|
|
Row row = sheet.getRow(rowIndex); |
|
|
XSSFWorkbook workbook = chart.getWorkbook(); |
|
|
if (row == null) { |
|
|
XSSFSheet sheet = workbook.getSheetAt(UniversalEnum.ZERO.getNumber()); |
|
|
// 如果行不存在,则创建新行
|
|
|
// 更新图表数据
|
|
|
row = sheet.createRow(rowIndex); |
|
|
for (int i = UniversalEnum.ZERO.getNumber(); i < rows; i++) { |
|
|
} |
|
|
|
|
|
|
|
|
sheet.getRow(i + 1).getCell(0).setCellValue(entrance.get(i).getFacilityName()); |
|
|
|
|
|
int rowIndex = i + UniversalEnum.ONE.getNumber(); // 计算行索引
|
|
|
|
|
|
Row row = sheet.getRow(rowIndex); |
|
|
|
|
|
if (row == null) { |
|
|
|
|
|
// 如果行不存在,则创建新行
|
|
|
|
|
|
row = sheet.createRow(rowIndex); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// 现在可以安全地访问或创建单元格了
|
|
|
// 现在可以安全地访问或创建单元格了
|
|
|
Cell cell = row.getCell(UniversalEnum.ONE.getNumber()); |
|
|
Cell cell = row.getCell(UniversalEnum.ONE.getNumber()); |
|
|
if (cell == null) { |
|
|
if (cell == null) { |
|
|
// 通常情况下,getCell 会创建新的单元格,但这里我们显式地检查以防万一
|
|
|
// 通常情况下,getCell 会创建新的单元格,但这里我们显式地检查以防万一
|
|
|
cell = row.createCell(UniversalEnum.ONE.getNumber(), CellType.NUMERIC); |
|
|
cell = row.createCell(UniversalEnum.ONE.getNumber(), CellType.NUMERIC); |
|
|
} |
|
|
} |
|
|
// 设置单元格的值
|
|
|
// 设置单元格的值
|
|
|
sheet.getRow(i + 1).getCell(1).setCellValue( entrance.get(i).getTrafficVolume()); |
|
|
sheet.getRow(i + 1).getCell(1).setCellValue(entrance.get(i).getTrafficVolume()); |
|
|
int rowIndexTwo = i + 1 + UniversalEnum.ONE.getNumber(); // 计算行索引
|
|
|
int rowIndexTwo = i + 1 + UniversalEnum.ONE.getNumber(); // 计算行索引
|
|
|
Row rowTwo = sheet.getRow(rowIndexTwo); |
|
|
Row rowTwo = sheet.getRow(rowIndexTwo); |
|
|
if (rowTwo == null) { |
|
|
if (rowTwo == null) { |
|
|
// 如果行不存在,则创建新行
|
|
|
// 如果行不存在,则创建新行
|
|
|
rowTwo = sheet.createRow(rowIndexTwo); |
|
|
rowTwo = sheet.createRow(rowIndexTwo); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 现在可以安全地访问或创建单元格了
|
|
|
// 现在可以安全地访问或创建单元格了
|
|
|
Cell cellTwo = row.getCell(UniversalEnum.TWO.getNumber()); |
|
|
Cell cellTwo = row.getCell(UniversalEnum.TWO.getNumber()); |
|
|
if (cellTwo == null) { |
|
|
if (cellTwo == null) { |
|
|
// 通常情况下,getCell 会创建新的单元格,但这里我们显式地检查以防万一
|
|
|
// 通常情况下,getCell 会创建新的单元格,但这里我们显式地检查以防万一
|
|
|
cell = row.createCell(UniversalEnum.TWO.getNumber(), CellType.NUMERIC); |
|
|
cell = row.createCell(UniversalEnum.TWO.getNumber(), CellType.NUMERIC); |
|
|
|
|
|
} |
|
|
|
|
|
sheet.getRow(i + 1).getCell(2).setCellValue(exit.get(i).getTrafficVolume()); |
|
|
|
|
|
//sheet.getRow(i+UniversalEnum.ONE.getNumber()).getCell(UniversalEnum.ONE.getNumber()).setCellValue(Long.parseLong(entries.get(i).getValue().toString()));
|
|
|
} |
|
|
} |
|
|
sheet.getRow(i + 1).getCell(2).setCellValue(exit.get(i).getTrafficVolume()); |
|
|
|
|
|
//sheet.getRow(i+UniversalEnum.ONE.getNumber()).getCell(UniversalEnum.ONE.getNumber()).setCellValue(Long.parseLong(entries.get(i).getValue().toString()));
|
|
|
|
|
|
} |
|
|
|
|
|
/* for (int i = 0; i < 24; i++) { |
|
|
/* for (int i = 0; i < 24; i++) { |
|
|
|
|
|
|
|
|
sheet.getRow(i + 1).getCell(0).setCellValue((i) + "点"); |
|
|
sheet.getRow(i + 1).getCell(0).setCellValue((i) + "点"); |
|
|
sheet.getRow(i + 1).getCell(1).setCellValue(currentYearData.get(i)); |
|
|
sheet.getRow(i + 1).getCell(1).setCellValue(currentYearData.get(i)); |
|
|
sheet.getRow(i + 1).getCell(2).setCellValue(lastYearData.get(i)); |
|
|
sheet.getRow(i + 1).getCell(2).setCellValue(lastYearData.get(i)); |
|
|
}*/ |
|
|
}*/ |
|
|
for (int i = sheet.getLastRowNum(); i > entrance.size(); i--) { |
|
|
for (int i = sheet.getLastRowNum(); i > entrance.size(); i--) { |
|
|
sheet.removeRow(sheet.getRow(i)); |
|
|
sheet.removeRow(sheet.getRow(i)); |
|
|
} |
|
|
} |
|
|
// 更新图表
|
|
|
// 更新图表
|
|
|
PoiUtil.wordExportChar(chart, "收费站出入口车流量", new String[]{"入口", "出口"}, sheet); |
|
|
PoiUtil.wordExportChar(chart, "收费站出入口车流量", new String[]{"入口", "出口"}, sheet); |
|
|
|
|
|
|
|
|
// 合并图表到Word文档
|
|
|
// 合并图表到Word文档
|
|
|
mergeChart(chart, doc); |
|
|
mergeChart(chart, doc); |
|
|
|
|
|
|
|
|
// 关闭模板文档
|
|
|
// 关闭模板文档
|
|
|
copiedTemplate.close(); |
|
|
copiedTemplate.close(); |
|
|
} catch (Exception e) { |
|
|
} catch (Exception e) { |
|
|
e.printStackTrace(); |
|
|
e.printStackTrace(); |
|
|
|
|
|
} |
|
|
|
|
|
//换行
|
|
|
|
|
|
createLineBreak(doc); |
|
|
} |
|
|
} |
|
|
//换行
|
|
|
|
|
|
createLineBreak(doc); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
/** |
|
|
/** |
|
@ -1977,6 +1988,7 @@ public class DcSdhsEventServiceImpl implements IDcSdhsEventService { |
|
|
List<TrafficFlowStatisticsMap> exit = map.get("jinanDirection"); |
|
|
List<TrafficFlowStatisticsMap> exit = map.get("jinanDirection"); |
|
|
int rows = entrance.size(); |
|
|
int rows = entrance.size(); |
|
|
String name = "wordTemplate/frameDataAnalysis.docx"; |
|
|
String name = "wordTemplate/frameDataAnalysis.docx"; |
|
|
|
|
|
if (map != null && map.size() != UniversalEnum.ZERO.getNumber()) { |
|
|
|
|
|
|
|
|
// 创建表格
|
|
|
// 创建表格
|
|
|
XWPFTable table = doc.createTable(rows+1, 3); |
|
|
XWPFTable table = doc.createTable(rows+1, 3); |
|
@ -2068,7 +2080,7 @@ public class DcSdhsEventServiceImpl implements IDcSdhsEventService { |
|
|
} |
|
|
} |
|
|
//换行
|
|
|
//换行
|
|
|
createLineBreak(doc); |
|
|
createLineBreak(doc); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|