From cb25acc46bf41863e068b6f968f1592b7a14d1c9 Mon Sep 17 00:00:00 2001
From: helongyang <647556386@qq.com>
Date: 星期六, 13 九月 2025 08:12:14 +0800
Subject: [PATCH] 功能更新优化

---
 代码管理/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/干膜仓/StackerCraneJob_GM.cs |   28 +++++++++++++++++++++++++---
 1 files changed, 25 insertions(+), 3 deletions(-)

diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/\345\271\262\350\206\234\344\273\223/StackerCraneJob_GM.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/\345\271\262\350\206\234\344\273\223/StackerCraneJob_GM.cs"
index e8111b2..bdc3052 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/\345\271\262\350\206\234\344\273\223/StackerCraneJob_GM.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/\345\271\262\350\206\234\344\273\223/StackerCraneJob_GM.cs"
@@ -28,6 +28,8 @@
 using WIDESEAWCS_QuartzJob.Repository;
 using WIDESEAWCS_DTO.TaskInfo;
 using AutoMapper;
+using HslCommunication.WebSocket;
+using WIDESEAWCS_Tasks.骞茶啘浠�;
 
 namespace WIDESEAWCS_Tasks
 {
@@ -38,13 +40,15 @@
         private readonly ITaskService _taskService;
         private readonly ITaskExecuteDetailService _taskExecuteDetailService;
         private readonly ITaskRepository _taskRepository;
+        public static GMReadData gMReadData = new GMReadData();
         private readonly IRouterService _routerService;
         private readonly IStationMangerRepository _stationMangerRepository;
         private readonly IRouterRepository _routerRepository;
         private readonly IMapper _mapper;
         private List<Dt_ApiInfo> apiInfos;
+        private WebSocketServer _webSocketServer;
 
-        public StackerCraneJob_GM(ITaskService taskService, ICacheService cacheService, ITaskExecuteDetailService taskExecuteDetailService, ITaskRepository taskRepository, IRouterService routerService, IStationMangerRepository stationMangerRepository, IRouterRepository routerRepository, IMapper mapper)
+        public StackerCraneJob_GM(ITaskService taskService, ICacheService cacheService, ITaskExecuteDetailService taskExecuteDetailService, ITaskRepository taskRepository, IRouterService routerService, IStationMangerRepository stationMangerRepository, IRouterRepository routerRepository, IMapper mapper,WebSocketServer webSocketServer)
         {
             _taskService = taskService;
             _taskExecuteDetailService = taskExecuteDetailService;
@@ -54,6 +58,7 @@
             _cacheService = cacheService;
             _routerRepository = routerRepository;
             _mapper = mapper;
+            _webSocketServer = webSocketServer;
 
             string? apiInfoStr = _cacheService.Get("apiInfos");
             if (!string.IsNullOrEmpty(apiInfoStr))
@@ -74,6 +79,7 @@
         {
             try
             {
+                Thread.Sleep(2200);
                 CommonStackerCrane commonStackerCrane = (CommonStackerCrane)context.JobDetail.JobDataMap.Get("JobParams");
                 if (commonStackerCrane != null)
                 {
@@ -110,6 +116,14 @@
                             }
                         }
                     }
+                    gMReadData.R_GM_Status = ((short)commonStackerCrane.StackerCraneStatusValue);
+                    gMReadData.R_GM_AutoStatus = ((short)commonStackerCrane.StackerCraneAutoStatusValue);
+                    gMReadData.R_GM_WorkStatus = ((short)commonStackerCrane.StackerCraneWorkStatusValue);
+                    gMReadData.R_GM_TaskNum = commonStackerCrane.CurrentTaskNum.ObjToInt();
+                    gMReadData.R_GM_WorkType = commonStackerCrane.GetValue<StackerCraneDBName, short>(StackerCraneDBName.WorkType);
+                    gMReadData.R_GM_TrayType = commonStackerCrane.GetValue<StackerCraneDBName, short>(StackerCraneDBName.TrayType);
+                    string gMData = JsonConvert.SerializeObject(gMReadData);
+                    _webSocketServer.PublishAllClientPayload(gMData);
                 }
             }
             catch (Exception ex)
@@ -275,7 +289,6 @@
                     WriteError(commonStackerCrane.DeviceCode, $"绉诲簱鎺ュ彛璋冪敤閿欒");
                     _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"绉诲簱鎺ュ彛璋冪敤閿欒");
                     return null;
-
                 }
                 if (task.TaskNum == taskDTO.TaskNum)
                 {
@@ -286,10 +299,19 @@
                     Dt_Task reloTask = _mapper.Map<Dt_Task>(taskDTO);
                     //鍒ゆ柇绉诲簱璐т綅浠诲姟鏄惁宸插瓨鍦紝濡傚瓨鍦ㄥ厛鎵ц
                     Dt_Task existTask = _taskService.QueryStackerExistTask(reloTask.PalletCode, reloTask.SourceAddress);
-                    if (existTask != null)
+                    if (existTask != null && existTask.TaskState == (int)TaskStatusEnum.SC_Execute)
                     {
+                        Dt_StationManger? stationManger = _stationMangerRepository.QueryFirst(x => (x.StationCode == task.NextAddress || x.StackerCraneStationCode == task.NextAddress) && x.StackerCraneCode == task.DeviceCode);
+                        existTask.NextAddress = stationManger.StackerCraneStationCode;
+                        _taskRepository.UpdateData(existTask);
                         return existTask;
                     }
+                    else if (existTask != null && existTask.TaskState != (int)TaskStatusEnum.SC_Execute)
+                    {
+                        WriteError(commonStackerCrane.DeviceCode, $"浠诲姟{task.TaskNum}娴呰揣浣嶄换鍔existTask.TaskNum}浠诲姟鐘舵�佷笉涓哄爢鍨涘緟鎵ц");
+                        _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"浠诲姟{task.TaskNum}娴呰揣浣嶄换鍔existTask.TaskNum}浠诲姟鐘舵�佷笉涓哄爢鍨涘緟鎵ц");
+                        return null;
+                    }
                     else
                     {
                         reloTask.TaskState = TaskStatusEnum.SC_Execute.ObjToInt();

--
Gitblit v1.9.3