From 19c66ba052a7fb26c4d27deaa75ae46479eee342 Mon Sep 17 00:00:00 2001 From: dengjunjie <dengjunjie@hnkhzn.com> Date: 星期一, 01 四月 2024 10:36:44 +0800 Subject: [PATCH] 优化堆垛逻辑和入库逻辑 --- 代码管理/PCS/WCS_Server/WIDESEA_WCS/Common/Gantry.cs | 327 ++++++++++++++++++++++++++++++++--------------------- 1 files changed, 197 insertions(+), 130 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 f78df0c..9cc2340 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" @@ -11,6 +11,7 @@ using WIDESEA_Comm.LogInfo; using WIDESEA_Comm.TaskNo; using WIDESEA_Core.EFDbContext; +using WIDESEA_Core.FreeDB; using WIDESEA_Entity.DomainModels; using WIDESEA_WCS.IRepositories; using WIDESEA_WCS.JobsPart.Common; @@ -37,6 +38,7 @@ VOLContext Context = new VOLContext(); Idt_plcinfoheadRepository repository = new dt_plcinfoheadRepository(Context); Idt_plcinfodetailRepository plcRepository = new dt_plcinfodetailRepository(Context); + IVV_Mes_WorkinfoRepository workinfoRepository = new VV_Mes_WorkinfoRepository(Context); Idt_geometry_dataRepository dataRepository = new dt_geometry_dataRepository(Context); Idt_mes_detailRepository mes_DetailRepository = new dt_mes_detailRepository(Context); Idt_mes_headRepository mes_HeadRepository = new dt_mes_headRepository(Context); @@ -56,32 +58,47 @@ if (name == "3鍗曞厓杈婇亾涓嬫枡鏌ヨ杞﹁疆") number = "3鍗曞厓杈婇亾涓嬫枡鏌ヨ璁㈠崟"; if (name == "杈婇亾涓婃枡鏌ヨ杞﹁疆") number = "杈婇亾涓婃枡鏌ヨ璁㈠崟"; var wp_id = client.ReadByOrder<string>("R_o_wp_id", number); - var mes_Detail = mes_DetailRepository.FindFirst(x => x.SN == wp_id); - if (mes_Detail == null) + + var Mes_Work = workinfoRepository.Find(x => x.SN == wp_id && x.processCode == (name != "杈婇亾涓婃枡鏌ヨ杞﹁疆" ? "17" : "28")).FirstOrDefault(); + if (Mes_Work == null) { 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"); - #endregion - continue; - } - var mes_Head = mes_HeadRepository.FindFirst(x => x.jobID == mes_Detail.jobID); - if (mes_Head == null) - { - 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"); #endregion continue; } + #region MyRegion + //var mes_Detail = mes_DetailRepository.FindFirst(x => x.SN == wp_id); + //if (mes_Detail == null) + //{ + // 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"); + // #endregion + // continue; + //} + //var mes_Head = mes_HeadRepository.FindFirst(x => x.jobID == mes_Detail.jobID); + //if (mes_Head == null) + //{ + // 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"); + // #endregion + // continue; + //} + #endregion + + if (name != "杈婇亾涓婃枡鏌ヨ杞﹁疆") { //var geometry = dataRepository.FindFirst(x => x.TypeId == (Int32)wp_type); - var geometry = dataRepository.Find(x => x.Description == mes_Head.drawingNo).FirstOrDefault(); - var geometry1 = detectionlineRepository.Find(x => x.Description == mes_Head.drawingNo).FirstOrDefault(); + var geometry = dataRepository.Find(x => x.Description == Mes_Work.drawingNo).FirstOrDefault(); + var geometry1 = detectionlineRepository.Find(x => x.Description == Mes_Work.drawingNo).FirstOrDefault(); if (geometry == null && geometry1 == null) { //DBExtension.Write(details.Where(x => x.plcdetail_name == "W_i_status").First(), client, (Int16)2); @@ -121,8 +138,8 @@ } else { - var geometry = detectionlineRepository.Find(x => x.Description == mes_Head.drawingNo).FirstOrDefault(); - var geometry1 = dataRepository.Find(x => x.Description == mes_Head.drawingNo).FirstOrDefault(); + var geometry = detectionlineRepository.Find(x => x.Description == Mes_Work.drawingNo).FirstOrDefault(); + var geometry1 = dataRepository.Find(x => x.Description == Mes_Work.drawingNo).FirstOrDefault(); if (geometry == null && geometry1 == null) { client.WriteByOrder("W_i_status", (byte)2, name); @@ -183,6 +200,7 @@ Idt_geometry_dataRepository dataRepository = new dt_geometry_dataRepository(Context); Idt_geometry_data_detectionlineRepository detectionlineRepository = new dt_geometry_data_detectionlineRepository(Context); Idt_mes_detailRepository mes_DetailRepository = new dt_mes_detailRepository(Context); + IVV_Mes_WorkinfoRepository workinfoRepository = new VV_Mes_WorkinfoRepository(Context); Idt_mes_headRepository mes_HeadRepository = new dt_mes_headRepository(Context); Idt_patternRepository patternRepository = new dt_patternRepository(Context); var plc = repository.FindFirst(x => x.plcinfo_name == client.PLCName); @@ -206,16 +224,9 @@ continue; } var wp_type = DBExtension.Read(details.Where(x => x.plcdetail_name == "R_o_wp_type").First(), client); - var mes_Detail = mes_DetailRepository.FindFirst(x => x.SN == wp_id); - #region 娴嬭瘯浣跨敤 - //if (mes_Detail == null) - //{ - // mes_Detail = mes_DetailRepository.FindFirst(x => x.jobID == (name == "3鍗曞厓杈婇亾涓嬫枡鏌ヨ璁㈠崟" ? "01180127004-2" : "01180127004-1")); - // mes_Detail.SN = wp_id; - // mes_DetailRepository.Update(mes_Detail, true); - //} - #endregion - if (mes_Detail == null) + + var Mes_Work = workinfoRepository.Find(x => x.SN == wp_id && x.processCode == (name != "杈婇亾涓婃枡鏌ヨ璁㈠崟" ? "17" : "28")).FirstOrDefault(); + if (Mes_Work == null) { client.WriteByOrder("W_i_status", (byte)2, name); client.WriteByOrder("R_oi_on", (byte)0, name); @@ -224,16 +235,30 @@ #endregion continue; } - var mes_Head = mes_HeadRepository.FindFirst(x => x.jobID == mes_Detail.jobID); - if (mes_Head == null) - { - 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"); - #endregion - continue; - } + #region MyRegion + //var mes_Detail = mes_DetailRepository.FindFirst(x => x.SN == wp_id); + //if (mes_Detail == null) + //{ + // 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"); + // #endregion + // continue; + //} + //var mes_Head = mes_HeadRepository.FindFirst(x => x.jobID == mes_Detail.jobID); + //if (mes_Head == null) + //{ + // 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"); + // #endregion + // continue; + //} + #endregion + + var mes_Head = mes_HeadRepository.FindFirst(x => x.jobID == Mes_Work.jobID); if (name != "杈婇亾涓婃枡鏌ヨ璁㈠崟") { @@ -265,11 +290,11 @@ { //1-濂�,鍏佽鍔犲伐锛�2-涓嶅湪鍒楄〃涓紝3-涓嶅姞宸ヨ溅杞被鍨嬶紝4-鎵嬪姩鍏ュ簱妯″紡浜哄伐鏈�夋嫨搴撳尯 client.WriteByOrder("W_i_status", (byte)1, name); - client.WriteByOrder("W_i_job_id", mes_Detail.jobID, name); - client.WriteByOrder("W_i_drawing_id", mes_Head.drawingNo, name); - client.WriteByOrder("W_i_heat_id", mes_Detail.heatID, name); + client.WriteByOrder("W_i_job_id", Mes_Work.jobID, name); + client.WriteByOrder("W_i_drawing_id", Mes_Work.drawingNo, name); + client.WriteByOrder("W_i_heat_id", Mes_Work.heatID, name); //client.WriteByOrder("W_i_sourceheat", "", name); - client.WriteByOrder("W_i_batch_id", mes_Detail.heatBatchID, name); + client.WriteByOrder("W_i_batch_id", Mes_Work.heatBatchID, name); //灞忚斀宸ヨ壓(灞忚斀瑙嗚妫�娴�/灞忚斀娑傛补) //if (name != "杈婇亾涓婃枡鏌ヨ杞﹁疆") @@ -281,7 +306,7 @@ 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_Detail.jobID}\nW_i_drawing_id锛歿mes_Head.drawingNo}\nW_i_heat_id锛歿mes_Detail.heatID}\nW_i_batch_id锛歿mes_Detail.heatBatchID}" + + $"\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 @@ -305,15 +330,15 @@ { //1-濂�,鍏佽鍔犲伐锛�2-涓嶅湪鍒楄〃涓紝3-涓嶅姞宸ヨ溅杞被鍨嬶紝4-鎵嬪姩鍏ュ簱妯″紡浜哄伐鏈�夋嫨搴撳尯 client.WriteByOrder("W_i_status", (byte)1, name); - client.WriteByOrder("W_i_job_id", mes_Detail.jobID, name); - client.WriteByOrder("W_i_drawing_id", mes_Head.drawingNo, name); - client.WriteByOrder("W_i_heat_id", mes_Detail.heatID, name); + client.WriteByOrder("W_i_job_id", Mes_Work.jobID, name); + client.WriteByOrder("W_i_drawing_id", Mes_Work.drawingNo, name); + client.WriteByOrder("W_i_heat_id", Mes_Work.heatID, name); //client.WriteByOrder("W_i_sourceheat", "", name); - client.WriteByOrder("W_i_batch_id", mes_Detail.heatBatchID, name); + 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_Detail.jobID}" + - $"\nW_i_drawing_id锛歿mes_Head.drawingNo}\nW_i_heat_id锛歿mes_Detail.heatID}\nW_i_batch_id锛歿mes_Detail.heatBatchID}\nR_oi_on锛�0", "PCS"); + 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 } } @@ -344,6 +369,7 @@ Idt_geometry_data_detectionlineRepository detectionlineRepository = new dt_geometry_data_detectionlineRepository(Context); Idt_mes_detailRepository mes_DetailRepository = new dt_mes_detailRepository(Context); Idt_mes_headRepository mes_HeadRepository = new dt_mes_headRepository(Context); + IVV_Mes_WorkinfoRepository workinfoRepository = new VV_Mes_WorkinfoRepository(Context); Idt_patternRepository patternRepository = new dt_patternRepository(Context); var plc = repository.FindFirst(x => x.plcinfo_name == client.PLCName); var Pipeline_client = PLCClient.Clients.FirstOrDefault(t => t.PLCName == "閾炬潯鏈�"); @@ -405,28 +431,38 @@ var Wheel_SN = client.ReadByOrder<string>("R_Wheel_id", name);//杞﹁疆SN鍙� if (string.IsNullOrEmpty(Wheel_SN)) { - WriteDBLog.Error(name, $"璇诲彇妗佹灦淇℃伅锛歕n杞﹁疆SN鍙蜂负绌�", "PCS"); + WriteDBLog.Error(name + "鏀炬枡瀹屾垚", $"璇诲彇妗佹灦淇℃伅锛歕n杞﹁疆SN鍙蜂负绌�", "PCS"); continue; } //var Wheel_id = DBExtension.Read(details.Where(x => x.plcdetail_name == "R_Wheel_id").First(), client).ToString(); - - var Detail = mes_DetailRepository.FindFirst(x => x.SN == Wheel_SN); - if (Detail == null) + var Mes_Work = workinfoRepository.Find(x => x.SN == Wheel_SN && x.processCode == "17").FirstOrDefault(); + if (Mes_Work == null) { #region 鏃ュ織璁板綍 WriteDBLog.Error(name, $"璇诲彇妗佹灦淇℃伅锛歕n杞﹁疆SN鍙凤細{Wheel_SN}\n\n鏈煡璇㈠埌宸ュ崟璇︽儏", "PCS"); #endregion continue; } - var Head = mes_HeadRepository.FindFirst(x => x.jobID == Detail.jobID && x.processCode == "17"); - if (Head == null) - { - #region 鏃ュ織璁板綍 - WriteDBLog.Error(name, $"璇诲彇妗佹灦淇℃伅锛歕n杞﹁疆SN鍙凤細{Wheel_SN}\n\n鏈煡璇㈠埌宸ュ崟澶磋〃{Detail.jobID}", "PCS"); - #endregion - continue; - } + #region MyRegion + //var Detail = mes_DetailRepository.FindFirst(x => x.SN == Wheel_SN); + //if (Detail == null) + //{ + // #region 鏃ュ織璁板綍 + // WriteDBLog.Error(name, $"璇诲彇妗佹灦淇℃伅锛歕n杞﹁疆SN鍙凤細{Wheel_SN}\n\n鏈煡璇㈠埌宸ュ崟璇︽儏", "PCS"); + // #endregion + // continue; + //} + //var Head = mes_HeadRepository.FindFirst(x => x.jobID == Detail.jobID && x.processCode == "17"); + //if (Head == null) + //{ + // #region 鏃ュ織璁板綍 + // WriteDBLog.Error(name, $"璇诲彇妗佹灦淇℃伅锛歕n杞﹁疆SN鍙凤細{Wheel_SN}\n\n鏈煡璇㈠埌宸ュ崟澶磋〃{Detail.jobID}", "PCS"); + // #endregion + // continue; + //} + #endregion + #endregion var AreaNr = (Int16)DBExtension.Read(details.Where(x => x.plcdetail_name == "W_AreaNr").First(), client); @@ -448,9 +484,9 @@ station.quantity++; if (station.quantity == 1) { - station.stationType = Head.drawingNo; - station.Number = Head.jobID; - station.heatNumber = Detail.heatID; + station.stationType = Mes_Work.drawingNo; + station.Number = Mes_Work.workOrder; + station.heatNumber = Mes_Work.heatID; station.tray_status = "StrogeTray"; } @@ -473,11 +509,13 @@ //client.WriteByOrder("W_Enabl_Load", false, name);//鏄惁鍏佽 #region 淇敼宸ュ崟鐘舵�� + var Detail = mes_DetailRepository.FindFirst(x => x.jobID == Mes_Work.jobID && x.SN == Mes_Work.SN); Detail.Status = "涓嬬嚎"; Detail.FinishTime = DateTime.Now; count = mes_DetailRepository.Update(Detail, true); if (count < 1) throw new Exception($"宸ュ崟瀛愯〃淇℃伅鏇存柊澶辫触锛佽溅杞甋N鍙凤細{Detail.SN}"); + var Head = mes_HeadRepository.FindFirst(x => x.jobID == Detail.jobID); Head.finishNum = Head.finishNum + 1; count = mes_HeadRepository.Update(Head, true); if (count < 1) @@ -505,30 +543,40 @@ var Request = (bool)DBExtension.Read(details.Where(x => x.plcdetail_name == "R_Request_Load").First(), client); if (!Request) continue; + var load_zone = (bool)DBExtension.Read(details.Where(x => x.plcdetail_name == "R_load_zone").First(), client); #region 璇诲彇妗佹灦淇℃伅 var Wheel_Type = DBExtension.Read(details.Where(x => x.plcdetail_name == "R_Wheel_Type").First(), client);//杞﹁疆绫诲瀷 var Wheel_id = client.ReadByOrder<string>("R_Wheel_id", name);//杞﹁疆SN鍙� if (string.IsNullOrEmpty(Wheel_id)) continue; - //var Wheel_id = DBExtension.Read(details.Where(x => x.plcdetail_name == "R_Wheel_id").First(), client).ToString(); - var mes_Detail = mes_DetailRepository.FindFirst(x => x.SN == Wheel_id); - if (mes_Detail == null) + var Work = workinfoRepository.Find(x => x.SN == Wheel_id && x.processCode == "17").FirstOrDefault(); + if (Work == null) { - #region 鏃ュ織璁板綍 client.WriteByOrder("W_Enabl_Load", false, name);//淇″彿涓篺alse妗佹灦鍋滄杩涘叆 - WriteDBLog.Error(name, $"璇诲彇妗佹灦淇℃伅锛歕n杞﹁疆SN锛歿Wheel_id}\n\n鏈煡璇㈠埌宸ュ崟璇︽儏", "PCS"); - #endregion - continue; + WriteDBLog.Error(name, $"璇诲彇妗佹灦淇℃伅锛歕n杞﹁疆SN锛歿Wheel_id}\n\n鏈煡璇㈠埌宸ュ崟淇℃伅", "PCS"); } - var mes_Head = mes_HeadRepository.FindFirst(x => x.jobID == mes_Detail.jobID); - if (mes_Head == null) - { - #region 鏃ュ織璁板綍 - client.WriteByOrder("W_Enabl_Load", false, name);//淇″彿涓篺alse妗佹灦鍋滄杩涘叆 - WriteDBLog.Error(name, $"璇诲彇妗佹灦淇℃伅锛歕n杞﹁疆SN锛歿Wheel_id}\n\n鏈煡璇㈠埌宸ュ崟澶磋〃", "PCS"); - #endregion - continue; - } + + #region MyRegion + //var mes_Detail = mes_DetailRepository.FindFirst(x => x.SN == Wheel_id); + //if (mes_Detail == null) + //{ + // #region 鏃ュ織璁板綍 + // client.WriteByOrder("W_Enabl_Load", false, name);//淇″彿涓篺alse妗佹灦鍋滄杩涘叆 + // WriteDBLog.Error(name, $"璇诲彇妗佹灦淇℃伅锛歕n杞﹁疆SN锛歿Wheel_id}\n\n鏈煡璇㈠埌宸ュ崟璇︽儏", "PCS"); + // #endregion + // continue; + //} + //var mes_Head = mes_HeadRepository.FindFirst(x => x.jobID == mes_Detail.jobID); + //if (mes_Head == null) + //{ + // #region 鏃ュ織璁板綍 + // client.WriteByOrder("W_Enabl_Load", false, name);//淇″彿涓篺alse妗佹灦鍋滄杩涘叆 + // WriteDBLog.Error(name, $"璇诲彇妗佹灦淇℃伅锛歕n杞﹁疆SN锛歿Wheel_id}\n\n鏈煡璇㈠埌宸ュ崟澶磋〃", "PCS"); + // #endregion + // continue; + //} + #endregion + #endregion @@ -538,11 +586,12 @@ if (name == "2鍗曞厓涓嬫枡鍖�") NGStation = "X02001003"; if (name == "3鍗曞厓涓嬫枡鍖�") NGStation = "X03001002"; - foreach (var station in Stations) //浠讳綍涓�涓笅鏂欎綅涓虹┖鎴栫鐢ㄦ椂,閮戒細鍋滄妗佹灦 - { - if (!station.enable || station.location_state == LocationStateEnum.Empty.ToString()) - client.WriteByOrder("W_Enabl_Load", false, name);//淇″彿涓篺alse妗佹灦鍋滄杩涘叆 - } + //foreach (var station in Stations) //浠讳綍涓�涓笅鏂欎綅涓虹┖鎴栫鐢ㄦ椂,閮戒細鍋滄妗佹灦 + //{ + // if (!station.enable || station.location_state == LocationStateEnum.Empty.ToString()) + // client.WriteByOrder("W_Enabl_Load", false, name);//淇″彿涓篺alse妗佹灦鍋滄杩涘叆 + //} + #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爜 @@ -552,8 +601,8 @@ #endregion - var wheel = PipelineJob.QueryMateriel(mes_Head.drawingNo); - var wheel1 = PipelineJob.QueryMateriel1(mes_Head.drawingNo); + var wheel = PipelineJob.QueryMateriel(Work.drawingNo); + var wheel1 = PipelineJob.QueryMateriel1(Work.drawingNo); if (wheel == null && wheel1 == null) { #region 鏃ュ織璁板綍 @@ -565,22 +614,23 @@ var PartStatus = DBExtension.Read(details.Where(x => x.plcdetail_name == "R_PartStatus").First(), client);//1:ok;2:nok #region 鏃ュ織璁板綍 - WriteDBLog.Success(name + "鐢宠鏀炬枡", $"璇诲彇妗佹灦淇℃伅锛歕n杞﹁疆SN锛歿Wheel_id}\n杞瀷ID锛歿Wheel_Type}\n杞﹁疆鐘舵�侊細{PartStatus}", "PCS"); + WriteDBLog.Success(name + "鐢宠鏀炬枡", $"璇诲彇妗佹灦淇℃伅锛歕n杞﹁疆SN锛歿Wheel_id}\n杞瀷ID锛歿Wheel_Type}\n杞﹁疆鐘舵�侊細{PartStatus}\n鏄惁杩涘叆涓嬫枡鍖猴細{load_zone}", "PCS"); + if (load_zone) continue; #endregion if ((Int16)PartStatus == 1) { dt_stationinfo Stationinfo = null; - if (mes_Detail.heatID != null) + if (Work.heatID != null) { Stationinfo = Stations .Where(x => x.enable && x.stationCode != NGStation && x.location_state == LocationStateEnum.Stroge.ToString() && x.quantity < 5 - && x.stationType == mes_Head.drawingNo + && x.stationType == Work.drawingNo && x.tray_type == ((wheel == null ? wheel1.e : wheel.e) < 1100 ? "SmallTray" : "LargeTray") - && x.Number == mes_Detail.jobID - && x.heatNumber == mes_Detail.heatID) + && x.Number == Work.workOrder + && x.heatNumber == Work.heatID) .OrderByDescending(x => x.quantity) .FirstOrDefault(); } @@ -591,9 +641,9 @@ && x.stationCode != NGStation && x.location_state == LocationStateEnum.Stroge.ToString() && x.quantity < 5 - && x.stationType == mes_Head.drawingNo + && x.stationType == Work.drawingNo && x.tray_type == ((wheel == null ? wheel1.e : wheel.e) < 1100 ? "SmallTray" : "LargeTray") - && x.Number == mes_Detail.jobID) + && x.Number == Work.workOrder) .OrderByDescending(x => x.quantity) .FirstOrDefault(); } @@ -613,23 +663,12 @@ var NG = Stations.Where(x => x.enable && x.stationCode == NGStation && x.location_state == LocationStateEnum.Stroge.ToString() && x.quantity > 0).FirstOrDefault(); if (NG != null) { - if (NG.stationType != mes_Head.drawingNo) - agvtask(stationinfoRepository, NG, (wheel == null ? wheel1.e : wheel.e), "TaskType_OutsourceInbound"); + if (NG.stationType != Work.drawingNo || NG.Number != Work.workOrder) + 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(); - - #region 娌℃墭鐩樺彲鐢�,瑙﹀彂鍏ュ簱浠诲姟 - if (Stationinfo == null) - { - var stationinfos = Stations.Where(x => x.enable && x.stationCode != NGStation && x.location_state == LocationStateEnum.Stroge.ToString() && x.quantity > 0).ToList(); - foreach (var stationinfo in stationinfos) - { - agvtask(stationinfoRepository, stationinfo, (wheel == null ? wheel1.e : wheel.e), name == "3鍗曞厓涓嬫枡鍖�" ? "TaskType_OutsourceInbound" : "TaskType_Inbound"); - } - } - #endregion #region MyRegion //var stationinfo = Stations.Where(x => x.enable && x.stationCode != NGStation && x.location_state == LocationStateEnum.Stroge.ToString() && x.quantity > 0).FirstOrDefault(); @@ -675,9 +714,23 @@ #region 璐т綅鏁伴噺涓庡厜鐢典笉鍖归厤锛屾姤璀� if (list.Count > 0 && MaterialSignal != 1) + { + client.WriteByOrder("W_Enabl_Load", false, name);//淇″彿涓篺alse妗佹灦鍋滄杩涘叆 Pipeline_client.WriteByOrder("W_AlarmSignal", (Int16)2, name);//鎶ヨ - //else if (list.Count < 1 && MaterialSignal == 1) - // Pipeline_client.WriteByOrder("W_AlarmSignal", (Int16)2, name);//鎶ヨ + Stationinfo.location_state = LocationStateEnum.Abnormal.ToString(); + Stationinfo.remark = "杞﹁疆鏁伴噺涓庡厜鐢典笉鍖归厤"; + stationinfoRepository.Update(Stationinfo, true); + //WriteDBLog.Error(name+"鐢宠涓嬫枡",$"{Stationinfo.stationCode}鐨勮揣浣�","PCS"); + } + else if (list.Count < 1 && MaterialSignal == 1) + { + client.WriteByOrder("W_Enabl_Load", false, name);//淇″彿涓篺alse妗佹灦鍋滄杩涘叆 + Pipeline_client.WriteByOrder("W_AlarmSignal", (Int16)2, name);//鎶ヨ + Stationinfo.location_state = LocationStateEnum.Abnormal.ToString(); + Stationinfo.remark = "杞﹁疆鏁伴噺涓庡厜鐢典笉鍖归厤"; + stationinfoRepository.Update(Stationinfo, true); + } + #endregion //缂撳瓨鏋朵笂杞﹁疆鏁伴噺涓嶴N鍙锋暟閲忎笉涓�鑷� @@ -703,6 +756,17 @@ continue; } } + else + { + #region 娌℃墭鐩樺彲鐢�,瑙﹀彂鍏ュ簱浠诲姟 + var stationinfos = Stations.Where(x => x.enable && x.stationCode != NGStation && x.location_state == LocationStateEnum.Stroge.ToString() && x.quantity > 0).ToList(); + foreach (var stationinfo in stationinfos) + { + agvtask(stationinfoRepository, stationinfo, Work, name == "3鍗曞厓涓嬫枡鍖�" ? "TaskType_OutsourceInbound" : "TaskType_Inbound"); + } + #endregion + } + } else if ((Int16)PartStatus == 2) { @@ -728,18 +792,18 @@ && x.stationCode == NGStation && x.location_state == LocationStateEnum.Stroge.ToString() && x.quantity < 5 - && x.stationType == mes_Head.drawingNo + && x.stationType == Work.drawingNo && x.tray_type == ((wheel == null ? wheel1.e : wheel.e) < 1100 ? "SmallTray" : "LargeTray") /*&& x.Number == mes_Detail.jobID*/).FirstOrDefault(); //} if (Stationinfo == null) { - var stationinfo = Stations.Where(x => x.enable && x.stationCode == NGStation && x.location_state == LocationStateEnum.Stroge.ToString() && x.quantity > 0).FirstOrDefault(); - if (stationinfo != null) - { - agvtask(stationinfoRepository, stationinfo, (wheel == null ? wheel1.e : wheel.e), "TaskType_OutsourceInbound"); - } + //var stationinfo = Stations.Where(x => x.enable && x.stationCode == NGStation && x.location_state == LocationStateEnum.Stroge.ToString() && x.quantity > 0).FirstOrDefault(); + //if (stationinfo != null) + //{ + // agvtask(stationinfoRepository, stationinfo, (wheel == null ? wheel1.e : wheel.e), "TaskType_OutsourceInbound"); + //} Stationinfo = Stations.Where(x => x.enable && x.stationCode == NGStation && x.location_state == LocationStateEnum.Stroge.ToString() && x.quantity == 0).FirstOrDefault(); } if (Stationinfo != null) @@ -772,8 +836,8 @@ #region 璐т綅鏁伴噺涓庡厜鐢典笉鍖归厤锛屾姤璀� if (list.Count > 0 && MaterialSignal != 1) Pipeline_client.WriteByOrder("W_AlarmSignal", (Int16)2, name);//鎶ヨ - //else if (list.Count < 1 && MaterialSignal == 1) - // Pipeline_client.WriteByOrder("W_AlarmSignal", (Int16)2, name);//鎶ヨ + else if (list.Count < 1 && MaterialSignal == 1) + Pipeline_client.WriteByOrder("W_AlarmSignal", (Int16)2, name);//鎶ヨ #endregion //缂撳瓨鏋朵笂杞﹁疆鏁伴噺涓嶴N鍙锋暟閲忎笉涓�鑷� @@ -870,7 +934,7 @@ /// <summary> /// AGV浠诲姟 /// </summary> - public void agvtask(Idt_stationinfoRepository stationinfoRepository, dt_stationinfo stationinfo, float e, string tasktype) + public void agvtask(Idt_stationinfoRepository stationinfoRepository, dt_stationinfo stationinfo, VV_Mes_Workinfo Work, string tasktype) { VOLContext Context = new VOLContext(); Idt_agvtaskRepository agvtaskRepository = new dt_agvtaskRepository(Context); @@ -878,23 +942,24 @@ var task = agvtaskRepository.Find(x => x.agv_fromaddress == stationinfo.stationCode).FirstOrDefault(); if (task != null) return; - var mes_Head = mes_HeadRepository.Find(x => x.jobID == stationinfo.Number).FirstOrDefault(); - if (mes_Head == null) - { - stationinfo.remark = "瑙﹀彂鍏ュ簱浠诲姟,浣嗘湭鎵惧埌宸ュ崟澶磋〃锛�"; - stationinfo.location_state = LocationStateEnum.Abnormal.ToString(); - stationinfoRepository.Update(stationinfo, true); - return; - } + //var mes_Head = mes_HeadRepository.Find(x => x.jobID == Work.jobID).FirstOrDefault(); + //if (mes_Head == null) + //{ + // stationinfo.remark = "瑙﹀彂鍏ュ簱浠诲姟,浣嗘湭鎵惧埌宸ュ崟澶磋〃锛�"; + // stationinfo.location_state = LocationStateEnum.Abnormal.ToString(); + // stationinfoRepository.Update(stationinfo, true); + // return; + //} dt_stationinfo TargetLocation = null; - int CompeletedNum = Convert.ToInt32(mes_Head.quantity) - Convert.ToInt32(mes_Head.finishNum); - if (mes_Head.quantity <= 50) tasktype = "TaskType_OutsourceInbound"; + //int CompeletedNum = Convert.ToInt32(mes_Head.quantity) - Convert.ToInt32(mes_Head.finishNum); + //if (mes_Head.quantity <= 50) tasktype = "TaskType_OutsourceInbound"; if (tasktype == "TaskType_OutsourceInbound") TargetLocation = StationTask.GetEmptyLocation(stationinfoRepository); else if (tasktype == "TaskType_Inbound") - TargetLocation = StationTask.GetEmptyLocation(stationinfoRepository, mes_Head, stationinfo, CompeletedNum, e); + TargetLocation = GetLocation.GetEmptyLocation(stationinfoRepository, Work, stationinfo); + //TargetLocation = GetLocation.GetEmptyLocation(stationinfoRepository, mes_Head, stationinfo); if (TargetLocation != null) { dt_agvtask agvtask = new dt_agvtask() @@ -911,8 +976,8 @@ agv_toaddress = TargetLocation.stationCode, agv_userid = "绯荤粺", bindSN = stationinfo.bindSN, - agv_worktype = Convert.ToInt32(mes_Head.processCode), - agv_materbarcode = mes_Head.materialCode, + agv_worktype = Convert.ToInt32(Work.processCode), + agv_materbarcode = Work.materialCode, agv_Traytype = stationinfo.tray_type, jobID = stationinfo.Number, agv_TrayStatus = stationinfo.tray_status @@ -922,6 +987,8 @@ stationinfoRepository.Update(stationinfo, true); TargetLocation.location_state = LocationStateEnum.InBusy.ToString(); TargetLocation.stationType = agvtask.agv_materielid; + TargetLocation.heatNumber = stationinfo.heatNumber; + TargetLocation.Number = agvtask.jobID; stationinfoRepository.Update(TargetLocation, true); } } -- Gitblit v1.9.3