|
@ -2,6 +2,7 @@ package com.zc.business.controller; |
|
|
|
|
|
|
|
|
import com.ruoyi.common.config.RuoYiConfig; |
|
|
import com.ruoyi.common.config.RuoYiConfig; |
|
|
import com.ruoyi.common.core.domain.AjaxResult; |
|
|
import com.ruoyi.common.core.domain.AjaxResult; |
|
|
|
|
|
import com.zc.business.domain.DcTrafficSectionData; |
|
|
import com.zc.business.mapper.DcTrafficIncidentsMapper; |
|
|
import com.zc.business.mapper.DcTrafficIncidentsMapper; |
|
|
import com.zc.business.utils.PoiUtil; |
|
|
import com.zc.business.utils.PoiUtil; |
|
|
import io.swagger.annotations.Api; |
|
|
import io.swagger.annotations.Api; |
|
@ -19,9 +20,12 @@ import javax.servlet.http.HttpServletResponse; |
|
|
import java.io.InputStream; |
|
|
import java.io.InputStream; |
|
|
import java.math.BigInteger; |
|
|
import java.math.BigInteger; |
|
|
import java.text.SimpleDateFormat; |
|
|
import java.text.SimpleDateFormat; |
|
|
|
|
|
import java.time.LocalDate; |
|
|
|
|
|
import java.time.LocalDateTime; |
|
|
import java.time.OffsetDateTime; |
|
|
import java.time.OffsetDateTime; |
|
|
import java.time.format.DateTimeFormatter; |
|
|
import java.time.format.DateTimeFormatter; |
|
|
import java.util.*; |
|
|
import java.util.*; |
|
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
import static com.zc.business.utils.PoiUtil.*; |
|
|
import static com.zc.business.utils.PoiUtil.*; |
|
|
|
|
|
|
|
@ -128,68 +132,102 @@ public class WordController { |
|
|
|
|
|
|
|
|
PoiUtil.createHeading2(doc,"天气情况统计"); |
|
|
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)) { |
|
|
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){ |
|
|
if (data != null && data.size() != 0){ |
|
|
|
|
|
|
|
|
XWPFTable table = doc.createTable(9, 25); |
|
|
XWPFTable table = doc.createTable(9, 10); |
|
|
//列宽自动分割
|
|
|
//列宽自动分割
|
|
|
CTTblWidth infoTableWidth = table.getCTTbl().addNewTblPr().addNewTblW(); |
|
|
CTTblWidth infoTableWidth = table.getCTTbl().addNewTblPr().addNewTblW(); |
|
|
infoTableWidth.setType(STTblWidth.DXA); |
|
|
infoTableWidth.setType(STTblWidth.DXA); |
|
|
infoTableWidth.setW(BigInteger.valueOf(9072)); |
|
|
infoTableWidth.setW(BigInteger.valueOf(9072)); |
|
|
|
|
|
|
|
|
data.keySet().forEach(key ->{ |
|
|
DateTimeFormatter parseFormatter = DateTimeFormatter.ISO_LOCAL_DATE_TIME; |
|
|
if ("hourlyWeather1".equals(key)){ |
|
|
|
|
|
|
|
|
data.forEach(dataItem ->{ |
|
|
|
|
|
if ("K60+000".equals(dataItem.get("stakeNum"))){ |
|
|
setTableFonts(table.getRow(1).getCell(0), "长清区"); |
|
|
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++) { |
|
|
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时"))); |
|
|
LocalDateTime localDateTime = LocalDateTime.parse(weatherList.get(i).get("weatherTime").toString(), parseFormatter); |
|
|
setTableFonts(table.getRow(1).getCell(i+1), weatherList.get(i).get("text").toString()); |
|
|
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), "平阴县"); |
|
|
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++) { |
|
|
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), "东平县"); |
|
|
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++) { |
|
|
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), "汶上县"); |
|
|
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++) { |
|
|
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), "梁山县"); |
|
|
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++) { |
|
|
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), "嘉祥县"); |
|
|
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++) { |
|
|
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), "巨野县"); |
|
|
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++) { |
|
|
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), "郓城县"); |
|
|
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++) { |
|
|
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,"暂无数据"); |
|
|
addDescription(doc,"暂无数据"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
addDescription(doc,"暂无数据"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
//换行
|
|
|
//换行
|
|
|