From ef4539ff08efd924ab7d545d39d24ce58befe923 Mon Sep 17 00:00:00 2001 From: lau572 <1010031226@qq.com> Date: Fri, 30 Aug 2024 11:39:59 +0800 Subject: [PATCH] =?UTF-8?q?=E9=AB=98=E9=80=9F=E8=BF=90=E8=A1=8C=E5=BF=AB?= =?UTF-8?q?=E6=8A=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../business/controller/WordController.java | 120 +++++++----------- 1 file changed, 48 insertions(+), 72 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 d9168051..406bc3d4 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 @@ -171,81 +171,57 @@ public class WordController { DateTimeFormatter parseFormatter = DateTimeFormatter.ISO_LOCAL_DATE_TIME; data.forEach(dataItem ->{ - if (UniversalEnum.STAKE_NUM_K60.getValue().equals(dataItem.get("stakeNum"))){ - setTableFonts(table.getRow(UniversalEnum.ONE.getNumber()).getCell(UniversalEnum.ZERO.getNumber()), UniversalEnum.CHANG_QING_DISTRICT.getValue()); - List> weatherList = (List>) dataItem.get("forecastList"); + List> weatherList = (List>) dataItem.get("forecastList"); + if (weatherList != null && weatherList.size() > 0){ weatherList = weatherList.stream() .sorted(Comparator.comparing(map -> LocalDateTime.parse(map.get("weatherTime").toString(), parseFormatter))) .collect(Collectors.toList()); - for (int i = UniversalEnum.ZERO.getNumber(); i < weatherList.size(); i++) { - //第一行 格式化时间 - LocalDateTime localDateTime = LocalDateTime.parse(weatherList.get(i).get("weatherTime").toString(), parseFormatter); - DateTimeFormatter formatFormatter = DateTimeFormatter.ofPattern("dd日HH时"); - setTableFonts(table.getRow(UniversalEnum.ZERO.getNumber()).getCell(i+UniversalEnum.ONE.getNumber()),localDateTime.format(formatFormatter)); - setTableFonts(table.getRow(UniversalEnum.ONE.getNumber()).getCell(i+UniversalEnum.ONE.getNumber()), weatherList.get(i).get("weatherDescription").toString()); - } - } else if (UniversalEnum.STAKE_NUM_K105.getValue().equals(dataItem.get("stakeNum"))){ - setTableFonts(table.getRow(UniversalEnum.TWO.getNumber()).getCell(UniversalEnum.ZERO.getNumber()), UniversalEnum.PING_YIN_COUNTY.getValue()); - 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 = UniversalEnum.ZERO.getNumber(); i < weatherList.size(); i++) { - setTableFonts(table.getRow(UniversalEnum.TWO.getNumber()).getCell(i+UniversalEnum.ONE.getNumber()), weatherList.get(i).get("weatherDescription").toString()); - } - } else if (UniversalEnum.STAKE_NUM_K145.getValue().equals(dataItem.get("stakeNum"))){ - setTableFonts(table.getRow(UniversalEnum.THREE.getNumber()).getCell(UniversalEnum.ZERO.getNumber()), UniversalEnum.DONG_PING_COUNTY.getValue()); - 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 = UniversalEnum.ZERO.getNumber(); i < weatherList.size(); i++) { - setTableFonts(table.getRow(UniversalEnum.THREE.getNumber()).getCell(i+UniversalEnum.ONE.getNumber()), weatherList.get(i).get("weatherDescription").toString()); - } - } else if (UniversalEnum.STAKE_NUM_K165.getValue().equals(dataItem.get("stakeNum"))){ - setTableFonts(table.getRow(UniversalEnum.FOUR.getNumber()).getCell(UniversalEnum.ZERO.getNumber()), UniversalEnum.WEN_SHANG_COUNTY.getValue()); - 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 = UniversalEnum.ZERO.getNumber(); i < weatherList.size(); i++) { - setTableFonts(table.getRow(UniversalEnum.FOUR.getNumber()).getCell(i+UniversalEnum.ONE.getNumber()), weatherList.get(i).get("weatherDescription").toString()); - } - } else if (UniversalEnum.STAKE_NUM_K175.getValue().equals(dataItem.get("stakeNum"))){ - setTableFonts(table.getRow(UniversalEnum.FIVE.getNumber()).getCell(UniversalEnum.ZERO.getNumber()), UniversalEnum.LIANG_SHAN_COUNTY.getValue()); - 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 = UniversalEnum.ZERO.getNumber(); i < weatherList.size(); i++) { - setTableFonts(table.getRow(UniversalEnum.FIVE.getNumber()).getCell(i+UniversalEnum.ONE.getNumber()), weatherList.get(i).get("weatherDescription").toString()); - } - } else if (UniversalEnum.STAKE_NUM_K190.getValue().equals(dataItem.get("stakeNum"))){ - setTableFonts(table.getRow(UniversalEnum.SIX.getNumber()).getCell(UniversalEnum.ZERO.getNumber()), UniversalEnum.JIA_XIANG_COUNTY.getValue()); - 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 = UniversalEnum.ZERO.getNumber(); i < weatherList.size(); i++) { - setTableFonts(table.getRow(UniversalEnum.SIX.getNumber()).getCell(i+UniversalEnum.ONE.getNumber()), weatherList.get(i).get("weatherDescription").toString()); - } - } else if (UniversalEnum.STAKE_NUM_K200.getValue().equals(dataItem.get("stakeNum"))){ - setTableFonts(table.getRow(UniversalEnum.SEVEN.getNumber()).getCell(UniversalEnum.ZERO.getNumber()), UniversalEnum.JUYE_COUNTY.getValue()); - 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 = UniversalEnum.ZERO.getNumber(); i < weatherList.size(); i++) { - setTableFonts(table.getRow(UniversalEnum.SEVEN.getNumber()).getCell(i+UniversalEnum.ONE.getNumber()), weatherList.get(i).get("weatherDescription").toString()); - } - } else if (UniversalEnum.STAKE_NUM_K205.getValue().equals(dataItem.get("stakeNum"))){ - setTableFonts(table.getRow(UniversalEnum.EIGHT.getNumber()).getCell(UniversalEnum.ZERO.getNumber()), UniversalEnum.YUN_CHENG_COUNTY.getValue()); - 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 = UniversalEnum.ZERO.getNumber(); i < weatherList.size(); i++) { - setTableFonts(table.getRow(UniversalEnum.EIGHT.getNumber()).getCell(i+UniversalEnum.ONE.getNumber()), weatherList.get(i).get("weatherDescription").toString()); + + if (UniversalEnum.STAKE_NUM_K60.getValue().equals(dataItem.get("stakeNum"))){ + setTableFonts(table.getRow(UniversalEnum.ONE.getNumber()).getCell(UniversalEnum.ZERO.getNumber()), UniversalEnum.CHANG_QING_DISTRICT.getValue()); + + for (int i = UniversalEnum.ZERO.getNumber(); i < weatherList.size(); i++) { + //第一行 格式化时间 + LocalDateTime localDateTime = LocalDateTime.parse(weatherList.get(i).get("weatherTime").toString(), parseFormatter); + DateTimeFormatter formatFormatter = DateTimeFormatter.ofPattern("dd日HH时"); + setTableFonts(table.getRow(UniversalEnum.ZERO.getNumber()).getCell(i+UniversalEnum.ONE.getNumber()),localDateTime.format(formatFormatter)); + setTableFonts(table.getRow(UniversalEnum.ONE.getNumber()).getCell(i+UniversalEnum.ONE.getNumber()), weatherList.get(i).get("weatherDescription").toString()); + } + } else if (UniversalEnum.STAKE_NUM_K105.getValue().equals(dataItem.get("stakeNum"))){ + setTableFonts(table.getRow(UniversalEnum.TWO.getNumber()).getCell(UniversalEnum.ZERO.getNumber()), UniversalEnum.PING_YIN_COUNTY.getValue()); + for (int i = UniversalEnum.ZERO.getNumber(); i < weatherList.size(); i++) { + setTableFonts(table.getRow(UniversalEnum.TWO.getNumber()).getCell(i+UniversalEnum.ONE.getNumber()), weatherList.get(i).get("weatherDescription").toString()); + } + } else if (UniversalEnum.STAKE_NUM_K145.getValue().equals(dataItem.get("stakeNum"))){ + setTableFonts(table.getRow(UniversalEnum.THREE.getNumber()).getCell(UniversalEnum.ZERO.getNumber()), UniversalEnum.DONG_PING_COUNTY.getValue()); + for (int i = UniversalEnum.ZERO.getNumber(); i < weatherList.size(); i++) { + setTableFonts(table.getRow(UniversalEnum.THREE.getNumber()).getCell(i+UniversalEnum.ONE.getNumber()), weatherList.get(i).get("weatherDescription").toString()); + } + } else if (UniversalEnum.STAKE_NUM_K165.getValue().equals(dataItem.get("stakeNum"))){ + setTableFonts(table.getRow(UniversalEnum.FOUR.getNumber()).getCell(UniversalEnum.ZERO.getNumber()), UniversalEnum.WEN_SHANG_COUNTY.getValue()); + for (int i = UniversalEnum.ZERO.getNumber(); i < weatherList.size(); i++) { + setTableFonts(table.getRow(UniversalEnum.FOUR.getNumber()).getCell(i+UniversalEnum.ONE.getNumber()), weatherList.get(i).get("weatherDescription").toString()); + } + } else if (UniversalEnum.STAKE_NUM_K175.getValue().equals(dataItem.get("stakeNum"))){ + setTableFonts(table.getRow(UniversalEnum.FIVE.getNumber()).getCell(UniversalEnum.ZERO.getNumber()), UniversalEnum.LIANG_SHAN_COUNTY.getValue()); + for (int i = UniversalEnum.ZERO.getNumber(); i < weatherList.size(); i++) { + setTableFonts(table.getRow(UniversalEnum.FIVE.getNumber()).getCell(i+UniversalEnum.ONE.getNumber()), weatherList.get(i).get("weatherDescription").toString()); + } + } else if (UniversalEnum.STAKE_NUM_K190.getValue().equals(dataItem.get("stakeNum"))){ + setTableFonts(table.getRow(UniversalEnum.SIX.getNumber()).getCell(UniversalEnum.ZERO.getNumber()), UniversalEnum.JIA_XIANG_COUNTY.getValue()); + for (int i = UniversalEnum.ZERO.getNumber(); i < weatherList.size(); i++) { + setTableFonts(table.getRow(UniversalEnum.SIX.getNumber()).getCell(i+UniversalEnum.ONE.getNumber()), weatherList.get(i).get("weatherDescription").toString()); + } + } else if (UniversalEnum.STAKE_NUM_K200.getValue().equals(dataItem.get("stakeNum"))){ + setTableFonts(table.getRow(UniversalEnum.SEVEN.getNumber()).getCell(UniversalEnum.ZERO.getNumber()), UniversalEnum.JUYE_COUNTY.getValue()); + for (int i = UniversalEnum.ZERO.getNumber(); i < weatherList.size(); i++) { + setTableFonts(table.getRow(UniversalEnum.SEVEN.getNumber()).getCell(i+UniversalEnum.ONE.getNumber()), weatherList.get(i).get("weatherDescription").toString()); + } + } else if (UniversalEnum.STAKE_NUM_K205.getValue().equals(dataItem.get("stakeNum"))){ + setTableFonts(table.getRow(UniversalEnum.EIGHT.getNumber()).getCell(UniversalEnum.ZERO.getNumber()), UniversalEnum.YUN_CHENG_COUNTY.getValue()); + for (int i = UniversalEnum.ZERO.getNumber(); i < weatherList.size(); i++) { + setTableFonts(table.getRow(UniversalEnum.EIGHT.getNumber()).getCell(i+UniversalEnum.ONE.getNumber()), weatherList.get(i).get("weatherDescription").toString()); + } } } });