diff --git a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/CJT/SyncAccountsJobAbstract.java b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/CJT/SyncAccountsJobAbstract.java index d17f3d8..c6c5429 100644 --- a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/CJT/SyncAccountsJobAbstract.java +++ b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/CJT/SyncAccountsJobAbstract.java @@ -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> rows = new ArrayList<>(); + do { try { //初始化数据 if (cjtRequestBody == null) { @@ -203,19 +203,16 @@ public abstract class SyncAccountsJobAbstract { cjtRequest.setOpenToken(generateToken(context)); //请求接口并序列化数据 CJTResponseBodyDetail response = request(cjtRequest); - //同步总页数方便循环 - total = response.getTotalPageNum(); //实际返回数据 - List> rows = response.getRows(); - if (CollectionUtils.isEmpty(rows)){ - return; - } - Map existKeyMap = getExistKeyMap(cjtRequest,response.getColumns(), rows); - //批量同步飞书 - List errorCodeList = syncLarkBatch(response.getColumns(), rows, existKeyMap,addRecordRequest); - if (!CollectionUtils.isEmpty(errorCodeList)){ - String errorKey = String.join(",", errorCodeList); - throw new RuntimeException(String.format("存在同步失败的记录 %s",errorKey)); + rows = response.getRows(); + if (!CollectionUtils.isEmpty(rows)){ + Map existKeyMap = getExistKeyMap(cjtRequest,response.getColumns(), rows); + //批量同步飞书 + List errorCodeList = syncLarkBatch(response.getColumns(), rows, existKeyMap,addRecordRequest); + if (!CollectionUtils.isEmpty(errorCodeList)){ + String errorKey = String.join(",", errorCodeList); + throw new RuntimeException(String.format("存在同步失败的记录 %s",errorKey)); + } } } catch (Exception e) { log.error("{} exception", this.getClassName(), e); @@ -223,7 +220,7 @@ public abstract class SyncAccountsJobAbstract { } finally { page++; } - } + }while (!CollectionUtils.isEmpty(rows)); } private List getUniqueKey(List keyList,List> rows) {