From 49c46efece53226dc28862a3b1d2cee9b070ea49 Mon Sep 17 00:00:00 2001 From: lau572 <1010031226@qq.com> Date: Fri, 21 Jun 2024 15:07:32 +0800 Subject: [PATCH] =?UTF-8?q?=E9=9B=B7=E8=BE=BE=E5=9B=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../business/controller/DcNmcController.java | 94 ++++++++++++++++++- .../business/controller/WordController.java | 4 +- 2 files changed, 94 insertions(+), 4 deletions(-) diff --git a/zc-business/src/main/java/com/zc/business/controller/DcNmcController.java b/zc-business/src/main/java/com/zc/business/controller/DcNmcController.java index 6cc66ee1..d5790dfa 100644 --- a/zc-business/src/main/java/com/zc/business/controller/DcNmcController.java +++ b/zc-business/src/main/java/com/zc/business/controller/DcNmcController.java @@ -1,8 +1,10 @@ package com.zc.business.controller; +import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.utils.StringUtils; import com.zc.common.core.httpclient.OkHttp; import com.zc.common.core.httpclient.exception.HttpException; import io.swagger.annotations.Api; @@ -12,9 +14,16 @@ import org.jsoup.Jsoup; import org.jsoup.nodes.Document; import org.jsoup.nodes.Element; import org.jsoup.select.Elements; -import org.springframework.web.bind.annotation.*; +import org.junit.Test; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; import java.io.IOException; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.*; +import java.util.stream.Collectors; /** * 全国气象数据 @@ -93,5 +102,88 @@ public class DcNmcController { } + /** + * 雷达图 + */ + @Test + @ApiOperation("雷达图") + @GetMapping("/radarMap") + public AjaxResult radarMap() throws HttpException, IOException, ParseException { + + List> result = new ArrayList<>(); + + Date now = new Date(); + String url = "http://d1.weather.com.cn/newwebgis/radar/radar_list_new.json?_=" + now.getTime(); + + Map headers = new HashMap<>(); + headers.put("Referer", "http://www.weather.com.cn/"); + + OkHttp okHttp = new OkHttp(); + Response response // 请求响应 + = okHttp.headers(headers) + .url(url) // 请求地址 + .get(); // 请求方法 + String body = response.body().string(); + if (StringUtils.isNotEmpty(body)){ + /*var fc40 = { + "stime":"2024-06-21 13:50", + "value":[ + { + "date":["2024062115"], + "path":[ + "5m/QPFRef_202406211540.png", + "5m/QPFRef_202406211530.png", + "5m/QPFRef_202406211520.png", + "5m/QPFRef_202406211510.png", + "5m/QPFRef_202406211500.png" + ], + "time":["1540","1530","1520","1510","1500"] + }, + { + "date":["2024062114"], + "path":[ + "5m/QPFRef_202406211450.png", + "5m/QPFRef_202406211440.png", + "5m/QPFRef_202406211430.png", + "5m/QPFRef_202406211420.png", + "5m/QPFRef_202406211410.png", + "5m/QPFRef_202406211400.png"], + "time":["1450","1440","1430","1420","1410","1400"] + }, + ... + ... + ]}*/ + SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + + + body = body.substring(11); + JSONObject jsonObject = JSON.parseObject(body); + List> list = (List>) jsonObject.get("value"); + for (Map map : list) { + List dateList = (List) map.get("date"); + String date = dateList.get(0).substring(0, dateList.get(0).length() - 2); + + List pathList = (List) map.get("path"); + List timeList = (List) map.get("time"); + for (int i = 0; i < timeList.size(); i++) { + String[] timeArr = {timeList.get(i).substring(0,2),timeList.get(i).substring(2)}; + + Map item = new HashMap<>(); + item.put("time",date + " " + timeArr[0] + ":" + timeArr[1] + ":00"); + item.put("path","https://10.0.111.11/leidatu/" + pathList.get(i)); + result.add(item); + + } + } + } + + result = result.stream() + .sorted(Comparator.comparing(map -> map.get("time").toString())) + .collect(Collectors.toList()); + return AjaxResult.success(result); + } + + + } 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 5a24c460..4858ecff 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 @@ -287,7 +287,7 @@ public class WordController { List> tollStationAnalysisList = dcTrafficIncidentsMapper.selectTollStationAnalysisByFacility(null,startDate,endDate); if (tollStationAnalysisList != null && tollStationAnalysisList.size() > 0) { - XWPFTable table = doc.createTable(11, 4); + XWPFTable table = doc.createTable(11, 3); //列宽自动分割 CTTblWidth infoTableWidth = table.getCTTbl().addNewTblPr().addNewTblW(); infoTableWidth.setType(STTblWidth.DXA); @@ -295,14 +295,12 @@ public class WordController { setTableFonts(table.getRow(0).getCell(1), "封闭"); setTableFonts(table.getRow(0).getCell(2), "限行"); - setTableFonts(table.getRow(0).getCell(3), "间隔放行"); //excel for (int i = 0; i < tollStationAnalysisList.size(); i++){ setTableFonts(table.getRow(i+1).getCell(0), tollStationAnalysisList.get(i).get("facilityName").toString()); setTableFonts(table.getRow(i+1).getCell(1), tollStationAnalysisList.get(i).get("facilityClose").toString()); setTableFonts(table.getRow(i+1).getCell(2), tollStationAnalysisList.get(i).get("facilityRestriction").toString()); - setTableFonts(table.getRow(i+1).getCell(3), tollStationAnalysisList.get(i).get("facilityInterval").toString()); } try {