wangxinhui
2024-11-06 8f392cc88b0768b74efca3b68785cf5aa1c38e70
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调度", "正极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调度", "正极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);
            }
        }
    }
}