From aea5493c4cdffa4634bb9e096ffd85083857c3bd Mon Sep 17 00:00:00 2001 From: mahao Date: Mon, 16 Oct 2023 09:38:16 +0800 Subject: [PATCH] =?UTF-8?q?[CI=20SKIP]=20=E5=8F=91=E8=BF=90=E5=90=8C?= =?UTF-8?q?=E6=AD=A5=E6=B7=BB=E5=8A=A0Lock?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Entities/BQ/Syncs/InvoiceSyncQadInvocable.cs | 2 -- .../Entities/BQ/Syncs/JisBBACSeSyncBaseAppService.cs | 9 +++++++-- .../Entities/BQ/Syncs/JisHBPOSeSyncBaseAppService.cs | 9 +++++++-- .../Entities/BQ/Syncs/JitSeSyncAppService.cs | 10 ++++++++++ 4 files changed, 24 insertions(+), 6 deletions(-) diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/InvoiceSyncQadInvocable.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/InvoiceSyncQadInvocable.cs index 3251bc6b..e47a8042 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/InvoiceSyncQadInvocable.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/InvoiceSyncQadInvocable.cs @@ -38,8 +38,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs /// public async Task Invoke() { - await Task.CompletedTask.ConfigureAwait(false); - if (!_globalConfigOptions.IsSyncInvoiceQadState) { return; diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JisBBACSeSyncBaseAppService.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JisBBACSeSyncBaseAppService.cs index 7cd62c05..d20a5bfc 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JisBBACSeSyncBaseAppService.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JisBBACSeSyncBaseAppService.cs @@ -20,6 +20,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs [ApiExplorerSettings(IgnoreApi = true)] public class JisBBACSeSyncBaseAppService : ApplicationService, IInvocable { + private static readonly object _locker = new object(); /// /// WMS数据上下文 /// @@ -61,12 +62,16 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs [HttpPost] public async Task Invoke() { + await Task.CompletedTask.ConfigureAwait(false); if (SeSyncConfigInfo == null) { return; } - await SyncJitRecordAsync().ConfigureAwait(false); - await SyncJisRecordAsync().ConfigureAwait(false); + lock (_locker) + { + SyncJitRecordAsync().Wait(); + SyncJisRecordAsync().Wait(); + } } /// diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JisHBPOSeSyncBaseAppService.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JisHBPOSeSyncBaseAppService.cs index d5074f24..095f0ecb 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JisHBPOSeSyncBaseAppService.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JisHBPOSeSyncBaseAppService.cs @@ -20,6 +20,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs [ApiExplorerSettings(IgnoreApi = true)] public class JisHBPOSeSyncBaseAppService : ApplicationService, IInvocable { + private static readonly object _locker = new object(); /// /// WMS数据上下文 /// @@ -62,12 +63,16 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs [HttpPost] public virtual async Task Invoke() { + await Task.CompletedTask.ConfigureAwait(false); if (SeSyncConfigInfo == null) { return; } - await SyncJitRecordAsync().ConfigureAwait(false); - await SyncJisRecordAsync().ConfigureAwait(false); + lock (_locker) + { + SyncJitRecordAsync().Wait(); + SyncJisRecordAsync().Wait(); + } } /// diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JitSeSyncAppService.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JitSeSyncAppService.cs index 5eecce8d..dcc402b3 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JitSeSyncAppService.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JitSeSyncAppService.cs @@ -21,6 +21,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs [ApiExplorerSettings(IgnoreApi = true)] public class JitSeSyncAppService : ApplicationService, IInvocable { + private static readonly object _locker = new object(); /// /// WMS数据上下文 /// @@ -62,10 +63,19 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs [HttpPost] public async Task Invoke() { + await Task.CompletedTask.ConfigureAwait(false); if (SeSyncConfigInfo == null) { return; } + lock (_locker) + { + SyncJitRecordAsync().Wait(); + } + } + + public async Task SyncJitRecordAsync() + { //同步表名称 var syncTableName = SeSyncConfigInfo.SyncTableName; //同步发运主类型