令牌放入缓存
This commit is contained in:
@@ -53,9 +53,9 @@ namespace Tnb.WarehouseMgr
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Task<ClaimsPrincipal> GetUserIdentity()
|
protected Task<ClaimsPrincipal> GetUserIdentity(string aToken)
|
||||||
{
|
{
|
||||||
var claims = JWTEncryption.ReadJwtToken(UserManager.AsscessToken)?.Claims;
|
var claims = JWTEncryption.ReadJwtToken(aToken)?.Claims;
|
||||||
ClaimsIdentity toKen = new ClaimsIdentity();
|
ClaimsIdentity toKen = new ClaimsIdentity();
|
||||||
foreach (Claim item in claims)
|
foreach (Claim item in claims)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ using JNPF.Common.Core.Manager;
|
|||||||
using JNPF.Common.Dtos.VisualDev;
|
using JNPF.Common.Dtos.VisualDev;
|
||||||
using JNPF.Common.Enums;
|
using JNPF.Common.Enums;
|
||||||
using JNPF.Common.Extension;
|
using JNPF.Common.Extension;
|
||||||
|
using JNPF.Common.Manager;
|
||||||
using JNPF.Common.Security;
|
using JNPF.Common.Security;
|
||||||
using JNPF.DataEncryption;
|
using JNPF.DataEncryption;
|
||||||
using JNPF.FriendlyException;
|
using JNPF.FriendlyException;
|
||||||
@@ -51,14 +52,23 @@ namespace Tnb.WarehouseMgr
|
|||||||
private readonly IUserManager _userManager;
|
private readonly IUserManager _userManager;
|
||||||
private readonly IBillRullService _billRullService;
|
private readonly IBillRullService _billRullService;
|
||||||
private readonly IWmsCarryService _carryService;
|
private readonly IWmsCarryService _carryService;
|
||||||
|
private readonly ICacheManager _cacheManager;
|
||||||
private const string BizTypeId = "26169472620837";
|
private const string BizTypeId = "26169472620837";
|
||||||
public WmskittingOutService(ISqlSugarRepository<WmsKittingoutH> repository, IWareHouseService warehouseService, IUserManager userManager, IBillRullService billRullService, IWmsCarryService carryService)
|
public WmskittingOutService(
|
||||||
|
ISqlSugarRepository<WmsKittingoutH> repository,
|
||||||
|
IWareHouseService warehouseService,
|
||||||
|
IUserManager userManager,
|
||||||
|
IBillRullService billRullService,
|
||||||
|
IWmsCarryService carryService,
|
||||||
|
ICacheManager cacheManager
|
||||||
|
)
|
||||||
{
|
{
|
||||||
_db = repository.AsSugarClient();
|
_db = repository.AsSugarClient();
|
||||||
_warehouseService = warehouseService;
|
_warehouseService = warehouseService;
|
||||||
_userManager = userManager;
|
_userManager = userManager;
|
||||||
_billRullService = billRullService;
|
_billRullService = billRullService;
|
||||||
_carryService = carryService;
|
_carryService = carryService;
|
||||||
|
_cacheManager = cacheManager;
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 齐套出库(新增状态)
|
/// 齐套出库(新增状态)
|
||||||
@@ -67,8 +77,9 @@ namespace Tnb.WarehouseMgr
|
|||||||
[HttpPost]
|
[HttpPost]
|
||||||
public async Task KittingOutByAdd(CancellationTokenSource? cts = default)
|
public async Task KittingOutByAdd(CancellationTokenSource? cts = default)
|
||||||
{
|
{
|
||||||
if (UserManager.AsscessToken.IsNullOrWhiteSpace()) return;
|
var aToken = await _cacheManager.GetAsync("AsscessToken");
|
||||||
var curUser = await GetUserIdentity();
|
if (aToken.IsNullOrWhiteSpace()) return;
|
||||||
|
var curUser = await GetUserIdentity(aToken);
|
||||||
|
|
||||||
var curDb = _db.CopyNew();
|
var curDb = _db.CopyNew();
|
||||||
try
|
try
|
||||||
@@ -123,8 +134,8 @@ namespace Tnb.WarehouseMgr
|
|||||||
setSortingH.id = SnowflakeIdHelper.NextId();
|
setSortingH.id = SnowflakeIdHelper.NextId();
|
||||||
setSortingH.kittingout_id = ko.id;
|
setSortingH.kittingout_id = ko.id;
|
||||||
setSortingH.seq = ko.seq;
|
setSortingH.seq = ko.seq;
|
||||||
setSortingH.org_id = ko.org_id;
|
setSortingH.org_id = curUser.FindFirst(ClaimConst.CLAINMORGID)?.Value;
|
||||||
setSortingH.create_id = ko.create_id;
|
setSortingH.create_id = curUser.FindFirst(ClaimConst.CLAINMUSERID)?.Value;
|
||||||
setSortingH.create_time = DateTime.Now;
|
setSortingH.create_time = DateTime.Now;
|
||||||
await curDb.Insertable(setSortingH).ExecuteCommandAsync();
|
await curDb.Insertable(setSortingH).ExecuteCommandAsync();
|
||||||
|
|
||||||
@@ -164,6 +175,10 @@ namespace Tnb.WarehouseMgr
|
|||||||
[HttpPost]
|
[HttpPost]
|
||||||
public async Task KittingOutByIsToBeShipped(CancellationTokenSource? cts = default)
|
public async Task KittingOutByIsToBeShipped(CancellationTokenSource? cts = default)
|
||||||
{
|
{
|
||||||
|
var aToken = await _cacheManager.GetAsync("AsscessToken");
|
||||||
|
if (aToken.IsNullOrWhiteSpace()) return;
|
||||||
|
var curUser = await GetUserIdentity(aToken);
|
||||||
|
|
||||||
var curDb = _db.CopyNew();
|
var curDb = _db.CopyNew();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -202,7 +217,7 @@ namespace Tnb.WarehouseMgr
|
|||||||
|
|
||||||
WmsPretaskH preTask = new()
|
WmsPretaskH preTask = new()
|
||||||
{
|
{
|
||||||
org_id = ko.org_id,
|
org_id = curUser.FindFirst(ClaimConst.CLAINMORGID)?.Value,
|
||||||
startlocation_id = sPoint?.location_id!,
|
startlocation_id = sPoint?.location_id!,
|
||||||
startlocation_code = sPoint?.location_code!,
|
startlocation_code = sPoint?.location_code!,
|
||||||
endlocation_id = ePoint?.location_id!,
|
endlocation_id = ePoint?.location_id!,
|
||||||
@@ -223,7 +238,7 @@ namespace Tnb.WarehouseMgr
|
|||||||
area_code = it.Key,
|
area_code = it.Key,
|
||||||
require_id = ko.id,
|
require_id = ko.id,
|
||||||
require_code = ko.bill_code,
|
require_code = ko.bill_code,
|
||||||
create_id = ko.create_id,
|
create_id = curUser.FindFirst(ClaimConst.CLAINMUSERID)?.Value,
|
||||||
create_time = DateTime.Now,
|
create_time = DateTime.Now,
|
||||||
source_id = ko.source_id,
|
source_id = ko.source_id,
|
||||||
source_code = ko.source_code
|
source_code = ko.source_code
|
||||||
@@ -243,14 +258,6 @@ namespace Tnb.WarehouseMgr
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
throw new AppFriendlyException("无可用的载具", 500);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw new AppFriendlyException("无可用的库位", 500);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -386,6 +386,7 @@ public class OAuthService : IDynamicApiController, ITransient
|
|||||||
[HttpGet("Logout")]
|
[HttpGet("Logout")]
|
||||||
public async Task Logout([FromQuery] string ticket)
|
public async Task Logout([FromQuery] string ticket)
|
||||||
{
|
{
|
||||||
|
await _cacheManager.DelAsync("AsscessToken");
|
||||||
|
|
||||||
var tenantId = _userManager.TenantId ?? "default";
|
var tenantId = _userManager.TenantId ?? "default";
|
||||||
var userId = _userManager.UserId ?? "admim";
|
var userId = _userManager.UserId ?? "admim";
|
||||||
@@ -607,6 +608,8 @@ public class OAuthService : IDynamicApiController, ITransient
|
|||||||
|
|
||||||
//modify by ly on 20230804
|
//modify by ly on 20230804
|
||||||
UserManager.AsscessToken = accessToken;
|
UserManager.AsscessToken = accessToken;
|
||||||
|
await _cacheManager.SetAsync("AsscessToken", accessToken,TimeSpan.FromMinutes(30));
|
||||||
|
|
||||||
// 单点登录标识缓存
|
// 单点登录标识缓存
|
||||||
if (_oauthOptions.Enabled) _cacheManager.Set("OnlineTicket_" + input.online_ticket, options.ConfigId);
|
if (_oauthOptions.Enabled) _cacheManager.Set("OnlineTicket_" + input.online_ticket, options.ConfigId);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user