From a9eb1d82d4970aac06fe3605c1efcec9ae668a40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E6=B3=89=E4=BD=B3?= <1107186916@qq.com> Date: Tue, 29 Sep 2026 12:12:59 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=94=B6=E6=AC=BE=E8=AE=A4=E9=A2=86?= =?UTF-8?q?=E6=8E=A8=E9=80=81=E9=87=91=E8=9D=B6=E5=AE=9A=E6=97=B6=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1=E5=A2=9E=E5=8A=A0single-flight=E5=88=86=E5=B8=83?= =?UTF-8?q?=E5=BC=8F=E9=94=81=E5=8F=8ANacos=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/ReceiptFlowServiceImpl.java | 38 ++++++++++++++++--- doc/nacos/blade-dev.yaml | 9 +++++ doc/nacos/blade-prod.yaml | 9 +++++ doc/nacos/third-party-api.yaml | 9 +++++ 4 files changed, 59 insertions(+), 6 deletions(-) diff --git a/blade-service/blade-transport/src/main/java/org/springblade/transport/service/impl/ReceiptFlowServiceImpl.java b/blade-service/blade-transport/src/main/java/org/springblade/transport/service/impl/ReceiptFlowServiceImpl.java index 3cba039a..c5f1bee1 100644 --- a/blade-service/blade-transport/src/main/java/org/springblade/transport/service/impl/ReceiptFlowServiceImpl.java +++ b/blade-service/blade-transport/src/main/java/org/springblade/transport/service/impl/ReceiptFlowServiceImpl.java @@ -63,8 +63,10 @@ import org.springblade.transport.pojo.entity.ReceiptFlowRecord; import org.springblade.transport.pojo.vo.ReceiptFlowVO; import org.springblade.transport.service.IFormalSettlementService; import org.springblade.transport.service.IReceiptFlowService; +import org.springblade.transport.support.KingdeeSyncLockSupport; import org.springblade.transport.support.TransportBusinessSupport; import org.springblade.transport.wrapper.ReceiptFlowWrapper; +import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.support.TransactionTemplate; @@ -115,6 +117,10 @@ public class ReceiptFlowServiceImpl extends BaseServiceImpl selectPage(IPage page, ReceiptFlowVO query) { @@ -691,15 +705,27 @@ public class ReceiptFlowServiceImpl extends BaseServiceImpl - * A301-2 的 claimusers 必填且为单个用户姓名,定时任务无登录人上下文, - * 故按认领人逐人查询公告,按公告id(bill_id)匹配流水。 - * 单条流水推送失败独立消化,不影响同批其他流水。 + * 定时推送金蝶:扫描认领完成且未推送过的流水,按认领人姓名分组重查 A301-2 最新公告后逐条推送。 + * 多副本部署下由 single-flight 分布式锁保证同一轮全局最多一份在跑,已有轮次进行中则本轮跳过。 + * + * @return 执行摘要 */ @Override public String pushClaimByTask() { + return kingdeeSyncLockSupport.runSingleFlight(RECEIPT_CLAIM_PUSH_LOCK_PREFIX, receiptClaimPushLockLeaseSeconds, + "定时推送收款认领", this::executeReceiptClaimPush); + } + + /** + * 定时推送收款认领主体:按认领人姓名串行处理—— + * 先重查该认领人的 A301-2 最新公告并推完其名下全部流水,再到下一个认领人。 + * A301-2 的 claimusers 必填且为单个用户姓名,定时任务无登录人上下文, + * 故按认领人逐人查询公告,按公告id(bill_id)匹配流水。 + * 单条流水推送失败独立消化,不影响同批其他流水。 + * + * @return 执行摘要 + */ + private String executeReceiptClaimPush() { List candidates = list(Wrappers.lambdaQuery() .isNotNull(KingdeeReceiptFlow::getBillId) .in(KingdeeReceiptFlow::getPushStatus, List.of( diff --git a/doc/nacos/blade-dev.yaml b/doc/nacos/blade-dev.yaml index 629c49e9..063e4cc1 100644 --- a/doc/nacos/blade-dev.yaml +++ b/doc/nacos/blade-dev.yaml @@ -164,6 +164,15 @@ thirdParty: syncEnabled: ${BFI_PAY_RESULT_SYNC_ENABLED:true} # 调度 cron,默认每10分钟 cron: ${BFI_PAY_RESULT_CRON:0 */10 * * * ?} + # 收款认领推送金蝶定时任务(A301-3 收款认领结果推送) + receiptClaimPush: + # 推送任务开关,默认关闭(联调稳定后开启) + syncEnabled: ${BFI_RECEIPT_CLAIM_PUSH_SYNC_ENABLED:false} + # 调度 cron,默认每10分钟 + cron: ${BFI_RECEIPT_CLAIM_PUSH_CRON:0 */10 * * * ?} + # single-flight 分布式锁租约秒数,须大于最坏一轮耗时(逐认领人远程查公告+逐条推送), + # 进程异常退出时锁在租约到期后自动释放 + lockLeaseSeconds: ${BFI_RECEIPT_CLAIM_PUSH_LOCK_LEASE_SECONDS:1800} #百度OCR配置,API Key和Secret Key请通过环境变量注入 baidu: diff --git a/doc/nacos/blade-prod.yaml b/doc/nacos/blade-prod.yaml index b031f0ed..dfb6220c 100644 --- a/doc/nacos/blade-prod.yaml +++ b/doc/nacos/blade-prod.yaml @@ -135,6 +135,15 @@ thirdParty: syncEnabled: ${BFI_PAY_RESULT_SYNC_ENABLED:true} # 调度 cron,默认每10分钟 cron: ${BFI_PAY_RESULT_CRON:0 */10 * * * ?} + # 收款认领推送金蝶定时任务(A301-3 收款认领结果推送) + receiptClaimPush: + # 推送任务开关,默认关闭(联调稳定后开启) + syncEnabled: ${BFI_RECEIPT_CLAIM_PUSH_SYNC_ENABLED:false} + # 调度 cron,默认每10分钟 + cron: ${BFI_RECEIPT_CLAIM_PUSH_CRON:0 */10 * * * ?} + # single-flight 分布式锁租约秒数,须大于最坏一轮耗时(逐认领人远程查公告+逐条推送), + # 进程异常退出时锁在租约到期后自动释放 + lockLeaseSeconds: ${BFI_RECEIPT_CLAIM_PUSH_LOCK_LEASE_SECONDS:1800} #百度OCR配置,API Key和Secret Key请通过环境变量注入 baidu: diff --git a/doc/nacos/third-party-api.yaml b/doc/nacos/third-party-api.yaml index 184602fd..49834717 100644 --- a/doc/nacos/third-party-api.yaml +++ b/doc/nacos/third-party-api.yaml @@ -64,3 +64,12 @@ thirdParty: syncEnabled: ${BFI_PAY_RESULT_SYNC_ENABLED:true} # 调度 cron,默认每10分钟 cron: ${BFI_PAY_RESULT_CRON:0 */10 * * * ?} + # 收款认领推送金蝶定时任务(A301-3 收款认领结果推送) + receiptClaimPush: + # 推送任务开关,默认关闭(联调稳定后开启) + syncEnabled: ${BFI_RECEIPT_CLAIM_PUSH_SYNC_ENABLED:false} + # 调度 cron,默认每10分钟 + cron: ${BFI_RECEIPT_CLAIM_PUSH_CRON:0 */10 * * * ?} + # single-flight 分布式锁租约秒数,须大于最坏一轮耗时(逐认领人远程查公告+逐条推送), + # 进程异常退出时锁在租约到期后自动释放 + lockLeaseSeconds: ${BFI_RECEIPT_CLAIM_PUSH_LOCK_LEASE_SECONDS:1800}