|
|
@ -10,23 +10,26 @@ import com.zc.business.constant.RedisKeyConstants; |
|
|
|
import com.zc.business.controller.WeatherForecastController; |
|
|
|
import com.zc.business.domain.DcSdhsEvent; |
|
|
|
import com.zc.business.domain.DcSdhsEventQuery; |
|
|
|
import com.zc.business.domain.DcTollStationStatisticsDataMap; |
|
|
|
import com.zc.business.domain.TrafficFlowStatisticsMap; |
|
|
|
import com.zc.business.enums.UniversalEnum; |
|
|
|
import com.zc.business.service.IDcGantryStatisticsDataService; |
|
|
|
import com.zc.business.service.IDcSdhsEventService; |
|
|
|
import com.zc.business.service.IDcTollStationStatisticsDataService; |
|
|
|
import com.zc.business.utils.PoiUtil; |
|
|
|
import org.apache.poi.xssf.usermodel.XSSFSheet; |
|
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook; |
|
|
|
import org.apache.poi.xwpf.usermodel.*; |
|
|
|
import org.apache.poi.ss.usermodel.Cell; |
|
|
|
import org.apache.poi.ss.usermodel.CellType; |
|
|
|
import org.apache.poi.ss.usermodel.Row; |
|
|
|
import org.apache.poi.xssf.usermodel.XSSFCell; |
|
|
|
import org.apache.poi.xssf.usermodel.XSSFRow; |
|
|
|
import org.apache.poi.xssf.usermodel.XSSFSheet; |
|
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook; |
|
|
|
import org.apache.poi.xwpf.usermodel.*; |
|
|
|
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTblWidth; |
|
|
|
import org.openxmlformats.schemas.wordprocessingml.x2006.main.STTblWidth; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
import javax.naming.NamingEnumeration; |
|
|
|
import java.io.FileInputStream; |
|
|
|
import java.io.IOException; |
|
|
|
import java.io.InputStream; |
|
|
@ -35,18 +38,16 @@ import java.text.SimpleDateFormat; |
|
|
|
import java.time.LocalDate; |
|
|
|
import java.time.LocalDateTime; |
|
|
|
import java.time.LocalTime; |
|
|
|
import java.time.ZoneId; |
|
|
|
import java.time.format.DateTimeFormatter; |
|
|
|
import java.time.temporal.TemporalAdjusters; |
|
|
|
import java.util.*; |
|
|
|
import java.time.ZoneId; |
|
|
|
import java.util.regex.Matcher; |
|
|
|
import java.util.regex.Pattern; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
import static com.zc.business.utils.PoiUtil.*; |
|
|
|
|
|
|
|
import static com.zc.business.utils.PoiUtil.addDescription; |
|
|
|
|
|
|
|
/** |
|
|
|
* 高速云事件分析Service业务层处理 |
|
|
|
* |
|
|
@ -61,6 +62,10 @@ public class DcSdhsEventServiceImpl implements IDcSdhsEventService { |
|
|
|
@Autowired |
|
|
|
private WeatherForecastController weatherForecastController; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private IDcTollStationStatisticsDataService dcTollStationStatisticsDataService; |
|
|
|
@Autowired |
|
|
|
private IDcGantryStatisticsDataService dcGantryStatisticsDataService; |
|
|
|
|
|
|
|
@Override |
|
|
|
public AjaxResult importData(String fileName, String fileUrl) throws IOException { |
|
|
@ -237,6 +242,7 @@ public class DcSdhsEventServiceImpl implements IDcSdhsEventService { |
|
|
|
|
|
|
|
/** |
|
|
|
* 事故车型分析 导出 |
|
|
|
* |
|
|
|
* @param doc |
|
|
|
* @param dcSdhsEventQuery |
|
|
|
*/ |
|
|
@ -351,6 +357,7 @@ public class DcSdhsEventServiceImpl implements IDcSdhsEventService { |
|
|
|
|
|
|
|
/** |
|
|
|
* 事故车型分析 查询 |
|
|
|
* |
|
|
|
* @param dcSdhsEventQuery |
|
|
|
* @return |
|
|
|
*/ |
|
|
@ -421,6 +428,7 @@ public class DcSdhsEventServiceImpl implements IDcSdhsEventService { |
|
|
|
|
|
|
|
/** |
|
|
|
* 事故时间分析查询 |
|
|
|
* |
|
|
|
* @param dcSdhsEventQuery |
|
|
|
* @return |
|
|
|
*/ |
|
|
@ -512,6 +520,7 @@ public class DcSdhsEventServiceImpl implements IDcSdhsEventService { |
|
|
|
|
|
|
|
/** |
|
|
|
* // 在指定时间范围内的事件
|
|
|
|
* |
|
|
|
* @param dcSdhsEventQuery |
|
|
|
* @param cacheList |
|
|
|
* @param zoneId |
|
|
@ -542,6 +551,7 @@ public class DcSdhsEventServiceImpl implements IDcSdhsEventService { |
|
|
|
|
|
|
|
/** |
|
|
|
* 事故时间分析导出 |
|
|
|
* |
|
|
|
* @param doc |
|
|
|
* @param dcSdhsEventQuery |
|
|
|
*/ |
|
|
@ -689,17 +699,15 @@ public class DcSdhsEventServiceImpl implements IDcSdhsEventService { |
|
|
|
createLineBreak(doc); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* @param input |
|
|
|
* @return java.util.List<java.lang.Integer> |
|
|
|
* @Description 提取文字中的数字 |
|
|
|
* |
|
|
|
* @author liuwenge |
|
|
|
* @date 2024/8/15 17:05 |
|
|
|
* @param input |
|
|
|
* @return java.util.List<java.lang.Integer> |
|
|
|
*/ |
|
|
|
private static List<Integer> extractNumbers(String input) { |
|
|
|
List<Integer> numbers = new ArrayList<>(); |
|
|
@ -736,12 +744,11 @@ public class DcSdhsEventServiceImpl implements IDcSdhsEventService { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* @param dcSdhsEventQuery |
|
|
|
* @return com.ruoyi.common.core.domain.AjaxResult |
|
|
|
* @Description 事故地市分布 |
|
|
|
* |
|
|
|
* @author liuwenge |
|
|
|
* @date 2024/8/20 9:13 |
|
|
|
* @param dcSdhsEventQuery |
|
|
|
* @return com.ruoyi.common.core.domain.AjaxResult |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public AjaxResult selectRegionAnalysis(DcSdhsEventQuery dcSdhsEventQuery) { |
|
|
@ -807,13 +814,12 @@ public class DcSdhsEventServiceImpl implements IDcSdhsEventService { |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @Description 导出事故地市分布 |
|
|
|
* |
|
|
|
* @author liuwenge |
|
|
|
* @date 2024/8/20 9:17 |
|
|
|
* @param doc |
|
|
|
* @param dcSdhsEventQuery |
|
|
|
* @return void |
|
|
|
* @Description 导出事故地市分布 |
|
|
|
* @author liuwenge |
|
|
|
* @date 2024/8/20 9:17 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public void exportRegionAnalysis(XWPFDocument doc, DcSdhsEventQuery dcSdhsEventQuery) { |
|
|
@ -893,12 +899,11 @@ public class DcSdhsEventServiceImpl implements IDcSdhsEventService { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* @param dcSdhsEventQuery |
|
|
|
* @return com.ruoyi.common.core.domain.AjaxResult |
|
|
|
* @Description 查询交通管制情况统计 |
|
|
|
* |
|
|
|
* @author liuwenge |
|
|
|
* @date 2024/8/20 11:06 |
|
|
|
* @param dcSdhsEventQuery |
|
|
|
* @return com.ruoyi.common.core.domain.AjaxResult |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public AjaxResult selectStationAnalysis(DcSdhsEventQuery dcSdhsEventQuery) { |
|
|
@ -980,12 +985,11 @@ public class DcSdhsEventServiceImpl implements IDcSdhsEventService { |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @param title |
|
|
|
* @return java.lang.String |
|
|
|
* @Description 从标题中截取收费站名称 |
|
|
|
* |
|
|
|
* @author liuwenge |
|
|
|
* @date 2024/8/19 15:32 |
|
|
|
* @param title |
|
|
|
* @return java.lang.String |
|
|
|
*/ |
|
|
|
private static String getStationName(String title) { |
|
|
|
|
|
|
@ -1004,13 +1008,12 @@ public class DcSdhsEventServiceImpl implements IDcSdhsEventService { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* @Description 导出交通管制情况统计 |
|
|
|
* |
|
|
|
* @author liuwenge |
|
|
|
* @date 2024/8/20 11:05 |
|
|
|
* @param doc |
|
|
|
* @param dcSdhsEventQuery |
|
|
|
* @return com.ruoyi.common.core.domain.AjaxResult |
|
|
|
* @Description 导出交通管制情况统计 |
|
|
|
* @author liuwenge |
|
|
|
* @date 2024/8/20 11:05 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public void exportStationAnalysis(XWPFDocument doc, DcSdhsEventQuery dcSdhsEventQuery) { |
|
|
@ -1094,12 +1097,11 @@ public class DcSdhsEventServiceImpl implements IDcSdhsEventService { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* @param dcSdhsEventQuery |
|
|
|
* @return com.ruoyi.common.core.domain.AjaxResult |
|
|
|
* @Description 查询交通事故类型统计 |
|
|
|
* |
|
|
|
* @author liuwenge |
|
|
|
* @date 2024/8/21 10:56 |
|
|
|
* @param dcSdhsEventQuery |
|
|
|
* @return com.ruoyi.common.core.domain.AjaxResult |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public AjaxResult selectAccidentType(DcSdhsEventQuery dcSdhsEventQuery) { |
|
|
@ -1130,13 +1132,12 @@ public class DcSdhsEventServiceImpl implements IDcSdhsEventService { |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @Description 导出交通事故类型统计 |
|
|
|
* |
|
|
|
* @author liuwenge |
|
|
|
* @date 2024/8/21 11:07 |
|
|
|
* @param doc |
|
|
|
* @param dcSdhsEventQuery |
|
|
|
* @return void |
|
|
|
* @Description 导出交通事故类型统计 |
|
|
|
* @author liuwenge |
|
|
|
* @date 2024/8/21 11:07 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public void exportAccidentType(XWPFDocument doc, DcSdhsEventQuery dcSdhsEventQuery) { |
|
|
@ -1334,4 +1335,289 @@ public class DcSdhsEventServiceImpl implements IDcSdhsEventService { |
|
|
|
result.put("dataList",dataList); |
|
|
|
return AjaxResult.success(result); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 收费站出入口分析 |
|
|
|
* |
|
|
|
* @param dcSdhsEventQuery |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public Map<String, List<DcTollStationStatisticsDataMap>> TollBoothStatisticsList(DcSdhsEventQuery dcSdhsEventQuery) { |
|
|
|
Date startTime = dcSdhsEventQuery.getStartTime(); |
|
|
|
LocalDateTime localDateTime = startTime.toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime(); |
|
|
|
// 定义日期时间格式
|
|
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); |
|
|
|
// 将 LocalDateTime 转换为字符串
|
|
|
|
String startDate = localDateTime.format(formatter); |
|
|
|
String type = dcSdhsEventQuery.getType(); |
|
|
|
String periodType = ""; |
|
|
|
if (type.equals("2")) { |
|
|
|
periodType = "4"; |
|
|
|
} |
|
|
|
if (type.equals("1")) { |
|
|
|
periodType = "3"; |
|
|
|
} |
|
|
|
if (type.equals("0")) { |
|
|
|
periodType = "1"; |
|
|
|
} |
|
|
|
Map<String, List<DcTollStationStatisticsDataMap>> map = new HashMap<>(); |
|
|
|
//入口
|
|
|
|
List<DcTollStationStatisticsDataMap> entrance = dcTollStationStatisticsDataService.TollBoothStatisticsList(startDate, "1",periodType); |
|
|
|
//出口
|
|
|
|
List<DcTollStationStatisticsDataMap> exit = dcTollStationStatisticsDataService.TollBoothStatisticsList(startDate, "2",periodType); |
|
|
|
map.put("entrance", entrance); |
|
|
|
map.put("exit", exit); |
|
|
|
|
|
|
|
return map; |
|
|
|
} |
|
|
|
/** |
|
|
|
* 收费站出入口导出 |
|
|
|
* |
|
|
|
* @param doc |
|
|
|
* @param dcSdhsEventQuery |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public void exporttollGateEntrance(XWPFDocument doc, DcSdhsEventQuery dcSdhsEventQuery) { |
|
|
|
Map<String, List<DcTollStationStatisticsDataMap>> map = TollBoothStatisticsList( dcSdhsEventQuery); |
|
|
|
List<DcTollStationStatisticsDataMap> entrance = map.get("entrance"); |
|
|
|
List<DcTollStationStatisticsDataMap> exit = map.get("exit"); |
|
|
|
int rows = entrance.size(); |
|
|
|
String name = "wordTemplate/tollGateEntrance.docx"; |
|
|
|
|
|
|
|
// 创建表格
|
|
|
|
XWPFTable table = doc.createTable(rows+1, 3); |
|
|
|
CTTblWidth infoTableWidth = table.getCTTbl().addNewTblPr().addNewTblW(); |
|
|
|
infoTableWidth.setType(STTblWidth.DXA); |
|
|
|
infoTableWidth.setW(BigInteger.valueOf(UniversalEnum.NINE_THOUSAND_AND_SEVENTY_TWO.getNumber())); |
|
|
|
|
|
|
|
// 表头
|
|
|
|
setTableFonts(table.getRow(0).getCell(0), "收费站"); |
|
|
|
setTableFonts(table.getRow(0).getCell(1), "入口"); |
|
|
|
setTableFonts(table.getRow(0).getCell(2), "出口"); |
|
|
|
// 填充表格数据
|
|
|
|
for (int i = 0; i < rows ; i++) { |
|
|
|
|
|
|
|
setTableFonts(table.getRow(i + 1).getCell(0), (entrance.get(i).getFacilityName())); |
|
|
|
Integer entranceValue = entrance.get(i).getTrafficVolume(); |
|
|
|
setTableFonts(table.getRow(i + 1).getCell(1), String.valueOf(entranceValue)); |
|
|
|
Integer exitValue = exit.get(i).getTrafficVolume(); |
|
|
|
setTableFonts(table.getRow(i + 1).getCell(2), String.valueOf(exitValue)); |
|
|
|
} |
|
|
|
|
|
|
|
// 图表部分
|
|
|
|
try { |
|
|
|
|
|
|
|
InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream(name); |
|
|
|
|
|
|
|
|
|
|
|
XWPFDocument copiedTemplate = new XWPFDocument(inputStream); |
|
|
|
|
|
|
|
List<XWPFChart> charts = copiedTemplate.getCharts(); |
|
|
|
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()); |
|
|
|
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()); |
|
|
|
if (cell == null) { |
|
|
|
// 通常情况下,getCell 会创建新的单元格,但这里我们显式地检查以防万一
|
|
|
|
cell = row.createCell(UniversalEnum.ONE.getNumber(), CellType.NUMERIC); |
|
|
|
} |
|
|
|
// 设置单元格的值
|
|
|
|
sheet.getRow(i + 1).getCell(1).setCellValue( entrance.get(i).getTrafficVolume()); |
|
|
|
int rowIndexTwo = i + 1 + UniversalEnum.ONE.getNumber(); // 计算行索引
|
|
|
|
Row rowTwo = sheet.getRow(rowIndexTwo); |
|
|
|
if (rowTwo == null) { |
|
|
|
// 如果行不存在,则创建新行
|
|
|
|
rowTwo = sheet.createRow(rowIndexTwo); |
|
|
|
} |
|
|
|
|
|
|
|
// 现在可以安全地访问或创建单元格了
|
|
|
|
Cell cellTwo = row.getCell(UniversalEnum.TWO.getNumber()); |
|
|
|
if (cellTwo == null) { |
|
|
|
// 通常情况下,getCell 会创建新的单元格,但这里我们显式地检查以防万一
|
|
|
|
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()));
|
|
|
|
} |
|
|
|
/* for (int i = 0; i < 24; i++) { |
|
|
|
|
|
|
|
sheet.getRow(i + 1).getCell(0).setCellValue((i) + "点"); |
|
|
|
sheet.getRow(i + 1).getCell(1).setCellValue(currentYearData.get(i)); |
|
|
|
sheet.getRow(i + 1).getCell(2).setCellValue(lastYearData.get(i)); |
|
|
|
}*/ |
|
|
|
for (int i = sheet.getLastRowNum(); i > entrance.size(); i--) { |
|
|
|
sheet.removeRow(sheet.getRow(i)); |
|
|
|
} |
|
|
|
// 更新图表
|
|
|
|
PoiUtil.wordExportChar(chart, "收费站出入口车流量", new String[]{"入口", "出口"}, sheet); |
|
|
|
|
|
|
|
// 合并图表到Word文档
|
|
|
|
mergeChart(chart, doc); |
|
|
|
|
|
|
|
// 关闭模板文档
|
|
|
|
copiedTemplate.close(); |
|
|
|
} catch (Exception e) { |
|
|
|
e.printStackTrace(); |
|
|
|
} |
|
|
|
//换行
|
|
|
|
createLineBreak(doc); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
/** |
|
|
|
* 收门架数据导出 |
|
|
|
* |
|
|
|
* @param doc |
|
|
|
* @param dcSdhsEventQuery |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public void exporFrameDataAnalysis(XWPFDocument doc, DcSdhsEventQuery dcSdhsEventQuery) { |
|
|
|
Map<String, List<TrafficFlowStatisticsMap>> map = trafficFlowStatistics( dcSdhsEventQuery); |
|
|
|
List<TrafficFlowStatisticsMap>entrance = map.get("hezeDirection"); |
|
|
|
List<TrafficFlowStatisticsMap> exit = map.get("jinanDirection"); |
|
|
|
int rows = entrance.size(); |
|
|
|
String name = "wordTemplate/frameDataAnalysis.docx"; |
|
|
|
|
|
|
|
// 创建表格
|
|
|
|
XWPFTable table = doc.createTable(rows+1, 3); |
|
|
|
CTTblWidth infoTableWidth = table.getCTTbl().addNewTblPr().addNewTblW(); |
|
|
|
infoTableWidth.setType(STTblWidth.DXA); |
|
|
|
infoTableWidth.setW(BigInteger.valueOf(UniversalEnum.NINE_THOUSAND_AND_SEVENTY_TWO.getNumber())); |
|
|
|
|
|
|
|
// 表头
|
|
|
|
setTableFonts(table.getRow(0).getCell(0), "门架"); |
|
|
|
setTableFonts(table.getRow(0).getCell(1), "菏泽方向"); |
|
|
|
setTableFonts(table.getRow(0).getCell(2), "济南方向"); |
|
|
|
// 填充表格数据
|
|
|
|
for (int i = 0; i < rows ; i++) { |
|
|
|
|
|
|
|
setTableFonts(table.getRow(i + 1).getCell(0), (entrance.get(i).getFacilityName())); |
|
|
|
Long entranceValue = entrance.get(i).getTrafficVolume()!=null ?entrance.get(i).getTrafficVolume() : 0; |
|
|
|
|
|
|
|
setTableFonts(table.getRow(i + 1).getCell(1), String.valueOf(entranceValue)); |
|
|
|
Long exitValue = exit.get(i).getTrafficVolume()!=null ?exit.get(i).getTrafficVolume() : 0; |
|
|
|
setTableFonts(table.getRow(i + 1).getCell(2), String.valueOf(exitValue)); |
|
|
|
} |
|
|
|
|
|
|
|
// 图表部分
|
|
|
|
try { |
|
|
|
|
|
|
|
InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream(name); |
|
|
|
|
|
|
|
|
|
|
|
XWPFDocument copiedTemplate = new XWPFDocument(inputStream); |
|
|
|
|
|
|
|
List<XWPFChart> charts = copiedTemplate.getCharts(); |
|
|
|
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()); |
|
|
|
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()); |
|
|
|
if (cell == null) { |
|
|
|
// 通常情况下,getCell 会创建新的单元格,但这里我们显式地检查以防万一
|
|
|
|
cell = row.createCell(UniversalEnum.ONE.getNumber(), CellType.NUMERIC); |
|
|
|
} |
|
|
|
// 设置单元格的值
|
|
|
|
sheet.getRow(i + 1).getCell(1).setCellValue( entrance.get(i).getTrafficVolume()!=null ?entrance.get(i).getTrafficVolume() : 0); |
|
|
|
int rowIndexTwo = i + 1 + UniversalEnum.ONE.getNumber(); // 计算行索引
|
|
|
|
Row rowTwo = sheet.getRow(rowIndexTwo); |
|
|
|
if (rowTwo == null) { |
|
|
|
// 如果行不存在,则创建新行
|
|
|
|
rowTwo = sheet.createRow(rowIndexTwo); |
|
|
|
} |
|
|
|
|
|
|
|
// 现在可以安全地访问或创建单元格了
|
|
|
|
Cell cellTwo = row.getCell(UniversalEnum.TWO.getNumber()); |
|
|
|
if (cellTwo == null) { |
|
|
|
// 通常情况下,getCell 会创建新的单元格,但这里我们显式地检查以防万一
|
|
|
|
cell = row.createCell(UniversalEnum.TWO.getNumber(), CellType.NUMERIC); |
|
|
|
} |
|
|
|
sheet.getRow(i + 1).getCell(2).setCellValue(exit.get(i).getTrafficVolume()!=null ?exit.get(i).getTrafficVolume() : 0); |
|
|
|
//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++) { |
|
|
|
|
|
|
|
sheet.getRow(i + 1).getCell(0).setCellValue((i) + "点"); |
|
|
|
sheet.getRow(i + 1).getCell(1).setCellValue(currentYearData.get(i)); |
|
|
|
sheet.getRow(i + 1).getCell(2).setCellValue(lastYearData.get(i)); |
|
|
|
}*/ |
|
|
|
for (int i = sheet.getLastRowNum(); i > entrance.size(); i--) { |
|
|
|
sheet.removeRow(sheet.getRow(i)); |
|
|
|
} |
|
|
|
// 更新图表
|
|
|
|
PoiUtil.wordExportChar(chart, "门架车流量", new String[]{"菏泽", "济南"}, sheet); |
|
|
|
|
|
|
|
// 合并图表到Word文档
|
|
|
|
mergeChart(chart, doc); |
|
|
|
|
|
|
|
// 关闭模板文档
|
|
|
|
copiedTemplate.close(); |
|
|
|
} catch (Exception e) { |
|
|
|
e.printStackTrace(); |
|
|
|
} |
|
|
|
//换行
|
|
|
|
createLineBreak(doc); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 门架数据分析 |
|
|
|
* @param dcSdhsEventQuery |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public Map<String, List<TrafficFlowStatisticsMap>> trafficFlowStatistics(DcSdhsEventQuery dcSdhsEventQuery) { |
|
|
|
Date startTime = dcSdhsEventQuery.getStartTime(); |
|
|
|
LocalDateTime localDateTime = startTime.toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime(); |
|
|
|
// 定义日期时间格式
|
|
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); |
|
|
|
// 将 LocalDateTime 转换为字符串
|
|
|
|
String startDate = localDateTime.format(formatter); |
|
|
|
String type = dcSdhsEventQuery.getType(); |
|
|
|
String periodType = ""; |
|
|
|
if (type.equals("2")) { |
|
|
|
periodType = "4"; |
|
|
|
} |
|
|
|
if (type.equals("1")) { |
|
|
|
periodType = "3"; |
|
|
|
} |
|
|
|
if (type.equals("0")) { |
|
|
|
periodType = "1"; |
|
|
|
} |
|
|
|
//菏泽方向
|
|
|
|
List<TrafficFlowStatisticsMap> hezeDirection = dcGantryStatisticsDataService.trafficFlowStatisticsAsc(startDate,startDate,"1",periodType); |
|
|
|
//济南方向
|
|
|
|
List<TrafficFlowStatisticsMap> jinanDirection = dcGantryStatisticsDataService.trafficFlowStatisticsAsc(startDate,startDate,"3",periodType); |
|
|
|
Map<String, List<TrafficFlowStatisticsMap>> map = new HashMap<>(); |
|
|
|
map.put("hezeDirection",hezeDirection); |
|
|
|
map.put("jinanDirection",jinanDirection); |
|
|
|
|
|
|
|
return map; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|