|
|
@ -80,130 +80,133 @@ public class WeatherForecastController extends BaseController { |
|
|
|
return; |
|
|
|
} |
|
|
|
JSONArray data = (JSONArray) JSON.toJSON(ajaxResult.get("data")); |
|
|
|
List<DcNoStakeWarningTable> dcNoStakeWarningTables = noStakeWarningTableService.listDcNoStakeWarningTable(new DcNoStakeWarningTable(),null,null); |
|
|
|
data.forEach(item -> { |
|
|
|
JSONObject jsonObject = (JSONObject) JSON.toJSON(item); |
|
|
|
String earlyWorningSignal = jsonObject.getString("earlyWorningSignal"); |
|
|
|
String[] split = earlyWorningSignal.split(UniversalEnum.EMPTY_STRING.getValue()); |
|
|
|
String earlyWarningType = split[UniversalEnum.ZERO.getNumber()]; |
|
|
|
String warningLevel = split[UniversalEnum.THREE.getNumber()]; |
|
|
|
|
|
|
|
switch (warningLevel) { |
|
|
|
case "0": |
|
|
|
//蓝色预警
|
|
|
|
jsonObject.put("warningLevelStringNumber", UniversalEnum.ZERO.getValue()); |
|
|
|
jsonObject.put("warningLevelString", UniversalEnum.BLUE_ALERT.toString()); |
|
|
|
break; |
|
|
|
case "1": |
|
|
|
//黄色预警
|
|
|
|
jsonObject.put("warningLevelStringNumber", UniversalEnum.ONE.getValue()); |
|
|
|
jsonObject.put("warningLevelString", UniversalEnum.YELLOW_ALERT.toString()); |
|
|
|
break; |
|
|
|
case "2": |
|
|
|
//橙色预警
|
|
|
|
jsonObject.put("warningLevelStringNumber", UniversalEnum.TWO.getValue()); |
|
|
|
jsonObject.put("warningLevelString", UniversalEnum.ORANGE_ALERT.toString()); |
|
|
|
break; |
|
|
|
case "3": |
|
|
|
//红色预警
|
|
|
|
jsonObject.put("warningLevelStringNumber", UniversalEnum.THREE.getValue()); |
|
|
|
jsonObject.put("warningLevelString", UniversalEnum.RED_ALERT.toString()); |
|
|
|
break; |
|
|
|
} |
|
|
|
if (data.size() > UniversalEnum.ZERO.getNumber()) { |
|
|
|
|
|
|
|
List<DcNoStakeWarningTable> dcNoStakeWarningTables = noStakeWarningTableService.listDcNoStakeWarningTable(new DcNoStakeWarningTable(), null, null); |
|
|
|
data.forEach(item -> { |
|
|
|
JSONObject jsonObject = (JSONObject) JSON.toJSON(item); |
|
|
|
String earlyWorningSignal = jsonObject.getString("earlyWorningSignal"); |
|
|
|
String[] split = earlyWorningSignal.split(UniversalEnum.EMPTY_STRING.getValue()); |
|
|
|
String earlyWarningType = split[UniversalEnum.ZERO.getNumber()]; |
|
|
|
String warningLevel = split[UniversalEnum.THREE.getNumber()]; |
|
|
|
|
|
|
|
switch (warningLevel) { |
|
|
|
case "0": |
|
|
|
//蓝色预警
|
|
|
|
jsonObject.put("warningLevelStringNumber", UniversalEnum.ZERO.getValue()); |
|
|
|
jsonObject.put("warningLevelString", UniversalEnum.BLUE_ALERT.toString()); |
|
|
|
break; |
|
|
|
case "1": |
|
|
|
//黄色预警
|
|
|
|
jsonObject.put("warningLevelStringNumber", UniversalEnum.ONE.getValue()); |
|
|
|
jsonObject.put("warningLevelString", UniversalEnum.YELLOW_ALERT.toString()); |
|
|
|
break; |
|
|
|
case "2": |
|
|
|
//橙色预警
|
|
|
|
jsonObject.put("warningLevelStringNumber", UniversalEnum.TWO.getValue()); |
|
|
|
jsonObject.put("warningLevelString", UniversalEnum.ORANGE_ALERT.toString()); |
|
|
|
break; |
|
|
|
case "3": |
|
|
|
//红色预警
|
|
|
|
jsonObject.put("warningLevelStringNumber", UniversalEnum.THREE.getValue()); |
|
|
|
jsonObject.put("warningLevelString", UniversalEnum.RED_ALERT.toString()); |
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
|
switch (earlyWarningType) { |
|
|
|
case "0": |
|
|
|
//台风
|
|
|
|
jsonObject.put("earlyWarningTypeStringNumber", UniversalEnum.ZERO.getValue()); |
|
|
|
jsonObject.put("earlyWarningTypeString", UniversalEnum.TYPHOON.toString()); |
|
|
|
break; |
|
|
|
case "1": |
|
|
|
//暴雨
|
|
|
|
jsonObject.put("earlyWarningTypeStringNumber", UniversalEnum.ONE.getValue()); |
|
|
|
jsonObject.put("earlyWarningTypeString", UniversalEnum.RAINSTORM.toString()); |
|
|
|
break; |
|
|
|
case "2": |
|
|
|
//暴雪
|
|
|
|
jsonObject.put("earlyWarningTypeStringNumber", UniversalEnum.TWO.getValue()); |
|
|
|
jsonObject.put("earlyWarningTypeString", UniversalEnum.BLIZZARD.toString()); |
|
|
|
break; |
|
|
|
case "3": |
|
|
|
//寒潮
|
|
|
|
jsonObject.put("earlyWarningTypeStringNumber", UniversalEnum.THREE.getValue()); |
|
|
|
jsonObject.put("earlyWarningTypeString", UniversalEnum.COLD_WAVE.toString()); |
|
|
|
break; |
|
|
|
case "4": |
|
|
|
//大风
|
|
|
|
jsonObject.put("earlyWarningTypeStringNumber", UniversalEnum.FOUR.getValue()); |
|
|
|
jsonObject.put("earlyWarningTypeString", UniversalEnum.GALE.toString()); |
|
|
|
break; |
|
|
|
case "5": |
|
|
|
//沙尘暴
|
|
|
|
jsonObject.put("earlyWarningTypeStringNumber", UniversalEnum.FIVE.getValue()); |
|
|
|
jsonObject.put("earlyWarningTypeString", UniversalEnum.SANDSTORM.toString()); |
|
|
|
break; |
|
|
|
case "6": |
|
|
|
//高温
|
|
|
|
jsonObject.put("earlyWarningTypeStringNumber", UniversalEnum.SIX.getValue()); |
|
|
|
jsonObject.put("earlyWarningTypeString", UniversalEnum.HYPERTHERMIA.toString()); |
|
|
|
break; |
|
|
|
case "7": |
|
|
|
//干旱
|
|
|
|
jsonObject.put("earlyWarningTypeStringNumber", UniversalEnum.SEVEN.getValue()); |
|
|
|
jsonObject.put("earlyWarningTypeString", UniversalEnum.ARIDITY.toString()); |
|
|
|
break; |
|
|
|
case "8": |
|
|
|
//雷电
|
|
|
|
jsonObject.put("earlyWarningTypeStringNumber", UniversalEnum.EIGHT.getValue()); |
|
|
|
jsonObject.put("earlyWarningTypeString", UniversalEnum.AEGIS.toString()); |
|
|
|
break; |
|
|
|
case "9": |
|
|
|
//冰雹
|
|
|
|
jsonObject.put("earlyWarningTypeStringNumber", UniversalEnum.NINE.getValue()); |
|
|
|
jsonObject.put("earlyWarningTypeString", UniversalEnum.HAILSTONE.toString()); |
|
|
|
break; |
|
|
|
case "10": |
|
|
|
//霜冻
|
|
|
|
jsonObject.put("earlyWarningTypeStringNumber", UniversalEnum.TEN.getValue()); |
|
|
|
jsonObject.put("earlyWarningTypeString", UniversalEnum.FROST.toString()); |
|
|
|
break; |
|
|
|
case "11": |
|
|
|
//大雾
|
|
|
|
jsonObject.put("earlyWarningTypeStringNumber", UniversalEnum.ELEVEN.getValue()); |
|
|
|
jsonObject.put("earlyWarningTypeString", UniversalEnum.HEAVY_FOG.toString()); |
|
|
|
break; |
|
|
|
case "12": |
|
|
|
//霾
|
|
|
|
jsonObject.put("earlyWarningTypeStringNumber", UniversalEnum.TWELVE.getValue()); |
|
|
|
jsonObject.put("earlyWarningTypeString", UniversalEnum.HAZE.toString()); |
|
|
|
break; |
|
|
|
case "13": |
|
|
|
//道路结冰
|
|
|
|
jsonObject.put("earlyWarningTypeStringNumber", UniversalEnum.THIRTEEN.getValue()); |
|
|
|
jsonObject.put("earlyWarningTypeString", UniversalEnum.ICY_ROADS.toString()); |
|
|
|
break; |
|
|
|
} |
|
|
|
switch (earlyWarningType) { |
|
|
|
case "0": |
|
|
|
//台风
|
|
|
|
jsonObject.put("earlyWarningTypeStringNumber", UniversalEnum.ZERO.getValue()); |
|
|
|
jsonObject.put("earlyWarningTypeString", UniversalEnum.TYPHOON.toString()); |
|
|
|
break; |
|
|
|
case "1": |
|
|
|
//暴雨
|
|
|
|
jsonObject.put("earlyWarningTypeStringNumber", UniversalEnum.ONE.getValue()); |
|
|
|
jsonObject.put("earlyWarningTypeString", UniversalEnum.RAINSTORM.toString()); |
|
|
|
break; |
|
|
|
case "2": |
|
|
|
//暴雪
|
|
|
|
jsonObject.put("earlyWarningTypeStringNumber", UniversalEnum.TWO.getValue()); |
|
|
|
jsonObject.put("earlyWarningTypeString", UniversalEnum.BLIZZARD.toString()); |
|
|
|
break; |
|
|
|
case "3": |
|
|
|
//寒潮
|
|
|
|
jsonObject.put("earlyWarningTypeStringNumber", UniversalEnum.THREE.getValue()); |
|
|
|
jsonObject.put("earlyWarningTypeString", UniversalEnum.COLD_WAVE.toString()); |
|
|
|
break; |
|
|
|
case "4": |
|
|
|
//大风
|
|
|
|
jsonObject.put("earlyWarningTypeStringNumber", UniversalEnum.FOUR.getValue()); |
|
|
|
jsonObject.put("earlyWarningTypeString", UniversalEnum.GALE.toString()); |
|
|
|
break; |
|
|
|
case "5": |
|
|
|
//沙尘暴
|
|
|
|
jsonObject.put("earlyWarningTypeStringNumber", UniversalEnum.FIVE.getValue()); |
|
|
|
jsonObject.put("earlyWarningTypeString", UniversalEnum.SANDSTORM.toString()); |
|
|
|
break; |
|
|
|
case "6": |
|
|
|
//高温
|
|
|
|
jsonObject.put("earlyWarningTypeStringNumber", UniversalEnum.SIX.getValue()); |
|
|
|
jsonObject.put("earlyWarningTypeString", UniversalEnum.HYPERTHERMIA.toString()); |
|
|
|
break; |
|
|
|
case "7": |
|
|
|
//干旱
|
|
|
|
jsonObject.put("earlyWarningTypeStringNumber", UniversalEnum.SEVEN.getValue()); |
|
|
|
jsonObject.put("earlyWarningTypeString", UniversalEnum.ARIDITY.toString()); |
|
|
|
break; |
|
|
|
case "8": |
|
|
|
//雷电
|
|
|
|
jsonObject.put("earlyWarningTypeStringNumber", UniversalEnum.EIGHT.getValue()); |
|
|
|
jsonObject.put("earlyWarningTypeString", UniversalEnum.AEGIS.toString()); |
|
|
|
break; |
|
|
|
case "9": |
|
|
|
//冰雹
|
|
|
|
jsonObject.put("earlyWarningTypeStringNumber", UniversalEnum.NINE.getValue()); |
|
|
|
jsonObject.put("earlyWarningTypeString", UniversalEnum.HAILSTONE.toString()); |
|
|
|
break; |
|
|
|
case "10": |
|
|
|
//霜冻
|
|
|
|
jsonObject.put("earlyWarningTypeStringNumber", UniversalEnum.TEN.getValue()); |
|
|
|
jsonObject.put("earlyWarningTypeString", UniversalEnum.FROST.toString()); |
|
|
|
break; |
|
|
|
case "11": |
|
|
|
//大雾
|
|
|
|
jsonObject.put("earlyWarningTypeStringNumber", UniversalEnum.ELEVEN.getValue()); |
|
|
|
jsonObject.put("earlyWarningTypeString", UniversalEnum.HEAVY_FOG.toString()); |
|
|
|
break; |
|
|
|
case "12": |
|
|
|
//霾
|
|
|
|
jsonObject.put("earlyWarningTypeStringNumber", UniversalEnum.TWELVE.getValue()); |
|
|
|
jsonObject.put("earlyWarningTypeString", UniversalEnum.HAZE.toString()); |
|
|
|
break; |
|
|
|
case "13": |
|
|
|
//道路结冰
|
|
|
|
jsonObject.put("earlyWarningTypeStringNumber", UniversalEnum.THIRTEEN.getValue()); |
|
|
|
jsonObject.put("earlyWarningTypeString", UniversalEnum.ICY_ROADS.toString()); |
|
|
|
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> collect = dcNoStakeWarningTables.stream().filter(ite -> |
|
|
|
Objects.equals(ite.getWarningTime(), jsonObject.getDate("earlyWorningIssueDate")) |
|
|
|
&& Objects.equals(ite.getWarningDescription(), jsonObject.getString("earlyWorningContent")) |
|
|
|
&& Objects.equals(ite.getWarningType(), UniversalEnum.TWO.getValue())).collect(Collectors.toList()); |
|
|
|
if (collect.size() == UniversalEnum.ZERO.getNumber()) { |
|
|
|
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); |
|
|
|
} |
|
|
|
//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> collect = dcNoStakeWarningTables.stream().filter(ite -> |
|
|
|
Objects.equals(ite.getWarningTime(), jsonObject.getDate("earlyWorningIssueDate")) |
|
|
|
&& Objects.equals(ite.getWarningDescription(), jsonObject.getString("earlyWorningContent")) |
|
|
|
&& Objects.equals(ite.getWarningType(), UniversalEnum.TWO.getValue())).collect(Collectors.toList()); |
|
|
|
if (collect.size() == UniversalEnum.ZERO.getNumber()) { |
|
|
|
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); |
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
//redisCache.setCacheList(UniversalEnum.CURRENT_WEATHER_AND_FORECAST_INFORMATION.getValue(), data);
|
|
|
|
|
|
|
|
|
|
|
@ -318,7 +321,33 @@ public class WeatherForecastController extends BaseController { |
|
|
|
JSONObject jsonResult = JSONObject.parseObject(response.body().string()); |
|
|
|
if (jsonResult.getInteger("code") == UniversalEnum.TWO_HUNDRED.getNumber()) { |
|
|
|
JSONArray jsonArray = jsonResult.getJSONArray("data"); |
|
|
|
List<Object> collect = jsonArray.stream().filter(item -> { |
|
|
|
//List<Object> collect = 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());
|
|
|
|
// //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());
|
|
|
|
//if (collect.size() != UniversalEnum.ZERO.getNumber()) {
|
|
|
|
// redisCache.deleteObject("currentWeatherWarningInformationQuery");
|
|
|
|
// redisCache.setCacheList("currentWeatherWarningInformationQuery", collect);
|
|
|
|
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()) |
|
|
@ -340,14 +369,10 @@ public class WeatherForecastController extends BaseController { |
|
|
|
//} else {
|
|
|
|
// return false;
|
|
|
|
//}
|
|
|
|
}).collect(Collectors.toList()); |
|
|
|
if (collect.size() != UniversalEnum.ZERO.getNumber()) { |
|
|
|
redisCache.deleteObject("currentWeatherWarningInformationQuery"); |
|
|
|
redisCache.setCacheList("currentWeatherWarningInformationQuery", collect); |
|
|
|
return AjaxResult.success(collect); |
|
|
|
} else { |
|
|
|
return AjaxResult.success(redisCache.getCacheList("currentWeatherWarningInformationQuery")); |
|
|
|
} |
|
|
|
}).collect(Collectors.toList())); |
|
|
|
//} else {
|
|
|
|
// return AjaxResult.success(redisCache.getCacheList("currentWeatherWarningInformationQuery"));
|
|
|
|
//}
|
|
|
|
} else { |
|
|
|
return AjaxResult.error(jsonResult.getInteger("code"), UniversalEnum.REQUEST_FAILED.getValue()); |
|
|
|
} |
|
|
|