From ef986338133c1e636fee455356f10d01e5f7b293 Mon Sep 17 00:00:00 2001
From: czw <selecti@yeah.net>
Date: 星期三, 25 六月 2025 15:18:20 +0800
Subject: [PATCH] 1

---
 2025年6月12日/AuxAllWCS/Build/Project/代码/VS自定义类/AutoThread.cs |   89 +++++++++++++++++++++++++++++++-------------
 1 files changed, 63 insertions(+), 26 deletions(-)

diff --git "a/2025\345\271\2646\346\234\21012\346\227\245/AuxAllWCS/Build/Project/\344\273\243\347\240\201/VS\350\207\252\345\256\232\344\271\211\347\261\273/AutoThread.cs" "b/2025\345\271\2646\346\234\21012\346\227\245/AuxAllWCS/Build/Project/\344\273\243\347\240\201/VS\350\207\252\345\256\232\344\271\211\347\261\273/AutoThread.cs"
index b9d7a95..4d71280 100644
--- "a/2025\345\271\2646\346\234\21012\346\227\245/AuxAllWCS/Build/Project/\344\273\243\347\240\201/VS\350\207\252\345\256\232\344\271\211\347\261\273/AutoThread.cs"
+++ "b/2025\345\271\2646\346\234\21012\346\227\245/AuxAllWCS/Build/Project/\344\273\243\347\240\201/VS\350\207\252\345\256\232\344\271\211\347\261\273/AutoThread.cs"
@@ -15,6 +15,7 @@
 using static System.Windows.Forms.VisualStyles.VisualStyleElement;
 using System.Windows.Interop;
 using static System.Windows.Forms.VisualStyles.VisualStyleElement.TextBox;
+using System.Security.Cryptography;
 
 namespace GZ.Projects.AuxAllWCS
 {
@@ -103,6 +104,12 @@
             else if (Settings.deviceInfos.Count == 0)
             {
                 tag.Global.SettingsOver = 0;
+            }
+            else tag.Global.SettingsOver++;
+            if (tag.Global.SettingsOver > 999)
+            {
+                tag.Global.SettingsOver = 1;
+                Console.Clear();
             }
         }
 
@@ -237,7 +244,8 @@
                         LogHelper.Info($"{VERX.location[0]}鐢宠mes浠诲姟缁撴灉{str}");
                         if (str.Contains("true"))
                         {
-                            tag.wxr1.R44_LAST = true;
+                            //tag.wxr1.R44_LAST = true;
+                            RedisHelper.Add($"缁村笇灏旀姄鑷�.R44_LAST", "true", out string msg);
                         }
                     }
                     else
@@ -252,7 +260,8 @@
                     {
                         if (tag.wxr1.R10)
                         {
-                            tag.wxr1.R10_LAST = false;
+                            //tag.wxr1.R10_LAST = false;
+                            RedisHelper.Add($"缁村笇灏旀姄鑷�.R10_LAST", "false", out string msg);
                         }
                         else
                         if (TcpServer.TrayIps.TryGetValue(VERX.deviceNo[0], out string traycode))
@@ -268,7 +277,8 @@
                             {
                                 //Conn.榛樿Redis.SetValue("缁村笇灏旀姄鑷�.R10", "true", "缁村笇灏旀姄鑷�Queue");
                                 tag.wxr1.R10 = true;
-                                tag.wxr1.R44_LAST = false;
+                                //tag.wxr1.R44_LAST = false;
+                                RedisHelper.Add($"缁村笇灏旀姄鑷�.R44_LAST", "false", out string msg);
                             }
                             else
                             {
@@ -306,7 +316,8 @@
                         LogHelper.Info($"{VERX.location[1]}鐢宠mes浠诲姟缁撴灉{str}");
                         if (str.Contains("true"))
                         {
-                            tag.wxr1.R46_LAST = true;
+                            //tag.wxr1.R46_LAST = true;
+                            RedisHelper.Add($"缁村笇灏旀姄鑷�.R46_LAST", "true", out string msg);
                         }
                     }
                     else
@@ -320,7 +331,8 @@
                     {
                         if (tag.wxr1.R11)
                         {
-                            tag.wxr1.R11_LAST = false;
+                            //tag.wxr1.R11_LAST = false;
+                            RedisHelper.Add($"缁村笇灏旀姄鑷�.R11_LAST", "false", out string msg);
                         }
                         else
                         if (TcpServer.TrayIps.TryGetValue(VERX.deviceNo[1], out string traycode))
@@ -336,7 +348,8 @@
                             {
                                 //Conn.榛樿Redis.SetValue("缁村笇灏旀姄鑷�.R10", "true", "缁村笇灏旀姄鑷�Queue");
                                 tag.wxr1.R11 = true;
-                                tag.wxr1.R46_LAST = false;
+                                //tag.wxr1.R46_LAST = false;
+                                RedisHelper.Add($"缁村笇灏旀姄鑷�.R46_LAST", "false", out string msg);
                             }
                             else
                             {
@@ -374,7 +387,8 @@
                         LogHelper.Info($"{VERX.location[0]}鐢宠mes浠诲姟缁撴灉{str}");
                         if (str.Contains("true"))
                         {
-                            tag.wxr2.R44_LAST = true;
+                            //tag.wxr2.R44_LAST = true;
+                            RedisHelper.Add($"缁村笇灏旀姄鑷�.R44_LAST", "true", out string msg);
                         }
                     }
                     else
@@ -388,7 +402,8 @@
                     {
                         if (tag.wxr2.R10)
                         {
-                            tag.wxr2.R10_LAST = false;
+                            //tag.wxr2.R10_LAST = false;
+                            RedisHelper.Add($"缁村笇灏旀姄鑷�.R10_LAST", "false", out string msg);
                         }
                         else
                         if (TcpServer.TrayIps.TryGetValue(VERX.deviceNo[0], out string traycode))
@@ -404,7 +419,8 @@
                             {
                                 //Conn.榛樿Redis.SetValue("缁村笇灏旀姄鑷�.R10", "true", "缁村笇灏旀姄鑷�Queue");
                                 tag.wxr2.R10 = true;
-                                tag.wxr2.R44_LAST = false;
+                                //tag.wxr2.R44_LAST = false;
+                                RedisHelper.Add($"缁村笇灏旀姄鑷�.R44_LAST", "false", out string msg);
                             }
                             else
                             {
@@ -443,7 +459,8 @@
                         LogHelper.Info($"{VERX.location[1]}鐢宠mes浠诲姟缁撴灉{str}");
                         if (str.Contains("true"))
                         {
-                            tag.wxr2.R46_LAST = true;
+                            //tag.wxr2.R46_LAST = true;
+                            RedisHelper.Add($"缁村笇灏旀姄鑷�.R46_LAST", "true", out string msg);
                         }
                     }
                     else
@@ -457,7 +474,8 @@
                     {
                         if (tag.wxr2.R11)
                         {
-                            tag.wxr2.R11_LAST = false;
+                            //tag.wxr2.R11_LAST = false;
+                            RedisHelper.Add($"缁村笇灏旀姄鑷�.R11_LAST", "false", out string msg);
                         }
                         else
                         if (TcpServer.TrayIps.TryGetValue(VERX.deviceNo[1], out string traycode))
@@ -473,7 +491,8 @@
                             {
                                 //Conn.榛樿Redis.SetValue("缁村笇灏旀姄鑷�.R10", "true", "缁村笇灏旀姄鑷�Queue");
                                 tag.wxr2.R11 = true;
-                                tag.wxr2.R46_LAST = false;
+                                //tag.wxr2.R46_LAST = false;
+                                RedisHelper.Add($"缁村笇灏旀姄鑷�.R46_LAST", "false", out string msg);
                             }
                             else
                             {
@@ -597,7 +616,7 @@
                     string tno = "TN" + (DateTime.Now.ToString("yy")) + ((taskno.ToString()).PadLeft(8, '0'));
                     task1 = taskservice.FindEntity(x => x.S_TASK_NO == tno);
 
-                    LogHelper.Info($"RGV 1宸ヤ綅浠诲姟{JsonConvert.SerializeObject(task1)}.bit1taskOver_LAST锛歿tag.RGV.bit1taskOver_LAST}");
+                    LogHelper.Info($"RGV 1宸ヤ綅浠诲姟{task1?.S_TASK_NO}.bit1taskOver_LAST锛歿tag.RGV.bit1taskOver_LAST}");
                     if (tag.RGV.bit1taskOver_LAST == 0 && task1 != null)
                     {
                         if (task1.S_B_STATE != "瀹屾垚")
@@ -881,13 +900,15 @@
 
         public void ThreadGrats(Tag tag, Action<HaiKangOrderInfo> continueTask)
         {
-            Console.WriteLine($"ThreadGrats 鍏夋爡澶勭悊 =================> ");
+            LogHelper.Info($"ThreadGrats 鍏夋爡澶勭悊 =================> ");
+
             var taskCOdes = new List<string> { "Sarrive", "Srelease", "Earrive", "Erelease" };
             TaskActRepository taskActRepository = new TaskActRepository();
             TaskRepository taskRepository = new TaskRepository();
-            var requires = taskActRepository.FindList(x => taskCOdes.Contains(x.S_ACTION_CODE) && x.N_CREATEMETHOD == 0);
+            var requires = taskActRepository.FindList(x => taskCOdes.Contains(x.S_ACTION_CODE) && x.N_CREATEMETHOD == 0).OrderBy(x => x.T_CREATE);
             foreach (var item in requires)
             {
+                LogHelper.Info($"ThreadGrats {item.S_TASK_NO} >{item.S_ACTION_CODE}鍏夋爡澶勭悊 =================> ");
                 var tin = taskCOdes.IndexOf(item.S_ACTION_CODE);
                 if (tin == -1)
                 {
@@ -895,7 +916,13 @@
                     taskActRepository.Update(item);
                     continue;
                 }
-                //var task = taskRepository.FindEntity(x => x.S_TASK_NO == item.S_TASK_NO);
+                var task = taskRepository.FindEntity(x => x.S_TASK_NO == item.S_TASK_NO);
+                if (task == null)
+                {
+                    item.N_CREATEMETHOD = -1;
+                    taskActRepository.Update(item);
+                    continue;
+                }
                 string loc = "";
                 if (tin < 2)
                 {
@@ -911,21 +938,24 @@
                 var dev = Settings.deviceInfos.Find(x => x.location.Contains(loc));
                 if (dev != null)
                 {
+                    LogHelper.Info($"ThreadGrats {item.S_TASK_NO} >{item.S_ACTION_CODE} 璁惧鏄瘂dev.deviceName} 鍏夋爡澶勭悊 =================> ");
                     var V = dev.location.ToList().FindIndex(x => x == loc) == 0;
                     //杞﹁蛋浜� 寮�厜鏍�                     if (!goin)
                     {
                         if (dev.deviceType == 1)
                         {
+                            LogHelper.Info($"ThreadGrats {item.S_TASK_NO} >{item.S_ACTION_CODE} 璁惧鏄瘂dev.deviceName} 寮�惎鍏夋爡澶勭悊 =================> ");
                             LogHelper.Info($"{dev.deviceName}{(V ? "宸� : "鍙�)} 鍏夋爡{(goin ? "鍏抽棴" : "寮�惎")} 鐢宠銆� + string.Format("{0}{1}{2}", dev.deviceName + "." + (V ? "R02" : "R04"), "true", dev.deviceName + "Queue"));
-                            Conn.榛樿Redis.SetValue(dev.deviceName + "." + (V ? "R02" : "R04"), "true", dev.deviceName + "Queue");
-
+                            Conn.榛樿Redis.SetValue(dev.deviceName + "." + (V ? "R02" : "R04"), "true", dev.deviceName + "Queue", false);
                         }
                         else if (dev.deviceType == 2)
                         {
+                            LogHelper.Info($"ThreadGrats {item.S_TASK_NO} >{item.S_ACTION_CODE} 璁惧鏄瘂dev.deviceName} 寮�惎鍏夋爡澶勭悊 =================> ");
                             LogHelper.Info($"{dev.deviceName}{(V ? "宸� : "鍙�)} 鍏夋爡{(goin ? "鍏抽棴" : "寮�惎")} 鐢宠銆� + string.Format("{0}{1}{2}", dev.deviceName + "." + (V ? "D1222" : "D1223"), "1", dev.deviceName + "Queue"));
                             Conn.榛樿Redis.SetValue(dev.deviceName + "." + (V ? "D1222" : "D1223"), "1", dev.deviceName + "Queue");
                         }
+                        LogHelper.Info($"ThreadGrats {item.S_TASK_NO} >{item.S_ACTION_CODE} 璁惧鏄瘂dev.deviceName} 寮�惎鍏夋爡澶勭悊瀹屾垚 =================> ");
 
                         item.N_CREATEMETHOD = 1;
                         taskActRepository.Update(item);
@@ -935,7 +965,9 @@
                     {
                         if (dev.deviceType == 1)
                         {
+                            LogHelper.Info($"ThreadGrats {item.S_TASK_NO} >{item.S_ACTION_CODE} 璁惧鏄瘂dev.deviceName} 鍏抽棴鍏夋爡澶勭悊 =================> ");
                             var tf = Conn.榛樿Redis.GetValue(dev.deviceName + "." + (V ? "R50" : "R52"));//璇诲叧闂姸鎬�+                            LogHelper.Info($"ThreadGrats {item.S_TASK_NO} >{item.S_ACTION_CODE} 璁惧鏄瘂dev.deviceName} 鍏夋爡鍏抽棴淇″彿{tf}");
                             if (tf?.ToLower() == "true")
                             {
                                 LogHelper.Info($"{dev.deviceName}{(V ? "宸� : "鍙�)} 鍏夋爡{(goin ? "鍏抽棴" : "寮�惎")} 鐢宠銆�宸茬粡鍏抽棴锛�);
@@ -944,15 +976,18 @@
                             else
                             {
                                 LogHelper.Info($"{dev.deviceName}{(V ? "宸� : "鍙�)} 鍏夋爡{(goin ? "鍏抽棴" : "寮�惎")} 鐢宠銆� + string.Format("{0}{1}{2}", dev.deviceName + "." + (V ? "R01" : "R03"), "true", dev.deviceName + "Queue"));
-                                Conn.榛樿Redis.SetValue(dev.deviceName + "." + (V ? "R01" : "R03"), "true", dev.deviceName + "Queue");
+                                Conn.榛樿Redis.SetValue(dev.deviceName + "." + (V ? "R01" : "R03"), "true", dev.deviceName + "Queue", false);
                             }
-
+                            LogHelper.Info($"ThreadGrats {item.S_TASK_NO} >{item.S_ACTION_CODE} 璁惧鏄瘂dev.deviceName} 鍏抽棴鍏夋爡澶勭悊瀹屾垚 =================> ");
                         }
                         else if (dev.deviceType == 2)
                         {
+                            LogHelper.Info($"ThreadGrats {item.S_TASK_NO} >{item.S_ACTION_CODE} 璁惧鏄瘂dev.deviceName} 鍏抽棴鍏夋爡澶勭悊 =================> ");
                             var tf = Conn.榛樿Redis.GetValue(dev.deviceName + ".D1202");
                             int numm = int.Parse(string.IsNullOrEmpty(tf) ? "0" : tf);
-                            if (TcpServer.GetBitdata(numm, (V ? 0 : 1)) == 1)
+                            int close = TcpServer.GetBitdata(numm, (V ? 0 : 1));
+                            LogHelper.Info($"ThreadGrats {item.S_TASK_NO} >{item.S_ACTION_CODE} 璁惧鏄瘂dev.deviceName} 鍏夋爡鍏抽棴淇″彿{close}");
+                            if (close == 1)
                             {
                                 LogHelper.Info($"{dev.deviceName}{(V ? "宸� : "鍙�)} 鍏夋爡{(goin ? "鍏抽棴" : "寮�惎")} 鐢宠銆�宸茬粡鍏抽棴锛�);
                                 continuuuuu = true;
@@ -962,6 +997,7 @@
                                 LogHelper.Info($"{dev.deviceName}{(V ? "宸� : "鍙�)} 鍏夋爡{(goin ? "鍏抽棴" : "寮�惎")} 鐢宠銆� + string.Format("{0}{1}{2}", dev.deviceName + "." + (V ? "D1220" : "D1221"), dev.deviceName + "Queue"));
                                 Conn.榛樿Redis.SetValue(dev.deviceName + "." + (V ? "D1220" : "D1221"), "1", dev.deviceName + "Queue");
                             }
+                            LogHelper.Info($"ThreadGrats {item.S_TASK_NO} >{item.S_ACTION_CODE} 璁惧鏄瘂dev.deviceName} 鍏抽棴鍏夋爡澶勭悊瀹屾垚 =================> ");
                         }
 
                     }
@@ -980,6 +1016,7 @@
                 }
             }
             System.Threading.Thread.Sleep(3000);
+            LogHelper.Info($"ThreadGrats deviceType2鍏夋爡鍐欏叆浣嶉噸缃�=================> ");
             //閲嶇疆淇″彿
             foreach (var dev in Settings.deviceInfos.FindAll(x => x.deviceType == 2))
             {
@@ -987,16 +1024,16 @@
                 int numm = int.Parse(string.IsNullOrEmpty(tf) ? "0" : tf);
                 if (TcpServer.GetBitdata(numm, 0) == 0)
                 {
-                    Conn.榛樿Redis.SetValue(dev.deviceName + ".D1220", "0", dev.deviceName + "Queue");
-                    Conn.榛樿Redis.SetValue(dev.deviceName + ".D1222", "0", dev.deviceName + "Queue");
+                    Conn.榛樿Redis.SetValue(dev.deviceName + ".D1220", "0", dev.deviceName + "Queue", false);
+                    Conn.榛樿Redis.SetValue(dev.deviceName + ".D1222", "0", dev.deviceName + "Queue", false);
                 }
                 else if (TcpServer.GetBitdata(numm, 1) == 0)
                 {
-                    Conn.榛樿Redis.SetValue(dev.deviceName + ".D1221", "0", dev.deviceName + "Queue");
-                    Conn.榛樿Redis.SetValue(dev.deviceName + ".D1223", "0", dev.deviceName + "Queue");
+                    Conn.榛樿Redis.SetValue(dev.deviceName + ".D1221", "0", dev.deviceName + "Queue", false);
+                    Conn.榛樿Redis.SetValue(dev.deviceName + ".D1223", "0", dev.deviceName + "Queue", false);
                 }
             }
-
+            LogHelper.Info($"ThreadGrats deviceType2鍏夋爡鍐欏叆浣嶉噸缃畬鎴愩� =================> ");
         }
         /// <summary>
         /// 1020  1023绌烘涓嬬嚎

--
Gitblit v1.9.1