From 52ba6b195a4126df405ef453d52ba6eaab6521da Mon Sep 17 00:00:00 2001
From: yanjinhui <3306209981@qq.com>
Date: 星期五, 17 四月 2026 17:37:32 +0800
Subject: [PATCH] 优化3-4楼提升机以及添加报错接口

---
 代码管理/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskMethods.cs |  183 +++++++++++++++++++++++++++++----------------
 1 files changed, 118 insertions(+), 65 deletions(-)

diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskMethods.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskMethods.cs"
index f234fcb..7f50277 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskMethods.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskMethods.cs"
@@ -3,6 +3,7 @@
 using NetTaste;
 using OfficeOpenXml.FormulaParsing.Excel.Functions.Text;
 using System;
+using System.Collections;
 using System.Collections.Generic;
 using System.Linq;
 using System.Net.NetworkInformation;
@@ -101,6 +102,44 @@
                                 //鍏ユ彁鍗囨満
                                 if (task.TaskType == TaskTypeEnum.RK3F.ObjToInt() && task.TaskState == (int)TaskStatusEnum.CheckPalletCodeFinish)
                                 {
+                                    if (task.CurrentAddress==task.TargetAddress)
+                                    {
+                                        var device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == "TSJ") as OtherDevice;
+                                        if (device == null) task.ExceptionMessage = "鏈壘鍒版彁鍗囨満淇℃伅";
+                                        else
+                                        {
+                                            bool Work = false;
+                                            try
+                                            {
+                                                if (device.IsConnected)
+                                                {
+                                                    int i = 0;
+                                                    while (!Work && i <= 3)
+                                                    {
+                                                        i++;
+                                                        Work = device.SetValue(HoistEnum.Inboundboxon, 1, task.CurrentAddress);
+                                                        Thread.Sleep(500);
+                                                    }
+                                                }
+                                                if (!Work)
+                                                {
+                                                    task.ExceptionMessage = $"銆恵task.CurrentAddress}銆戝啓鍏�3妤煎叆搴撶鏀惧埌浣嶅け璐�";
+                                                    task.Remark = $"{device.DeviceCode}_Inboundboxon_{1}_{task.CurrentAddress}";
+                                                }
+                                            }
+                                            catch (Exception ex)
+                                            {
+                                                task.ExceptionMessage = $"銆恵task.CurrentAddress}銆戝啓鍏�3妤煎叆搴撶鏀惧埌浣嶅け璐ワ紒{ex.Message}";
+                                                task.Remark = $"{device.DeviceCode}_Inboundboxon_{1}_{task.CurrentAddress}";
+                                            }
+                                        }
+                                        BaseDal.UpdateData(task);
+                                    }
+                                }
+
+                                //3 鍑烘彁鍗囨満 涔嬪墠鏄疉GV_ToExecute
+                                else if (task.TaskType == TaskTypeEnum.CK3F.ObjToInt() && task.TaskState == (int)TaskStatusEnum.TakeFinish)
+                                {
                                     var device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == "TSJ") as OtherDevice;
                                     if (device == null) task.ExceptionMessage = "鏈壘鍒版彁鍗囨満淇℃伅";
                                     else
@@ -114,48 +153,22 @@
                                                 while (!Work && i <= 3)
                                                 {
                                                     i++;
-                                                    Work = device.SetValue(HoistEnum.Inboundboxon, 1, task.TargetAddress);
+                                                    Work = device.SetValue(HoistEnum.Outboundboxon, 1, task.SourceAddress);//鍑哄簱瀹屾垚
                                                     Thread.Sleep(500);
                                                 }
                                             }
                                             if (!Work)
                                             {
-                                                task.ExceptionMessage = $"銆恵task.TargetAddress}銆戝啓鍏�3妤煎叆搴撶鏀惧埌浣嶅け璐�";
-                                                task.Remark = $"{device.DeviceCode}_Inboundboxon_{1}_{task.TargetAddress}";
+                                                task.ExceptionMessage = $"銆恵task.SourceAddress}銆戝啓鍏�3妤煎嚭搴撶鏀惧埌浣嶅け璐�";
+                                                task.Remark = $"{device.DeviceCode}_Outboundboxon_{1}_{task.SourceAddress}";
                                             }
                                         }
                                         catch (Exception ex)
                                         {
-                                            task.ExceptionMessage = $"銆恵task.TargetAddress}銆戝啓鍏�3妤煎叆搴撶鏀惧埌浣嶅け璐ワ紒{ex.Message}";
-                                            task.Remark = $"{device.DeviceCode}_Inboundboxon_{1}_{task.TargetAddress}";
+                                            task.ExceptionMessage = $"銆恵task.SourceAddress}銆戝啓鍏�3妤煎嚭搴撶鏀惧埌浣嶅け璐ex.Message}";
+                                            task.Remark = $"{device.DeviceCode}_Outboundboxon_{1}_{task.SourceAddress}"; throw;
                                         }
-                                    }
-                                    BaseDal.UpdateData(task);
-                                }
-
-                                //3 鍑烘彁鍗囨満 涔嬪墠鏄疉GV_ToExecute
-                                else if (task.TaskType == TaskTypeEnum.CK3F.ObjToInt() && task.TaskState == (int)TaskStatusEnum.TakeFinish)
-                                {
-                                    var device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == "TSJ") as OtherDevice;
-                                    if (device == null) task.ExceptionMessage = "鏈壘鍒版彁鍗囨満淇℃伅";
-                                    else
-                                    {
-                                        bool Work = false;
-                                        if (device.IsConnected)
-                                        {
-                                            int i = 0;
-                                            while (!Work && i <= 3)
-                                            {
-                                                i++;
-                                                Work = device.SetValue(HoistEnum.Outboundboxon, 1, task.SourceAddress);//鍑哄簱瀹屾垚
-                                                Thread.Sleep(500);
-                                            }
-                                        }
-                                        if (!Work)
-                                        {
-                                            task.ExceptionMessage = $"銆恵task.SourceAddress}銆戝啓鍏�3妤煎嚭搴撶鏀惧埌浣嶅け璐�";
-                                            task.Remark = $"{device.DeviceCode}_Outboundboxon_{1}_{task.SourceAddress}";
-                                        }
+                                        
                                     }
                                     BaseDal.UpdateData(task);
                                 }
@@ -167,21 +180,31 @@
                                     else
                                     {
                                         bool Work = false;
-                                        if (device.IsConnected)
+                                        try
                                         {
-                                            int i = 0;
-                                            while (!Work && i <= 3)
+                                            if (device.IsConnected)
                                             {
-                                                i++;
-                                                Work = device.SetValue(HoistEnum.Emptyboxplacedinposition, 1, task.TargetAddress);
-                                                Thread.Sleep(500);
+                                                int i = 0;
+                                                while (!Work && i <= 3)
+                                                {
+                                                    i++;
+                                                    Work = device.SetValue(HoistEnum.Emptyboxplacedinposition, 1, task.TargetAddress);
+                                                    Thread.Sleep(500);
+                                                }
+                                            }
+                                            if (!Work)
+                                            {
+                                                task.ExceptionMessage = $"銆恵task.TargetAddress}銆戝啓鍏�4妤肩┖绠辨斁鍒颁綅澶辫触";
+                                                task.Remark = $"{device.DeviceCode}_Emptyboxplacedinposition_{1}_{task.TargetAddress}";
                                             }
                                         }
-                                        if (!Work)
+                                        catch (Exception ex)
                                         {
-                                            task.ExceptionMessage = $"銆恵task.TargetAddress}銆戝啓鍏�4妤肩┖绠辨斁鍒颁綅澶辫触";
+
+                                            task.ExceptionMessage = $"銆恵task.TargetAddress}銆戝啓鍏�4妤肩┖绠辨斁鍒颁綅澶辫触{ex.Message}";
                                             task.Remark = $"{device.DeviceCode}_Emptyboxplacedinposition_{1}_{task.TargetAddress}";
                                         }
+                                        
                                     }
                                     BaseDal.UpdateData(task);
                                 }
@@ -193,21 +216,31 @@
                                     else
                                     {
                                         bool Work = false;
-                                        if (device.IsConnected)
+                                        try
                                         {
-                                            int i = 0;
-                                            while (!Work && i <= 3)
+                                            if (device.IsConnected)
                                             {
-                                                i++;
-                                                Work = device.SetValue(HoistEnum.Outboundboxretrievalcompleted, 1, task.SourceAddress);
-                                                Thread.Sleep(500);
+                                                int i = 0;
+                                                while (!Work && i <= 3)
+                                                {
+                                                    i++;
+                                                    Work = device.SetValue(HoistEnum.Outboundboxretrievalcompleted, 1, task.SourceAddress);
+                                                    Thread.Sleep(500);
+                                                }
+                                            }
+                                            if (!Work)
+                                            {
+                                                task.ExceptionMessage = $"銆恵task.SourceAddress}銆戝啓鍏�4妤煎嚭搴撳彇绠卞畬鎴愬け璐�";
+                                                task.Remark = $"{device.DeviceCode}_Outboundboxretrievalcompleted_{1}_{task.SourceAddress}";
                                             }
                                         }
-                                        if (!Work)
+                                        catch (Exception ex)
                                         {
-                                            task.ExceptionMessage = $"銆恵task.SourceAddress}銆戝啓鍏�4妤煎嚭搴撳彇绠卞畬鎴愬け璐�";
+
+                                            task.ExceptionMessage = $"銆恵task.SourceAddress}銆戝啓鍏�4妤煎嚭搴撳彇绠卞畬鎴愬け璐ex.Message}";
                                             task.Remark = $"{device.DeviceCode}_Outboundboxretrievalcompleted_{1}_{task.SourceAddress}";
                                         }
+                                      
                                     }
                                     BaseDal.UpdateData(task);
                                 }
@@ -220,21 +253,31 @@
                                     {
                                         bool Wok = false;
                                         var Address = task.TaskType == TaskTypeEnum.Q3RK.ObjToInt() ? task.TargetAddress : task.SourceAddress;
-                                        if (device.IsConnected)
+                                        try
                                         {
-                                            int i = 0;
-                                            while (!Wok && i <= 3)
+                                            if (device.IsConnected)
                                             {
-                                                i++;
-                                                Wok = device.SetValue(QualityInspectionCommandEnum.RequestToEnter, false, Address);
-                                                Thread.Sleep(500);
+                                                int i = 0;
+                                                while (!Wok && i <= 3)
+                                                {
+                                                    i++;
+                                                    Wok = device.SetValue(QualityInspectionCommandEnum.RequestToEnter, false, Address);
+                                                    Thread.Sleep(500);
+                                                }
+                                            }
+                                            if (!Wok)
+                                            {
+                                                task.ExceptionMessage = $"銆恵Address}銆戝叧闂姹傝繘鍏ュけ璐ワ紒";
+                                                task.Remark = $"{device.DeviceCode}_RequestToEnter_{false}_{Address}";
                                             }
                                         }
-                                        if (!Wok)
+                                        catch (Exception ex)
                                         {
-                                            task.ExceptionMessage = $"銆恵Address}銆戝叧闂姹傝繘鍏ュけ璐ワ紒";
+
+                                            task.ExceptionMessage = $"銆恵Address}銆戝叧闂姹傝繘鍏ュけ璐ワ紒{ex.Message}";
                                             task.Remark = $"{device.DeviceCode}_RequestToEnter_{false}_{Address}";
                                         }
+                                        
                                     }
                                     BaseDal.UpdateData(task);
                                 }
@@ -254,21 +297,31 @@
                                 else
                                 {
                                     bool Wok = false;
-                                    if (device.IsConnected)
+                                    try
                                     {
-                                        int i = 0;
-                                        while (!Wok && i <= 3)
+                                        if (device.IsConnected)
                                         {
-                                            i++;
-                                            Wok = device.SetValue<HoistEnum, short>(HoistEnum.Codereadingtriggered, 1, "TSJR3F");
-                                            Thread.Sleep(500);
+                                            int i = 0;
+                                            while (!Wok && i <= 3)
+                                            {
+                                                i++;
+                                                Wok = device.SetValue<HoistEnum, short>(HoistEnum.Codereadingtriggered, 1, "TSJR3F");
+                                                Thread.Sleep(500);
+                                            }
+                                        }
+                                        if (!Wok)
+                                        {
+                                            task.ExceptionMessage = $"銆怲SJR3F銆�3妤艰鐮佽Е鍙戝け璐ワ紒";
+                                            task.Remark = $"{device.DeviceCode}_Codereadingtriggered_{1}_TSJR3F";
                                         }
                                     }
-                                    if (!Wok)
+                                    catch (Exception ex)
                                     {
-                                        task.ExceptionMessage = $"銆怲SJR3F銆�3妤艰鐮佽Е鍙戝け璐ワ紒";
+
+                                        task.ExceptionMessage = $"銆怲SJR3F銆�3妤艰鐮佽Е鍙戝け璐ワ紒{ex.Message}";
                                         task.Remark = $"{device.DeviceCode}_Codereadingtriggered_{1}_TSJR3F";
                                     }
+                                    
                                 }
                                 task.TaskState = (int)TaskStatusEnum.CheckPalletCodeing;
                                 BaseDal.UpdateData(task);
@@ -634,7 +687,7 @@
                     {
                         if (locationStatusEnum == LocationStatusEnum.Free) //濡傛灉璧风偣瀹屾垚灏辩粰璐т綅璧嬪�兼墭鐩樺彿
                         {
-                            stationManger.Remark = "";
+                            stationManger.Remark ="";
                             stationManger.IsOccupied = LocationStatusEnum.Free.ObjToInt();
                         }
                         else

--
Gitblit v1.9.3