From b7410535fd749631132ebe29a273f0f7d7c38298 Mon Sep 17 00:00:00 2001 From: lvzb <35200379@qq.com> Date: Wed, 10 Apr 2024 10:03:08 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=BA=93=E5=AD=98=E4=BA=8B?= =?UTF-8?q?=E5=8A=A1=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../IErpLocationItemAclService.cs | 3 +- .../SfsStoreWithDetailsAppServiceBase.cs | 4 ++- .../ErpLocationItemAclService.cs | 36 +++++++++++++++++++ .../IErpLocationItemAclService.cs | 10 ++++++ .../Win_in.Sfs.Wms.Store.Domain.Acl.csproj | 4 +++ .../Jobs/SfsJobManagerBase.cs | 3 ++ .../Bases/StoreEventHandlerBase.cs | 3 ++ 7 files changed, 61 insertions(+), 2 deletions(-) create mode 100644 be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain.Acl/ErpLocationItem/ErpLocationItemAclService.cs create mode 100644 be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain.Acl/ErpLocationItem/IErpLocationItemAclService.cs diff --git a/be/Modules/Inventory/src/Win_in.Sfs.Wms.Inventory.Domain.Acl/ErpLocationItem/IErpLocationItemAclService.cs b/be/Modules/Inventory/src/Win_in.Sfs.Wms.Inventory.Domain.Acl/ErpLocationItem/IErpLocationItemAclService.cs index 9b52bbfa7..045f69a74 100644 --- a/be/Modules/Inventory/src/Win_in.Sfs.Wms.Inventory.Domain.Acl/ErpLocationItem/IErpLocationItemAclService.cs +++ b/be/Modules/Inventory/src/Win_in.Sfs.Wms.Inventory.Domain.Acl/ErpLocationItem/IErpLocationItemAclService.cs @@ -1,9 +1,10 @@ using System.Collections.Generic; using System.Threading.Tasks; +using Volo.Abp.DependencyInjection; using Win_in.Sfs.Basedata.Application.Contracts; namespace Win_in.Sfs.Wms.Inventory.Domain.Acl.ErpLocationItem; -public interface IErpLocationItemAclService +public interface IErpLocationItemAclService : ITransientDependency { Task GetFirstAsync(string itemCode, string locationCode); } diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Bases/SfsStoreWithDetailsAppServiceBase.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Bases/SfsStoreWithDetailsAppServiceBase.cs index 891dd4cc1..1d0708cfe 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Bases/SfsStoreWithDetailsAppServiceBase.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Bases/SfsStoreWithDetailsAppServiceBase.cs @@ -12,6 +12,7 @@ using Win_in.Sfs.Wms.Store.Domain; using Win_in.Sfs.Wms.Store.Domain.Acl.Balance; using Win_in.Sfs.Wms.Store.Domain.Acl.DataExportTask; using Win_in.Sfs.Wms.Store.Domain.Acl.Dict; +using Win_in.Sfs.Wms.Store.Domain.Acl.ErpLocationItem; using Win_in.Sfs.Wms.Store.Domain.Acl.File; using Win_in.Sfs.Wms.Store.Domain.Acl.ItemBasic; using Win_in.Sfs.Wms.Store.Domain.Acl.Location; @@ -54,7 +55,8 @@ public abstract class SfsStoreWithDetailsAppServiceBase LazyServiceProvider.LazyGetRequiredService(); - + protected IErpLocationItemAclService ErpLocationItemAclService => + LazyServiceProvider.LazyGetRequiredService(); protected ILocationAclService LocationAclService => LazyServiceProvider.LazyGetRequiredService(); diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain.Acl/ErpLocationItem/ErpLocationItemAclService.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain.Acl/ErpLocationItem/ErpLocationItemAclService.cs new file mode 100644 index 000000000..6772abff1 --- /dev/null +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain.Acl/ErpLocationItem/ErpLocationItemAclService.cs @@ -0,0 +1,36 @@ +using System.Collections.Generic; +using System.Threading.Tasks; +using Volo.Abp.Caching; +using Win_in.Sfs.Basedata.Application.Contracts; +using Win_in.Sfs.Shared.Application; + +namespace Win_in.Sfs.Wms.Store.Domain.Acl.ErpLocationItem; +public class ErpLocationItemAclService + : AclServiceBase, IErpLocationItemAclService +{ + private readonly IErpLocationItemAppService _appService; + private readonly IDistributedCache _cache; + + public ErpLocationItemAclService( + IErpLocationItemAppService appService + , IDistributedCache cache + ) + { + _appService = appService; + _cache = cache; + } + + public virtual async Task GetFirstAsync(string itemCode, string locationCode) + { + var dto = await _cache.GetOrAddItemAsync( + $"{itemCode}:{locationCode}", + async () => await GetFromAppServiceAsync(itemCode, locationCode).ConfigureAwait(false), + CacheMinutes).ConfigureAwait(false); + return dto; + } + + private async Task GetFromAppServiceAsync(string itemCode, string locationCode) + { + return await _appService.CheckItemErpLocationIsAvailable(itemCode, locationCode).ConfigureAwait(false); + } +} diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain.Acl/ErpLocationItem/IErpLocationItemAclService.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain.Acl/ErpLocationItem/IErpLocationItemAclService.cs new file mode 100644 index 000000000..550ef43de --- /dev/null +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain.Acl/ErpLocationItem/IErpLocationItemAclService.cs @@ -0,0 +1,10 @@ +using System.Collections.Generic; +using System.Threading.Tasks; +using Volo.Abp.DependencyInjection; +using Win_in.Sfs.Basedata.Application.Contracts; + +namespace Win_in.Sfs.Wms.Store.Domain.Acl.ErpLocationItem; +public interface IErpLocationItemAclService : ITransientDependency +{ + Task GetFirstAsync(string itemCode, string locationCode); +} diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain.Acl/Win_in.Sfs.Wms.Store.Domain.Acl.csproj b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain.Acl/Win_in.Sfs.Wms.Store.Domain.Acl.csproj index dc2a4974a..ddd4e0cef 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain.Acl/Win_in.Sfs.Wms.Store.Domain.Acl.csproj +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain.Acl/Win_in.Sfs.Wms.Store.Domain.Acl.csproj @@ -18,5 +18,9 @@ + + + + diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Jobs/SfsJobManagerBase.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Jobs/SfsJobManagerBase.cs index 8c5528932..8c0958daa 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Jobs/SfsJobManagerBase.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Jobs/SfsJobManagerBase.cs @@ -21,6 +21,7 @@ using Win_in.Sfs.Message.Application.Contracts; using Win_in.Sfs.Shared.Domain; using Win_in.Sfs.Shared.Domain.Shared; using Win_in.Sfs.Shared.Event; +using Win_in.Sfs.Wms.Store.Domain.Acl.ErpLocationItem; using Win_in.Sfs.Wms.Store.Domain.Acl.Balance; using Win_in.Sfs.Wms.Store.Domain.Acl.DocumentSettings; using Win_in.Sfs.Wms.Store.Domain.Acl.ItemBasic; @@ -52,6 +53,8 @@ public abstract class SfsJobManagerBase protected IItemBasicAclService ItemBasicAclService => LazyServiceProvider.LazyGetRequiredService(); + protected IErpLocationItemAclService ErpLocationItemAclService => LazyServiceProvider.LazyGetRequiredService(); + protected IBalanceAclService BalanceAclService => LazyServiceProvider.LazyGetRequiredService(); protected ITransactionTypeAclService TransactionTypeAclService => LazyServiceProvider.LazyGetRequiredService(); diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Bases/StoreEventHandlerBase.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Bases/StoreEventHandlerBase.cs index a0a433e43..4f549a3fa 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Bases/StoreEventHandlerBase.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Bases/StoreEventHandlerBase.cs @@ -10,6 +10,7 @@ using Volo.Abp.Timing; using Win_in.Sfs.Basedata.Application.Contracts; using Win_in.Sfs.Wms.Inventory.Application.Contracts; using Win_in.Sfs.Wms.Store.Domain.Acl.Balance; +using Win_in.Sfs.Wms.Store.Domain.Acl.ErpLocationItem; using Win_in.Sfs.Wms.Store.Domain.Acl.ItemBasic; using Win_in.Sfs.Wms.Store.Domain.Acl.Location; using Win_in.Sfs.Wms.Store.Domain.Acl.TransactionType; @@ -40,5 +41,7 @@ public abstract class StoreEventHandlerBase : ITransientDependency protected IItemBasicAclService ItemBasicAclService => LazyServiceProvider.LazyGetRequiredService(); + protected IErpLocationItemAclService ErpLocationItemAclService => LazyServiceProvider.LazyGetRequiredService(); + protected IDatabase RedisDB; }