From a765da90e5ee63e04d2d8460a5ad1ebd0e8eb4db Mon Sep 17 00:00:00 2001
From: huanghongfeng <huanghongfeng@hnkhzn.com>
Date: 星期一, 15 七月 2024 21:43:59 +0800
Subject: [PATCH] 工单处理

---
 代码管理/PCS/WCS_Server/WIDESEA_WCS/JobsPart/Common/OutboundTask.cs |   37 +++++++++++++++----------------------
 1 files changed, 15 insertions(+), 22 deletions(-)

diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/JobsPart/Common/OutboundTask.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/JobsPart/Common/OutboundTask.cs"
index 4f2348c..ca16830 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/JobsPart/Common/OutboundTask.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/JobsPart/Common/OutboundTask.cs"
@@ -34,7 +34,7 @@
                 Idt_agvtaskRepository agvtaskRepository = new dt_agvtaskRepository(context);
                 IVV_Mes_WorkinfoRepository workinfoRepository = new VV_Mes_WorkinfoRepository(context);
 
-                var Mes_Works = workinfoRepository.Find(x => x.processCode == "28").OrderBy(x => x.CreateTime).ToList();
+                var Mes_Works = workinfoRepository.Find(x => x.processCode == "28").OrderByDescending(x => x.CreateTime).ToList();
                 foreach (var Mes_Work in Mes_Works)
                 {
                     var inventory = inventoryRepository.Find(x => x.SN == Mes_Work.SN).FirstOrDefault();
@@ -43,27 +43,20 @@
                         var Station = stationinfoRepository.Find(x => x.stationCode == inventory.stationCode).FirstOrDefault();//鏌ユ壘搴撳瓨璐т綅
                         if (Station != null)
                         {
+
+                            #region 
+
                             dt_stationinfo stationinfo = null;
+                            //鏌ユ壘褰撳墠璐т綅鍚岃鏄惁瀛樺湪鍏ュ簱浠诲姟
+                            if (GetStation.InBusyStation(Station.stationCode)) continue;
 
-                            #region 搴撳尯涓�
-                            if (Station.area == "1")
-                            {
-                                //鏌ユ壘褰撳墠璐т綅鍚屽垪鏄惁瀛樺湪鍏ュ簱浠诲姟
-                                if (stationinfoRepository.Find(x => x.column == Station.column && x.area == "1" && x.location_state == LocationStateEnum.InBusy.ToString()).Any()) continue;
-
-                                stationinfo = stationinfoRepository.Find(x => x.column == Station.column && x.enable && x.area == "1" && x.location_state == LocationStateEnum.Stroge.ToString() && x.quantity > 0).OrderBy(x => x.line).FirstOrDefault();
-                            }
-                            #endregion
-                            else
-                            {
-                                //鏌ユ壘褰撳墠璐т綅鍚屽垪鏄惁瀛樺湪鍏ュ簱浠诲姟
-                                if (stationinfoRepository.Find(x => x.line == Station.line && x.area == Station.area && x.location_state == LocationStateEnum.InBusy.ToString()).Any()) continue;
-
-                                stationinfo = stationinfoRepository.Find(x => x.line == Station.line && x.area == Station.area && x.enable && x.location_state == LocationStateEnum.Stroge.ToString() && x.quantity > 0).OrderByDescending(x => x.column).FirstOrDefault();
-                            }
-
+                            stationinfo = stationinfoRepository.Find(x => x.line == Station.line && x.area == Station.area && x.enable && x.location_state == LocationStateEnum.Stroge.ToString() && x.quantity > 0).OrderByDescending(x => x.column).FirstOrDefault();
                             if (stationinfo != null)
                             {
+                                if (agvtaskRepository.Find(x => x.agv_fromaddress == stationinfo.stationCode).Any()) continue;
+
+                                if (stationinfoRepository.Find(x => x.line == stationinfo.line && x.area == stationinfo.area && x.column > stationinfo.column && !x.enable).Any())
+                                    continue;
                                 if (string.IsNullOrEmpty(stationinfo.bindSN))
                                 {
                                     stationinfo.remark = "杞﹁疆SN鍙蜂俊鎭紓甯�";
@@ -86,8 +79,8 @@
                                 var count = 0;
                                 foreach (var SN in lists)
                                 {
-                                    //if (!workinfoRepository.Find(x => x.processCode == "28" && x.SN.Contains(SN)).Any()) return;
-                                    if (workinfoRepository.Find(x => x.processCode == "28" && x.SN.Contains(SN)).Any()) count++;
+                                    if (workinfoRepository.Find(x => x.processCode == "28" && x.SN == SN).Any()) count++;
+                                    //if (workinfoRepository.Find(x => x.processCode == "28" && x.SN.Contains(SN)).Any()) count++;
 
                                 }
                                 if (count != lists.Count) continue;
@@ -105,7 +98,7 @@
                                     agv_toaddress = "",
                                     agv_userid = "绯荤粺",
                                     bindSN = stationinfo.bindSN,
-                                    jobID = Mes_Work.jobID,
+                                    jobID = Mes_Work.workOrder,
                                     agv_worktype = Convert.ToInt32(Mes_Work.processCode),
                                     agv_materbarcode = Mes_Work.materialCode,
                                     agv_Traytype = stationinfo.tray_type,
@@ -153,6 +146,7 @@
                                 //}
                                 #endregion
                             }
+                            #endregion
                         }
                     }
                 }
@@ -162,6 +156,5 @@
                 WriteDBLog.Error("鍒涘缓鍑哄簱浠诲姟", $"閿欒淇℃伅锛歿ex.Message}", "PCS");
             }
         }
-
     }
 }

--
Gitblit v1.9.3