From 7a4c218909936721fe281737491d10efc7378e09 Mon Sep 17 00:00:00 2001
From: dengjunjie <dengjunjie@hnkhzn.com>
Date: 星期五, 19 七月 2024 17:53:30 +0800
Subject: [PATCH] 优化工单信息页面

---
 代码管理/PCS/WCS_Server/WIDESEA_WCS/Common/Gantry.cs |   42 ++++++++++++------------------------------
 1 files changed, 12 insertions(+), 30 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 2a00245..1d71ab5 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"
@@ -27,7 +27,7 @@
 
 namespace WIDESEA_WCS
 {
-    public class Gantry
+    public class Gantry : Gantry2
     {
         #region 鏌ヨ杞﹁疆鏁版嵁
         /// <summary>
@@ -75,7 +75,7 @@
                             }
                         }
 
-                        var Mes_Work = workinfoRepository.Find(x => x.SN == wp_id && x.processCode == (name != "杈婇亾涓婃枡鏌ヨ杞﹁疆" ? "17" : "28")).FirstOrDefault();
+                        var Mes_Work = workinfoRepository.Find(x => x.SN == wp_id && x.processCode == (name != "杈婇亾涓婃枡鏌ヨ杞﹁疆" ? "17" : "28")).OrderByDescending(x => x.CreateTime).FirstOrDefault();
                         if (Mes_Work == null)
                         {
                             client.WriteByOrder("W_i_status", (byte)2, name);
@@ -173,7 +173,7 @@
                         }
                         var wp_type = DBExtension.Read(details.Where(x => x.plcdetail_name == "R_o_wp_type").First(), client);
 
-                        var Mes_Work = workinfoRepository.Find(x => x.SN == wp_id && x.processCode == (name != "杈婇亾涓婃枡鏌ヨ璁㈠崟" ? "17" : "28")).FirstOrDefault();
+                        var Mes_Work = workinfoRepository.Find(x => x.SN == wp_id && x.processCode == (name != "杈婇亾涓婃枡鏌ヨ璁㈠崟" ? "17" : "28")).OrderByDescending(x => x.CreateTime).FirstOrDefault();
                         if (Mes_Work == null)
                         {
                             client.WriteByOrder("W_i_status", (byte)2, name);
@@ -186,17 +186,6 @@
 
                         var mes_Head = mes_HeadRepository.FindFirst(x => x.jobID == Mes_Work.jobID);
 
-                        //闇�娣诲姞鏌ヨ杞﹁疆SN鍙疯鍗曢�昏緫   闇�娣诲姞鍏ュ簱妯″紡鍒ゆ柇锛屾墜鍔ㄥ叆搴撴ā寮忛渶浜哄伐娣诲姞鍏ュ簱搴撳尯锛屽惁鍒欐姤璀�
-                        //var pattern = patternRepository.FindFirst(x => x.pattern_name == "鍏ュ簱妯″紡").pattern_state;
-                        //if (pattern != 1 && string.IsNullOrEmpty(mes_Head.area))
-                        //{
-                        //    client.WriteByOrder("W_i_status", (byte)4, name);
-                        //    client.WriteByOrder("R_oi_on", (byte)0, name);
-                        //    #region 鏃ュ織璁板綍
-                        //    WriteLog.Write_Log(name, wp_id, "閿欒淇℃伅锛�", $"璇诲彇妗佹灦淇℃伅锛歕n杞﹁疆SN锛歿wp_id}\n\n鍐欏叆妗佹灦淇℃伅锛歕nW_i_status锛�4\nR_oi_on锛�0\n\n鎵嬪姩鍏ュ簱妯″紡鏈�夋嫨搴撳尯");
-                        //    #endregion
-                        //    continue;
-                        //}
                         var geometry = Pipeline.QueryMateriel(Mes_Work.drawingNo);
                         if (geometry == null)
                         {
@@ -218,19 +207,10 @@
                             //client.WriteByOrder("W_i_sourceheat", "", name);
                             client.WriteByOrder("W_i_batch_id", Mes_Work.heatBatchID, name);
 
-                            //灞忚斀宸ヨ壓(灞忚斀瑙嗚妫�娴�/灞忚斀娑傛补)
-                            if (name != "杈婇亾涓婃枡鏌ヨ璁㈠崟")
-                            {
-                                client.WriteByOrder("W_i_skip_op_SJ1", name == "3鍗曞厓杈婇亾涓嬫枡鏌ヨ璁㈠崟" ? true : mes_Head.skip_op_1, name);//灞忚斀瑙嗚妫�娴嬭澶�1
-                                client.WriteByOrder("W_i_skip_op_SJ2", name == "3鍗曞厓杈婇亾涓嬫枡鏌ヨ璁㈠崟" ? true : mes_Head.skip_op_2, name);//灞忚斀瑙嗚妫�娴嬭澶�2
-                                client.WriteByOrder("W_i_skip_op_LT", mes_Head.skip_op_3, name);//灞忚斀閾炬潯鏈�
-                            }
                             client.WriteByOrder("R_oi_on", (byte)0, name);
                             #region 鏃ュ織璁板綍
                             WriteLog.Write_Log(name, wp_id, "鍐欏叆淇℃伅锛�", $"璇诲彇妗佹灦淇℃伅锛歕n杞﹁疆SN锛歿wp_id}\n杞瀷ID锛歿wp_type}\n\n鍐欏叆妗佹灦淇℃伅锛歕nW_i_status锛�1" +
-                                $"\nW_i_job_id锛歿Mes_Work.jobID}\nW_i_drawing_id锛歿Mes_Work.drawingNo}\nW_i_heat_id锛歿Mes_Work.heatID}\nW_i_batch_id锛歿Mes_Work.heatBatchID}" +
-                                $"\nW_i_skip_op_SJ1锛歿(name == "3鍗曞厓杈婇亾涓嬫枡鏌ヨ璁㈠崟" ? true : mes_Head.skip_op_1)}\nW_i_skip_op_SJ2锛歿(name == "3鍗曞厓杈婇亾涓嬫枡鏌ヨ璁㈠崟" ? true : mes_Head.skip_op_2)}" +
-                                $"\nW_i_skip_op_LT锛歿mes_Head.skip_op_3}\nR_oi_on锛�0");
+                                $"\nW_i_job_id锛歿Mes_Work.jobID}\nW_i_drawing_id锛歿Mes_Work.drawingNo}\nW_i_heat_id锛歿Mes_Work.heatID}\nW_i_batch_id锛歿Mes_Work.heatBatchID}");
                             #endregion
                         }
                     }
@@ -310,7 +290,7 @@
                             }
 
                             //var Wheel_id = DBExtension.Read(details.Where(x => x.plcdetail_name == "R_Wheel_id").First(), client).ToString();
-                            var Mes_Work = workinfoRepository.Find(x => x.SN == Wheel_SN && x.processCode == "17").FirstOrDefault();
+                            var Mes_Work = workinfoRepository.Find(x => x.SN == Wheel_SN && x.processCode == "17").OrderByDescending(x => x.CreateTime).FirstOrDefault();
                             if (Mes_Work == null)
                             {
                                 #region 鏃ュ織璁板綍
@@ -440,7 +420,7 @@
                             WriteLog.Write_Log(name + "鐢宠鏀炬枡寮傚父", "杞﹁疆SN鍙蜂负绌�", "", $"璇诲彇妗佹灦淇℃伅锛歕n杞﹁疆SN鍙凤細{Wheel_id}涓虹┖");
                             continue;
                         }
-                        var Work = workinfoRepository.Find(x => x.SN == Wheel_id && x.processCode == "17").FirstOrDefault();
+                        var Work = workinfoRepository.Find(x => x.SN == Wheel_id && x.processCode == "17").OrderByDescending(x => x.CreateTime).FirstOrDefault();
                         if (Work == null)
                         {
                             client.WriteByOrder("W_Enabl_Load", false, name);//淇″彿涓篺alse妗佹灦鍋滄杩涘叆
@@ -474,7 +454,8 @@
                         #endregion
 
                         #region 鎵樼洏绫诲瀷涓嶄竴鑷撮渶鏇存崲鎵樼洏
-                        foreach (var Stationinfo in Stations)
+                        stations = Stations.Where(x => x.enable).ToList();
+                        foreach (var Stationinfo in stations)
                         {
                             if (Stationinfo.tray_type != "LargeTray" && /*(wheel == null ? wheel1.e :)*/ wheel.e > 1100)
                             {
@@ -637,7 +618,8 @@
                                 if (!Stations.Where(x => x.enable && x.stationCode != NGStation && x.location_state != LocationStateEnum.Stroge.ToString()).Any())
                                 {
                                     var station = Stations.Where(x => x.enable && x.stationCode != NGStation && x.location_state == LocationStateEnum.Stroge.ToString()).OrderBy(x => x.lastUpdateTime).FirstOrDefault();
-                                    agvtask(stationinfoRepository, station, Work, name == "3鍗曞厓涓嬫枡鍖�" ? "TaskType_OutsourceInbound" : "TaskType_Inbound");
+                                    if (station != null)
+                                        agvtask(stationinfoRepository, station, Work, name == "3鍗曞厓涓嬫枡鍖�" ? "TaskType_OutsourceInbound" : "TaskType_Inbound");
                                 }
                                 #endregion
                             }
@@ -728,7 +710,7 @@
                                     //WriteDBLog.Success(name + "鍏佽鏀炬枡", $"璇诲彇妗佹灦淇℃伅锛歕n杞﹁疆SN锛歿Wheel_id}\n杞瀷ID锛歿Wheel_Type}\n杞﹁疆鐘舵�侊細NG" +$"\n璇诲彇鎵樼洏鍏夌數淇″彿锛歿PalletSignal}" +
                                     //    $"\n\n鍐欏叆妗佹灦淇℃伅锛歕n涓嬫枡浣嶅彿锛歿area}\n绗嚑涓溅杞細{(Stationinfo.quantity + 1)}\n鎵樼洏绫诲瀷锛�1\nW_Enabl_Load锛歵rue", "PCS");
                                     WriteLog.Write_Log(name + "鐢宠鏀炬枡", Wheel_id, "鍏佽鏀炬枡",
-                                        $"璇诲彇妗佹灦淇℃伅锛歕n杞﹁疆SN锛歿Wheel_id}\n杞瀷ID锛歿Wheel_Type}\n杞﹁疆鐘舵�侊細鍚堟牸" +
+                                        $"璇诲彇妗佹灦淇℃伅锛歕n杞﹁疆SN锛歿Wheel_id}\n杞瀷ID锛歿Wheel_Type}\n杞﹁疆鐘舵�侊細涓嶅悎鏍�" +
                                         $"\n璇诲彇鎵樼洏鍏夌數淇″彿锛歿PalletSignal}" +
                                         $"\n\n鍐欏叆妗佹灦淇℃伅锛歕n涓嬫枡浣嶅彿锛歿area}\n绗嚑涓溅杞細{(Stationinfo.quantity + 1)}\n鎵樼洏绫诲瀷锛�1\n鏄惁鍏佽涓嬫枡锛歵rue");
                                     #endregion
@@ -759,7 +741,7 @@
             VOLContext Context = new VOLContext();
             Idt_agvtaskRepository agvtaskRepository = new dt_agvtaskRepository(Context);
             IVV_Mes_WorkinfoRepository workinfoRepository = new VV_Mes_WorkinfoRepository(Context);
-            Work = workinfoRepository.Find(x => x.workOrder == stationinfo.Number && x.processCode == "17").FirstOrDefault();
+            Work = workinfoRepository.Find(x => x.workOrder == stationinfo.Number && x.processCode == "17").OrderByDescending(x => x.CreateTime).FirstOrDefault();
             var task = agvtaskRepository.Find(x => x.agv_fromaddress == stationinfo.stationCode).FirstOrDefault();
             if (task != null) return;
             if (!string.IsNullOrEmpty(Work.area))

--
Gitblit v1.9.3