|
@ -1,8 +1,10 @@ |
|
|
package com.zc.business.controller; |
|
|
package com.zc.business.controller; |
|
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
import com.alibaba.fastjson.JSONArray; |
|
|
import com.alibaba.fastjson.JSONArray; |
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
import com.ruoyi.common.core.domain.AjaxResult; |
|
|
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.OkHttp; |
|
|
import com.zc.common.core.httpclient.exception.HttpException; |
|
|
import com.zc.common.core.httpclient.exception.HttpException; |
|
|
import io.swagger.annotations.Api; |
|
|
import io.swagger.annotations.Api; |
|
@ -12,9 +14,16 @@ import org.jsoup.Jsoup; |
|
|
import org.jsoup.nodes.Document; |
|
|
import org.jsoup.nodes.Document; |
|
|
import org.jsoup.nodes.Element; |
|
|
import org.jsoup.nodes.Element; |
|
|
import org.jsoup.select.Elements; |
|
|
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.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<Map<String,Object>> result = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
|
|
Date now = new Date(); |
|
|
|
|
|
String url = "http://d1.weather.com.cn/newwebgis/radar/radar_list_new.json?_=" + now.getTime(); |
|
|
|
|
|
|
|
|
|
|
|
Map<String, String> 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<Map<String,Object>> list = (List<Map<String, Object>>) jsonObject.get("value"); |
|
|
|
|
|
for (Map<String, Object> map : list) { |
|
|
|
|
|
List<String> dateList = (List<String>) map.get("date"); |
|
|
|
|
|
String date = dateList.get(0).substring(0, dateList.get(0).length() - 2); |
|
|
|
|
|
|
|
|
|
|
|
List<String> pathList = (List<String>) map.get("path"); |
|
|
|
|
|
List<String> timeList = (List<String>) 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<String,Object> 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); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|