✨ 金蝶结果定时任务编排应收勾稽纠偏与开票结果回写子流程

This commit is contained in:
刘泉佳
2026-09-21 19:14:38 +08:00
parent 39ffac15e2
commit b454bdc6e3
@@ -21,17 +21,21 @@ package org.springblade.transport.task;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.transport.service.IFormalSettlementService;
import org.springblade.transport.service.IInvoiceApplicationService;
import org.springblade.transport.service.IPaymentApplicationService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
/**
* 金蝶付款结果定时回写任务
* 金蝶结果定时回写任务
* <p>
* 定时查询金蝶(星瀚)付款结果并更新付款信息与履约付款数据:
* A103-2 付款申请单查询回填金蝶单据编号与单据状态,A103-4 付款处理查询回填付款记录。
* 业务逻辑收敛在 {@link IPaymentApplicationService#syncKingdeePaymentResult()},便于手动触发联调。
* 定时查询金蝶(星瀚)结果并回写 TMS 单据,编排三个子流程(各自独立 try/catch,互不影响):
* ① A103-2/A103-4 付款结果:回填付款申请单据编号、单据状态与付款记录;
* ② A302-4 应收勾稽纠偏:应收结算单回填金蝶应收单编号、生成失败纠偏为已同步;
* ③ A303-5 开票结果回写:开票申请发票结果落库并推进开票完成。
* 各子流程业务逻辑收敛在对应服务方法,便于手动触发联调。
* <p>
* 调度配置(Nacos thirdParty.bfi.payResult.*):syncEnabled 开关、cron 表达式。
*
@@ -43,22 +47,39 @@ import org.springframework.stereotype.Component;
public class PaymentKingdeeResultTask {
private final IPaymentApplicationService paymentApplicationService;
private final IFormalSettlementService formalSettlementService;
private final IInvoiceApplicationService invoiceApplicationService;
/** 付款结果回写开关,默认开启 */
@Value("${thirdParty.bfi.payResult.syncEnabled:false}")
private boolean syncEnabled;
/** 金蝶付款结果回写调度,默认每10分钟执行一次 */
/** 金蝶结果回写调度,默认每10分钟执行一次 */
@Scheduled(cron = "${thirdParty.bfi.payResult.cron:0 */10 * * * ?}")
public void syncKingdeePaymentResult() {
if (!syncEnabled) {
return;
}
// ① A103-2/A103-4 付款结果回写
try {
String summary = paymentApplicationService.syncKingdeePaymentResult();
log.info("定时回写金蝶付款结果:{}", summary);
} catch (Exception exception) {
log.error("定时回写金蝶付款结果异常", exception);
}
// ② A302-4 应收勾稽纠偏
try {
String summary = formalSettlementService.syncKingdeeArResult();
log.info("定时勾稽金蝶应收单:{}", summary);
} catch (Exception exception) {
log.error("定时勾稽金蝶应收单异常", exception);
}
// ③ A303-5 开票结果回写
try {
String summary = invoiceApplicationService.syncKingdeeInvoiceResult();
log.info("定时回写金蝶开票结果:{}", summary);
} catch (Exception exception) {
log.error("定时回写金蝶开票结果异常", exception);
}
}
}