Browse Source

气象预报数据下载

hdc 2 years ago
parent
commit
0fe7a5b931

+ 5 - 1
tongfei_river_data_collection/src/main/java/com/ublinkage/datacollection/service/QxybDataService.java

@@ -454,8 +454,12 @@ public class QxybDataService {
             response = client.newCall(request).execute();
             result = response.body().string();
             JSONObject json = JSONObject.parseObject(result);
+            String data = json.getString("data");
+            if (data == null || "[]".equals(data) || "{}".equals(data)) {
+                throw new RuntimeException("无有效数据");
+            }
             Integer code = json.getInteger("code");
-            if (code == 200) {
+            if (code != null && code == 200) {
                 return result;
             } else {
                 throw new RuntimeException(result);