From d118ffb1b2d14cb1c6c7751a5d53aacabce0ea50 Mon Sep 17 00:00:00 2001 From: lau572 <1010031226@qq.com> Date: Mon, 3 Jun 2024 19:44:58 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E9=80=9A=E8=A1=8C=E5=BF=AB=E6=8A=A5=20?= =?UTF-8?q?=E5=A4=A9=E6=B0=94=E6=83=85=E5=86=B5=E6=8E=A5=E5=8F=A3=E6=9B=B4?= =?UTF-8?q?=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../business/controller/WordController.java | 100 ++++++++++++------ 1 file changed, 70 insertions(+), 30 deletions(-) diff --git a/zc-business/src/main/java/com/zc/business/controller/WordController.java b/zc-business/src/main/java/com/zc/business/controller/WordController.java index 775ff31f..76929ef0 100644 --- a/zc-business/src/main/java/com/zc/business/controller/WordController.java +++ b/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 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>> data = (Map>>) ajaxResult.get("data"); + List> data = (List>) 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> weatherList = data.get(key); + List> weatherList = (List>) 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> weatherList = data.get(key); + List> weatherList = (List>) 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> weatherList = data.get(key); + List> weatherList = (List>) 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> weatherList = data.get(key); + List> weatherList = (List>) 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> weatherList = data.get(key); + List> weatherList = (List>) 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> weatherList = data.get(key); + List> weatherList = (List>) 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> weatherList = data.get(key); + List> weatherList = (List>) 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> weatherList = data.get(key); + List> weatherList = (List>) 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,"暂无数据"); } //换行 From e6f270ac639f13866b0b03d79d6392d10bef9087 Mon Sep 17 00:00:00 2001 From: zhaoxianglong Date: Tue, 4 Jun 2024 15:41:12 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=9C=B0=E5=8C=BA?= =?UTF-8?q?=E8=A1=A8=E6=9F=A5=E8=AF=A2=E8=BF=94=E5=9B=9E=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- zc-business/src/main/java/com/zc/business/domain/DcRegion.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/zc-business/src/main/java/com/zc/business/domain/DcRegion.java b/zc-business/src/main/java/com/zc/business/domain/DcRegion.java index f15246e6..5cc48e2b 100644 --- a/zc-business/src/main/java/com/zc/business/domain/DcRegion.java +++ b/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; }