From 8554717a7abbe2889ae1d835857661dc8b91aa68 Mon Sep 17 00:00:00 2001
From: dengjunjie <dengjunjie@hnkhzn.com>
Date: 星期六, 25 五月 2024 10:05:23 +0800
Subject: [PATCH] 优化自动切换大小托盘

---
 代码管理/PCS/WCS_Server/WIDESEA_WCS/Common/Gantry.cs |   55 +++++++++++++++----------------------------------------
 1 files changed, 15 insertions(+), 40 deletions(-)

diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/Common/Gantry.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/Common/Gantry.cs"
index c1ad6b1..9ad8b37 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/Common/Gantry.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/Common/Gantry.cs"
@@ -590,8 +590,6 @@
                             WriteLog.Write_Log(name + "鐢宠鏀炬枡寮傚父", "杞﹁疆SN鍙蜂负绌�", "", $"璇诲彇妗佹灦淇℃伅锛歕n杞﹁疆SN鍙凤細{Wheel_id}涓虹┖");
                             continue;
                         }
-
-
                         var Work = workinfoRepository.Find(x => x.SN == Wheel_id && x.processCode == "17").FirstOrDefault();
                         if (Work == null)
                         {
@@ -600,22 +598,7 @@
                             WriteLog.Write_Log(name + "鐢宠鏀炬枡寮傚父", Wheel_id, "鏌ヨ鏈哄姞宸ュ伐鍗�", $"璇诲彇妗佹灦淇℃伅锛歕n杞﹁疆SN鍙凤細{Wheel_id}鏈煡璇㈠埌宸ュ崟淇℃伅\n鍐欏叆妗佹灦淇℃伅锛歕n鏄惁鍏佽涓嬫枡锛歿false}");
                             continue;
                         }
-
-
                         #endregion
-
-
-
-                        #region MyRegion
-                        //var currentAreaNr = (Int16)DBExtension.Read(details.Where(x => x.plcdetail_name == "W_Are00aNr").First(), client);
-                        //var currentAreaCode = PipelineJob.area_code(name);   //鏍规嵁涓嬫枡鍙e崟鍏冨悕鑾峰彇鍖哄煙浠g爜
-                        //var currentStation = stationinfoRepository.FindFirst(x => x.area == currentAreaCode && x.stationCode.Substring(x.stationCode.Length - 1, 1) == currentAreaNr.ToString());
-                        //if (!currentStation.enable || currentStation.location_state == LocationStateEnum.Empty.ToString())
-                        //    client.WriteByOrder("W_Enabl_Load", false, name);//淇″彿涓篺alse妗佹灦鍋滄杩涘叆
-                        #endregion
-
-
-
 
                         var wheel = Pipeline.QueryMateriel(Work.drawingNo);
                         var wheel1 = Pipeline.QueryMateriel1(Work.drawingNo);
@@ -639,6 +622,21 @@
                                 agvtask(stationinfoRepository, station, Work, "TaskType_Inbound");
                         }
                         #endregion
+
+                        #region 鎵樼洏绫诲瀷涓嶄竴鑷撮渶鏇存崲鎵樼洏
+                        foreach (var Stationinfo in Stations)
+                        {
+                            if (Stationinfo.tray_type != "LargeTray" && (wheel == null ? wheel1.e : wheel.e) > 1100)
+                            {
+                                client.WriteByOrder("W_Enabl_Load", false, name);//淇″彿涓篺alse妗佹灦鍋滄杩涘叆
+                                Stationinfo.location_state = LocationStateEnum.Trayswitching.ToString();
+                                Stationinfo.remark = "鎵樼洏绫诲瀷涓嶄竴鑷撮渶鏇存崲鎵樼洏";
+                                stationinfoRepository.Update(Stationinfo, x => new { x.location_state }, true);
+                            }
+                        }
+                        #endregion
+
+                        Stations = stationinfoRepository.Find(x => x.area == Pipeline.area_code(name)).OrderBy(x => x.lastUpdateTime).ToList();
 
                         var PartStatus = DBExtension.Read(details.Where(x => x.plcdetail_name == "R_PartStatus").First(), client);//1:ok;2:nok
 
@@ -708,18 +706,6 @@
                                         agvtask(stationinfoRepository, stationinfo, Work, name == "3鍗曞厓涓嬫枡鍖�" ? "TaskType_OutsourceInbound" : "TaskType_Inbound");
                                 }
 
-                                #endregion
-
-                                #region 鎵樼洏绫诲瀷涓嶄竴鑷撮渶鏇存崲鎵樼洏
-                                if (Stationinfo.tray_type != "LargeTray" && (wheel == null ? wheel1.e : wheel.e) > 1100)
-                                {
-                                    client.WriteByOrder("W_Enabl_Load", false, name);//淇″彿涓篺alse妗佹灦鍋滄杩涘叆
-                                    Stationinfo.location_state = LocationStateEnum.Abnormal.ToString();
-                                    Stationinfo.tray_type = Stationinfo.tray_type == "SmallTray" ? "SmallTray/LargeTray" : "LargeTray/SmallTray";
-                                    Stationinfo.remark = "鎵樼洏绫诲瀷涓嶄竴鑷撮渶鏇存崲鎵樼洏";
-                                    stationinfoRepository.Update(Stationinfo, true);
-                                    continue;
-                                }
                                 #endregion
 
                                 var Pipelinedetails = plcRepository.Find(x => x.plcdetail_iotype == Pipelineplc.plcinfo_iotyep && x.plcdetail_number == Stationinfo.stationCode).ToList();
@@ -831,17 +817,6 @@
                             }
                             if (Stationinfo != null)
                             {
-                                #region 鎵樼洏绫诲瀷涓嶄竴鑷撮渶鏇存崲鎵樼洏
-                                //if (Stationinfo.tray_type != ((wheel == null ? wheel1.e : wheel.e) < 1100 ? "SmallTray" : "LargeTray"))
-                                if (Stationinfo.tray_type != "LargeTray" && (wheel == null ? wheel1.e : wheel.e) > 1100)
-                                {
-                                    Stationinfo.location_state = LocationStateEnum.Abnormal.ToString();
-                                    Stationinfo.tray_type = Stationinfo.tray_type == "SmallTray" ? "SmallTray/LargeTray" : "LargeTray/SmallTray";
-                                    Stationinfo.remark = "鎵樼洏绫诲瀷涓嶄竴鑷撮渶鏇存崲鎵樼洏";
-                                    stationinfoRepository.Update(Stationinfo, true);
-                                    continue;
-                                }
-                                #endregion
                                 var Pipelinedetails = plcRepository.Find(x => x.plcdetail_iotype == Pipelineplc.plcinfo_iotyep && x.plcdetail_number == Stationinfo.stationCode).ToList();
                                 var PalletSignal = (Int16)DBExtension.Read(Pipelinedetails.Where(x => x.plcdetail_name == "R_PalletSignal").First(), Pipeline_client);//璇诲彇鎵樼洏淇″彿:1:鏈�,2鏃�
                                 var MaterialSignal = (Int16)DBExtension.Read(Pipelinedetails.Where(x => x.plcdetail_name == "R_MaterialSignal").First(), Pipeline_client);//璇诲彇璐х墿淇″彿:1:鏈�,2鏃�

--
Gitblit v1.9.3