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/Jobs/equipment/PipelineJob.cs | 66 +++++++++++++++++++++++---------- 1 files changed, 46 insertions(+), 20 deletions(-) diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/Jobs/equipment/PipelineJob.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/Jobs/equipment/PipelineJob.cs" index b452b93..64c0e42 100644 --- "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/Jobs/equipment/PipelineJob.cs" +++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/Jobs/equipment/PipelineJob.cs" @@ -79,11 +79,11 @@ ///鏌ユ壘涓婃枡鍖虹殑璐т綅 var Stations = stationinfoRepository.Find(x => x.area == area_code(number)); //缂撳瓨鏋舵湭鍚敤绂佹妗佹灦杩涘叆 - foreach (var station in Stations) - { - if (!station.enable || station.location_state != LocationStateEnum.Stroge.ToString()) - Gantry_client.WriteByOrder("W_RequestUnload", false, number);//淇″彿涓篺alse妗佹灦鍋滄杩涘叆 - } + //foreach (var station in Stations) + //{ + // if (!station.enable || station.location_state != LocationStateEnum.Stroge.ToString()) + // Gantry_client.WriteByOrder("W_RequestUnload", false, number);//淇″彿涓篺alse妗佹灦鍋滄杩涘叆 + //} var Station = Stations?.Where(x => x.enable && x.location_state == LocationStateEnum.Stroge.ToString() && x.quantity > 0).OrderBy(x => x.quantity).FirstOrDefault(); if (Station != null) @@ -140,10 +140,10 @@ var Date_Vaild = (bool)DBExtension.Read(Gantrydetails.Where(x => x.plcdetail_name == "R_Date_Vaild").First(), Gantry_client);//淇℃伅纭 if (!Date_Vaild)//淇℃伅鏈夎锛岃褰曟棩蹇� { + Gantry_client.WriteByOrder("W_RequestUnload", false, number);//淇″彿涓篺alse妗佹灦鍋滄杩涘叆 Station.location_state = LocationStateEnum.Abnormal.ToString(); Station.remark = $"鏈煡璇㈠埌SN鍙凤細{SNS[SNS.Length - 1]}鐨勮鍗�"; stationinfoRepository.Update(Station, true); - Gantry_client.WriteByOrder("W_RequestUnload", false, number);//淇″彿涓篺alse妗佹灦鍋滄杩涘叆 //throw new Exception($"鏈煡璇㈠埌SN鍙凤細{SNS[SNS.Length - 1]}鐨勮鍗曪紝涓婃枡浣嶇紪鍙凤細{Station.stationCode}"); WriteDBLog.Error("涓婃枡鍖轰俊鎭煡璇�", $"鍐欏叆妗佹灦淇℃伅锛歕nW_RequestUnload锛歠alse\n\n{Station.stationCode}鏈煡璇㈠埌SN鍙凤細{SNS[SNS.Length - 1]}鐨勮鍗�", "PCS"); return; @@ -178,16 +178,23 @@ #region 鏃ュ織璁板綍 WriteDBLog.Success("鍙栨枡瀹屾垚", $"鍐欏叆妗佹灦淇℃伅锛歕n璐т綅鐘舵�佹洿鏂帮細{true}\nW_RequestUnload锛歿false}", "PCS"); #endregion - //finished = (bool)DBExtension.Read(Gantrydetails.Where(x => x.plcdetail_name == "R_Unlod_finished").First(), Gantry_client); - //while (finished) - //{ - // finished = (bool)DBExtension.Read(Gantrydetails.Where(x => x.plcdetail_name == "R_Unlod_finished").First(), Gantry_client); - // Gantry_client.WriteByOrder("W_Storage_update", false, number);//璐т綅鐘舵�佹洿鏂� - //} + PalletSignal = (Int16)DBExtension.Read(details.Where(x => x.plcdetail_name == "R_PalletSignal").First(), client);//璇诲彇鎵樼洏淇″彿:1:鏈�,2鏃� + MaterialSignal = (Int16)DBExtension.Read(details.Where(x => x.plcdetail_name == "R_MaterialSignal").First(), client);//璇诲彇璐х墿淇″彿:1:鏈�,2鏃� + if (Station.quantity > 0 && (PalletSignal != 1 || MaterialSignal != 1)) + { + Station.location_state = LocationStateEnum.Abnormal.ToString(); + Station.remark = "杞﹁疆鏁伴噺澶т簬0锛屽厜鐢垫娴嬫棤鎵樼洏鎴栨棤杞﹁疆"; + stationinfoRepository.Update(Station, true); + client.WriteByOrder("W_AlarmSignal", (Int16)2, number);//鎶ヨ + } + else if (Station.quantity < 1 && MaterialSignal == 1) + { + Station.location_state = LocationStateEnum.Abnormal.ToString(); + Station.remark = "杞﹁疆鏁伴噺灏忎簬0锛屽厜鐢垫娴嬫湁杞﹁疆"; + stationinfoRepository.Update(Station, true); + client.WriteByOrder("W_AlarmSignal", (Int16)2, number);//鎶ヨ + } } - //else if (!finished && updatefinished) - // Gantry_client.WriteByOrder("W_Storage_update", false, number);//璐т綅鐘舵�佹洿鏂� - } else Gantry_client.WriteByOrder("W_RequestUnload", false, number);//淇″彿涓篺alse妗佹灦鍋滄杩涘叆 @@ -224,20 +231,37 @@ if (PalletSignal == 1 && MaterialSignal == 2 && (station.stationCode.Contains("S0100100") ? station.tray_status == "EmptyTray" : true)) { var area = station.tray_type == "SmallTray" ? "11" : "10"; - var task = agvtaskService.Find(x => (x.agv_toaddress.Contains("W") || x.agv_toaddress.Contains("X")) && x.agv_taskstate == "Queue" /*&& x.agv_tasktype == "TaskType_EmptyPallet" */ && x.agv_Traytype == station.tray_type).OrderBy(x => x.agv_createtime).FirstOrDefault(); + var task = agvtaskService.Find(x => (x.agv_toaddress.Contains("W") || x.agv_toaddress.Contains("X")) && x.agv_taskstate == "Queue" /*&& x.agv_tasktype == "TaskType_EmptyPallet" */ && x.agv_Traytype == station.tray_type).OrderByDescending(x => x.agv_grade).ThenBy(x => x.agv_createtime).FirstOrDefault(); if (task != null) { task.agv_fromaddress = station.stationCode; task.StarQuantity = 0; task.agv_taskstate = "Create"; + if (station.stationCode.Contains("S0100100")) + task.agv_grade = 3; agvtaskService.Update(task, true); station.location_state = LocationStateEnum.Busy.ToString(); stationinfoRepository.Update(station, true); continue; } + #region 鏌ユ壘搴撳尯涓�绌烘墭鐩樼┖璐т綅 var EmptyStation = stationinfoRepository.Find(x => x.area == area && x.quantity < 5 && x.stationCode.Contains("A") && x.location_state != LocationStateEnum.Busy.ToString() && x.enable) - .OrderByDescending(x => x.line).OrderBy(x => x.column).FirstOrDefault(); + .OrderBy(x => x.column).ThenByDescending(x => x.line).FirstOrDefault();//鏌ユ壘娌℃湁浠诲姟鐨勭┖鎵樼洏璐т綅 + + if (EmptyStation != null) + { + if (stationinfoRepository.Find(x => x.area == EmptyStation.area && x.stationCode.Contains("A") && x.column == EmptyStation.column && x.location_state.Contains("Busy")).Any()) + { + EmptyStation = stationinfoRepository.Find(x => x.area == area && x.quantity < 5 && x.stationCode.Contains("A") && x.column != EmptyStation.column && x.location_state != LocationStateEnum.Busy.ToString() && x.enable).OrderBy(x => x.column).ThenByDescending(x => x.line).FirstOrDefault();//鎺掗櫎褰撳垪瀛樺湪浠诲姟鐨勮揣浣� + } + if (EmptyStation != null && EmptyStation.line == 2)//濡傛灉浠诲姟瀛樺湪绗簩琛�,鎺掓煡绗竴琛屾槸鍚︽湁璐� + { + if (stationinfoRepository.Find(x => x.area == EmptyStation.area && x.stationCode.Contains("A") && x.column == EmptyStation.column && x.line == 1 && x.location_state != LocationStateEnum.Empty.ToString()).Any()) EmptyStation = null; + } + } + #endregion + if (EmptyStation == null) { EmptyStation = stationinfoRepository.Find(x => x.area == area && x.quantity < 5 && x.stationCode.Contains(area == "10" ? "D" : "C") && x.location_state == LocationStateEnum.Busy.ToString() && x.enable).OrderByDescending(x => x.column).FirstOrDefault();//鏈�鍚庝竴涓揣浣嶆湁浠诲姟鍒欎笉鑳界敓鎴愬叆搴撲换鍔� @@ -258,7 +282,7 @@ agv_fromaddress = station.stationCode, agv_id = Guid.NewGuid(), agv_tasknum = IdenxManager.GetTaskNo("KH-", "WMS"), - agv_grade = 1, + agv_grade = station.stationCode.Contains("S0100100") ? 3 : 1, agv_createtime = DateTime.Now, agv_taskstate = "Create", //agv_materielid = station.stationType, @@ -296,7 +320,7 @@ { try { - List<string> names = new List<string>() { "1鍗曞厓涓嬫枡鍖�", "2鍗曞厓涓嬫枡鍖�", "3鍗曞厓涓嬫枡鍖�", "涓婃枡鍖�" }; + List<string> names = new List<string>() { "1鍗曞厓涓嬫枡鍖�", "2鍗曞厓涓嬫枡鍖�", "3鍗曞厓涓嬫枡鍖�" };/*, "涓婃枡鍖�"*/ foreach (var name in names) { VOLContext Context = new VOLContext(); @@ -392,8 +416,10 @@ VOLContext Context = new VOLContext(); 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); //var mes_Detail = freeDB.Select<dt_mes_detail>().Where(x => x.SN == SN).First(); - var mes_Detail = mes_DetailRepository.Find(x => x.SN == SN).FirstOrDefault(); + var Mes_Work = workinfoRepository.Find(x => x.SN == SN && x.processCode == "28").FirstOrDefault(); + var mes_Detail = mes_DetailRepository.Find(x => x.SN == SN && x.jobID == Mes_Work.jobID).FirstOrDefault(); if (mes_Detail != null) { mes_Detail.Status = "涓婄嚎"; -- Gitblit v1.9.3