|
@@ -143,60 +143,8 @@ public class QwExternalContactTransferLogServiceImpl extends ServiceImpl<QwExter
|
|
|
|
|
|
|
|
List<QwExternalContactTransferLog> transferLogListEntry = entry.getValue();
|
|
List<QwExternalContactTransferLog> transferLogListEntry = entry.getValue();
|
|
|
|
|
|
|
|
-
|
|
|
|
|
- QwGetTransferParam getTransferParam = new QwGetTransferParam();
|
|
|
|
|
- getTransferParam.setTakeover_userid(keyPartsTakeoverUserId);
|
|
|
|
|
- getTransferParam.setHandover_userid(keyPartsHandoverUserId);
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- // 第一次请求游标为空
|
|
|
|
|
- String cursor = null;
|
|
|
|
|
- List<QwGetTransferResult.Customer> allCustomers = new ArrayList<>();
|
|
|
|
|
-
|
|
|
|
|
- int page = 0;
|
|
|
|
|
- do {
|
|
|
|
|
- page++;
|
|
|
|
|
-
|
|
|
|
|
- // 设置游标(第一次请求可能不需要设置或设为空)
|
|
|
|
|
- if (cursor != null) {
|
|
|
|
|
- getTransferParam.setCursor(cursor);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- // 调用接口
|
|
|
|
|
- QwGetTransferResult transfer = qwApiService.getTransfer(getTransferParam, keyPartsCorpId);
|
|
|
|
|
-
|
|
|
|
|
- // 检查接口返回是否成功
|
|
|
|
|
- if (transfer.getErrcode() != 0) {
|
|
|
|
|
- log.error("获取转移记录失败: errcode={}, errmsg={}, takeover_userid={}, handover_userid={}",
|
|
|
|
|
- transfer.getErrcode(), transfer.getErrmsg(),
|
|
|
|
|
- keyPartsTakeoverUserId, keyPartsHandoverUserId);
|
|
|
|
|
- break;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- // 获取当前页数据
|
|
|
|
|
- List<QwGetTransferResult.Customer> customers = transfer.getCustomer();
|
|
|
|
|
- if (customers != null && !customers.isEmpty()) {
|
|
|
|
|
- allCustomers.addAll(customers);
|
|
|
|
|
- log.info("第 {} 页获取到 {} 条转移记录", page, customers.size());
|
|
|
|
|
- } else {
|
|
|
|
|
- log.info("第 {} 页没有数据", page);
|
|
|
|
|
- // 如果没有数据,也退出循环
|
|
|
|
|
- break;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- // 更新游标,准备下一次请求
|
|
|
|
|
- cursor = transfer.getNext_cursor();
|
|
|
|
|
-
|
|
|
|
|
- // 添加短暂延时,避免请求过快
|
|
|
|
|
- try {
|
|
|
|
|
- Thread.sleep(200);
|
|
|
|
|
- } catch (InterruptedException e) {
|
|
|
|
|
- Thread.currentThread().interrupt();
|
|
|
|
|
- break;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- // 如果next_cursor为空或没有更多数据,则退出循环
|
|
|
|
|
- } while (cursor != null && !cursor.isEmpty() && !"0".equals(cursor));
|
|
|
|
|
|
|
+ List<QwGetTransferResult.Customer> allCustomers = fetchAllTransferCustomers(
|
|
|
|
|
+ keyPartsCorpId, keyPartsTakeoverUserId, keyPartsHandoverUserId);
|
|
|
|
|
|
|
|
List<QwExternalContactTransferLog> transferLogList=new ArrayList<>();
|
|
List<QwExternalContactTransferLog> transferLogList=new ArrayList<>();
|
|
|
|
|
|
|
@@ -225,6 +173,13 @@ public class QwExternalContactTransferLogServiceImpl extends ServiceImpl<QwExter
|
|
|
qwExternalContact.setUserId(transferLog.getTakeoverUserId());
|
|
qwExternalContact.setUserId(transferLog.getTakeoverUserId());
|
|
|
qwExternalContact.setQwUserId(transferLog.getQwUserId());
|
|
qwExternalContact.setQwUserId(transferLog.getQwUserId());
|
|
|
qwExternalContact.setCompanyUserId(transferLog.getCompanyUserId());
|
|
qwExternalContact.setCompanyUserId(transferLog.getCompanyUserId());
|
|
|
|
|
+
|
|
|
|
|
+ QwExternalContact takeoverContact = qwExternalContactMapper.selectQwExternalContactUserIdAndExternalIdAndCompanyId(
|
|
|
|
|
+ transferLog.getExternalUserId(), transferLog.getTakeoverUserId(), transferLog.getCorpId());
|
|
|
|
|
+ if (takeoverContact != null) {
|
|
|
|
|
+ iQwExternalContactService.applyTransferContactInfo(
|
|
|
|
|
+ takeoverContact.getId(), transferLog, transferLog.getExternalContactId());
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
contactList.add(qwExternalContact);
|
|
contactList.add(qwExternalContact);
|
|
|
}
|
|
}
|
|
@@ -264,4 +219,59 @@ public class QwExternalContactTransferLogServiceImpl extends ServiceImpl<QwExter
|
|
|
qwExternalContactTransferLogMapper.updateQwExternalContactByStatus();
|
|
qwExternalContactTransferLogMapper.updateQwExternalContactByStatus();
|
|
|
qwExternalContactTransferLogMapper.updateQwExternalContactTransferLogByStatus();
|
|
qwExternalContactTransferLogMapper.updateQwExternalContactTransferLogByStatus();
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ private List<QwGetTransferResult.Customer> fetchAllTransferCustomers(String corpId, String takeoverUserId, String handoverUserId) {
|
|
|
|
|
+ List<QwGetTransferResult.Customer> onJobCustomers = fetchTransferCustomers(corpId, takeoverUserId, handoverUserId, true);
|
|
|
|
|
+ if (!onJobCustomers.isEmpty()) {
|
|
|
|
|
+ return onJobCustomers;
|
|
|
|
|
+ }
|
|
|
|
|
+ return fetchTransferCustomers(corpId, takeoverUserId, handoverUserId, false);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private List<QwGetTransferResult.Customer> fetchTransferCustomers(String corpId, String takeoverUserId, String handoverUserId, boolean onJobTransfer) {
|
|
|
|
|
+ QwGetTransferParam getTransferParam = new QwGetTransferParam();
|
|
|
|
|
+ getTransferParam.setTakeover_userid(takeoverUserId);
|
|
|
|
|
+ getTransferParam.setHandover_userid(handoverUserId);
|
|
|
|
|
+
|
|
|
|
|
+ String cursor = null;
|
|
|
|
|
+ List<QwGetTransferResult.Customer> allCustomers = new ArrayList<>();
|
|
|
|
|
+ int page = 0;
|
|
|
|
|
+
|
|
|
|
|
+ do {
|
|
|
|
|
+ page++;
|
|
|
|
|
+ if (cursor != null) {
|
|
|
|
|
+ getTransferParam.setCursor(cursor);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ QwGetTransferResult transfer = onJobTransfer
|
|
|
|
|
+ ? qwApiService.getTransfer(getTransferParam, corpId)
|
|
|
|
|
+ : qwApiService.getResignedTransfer(getTransferParam, corpId);
|
|
|
|
|
+
|
|
|
|
|
+ if (transfer.getErrcode() != 0) {
|
|
|
|
|
+ log.warn("获取{}转移记录失败: errcode={}, errmsg={}, takeover_userid={}, handover_userid={}",
|
|
|
|
|
+ onJobTransfer ? "在职" : "离职",
|
|
|
|
|
+ transfer.getErrcode(), transfer.getErrmsg(),
|
|
|
|
|
+ takeoverUserId, handoverUserId);
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ List<QwGetTransferResult.Customer> customers = transfer.getCustomer();
|
|
|
|
|
+ if (customers == null || customers.isEmpty()) {
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ allCustomers.addAll(customers);
|
|
|
|
|
+ log.info("获取{}转移记录第 {} 页: {} 条", onJobTransfer ? "在职" : "离职", page, customers.size());
|
|
|
|
|
+
|
|
|
|
|
+ cursor = transfer.getNext_cursor();
|
|
|
|
|
+ try {
|
|
|
|
|
+ Thread.sleep(200);
|
|
|
|
|
+ } catch (InterruptedException e) {
|
|
|
|
|
+ Thread.currentThread().interrupt();
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ } while (cursor != null && !cursor.isEmpty() && !"0".equals(cursor));
|
|
|
|
|
+
|
|
|
|
|
+ return allCustomers;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|