Browse Source

Merge remote-tracking branch 'origin/develop' into develop

develop
Mr.Wang 5 months ago
parent
commit
5f39d557c3
  1. 94
      zc-business/src/main/java/com/zc/business/controller/DcNmcController.java
  2. 4
      zc-business/src/main/java/com/zc/business/controller/WordController.java
  3. 10
      zc-business/src/main/java/com/zc/business/message/device/handler/DeviceMessageHandler.java

94
zc-business/src/main/java/com/zc/business/controller/DcNmcController.java

@ -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);
}
} }

4
zc-business/src/main/java/com/zc/business/controller/WordController.java

@ -287,7 +287,7 @@ public class WordController {
List<Map<String,Object>> tollStationAnalysisList = dcTrafficIncidentsMapper.selectTollStationAnalysisByFacility(null,startDate,endDate); List<Map<String,Object>> tollStationAnalysisList = dcTrafficIncidentsMapper.selectTollStationAnalysisByFacility(null,startDate,endDate);
if (tollStationAnalysisList != null && tollStationAnalysisList.size() > 0) { if (tollStationAnalysisList != null && tollStationAnalysisList.size() > 0) {
XWPFTable table = doc.createTable(11, 4); XWPFTable table = doc.createTable(11, 3);
//列宽自动分割 //列宽自动分割
CTTblWidth infoTableWidth = table.getCTTbl().addNewTblPr().addNewTblW(); CTTblWidth infoTableWidth = table.getCTTbl().addNewTblPr().addNewTblW();
infoTableWidth.setType(STTblWidth.DXA); infoTableWidth.setType(STTblWidth.DXA);
@ -295,14 +295,12 @@ public class WordController {
setTableFonts(table.getRow(0).getCell(1), "封闭"); setTableFonts(table.getRow(0).getCell(1), "封闭");
setTableFonts(table.getRow(0).getCell(2), "限行"); setTableFonts(table.getRow(0).getCell(2), "限行");
setTableFonts(table.getRow(0).getCell(3), "间隔放行");
//excel //excel
for (int i = 0; i < tollStationAnalysisList.size(); i++){ 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(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(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(2), tollStationAnalysisList.get(i).get("facilityRestriction").toString());
setTableFonts(table.getRow(i+1).getCell(3), tollStationAnalysisList.get(i).get("facilityInterval").toString());
} }
try { try {

10
zc-business/src/main/java/com/zc/business/message/device/handler/DeviceMessageHandler.java

@ -619,6 +619,11 @@ if (meteorologicalDetectorData.getPrecipitationType().equals("1")){
String string = object.toString(); String string = object.toString();
DcWarning dcWarning = new DcWarning(); DcWarning dcWarning = new DcWarning();
dcWarning.setWarningState(1);
dcWarning.setRemark(content);
dcWarning.setWarningTime(new Date());
dcWarning.setWarningType(8);
dcWarning.setWarningSubclass("8-1");
dcWarning.setStakeMark(stakeMark); dcWarning.setStakeMark(stakeMark);
dcWarning.setWarningSource(7);//气象检测器 dcWarning.setWarningSource(7);//气象检测器
@ -655,6 +660,11 @@ if (meteorologicalDetectorData.getPrecipitationType().equals("1")){
object.put("meteorologicalDetectorData", meteorologicalDetectorData); object.put("meteorologicalDetectorData", meteorologicalDetectorData);
String string = object.toString(); String string = object.toString();
DcWarning dcWarning = new DcWarning(); DcWarning dcWarning = new DcWarning();
dcWarning.setWarningState(1);
dcWarning.setRemark(content);
dcWarning.setWarningTime(new Date());
dcWarning.setWarningType(8);
dcWarning.setWarningSubclass("8-4");
dcWarning.setStakeMark(stakeMark); dcWarning.setStakeMark(stakeMark);
dcWarning.setWarningSource(7);//气象检测器 dcWarning.setWarningSource(7);//气象检测器
dcWarning.setOtherConfig(string); dcWarning.setOtherConfig(string);

Loading…
Cancel
Save