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; }