소스 검색

气象预报数据下载

hdc 2 년 전
부모
커밋
0fe7a5b931
1개의 변경된 파일5개의 추가작업 그리고 1개의 파일을 삭제
  1. 5 1
      tongfei_river_data_collection/src/main/java/com/ublinkage/datacollection/service/QxybDataService.java

+ 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);