Browse Source

Merge remote-tracking branch 'origin/develop' into develop

develop
王兴琳 6 months ago
parent
commit
68988657ca
  1. 100
      zc-business/src/main/java/com/zc/business/controller/WordController.java
  2. 2
      zc-business/src/main/java/com/zc/business/domain/DcRegion.java

100
zc-business/src/main/java/com/zc/business/controller/WordController.java

@ -2,6 +2,7 @@ package com.zc.business.controller;
import com.ruoyi.common.config.RuoYiConfig;
import com.ruoyi.common.core.domain.AjaxResult;
import com.zc.business.domain.DcTrafficSectionData;
import com.zc.business.mapper.DcTrafficIncidentsMapper;
import com.zc.business.utils.PoiUtil;
import io.swagger.annotations.Api;
@ -19,9 +20,12 @@ import javax.servlet.http.HttpServletResponse;
import java.io.InputStream;
import java.math.BigInteger;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.OffsetDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.stream.Collectors;
import static com.zc.business.utils.PoiUtil.*;
@ -128,68 +132,102 @@ public class WordController {
PoiUtil.createHeading2(doc,"天气情况统计");
AjaxResult ajaxResult = weatherForecastController.hourlyWeather();
// AjaxResult ajaxResult = weatherForecastController.hourlyWeather();
HashMap<String,Object> params = new HashMap<>();
params.put("roadId","G003537");
params.put("stakeNum","K60+000|K105+000|K145+000|K165+000|K175+000|K190+000|K200+000|K205+000");
params.put("forecastHour","24");
AjaxResult ajaxResult = weatherForecastController.currentWeatherAndForecastInformation(params);
if (ajaxResult.get("code").equals(200)) {
Map<String,List<Map<String,Object>>> data = (Map<String, List<Map<String,Object>>>) ajaxResult.get("data");
List<Map<String,Object>> data = (List<Map<String,Object>>) ajaxResult.get("data");
if (data != null && data.size() != 0){
XWPFTable table = doc.createTable(9, 25);
XWPFTable table = doc.createTable(9, 10);
//列宽自动分割
CTTblWidth infoTableWidth = table.getCTTbl().addNewTblPr().addNewTblW();
infoTableWidth.setType(STTblWidth.DXA);
infoTableWidth.setW(BigInteger.valueOf(9072));
data.keySet().forEach(key ->{
if ("hourlyWeather1".equals(key)){
DateTimeFormatter parseFormatter = DateTimeFormatter.ISO_LOCAL_DATE_TIME;
data.forEach(dataItem ->{
if ("K60+000".equals(dataItem.get("stakeNum"))){
setTableFonts(table.getRow(1).getCell(0), "长清区");
List<Map<String,Object>> weatherList = data.get(key);
List<Map<String,Object>> weatherList = (List<Map<String,Object>>) dataItem.get("forecastList");
weatherList = weatherList.stream()
.sorted(Comparator.comparing(map -> LocalDateTime.parse(map.get("weatherTime").toString(), parseFormatter)))
.collect(Collectors.toList());
for (int i = 0; i < weatherList.size(); i++) {
OffsetDateTime offsetDateTime = OffsetDateTime.parse(weatherList.get(i).get("fxTime").toString());
setTableFonts(table.getRow(0).getCell(i+1),offsetDateTime.format(DateTimeFormatter.ofPattern("dd日HH时")));
setTableFonts(table.getRow(1).getCell(i+1), weatherList.get(i).get("text").toString());
//第一行 格式化时间
LocalDateTime localDateTime = LocalDateTime.parse(weatherList.get(i).get("weatherTime").toString(), parseFormatter);
DateTimeFormatter formatFormatter = DateTimeFormatter.ofPattern("dd日HH时");
setTableFonts(table.getRow(0).getCell(i+1),localDateTime.format(formatFormatter));
setTableFonts(table.getRow(1).getCell(i+1), weatherList.get(i).get("weatherDescription").toString());
}
} else if ("hourlyWeather2".equals(key)){
} else if ("K105+000".equals(dataItem.get("stakeNum"))){
setTableFonts(table.getRow(2).getCell(0), "平阴县");
List<Map<String,Object>> weatherList = data.get(key);
List<Map<String,Object>> weatherList = (List<Map<String,Object>>) dataItem.get("forecastList");
weatherList = weatherList.stream()
.sorted(Comparator.comparing(map -> LocalDateTime.parse(map.get("weatherTime").toString(), parseFormatter)))
.collect(Collectors.toList());
for (int i = 0; i < weatherList.size(); i++) {
setTableFonts(table.getRow(2).getCell(i+1), weatherList.get(i).get("text").toString());
setTableFonts(table.getRow(2).getCell(i+1), weatherList.get(i).get("weatherDescription").toString());
}
} else if ("hourlyWeather3".equals(key)){
} else if ("K145+000".equals(dataItem.get("stakeNum"))){
setTableFonts(table.getRow(3).getCell(0), "东平县");
List<Map<String,Object>> weatherList = data.get(key);
List<Map<String,Object>> weatherList = (List<Map<String,Object>>) dataItem.get("forecastList");
weatherList = weatherList.stream()
.sorted(Comparator.comparing(map -> LocalDateTime.parse(map.get("weatherTime").toString(), parseFormatter)))
.collect(Collectors.toList());
for (int i = 0; i < weatherList.size(); i++) {
setTableFonts(table.getRow(3).getCell(i+1), weatherList.get(i).get("text").toString());
setTableFonts(table.getRow(3).getCell(i+1), weatherList.get(i).get("weatherDescription").toString());
}
} else if ("hourlyWeather4".equals(key)){
} else if ("K165+000".equals(dataItem.get("stakeNum"))){
setTableFonts(table.getRow(4).getCell(0), "汶上县");
List<Map<String,Object>> weatherList = data.get(key);
List<Map<String,Object>> weatherList = (List<Map<String,Object>>) dataItem.get("forecastList");
weatherList = weatherList.stream()
.sorted(Comparator.comparing(map -> LocalDateTime.parse(map.get("weatherTime").toString(), parseFormatter)))
.collect(Collectors.toList());
for (int i = 0; i < weatherList.size(); i++) {
setTableFonts(table.getRow(4).getCell(i+1), weatherList.get(i).get("text").toString());
setTableFonts(table.getRow(4).getCell(i+1), weatherList.get(i).get("weatherDescription").toString());
}
} else if ("hourlyWeather5".equals(key)){
} else if ("K175+000".equals(dataItem.get("stakeNum"))){
setTableFonts(table.getRow(5).getCell(0), "梁山县");
List<Map<String,Object>> weatherList = data.get(key);
List<Map<String,Object>> weatherList = (List<Map<String,Object>>) dataItem.get("forecastList");
weatherList = weatherList.stream()
.sorted(Comparator.comparing(map -> LocalDateTime.parse(map.get("weatherTime").toString(), parseFormatter)))
.collect(Collectors.toList());
for (int i = 0; i < weatherList.size(); i++) {
setTableFonts(table.getRow(5).getCell(i+1), weatherList.get(i).get("text").toString());
setTableFonts(table.getRow(5).getCell(i+1), weatherList.get(i).get("weatherDescription").toString());
}
} else if ("hourlyWeather6".equals(key)){
} else if ("K190+000".equals(dataItem.get("stakeNum"))){
setTableFonts(table.getRow(6).getCell(0), "嘉祥县");
List<Map<String,Object>> weatherList = data.get(key);
List<Map<String,Object>> weatherList = (List<Map<String,Object>>) dataItem.get("forecastList");
weatherList = weatherList.stream()
.sorted(Comparator.comparing(map -> LocalDateTime.parse(map.get("weatherTime").toString(), parseFormatter)))
.collect(Collectors.toList());
for (int i = 0; i < weatherList.size(); i++) {
setTableFonts(table.getRow(6).getCell(i+1), weatherList.get(i).get("text").toString());
setTableFonts(table.getRow(6).getCell(i+1), weatherList.get(i).get("weatherDescription").toString());
}
} else if ("hourlyWeather7".equals(key)){
} else if ("K200+000".equals(dataItem.get("stakeNum"))){
setTableFonts(table.getRow(7).getCell(0), "巨野县");
List<Map<String,Object>> weatherList = data.get(key);
List<Map<String,Object>> weatherList = (List<Map<String,Object>>) dataItem.get("forecastList");
weatherList = weatherList.stream()
.sorted(Comparator.comparing(map -> LocalDateTime.parse(map.get("weatherTime").toString(), parseFormatter)))
.collect(Collectors.toList());
for (int i = 0; i < weatherList.size(); i++) {
setTableFonts(table.getRow(7).getCell(i+1), weatherList.get(i).get("text").toString());
setTableFonts(table.getRow(7).getCell(i+1), weatherList.get(i).get("weatherDescription").toString());
}
} else if ("hourlyWeather8".equals(key)){
} else if ("K205+000".equals(dataItem.get("stakeNum"))){
setTableFonts(table.getRow(8).getCell(0), "郓城县");
List<Map<String,Object>> weatherList = data.get(key);
List<Map<String,Object>> weatherList = (List<Map<String,Object>>) dataItem.get("forecastList");
weatherList = weatherList.stream()
.sorted(Comparator.comparing(map -> LocalDateTime.parse(map.get("weatherTime").toString(), parseFormatter)))
.collect(Collectors.toList());
for (int i = 0; i < weatherList.size(); i++) {
setTableFonts(table.getRow(8).getCell(i+1), weatherList.get(i).get("text").toString());
setTableFonts(table.getRow(8).getCell(i+1), weatherList.get(i).get("weatherDescription").toString());
}
}
});
@ -197,6 +235,8 @@ public class WordController {
addDescription(doc,"暂无数据");
}
} else {
addDescription(doc,"暂无数据");
}
//换行

2
zc-business/src/main/java/com/zc/business/domain/DcRegion.java

@ -18,4 +18,6 @@ public class DcRegion {
private String longitude;
@ApiModelProperty("纬度")
private String latitude;
@ApiModelProperty("桩号")
private String stakeNum;
}

Loading…
Cancel
Save