|
|
|
@ -185,11 +185,11 @@ public abstract class SyncAccountsJobAbstract {
|
|
|
|
|
CJTRequest cjtRequest = null;
|
|
|
|
|
CJTRequestBody cjtRequestBody = null;
|
|
|
|
|
Integer page = 0;
|
|
|
|
|
Integer total = 0;
|
|
|
|
|
LarkCompanyRelation companyRelation = context.getCompanyRelation();
|
|
|
|
|
LarkTableRelation tableRelation = context.getTableRelation();
|
|
|
|
|
LarkTableRequest addRecordRequest = new LarkTableRequest(companyRelation.getAppId(), companyRelation.getSecret(), tableRelation.getToAppToken(), tableRelation.getToTableId());
|
|
|
|
|
while (page <= total) {
|
|
|
|
|
List<List<String>> rows = new ArrayList<>();
|
|
|
|
|
do {
|
|
|
|
|
try {
|
|
|
|
|
//初始化数据
|
|
|
|
|
if (cjtRequestBody == null) {
|
|
|
|
@ -203,13 +203,9 @@ public abstract class SyncAccountsJobAbstract {
|
|
|
|
|
cjtRequest.setOpenToken(generateToken(context));
|
|
|
|
|
//请求接口并序列化数据
|
|
|
|
|
CJTResponseBodyDetail response = request(cjtRequest);
|
|
|
|
|
//同步总页数方便循环
|
|
|
|
|
total = response.getTotalPageNum();
|
|
|
|
|
//实际返回数据
|
|
|
|
|
List<List<String>> rows = response.getRows();
|
|
|
|
|
if (CollectionUtils.isEmpty(rows)){
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
rows = response.getRows();
|
|
|
|
|
if (!CollectionUtils.isEmpty(rows)){
|
|
|
|
|
Map<String, String> existKeyMap = getExistKeyMap(cjtRequest,response.getColumns(), rows);
|
|
|
|
|
//批量同步飞书
|
|
|
|
|
List<String> errorCodeList = syncLarkBatch(response.getColumns(), rows, existKeyMap,addRecordRequest);
|
|
|
|
@ -217,13 +213,14 @@ public abstract class SyncAccountsJobAbstract {
|
|
|
|
|
String errorKey = String.join(",", errorCodeList);
|
|
|
|
|
throw new RuntimeException(String.format("存在同步失败的记录 %s",errorKey));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
log.error("{} exception", this.getClassName(), e);
|
|
|
|
|
throw new RuntimeException(buildErrorBody(cjtRequest, e.getMessage()));
|
|
|
|
|
} finally {
|
|
|
|
|
page++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}while (!CollectionUtils.isEmpty(rows));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private List<String> getUniqueKey(List<String> keyList,List<List<String>> rows) {
|
|
|
|
|