修复问题
This commit is contained in:
@@ -9,8 +9,8 @@ import cn.wepact.dfm.training.dto.entity.*;
|
||||
import cn.wepact.dfm.training.mapper.*;
|
||||
import cn.wepact.dfm.training.util.HttpClientUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.itextpdf.text.log.Logger;
|
||||
import com.itextpdf.text.log.LoggerFactory;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.client.methods.HttpGet;
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
@@ -107,9 +107,14 @@ public class SyncTaskService {
|
||||
// 将返回的数据解析为 JSONObject
|
||||
JSONObject responseJson = new JSONObject(response);
|
||||
|
||||
// 响应中没有data字段(如权限错误),终止同步
|
||||
if (!responseJson.containsKey("data")) {
|
||||
logger.error("全量同步响应中不存在data字段,终止同步 - offset: {}, 响应: {}", offset, response);
|
||||
break;
|
||||
}
|
||||
// 检查返回的 "data" 是否为空
|
||||
if (responseJson.containsKey("data") && responseJson.getJSONArray("data").size() == 0) {
|
||||
System.out.println("Data is empty, exiting the loop.");
|
||||
if (responseJson.getJSONArray("data").size() == 0) {
|
||||
logger.info("全量同步完成,没有更多数据 - offset: {}", offset);
|
||||
break; // 如果 "data" 为空,跳出循环
|
||||
}
|
||||
|
||||
@@ -119,7 +124,7 @@ public class SyncTaskService {
|
||||
|
||||
} catch (JSONException e) {
|
||||
// 如果 JSON 解析出错,打印异常并跳出循环
|
||||
System.err.println("Error parsing JSON response: " + e.getMessage());
|
||||
logger.error("全量同步JSON解析失败 - offset: {}, 错误: {}", offset, e.getMessage());
|
||||
break;
|
||||
}
|
||||
// 解析返回数据并保存到数据库
|
||||
@@ -165,9 +170,14 @@ public class SyncTaskService {
|
||||
// 将返回的数据解析为 JSONObject
|
||||
JSONObject responseJson = new JSONObject(response);
|
||||
|
||||
// 响应中没有data字段(如权限错误),终止同步
|
||||
if (!responseJson.containsKey("data")) {
|
||||
logger.error("增量同步响应中不存在data字段,终止同步 - offset: {}, 响应: {}", offset, response);
|
||||
break;
|
||||
}
|
||||
// 检查返回的 "data" 是否为空
|
||||
if (responseJson.containsKey("data") && responseJson.getJSONArray("data").size() == 0) {
|
||||
System.out.println("Data is empty, exiting the loop.");
|
||||
if (responseJson.getJSONArray("data").size() == 0) {
|
||||
logger.info("增量同步完成,没有更多数据 - offset: {}", offset);
|
||||
break; // 如果 "data" 为空,跳出循环
|
||||
}
|
||||
|
||||
@@ -177,7 +187,7 @@ public class SyncTaskService {
|
||||
|
||||
} catch (JSONException e) {
|
||||
// 如果 JSON 解析出错,打印异常并跳出循环
|
||||
System.err.println("Error parsing JSON response: " + e.getMessage());
|
||||
logger.error("增量同步JSON解析失败 - offset: {}, 错误: {}", offset, e.getMessage());
|
||||
break;
|
||||
}
|
||||
// 解析返回数据并保存到数据库
|
||||
|
||||
@@ -119,8 +119,13 @@ public class SyncUserInfoService {
|
||||
// 将返回的数据解析为 JSONObject
|
||||
JSONObject responseJson = new JSONObject(response);
|
||||
|
||||
// 响应中没有data字段(如权限错误),终止同步
|
||||
if (!responseJson.containsKey("data")) {
|
||||
logger.error("全量同步响应中不存在data字段,终止同步 - offset: {}, 响应: {}", offset, response);
|
||||
break;
|
||||
}
|
||||
// 检查返回的 "data" 是否为空
|
||||
if (responseJson.containsKey("data") && responseJson.getJSONArray("data").size() == 0) {
|
||||
if (responseJson.getJSONArray("data").size() == 0) {
|
||||
logger.info("全量同步完成,没有更多数据 - offset: {}", offset);
|
||||
break; // 如果 "data" 为空,跳出循环
|
||||
}
|
||||
@@ -188,8 +193,13 @@ public class SyncUserInfoService {
|
||||
// 将返回的数据解析为 JSONObject
|
||||
JSONObject responseJson = new JSONObject(response);
|
||||
|
||||
// 响应中没有data字段(如权限错误),终止同步
|
||||
if (!responseJson.containsKey("data")) {
|
||||
logger.error("增量同步响应中不存在data字段,终止同步 - offset: {}, 响应: {}", offset, response);
|
||||
break;
|
||||
}
|
||||
// 检查返回的 "data" 是否为空
|
||||
if (responseJson.containsKey("data") && responseJson.getJSONArray("data").size() == 0) {
|
||||
if (responseJson.getJSONArray("data").size() == 0) {
|
||||
logger.info("增量同步完成,没有更多数据 - offset: {}", offset);
|
||||
break; // 如果 "data" 为空,跳出循环
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user