Browse Source

优化气象预警返回参数

develop
zhaoxianglong 5 months ago
parent
commit
1a7fae8e70
  1. 43
      zc-business/src/main/java/com/zc/business/controller/WeatherForecastController.java

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

@ -80,6 +80,8 @@ public class WeatherForecastController extends BaseController {
return;
}
JSONArray data = (JSONArray) JSON.toJSON(ajaxResult.get("data"));
if (data.size() > UniversalEnum.ZERO.getNumber()) {
List<DcNoStakeWarningTable> dcNoStakeWarningTables = noStakeWarningTableService.listDcNoStakeWarningTable(new DcNoStakeWarningTable(), null, null);
data.forEach(item -> {
JSONObject jsonObject = (JSONObject) JSON.toJSON(item);
@ -204,6 +206,7 @@ public class WeatherForecastController extends BaseController {
}
});
}
//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());
}

Loading…
Cancel
Save