From 4485cf13b64f8a2bde6609b7d9ecc1cd4f33868b Mon Sep 17 00:00:00 2001
From: huangxiaoqiang <huangxiaoqiang@hnkhzn.com>
Date: 星期二, 25 十一月 2025 11:02:12 +0800
Subject: [PATCH] 1

---
 项目代码/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs |  102 +++++++++++++++++++++++++++++++--------------------
 1 files changed, 62 insertions(+), 40 deletions(-)

diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs"
index 06af2dd..3ac4875 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs"
@@ -9,6 +9,7 @@
 using WIDESEAWCS_BasicInfoRepository;
 using WIDESEAWCS_Common;
 using WIDESEAWCS_Common.TaskEnum;
+using WIDESEAWCS_Communicator;
 using WIDESEAWCS_Core;
 using WIDESEAWCS_Core.Caches;
 using WIDESEAWCS_Core.Helper;
@@ -63,7 +64,6 @@
         {
             try
             {
-
                 CommonStackerCrane commonStackerCrane = (CommonStackerCrane)context.JobDetail.JobDataMap.Get("JobParams");
                 if (commonStackerCrane != null)
                 {
@@ -87,9 +87,11 @@
                                     bool sendFlag = commonStackerCrane.SendCommand(stackerCraneTaskCommand);
                                     if (sendFlag)
                                     {
+                                        Thread.Sleep(1000);
+                                        commonStackerCrane.Communicator.Write("DB100.18.0", Convert.ToInt16(1));
                                         commonStackerCrane.LastTaskType = task.TaskType;
                                         _taskService.UpdateTaskStatusToNext(task.TaskNum);
-                                        Thread.Sleep(1000);
+                                        Thread.Sleep(2000);
                                     }
                                 }
                             }
@@ -237,42 +239,40 @@
                     ConsoleHelper.WriteColorLine(str, ConsoleColor.Blue);
                     var task = _taskRepository.QueryFirst(x => x.TaskNum == e.TaskNum);
 
-                    if (task == null) commonStackerCrane.SetValue(StackerCraneDBName.FinishConfirm, 1);
-                    string WorkStatus = $"銆恵commonStackerCrane.StackerCraneWorkStatusValue}銆�";
-                    bool IsWrite = false;
+                    if (task == null)
+                    {
+                        commonStackerCrane.SetValue(StackerCraneDBName.FinishConfirm, 1);
+                        return;
+                    }
                     var content = _taskService.StackCraneTaskCompleted(e.TaskNum);
 
-                    if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup)
-                    {
-                        CommonConveyorLine? conveyorLine = Storage.Devices.FirstOrDefault(x => x.DeviceCode == "1001") as CommonConveyorLine;
-                        if (conveyorLine != null)
-                        {
-                            short InteractiveSignal = conveyorLine.GetValue<ConveyorLineDBName, short>(ConveyorLineDBName.InteractiveSignal, "LK001");
-                            var structs = BitConverter.GetBytes(InteractiveSignal).Reverse().ToArray().ToBoolArray();
-                            if (structs[0])
-                            {
-                                IsWrite = conveyorLine.Communicator.WriteNoRead("DB100.0", 0);
-                                Thread.Sleep(1000);
-                                IsWrite = conveyorLine.Communicator.WriteNoRead("DB100.0", 9999);
-                                if (!IsWrite)
-                                {
-                                    return;
-                                }
-                            }
-                        }
-                        var station = _stationManagerRepository.QueryFirst(x => x.stationChildCode == task.TargetAddress);
-                        if (station != null)
-                        {
-                            _taskService.SendAgvTask(station.stationRemark, task.TaskNum);
-                            _taskService.UpdateTaskStatusToNext(task.TaskNum);
-                        }
-                    }
+                    #region
+                    //if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup)
+                    //{
+                    //    CommonConveyorLine? conveyorLine = Storage.Devices.FirstOrDefault(x => x.DeviceCode == "1001") as CommonConveyorLine;
+                    //    if (conveyorLine != null)
+                    //    {
+                    //        short InteractiveSignal = conveyorLine.GetValue<ConveyorLineDBName, short>(ConveyorLineDBName.InteractiveSignal, "LK001");
+                    //        var structs = BitConverter.GetBytes(InteractiveSignal).Reverse().ToArray().ToBoolArray();
+                    //        if (structs[0])
+                    //        {
+                    //            IsWrite = conveyorLine.Communicator.WriteNoRead("DB100.0", Convert.ToInt32(9999));
+                    //            conveyorLine.Communicator.WriteNoRead("DB100.4", Convert.ToInt16(task.TaskNum));
+                    //            if (!IsWrite)
+                    //            {
+                    //                return;
+                    //            }
+                    //        }
+                    //    }
 
-                    var isWorkType = commonStackerCrane.SetValue(StackerCraneDBName.FinishConfirm, 1);
+                    //    _taskService.UpdateTaskStatusToNext(task.TaskNum);
+                    //}
+                    #endregion
 
+                    var isWorkType = commonStackerCrane.Communicator.WriteNoRead("DB100.0", Convert.ToInt16(1));
 
-                    str = $"{commonStackerCrane.DeviceName}銆慦MS|WCS浠诲姟瀹屾垚锛氥�恵content.Status}{content.Message}銆�,鍫嗗灈鏈哄畬鎴愪俊鍙峰啓鍏ワ細銆恵isWorkType}銆�,浠诲姟鍙凤細銆恵e.TaskNum}銆戞椂闂淬�恵DateTime.Now}銆戣緭閫佺嚎鍐欏叆{IsWrite}";
-                    WriteInfo(commonStackerCrane.DeviceName, str + WorkStatus);
+                    str = $"{commonStackerCrane.DeviceName}銆慦MS|WCS浠诲姟瀹屾垚锛氥�恵content.Status}{content.Message}銆�,鍫嗗灈鏈哄畬鎴愪俊鍙峰啓鍏ワ細銆恵isWorkType}銆�,浠诲姟鍙凤細銆恵e.TaskNum}銆戞椂闂淬�恵DateTime.Now}銆�";
+                    WriteInfo(commonStackerCrane.DeviceName, str);
                     ConsoleHelper.WriteColorLine(str, ConsoleColor.Blue);
                 }
             }
@@ -286,6 +286,11 @@
         private Dt_Task? GetTask(CommonStackerCrane commonStackerCrane)
         {
             Dt_Task task;
+            if (_taskService.QueryExecutingTask(commonStackerCrane.DeviceCode) != null)
+            {
+                return null;
+            }
+
             task = _taskService.QueryRelocationTask(commonStackerCrane.DeviceCode);
             if (task != null)
             {
@@ -315,11 +320,12 @@
 
             if (task != null && task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup)
             {
-                var InTask = _taskRepository.QueryFirst(x => x.TaskState > (int)TaskInStatusEnum.InNew && x.TaskState< (int)TaskInStatusEnum.SC_InExecuting);
+                var InTask = _taskRepository.QueryFirst(x => x.TaskState > (int)TaskInStatusEnum.InNew && x.TaskState < (int)TaskInStatusEnum.SC_InExecuting);
                 var OutTask = _taskRepository.QueryFirst(x => x.TaskState > (int)TaskOutStatusEnum.OutNew && x.TaskState < (int)TaskOutStatusEnum.AGV_OutExecuting);
                 if (InTask != null)
                 {
-                    return null;
+                    task= _taskRepository.QueryFirst(x => x.TaskState == (int)TaskInStatusEnum.Line_InFinish && x.Roadway == commonStackerCrane.DeviceCode);
+                    return task;
                 }
                 else if (OutTask != null)
                 {
@@ -363,8 +369,16 @@
 
                         if (taskDTO.TaskNum != task.TaskNum)
                         {
-                            _taskService.ReceiveWMSTask(new List<WMSTaskDTO> { taskDTO });
-                            return _taskRepository.QueryFirst(x => x.TaskNum == taskDTO.TaskNum);
+                            var taskNew=_taskRepository.QueryFirst(x=>x.PalletCode==taskDTO.PalletCode);
+                            if (taskNew != null)
+                            {
+                                task = taskNew;
+                            }
+                            else
+                            {
+                                _taskService.ReceiveWMSTask(new List<WMSTaskDTO> { taskDTO });
+                                task = _taskRepository.QueryFirst(x => x.TaskNum == taskDTO.TaskNum);
+                            } 
                         }
                     }
 
@@ -373,24 +387,33 @@
                     {
                         short InteractiveSignal = conveyorLine.GetValue<ConveyorLineDBName, short>(ConveyorLineDBName.InteractiveSignal, "LK001");
                         var structs = BitConverter.GetBytes(InteractiveSignal).Reverse().ToArray().ToBoolArray();
+                        if (structs[1])
+                        {
+                            task.ExceptionMessage = "杈撻�佺嚎鏈夎揣鏆備笉涓嬪彂鍑哄簱浠诲姟";
+                            _taskRepository.UpdateData(task);
+                            return null;
+                        }
                         if (structs[0] && !structs[2] && !structs[1])
                         {
-                            conveyorLine.Communicator.WriteNoRead("DB100.0", 9990);
+                            conveyorLine.Communicator.Write("DB100.0", 9990);
                         }
                         if (structs[0] && structs[2])
                         {
-                            conveyorLine.Communicator.WriteNoRead("DB100.0", 9990);
+                            conveyorLine.Communicator.Write("DB100.0", 9990);
                             return task;
                         }
                         else
                         {
                             task.ExceptionMessage = "璇锋鏌ヨ緭閫佺嚎鏄惁鏄嚜鍔ㄦā寮忔垨宸茬粡绉诲姩鍒板嚭搴撳彛";
+                            _taskRepository.UpdateData(task);
                             return null;
                         }
+
                     }
                     else
                     {
                         task.ExceptionMessage = "杈撻�佺嚎璁惧鏂紑杩炴帴";
+                        _taskRepository.UpdateData(task);
                         return null;
                     }
                 }   
@@ -481,7 +504,6 @@
 
             stackerCraneTaskCommand.TaskNum = Convert.ToInt16(task.TaskNum);
             stackerCraneTaskCommand.WorkType = Convert.ToInt16(1);
-            stackerCraneTaskCommand.StartCommand = Convert.ToInt16(1);
             if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.InboundGroup)//鍒ゆ柇鏄惁鏄叆搴撲换鍔�
             {
                 var station = _stationManagerRepository.QueryFirst(x => x.stationType == 1 && x.stationChildCode == task.CurrentAddress);

--
Gitblit v1.9.3