From 2f263d548dc8b9e270f5f5663e80f9d4f5880b10 Mon Sep 17 00:00:00 2001
From: wxw <Administrator@DESKTOP-5BIMHQ3>
Date: 星期日, 15 六月 2025 15:05:58 +0800
Subject: [PATCH] 申请储位增加锁防止向WMS重复申请
---
Admin.NET/WCS.Application/PLC/PLCService.cs | 109 ++++++++++++++++++++++++++++++++++--------------------
1 files changed, 69 insertions(+), 40 deletions(-)
diff --git a/Admin.NET/WCS.Application/PLC/PLCService.cs b/Admin.NET/WCS.Application/PLC/PLCService.cs
index 1f94f94..567ebb6 100644
--- a/Admin.NET/WCS.Application/PLC/PLCService.cs
+++ b/Admin.NET/WCS.Application/PLC/PLCService.cs
@@ -21,6 +21,7 @@
public static class PLCService
{
private static readonly object OLock = new object();
+ private static readonly object RuKuLock = new object();
private static readonly ISqlSugarClient _db = SqlSugarSetup.ITenant.GetConnectionScope(SqlSugarConst.MainConfigId);
private static decimal weight94 = 0;
@@ -1200,55 +1201,59 @@
#region#瀹炴椂鏄剧ず閲嶉噺鍒癓ED灞忓箷
var modPosPalletWeightIng = modDevice.listStation.FirstOrDefault(m => m.Text == "瀹為檯閲嶉噺");
- var (resPalletWeightIng, palletWeightValIng) = plcConn.GetPlcDBValue(modPosPalletWeightIng.PosType, modDevice.DbNumber, modPosPalletWeightIng.PlcPos);
- switch (modDevice.StationNum)
+ if (modPosPalletWeightIng != null)
{
- case "094":
- {
- if (Convert.ToDecimal(palletWeightValIng) != weight94)
+ var (resPalletWeightIng, palletWeightValIng) = plcConn.GetPlcDBValue(modPosPalletWeightIng.PosType, modDevice.DbNumber, modPosPalletWeightIng.PlcPos);
+ switch (modDevice.StationNum)
+ {
+ case "094":
{
- LedDisplay(modDevice.LedIP, $"褰撳墠閲嶉噺(KG)锛歿Convert.ToDecimal(palletWeightValIng)}");
- weight94 = Convert.ToDecimal(palletWeightValIng);
+ if (Convert.ToDecimal(palletWeightValIng) != weight94)
+ {
+ LedDisplay(modDevice.LedIP, $"褰撳墠閲嶉噺(KG)锛歿Convert.ToDecimal(palletWeightValIng)}");
+ weight94 = Convert.ToDecimal(palletWeightValIng);
+ }
}
- }
- break;
- case "160":
- {
- if (Convert.ToDecimal(palletWeightValIng) != weight160)
+ break;
+ case "160":
{
- LedDisplay(modDevice.LedIP, $"褰撳墠閲嶉噺(KG)锛歿Convert.ToDecimal(palletWeightValIng)}");
- weight160 = Convert.ToDecimal(palletWeightValIng);
+ if (Convert.ToDecimal(palletWeightValIng) != weight160)
+ {
+ LedDisplay(modDevice.LedIP, $"褰撳墠閲嶉噺(KG)锛歿Convert.ToDecimal(palletWeightValIng)}");
+ weight160 = Convert.ToDecimal(palletWeightValIng);
+ }
}
- }
- break;
- case "155":
- {
- if (Convert.ToDecimal(palletWeightValIng) != weight155)
+ break;
+ case "155":
{
- LedDisplay(modDevice.LedIP, $"褰撳墠閲嶉噺(KG)锛歿Convert.ToDecimal(palletWeightValIng)}");
- weight155 = Convert.ToDecimal(palletWeightValIng);
+ if (Convert.ToDecimal(palletWeightValIng) != weight155)
+ {
+ LedDisplay(modDevice.LedIP, $"褰撳墠閲嶉噺(KG)锛歿Convert.ToDecimal(palletWeightValIng)}");
+ weight155 = Convert.ToDecimal(palletWeightValIng);
+ }
}
- }
- break;
- case "152":
- {
- if (Convert.ToDecimal(palletWeightValIng) != weight152)
+ break;
+ case "152":
{
- LedDisplay(modDevice.LedIP, $"褰撳墠閲嶉噺(KG)锛歿Convert.ToDecimal(palletWeightValIng)}");
- weight152 = Convert.ToDecimal(palletWeightValIng);
+ if (Convert.ToDecimal(palletWeightValIng) != weight152)
+ {
+ LedDisplay(modDevice.LedIP, $"褰撳墠閲嶉噺(KG)锛歿Convert.ToDecimal(palletWeightValIng)}");
+ weight152 = Convert.ToDecimal(palletWeightValIng);
+ }
}
- }
- break;
- case "153":
- {
- if (Convert.ToDecimal(palletWeightValIng) != weight153)
+ break;
+ case "153":
{
- LedDisplay(modDevice.LedIP, $"褰撳墠閲嶉噺(KG)锛歿Convert.ToDecimal(palletWeightValIng)}");
- weight153 = Convert.ToDecimal(palletWeightValIng);
+ if (Convert.ToDecimal(palletWeightValIng) != weight153)
+ {
+ LedDisplay(modDevice.LedIP, $"褰撳墠閲嶉噺(KG)锛歿Convert.ToDecimal(palletWeightValIng)}");
+ weight153 = Convert.ToDecimal(palletWeightValIng);
+ }
}
- }
- break;
+ break;
+ }
}
+
#endregion
@@ -1442,6 +1447,27 @@
var http = new HttpService();
string TaskNo = "", EndLocate = "";
+
+ //鏍规嵁宸ヤ綅鍒ゆ柇鏄惁涓哄彔鎵樻満宸ヤ綅鐢宠绌烘墭鐩樿泛鍏ュ簱锛屾槸锛氬悜WMS鐢宠绌烘墭鐩樿泛缁勬墭
+ string groupMsg = "";
+ if (modDevice.StationNum == "72")
+ {
+ groupMsg = http.BindNullPalletWcs(10, palletVal);
+
+ if (groupMsg.Contains("-1"))
+ {
+ // 鍐欏叆杈撻�佺嚎閫�鍥炴寚浠�
+ var ret = plcConn.SetPlcDBValue(modDevice.PosType, modDevice.DbNumber, modPosEndLocat.PlcPos, modDevice.StationNum);
+ if (ret.IsSucceed)
+ {
+ plcConn.SetPlcDBValue(modDevice.PosType, modDevice.DbNumber, modDevice.WcsPos, "350");
+ }
+
+ break;
+ }
+ }
+
+ //鍚慦MS鐢宠宸烽亾
strMsg = http.RequestRoadWay(palletVal, modDevice.StationNum, taskModel, louCeng, ref EndLocate, ref TaskNo, (int)palletHeightVal);
if (!strMsg.Contains("-1"))
@@ -1789,9 +1815,12 @@
#endregion
var http = new HttpService();
- string TaskNo = "";
- // 鍚慦MS鐢宠鍌ㄤ綅淇℃伅
- strMsg = http.RequestLocate(palletVal, modDevice.StationNum, taskModel, roadway, ref TaskNo, (int)taskInfo2.PalletQty);
+ string TaskNo = "";
+ lock (RuKuLock)
+ {
+ // 鍚慦MS鐢宠鍌ㄤ綅淇℃伅
+ strMsg = http.RequestLocate(palletVal, modDevice.StationNum, taskModel, roadway, ref TaskNo, (int)taskInfo2.PalletQty);
+ }
// 鏍规嵁浠诲姟鍙疯幏鍙栬捣濮嬪伐浣嶅湴鍧�锛屾牴鎹捣濮嬪伐浣嶅湴鍧�鑾峰彇LEDIP 鎺ㄩ�佸埌LED灞忓箷銆�
var taskInfo = _db.Queryable<WcsTask>().First(w => w.TaskNo == TaskNo);
--
Gitblit v1.8.0