From 433be346b919561abd521467faee1d2249de19e7 Mon Sep 17 00:00:00 2001
From: majian <780924089@qq.com>
Date: Thu, 8 Aug 2024 11:48:51 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BA=8C=E6=A5=BC=E7=BC=93=E5=AD=98=E4=BB=93?=
=?UTF-8?q?=E5=92=8C=E6=9A=82=E5=AD=98=E4=BB=93=E5=87=BA=E5=85=A5=E5=BA=93?=
=?UTF-8?q?=E4=BC=98=E5=8C=96?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Tnb.ProductionMgr/RedisBackGround.cs | 28 +++++++++----------
.../IWareHouseService.cs | 8 ++++++
.../Tnb.WarehouseMgr/BaseWareHouseService.cs | 11 ++++++--
.../Tnb.WarehouseMgr/WareHouseService.cs | 11 ++++++++
.../WmsMaterialTransferService.cs | 21 ++++++++++++--
.../WmsPDAEmptyOutstockService .cs | 9 +++---
.../Tnb.WarehouseMgr/WmsPrdInstockHService.cs | 22 +++++++--------
7 files changed, 76 insertions(+), 34 deletions(-)
diff --git a/ProductionMgr/Tnb.ProductionMgr/RedisBackGround.cs b/ProductionMgr/Tnb.ProductionMgr/RedisBackGround.cs
index 58ff1fa7..df2b1125 100644
--- a/ProductionMgr/Tnb.ProductionMgr/RedisBackGround.cs
+++ b/ProductionMgr/Tnb.ProductionMgr/RedisBackGround.cs
@@ -1229,9 +1229,9 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
///
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
///
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
///
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
///
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));
diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Interfaces/IWareHouseService.cs b/WarehouseMgr/Tnb.WarehouseMgr.Interfaces/IWareHouseService.cs
index 180542c7..3b9d8b97 100644
--- a/WarehouseMgr/Tnb.WarehouseMgr.Interfaces/IWareHouseService.cs
+++ b/WarehouseMgr/Tnb.WarehouseMgr.Interfaces/IWareHouseService.cs
@@ -23,6 +23,14 @@ namespace Tnb.WarehouseMgr.Interfaces
/// 原材料出库
///
SemaphoreSlim s_taskExecuteSemaphore_YCLOutstock { get; }
+ ///
+ /// 暂存仓入库
+ ///
+ SemaphoreSlim s_taskExecuteSemaphore_F2ZCCInstock { get; }
+ ///
+ /// 暂存仓出库
+ ///
+ SemaphoreSlim s_taskExecuteSemaphore_F2ZCCOutstock { get; }
///
/// 入库策略
diff --git a/WarehouseMgr/Tnb.WarehouseMgr/BaseWareHouseService.cs b/WarehouseMgr/Tnb.WarehouseMgr/BaseWareHouseService.cs
index 15091b79..1bbe0997 100644
--- a/WarehouseMgr/Tnb.WarehouseMgr/BaseWareHouseService.cs
+++ b/WarehouseMgr/Tnb.WarehouseMgr/BaseWareHouseService.cs
@@ -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 _s_eleUseStatusDic;
protected IEventPublisher? EventPublisher { set; get; }
diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs
index d5d2e423..09e0198e 100644
--- a/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs
+++ b/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs
@@ -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 repository, IDictionaryDataService dictionaryDataService, StackExRedisHelper redisData,
IBillRullService billRullService, IUserManager userManager, ICacheManager cacheManager, IElevatorControlService elevatorControlService,
diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsMaterialTransferService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsMaterialTransferService.cs
index 101b9668..022b8892 100644
--- a/WarehouseMgr/Tnb.WarehouseMgr/WmsMaterialTransferService.cs
+++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsMaterialTransferService.cs
@@ -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().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 wmsCarryDs = _db.Queryable().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().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, "成功");
}
diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAEmptyOutstockService .cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAEmptyOutstockService .cs
index 1c580d87..1dad4786 100644
--- a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAEmptyOutstockService .cs
+++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAEmptyOutstockService .cs
@@ -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);
diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsPrdInstockHService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsPrdInstockHService.cs
index 43ac200e..ba7b5454 100644
--- a/WarehouseMgr/Tnb.WarehouseMgr/WmsPrdInstockHService.cs
+++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsPrdInstockHService.cs
@@ -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】注塑车间生产提报");
// 注塑线边库到2,4输送线
@@ -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().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().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)
{
}