Parcourir la source

修复 一张图获取孢子仪数据接口响应超时的问题

zhaiyifei il y a 1 an
Parent
commit
de4e66a7ff

+ 23 - 25
agmp_fms/trunk/agmp-fms/src/main/java/com/yunfeiyun/agmp/fms/controller/FmsConsoleController.java

@@ -307,34 +307,32 @@ public class FmsConsoleController {
         }catch (Exception e){
             throw new BizException(ErrorCode.WEATHER_PARAM_GET_ERROR);
         }
-
-        String result = WeatherUtil.getWeatherNearlySevenDays(weatherReqVo);
-        if (StringUtils.isEmpty(result)) {
-            throw new BizException(ErrorCode.FMS_WEATHER_SEARCH_FAILED);
-        }
-        FmsWeatherInfoResVo fmsWeatherInfoResVo = JSONObject.parseObject(result, FmsWeatherInfoResVo.class);
-        if (null == fmsWeatherInfoResVo) {
+        FmsWeatherInfoResVo fmsWeatherInfoResVo = null;
+        try {
+            String result = WeatherUtil.getWeatherNearlySevenDays(weatherReqVo);
+            JSONObject resultObj = JSONObject.parseObject(result).getJSONObject("data").getJSONObject("content");
+            fmsWeatherInfoResVo = JSONObject.parseObject(resultObj.toString(), FmsWeatherInfoResVo.class);
+            Map<String, Object> map = new HashMap<>();
+            if (!StringUtils.isEmpty(fmsWeatherInfoResVo.getCityid())) {
+                map = iFmsSolarService.getSysZoneByZoneCode(fmsWeatherInfoResVo.getCityid());
+            }
+            List<FmsWeatherInfoResVo> weatherList = new ArrayList<>();
+            JSONArray data = resultObj.getJSONArray("data");
+            if (data != null) {
+                for (int i = 0; i < data.size(); i++) {
+                    String str = data.getString(i);
+                    FmsWeatherInfoResVo weatherResVo = JSONObject.parseObject(str, FmsWeatherInfoResVo.class);
+                    weatherResVo.setCity(fmsWeatherInfoResVo.getCity());
+                    weatherResVo.setZoneProvincezh(map.get("zoneProvincezh") == null ? "" : map.get("zoneProvincezh").toString());
+                    weatherResVo.setZoneCapitalzh(map.get("zoneCapitalzh") == null ? "" : map.get("zoneCapitalzh").toString());
+                    weatherList.add(weatherResVo);
+                }
+            }
+            resultMap.put("weather", weatherList);
+        }catch (Exception e){
             throw new BizException(ErrorCode.FMS_WEATHER_SEARCH_FAILED);
         }
-        Map<String, Object> map = new HashMap<>();
-        if (!StringUtils.isEmpty(fmsWeatherInfoResVo.getCityid())) {
-            map = iFmsSolarService.getSysZoneByZoneCode(fmsWeatherInfoResVo.getCityid());
-        }
 
-        JSONObject jsonObject = JSONObject.parseObject(result);
-        JSONArray data = jsonObject.getJSONArray("data");
-        List<FmsWeatherInfoResVo> weatherList = new ArrayList<>();
-        if (data != null) {
-            for (int i = 0; i < data.size(); i++) {
-                String str = data.getString(i);
-                FmsWeatherInfoResVo weatherResVo = JSONObject.parseObject(str, FmsWeatherInfoResVo.class);
-                weatherResVo.setCity(fmsWeatherInfoResVo.getCity());
-                weatherResVo.setZoneProvincezh(map.get("zoneProvincezh") == null ? "" : map.get("zoneProvincezh").toString());
-                weatherResVo.setZoneCapitalzh(map.get("zoneCapitalzh") == null ? "" : map.get("zoneCapitalzh").toString());
-                weatherList.add(weatherResVo);
-            }
-        }
-        resultMap.put("weather", weatherList);
     }
 
     public void getLandStat(ScreenDataReqVo reqVo, Map<String, Object> resultMap, boolean isValid) {