From 2e2b2a3efe2a5def011834daa43d71da9b3b5d00 Mon Sep 17 00:00:00 2001
From: dengjunjie <dengjunjie@hnkhzn.com>
Date: 星期三, 03 四月 2024 10:55:57 +0800
Subject: [PATCH] 优化逻辑

---
 代码管理/PCS/WCS_Server/WIDESEA_WCS/JobsPart/Common/RestockHCJ.cs |   30 ++++++++++++++++++++++++++----
 1 files changed, 26 insertions(+), 4 deletions(-)

diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/JobsPart/Common/RestockHCJ.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/JobsPart/Common/RestockHCJ.cs"
index 98b94fe..787ff0d 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/JobsPart/Common/RestockHCJ.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/JobsPart/Common/RestockHCJ.cs"
@@ -29,8 +29,9 @@
             {
                 VOLContext Context = new VOLContext();
                 Idt_stationinfoRepository stationinfoRepository = new dt_stationinfoRepository(Context);
+
                 Idt_agvtaskRepository agvtaskService = new dt_agvtaskRepository(Context);
-                var tasks = agvtaskService.Find(x => x.agv_taskstate == "Queue").OrderBy(x => x.agv_createtime).ToList();
+                var tasks = agvtaskService.Find(x => x.agv_taskstate == "Queue").OrderByDescending(x => x.agv_grade).ThenBy(x => x.agv_createtime).ToList();
                 foreach (var task in tasks)
                 {
                     if (task.agv_tasktype == "TaskType_EmptyPallet")//绌烘墭浠诲姟
@@ -42,9 +43,9 @@
                             if (!Pipeline_client.IsConnected) throw new Exception("涓庨摼鏉℃満杩炴帴瓒呮椂锛�");
                             var area = task.agv_Traytype == "SmallTray" ? "11" : "10";
                             //鎵�1搴撳尯鐨勭┖鎵樹綅
-                            var EmptyStation = stationinfoRepository.Find(x => x.area == area && x.quantity > 0 && x.stationCode.Contains("A") && x.location_state == "Stroge"/*LocationStateEnum.Stroge.ToString()*/ && x.enable)
-                                .OrderBy(x => x.line).OrderByDescending(x => x.column).FirstOrDefault();
-
+                            var EmptyStation = stationinfoRepository.Find(x => x.area == area && x.quantity > 0 && x.stationCode.Contains("A") /*&& x.location_state == "Stroge"*//*LocationStateEnum.Stroge.ToString()*/ && x.enable).OrderBy(x => x.column).ThenBy(x => x.line).FirstOrDefault();
+                            if (EmptyStation != null)
+                                if (EmptyStation.location_state == LocationStateEnum.Busy.ToString()) EmptyStation = null;
                             #region 涓�涓尯鍩熷彧鑳芥湁涓�涓┖鎵樹换鍔�
                             //bool ok = false;
                             //if (EmptyStation != null)
@@ -55,6 +56,7 @@
                             #endregion
                             if (EmptyStation == null)
                                 EmptyStation = stationinfoRepository.Find(x => x.area == area && x.quantity > 0 && x.stationCode.Contains(area == "10" ? "D" : "C") && x.enable).OrderByDescending(x => x.column).FirstOrDefault();
+                            if (EmptyStation == null) continue;
                             #region 搴撳唴瀛樺湪浠诲姟鍗犵敤
                             if (EmptyStation.location_state == LocationStateEnum.Busy.ToString())
                                 continue;
@@ -106,6 +108,26 @@
                             }
                         }
                     }
+                    else if (task.agv_tasktype == "TaskType_OutsourceCarry")//澶栧崗绉诲簱
+                    {
+                        if (task.agv_toaddress == "")
+                        {
+                            var TargetLocation = StationTask.GetEmptyLocation(stationinfoRepository);
+                            if (TargetLocation != null)
+                            {
+                                if (agvtaskService.Find(x => x.agv_toaddress == TargetLocation.stationCode).Any()) continue;
+
+                                task.agv_taskstate = "Create";
+                                task.agv_toaddress = TargetLocation.stationCode;
+                                TargetLocation.location_state = LocationStateEnum.OutBusy.ToString();
+                                TargetLocation.stationType = task.agv_materielid;
+                                stationinfoRepository.Update(TargetLocation, true);
+                                agvtaskService.Update(task, true);
+                                WriteDBLog.Success("鏇存柊鍑哄簱闃熷垪浠诲姟", $"浠诲姟缂栧彿锛歿task.agv_tasknum}", "PCS");
+                                return;
+                            }
+                        }
+                    }
                 }
             }
             catch (Exception ex)

--
Gitblit v1.9.3