From 745aa71a76544989535ff193f3ede69200bab2db Mon Sep 17 00:00:00 2001
From: z8018 <1282578289@qq.com>
Date: 星期二, 20 五月 2025 14:08:33 +0800
Subject: [PATCH] 未优化的稳定版本

---
 项目代码/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/CommonConveyorLineOutJob.cs |   77 +++++++++++++++++++++++---------------
 1 files changed, 47 insertions(+), 30 deletions(-)

diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/CommonConveyorLineOutJob.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/CommonConveyorLineOutJob.cs"
index 974e079..17c4853 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/CommonConveyorLineOutJob.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/CommonConveyorLineOutJob.cs"
@@ -104,25 +104,20 @@
                             if (!string.IsNullOrEmpty(barcode))
                             {
                                 OrderInfo orderInfo = _orderDetailsService.GetOrderInfoByBarcode(barcode);
-                                if (orderInfo.Width > AppSettings.Get("MaxWidth").ObjToInt() && orderInfo.Width < AppSettings.Get("MinWidth").ObjToInt())
-                                {
-                                    otherDevice.SetValue(ConveyorLineStationDBName.WCSStationTarget, Convert.ToInt32(orderInfo.Length));
-                                    otherDevice.SetValue(ConveyorLineStationDBName.WCSStationTarget, Convert.ToInt32(orderInfo.Width));
-                                    otherDevice.SetValue(ConveyorLineStationDBName.WCSStationTarget, Convert.ToInt32(orderInfo.Thickness));
-                                    otherDevice.SetValue(ConveyorLineStationDBName.WCSStationTarget, dischargeStation);
-                                    otherDevice.SetValue(ConveyorLineStationDBName.WCSStationTaskNum, 999);
-                                    otherDevice.SetValue(ConveyorLineStationDBName.WCSStationResponse, true);
-                                }
-                                else
+
+                                _orderDetailsService.ToMes(barcode, 3);
+
+                                if (orderInfo.Width >= AppSettings.Get("MinWidth").ObjToInt() && orderInfo.Width <= AppSettings.Get("MaxWidth").ObjToInt() && orderInfo.Length >= AppSettings.Get("MinLength").ObjToInt() && orderInfo.Length <= AppSettings.Get("MaxLength").ObjToInt() || orderInfo.Length >= AppSettings.Get("MinWidth").ObjToInt() && orderInfo.Length <= AppSettings.Get("MaxWidth").ObjToInt() && orderInfo.Width >= AppSettings.Get("MinLength").ObjToInt() && orderInfo.Width <= AppSettings.Get("MaxLength").ObjToInt())
                                 {
                                     Dt_Task task = _taskRepository.QueryFirst(x => x.PalletCode == barcode);
                                     if (task == null)
                                     {
                                         try
                                         {
-                                            task = _taskService.GenerateTask(orderInfo);
-                                            if (task != null)
+                                            var (taskFlag, gTask, message) = _taskService.GenerateTask(orderInfo);
+                                            if (taskFlag && gTask != null)
                                             {
+                                                task = gTask;
                                                 if (!string.IsNullOrEmpty(task.ItemInfo))
                                                 {
                                                     string[] itemInfos = task.ItemInfo.Split("*");
@@ -138,22 +133,6 @@
                                                 otherDevice.SetValue(ConveyorLineStationDBName.WCSStationTaskNum, task.TaskNum);
                                                 otherDevice.SetValue(ConveyorLineStationDBName.WCSStationResponse, true);
                                             }
-                                        }
-                                        catch (Exception ex)
-                                        {
-                                            if (ex.Message.Contains("10001"))
-                                            {
-                                                otherDevice.SetValue(ConveyorLineStationDBName.WCSStationTarget, Convert.ToInt32(orderInfo.Length));
-                                                otherDevice.SetValue(ConveyorLineStationDBName.WCSStationTarget, Convert.ToInt32(orderInfo.Width));
-                                                otherDevice.SetValue(ConveyorLineStationDBName.WCSStationTarget, Convert.ToInt32(orderInfo.Thickness));
-                                                otherDevice.SetValue(ConveyorLineStationDBName.WCSStationTarget, dischargeStation);
-                                                otherDevice.SetValue(ConveyorLineStationDBName.WCSStationTaskNum, 999);
-                                                otherDevice.SetValue(ConveyorLineStationDBName.WCSStationResponse, true);
-                                            }
-                                            else if (ex.Message.Contains("10002"))
-                                            {
-                                                WriteError($"{otherDevice.DeviceCode}-{otherDevice.DeviceName}", ex.Message, ex);
-                                            }
                                             else
                                             {
                                                 otherDevice.SetValue(ConveyorLineStationDBName.WCSStationTarget, Convert.ToInt32(orderInfo.Length));
@@ -163,10 +142,49 @@
                                                 otherDevice.SetValue(ConveyorLineStationDBName.WCSStationTaskNum, 998);
                                                 otherDevice.SetValue(ConveyorLineStationDBName.WCSStationResponse, true);
 
-                                                WriteError(nameof(CommonConveyorLineOutJob), ex.Message, ex);
+                                                WriteError(nameof(CommonConveyorLineOutJob), message);
+
+                                                WriteError("鏉垮瓙鎺掑嚭閿欒鍘熷洜璁板綍鏃ュ織", message);
                                             }
                                         }
+                                        catch (Exception ex)
+                                        {
+                                            otherDevice.SetValue(ConveyorLineStationDBName.WCSStationTarget, Convert.ToInt32(orderInfo.Length));
+                                            otherDevice.SetValue(ConveyorLineStationDBName.WCSStationTarget, Convert.ToInt32(orderInfo.Width));
+                                            otherDevice.SetValue(ConveyorLineStationDBName.WCSStationTarget, Convert.ToInt32(orderInfo.Thickness));
+                                            otherDevice.SetValue(ConveyorLineStationDBName.WCSStationTarget, dischargeStation);
+                                            otherDevice.SetValue(ConveyorLineStationDBName.WCSStationTaskNum, 999);
+                                            otherDevice.SetValue(ConveyorLineStationDBName.WCSStationResponse, true);
+                                            WriteError("鏀炬澘閫昏緫杩愮畻閿欒璁板綍鏃ュ織", ex.Message, ex);
+                                        }
                                     }
+                                    else
+                                    {
+                                        if (!string.IsNullOrEmpty(task.ItemInfo))
+                                        {
+                                            string[] itemInfos = task.ItemInfo.Split("*");
+                                            if (itemInfos.Length == 3)
+                                            {
+                                                otherDevice.SetValue(ConveyorLineStationDBName.WCSStationTarget, Convert.ToInt32(itemInfos[0]));
+                                                otherDevice.SetValue(ConveyorLineStationDBName.WCSStationTarget, Convert.ToInt32(itemInfos[1]));
+                                                otherDevice.SetValue(ConveyorLineStationDBName.WCSStationTarget, Convert.ToInt32(itemInfos[2]));
+                                            }
+                                        }
+
+                                        otherDevice.SetValue(ConveyorLineStationDBName.WCSStationTarget, Convert.ToInt32(task.TargetAddress));
+                                        otherDevice.SetValue(ConveyorLineStationDBName.WCSStationTaskNum, task.TaskNum);
+                                        otherDevice.SetValue(ConveyorLineStationDBName.WCSStationResponse, true);
+                                    }
+                                }
+                                else
+                                {
+                                    //todo 瓒呭澶勭悊
+                                    otherDevice.SetValue(ConveyorLineStationDBName.WCSStationTarget, Convert.ToInt32(orderInfo.Length));
+                                    otherDevice.SetValue(ConveyorLineStationDBName.WCSStationTarget, Convert.ToInt32(orderInfo.Width));
+                                    otherDevice.SetValue(ConveyorLineStationDBName.WCSStationTarget, Convert.ToInt32(orderInfo.Thickness));
+                                    otherDevice.SetValue(ConveyorLineStationDBName.WCSStationTarget, dischargeStation);
+                                    otherDevice.SetValue(ConveyorLineStationDBName.WCSStationTaskNum, 999);
+                                    otherDevice.SetValue(ConveyorLineStationDBName.WCSStationResponse, true);
                                 }
                             }
                             else
@@ -174,7 +192,6 @@
                                 otherDevice.SetValue(ConveyorLineStationDBName.WCSStationTarget, dischargeStation);
                                 otherDevice.SetValue(ConveyorLineStationDBName.WCSStationTaskNum, 997);
                                 otherDevice.SetValue(ConveyorLineStationDBName.WCSStationResponse, true);
-                                //otherDevice.SetValue(ConveyorLineStationDBName.WCSStationNoBarcode, true);
                             }
                         }
 

--
Gitblit v1.9.3