|
|
@@ -218,10 +218,10 @@ public class JkApiServiceImpl implements IJkApiService {
|
|
|
public List<JSONObject> getApiData(String url,String objectName) throws IOException {
|
|
|
List<JSONObject> objectList = new ArrayList<>();
|
|
|
int page = 1;
|
|
|
- int total = 1;
|
|
|
+ int totalPage = 1;
|
|
|
+ int retryCount = 3;
|
|
|
logger.info("获取建科"+objectName+"请求url:" + url);
|
|
|
- while(total >= page){
|
|
|
-
|
|
|
+ while(totalPage >= page && retryCount > 0){
|
|
|
Request request = buildRequest(url,page);
|
|
|
// 执行请求并获取响应
|
|
|
try {
|
|
|
@@ -237,17 +237,19 @@ public class JkApiServiceImpl implements IJkApiService {
|
|
|
//“0”为成功其余均为失败
|
|
|
String code = jsonObject.getString("code");
|
|
|
if (CODE_SUCCESS.equals(code)) {
|
|
|
+ retryCount = 3;
|
|
|
JSONObject dataObject = jsonObject.getJSONObject(DATA);
|
|
|
//如果是用户接口,调用回调函数
|
|
|
if(INTERFACE_USER.equals(objectName)) {
|
|
|
doUserCallback(dataObject);
|
|
|
}
|
|
|
objectList.add(dataObject);
|
|
|
- total = dataObject.getInteger(TOTAL);
|
|
|
+ int total = dataObject.getInteger(TOTAL);
|
|
|
+ totalPage = (int) Math.ceil((total + DEFAULT_SIZE - 1)/DEFAULT_SIZE);
|
|
|
page++;
|
|
|
continue;
|
|
|
} else {
|
|
|
-
|
|
|
+ retryCount--;
|
|
|
}
|
|
|
} catch (IOException e) {
|
|
|
throw new IOException("获取建科用"+objectName+"信息失败 ", e);
|