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