From e46aa927d231af83724683c7286d9db503e24cf7 Mon Sep 17 00:00:00 2001
From: z8018 <1282578289@qq.com>
Date: 星期二, 10 六月 2025 11:46:20 +0800
Subject: [PATCH] 1

---
 项目代码/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/CommonConveyorLineStationJob.cs |   39 +++++++++++++++++++++++++++++++++------
 1 files changed, 33 insertions(+), 6 deletions(-)

diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/CommonConveyorLineStationJob.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/CommonConveyorLineStationJob.cs"
index 320385a..e90bcc2 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/CommonConveyorLineStationJob.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/CommonConveyorLineStationJob.cs"
@@ -37,6 +37,18 @@
 
 namespace WIDESEAWCS_Tasks
 {
+    /// <summary>
+    /// 閫氱敤杈撻�佺嚎绔欏彴浠诲姟绫伙紝鐢ㄤ簬澶勭悊杈撻�佺嚎绔欏彴鐨凱LC淇″彿浜や簰鍜屼换鍔$鐞�
+    /// </summary>
+    /// <remarks>
+    /// 1. 瀹炵幇IJob鎺ュ彛锛屼綔涓篞uartz.NET鐨勫畾鏃朵换鍔� <br/>
+    /// 2. 閫氳繃DisallowConcurrentExecution鐗规�ч槻姝㈠苟鍙戞墽琛� <br/>
+    /// 3. 涓昏鍔熻兘锛� <br/>
+    ///    - 鐩戞帶PLC绔欏彴璇锋眰淇″彿 <br/>
+    ///    - 澶勭悊浠诲姟閲嶆柊鐢熸垚閫昏緫 <br/>
+    ///    - 鏇存柊浠诲姟鐘舵�� <br/>
+    ///    - 璁剧疆PLC鍝嶅簲淇″彿
+    /// </remarks>
     [DisallowConcurrentExecution]
     public class CommonConveyorLineStationJob : JobBase, IJob
     {
@@ -44,19 +56,21 @@
 
         private readonly ITaskRepository _taskRepository;
 
-        public CommonConveyorLineStationJob(IMapper mapper, ITaskRepository taskRepository)
+        private readonly ITaskService _taskService;
+
+        public CommonConveyorLineStationJob(IMapper mapper, ITaskRepository taskRepository, ITaskService taskService)
         {
             _mapper = mapper;
             _taskRepository = taskRepository;
+            _taskService = taskService;
         }
 
 
         public Task Execute(IJobExecutionContext context)
         {
             bool flag = context.JobDetail.JobDataMap.TryGetValue("JobParams", out object? value);
-            if (flag && value != null && value is OtherDevice)
+            if (flag && value != null && value is OtherDevice otherDevice)
             {
-                OtherDevice otherDevice = (OtherDevice)value;
                 try
                 {
                     List<string> deviceChildCodes = otherDevice.DeviceProDTOs.GroupBy(x => x.DeviceChildCode).Select(x => x.Key).ToList();
@@ -64,7 +78,6 @@
                     {
                         bool request = otherDevice.GetValue<ConveyorLineStationDBName, bool>(ConveyorLineStationDBName.PLCStationRequest, deviceChildCodes[i]);   //鐢宠
                         bool response = otherDevice.GetValue<ConveyorLineStationDBName, bool>(ConveyorLineStationDBName.PLCStationResponse, deviceChildCodes[i]);    //搴旂瓟
-
                         bool wcsResponse = otherDevice.GetValue<ConveyorLineStationDBName, bool>(ConveyorLineStationDBName.WCSStationResponse, deviceChildCodes[i]);    //搴旂瓟
 
                         if (request && !response && !wcsResponse)
@@ -75,8 +88,22 @@
                                 Dt_Task task = _taskRepository.QueryFirst(x => x.TaskNum == taskNum);
                                 if (task != null)
                                 {
-                                    task.TaskState = TaskStatusEnum.Gantry_New.ObjToInt();
-                                    _taskRepository.UpdateData(task);
+                                    if (task.TaskState == TaskStatusEnum.Gantry_BeReassign.ObjToInt())
+                                    {
+                                        var (taskFlag, gTask, message) = _taskService.RegenerateTask(task, deviceChildCodes[i]);
+                                        if (!taskFlag || gTask == null)
+                                        {
+                                            otherDevice.SetValue(ConveyorLineStationDBName.WCSStationTarget, 8, deviceChildCodes[i]);
+                                            otherDevice.SetValue(ConveyorLineStationDBName.WCSStationResponse, true, deviceChildCodes[i]);
+                                            continue;
+                                        }
+                                    }
+                                    else
+                                    {
+                                        task.TaskState = TaskStatusEnum.Gantry_New.ObjToInt();
+                                        _taskRepository.UpdateData(task);
+                                    }
+
                                     otherDevice.SetValue(ConveyorLineStationDBName.WCSStationTarget, 0, deviceChildCodes[i]);
                                     otherDevice.SetValue(ConveyorLineStationDBName.WCSStationResponse, true, deviceChildCodes[i]);
                                 }

--
Gitblit v1.9.3