From 267ffc1263e9975adf0d3dcca9ccc5d7dbd239f6 Mon Sep 17 00:00:00 2001
From: zxx <zxx>
Date: 星期六, 31 五月 2025 17:54:14 +0800
Subject: [PATCH] jushi

---
 HH.WCS.Mobox3/HH.WCS.Mobox3.JuShi/process/TaskProcess.cs |  102 ++++++++++++++++++++++++++++++++++++++++++---------
 1 files changed, 84 insertions(+), 18 deletions(-)

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..7687ea1 100644
--- a/HH.WCS.Mobox3/HH.WCS.Mobox3.JuShi/process/TaskProcess.cs
+++ b/HH.WCS.Mobox3/HH.WCS.Mobox3.JuShi/process/TaskProcess.cs
@@ -26,6 +26,7 @@
 using System.ComponentModel;
 using Newtonsoft.Json.Linq;
 using S7.Net;
+using System.Threading.Tasks;
 
 namespace HH.WCS.JuShi.process
 {
@@ -823,6 +824,53 @@
                     {
                         list.RemoveAll(s => loca.Contains(s.S_CODE));
                     }
+                    // 3. 濡傛灉鏄珛搴撳叆搴撳尯锛屾鏌�PLC 鏄惁鍏佽鍗歌浇
+                    var reservoirs = Settings.ReservoirAreas.FirstOrDefault(s => s.areaName == "绔嬪簱鍏ュ簱鍖�);
+                    if (reservoirs != null && reservoirs.areaCode.Equals(area))
+                    {
+                        var plcDeviceTable = S7Helper.plcDeviceTables;
+                        // 鍏堟敹闆嗚绉婚櫎鐨勮揣浣嶏紝閬垮厤鍦ㄩ亶鍘嗘椂淇敼闆嗗悎
+                        List<Location> locationsToRemove = new List<Location>();
+
+                        foreach (var location in list)
+                        {
+                            var safeInteraction = Settings.SafeInteractions.FirstOrDefault(s => s.location == location.S_CODE);
+                            if (safeInteraction != null)
+                            {
+                                // 妫�煡 PLC 鏄惁鍏佽鍗歌浇锛堝彇绗簩浣嶆暟瀛楋紝鍒ゆ柇鏄惁涓�1锛�+                                string allowUnloadStr = plcDeviceTable.RGVAllowUnload[safeInteraction.code].ToString();
+                                int allowUnload = int.Parse(allowUnloadStr.Substring(1, 1));
+
+                                if (allowUnload != 1)
+                                {
+                                    locationsToRemove.Add(location); // 涓嶅厑璁稿嵏杞斤紝鍔犲叆寰呯Щ闄ゅ垪琛�+                                }
+                            }
+                        }
+
+                        // 閬嶅巻缁撴潫鍚庯紝鍐嶇粺涓�Щ闄や笉绗﹀悎鏉′欢鐨勮揣浣�+                        foreach (var locToRemove in locationsToRemove)
+                        {
+                            list.Remove(locToRemove);
+                        }
+                    }
+                    ////杩囨护涓�笅 鍏佽杩涘叆鐨勬墠鍒嗛厤
+                    //var reservoirs = Settings.ReservoirAreas.Where(s => s.areaName == "绔嬪簱鍏ュ簱鍖�).FirstOrDefault();
+                    //if (reservoirs.areaCode.Equals(area))
+                    //{
+                    //    var plcDeviceTable = S7Helper.plcDeviceTables;
+                    //    foreach (var l in list)
+                    //    {
+                    //        var safeInteraction = Settings.SafeInteractions.Where(s => s.location == l.S_CODE).FirstOrDefault();
+                    //        var res = int.Parse(plcDeviceTable.RGVAllowUnload[safeInteraction.code].ToString().Substring(1, 1));
+                    //        if (res!=1)
+                    //        {
+                    //            list.Remove(l);
+                    //        }
+                    //    }
+                    //}
+                    
+
                     //绗﹀悎鏉′欢鐨勬帓搴忛�绗竴涓� 鍏堟壘绗竴涓�                     if (list.Count > 0)
                     {
@@ -1761,10 +1809,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,7 +1826,21 @@
                         //鍗歌揣鍚庡凡绂诲紑
                         else if (model.APPLY_CODE.Equals("8"))
                         {
-                            safeAssistant(reservoirs.code,res);
+                            //鍙戦�鍗歌揣瀹屾垚銆佸浣嶄俊鍙�+                            //鍗歌揣瀹屾垚淇″彿
+                            S7Helper.WriteInt(50, reservoirs.code * 2 - 2, (short)(reservoirs.code * 10 + 1));
+
+                            // 鍚姩鍚庡彴浠诲姟澶勭悊寤惰繜澶嶄綅
+                            Task.Run(async () =>
+                            {
+                                //10绉掑悗澶嶄綅
+                                await Task.Delay(10000);
+                                S7Helper.WriteInt(50, reservoirs.code * 2 - 2, (short)(reservoirs.code * 10));
+                                LogHelper.Info($"RGV瀹夊叏浜や簰 澶嶄綅瀹屾垚");
+                            });
+                            //10绉掑悗澶嶄綅
+                            //S7Helper.WriteInt(50, reservoirs.code * 2 - 2, (short)(reservoirs.code * 10));
+                            //safeAssistant(reservoirs.code, res);
                             LogHelper.Info($"RGV瀹夊叏浜や簰 鍗歌揣瀹屾垚");
                             return new safeResult() { code = "0", msg = "success" };
                         }
@@ -1860,20 +1922,24 @@
                 throw;
             }
         }
-
-        private static void safeAssistant(int code,int res) {
-            //2鍗歌揣瀹屾垚纭
-            if (res != 2)
-            {
-                //鍗歌揣瀹屾垚淇″彿
-                S7Helper.WriteInt(50, 0, (short)(code * 10 + 1));
-                Thread.Sleep(3000);
-                safeAssistant(code,res);
-            }
-            else
-            {
-                S7Helper.WriteInt(50, 0, (short)(code * 10));
-            }
+        //寰幆鍙戦�淇″彿
+        private static void safeAssistant(int code, int res)
+        {
+            Thread.Sleep(10000);
+            S7Helper.WriteInt(50, code * 2 - 2, (short)(code * 10));
+            LogHelper.Info($"RGV瀹夊叏浜や簰 澶嶄綅瀹屾垚");
+            ////2鍗歌揣瀹屾垚纭
+            //if (res != 2)
+            //{
+            //    //鍗歌揣瀹屾垚淇″彿
+            //    S7Helper.WriteInt(50, code * 2 - 2, (short)(code * 10 + 1));
+            //    Thread.Sleep(3000);
+            //    safeAssistant(code, res);
+            //}
+            //else
+            //{
+            //    S7Helper.WriteInt(50, code * 2 - 2, (short)(code * 10));
+            //}
 
         }
 

--
Gitblit v1.9.1