From 2d3d006620bb15a2350c516f050058e5f84c7bf8 Mon Sep 17 00:00:00 2001
From: dengjunjie <dengjunjie@hnkhzn.com>
Date: 星期二, 21 五月 2024 17:03:44 +0800
Subject: [PATCH] 添加人工一键下料功能,人工一键切换托盘功能,优化任务等级

---
 代码管理/PCS/WCS_Server/WIDESEA_WCS/Common/Gantry.cs |  182 ++++++++++++++++++++++++++++++--------------
 1 files changed, 123 insertions(+), 59 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 25bf15f..c1ad6b1 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"
@@ -12,6 +12,7 @@
 using WIDESEA_Comm.LogInfo;
 using WIDESEA_Comm.TaskNo;
 using WIDESEA_Core.EFDbContext;
+using WIDESEA_Core.Extensions;
 using WIDESEA_Core.FreeDB;
 using WIDESEA_Entity.DomainModels;
 using WIDESEA_WCS.IRepositories;
@@ -34,6 +35,7 @@
         /// <param name="client"></param>
         public void QueryWheeldata(PLCClient client)
         {
+            string namea = "";
             try
             {
                 VOLContext Context = new VOLContext();
@@ -48,6 +50,7 @@
                 List<string> names = new List<string>() { "1鍗曞厓杈婇亾涓嬫枡鏌ヨ杞﹁疆", "2鍗曞厓杈婇亾涓嬫枡鏌ヨ杞﹁疆", "3鍗曞厓杈婇亾涓嬫枡鏌ヨ杞﹁疆", "杈婇亾涓婃枡鏌ヨ杞﹁疆" };
                 foreach (string name in names)
                 {
+                    namea = name;
                     var details = plcRepository.Find(x => x.plcdetail_iotype == plc.plcinfo_iotyep && x.plcdetail_number == name).ToList();
                     var on = DBExtension.Read(details.Where(x => x.plcdetail_name == "R_oi_on").First(), client);
                     if ((byte)on == 1)
@@ -66,7 +69,8 @@
                             client.WriteByOrder("W_i_status", (byte)2, name);
                             client.WriteByOrder("R_oi_on", (byte)0, name);
                             #region 鏃ュ織璁板綍
-                            WriteDBLog.Error(name, $"璇诲彇妗佹灦淇℃伅锛歕n杞﹁疆SN锛歿wp_id}\n\n鍐欏叆妗佹灦淇℃伅锛歕nW_i_status锛�2\nR_oi_on锛�0\n\n鏈煡璇㈠埌宸ュ崟淇℃伅", "PCS");
+                            //WriteDBLog.Error(name, $"璇诲彇妗佹灦淇℃伅锛歕n杞﹁疆SN锛歿wp_id}\n\n鍐欏叆妗佹灦淇℃伅锛歕nW_i_status锛�2\nR_oi_on锛�0\n\n鏈煡璇㈠埌宸ュ崟淇℃伅", "PCS");
+                            WriteLog.Write_Log(name, wp_id, "閿欒淇℃伅锛�", $"璇诲彇妗佹灦淇℃伅锛歕n杞﹁疆SN锛歿wp_id}\n\n鍐欏叆妗佹灦淇℃伅锛歕nW_i_status锛�2\nR_oi_on锛�0\n\n鏈煡璇㈠埌宸ュ崟淇℃伅");
                             #endregion
                             continue;
                         }
@@ -107,7 +111,8 @@
                                 client.WriteByOrder("W_i_status", (byte)2, name);
                                 client.WriteByOrder("R_oi_on", (byte)0, name);
                                 #region 鏃ュ織璁板綍
-                                WriteDBLog.Error(name, $"璇诲彇妗佹灦淇℃伅锛歕n杞瀷ID锛歿wp_type}\n\n鍐欏叆妗佹灦淇℃伅锛歕nW_i_status锛�2\nR_oi_on锛�0\n\n鏈煡璇㈠埌鏈哄姞宸ヨ溅杞俊鎭�", "PCS");
+                                //WriteDBLog.Error(name, $"璇诲彇妗佹灦淇℃伅锛歕n杞瀷ID锛歿wp_type}\n\n鍐欏叆妗佹灦淇℃伅锛歕nW_i_status锛�2\nR_oi_on锛�0\n\n鏈煡璇㈠埌鏈哄姞宸ヨ溅杞俊鎭�", "PCS");
+                                WriteLog.Write_Log(name, wp_id, "閿欒淇℃伅锛�", $"璇诲彇妗佹灦淇℃伅锛歕n杞瀷ID锛歿wp_type}\n\n鍐欏叆妗佹灦淇℃伅锛歕nW_i_status锛�2\nR_oi_on锛�0\n\n鏈煡璇㈠埌鏈哄姞宸ヨ溅杞俊鎭�");
                                 #endregion
                             }
                             else
@@ -124,7 +129,17 @@
                                 client.WriteByOrder("W_i_parameter_h", geometry == null ? (float)geometry1.h : (float)geometry.h, name);
                                 client.WriteByOrder("R_oi_on", (byte)0, name);
                                 #region 鏃ュ織璁板綍
-                                WriteDBLog.Success(name, $"璇诲彇妗佹灦淇℃伅锛歕n杞瀷ID锛歿wp_type}\n\n鍐欏叆妗佹灦淇℃伅锛歕nW_i_status锛�1" + $"\n" +
+                                //WriteDBLog.Success(name, $"璇诲彇妗佹灦淇℃伅锛歕n杞瀷ID锛歿wp_type}\n\n鍐欏叆妗佹灦淇℃伅锛歕nW_i_status锛�1" + $"\n" +
+                                //    $"a锛歿(geometry == null ? (float)geometry1.a : (float)geometry.a)}\n" +
+                                //    $"b锛歿(geometry == null ? (float)geometry1.b : (float)geometry.b)}\n" +
+                                //    $"c锛歿(geometry == null ? (float)geometry1.c : (float)geometry.c)}\n" +
+                                //    $"d锛歿(geometry == null ? (float)geometry1.d : (float)geometry.d)}\n" +
+                                //    $"e锛歿(geometry == null ? (float)geometry1.e : (float)geometry.e)}\n" +
+                                //    $"f锛歿(geometry == null ? (float)geometry1.f : (float)geometry.f)}\n" +
+                                //    $"g锛歿(geometry == null ? (float)geometry1.g : (float)geometry.g)}\n" +
+                                //    $"h锛歿(geometry == null ? (float)geometry1.h : (float)geometry.h)}\n" +
+                                //    $"R_oi_on锛�0", "PCS");
+                                WriteLog.Write_Log(name, wp_id, "鍐欏叆淇℃伅锛�", $"璇诲彇妗佹灦淇℃伅锛歕n杞瀷ID锛歿wp_type}\n\n鍐欏叆妗佹灦淇℃伅锛歕nW_i_status锛�1" + $"\n" +
                                     $"a锛歿(geometry == null ? (float)geometry1.a : (float)geometry.a)}\n" +
                                     $"b锛歿(geometry == null ? (float)geometry1.b : (float)geometry.b)}\n" +
                                     $"c锛歿(geometry == null ? (float)geometry1.c : (float)geometry.c)}\n" +
@@ -133,7 +148,7 @@
                                     $"f锛歿(geometry == null ? (float)geometry1.f : (float)geometry.f)}\n" +
                                     $"g锛歿(geometry == null ? (float)geometry1.g : (float)geometry.g)}\n" +
                                     $"h锛歿(geometry == null ? (float)geometry1.h : (float)geometry.h)}\n" +
-                                    $"R_oi_on锛�0", "PCS");
+                                    $"R_oi_on锛�0");
                                 #endregion
                             }
                         }
@@ -146,7 +161,8 @@
                                 client.WriteByOrder("W_i_status", (byte)2, name);
                                 client.WriteByOrder("R_oi_on", (byte)0, name);
                                 #region 鏃ュ織璁板綍
-                                WriteDBLog.Error(name, $"璇诲彇妗佹灦淇℃伅锛歕n杞瀷ID锛歿wp_type}\n\n鍐欏叆妗佹灦淇℃伅锛歕nW_i_status锛�2\nR_oi_on锛�0\n\n鏈煡璇㈠埌妫�娴嬬嚎杞﹁疆淇℃伅", "PCS");
+                                //WriteDBLog.Error(name, $"璇诲彇妗佹灦淇℃伅锛歕n杞瀷ID锛歿wp_type}\n\n鍐欏叆妗佹灦淇℃伅锛歕nW_i_status锛�2\nR_oi_on锛�0\n\n鏈煡璇㈠埌妫�娴嬬嚎杞﹁疆淇℃伅", "PCS");
+                                WriteLog.Write_Log(name, wp_id, "閿欒淇℃伅锛�", $"璇诲彇妗佹灦淇℃伅锛歕n杞瀷ID锛歿wp_type}\n\n鍐欏叆妗佹灦淇℃伅锛歕nW_i_status锛�2\nR_oi_on锛�0\n\n鏈煡璇㈠埌妫�娴嬬嚎杞﹁疆淇℃伅");
                                 #endregion
                             }
                             else
@@ -162,7 +178,17 @@
                                 client.WriteByOrder("W_i_parameter_h", geometry == null ? (float)geometry1.h : (float)geometry.h, name);
                                 client.WriteByOrder("R_oi_on", (byte)0, name);
                                 #region 鏃ュ織璁板綍
-                                WriteDBLog.Success(name, $"璇诲彇妗佹灦淇℃伅锛歕n杞瀷ID锛歿wp_type}\n\n鍐欏叆妗佹灦淇℃伅锛歕nW_i_status锛�1" + $"\n" +
+                                //WriteDBLog.Success(name, $"璇诲彇妗佹灦淇℃伅锛歕n杞瀷ID锛歿wp_type}\n\n鍐欏叆妗佹灦淇℃伅锛歕nW_i_status锛�1" + $"\n" +
+                                //    $"a锛歿(geometry == null ? (float)geometry1.a : (float)geometry.a)}\n" +
+                                //    $"b锛歿(geometry == null ? (float)geometry1.b : (float)geometry.b)}\n" +
+                                //    $"c锛歿(geometry == null ? (float)geometry1.c : (float)geometry.c)}\n" +
+                                //    $"d锛歿(geometry == null ? (float)geometry1.d : (float)geometry.d)}\n" +
+                                //    $"e锛歿(geometry == null ? (float)geometry1.e : (float)geometry.e)}\n" +
+                                //    $"f锛歿(geometry == null ? (float)geometry1.f : (float)geometry.f)}\n" +
+                                //    $"g锛歿(geometry == null ? (float)geometry1.g : (float)geometry.g)}\n" +
+                                //    $"h锛歿(geometry == null ? (float)geometry1.h : (float)geometry.h)}\n" +
+                                //    $"R_oi_on锛�0", "PCS");
+                                WriteLog.Write_Log(name, wp_id, "鍐欏叆淇℃伅锛�", $"璇诲彇妗佹灦淇℃伅锛歕n杞瀷ID锛歿wp_type}\n\n鍐欏叆妗佹灦淇℃伅锛歕nW_i_status锛�1" + $"\n" +
                                     $"a锛歿(geometry == null ? (float)geometry1.a : (float)geometry.a)}\n" +
                                     $"b锛歿(geometry == null ? (float)geometry1.b : (float)geometry.b)}\n" +
                                     $"c锛歿(geometry == null ? (float)geometry1.c : (float)geometry.c)}\n" +
@@ -171,7 +197,7 @@
                                     $"f锛歿(geometry == null ? (float)geometry1.f : (float)geometry.f)}\n" +
                                     $"g锛歿(geometry == null ? (float)geometry1.g : (float)geometry.g)}\n" +
                                     $"h锛歿(geometry == null ? (float)geometry1.h : (float)geometry.h)}\n" +
-                                    $"R_oi_on锛�0", "PCS");
+                                    $"R_oi_on锛�0");
                                 #endregion
                             }
                         }
@@ -181,7 +207,8 @@
             }
             catch (Exception ex)
             {
-                WriteDBLog.Error("鏌ヨ杞﹁疆鏁版嵁", $"閿欒淇℃伅锛歿ex.Message}", "PCS");
+                //WriteDBLog.Error("鏌ヨ杞﹁疆鏁版嵁", $"閿欒淇℃伅锛歿ex.Message}", "PCS");
+                WriteLog.Write_Log("鎶ラ敊鏃ュ織", namea, "閿欒淇℃伅锛�", $"閿欒淇℃伅锛歿ex.Message}");
             }
         }
         #endregion
@@ -193,6 +220,7 @@
         /// <param name="client"></param>
         public void QueryOrder(PLCClient client)
         {
+            string namea = "";
             try
             {
                 VOLContext Context = new VOLContext();
@@ -208,6 +236,7 @@
                 List<string> names = new List<string>() { "1鍗曞厓杈婇亾涓嬫枡鏌ヨ璁㈠崟", "2鍗曞厓杈婇亾涓嬫枡鏌ヨ璁㈠崟", "3鍗曞厓杈婇亾涓嬫枡鏌ヨ璁㈠崟", "杈婇亾涓婃枡鏌ヨ璁㈠崟" };
                 foreach (string name in names)
                 {
+                    namea = name;
                     var details = plcRepository.Find(x => x.plcdetail_iotype == plc.plcinfo_iotyep && x.plcdetail_number == name).ToList();
                     var on = DBExtension.Read(details.Where(x => x.plcdetail_name == "R_oi_on").First(), client);
                     //var on = DBExtension.Read(details.Where(x => x.plcdetail_name == "R_oi_on" && x.plcdetail_number == name).First(), client);
@@ -217,10 +246,11 @@
                         var wp_id = client.ReadByOrder<string>("R_o_wp_id", name);
                         if (string.IsNullOrEmpty(wp_id))
                         {
-                            #region 鏃ュ織璁板綍
                             client.WriteByOrder("W_i_status", (byte)2, name);
                             client.WriteByOrder("R_oi_on", (byte)0, name);
-                            WriteDBLog.Error(name, $"璇诲彇妗佹灦淇℃伅锛歕n杞﹁疆SN锛歿wp_id}\n\n鍐欏叆妗佹灦淇℃伅锛歕nW_i_status锛�2\nR_oi_on锛�0\n\n杞﹁疆SN鍙蜂负绌�", "PCS");
+                            #region 鏃ュ織璁板綍
+                            //WriteDBLog.Error(name, $"璇诲彇妗佹灦淇℃伅锛歕n杞﹁疆SN锛歿wp_id}\n\n鍐欏叆妗佹灦淇℃伅锛歕nW_i_status锛�2\nR_oi_on锛�0\n\n杞﹁疆SN鍙蜂负绌�", "PCS");
+                            WriteLog.Write_Log(name, wp_id, "閿欒淇℃伅锛�", $"璇诲彇妗佹灦淇℃伅锛歕n杞﹁疆SN锛歿wp_id}\n\n鍐欏叆妗佹灦淇℃伅锛歕nW_i_status锛�2\nR_oi_on锛�0\n\n杞﹁疆SN鍙蜂负绌�");
                             #endregion
                             continue;
                         }
@@ -232,7 +262,8 @@
                             client.WriteByOrder("W_i_status", (byte)2, name);
                             client.WriteByOrder("R_oi_on", (byte)0, name);
                             #region 鏃ュ織璁板綍
-                            WriteDBLog.Error(name, $"璇诲彇妗佹灦淇℃伅锛歕n杞﹁疆SN锛歿wp_id}\n\n鍐欏叆妗佹灦淇℃伅锛歕nW_i_status锛�2\nR_oi_on锛�0\n\n鏈煡璇㈠埌宸ュ崟璇︽儏", "PCS");
+                            //WriteDBLog.Error(name, $"璇诲彇妗佹灦淇℃伅锛歕n杞﹁疆SN锛歿wp_id}\n\n鍐欏叆妗佹灦淇℃伅锛歕nW_i_status锛�2\nR_oi_on锛�0\n\n鏈煡璇㈠埌宸ュ崟璇︽儏", "PCS");
+                            WriteLog.Write_Log(name, wp_id, "閿欒淇℃伅锛�", $"璇诲彇妗佹灦淇℃伅锛歕n杞﹁疆SN锛歿wp_id}\n\n鍐欏叆妗佹灦淇℃伅锛歕nW_i_status锛�2\nR_oi_on锛�0\n\n鏈煡璇㈠埌宸ュ崟璇︽儏");
                             #endregion
                             continue;
                         }
@@ -270,7 +301,8 @@
                                 client.WriteByOrder("W_i_status", (byte)4, name);
                                 client.WriteByOrder("R_oi_on", (byte)0, name);
                                 #region 鏃ュ織璁板綍
-                                WriteDBLog.Error(name, $"璇诲彇妗佹灦淇℃伅锛歕n杞﹁疆SN锛歿wp_id}\n\n鍐欏叆妗佹灦淇℃伅锛歕nW_i_status锛�4\nR_oi_on锛�0\n\n鎵嬪姩鍏ュ簱妯″紡鏈�夋嫨搴撳尯", "PCS");
+                                //WriteDBLog.Error(name, $"璇诲彇妗佹灦淇℃伅锛歕n杞﹁疆SN锛歿wp_id}\n\n鍐欏叆妗佹灦淇℃伅锛歕nW_i_status锛�4\nR_oi_on锛�0\n\n鎵嬪姩鍏ュ簱妯″紡鏈�夋嫨搴撳尯", "PCS");
+                                WriteLog.Write_Log(name, wp_id, "閿欒淇℃伅锛�", $"璇诲彇妗佹灦淇℃伅锛歕n杞﹁疆SN锛歿wp_id}\n\n鍐欏叆妗佹灦淇℃伅锛歕nW_i_status锛�4\nR_oi_on锛�0\n\n鎵嬪姩鍏ュ簱妯″紡鏈�夋嫨搴撳尯");
                                 #endregion
                                 continue;
                             }
@@ -283,7 +315,8 @@
                                 client.WriteByOrder("W_i_status", (byte)2, name);
                                 client.WriteByOrder("R_oi_on", (byte)0, name);
                                 #region 鏃ュ織璁板綍
-                                WriteDBLog.Error(name, $"璇诲彇妗佹灦淇℃伅锛歕n杞﹁疆SN锛歿wp_id}\n杞瀷ID锛歿wp_type}\n\n鍐欏叆妗佹灦淇℃伅锛歕nW_i_status锛�2\nR_oi_on锛�0\n\n鏈煡璇㈠埌鏈哄姞宸ヨ溅杞俊鎭�", "PCS");
+                                //WriteDBLog.Error(name, $"璇诲彇妗佹灦淇℃伅锛歕n杞﹁疆SN锛歿wp_id}\n杞瀷ID锛歿wp_type}\n\n鍐欏叆妗佹灦淇℃伅锛歕nW_i_status锛�2\nR_oi_on锛�0\n\n鏈煡璇㈠埌鏈哄姞宸ヨ溅杞俊鎭�", "PCS");
+                                WriteLog.Write_Log(name, wp_id, "閿欒淇℃伅锛�", $"璇诲彇妗佹灦淇℃伅锛歕n杞﹁疆SN锛歿wp_id}\n杞瀷ID锛歿wp_type}\n\n鍐欏叆妗佹灦淇℃伅锛歕nW_i_status锛�2\nR_oi_on锛�0\n\n鏈煡璇㈠埌鏈哄姞宸ヨ溅杞俊鎭�");
                                 #endregion
                                 continue;
                             }
@@ -306,10 +339,14 @@
                                 //}
                                 client.WriteByOrder("R_oi_on", (byte)0, name);
                                 #region 鏃ュ織璁板綍
-                                WriteDBLog.Success(name, $"璇诲彇妗佹灦淇℃伅锛歕n杞﹁疆SN锛歿wp_id}\n杞瀷ID锛歿wp_type}\n\n鍐欏叆妗佹灦淇℃伅锛歕nW_i_status锛�1" +
+                                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", "PCS");
+                                    $"\nW_i_skip_op_LT锛歿mes_Head.skip_op_3}\nR_oi_on锛�0");
+                                //WriteDBLog.Success(name, $"璇诲彇妗佹灦淇℃伅锛歕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", "PCS");
                                 #endregion
                             }
                         }
@@ -323,7 +360,8 @@
                                 client.WriteByOrder("W_i_status", (byte)2, name);
                                 client.WriteByOrder("R_oi_on", (byte)0, name);
                                 #region 鏃ュ織璁板綍
-                                WriteDBLog.Error(name, $"璇诲彇妗佹灦淇℃伅锛歕n杞﹁疆SN锛歿wp_id}\n杞瀷ID锛歿wp_type}\n\n鍐欏叆妗佹灦淇℃伅锛歕nW_i_status锛�2\nR_oi_on锛�0\n\n鏈煡璇㈠埌妫�娴嬬嚎杞﹁疆淇℃伅", "PCS");
+                                //WriteDBLog.Error(name, $"璇诲彇妗佹灦淇℃伅锛歕n杞﹁疆SN锛歿wp_id}\n杞瀷ID锛歿wp_type}\n\n鍐欏叆妗佹灦淇℃伅锛歕nW_i_status锛�2\nR_oi_on锛�0\n\n鏈煡璇㈠埌妫�娴嬬嚎杞﹁疆淇℃伅", "PCS");
+                                WriteLog.Write_Log(name, wp_id, "閿欒淇℃伅锛�", $"璇诲彇妗佹灦淇℃伅锛歕n杞﹁疆SN锛歿wp_id}\n杞瀷ID锛歿wp_type}\n\n鍐欏叆妗佹灦淇℃伅锛歕nW_i_status锛�2\nR_oi_on锛�0\n\n鏈煡璇㈠埌妫�娴嬬嚎杞﹁疆淇℃伅");
                                 #endregion
                                 continue;
                             }
@@ -338,8 +376,10 @@
                                 client.WriteByOrder("W_i_batch_id", Mes_Work.heatBatchID, name);
                                 client.WriteByOrder("R_oi_on", (byte)0, name);
                                 #region 鏃ュ織璁板綍
-                                WriteDBLog.Success(name, $"璇诲彇妗佹灦淇℃伅锛歕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_Head.drawingNo}\nW_i_heat_id锛歿Mes_Work.heatID}\nW_i_batch_id锛歿Mes_Work.heatBatchID}\nR_oi_on锛�0", "PCS");
+                                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_Head.drawingNo}\nW_i_heat_id锛歿Mes_Work.heatID}\nW_i_batch_id锛歿Mes_Work.heatBatchID}\nR_oi_on锛�0");
+                                //WriteDBLog.Success(name, $"璇诲彇妗佹灦淇℃伅锛歕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_Head.drawingNo}\nW_i_heat_id锛歿Mes_Work.heatID}\nW_i_batch_id锛歿Mes_Work.heatBatchID}\nR_oi_on锛�0", "PCS");
                                 #endregion
                             }
                         }
@@ -348,7 +388,8 @@
             }
             catch (Exception ex)
             {
-                WriteDBLog.Error("鏌ヨ杞﹁疆璁㈠崟", $"閿欒淇℃伅锛歿ex.Message}", "PCS");
+                //WriteDBLog.Error("鏌ヨ杞﹁疆璁㈠崟", $"閿欒淇℃伅锛歿ex.Message}", "PCS");
+                WriteLog.Write_Log("鎶ラ敊鏃ュ織", namea, "閿欒淇℃伅锛�", $"閿欒淇℃伅锛歿ex.Message}");
             }
         }
         #endregion
@@ -404,14 +445,6 @@
                         }
                         #endregion
 
-                        var Stations = stationinfoRepository.Find(x => x.area == PipelineJob.area_code(name)).OrderBy(x => x.lastUpdateTime).ToList();
-
-                        #region 涓嬫枡浣嶆槸鍚︿负绌虹姸鎬佸悓姝ョ粰妗佹灦
-                        foreach (var station in Stations)
-                        {
-                            client.WriteByOrder(station.stationCode, station.location_state != LocationStateEnum.Stroge.ToString(), name);
-                        }
-                        #endregion
 
                         if (finished && !updatefinished)
                         {
@@ -449,7 +482,7 @@
 
                             #region 鍒ゆ柇鍖哄煙鍙锋槸鍚︿竴鑷�
                             var area = client.ReadByOrder<Int16>("place_prog", name);//鏀炬枡瀹屾垚鐨勫尯鍩熷彿
-                            
+
                             if (AreaNr != area)
                             {
                                 Pipeline_client.WriteByOrder("W_AlarmSignal", (Int16)2, name);//鎶ヨ
@@ -459,7 +492,7 @@
                             }
                             #endregion
 
-                            var areaCode = PipelineJob.area_code(name);   //鏍规嵁涓嬫枡鍙e崟鍏冨悕鑾峰彇鍖哄煙浠g爜
+                            var areaCode = Pipeline.area_code(name);   //鏍规嵁涓嬫枡鍙e崟鍏冨悕鑾峰彇鍖哄煙浠g爜
                             var station = stationinfoRepository.Find(x => x.area == areaCode && x.stationCode.Substring(x.stationCode.Length - 1, 1) == AreaNr.ToString()).FirstOrDefault();
                             if (station != null)
                             {
@@ -486,21 +519,6 @@
                                         throw new Exception($"{station.stationCode}宸插瓨鍦ㄨ溅杞甋N鍙凤細{Wheel_SN}");
                                 }
 
-                                station.bindSN = string.IsNullOrEmpty(station.bindSN) ? Wheel_SN : station.bindSN + "," + Wheel_SN;
-                                station.billetID = string.IsNullOrEmpty(station.billetID) ? Mes_Work.billetID.ToString() : station.billetID + "," + Mes_Work.billetID;
-                                station.quantity++;
-                                if (station.quantity == 1)
-                                {
-                                    station.stationType = Mes_Work.drawingNo;
-                                    station.Number = Mes_Work.workOrder;
-                                    station.heatNumber = Mes_Work.heatID;
-                                    station.tray_status = "StrogeTray";
-                                }
-
-                                var count = stationinfoRepository.Update(station, true);
-                                if (count < 1)
-                                    throw new Exception($"涓嬫枡浣嶄俊鎭洿鏂板け璐ワ紒涓嬫枡浣嶇紪鍙凤細{station.stationCode}");
-
                                 #region 娓呯┖缁欐鏋剁殑涓嬫枡淇℃伅
                                 client.WriteByOrder("W_IndexNr", (Int16)0, name);//鎵樼洏涓婄殑绗嚑涓溅杞�
                                 client.WriteByOrder("W_Storage_Type", (Int16)0, name);//鎵樼洏绫诲瀷1-妯斁;2-绔栨斁(鏆傛椂鍙湁妯斁鎵樼洏)
@@ -516,6 +534,24 @@
                                 //    $"鍐欏叆妗佹灦淇℃伅锛歕nW_Storage_update锛歿true}\nW_Enabl_Load锛歿false}", "PCS");
                                 #endregion
 
+                                #region 璐т綅鐘舵�佹洿鏂�
+                                station.bindSN = string.IsNullOrEmpty(station.bindSN) ? Wheel_SN : station.bindSN + "," + Wheel_SN;
+                                station.billetID = string.IsNullOrEmpty(station.billetID) ? Mes_Work.billetID.ToString() : station.billetID + "," + Mes_Work.billetID;
+                                station.quantity++;
+                                if (station.quantity == 1)
+                                {
+                                    station.stationType = Mes_Work.drawingNo;
+                                    station.Number = Mes_Work.workOrder;
+                                    station.heatNumber = Mes_Work.heatID;
+                                    station.tray_status = "StrogeTray";
+                                }
+                                station.remark = "";
+                                var count = stationinfoRepository.Update(station, true);
+                                if (count < 1)
+                                    throw new Exception($"涓嬫枡浣嶄俊鎭洿鏂板け璐ワ紒涓嬫枡浣嶇紪鍙凤細{station.stationCode}");
+                                #endregion
+
+
                                 #region 淇敼宸ュ崟鐘舵��
                                 var Detail = mes_DetailRepository.FindFirst(x => x.jobID == Mes_Work.jobID && x.SN == Mes_Work.SN);
                                 Detail.Status = "涓嬬嚎";
@@ -525,6 +561,7 @@
                                     throw new Exception($"宸ュ崟瀛愯〃淇℃伅鏇存柊澶辫触锛佽溅杞甋N鍙凤細{Detail.SN}");
                                 var Head = mes_HeadRepository.FindFirst(x => x.jobID == Detail.jobID);
                                 Head.finishNum = Head.finishNum + 1;
+                                if (Head.finishNum == Head.quantity) Head.FinishTime = DateTime.Now;
                                 count = mes_HeadRepository.Update(Head, true);
                                 if (count < 1)
                                     throw new Exception($"宸ュ崟澶磋〃淇℃伅鏇存柊澶辫触锛佸伐鍗曞彿锛歿Head.jobID}");
@@ -532,11 +569,18 @@
                             }
                         }
 
+                        var Stations = stationinfoRepository.Find(x => x.area == Pipeline.area_code(name)).OrderBy(x => x.lastUpdateTime).ToList();
+
+                        #region 涓嬫枡浣嶆槸鍚︿负绌虹姸鎬佸悓姝ョ粰妗佹灦
+                        foreach (var station in Stations)
+                        {
+                            client.WriteByOrder(station.stationCode, station.location_state != LocationStateEnum.Stroge.ToString(), name);
+                        }
+                        #endregion
+
                         var Request = (bool)DBExtension.Read(details.Where(x => x.plcdetail_name == "R_Request_Load").First(), client);
                         if (!Request) continue;
 
-                        //var Area = client.ReadByOrder<Int16>("W_AreaNr", name);//璇诲彇璐т綅鍙蜂俊鎭�
-                        //if (Area != 0) continue;
 
                         #region 璇诲彇妗佹灦淇℃伅
                         var Wheel_Type = DBExtension.Read(details.Where(x => x.plcdetail_name == "R_Wheel_Type").First(), client);//杞﹁疆绫诲瀷
@@ -554,6 +598,7 @@
                             client.WriteByOrder("W_Enabl_Load", false, name);//淇″彿涓篺alse妗佹灦鍋滄杩涘叆
                             //WriteDBLog.Error(name, $"璇诲彇妗佹灦淇℃伅锛歕n杞﹁疆SN锛歿Wheel_id}\n\n鏈煡璇㈠埌宸ュ崟淇℃伅", "PCS");
                             WriteLog.Write_Log(name + "鐢宠鏀炬枡寮傚父", Wheel_id, "鏌ヨ鏈哄姞宸ュ伐鍗�", $"璇诲彇妗佹灦淇℃伅锛歕n杞﹁疆SN鍙凤細{Wheel_id}鏈煡璇㈠埌宸ュ崟淇℃伅\n鍐欏叆妗佹灦淇℃伅锛歕n鏄惁鍏佽涓嬫枡锛歿false}");
+                            continue;
                         }
 
 
@@ -570,8 +615,10 @@
                         #endregion
 
 
-                        var wheel = PipelineJob.QueryMateriel(Work.drawingNo);
-                        var wheel1 = PipelineJob.QueryMateriel1(Work.drawingNo);
+
+
+                        var wheel = Pipeline.QueryMateriel(Work.drawingNo);
+                        var wheel1 = Pipeline.QueryMateriel1(Work.drawingNo);
                         if (wheel == null && wheel1 == null)
                         {
                             #region 鏃ュ織璁板綍
@@ -581,6 +628,17 @@
                             #endregion
                             continue;
                         }
+
+                        #region 鎹㈠浘鍙�,涓嬫枡鍙e叾浠栧浘鍙锋墭鐩樺叏閮ㄥ叆搴�
+                        var stations = Stations.Where(x => x.enable && x.location_state == LocationStateEnum.Stroge.ToString() && x.quantity > 0 && x.stationType != Work.drawingNo).ToList();
+                        foreach (var station in stations)
+                        {
+                            if (station.stationCode == NGStation || name == "3鍗曞厓涓嬫枡鍖�")
+                                agvtask(stationinfoRepository, station, Work, "TaskType_OutsourceInbound");
+                            else
+                                agvtask(stationinfoRepository, station, Work, "TaskType_Inbound");
+                        }
+                        #endregion
 
                         var PartStatus = DBExtension.Read(details.Where(x => x.plcdetail_name == "R_PartStatus").First(), client);//1:ok;2:nok
 
@@ -624,12 +682,9 @@
                             if (Stationinfo == null)
                             {
                                 #region 瑙﹀彂NG浠诲姟
-                                var NG = Stations.Where(x => x.enable && x.stationCode == NGStation && x.location_state == LocationStateEnum.Stroge.ToString() && x.quantity > 0).FirstOrDefault();
+                                var NG = Stations.Where(x => x.enable && x.stationCode == NGStation && x.location_state == LocationStateEnum.Stroge.ToString() && x.Number != Work.workOrder && x.quantity > 0).FirstOrDefault();
                                 if (NG != null)
-                                {
-                                    if (NG.stationType != Work.drawingNo || NG.Number != Work.workOrder)
-                                        agvtask(stationinfoRepository, NG, Work, "TaskType_OutsourceInbound");
-                                }
+                                    agvtask(stationinfoRepository, NG, Work, "TaskType_OutsourceInbound");
                                 #endregion
 
                                 Stationinfo = Stations.Where(x => x.enable && x.stationCode != NGStation && x.location_state == LocationStateEnum.Stroge.ToString() && x.quantity == 0).FirstOrDefault();
@@ -640,9 +695,9 @@
                             {
 
                                 #region 鎹㈢被鍨嬬洿鎺ュ叆搴�
-                                var stationinfo1 = Stations.Where(x => x.enable && x.stationCode != NGStation && x.stationCode != Stationinfo.stationCode && x.location_state == LocationStateEnum.Stroge.ToString() && x.quantity > 0 && x.stationType != Work.drawingNo).FirstOrDefault();
-                                if (stationinfo1 != null)
-                                    agvtask(stationinfoRepository, stationinfo1, Work, name == "3鍗曞厓涓嬫枡鍖�" ? "TaskType_OutsourceInbound" : "TaskType_Inbound");
+                                //var stationinfo1 = Stations.Where(x => x.enable && x.stationCode != NGStation && x.stationCode != Stationinfo.stationCode && x.location_state == LocationStateEnum.Stroge.ToString() && x.quantity > 0 && x.stationType != Work.drawingNo).FirstOrDefault();
+                                //if (stationinfo1 != null)
+                                //    agvtask(stationinfoRepository, stationinfo1, Work, name == "3鍗曞厓涓嬫枡鍖�" ? "TaskType_OutsourceInbound" : "TaskType_Inbound");
                                 #endregion
 
                                 #region 鎵樼洏杞﹁疆鍫嗗灈绗洓涓椂涓嬪彂鍙﹀涓�涓倝鍙风殑鍏ュ簱浠诲姟
@@ -724,6 +779,8 @@
                                     client.WriteByOrder("W_IndexNr", (Int16)(Stationinfo.quantity + 1), name);//鎵樼洏涓婄殑绗嚑涓溅杞�
                                     client.WriteByOrder("W_Storage_Type", (Int16)1, name);//鎵樼洏绫诲瀷1-妯斁;2-绔栨斁(鏆傛椂鍙湁妯斁鎵樼洏)
                                     client.WriteByOrder("W_Enabl_Load", true, name);//鏄惁鍏佽
+                                    Stationinfo.remark = "妗佹灦涓嬫枡";
+                                    stationinfoRepository.Update(Stationinfo, true);
                                     #region 鏃ュ織璁板綍
                                     //WriteDBLog.Success(name + "鍏佽鏀炬枡", $"璇诲彇妗佹灦淇℃伅锛歕n杞﹁疆SN锛歿Wheel_id}\n杞瀷ID锛歿Wheel_Type}\n杞﹁疆鐘舵�侊細OK" +$"\n璇诲彇鎵樼洏鍏夌數淇″彿锛歿PalletSignal}" +
                                     //    $"\n\n鍐欏叆妗佹灦淇℃伅锛歕n涓嬫枡浣嶅彿锛歿area}\n绗嚑涓溅杞細{(Stationinfo.quantity + 1)}\n鎵樼洏绫诲瀷锛�1\nW_Enabl_Load锛歵rue", "PCS");
@@ -740,7 +797,7 @@
                                 #region 娌℃墭鐩樺彲鐢�,瑙﹀彂鍏ュ簱浠诲姟
                                 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).OrderBy(x => x.lastUpdateTime).FirstOrDefault();
+                                    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");
                                 }
                                 #endregion
@@ -782,6 +839,7 @@
                                     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();
@@ -835,6 +893,8 @@
                                     client.WriteByOrder("W_IndexNr", (Int16)(Stationinfo.quantity + 1), name);//鎵樼洏涓婄殑绗嚑涓溅杞�
                                     client.WriteByOrder("W_Storage_Type", (Int16)1, name);//鎵樼洏绫诲瀷1-妯斁;2-绔栨斁(鏆傛椂鍙湁妯斁鎵樼洏)
                                     client.WriteByOrder("W_Enabl_Load", true, name);//鏄惁鍏佽
+                                    Stationinfo.remark = "妗佹灦涓嬫枡";
+                                    stationinfoRepository.Update(Stationinfo, true);
                                     #region 鏃ュ織璁板綍
                                     //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");
@@ -852,13 +912,15 @@
                     }
                     catch (Exception ex)
                     {
-                        WriteDBLog.Error(name, $"閿欒淇℃伅锛歿ex.Message}", "PCS");
+                        //WriteDBLog.Error(name, $"閿欒淇℃伅锛歿ex.Message}", "PCS");
+                        WriteLog.Write_Log("鎶ラ敊鏃ュ織", name, "閿欒淇℃伅锛�", $"閿欒淇℃伅锛歿ex.Message}");
                     }
                 }
             }
             catch (Exception ex)
             {
-                WriteDBLog.Error("涓嬫枡鍖�", $"閿欒淇℃伅锛歿ex.Message}", "PCS");
+                //WriteDBLog.Error("涓嬫枡鍖�", $"閿欒淇℃伅锛歿ex.Message}", "PCS");
+                WriteLog.Write_Log("鎶ラ敊鏃ュ織", "涓嬫枡鍖�", "閿欒淇℃伅锛�", $"閿欒淇℃伅锛歿ex.Message}");
             }
         }
         #endregion
@@ -867,6 +929,8 @@
         {
             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();
             var task = agvtaskRepository.Find(x => x.agv_fromaddress == stationinfo.stationCode).FirstOrDefault();
             if (task != null) return;
             if (!string.IsNullOrEmpty(Work.area))

--
Gitblit v1.9.3