From 034839c93e9f18d2b77105a85f65c8400798d74c Mon Sep 17 00:00:00 2001
From: zxx <Zxx@HanInfo>
Date: 星期五, 30 五月 2025 08:31:10 +0800
Subject: [PATCH] 巨石

---
 HH.WCS.Mobox3/HH.WCS.Mobox3.JuShi/wms/ContainerHelper.cs |    8 ++++----
 HH.WCS.Mobox3/HH.WCS.Mobox3.JuShi/core/WMSCore.cs        |    1 +
 HH.WCS.Mobox3/HH.WCS.Mobox3.JuShi/api/WmsController.cs   |    2 +-
 HH.WCS.Mobox3/HH.WCS.Mobox3.JuShi/process/TaskProcess.cs |    9 +++++----
 HH.WCS.Mobox3/HH.WCS.Mobox3.JuShi/device/S7Helper.cs     |   34 ++++++++++++++++++++++------------
 5 files changed, 33 insertions(+), 21 deletions(-)

diff --git a/HH.WCS.Mobox3/HH.WCS.Mobox3.JuShi/api/WmsController.cs b/HH.WCS.Mobox3/HH.WCS.Mobox3.JuShi/api/WmsController.cs
index 2be43e3..19d0d63 100644
--- a/HH.WCS.Mobox3/HH.WCS.Mobox3.JuShi/api/WmsController.cs
+++ b/HH.WCS.Mobox3/HH.WCS.Mobox3.JuShi/api/WmsController.cs
@@ -159,7 +159,7 @@
         /// </summary>
         /// <returns></returns>
         [HttpPost]
-        public Results S7Write(int offsetAddr)
+        public Results S7Write(Isusing offsetAddr)
         {
             LogHelper.Info("S7Write 鍙傛暟锛� + offsetAddr, "WMSAPI");
             var res = S7Helper.S7Write(offsetAddr);
diff --git a/HH.WCS.Mobox3/HH.WCS.Mobox3.JuShi/core/WMSCore.cs b/HH.WCS.Mobox3/HH.WCS.Mobox3.JuShi/core/WMSCore.cs
index 28d7508..cb7fb29 100644
--- a/HH.WCS.Mobox3/HH.WCS.Mobox3.JuShi/core/WMSCore.cs
+++ b/HH.WCS.Mobox3/HH.WCS.Mobox3.JuShi/core/WMSCore.cs
@@ -323,6 +323,7 @@
                             //LogHelper.Info($"鎷嗘墭鏈鸿揣浣峽endLoc}涓嶅瓨鍦ㄦ垨宸茶閿�);
                             return;
                         }
+                        //鏍¢獙鏄惁鍏佽鏀捐揣
                         var plcDeviceTable = S7Helper.plcDeviceTables;
                         LogHelper.Info($"鑷姩閫佹墭 鎷嗘墭鏈簕dev}:{plcDeviceTable.requestPut1}");
                         if ((plcDeviceTable.requestPut1 && dev == "1") ||
diff --git a/HH.WCS.Mobox3/HH.WCS.Mobox3.JuShi/device/S7Helper.cs b/HH.WCS.Mobox3/HH.WCS.Mobox3.JuShi/device/S7Helper.cs
index 30eb63b..5f236c6 100644
--- a/HH.WCS.Mobox3/HH.WCS.Mobox3.JuShi/device/S7Helper.cs
+++ b/HH.WCS.Mobox3/HH.WCS.Mobox3.JuShi/device/S7Helper.cs
@@ -3,6 +3,7 @@
 using Microsoft.Owin.BuilderProperties;
 using Newtonsoft.Json;
 using Newtonsoft.Json.Linq;
+using Opc.Ua;
 using S7.Net;
 using S7.Net.Types;
 using SqlSugar;
@@ -298,9 +299,11 @@
             var db = new SqlHelper<WCSTask>().GetInstance();
             try
             {
-                var linkplc = Settings.linePlcInfos.Find(a => a.enable == 1);
-                var plc = new Plc(CpuType.S71500, linkplc.address, 0, 1);
+                var linkplc = Settings.SafeInteractions.FindAll(a => a.code == 1|| a.code == 7).ToList();
+                var plc = new Plc(CpuType.S71500, linkplc[1].ip, 0, 1);
                 Link(plc);
+                var plc1 = new Plc(CpuType.S71200, linkplc[0].ip, 0, 1);
+                Link(plc1);
                 //鎷嗘墭鏈�
                 //object rawValue = plc.Read(DataType.DataBlock, 8, 230, VarType.Byte, 1);
                 //LogHelper.Info($"Raw value: {rawValue} (Type: {rawValue?.GetType()})");
@@ -314,13 +317,17 @@
                 LogHelper.Info($"鎷嗘墭鏈烘帴鏀朵俊鍙�===={requestPut1}锛寋requestTake1}锛寋requestPut2}锛寋requestTake2}");
 
                 //RGV
+                //var rawValue = plc1.Read(DataType.DataBlock, 51, 0, VarType.Int, 1);
+                //LogHelper.Info($"Raw value: {rawValue}, Type: {rawValue?.GetType()}");
+
                 // RGV鍏佽鍗歌揣鐘舵�璇诲彇 (浠嶥B51璇诲彇)
-                int rgv1AllowUnload = (int)plc.Read(DataType.DataBlock, 51, 0, VarType.Int, 1);
-                int rgv2AllowUnload = (int)plc.Read(DataType.DataBlock, 51, 2, VarType.Int, 1);
-                int rgv3AllowUnload = (int)plc.Read(DataType.DataBlock, 51, 4, VarType.Int, 1);
-                int rgv4AllowUnload = (int)plc.Read(DataType.DataBlock, 51, 6, VarType.Int, 1);
-                int rgv5AllowUnload = (int)plc.Read(DataType.DataBlock, 51, 8, VarType.Int, 1);
-                int rgv6AllowUnload = (int)plc.Read(DataType.DataBlock, 51, 10, VarType.Int, 1);
+                int rgv1AllowUnload = Convert.ToInt32(plc1.Read(DataType.DataBlock, 51, 0, VarType.Int, 1));
+                int rgv2AllowUnload = Convert.ToInt32(plc1.Read(DataType.DataBlock, 51, 2, VarType.Int, 1));
+                int rgv3AllowUnload = Convert.ToInt32(plc1.Read(DataType.DataBlock, 51, 4, VarType.Int, 1));
+                int rgv4AllowUnload = Convert.ToInt32(plc1.Read(DataType.DataBlock, 51, 6, VarType.Int, 1));
+                int rgv5AllowUnload = Convert.ToInt32(plc1.Read(DataType.DataBlock, 51, 8, VarType.Int, 1));
+                int rgv6AllowUnload = Convert.ToInt32(plc1.Read(DataType.DataBlock, 51, 10, VarType.Int, 1));
+
                 LogHelper.Info($"RGV鎺ユ敹淇″彿=== 1={rgv1AllowUnload}, 2={rgv2AllowUnload}, 3={rgv3AllowUnload}, 4={rgv4AllowUnload}, 5={rgv5AllowUnload}, 6={rgv6AllowUnload}");
 
                 //瀛樺埌缂撳瓨
@@ -964,12 +971,15 @@
         }
 
         //S7鍐欏叆淇″彿 娴嬭瘯鐢�-        internal static Results S7Write(int offsetAddr)
+        internal static Results S7Write(Isusing offsetAddr)
         {
-            var linkplcs = Settings.linePlcInfos.Find(a => a.deviceNo == "1");
-            var plc = new Plc(CpuType.S71500, linkplcs.address, 0, 1);
+            //var linkplcs = Settings.linePlcInfos.Find(a => a.deviceNo == "1");
+            //var plc = new Plc(CpuType.S71200, linkplcs.address, 0, 1);
+            var linkplc = Settings.SafeInteractions.First();
+            var plc = new Plc(CpuType.S71200, linkplc.ip, 0, 1);
             Link(plc);
-            plc.WriteBit(DataType.DataBlock, 9, 182, offsetAddr, false);
+            S7Helper.WriteInt(50, 0, (short)(offsetAddr.S_STATUS * 10 + int.Parse(offsetAddr.S_TYPE)));
+            //plc.WriteBit(DataType.DataBlock, 9, 182, offsetAddr, false);
             return new Results() { Code = "0", Message = $"鍐欏叆鎴愬姛", Data = null };
         }
 
diff --git a/HH.WCS.Mobox3/HH.WCS.Mobox3.JuShi/process/TaskProcess.cs b/HH.WCS.Mobox3/HH.WCS.Mobox3.JuShi/process/TaskProcess.cs
index 20db7c6..0c4700b 100644
--- a/HH.WCS.Mobox3/HH.WCS.Mobox3.JuShi/process/TaskProcess.cs
+++ b/HH.WCS.Mobox3/HH.WCS.Mobox3.JuShi/process/TaskProcess.cs
@@ -1761,10 +1761,10 @@
                     if (reservoirs.type.Equals("RGV"))
                     {
                         LogHelper.Info($"RGV瀹夊叏浜や簰  璇锋眰鐐逛綅锛歿model.STATION_NAME}璇锋眰鐮侊細{model.APPLY_CODE}");
-                        //鏍规嵁ip璇荤姸鎬�-                        LogHelper.Info($"RGV瀹夊叏浜や簰缂撳瓨淇″彿{JsonConvert.SerializeObject(plcDeviceTable.RGVAllowUnload)}");
                         //澶勭悊淇″彿
-                        var res = plcDeviceTable.RGVAllowUnload[reservoirs.code];
+                        var res =int.Parse(plcDeviceTable.RGVAllowUnload[reservoirs.code].ToString().Substring(1, 1));
+                        //鏍规嵁ip璇荤姸鎬�+                        LogHelper.Info($"RGV瀹夊叏浜や簰缂撳瓨淇″彿{res}锛寋JsonConvert.SerializeObject(plcDeviceTable.RGVAllowUnload)}");
                         //鍗歌揣璇锋眰杩涘叆
                         if (model.APPLY_CODE.Equals("5"))
                         {
@@ -1778,6 +1778,7 @@
                         //鍗歌揣鍚庡凡绂诲紑
                         else if (model.APPLY_CODE.Equals("8"))
                         {
+                            //鍙戦�鍗歌揣瀹屾垚銆佸浣嶄俊鍙�                             safeAssistant(reservoirs.code,res);
                             LogHelper.Info($"RGV瀹夊叏浜や簰 鍗歌揣瀹屾垚");
                             return new safeResult() { code = "0", msg = "success" };
@@ -1860,7 +1861,7 @@
                 throw;
             }
         }
-
+        //寰幆鍙戦�淇″彿
         private static void safeAssistant(int code,int res) {
             //2鍗歌揣瀹屾垚纭
             if (res != 2)
diff --git a/HH.WCS.Mobox3/HH.WCS.Mobox3.JuShi/wms/ContainerHelper.cs b/HH.WCS.Mobox3/HH.WCS.Mobox3.JuShi/wms/ContainerHelper.cs
index a04aa45..e7931e2 100644
--- a/HH.WCS.Mobox3/HH.WCS.Mobox3.JuShi/wms/ContainerHelper.cs
+++ b/HH.WCS.Mobox3/HH.WCS.Mobox3.JuShi/wms/ContainerHelper.cs
@@ -559,16 +559,16 @@
                     if (db.Queryable<LocCntrRel>().Count(a => a.S_CNTR_CODE.Trim() == cntrCode) == 0)
                     {
                         var cir = new LocCntrRel { S_LOC_CODE = loc, S_CNTR_CODE = cntrCode};
-                        var con = new Container { S_CODE = cntrCode,N_DETAIL_COUNT = 1,C_FULL="0" };
+                        var con = new Container { S_CODE = cntrCode,N_DETAIL_COUNT = 1,C_FULL="2" };//榛樿婊�涓诲姩缁戝畾鏈嶅姟鐢�                         db.Insertable<LocCntrRel>(cir).ExecuteCommand();
                         db.Insertable<Container>(con).ExecuteCommand();
                         if (!string.IsNullOrEmpty(itemCode))
                         {
                             LogHelper.Info($"缁戝畾瀹瑰櫒鍙傛暟锛歿JsonConvert.SerializeObject(con)}");
                             ContainerHelper.BindCntrItem(cntrCode, itemCode, itemName);
-                            //鏈夌墿鏂欑殑璇濆氨鏄弧鐨�-                            con.C_FULL = "2";
-                            db.Updateable(con).UpdateColumns(it => it.C_FULL).ExecuteCommand();
+                            ////鏈夌墿鏂欑殑璇濆氨鏄弧鐨�+                            //con.C_FULL = "2";
+                            //db.Updateable(con).UpdateColumns(it => it.C_FULL).ExecuteCommand();
                         }
                     }
                 }

--
Gitblit v1.9.1