From 8f392cc88b0768b74efca3b68785cf5aa1c38e70 Mon Sep 17 00:00:00 2001
From: wangxinhui <wangxinhui@hnkhzn.com>
Date: 星期三, 06 十一月 2024 14:28:20 +0800
Subject: [PATCH] 代码更新

---
 wcs-server-hbf/WIDESEA_WCS/Jobs/AGV/AGVUpdateStatusJob.cs |   40 ++++++++++++++++++++++++++++------------
 1 files changed, 28 insertions(+), 12 deletions(-)

diff --git a/wcs-server-hbf/WIDESEA_WCS/Jobs/AGV/AGVUpdateStatusJob.cs b/wcs-server-hbf/WIDESEA_WCS/Jobs/AGV/AGVUpdateStatusJob.cs
index 1237aea..710b017 100644
--- a/wcs-server-hbf/WIDESEA_WCS/Jobs/AGV/AGVUpdateStatusJob.cs
+++ b/wcs-server-hbf/WIDESEA_WCS/Jobs/AGV/AGVUpdateStatusJob.cs
@@ -9,6 +9,7 @@
 using System.Runtime.Serialization.Json;
 using System.Security.Policy;
 using System.Text;
+using System.Threading;
 using System.Threading.Tasks;
 using WIDESEA_Common.Tools;
 using WIDESEA_Entity.DomainModels.Equipment;
@@ -17,6 +18,7 @@
 using WIDESEA_WCS.JobsPart.AGV;
 using WIDESEA_WCS.SchedulerExecute.AGV;
 using WIDESEA_WCS.WCSClient;
+using static FreeSql.Internal.GlobalFilter;
 
 namespace WIDESEA_WCS
 {
@@ -26,6 +28,7 @@
     [DisallowConcurrentExecution]
     public class AGVUpdateStatusJob : JobBase, IJob
     {
+        private static int lockObj1 = 0;
         public Task Execute(IJobExecutionContext context)
         {
             try
@@ -37,23 +40,36 @@
         }
         private void DoAction(IJobExecutionContext context)
         {
-            try
+            if (lockObj1 == 0)
             {
-                List<string> AGVS = new List<string> { "缁勮AGV璋冨害", "姝f瀬AGV璋冨害", "璐熸瀬AGV璋冨害", "缁勮AGV璋冨害" };
-                foreach (var item in AGVS)
+                try
                 {
-                    PLCClient pLCClient = WCSService.Clients.Find(v => v.PLCName == item);
-                    if (pLCClient == null)
+                    lockObj1 = 1;
+                    Task task = Task.Run(() =>
                     {
-                        continue;
-                    }
-                    AGVSchedulerExecute.UpdateAgvTask(pLCClient);
+                        List<string> AGVS = new List<string> { "缁勮AGV璋冨害", "姝f瀬AGV璋冨害", "璐熸瀬AGV璋冨害" };
+                        while (true) 
+                        {
+                            foreach (var item in AGVS)
+                            {
+                                PLCClient pLCClient = WCSService.Clients.Find(v => v.PLCName == item);
+                                if (pLCClient == null)
+                                {
+                                    continue;
+                                }
+                                AGVSchedulerExecute.UpdateAgvTaskText(pLCClient);
+                            }
+                            Thread.Sleep(200);
+                        }
+                    });
+                }
+                catch (Exception ex)
+                {
+                    lockObj1 = 0;
+                    throw new Exception(ex.Message);
                 }
             }
-            catch (Exception ex)
-            {
-                throw new Exception(ex.Message);
-            }
+
         }
     }
 }

--
Gitblit v1.9.3