二楼缓存仓和暂存仓出入库优化

This commit is contained in:
2024-08-08 11:48:51 +08:00
parent 18dac9b6b2
commit 433be346b9
7 changed files with 76 additions and 34 deletions

View File

@@ -1229,9 +1229,9 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
/// <returns></returns>
public async void (object? args)
{
if (s_task送空托到上升降区.CurrentCount == 0)
if (_wareHouseService.s_taskExecuteSemaphore_F2ZCCOutstock.CurrentCount == 0)
return;
await s_task送空托到上升降区.WaitAsync();
await _wareHouseService.s_taskExecuteSemaphore_F2ZCCOutstock.WaitAsync();
Stopwatch stopwatch = new Stopwatch();
stopwatch.Start();
try
@@ -1355,7 +1355,7 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
}
finally
{
s_task送空托到上升降区.Release();
_wareHouseService.s_taskExecuteSemaphore_F2ZCCOutstock.Release();
if (!db_Floor2timer送空托到上升降区.Ado.Transaction.IsNull())
try { await db_Floor2timer送空托到上升降区.Ado.CommitTranAsync(); } catch { };
_wareHouseService.GenTaskExecute();
@@ -1371,9 +1371,9 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
/// <returns></returns>
public async void (object? args)
{
if (s_task送满托到下升降区.CurrentCount == 0)
if (_wareHouseService.s_taskExecuteSemaphore_F2ZCCOutstock.CurrentCount == 0)
return;
await s_task送满托到下升降区.WaitAsync();
await _wareHouseService.s_taskExecuteSemaphore_F2ZCCOutstock.WaitAsync();
Stopwatch stopwatch = new Stopwatch();
stopwatch.Start();
try
@@ -1533,7 +1533,7 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
}
finally
{
s_task送满托到下升降区.Release();
_wareHouseService.s_taskExecuteSemaphore_F2ZCCOutstock.Release();
if (!db_Floor2timer送满托到下升降区.Ado.Transaction.IsNull())
try { await db_Floor2timer送满托到下升降区.Ado.CommitTranAsync(); } catch { };
_wareHouseService.GenTaskExecute();
@@ -1550,9 +1550,9 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
/// <returns></returns>
public async void (object? args)
{
if (s_task移走上升降区未生成预任务且满托的料架.CurrentCount == 0)
if (_wareHouseService.s_taskExecuteSemaphore_F2ZCCInstock.CurrentCount == 0)
return;
await s_task移走上升降区未生成预任务且满托的料架.WaitAsync();
await _wareHouseService.s_taskExecuteSemaphore_F2ZCCInstock.WaitAsync();
Stopwatch stopwatch = new Stopwatch();
stopwatch.Start();
try
@@ -1658,7 +1658,7 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
}
finally
{
s_task移走上升降区未生成预任务且满托的料架.Release();
_wareHouseService.s_taskExecuteSemaphore_F2ZCCInstock.Release();
if (!db_Floor2timer移走上升降区未生成预任务且满托的料架.Ado.Transaction.IsNull())
// 数据库连接断开时会报错
try { await db_Floor2timer移走上升降区未生成预任务且满托的料架.Ado.CommitTranAsync(); } catch { };
@@ -1676,9 +1676,9 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
/// <returns></returns>
public async void (object? args)
{
if (s_task移走下升降区未生成预任务且空托的料架.CurrentCount == 0)
if (_wareHouseService.s_taskExecuteSemaphore_F2ZCCInstock.CurrentCount == 0)
return;
await s_task移走下升降区未生成预任务且空托的料架.WaitAsync();
await _wareHouseService.s_taskExecuteSemaphore_F2ZCCInstock.WaitAsync();
Stopwatch stopwatch = new Stopwatch();
stopwatch.Start();
try
@@ -1789,7 +1789,7 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
}
finally
{
s_task移走下升降区未生成预任务且空托的料架.Release();
_wareHouseService.s_taskExecuteSemaphore_F2ZCCInstock.Release();
if (!db_Floor2timer移走下升降区未生成预任务且空托的料架.Ado.Transaction.IsNull())
try { await db_Floor2timer移走下升降区未生成预任务且空托的料架.Ado.CommitTranAsync(); } catch { };
_wareHouseService.GenTaskExecute();
@@ -2539,9 +2539,9 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
// 二楼料架配送
Floor2timer送空托到上升降区 = new Timer(, null, TimeSpan.Zero, TimeSpan.FromSeconds(30));
Floor2timer送满托到下升降区 = new Timer(, null, TimeSpan.Zero, TimeSpan.FromSeconds(30));
Floor2timer送满托到下升降区 = new Timer(, null, TimeSpan.FromSeconds(5), TimeSpan.FromSeconds(30));
Floor2timer移走上升降区未生成预任务且满托的料架 = new Timer(, null, TimeSpan.Zero, TimeSpan.FromSeconds(30));
Floor2timer移走下升降区未生成预任务且空托的料架 = new Timer(, null, TimeSpan.Zero, TimeSpan.FromSeconds(30));
Floor2timer移走下升降区未生成预任务且空托的料架 = new Timer(, null, TimeSpan.FromSeconds(5), TimeSpan.FromSeconds(30));
GenTaskExecutetimer = new Timer(GenTaskExecute, null, TimeSpan.Zero, TimeSpan.FromSeconds(30));

View File

@@ -23,6 +23,14 @@ namespace Tnb.WarehouseMgr.Interfaces
/// 原材料出库
/// </summary>
SemaphoreSlim s_taskExecuteSemaphore_YCLOutstock { get; }
/// <summary>
/// 暂存仓入库
/// </summary>
SemaphoreSlim s_taskExecuteSemaphore_F2ZCCInstock { get; }
/// <summary>
/// 暂存仓出库
/// </summary>
SemaphoreSlim s_taskExecuteSemaphore_F2ZCCOutstock { get; }
/// <summary>
/// 入库策略

View File

@@ -47,14 +47,21 @@ namespace Tnb.WarehouseMgr
public static SemaphoreSlim s_taskExecuteSemaphore = new(1);
public static SemaphoreSlim s_elevatorStatusSemaphore = new(1);
public static SemaphoreSlim _s_taskExecuteSemaphore_YCLInstock = new(1);
public static SemaphoreSlim _s_taskExecuteSemaphore_YCLOutstock = new(1);
public static SemaphoreSlim _s_taskExecuteSemaphore_F1ZCCInstock = new(1);
public static SemaphoreSlim _s_taskExecuteSemaphore_F1ZCCOutstock = new(1);
public static SemaphoreSlim _s_taskExecuteSemaphore_F2ZCCInstock = new(1);
public static SemaphoreSlim _s_taskExecuteSemaphore_F2ZCCOutstock = new(1);
public static SemaphoreSlim _s_taskExecuteSemaphore_F2HCCInstock = new(1);
public static SemaphoreSlim _s_taskExecuteSemaphore_F2HCCOutstock = new(1);
public static SemaphoreSlim _s_taskExecuteSemaphore_F4DMJCInstock = new(1);
public static SemaphoreSlim _s_taskExecuteSemaphore_F4DMJCOutstock = new(1);
protected static Dictionary<string, int> _s_eleUseStatusDic;
protected IEventPublisher? EventPublisher { set; get; }

View File

@@ -109,6 +109,17 @@ namespace Tnb.WarehouseMgr
get { return _s_taskExecuteSemaphore_F1ZCCOutstock; }
}
public SemaphoreSlim s_taskExecuteSemaphore_F2ZCCInstock
{
get { return _s_taskExecuteSemaphore_F2ZCCInstock; }
}
public SemaphoreSlim s_taskExecuteSemaphore_F2ZCCOutstock
{
get { return _s_taskExecuteSemaphore_F2ZCCOutstock; }
}
public WareHouseService(ISqlSugarRepository<WmsInstockH> repository, IDictionaryDataService dictionaryDataService, StackExRedisHelper redisData,
IBillRullService billRullService, IUserManager userManager, ICacheManager cacheManager, IElevatorControlService elevatorControlService,

View File

@@ -580,6 +580,8 @@ namespace Tnb.WarehouseMgr
{
try
{
await _s_taskExecuteSemaphore_F2HCCOutstock.WaitAsync();
if (string.IsNullOrEmpty(input.source_id))
{
throw new AppFriendlyException("来源单据id不可为空", 500);
@@ -642,8 +644,6 @@ namespace Tnb.WarehouseMgr
PrdMoTask prdMoTask = organizeEntityCXs.First();
await s_taskExecuteSemaphore.WaitAsync();
await _db.Ado.BeginTranAsync();
//入库取终点 //出库起点
@@ -711,7 +711,7 @@ namespace Tnb.WarehouseMgr
}
finally
{
_ = s_taskExecuteSemaphore.Release();
_s_taskExecuteSemaphore_F2HCCOutstock.Release();
InvokeGenPretaskExcute();
}
@@ -1532,6 +1532,7 @@ namespace Tnb.WarehouseMgr
{
try
{
await _s_taskExecuteSemaphore_F2ZCCOutstock.WaitAsync();
OrganizeEntity organizeEntity = _db.Queryable<OrganizeEntity>().Where(r => r.Id == input.workstation_id).First();
if (organizeEntity == null)
{
@@ -1632,6 +1633,10 @@ namespace Tnb.WarehouseMgr
Logger.LogError("【CallRackToProductionLine】" + ex.StackTrace);
return await ToApiResult(HttpStatusCode.InternalServerError, ex.Message);
}
finally
{
_s_taskExecuteSemaphore_F2ZCCOutstock.Release();
}
return await ToApiResult(HttpStatusCode.OK, "成功");
}
@@ -1738,6 +1743,7 @@ namespace Tnb.WarehouseMgr
{
try
{
await _s_taskExecuteSemaphore_F2ZCCInstock.WaitAsync();
List<WmsCarryD> wmsCarryDs = _db.Queryable<WmsCarryD>().Where(r => r.carry_id == wmsCarryH.id).ToList();
if (wmsCarryDs.Count > 0)
{
@@ -1839,6 +1845,10 @@ namespace Tnb.WarehouseMgr
await _db.Ado.RollbackTranAsync();
return await ToApiResult(HttpStatusCode.InternalServerError, ex.Message);
}
finally
{
_s_taskExecuteSemaphore_F2ZCCInstock.Release();
}
return await ToApiResult(HttpStatusCode.OK, "成功");
}
@@ -1846,6 +1856,7 @@ namespace Tnb.WarehouseMgr
{
try
{
await _s_taskExecuteSemaphore_F2HCCInstock.WaitAsync();
BasLocation startlocation = _db.Queryable<BasLocation>().Where(r => r.id == input.startlocation_id).First();
if (startlocation == null)
{
@@ -1898,6 +1909,10 @@ namespace Tnb.WarehouseMgr
await _db.Ado.RollbackTranAsync();
return await ToApiResult(HttpStatusCode.InternalServerError, ex.Message);
}
finally
{
_s_taskExecuteSemaphore_F2HCCInstock.Release();
}
return await ToApiResult(HttpStatusCode.OK, "成功");
}

View File

@@ -60,9 +60,9 @@ namespace Tnb.WarehouseMgr
{
if (input.data[nameof(OutStockStrategyQuery.warehouse_id)].ToString() == WmsWareHouseConst.WAREHOUSE_ZC_ID)
{
await _s_taskExecuteSemaphore_F1ZCCOutstock.WaitAsync();
}
else if (input.data[nameof(OutStockStrategyQuery.warehouse_id)].ToString() == WmsWareHouseConst.WAREHOUSE_HCC_ID)
await _s_taskExecuteSemaphore_F2HCCOutstock.WaitAsync();
try
{
Logger.Information("开始PDA空载具出库");
@@ -236,9 +236,10 @@ namespace Tnb.WarehouseMgr
finally
{
if (input.data[nameof(OutStockStrategyQuery.warehouse_id)].ToString() == WmsWareHouseConst.WAREHOUSE_ZC_ID)
{
_s_taskExecuteSemaphore_F1ZCCOutstock.Release();
}
else if (input.data[nameof(OutStockStrategyQuery.warehouse_id)].ToString() == WmsWareHouseConst.WAREHOUSE_HCC_ID)
_s_taskExecuteSemaphore_F2HCCOutstock.Release();
await InvokeGenPretaskExcute();
}
return Task.FromResult(true);

View File

@@ -143,15 +143,15 @@ namespace Tnb.WarehouseMgr
await db.Insertable(WmsPrdInstockCodes).ExecuteCommandAsync();
if (type == "25019163616533")
if (type == DictConst.PrdMoTypeZS)
{
await _s_taskExecuteSemaphore_F1ZCCInstock.WaitAsync();
}
else if (type == "25019172714005")
else if (type == DictConst.PrdMoTypeJC)
{
await _s_taskExecuteSemaphore_F1ZCCInstock.WaitAsync();
await _s_taskExecuteSemaphore_F2HCCInstock.WaitAsync();
}
else if (type == "25019191681045")
else if (type == DictConst.PrdMoTypeBZ)
{
}
@@ -177,7 +177,7 @@ namespace Tnb.WarehouseMgr
string startlocation_id_ssx = null;
if (type == "25019163616533")
if (type == DictConst.PrdMoTypeZS)
{
Logger.LogInformation($"【PrdInstock】注塑车间生产提报");
// 注塑线边库到24输送线
@@ -231,7 +231,7 @@ namespace Tnb.WarehouseMgr
throw new Exception($"注塑车间生成到中储仓的任务失败 {res2.msg}");
}
}
else if (type == "25019172714005")
else if (type == DictConst.PrdMoTypeJC)
{
Logger.LogInformation($"【PrdInstock】挤出车间生产提报");
WmsCarryH wmsCarryH = await db.Queryable<WmsCarryH>().Where(r => r.id == wmsPrdInstockD.carry_id).FirstAsync();
@@ -253,7 +253,7 @@ namespace Tnb.WarehouseMgr
throw new Exception($"挤出车间生成到中储仓的任务失败 {res2.msg}");
}
}
else if (type == "25019191681045")
else if (type == DictConst.PrdMoTypeBZ)
{
Logger.LogInformation($"【PrdInstock】包装车间生产提报");
WmsCarryH wmsCarryH = await db.Queryable<WmsCarryH>().Where(r => r.id == wmsPrdInstockD.carry_id).FirstAsync();
@@ -289,15 +289,15 @@ namespace Tnb.WarehouseMgr
}
finally
{
if (type == "25019163616533")
if (type == DictConst.PrdMoTypeZS)
{
_s_taskExecuteSemaphore_F1ZCCInstock.Release();
}
else if (type == "25019172714005")
else if (type == DictConst.PrdMoTypeJC)
{
_s_taskExecuteSemaphore_F1ZCCInstock.Release();
_s_taskExecuteSemaphore_F2HCCInstock.Release();
}
else if (type == "25019191681045")
else if (type == DictConst.PrdMoTypeBZ)
{
}