Browse Source

--气象预警增加规范文件提示信息

develop
mengff 3 weeks ago
parent
commit
a580b170c1
  1. 20
      zc-business/src/main/java/com/zc/business/controller/DcWarningController.java
  2. 152
      zc-business/src/main/java/com/zc/business/controller/WeatherForecastController.java
  3. 4
      zc-business/src/main/java/com/zc/business/enums/UniversalEnum.java
  4. 10
      zc-business/src/main/java/com/zc/business/utils/WeatherTrafficProposeUtil.java

20
zc-business/src/main/java/com/zc/business/controller/DcWarningController.java

@ -1,5 +1,7 @@
package com.zc.business.controller; package com.zc.business.controller;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.ruoyi.common.annotation.Log; import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.domain.AjaxResult;
@ -15,6 +17,7 @@ import com.zc.business.domain.DcWarning;
import com.zc.business.domain.DcWarningBatchConvert; import com.zc.business.domain.DcWarningBatchConvert;
import com.zc.business.enums.UniversalEnum; import com.zc.business.enums.UniversalEnum;
import com.zc.business.service.IDcWarningService; import com.zc.business.service.IDcWarningService;
import com.zc.business.utils.WeatherTrafficProposeUtil;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
@ -28,6 +31,7 @@ import java.net.URLEncoder;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
/** /**
* 预警信息Controller * 预警信息Controller
@ -238,7 +242,21 @@ public class DcWarningController extends BaseController
public TableDataInfo selectStakeWarningTable(){ public TableDataInfo selectStakeWarningTable(){
startPage(); startPage();
List<DcNoStakeWarningTable> list = dcWarningService.selectStakeWarningTable(); List<DcNoStakeWarningTable> list = dcWarningService.selectStakeWarningTable();
return getDataTable(list);
List<DcNoStakeWarningTable> updatedList = list.stream()
.peek(warningTable -> {
JSONObject otherConfig = JSONObject.parseObject(warningTable.getOtherConfig());
String earlyWorningSignal = otherConfig.getString("earlyWorningSignal");
String[] split = earlyWorningSignal.split(UniversalEnum.YJ_STRING.getValue());
String content = WeatherTrafficProposeUtil.content(
Integer.parseInt(split[UniversalEnum.ONE.getNumber()]),
split[UniversalEnum.ZERO.getNumber()]
);
warningTable.setWarningDescription(warningTable.getWarningDescription() + "\n" +content);
})
.collect(Collectors.toList());
return getDataTable(updatedList);
} }

152
zc-business/src/main/java/com/zc/business/controller/WeatherForecastController.java

@ -10,8 +10,10 @@ import com.ruoyi.system.service.ISysConfigService;
import com.zc.business.domain.DcNoStakeWarningTable; import com.zc.business.domain.DcNoStakeWarningTable;
import com.zc.business.domain.DcRegion; import com.zc.business.domain.DcRegion;
import com.zc.business.enums.UniversalEnum; import com.zc.business.enums.UniversalEnum;
import com.zc.business.service.IDcWarningService;
import com.zc.business.service.impl.DcNoStakeWarningTableServiceImpl; import com.zc.business.service.impl.DcNoStakeWarningTableServiceImpl;
import com.zc.business.service.impl.DcRegionServiceImpl; import com.zc.business.service.impl.DcRegionServiceImpl;
import com.zc.business.utils.WeatherTrafficProposeUtil;
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 com.zc.common.core.httpclient.request.RequestParams; import com.zc.common.core.httpclient.request.RequestParams;
@ -62,6 +64,9 @@ public class WeatherForecastController extends BaseController {
@Autowired @Autowired
private DcNoStakeWarningTableServiceImpl noStakeWarningTableService; private DcNoStakeWarningTableServiceImpl noStakeWarningTableService;
@Autowired
private IDcWarningService dcWarningService;
/*** /***
* 定时查询气象预警信息并上报 * 定时查询气象预警信息并上报
@ -87,9 +92,9 @@ public class WeatherForecastController extends BaseController {
data.forEach(item -> { data.forEach(item -> {
JSONObject jsonObject = (JSONObject) JSON.toJSON(item); JSONObject jsonObject = (JSONObject) JSON.toJSON(item);
String earlyWorningSignal = jsonObject.getString("earlyWorningSignal"); String earlyWorningSignal = jsonObject.getString("earlyWorningSignal");
String[] split = earlyWorningSignal.split(UniversalEnum.EMPTY_STRING.getValue()); String[] split = earlyWorningSignal.split(UniversalEnum.YJ_STRING.getValue());
String earlyWarningType = split[UniversalEnum.ZERO.getNumber()]; String earlyWarningType = split[UniversalEnum.ZERO.getNumber()];
String warningLevel = split[UniversalEnum.THREE.getNumber()]; String warningLevel = split[UniversalEnum.ONE.getNumber()];
switch (warningLevel) { switch (warningLevel) {
case "0": case "0":
@ -186,25 +191,21 @@ public class WeatherForecastController extends BaseController {
jsonObject.put("earlyWarningTypeString", UniversalEnum.ICY_ROADS.toString()); jsonObject.put("earlyWarningTypeString", UniversalEnum.ICY_ROADS.toString());
break; break;
} }
//List<JSONObject> currentWeatherAndForecastInformation = redisCache.getCacheList(UniversalEnum.CURRENT_WEATHER_AND_FORECAST_INFORMATION.getValue());
//List<JSONObject> collect = currentWeatherAndForecastInformation.stream().filter(ite ->
// !Objects.equals(ite.getString("earlyWorningIssueDate"), jsonObject.getString("earlyWorningIssueDate"))
// && !Objects.equals(ite.getString("earlyWorningTitle"), jsonObject.getString("earlyWorningTitle"))
// && !Objects.equals(ite.getString("stationName"), jsonObject.getString("stationName"))).collect(Collectors.toList());
List<DcNoStakeWarningTable> dcNoStakeWarningTables = noStakeWarningTableService.listDcNoStakeWarningTable(noStakeWarningTable, null, null); List<DcNoStakeWarningTable> dcNoStakeWarningTables = noStakeWarningTableService.listDcNoStakeWarningTable(noStakeWarningTable, null, null);
List<DcNoStakeWarningTable> collect = dcNoStakeWarningTables.stream().filter(ite -> List<DcNoStakeWarningTable> collect = dcNoStakeWarningTables.stream().filter(ite ->
Objects.equals(ite.getWarningTime(), jsonObject.getDate("earlyWorningIssueDate")) Objects.equals(ite.getWarningTime(), jsonObject.getDate("earlyWorningIssueDate"))
&& Objects.equals(ite.getWarningDescription(), jsonObject.getString("earlyWorningContent")) && Objects.equals(ite.getWarningDescription(), jsonObject.getString("earlyWorningContent"))
&& Objects.equals(ite.getWarningType(), UniversalEnum.TWO.getValue())).collect(Collectors.toList()); && Objects.equals(ite.getWarningType(), UniversalEnum.TWO.getValue())).collect(Collectors.toList());
if (collect.size() == UniversalEnum.ZERO.getNumber()) { if (collect.size() == UniversalEnum.ZERO.getNumber()) {
WebSocketService.broadcast(UniversalEnum.THREE.getValue(), jsonObject); //推送事件消息 不是感知事件
DcNoStakeWarningTable dcNoStakeWarningTable = new DcNoStakeWarningTable(); DcNoStakeWarningTable dcNoStakeWarningTable = new DcNoStakeWarningTable();
dcNoStakeWarningTable.setWarningDescription(jsonObject.getString("earlyWorningContent")); dcNoStakeWarningTable.setWarningDescription(jsonObject.getString("earlyWorningContent"));
dcNoStakeWarningTable.setWarningType(UniversalEnum.TWO.getValue()); dcNoStakeWarningTable.setWarningType(UniversalEnum.TWO.getValue());
dcNoStakeWarningTable.setWarningTime(jsonObject.getDate("earlyWorningIssueDate")); dcNoStakeWarningTable.setWarningTime(jsonObject.getDate("earlyWorningIssueDate"));
dcNoStakeWarningTable.setOtherConfig(String.valueOf(jsonObject)); dcNoStakeWarningTable.setOtherConfig(String.valueOf(jsonObject));
noStakeWarningTableService.addDcNoStakeWarningTable(dcNoStakeWarningTable); noStakeWarningTableService.addDcNoStakeWarningTable(dcNoStakeWarningTable);
String content= WeatherTrafficProposeUtil.content(Integer.parseInt(warningLevel), earlyWarningType);
jsonObject.put("earlyWorningContent", jsonObject.getString("earlyWorningContent")+content);
WebSocketService.broadcast(UniversalEnum.THREE.getValue(), jsonObject); //推送事件消息 不是感知事件
} }
}); });
@ -594,86 +595,59 @@ public class WeatherForecastController extends BaseController {
@ApiOperation("当前气象预警信息查询") @ApiOperation("当前气象预警信息查询")
@PostMapping(value = "/currentWeatherWarningInformationQuery") @PostMapping(value = "/currentWeatherWarningInformationQuery")
public AjaxResult currentWeatherWarningInformationQuery(@RequestBody HashMap<String, Object> parameter) { public AjaxResult currentWeatherWarningInformationQuery(@RequestBody HashMap<String, Object> parameter) {
List<DcNoStakeWarningTable> list = dcWarningService.selectStakeWarningTable();
try {
List<JSONObject> result = list.stream()
OkHttp okHttp = new OkHttp(); .map(table -> {
JSONObject otherConfig = JSONObject.parseObject(table.getOtherConfig());
RequestParams requestParams = new RequestParams(parameter); String earlyWorningSignal = otherConfig.getString("earlyWorningSignal");
Response response // 请求响应 String[] split = earlyWorningSignal.split(UniversalEnum.YJ_STRING.getValue());
= okHttp String content = WeatherTrafficProposeUtil.content(
.headers(new HashMap<>()) Integer.parseInt(split[UniversalEnum.ONE.getNumber()]),
.url(UniversalEnum.CURRENT_WEATHER_WARNING_INFORMATION_QUERY.getValue()) // 请求地址 split[UniversalEnum.ZERO.getNumber()]
//.url("http://10.166.133.9:38999/api/weather_service/get_earlyworning_info_jh") // 请求地址 );
.data(requestParams) otherConfig.put("earlyWorningContent", table.getWarningDescription() + "\n" +content);
.post(); // 请求方法 return otherConfig;
})
if (response.body() != null) { .collect(Collectors.toList());
return AjaxResult.success(result);
JSONObject jsonResult = JSONObject.parseObject(response.body().string());
if (jsonResult.getInteger("code") == UniversalEnum.TWO_HUNDRED.getNumber()) { // try {
JSONArray jsonArray = jsonResult.getJSONArray("data"); //
//List<Object> collect = jsonArray.stream().filter(item -> { // OkHttp okHttp = new OkHttp();
// JSONObject jsonObject = (JSONObject) JSON.toJSON(item); //
// return Objects.equals(jsonObject.getString("stationName"), UniversalEnum.CHANGQING_COUNTY.getValue()) // RequestParams requestParams = new RequestParams(parameter);
// || Objects.equals(jsonObject.getString("stationName"), UniversalEnum.PING_YIN.getValue()) // Response response // 请求响应
// || Objects.equals(jsonObject.getString("stationName"), UniversalEnum.DONG_PING.getValue()) // = okHttp
// || Objects.equals(jsonObject.getString("stationName"), UniversalEnum.MONKAMI.getValue()) // .headers(new HashMap<>())
// || Objects.equals(jsonObject.getString("stationName"), UniversalEnum.LIANG_SHAN.getValue()) // .url(UniversalEnum.CURRENT_WEATHER_WARNING_INFORMATION_QUERY.getValue()) // 请求地址
// || Objects.equals(jsonObject.getString("stationName"), UniversalEnum.JIA_XIANG.getValue()) // .data(requestParams)
// || Objects.equals(jsonObject.getString("stationName"), UniversalEnum.JU_YE.getValue()) // .post(); // 请求方法
// || Objects.equals(jsonObject.getString("stationName"), UniversalEnum.YUNCHENG_A_COUNTY_IN_SHANDONG_PROVINCE.getValue()); //
// //if (Objects.equals(jsonObject.getString("stationName"), "长清") // if (response.body() != null) {
// // || Objects.equals(jsonObject.getString("stationName"), "平阴") //
// // || Objects.equals(jsonObject.getString("stationName"), "东平") // JSONObject jsonResult = JSONObject.parseObject(response.body().string());
// // || Objects.equals(jsonObject.getString("stationName"), "汶上") // if (jsonResult.getInteger("code") == UniversalEnum.TWO_HUNDRED.getNumber()) {
// // || Objects.equals(jsonObject.getString("stationName"), "梁山") // JSONArray jsonArray = jsonResult.getJSONArray("data");
// // || Objects.equals(jsonObject.getString("stationName"), "嘉祥") // return AjaxResult.success(jsonArray.stream().filter(item -> {
// // || Objects.equals(jsonObject.getString("stationName"), "巨野") // JSONObject jsonObject = (JSONObject) JSON.toJSON(item);
// // || Objects.equals(jsonObject.getString("stationName"), "郓城")) { // return Objects.equals(jsonObject.getString("stationName"), UniversalEnum.CHANGQING_COUNTY.getValue())
// // return true; // || Objects.equals(jsonObject.getString("stationName"), UniversalEnum.PING_YIN.getValue())
// //} else { // || Objects.equals(jsonObject.getString("stationName"), UniversalEnum.DONG_PING.getValue())
// // return false; // || Objects.equals(jsonObject.getString("stationName"), UniversalEnum.MONKAMI.getValue())
// //} // || Objects.equals(jsonObject.getString("stationName"), UniversalEnum.LIANG_SHAN.getValue())
//}).collect(Collectors.toList()); // || Objects.equals(jsonObject.getString("stationName"), UniversalEnum.JIA_XIANG.getValue())
//if (collect.size() != UniversalEnum.ZERO.getNumber()) { // || Objects.equals(jsonObject.getString("stationName"), UniversalEnum.JU_YE.getValue())
// redisCache.deleteObject("currentWeatherWarningInformationQuery"); // || Objects.equals(jsonObject.getString("stationName"), UniversalEnum.YUNCHENG_A_COUNTY_IN_SHANDONG_PROVINCE.getValue());
// redisCache.setCacheList("currentWeatherWarningInformationQuery", collect); // }).collect(Collectors.toList()));
return AjaxResult.success(jsonArray.stream().filter(item -> { // } else {
JSONObject jsonObject = (JSONObject) JSON.toJSON(item); // return AjaxResult.success(new ArrayList<>());
return Objects.equals(jsonObject.getString("stationName"), UniversalEnum.CHANGQING_COUNTY.getValue()) // }
|| Objects.equals(jsonObject.getString("stationName"), UniversalEnum.PING_YIN.getValue()) // }
|| Objects.equals(jsonObject.getString("stationName"), UniversalEnum.DONG_PING.getValue()) // } catch (Exception ignored) {
|| Objects.equals(jsonObject.getString("stationName"), UniversalEnum.MONKAMI.getValue()) //
|| Objects.equals(jsonObject.getString("stationName"), UniversalEnum.LIANG_SHAN.getValue()) // }
|| Objects.equals(jsonObject.getString("stationName"), UniversalEnum.JIA_XIANG.getValue()) // return AjaxResult.success(new ArrayList<>());
|| Objects.equals(jsonObject.getString("stationName"), UniversalEnum.JU_YE.getValue())
|| Objects.equals(jsonObject.getString("stationName"), UniversalEnum.YUNCHENG_A_COUNTY_IN_SHANDONG_PROVINCE.getValue());
//if (Objects.equals(jsonObject.getString("stationName"), "长清")
// || Objects.equals(jsonObject.getString("stationName"), "平阴")
// || Objects.equals(jsonObject.getString("stationName"), "东平")
// || Objects.equals(jsonObject.getString("stationName"), "汶上")
// || Objects.equals(jsonObject.getString("stationName"), "梁山")
// || Objects.equals(jsonObject.getString("stationName"), "嘉祥")
// || Objects.equals(jsonObject.getString("stationName"), "巨野")
// || Objects.equals(jsonObject.getString("stationName"), "郓城")) {
// return true;
//} else {
// return false;
//}
}).collect(Collectors.toList()));
//} else {
// return AjaxResult.success(redisCache.getCacheList("currentWeatherWarningInformationQuery"));
//}
} else {
return AjaxResult.success(new ArrayList<>());
}
}
} catch (Exception ignored) {
}
return AjaxResult.success(new ArrayList<>());
} }

4
zc-business/src/main/java/com/zc/business/enums/UniversalEnum.java

@ -2198,6 +2198,10 @@ RADAR_ASSOCIATED_MONITORING_POINT_QUERY_INTERFACE(0,"/api/radar/v1/selectRelateB
// 空格 // 空格
BLANK_SPACE(0, " "), BLANK_SPACE(0, " "),
// 预警
YJ_STRING(0, "yj"),
// 金钱符 // 金钱符
MONEY_SIGN(0, "$"), MONEY_SIGN(0, "$"),

10
zc-business/src/main/java/com/zc/business/utils/WeatherTrafficProposeUtil.java

@ -73,11 +73,11 @@ public class WeatherTrafficProposeUtil {
case RAIN_LEVEL_2: case RAIN_LEVEL_2:
case FOG_LEVEL_2: case FOG_LEVEL_2:
case SNOW_LEVEL_2: case SNOW_LEVEL_2:
return "建议局部封闭、间断放行"; return "建议局部封闭、间断放行;";
case RAIN_LEVEL_1: case RAIN_LEVEL_1:
case FOG_LEVEL_1: case FOG_LEVEL_1:
case SNOW_LEVEL_1: case SNOW_LEVEL_1:
return "建议全线封闭收费站、必要时可带队通行的控制措施。全线封闭时,正在高速公路通行的车辆应以不大于 20km/h 的速度就近驶出高速公路或驶入服务区。带队通行时,应保障交通有序通行"; return "建议全线封闭收费站、必要时可带队通行的控制措施。全线封闭时,正在高速公路通行的车辆应以不大于 20km/h 的速度就近驶出高速公路或驶入服务区。带队通行时,应保障交通有序通行;";
default: default:
throw new IllegalArgumentException("Unknown weather condition: " + condition); throw new IllegalArgumentException("Unknown weather condition: " + condition);
} }
@ -109,6 +109,12 @@ public class WeatherTrafficProposeUtil {
} }
} }
public static String content(int warningLevelStringNumber, String earlyWarningTypeStringNumber){
WeatherCondition condition = WeatherCondition.fromLevelAndDescription(warningLevelStringNumber, earlyWarningTypeStringNumber);
System.out.println("Weather Condition: " + condition.name() + ", Level: " + condition.getLevel() + ", Description: " + condition.getDescription());
return "建议速度为"+getSpeedLimit(condition) + " km/h ;\n" + getTrafficControlAdvice(condition) + "\n" + getVehicleControlAdvice(condition);
}
public static void main(String[] args) { public static void main(String[] args) {
int warningLevelStringNumber = 3; int warningLevelStringNumber = 3;
String earlyWarningTypeStringNumber= "1"; String earlyWarningTypeStringNumber= "1";

Loading…
Cancel
Save