46 lines
1.6 KiB
C#
46 lines
1.6 KiB
C#
using System.Reflection;
|
|
using JNPF;
|
|
using JNPF.Common.Extension;
|
|
using Tnb.WarehouseMgr.Entities.Attributes;
|
|
using Tnb.WarehouseMgr.Entities.Dto;
|
|
using Tnb.WarehouseMgr.Interfaces;
|
|
|
|
namespace Tnb.WarehouseMgr
|
|
{
|
|
[Caller("app")]
|
|
public class PdaStroageService : IWHStorageService
|
|
{
|
|
private static readonly Dictionary<string, BaseWareHouseService> _serviceMap = new(StringComparer.OrdinalIgnoreCase);
|
|
static PdaStroageService()
|
|
{
|
|
List<Type> serviceTypes = App.EffectiveTypes.Where(u => u.IsClass && !u.IsInterface && !u.IsAbstract && typeof(IPdaStroage).IsAssignableFrom(u) && u.IsSubclassOf(typeof(BaseWareHouseService))).ToList();
|
|
foreach (Type? serviceType in serviceTypes)
|
|
{
|
|
string? bizTypeId = serviceType.GetCustomAttribute<ServiceModuleAttribute>()?.BizTypeId;
|
|
if (!bizTypeId.IsNullOrEmpty())
|
|
{
|
|
_serviceMap[bizTypeId!] = (BaseWareHouseService)App.GetService(serviceType)!;
|
|
}
|
|
}
|
|
}
|
|
|
|
public async Task Do(WareHouseUpInput input)
|
|
{
|
|
if (_serviceMap.ContainsKey(input.bizTypeId))
|
|
{
|
|
await _serviceMap[input.bizTypeId].ModifyAsync(input);
|
|
}
|
|
else
|
|
{
|
|
foreach (var key in _serviceMap.Keys)
|
|
{
|
|
if (key.Contains(input.bizTypeId))
|
|
{
|
|
await _serviceMap[input.bizTypeId].ModifyAsync(input);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|