From 2ecf3313e5c796461bf6ddb54acb2f7e4e05bca2 Mon Sep 17 00:00:00 2001 From: wangsixiang <2970484253@qq.com> Date: Mon, 24 Jun 2024 16:51:24 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=B3=E9=97=AD=E6=97=A7=E6=8E=A8=E9=80=81?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/WeatherForecastController.java | 34 ++++++++++++++++--- 1 file changed, 30 insertions(+), 4 deletions(-) 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 7b8942b0..2c16ff5f 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 @@ -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 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")); }