生产退料,暂存仓配送优化
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System.Text;
|
||||
using Aop.Api.Domain;
|
||||
using JNPF.Common.Const;
|
||||
using JNPF.Common.Core.Manager;
|
||||
using JNPF.Common.Core.Manager.Files;
|
||||
@@ -19,6 +20,7 @@ using JNPF.Systems.Interfaces.System;
|
||||
using Mapster;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using NPOI.SS.Formula.Functions;
|
||||
using SqlSugar;
|
||||
|
||||
namespace JNPF.Systems;
|
||||
@@ -65,6 +67,8 @@ public class BillRuleService : IBillRullService, IDynamicApiController, ITransie
|
||||
_fileManager = fileManager;
|
||||
}
|
||||
|
||||
public SemaphoreSlim s_getBillNumber = new(1);
|
||||
|
||||
#region Get
|
||||
|
||||
/// <summary>
|
||||
@@ -272,27 +276,42 @@ public class BillRuleService : IBillRullService, IDynamicApiController, ITransie
|
||||
[NonAction]
|
||||
public async Task<string> GetBillNumber(string enCode, bool isCache = false)
|
||||
{
|
||||
string cacheKey = string.Format("{0}{1}_{2}", CommonConst.CACHEKEYBILLRULE, _userManager.TenantId, _userManager.UserId + enCode);
|
||||
string strNumber = string.Empty;
|
||||
if (isCache)
|
||||
try
|
||||
{
|
||||
if (!_cacheManager.Exists(cacheKey))
|
||||
s_getBillNumber.WaitAsync();
|
||||
|
||||
string cacheKey = string.Format("{0}{1}_{2}", CommonConst.CACHEKEYBILLRULE, _userManager.TenantId, _userManager.UserId + enCode);
|
||||
string strNumber = string.Empty;
|
||||
if (isCache)
|
||||
{
|
||||
strNumber = await GetNumber(enCode);
|
||||
await _cacheManager.SetAsync(cacheKey, strNumber, new TimeSpan(0, 3, 0));
|
||||
if (!_cacheManager.Exists(cacheKey))
|
||||
{
|
||||
strNumber = await GetNumber(enCode);
|
||||
await _cacheManager.SetAsync(cacheKey, strNumber, new TimeSpan(0, 3, 0));
|
||||
}
|
||||
else
|
||||
{
|
||||
strNumber = await _cacheManager.GetAsync(cacheKey);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
strNumber = await _cacheManager.GetAsync(cacheKey);
|
||||
strNumber = await GetNumber(enCode);
|
||||
_cacheManager.Set(cacheKey, strNumber, new TimeSpan(0, 3, 0));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
strNumber = await GetNumber(enCode);
|
||||
_cacheManager.Set(cacheKey, strNumber, new TimeSpan(0, 3, 0));
|
||||
}
|
||||
|
||||
return strNumber;
|
||||
return strNumber;
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
Logging.Log.Error("【GetBillNumber】" + ex.Message);
|
||||
Logging.Log.Error("【GetBillNumber】" + ex.StackTrace);
|
||||
throw;
|
||||
}
|
||||
finally
|
||||
{
|
||||
s_getBillNumber.Release();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
Reference in New Issue
Block a user