调整,wms通用逻辑代码

This commit is contained in:
alex
2023-06-19 15:01:37 +08:00
parent 076cd0c641
commit 8bcc7958c9
28 changed files with 232 additions and 47 deletions

View File

@@ -13,6 +13,7 @@ using JNPF.VisualDev;
using Microsoft.AspNetCore.Mvc;
using Tnb.WarehouseMgr.Entities.Attributes;
using Tnb.WarehouseMgr.Entities.Dto;
using Tnb.WarehouseMgr.Interfaces;
namespace Tnb.WarehouseMgr
{
@@ -20,29 +21,27 @@ namespace Tnb.WarehouseMgr
[Route("api/[area]/[controller]/[action]")]
public class BaseWareHouseService : IOverideVisualDevService, IDynamicApiController, ITransient
{
private static Dictionary<string, BaseWareHouseService> _serviceMap = new Dictionary<string, BaseWareHouseService>(StringComparer.OrdinalIgnoreCase);
private static Dictionary<string, IWHStorageService> _stroageMap = new Dictionary<string, IWHStorageService>(StringComparer.OrdinalIgnoreCase);
public OverideVisualDevFunc OverideFuncs { get; } = new OverideVisualDevFunc();
static BaseWareHouseService()
{
var serviceTypes = App.EffectiveTypes.Where(u => u.IsClass && !u.IsInterface && !u.IsAbstract && u.IsSubclassOf(typeof(BaseWareHouseService))).ToList();
var serviceTypes = App.EffectiveTypes.Where(u => u.IsClass && !u.IsInterface && !u.IsAbstract && typeof(IWHStorageService).IsAssignableFrom(u)).ToList();
foreach (var serviceType in serviceTypes)
{
var bizTypeId = serviceType.GetCustomAttribute<ServiceModuleAttribute>()?.BizTypeId;
if (!bizTypeId.IsNullOrEmpty())
var callerName = serviceType.GetCustomAttribute<CallerAttribute>()?.Name;
if (!callerName.IsNullOrEmpty())
{
_serviceMap[bizTypeId!] = (BaseWareHouseService)App.GetService(serviceType)!;
_stroageMap[callerName!] = (IWHStorageService)Activator.CreateInstance(serviceType)!;
}
}
}
protected async Task DoUpdate(WareHouseUpInput input)
{
if (_serviceMap.ContainsKey(input.bizTypeId))
if (_stroageMap.ContainsKey(input.loginType))
{
await _serviceMap[input.bizTypeId].ModifyAsync(input);
await _stroageMap[input.loginType].Do(input);
}
}