载具查询返回接口,新增 供应商ID,检验结论,入库时间

This commit is contained in:
alex
2023-08-21 15:06:36 +08:00
parent 807f656792
commit 24fd778f28
4 changed files with 39 additions and 9 deletions

View File

@@ -8,6 +8,7 @@ using System.Text;
using System.Threading.Tasks;
using JNPF;
using JNPF.Common.Extension;
using Microsoft.Extensions.DependencyInjection;
using Tnb.WarehouseMgr.Entities.Attributes;
using Tnb.WarehouseMgr.Entities.Dto;
using Tnb.WarehouseMgr.Interfaces;
@@ -17,21 +18,20 @@ namespace Tnb.WarehouseMgr
[Caller("web")]
public class PcStroageService : IWHStorageService
{
private static Dictionary<string, Func<WareHouseUpInput, Task>> _serviceCallbackMap = new(StringComparer.OrdinalIgnoreCase);
private static Dictionary<string, BaseWareHouseService> _serviceMap = new(StringComparer.OrdinalIgnoreCase);
static PcStroageService()
{
_serviceCallbackMap = App.EffectiveTypes.AsParallel().Where(u => u.IsClass && !u.IsInterface && !u.IsAbstract && !typeof(IPdaStroage).IsAssignableFrom(u)
_serviceMap = App.EffectiveTypes.AsParallel().Where(u => u.IsClass && !u.IsInterface && !u.IsAbstract && !typeof(IPdaStroage).IsAssignableFrom(u)
&& u.IsSubclassOf(typeof(BaseWareHouseService)) && u.GetCustomAttribute<ServiceModuleAttribute>() != null)
.ToDictionary(x => x.GetCustomAttribute<ServiceModuleAttribute>().BizTypeId,
x => (Func<WareHouseUpInput, Task>)Delegate.CreateDelegate(typeof(Func<WareHouseUpInput, Task>), App.GetService(x), x.GetMethod(nameof(WareHouseService.ModifyAsync))));
.ToDictionary(x => x.GetCustomAttribute<ServiceModuleAttribute>().BizTypeId, x => (BaseWareHouseService)App.GetService(x));
}
public async Task Do(WareHouseUpInput input)
{
if (_serviceCallbackMap.ContainsKey(input.bizTypeId))
{
await _serviceCallbackMap[input.bizTypeId].Invoke(input);
}
if (_serviceMap.ContainsKey(input.bizTypeId))
await _serviceMap[input.bizTypeId].ModifyAsync(input);
}
}
}