diff --git a/zc-business/src/main/java/com/zc/business/controller/WeatherForecastController.java b/zc-business/src/main/java/com/zc/business/controller/WeatherForecastController.java index 6998e207..94580470 100644 --- a/zc-business/src/main/java/com/zc/business/controller/WeatherForecastController.java +++ b/zc-business/src/main/java/com/zc/business/controller/WeatherForecastController.java @@ -78,7 +78,7 @@ public class WeatherForecastController extends BaseController { hashMap.put("roadId", UniversalEnum.ROAD_ID.getValue()); hashMap.put("earlyWorningLevel", UniversalEnum.EARLY_WORNING_LEVEL.getValue()); //hashMap.put("managerId", UniversalEnum.MANAGER_ID.getValue()); - AjaxResult ajaxResult = currentWeatherWarningInformationQuery(hashMap); + AjaxResult ajaxResult = currentWeatherWarningInformationQuerys(hashMap); String code = String.valueOf(ajaxResult.get("code")); if (!Objects.equals(code, UniversalEnum.TWO_HUNDRED.getValue())) { @@ -197,15 +197,15 @@ public class WeatherForecastController extends BaseController { && Objects.equals(ite.getWarningDescription(), jsonObject.getString("earlyWorningContent")) && Objects.equals(ite.getWarningType(), UniversalEnum.TWO.getValue())).collect(Collectors.toList()); if (collect.size() == UniversalEnum.ZERO.getNumber()) { + String content= WeatherTrafficProposeUtil.content(Integer.parseInt(warningLevel), earlyWarningType); + jsonObject.put("earlyWorningContent", jsonObject.getString("earlyWorningContent")+content); + WebSocketService.broadcast(UniversalEnum.THREE.getValue(), jsonObject); //推送事件消息 不是感知事件 DcNoStakeWarningTable dcNoStakeWarningTable = new DcNoStakeWarningTable(); dcNoStakeWarningTable.setWarningDescription(jsonObject.getString("earlyWorningContent")); dcNoStakeWarningTable.setWarningType(UniversalEnum.TWO.getValue()); dcNoStakeWarningTable.setWarningTime(jsonObject.getDate("earlyWorningIssueDate")); dcNoStakeWarningTable.setOtherConfig(String.valueOf(jsonObject)); noStakeWarningTableService.addDcNoStakeWarningTable(dcNoStakeWarningTable); - String content= WeatherTrafficProposeUtil.content(Integer.parseInt(warningLevel), earlyWarningType); - jsonObject.put("earlyWorningContent", jsonObject.getString("earlyWorningContent")+content); - WebSocketService.broadcast(UniversalEnum.THREE.getValue(), jsonObject); //推送事件消息 不是感知事件 } }); @@ -651,6 +651,47 @@ public class WeatherForecastController extends BaseController { } + public AjaxResult currentWeatherWarningInformationQuerys(@RequestBody HashMap parameter) { + + try { + + OkHttp okHttp = new OkHttp(); + + RequestParams requestParams = new RequestParams(parameter); + Response response // 请求响应 + = okHttp + .headers(new HashMap<>()) + .url(UniversalEnum.CURRENT_WEATHER_WARNING_INFORMATION_QUERY.getValue()) // 请求地址 + .data(requestParams) + .post(); // 请求方法 + + if (response.body() != null) { + + JSONObject jsonResult = JSONObject.parseObject(response.body().string()); + if (jsonResult.getInteger("code") == UniversalEnum.TWO_HUNDRED.getNumber()) { + JSONArray jsonArray = jsonResult.getJSONArray("data"); + return AjaxResult.success(jsonArray.stream().filter(item -> { + JSONObject jsonObject = (JSONObject) JSON.toJSON(item); + 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()) + || 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()) + || Objects.equals(jsonObject.getString("stationName"), UniversalEnum.JU_YE.getValue()) + || Objects.equals(jsonObject.getString("stationName"), UniversalEnum.YUNCHENG_A_COUNTY_IN_SHANDONG_PROVINCE.getValue()); + }).collect(Collectors.toList())); + } else { + return AjaxResult.success(new ArrayList<>()); + } + } + } catch (Exception ignored) { + + } + return AjaxResult.success(new ArrayList<>()); + } + + /* * 天气实况查询 * */ diff --git a/zc-business/src/main/java/com/zc/business/utils/WeatherTrafficProposeUtil.java b/zc-business/src/main/java/com/zc/business/utils/WeatherTrafficProposeUtil.java index d073adda..8ced4bcb 100644 --- a/zc-business/src/main/java/com/zc/business/utils/WeatherTrafficProposeUtil.java +++ b/zc-business/src/main/java/com/zc/business/utils/WeatherTrafficProposeUtil.java @@ -73,11 +73,11 @@ public class WeatherTrafficProposeUtil { case RAIN_LEVEL_2: case FOG_LEVEL_2: case SNOW_LEVEL_2: - return "建议局部封闭、间断放行;"; + return "局部封闭、间断放行;"; case RAIN_LEVEL_1: case FOG_LEVEL_1: case SNOW_LEVEL_1: - return "建议全线封闭收费站、必要时可带队通行的控制措施。全线封闭时,正在高速公路通行的车辆应以不大于 20km/h 的速度就近驶出高速公路或驶入服务区。带队通行时,应保障交通有序通行;"; + return "全线封闭收费站、必要时可带队通行的控制措施。全线封闭时,正在高速公路通行的车辆应以不大于 20km/h 的速度就近驶出高速公路或驶入服务区。带队通行时,应保障交通有序通行;"; default: throw new IllegalArgumentException("Unknown weather condition: " + condition); }