From f0e2d9d2c7c41b311217bdb2c4d114ff53f6a146 Mon Sep 17 00:00:00 2001 From: dengjunjie <dengjunjie@hnkhzn.com> Date: 星期二, 16 四月 2024 07:47:17 +0800 Subject: [PATCH] 优化空托逻辑 --- 代码管理/PCS/WCS_Server/WIDESEA_WCS/Jobs/equipment/PipelineJob.cs | 97 ++++++++++++++++++++++++++++++------------------ 1 files changed, 61 insertions(+), 36 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 64c0e42..a7325f0 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" @@ -18,6 +18,7 @@ using WIDESEA_Entity.DomainModels; using WIDESEA_WCS.IRepositories; using WIDESEA_WCS.Jobs; +using WIDESEA_WCS.JobsPart.Common; using WIDESEA_WCS.Repositories; using WIDESEA_WCS.WCSClient; using WIDESEA_WMS.IRepositories; @@ -77,7 +78,7 @@ ///鏌ユ壘涓婃枡鍖虹殑璐т綅 - var Stations = stationinfoRepository.Find(x => x.area == area_code(number)); + var Stations = stationinfoRepository.Find(x => x.area == area_code(number)).OrderBy(x => x.lastUpdateTime);//鏍规嵁鏃堕棿鍏堝悗鎺掑簭 //缂撳瓨鏋舵湭鍚敤绂佹妗佹灦杩涘叆 //foreach (var station in Stations) //{ @@ -111,20 +112,25 @@ var details = plcRepository.Find(x => x.plcdetail_iotype == plc.plcinfo_iotyep && x.plcdetail_number == Station.stationCode).ToList(); var PalletSignal = (Int16)DBExtension.Read(details.Where(x => x.plcdetail_name == "R_PalletSignal").First(), client);//璇诲彇鎵樼洏淇″彿:1:鏈�,2鏃� var MaterialSignal = (Int16)DBExtension.Read(details.Where(x => x.plcdetail_name == "R_MaterialSignal").First(), client);//璇诲彇璐х墿淇″彿:1:鏈�,2鏃� + + var AreaNr = Gantry_client.ReadByOrder<Int16>("W_AreaNr", number);//璇诲彇璐т綅鍙蜂俊鎭� if (PalletSignal == 1 && MaterialSignal == 1) { - var area = Convert.ToInt16(Station.stationCode.Substring(Station.stationCode.Length - 1, 1)); - Gantry_client.WriteByOrder("W_AreaNr", (Int16)area, number);//鍖哄煙璐т綅鍙� - Gantry_client.WriteByOrder("W_IndexNr", (Int16)SNS.Length, number);//鎵樼洏涓婄殑绗嚑涓溅杞� - Gantry_client.WriteByOrder("W_Storage_Type", (Int16)1, number); //鎵樼洏绫诲瀷1-妯斁;2-绔栨斁 - Gantry_client.WriteByOrder("W_Wheel_Type", (Int16)Convert.ToInt16(QueryMateriel(Station.stationType) == null ? QueryMateriel1(Station.stationType).TypeId : QueryMateriel(Station.stationType).TypeId), number);//杞﹁疆绫诲瀷 - Gantry_client.WriteByOrder("W_Wheel_id", SNS[SNS.Length - 1], number);//杞﹁疆SN鍙� - Gantry_client.WriteByOrder("W_RequestUnload", true, number); - #region 鏃ュ織璁板綍 - WriteDBLog.Success("涓婃枡鍖虹敵璇�", $"璇诲彇鎵樼洏鍏夌數淇″彿锛歿PalletSignal}\n璇诲彇绗竴涓溅杞厜鐢典俊鍙凤細{MaterialSignal}\n\n" + - $"鍐欏叆妗佹灦淇℃伅锛歕n鍖哄煙璐т綅鍙凤細{area}\n鎵樼洏涓婄殑绗嚑涓溅杞細{SNS.Length}\n鎵樼洏绫诲瀷锛歿1}\n杞﹁疆绫诲瀷锛歿(QueryMateriel(Station.stationType).TypeId == null ? QueryMateriel1(Station.stationType).TypeId : QueryMateriel(Station.stationType).TypeId)}" + - $"\n杞﹁疆SN鍙凤細{SNS[SNS.Length - 1]}\nW_RequestUnload锛歵rue", "PCS"); - #endregion + if (AreaNr == 0) + { + var area = Convert.ToInt16(Station.stationCode.Substring(Station.stationCode.Length - 1, 1)); + Gantry_client.WriteByOrder("W_AreaNr", (Int16)area, number);//鍖哄煙璐т綅鍙� + Gantry_client.WriteByOrder("W_IndexNr", (Int16)SNS.Length, number);//鎵樼洏涓婄殑绗嚑涓溅杞� + Gantry_client.WriteByOrder("W_Storage_Type", (Int16)1, number); //鎵樼洏绫诲瀷1-妯斁;2-绔栨斁 + Gantry_client.WriteByOrder("W_Wheel_Type", (Int16)Convert.ToInt16(QueryMateriel(Station.stationType) == null ? QueryMateriel1(Station.stationType).TypeId : QueryMateriel(Station.stationType).TypeId), number);//杞﹁疆绫诲瀷 + Gantry_client.WriteByOrder("W_Wheel_id", SNS[SNS.Length - 1], number);//杞﹁疆SN鍙� + Gantry_client.WriteByOrder("W_RequestUnload", true, number); + #region 鏃ュ織璁板綍 + WriteDBLog.Success("涓婃枡鍖虹敵璇�", $"璇诲彇鎵樼洏鍏夌數淇″彿锛歿PalletSignal}\n璇诲彇绗竴涓溅杞厜鐢典俊鍙凤細{MaterialSignal}\n\n" + + $"鍐欏叆妗佹灦淇℃伅锛歕n鍖哄煙璐т綅鍙凤細{area}\n鎵樼洏涓婄殑绗嚑涓溅杞細{SNS.Length}\n鎵樼洏绫诲瀷锛歿1}\n杞﹁疆绫诲瀷锛歿(QueryMateriel(Station.stationType).TypeId == null ? QueryMateriel1(Station.stationType).TypeId : QueryMateriel(Station.stationType).TypeId)}" + + $"\n杞﹁疆SN鍙凤細{SNS[SNS.Length - 1]}\nW_RequestUnload锛歵rue", "PCS"); + #endregion + } } else { @@ -174,10 +180,20 @@ //throw new Exception($"涓婃枡浣嶄俊鎭洿鏂板け璐ワ紒涓婃枡浣嶇紪鍙凤細{Station.stationCode}"); return; } + + #region 娓呯┖淇℃伅 + Gantry_client.WriteByOrder("W_AreaNr", (Int16)0, number);//鍖哄煙璐т綅鍙� + Gantry_client.WriteByOrder("W_IndexNr", (Int16)0, number);//鎵樼洏涓婄殑绗嚑涓溅杞� + Gantry_client.WriteByOrder("W_Storage_Type", (Int16)0, number); //鎵樼洏绫诲瀷1-妯斁;2-绔栨斁 + Gantry_client.WriteByOrder("W_Wheel_Type", (Int16)0, number);//杞﹁疆绫诲瀷 + //Gantry_client.WriteByOrder("W_Wheel_id", SNS[SNS.Length - 1], number);//杞﹁疆SN鍙� + #endregion + Gantry_client.WriteByOrder("W_Storage_update", true, number);//璐т綅鐘舵�佹洿鏂� #region 鏃ュ織璁板綍 WriteDBLog.Success("鍙栨枡瀹屾垚", $"鍐欏叆妗佹灦淇℃伅锛歕n璐т綅鐘舵�佹洿鏂帮細{true}\nW_RequestUnload锛歿false}", "PCS"); #endregion + 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)) @@ -186,6 +202,7 @@ Station.remark = "杞﹁疆鏁伴噺澶т簬0锛屽厜鐢垫娴嬫棤鎵樼洏鎴栨棤杞﹁疆"; stationinfoRepository.Update(Station, true); client.WriteByOrder("W_AlarmSignal", (Int16)2, number);//鎶ヨ + WriteDBLog.Error(number + "鎶ヨ", $"璐т綅缂栧彿锛歿Station.stationCode}锛涢敊璇俊鎭細{Station.remark}", "PCS"); } else if (Station.quantity < 1 && MaterialSignal == 1) { @@ -193,6 +210,7 @@ Station.remark = "杞﹁疆鏁伴噺灏忎簬0锛屽厜鐢垫娴嬫湁杞﹁疆"; stationinfoRepository.Update(Station, true); client.WriteByOrder("W_AlarmSignal", (Int16)2, number);//鎶ヨ + WriteDBLog.Error(number + "鎶ヨ", $"璐т綅缂栧彿锛歿Station.stationCode}锛涢敊璇俊鎭細{Station.remark}", "PCS"); } } } @@ -227,7 +245,8 @@ var details = plcRepository.Find(x => x.plcdetail_iotype == plc.plcinfo_iotyep && x.plcdetail_number == stationCode).ToList(); var PalletSignal = (Int16)DBExtension.Read(details.Where(x => x.plcdetail_name == "R_PalletSignal").First(), client);//璇诲彇鎵樼洏淇″彿:1:鏈�,2鏃� var MaterialSignal = (Int16)DBExtension.Read(details.Where(x => x.plcdetail_name == "R_MaterialSignal").First(), client);//璇诲彇璐х墿淇″彿:1:鏈�,2鏃� - var station = stationinfoRepository.Find(x => x.stationCode == stationCode).FirstOrDefault(); + var station = stationinfoRepository.Find(x => x.stationCode == stationCode && x.enable).FirstOrDefault(); + if (station == null) continue; if (PalletSignal == 1 && MaterialSignal == 2 && (station.stationCode.Contains("S0100100") ? station.tray_status == "EmptyTray" : true)) { var area = station.tray_type == "SmallTray" ? "11" : "10"; @@ -245,31 +264,34 @@ continue; } + var EmptyStation = GetStation.EmptyPalletStation(area); + #region 鏌ユ壘搴撳尯涓�绌烘墭鐩樼┖璐т綅 - var EmptyStation = stationinfoRepository.Find(x => x.area == area && x.quantity < 5 && x.stationCode.Contains("A") && x.location_state != LocationStateEnum.Busy.ToString() && x.enable) - .OrderBy(x => x.column).ThenByDescending(x => x.line).FirstOrDefault();//鏌ユ壘娌℃湁浠诲姟鐨勭┖鎵樼洏璐т綅 + // EmptyStation = stationinfoRepository.Find(x => x.area == area && x.quantity < 5 && x.stationCode.Contains("A") && x.location_state != LocationStateEnum.Busy.ToString() && x.enable) + //.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; - } - } + // 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; + // } + // } + + // 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();//鏈�鍚庝竴涓揣浣嶆湁浠诲姟鍒欎笉鑳界敓鎴愬叆搴撲换鍔� + // if (EmptyStation != null) continue; + // EmptyStation = stationinfoRepository.Find(x => x.area == area && x.quantity < 5 && x.stationCode.Contains(area == "10" ? "D" : "C") && x.location_state == LocationStateEnum.Stroge.ToString() && x.enable).OrderByDescending(x => x.column).FirstOrDefault();//鎵炬渶澶栭潰娌″爢婊�5涓殑璐т綅 + // if (EmptyStation == null) + // EmptyStation = stationinfoRepository.Find(x => x.area == area && x.quantity < 5 && x.stationCode.Contains(area == "10" ? "D" : "C") && x.location_state == LocationStateEnum.Empty.ToString() && x.enable).OrderBy(x => x.column).FirstOrDefault(); + // } + #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();//鏈�鍚庝竴涓揣浣嶆湁浠诲姟鍒欎笉鑳界敓鎴愬叆搴撲换鍔� - if (EmptyStation != null) continue; - EmptyStation = stationinfoRepository.Find(x => x.area == area && x.quantity < 5 && x.stationCode.Contains(area == "10" ? "D" : "C") && x.location_state == LocationStateEnum.Stroge.ToString() && x.enable).OrderByDescending(x => x.column).FirstOrDefault();//鎵炬渶澶栭潰娌″爢婊�5涓殑璐т綅 - if (EmptyStation == null) - EmptyStation = stationinfoRepository.Find(x => x.area == area && x.quantity < 5 && x.stationCode.Contains(area == "10" ? "D" : "C") && x.location_state == LocationStateEnum.Empty.ToString() && x.enable).OrderBy(x => x.column).FirstOrDefault(); - } if (EmptyStation != null) { @@ -336,6 +358,7 @@ Station.remark = "杞﹁疆鏁伴噺澶т簬0锛屽厜鐢垫娴嬫棤鎵樼洏鎴栨棤杞﹁疆"; stationinfoRepository.Update(Station, true); client.WriteByOrder("W_AlarmSignal", (Int16)2, name);//鎶ヨ + WriteDBLog.Error(name + "鎶ヨ", $"璐т綅缂栧彿锛歿Station.stationCode}锛涢敊璇俊鎭細{Station.remark}", "PCS"); continue; } if (Station.location_state == LocationStateEnum.Stroge.ToString() && PalletSignal != 1) @@ -344,6 +367,7 @@ Station.remark = "璐т綅鏈夎揣锛屽厜鐢垫娴嬫棤鎵樼洏"; stationinfoRepository.Update(Station, true); client.WriteByOrder("W_AlarmSignal", (Int16)2, name);//鎶ヨ + WriteDBLog.Error(name + "鎶ヨ", $"璐т綅缂栧彿锛歿Station.stationCode}锛涢敊璇俊鎭細{Station.remark}", "PCS"); continue; } if (Station.location_state == LocationStateEnum.Empty.ToString() && (PalletSignal == 1 || MaterialSignal == 1))//绯荤粺璐т綅涓虹┖锛屽厜鐢垫娴嬫湁鏂� @@ -352,6 +376,7 @@ Station.remark = "璐т綅鏃犺揣锛屽厜鐢垫娴嬫湁鏂�"; stationinfoRepository.Update(Station, true); client.WriteByOrder("W_AlarmSignal", (Int16)2, name);//鎶ヨ + WriteDBLog.Error(name + "鎶ヨ", $"璐т綅缂栧彿锛歿Station.stationCode}锛涢敊璇俊鎭細{Station.remark}", "PCS"); continue; } //if (Station.quantity < 1 && MaterialSignal == 1)//绯荤粺璐т綅鏃犺溅杞紝鍏夌數妫�娴嬫湁杞﹁疆 -- Gitblit v1.9.3