✅ 金蝶客商定时同步补充执行日志并新增手动触发测试类

This commit is contained in:
刘泉佳
2026-09-20 16:45:56 +08:00
parent 719ec4e8f6
commit a78aa770c7
4 changed files with 76 additions and 14 deletions
@@ -193,16 +193,6 @@ public class CustomerArchiveController extends BladeController {
return R.data(customerArchiveService.syncKingdee(id));
}
/**
* 金蝶客商数据定时同步测试入口:手动触发 syncKingdeeCustomerData 定时任务逻辑,便于联调验证
*/
@PostMapping("/sync-kingdee-data-test")
@ApiOperationSupport(order = 13)
@Operation(summary = "金蝶客商数据同步测试", description = "手动触发定时任务逻辑:自动推送待推送客商(approved 且 none/failed),并联动已同步客商的金蝶使用状态")
public R<String> syncKingdeeCustomerDataTest() {
return R.data(customerArchiveService.syncKingdeeCustomerData());
}
/**
* 评分明细模板
*/
@@ -37,7 +37,7 @@ import org.springblade.core.tool.jackson.JsonUtil;
import org.springblade.core.tool.utils.BeanUtil;
import org.springblade.core.tool.utils.Func;
import org.springblade.core.tool.utils.SpringUtil;
import org.springblade.core.tool.utils.StringUtil;
import org.springblade.system.pojo.entity.UserCustomerScope;
import org.springblade.thirdparty.bfi.constant.BfiConstant;
import org.springblade.thirdparty.bfi.pojo.dto.BfiCustomerQueryDTO;
import org.springblade.thirdparty.bfi.pojo.vo.BfiBillSaveResultErrorVO;
@@ -76,17 +76,16 @@ import org.springblade.transport.pojo.entity.CustomerInvoiceContact;
import org.springblade.transport.pojo.entity.CustomerInvoiceInfo;
import org.springblade.transport.pojo.entity.CustomerReceiptAccount;
import org.springblade.transport.pojo.entity.PaymentApplication;
import org.springblade.transport.pojo.vo.CreditRatingStandardVO;
import org.springblade.transport.pojo.vo.CustomerArchiveVO;
import org.springblade.transport.pojo.vo.CustomerChangeRecordVO;
import org.springblade.transport.pojo.vo.CustomerContactVO;
import org.springblade.transport.pojo.vo.CustomerCreditScoreDetailVO;
import org.springblade.transport.pojo.vo.CustomerCreditScoreVO;
import org.springblade.transport.pojo.vo.CreditRatingStandardVO;
import org.springblade.transport.pojo.vo.CustomerInvoiceContactVO;
import org.springblade.transport.pojo.vo.CustomerInvoiceInfoVO;
import org.springblade.transport.pojo.vo.CustomerReceiptAccountVO;
import org.springblade.transport.service.ICustomerArchiveService;
import org.springblade.system.pojo.entity.UserCustomerScope;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -456,11 +455,13 @@ public class CustomerArchiveServiceImpl extends BaseServiceImpl<CustomerArchiveM
@Override
public String syncKingdeeCustomerData() {
log.info("金蝶客商数据定时同步开始");
// ① 待推送客商:审批通过且未推送/推送失败,复用单条推送(A902-1 复查 + A902-2 保存),单条失败不中断批次
List<CustomerArchive> pendingList = list(Wrappers.<CustomerArchive>lambdaQuery()
.eq(CustomerArchive::getApprovalStatus, APPROVAL_APPROVED)
.in(CustomerArchive::getKingdeeStatus, KINGDEE_STATUS_NONE, KINGDEE_STATUS_FAILED)
.orderByAsc(CustomerArchive::getId));
log.info("金蝶客商数据定时同步查询到待推送客商 {} 条", pendingList.size());
ICustomerArchiveService proxy = self();
int pushed = 0;
int existed = 0;
@@ -470,10 +471,16 @@ public class CustomerArchiveServiceImpl extends BaseServiceImpl<CustomerArchiveM
CustomerArchive after = proxy.syncKingdee(customer.getId());
if (Objects.equals(after.getKingdeeStatus(), KINGDEE_STATUS_SYNCED)) {
pushed++;
log.info("金蝶客商数据定时同步推送成功,id={},unifiedCreditCode={}",
customer.getId(), customer.getUnifiedCreditCode());
} else if (Objects.equals(after.getKingdeeStatus(), KINGDEE_STATUS_EXIST)) {
existed++;
log.info("金蝶客商数据定时同步金蝶已有档案跳过推送,id={},unifiedCreditCode={}",
customer.getId(), customer.getUnifiedCreditCode());
} else {
pushFailed++;
log.warn("金蝶客商数据定时同步推送失败,id={},unifiedCreditCode={},kingdeeStatus={},failReason={}",
customer.getId(), customer.getUnifiedCreditCode(), after.getKingdeeStatus(), after.getKingdeeFailReason());
}
} catch (Exception exception) {
pushFailed++;
@@ -490,6 +497,7 @@ public class CustomerArchiveServiceImpl extends BaseServiceImpl<CustomerArchiveM
int disabled = 0;
int disableFailed = 0;
if (!enabledList.isEmpty()) {
log.info("金蝶客商数据定时同步查询到已同步可用客商 {} 条,开始联动金蝶使用状态", enabledList.size());
List<String> creditCodes = enabledList.stream()
.map(CustomerArchive::getUnifiedCreditCode)
.filter(Func::isNotEmpty)
@@ -505,6 +513,8 @@ public class CustomerArchiveServiceImpl extends BaseServiceImpl<CustomerArchiveM
try {
if (proxy.disableCustomerFromKingdee(customer.getId())) {
disabled++;
log.info("金蝶侧客商已停用,联动停用客商档案成功,id={},unifiedCreditCode={}",
customer.getId(), customer.getUnifiedCreditCode());
}
} catch (Exception exception) {
disableFailed++;
@@ -513,8 +523,10 @@ public class CustomerArchiveServiceImpl extends BaseServiceImpl<CustomerArchiveM
}
}
}
return "待推送 " + pendingList.size() + " 条(推送成功 " + pushed + ",金蝶已有 " + existed
String summary = "待推送 " + pendingList.size() + " 条(推送成功 " + pushed + ",金蝶已有 " + existed
+ ",失败 " + pushFailed + "),停用联动 " + disabled + " 条(失败 " + disableFailed + ")";
log.info("金蝶客商数据定时同步结束:{}", summary);
return summary;
}
@Override