Browse Source

关闭旧推送接口

develop
wangsixiang 5 months ago
parent
commit
2ecf3313e5
  1. 34
      zc-business/src/main/java/com/zc/business/controller/WeatherForecastController.java

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

@ -1,5 +1,6 @@
package com.zc.business.controller;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.ruoyi.common.core.controller.BaseController;
@ -7,6 +8,7 @@ import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.redis.RedisCache;
import com.ruoyi.system.service.ISysConfigService;
import com.zc.business.domain.DcRegion;
import com.zc.business.enums.UniversalEnum;
import com.zc.business.service.impl.DcRegionServiceImpl;
import com.zc.common.core.httpclient.OkHttp;
import com.zc.common.core.httpclient.exception.HttpException;
@ -21,6 +23,7 @@ import javax.annotation.Resource;
import java.io.IOException;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
/**
@ -160,10 +163,33 @@ public class WeatherForecastController extends BaseController {
JSONObject jsonResult = JSONObject.parseObject(response.body().string());
if (jsonResult.getInteger("code") == 200) {
JSONArray data = jsonResult.getJSONArray("data");
if (data.size() != 0) {
redisCache.setCacheList("currentWeatherWarningInformationQuery", data);
return AjaxResult.success(data);
JSONArray jsonArray = jsonResult.getJSONArray("data");
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() != 0) {
redisCache.setCacheList("currentWeatherWarningInformationQuery", collect);
return AjaxResult.success(collect);
} else {
return AjaxResult.success(redisCache.getCacheList("currentWeatherWarningInformationQuery"));
}

Loading…
Cancel
Save