From d2cef0150abe6d14cbfa60c8845795b91a1f5f97 Mon Sep 17 00:00:00 2001 From: dengjunjie <dengjunjie@hnkhzn.com> Date: 星期六, 20 四月 2024 19:50:53 +0800 Subject: [PATCH] 添加入库触发条件,修改上料区任务逻辑 --- 代码管理/PCS/WCS_Server/WIDESEA_WCS/Common/Gantry.cs | 112 +++++++++++++++++++++++++++++++++++++++++++------------- 1 files changed, 86 insertions(+), 26 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 9cc2340..65f8cb7 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" @@ -384,6 +384,9 @@ { var details = plcRepository.Find(x => x.plcdetail_iotype == plc.plcinfo_iotyep && x.plcdetail_number == name).ToList(); + var NGStation = "X01001003"; + if (name == "2鍗曞厓涓嬫枡鍖�") NGStation = "X02001003"; + if (name == "3鍗曞厓涓嬫枡鍖�") NGStation = "X03001002"; #region MyRegion //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鍙� @@ -467,7 +470,11 @@ var AreaNr = (Int16)DBExtension.Read(details.Where(x => x.plcdetail_name == "W_AreaNr").First(), client); if (AreaNr == 0) + { client.WriteByOrder("W_Storage_update", true, name);//璐т綅鐘舵�佹洿鏂� + continue; + } + var areaCode = PipelineJob.area_code(name); //鏍规嵁涓嬫枡鍙e崟鍏冨悕鑾峰彇鍖哄煙浠g爜 var station = stationinfoRepository.FindFirst(x => x.area == areaCode && x.stationCode.Substring(x.stationCode.Length - 1, 1) == AreaNr.ToString()); @@ -481,6 +488,7 @@ } 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) { @@ -489,6 +497,10 @@ station.heatNumber = Mes_Work.heatID; station.tray_status = "StrogeTray"; } + //else if (station.stationCode == NGStation) + //{ + // station.heatNumber = string.IsNullOrEmpty(station.heatNumber) ? Mes_Work.heatID : station.heatNumber + "," + Mes_Work.heatID; + //} var count = stationinfoRepository.Update(station, true); if (count < 1) @@ -543,7 +555,9 @@ 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); + //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);//杞﹁疆绫诲瀷 var Wheel_id = client.ReadByOrder<string>("R_Wheel_id", name);//杞﹁疆SN鍙� @@ -580,11 +594,9 @@ #endregion - var Stations = stationinfoRepository.Find(x => x.area == PipelineJob.area_code(name)); + var Stations = stationinfoRepository.Find(x => x.area == PipelineJob.area_code(name)).OrderBy(x => x.lastUpdateTime).ToList(); - var NGStation = "X01001003"; - if (name == "2鍗曞厓涓嬫枡鍖�") NGStation = "X02001003"; - if (name == "3鍗曞厓涓嬫枡鍖�") NGStation = "X03001002"; + //foreach (var station in Stations) //浠讳綍涓�涓笅鏂欎綅涓虹┖鎴栫鐢ㄦ椂,閮戒細鍋滄妗佹灦 //{ @@ -613,6 +625,8 @@ } var PartStatus = DBExtension.Read(details.Where(x => x.plcdetail_name == "R_PartStatus").First(), client);//1:ok;2:nok + + var load_zone = (bool)DBExtension.Read(details.Where(x => x.plcdetail_name == "R_load_zone").First(), client); #region 鏃ュ織璁板綍 WriteDBLog.Success(name + "鐢宠鏀炬枡", $"璇诲彇妗佹灦淇℃伅锛歕n杞﹁疆SN锛歿Wheel_id}\n杞瀷ID锛歿Wheel_Type}\n杞﹁疆鐘舵�侊細{PartStatus}\n鏄惁杩涘叆涓嬫枡鍖猴細{load_zone}", "PCS"); if (load_zone) continue; @@ -628,7 +642,7 @@ && x.location_state == LocationStateEnum.Stroge.ToString() && x.quantity < 5 && x.stationType == Work.drawingNo - && x.tray_type == ((wheel == null ? wheel1.e : wheel.e) < 1100 ? "SmallTray" : "LargeTray") + //&& x.tray_type == ((wheel == null ? wheel1.e : wheel.e) < 1100 ? "SmallTray" : "LargeTray") && x.Number == Work.workOrder && x.heatNumber == Work.heatID) .OrderByDescending(x => x.quantity) @@ -642,7 +656,7 @@ && x.location_state == LocationStateEnum.Stroge.ToString() && x.quantity < 5 && x.stationType == Work.drawingNo - && x.tray_type == ((wheel == null ? wheel1.e : wheel.e) < 1100 ? "SmallTray" : "LargeTray") + //&& x.tray_type == ((wheel == null ? wheel1.e : wheel.e) < 1100 ? "SmallTray" : "LargeTray") && x.Number == Work.workOrder) .OrderByDescending(x => x.quantity) .FirstOrDefault(); @@ -681,8 +695,26 @@ if (Stationinfo != null) { + + #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"); + #endregion + + #region 鎵樼洏杞﹁疆鍫嗗灈绗洓涓椂涓嬪彂鍙﹀涓�涓倝鍙风殑鍏ュ簱浠诲姟 + if (Stationinfo.quantity + 1 >= 4) + { + var stationinfo = Stations.Where(x => x.enable && x.stationCode != NGStation && x.stationCode != Stationinfo.stationCode && x.location_state == LocationStateEnum.Stroge.ToString() && x.quantity > 0).FirstOrDefault(); + if (stationinfo != null) + agvtask(stationinfoRepository, stationinfo, Work, name == "3鍗曞厓涓嬫枡鍖�" ? "TaskType_OutsourceInbound" : "TaskType_Inbound"); + } + + #endregion + #region 鎵樼洏绫诲瀷涓嶄竴鑷撮渶鏇存崲鎵樼洏 - if (Stationinfo.tray_type != ((wheel == null ? wheel1.e : wheel.e) < 1100 ? "SmallTray" : "LargeTray")) + //if (Stationinfo.tray_type != ((wheel == null ? wheel1.e : wheel.e) < 1100 ? "SmallTray" : "LargeTray")) + if (Stationinfo.tray_type != "LargeTray" && (wheel == null ? wheel1.e : wheel.e) > 1100) { client.WriteByOrder("W_Enabl_Load", false, name);//淇″彿涓篺alse妗佹灦鍋滄杩涘叆 Stationinfo.location_state = LocationStateEnum.Abnormal.ToString(); @@ -720,6 +752,7 @@ Stationinfo.location_state = LocationStateEnum.Abnormal.ToString(); Stationinfo.remark = "杞﹁疆鏁伴噺涓庡厜鐢典笉鍖归厤"; stationinfoRepository.Update(Stationinfo, true); + WriteDBLog.Error(name + "鎶ヨ", $"璐т綅缂栧彿锛歿Stationinfo.stationCode}锛涢敊璇俊鎭細{Stationinfo.remark}", "PCS"); //WriteDBLog.Error(name+"鐢宠涓嬫枡",$"{Stationinfo.stationCode}鐨勮揣浣�","PCS"); } else if (list.Count < 1 && MaterialSignal == 1) @@ -729,6 +762,7 @@ Stationinfo.location_state = LocationStateEnum.Abnormal.ToString(); Stationinfo.remark = "杞﹁疆鏁伴噺涓庡厜鐢典笉鍖归厤"; stationinfoRepository.Update(Stationinfo, true); + WriteDBLog.Error(name + "鎶ヨ", $"璐т綅缂栧彿锛歿Stationinfo.stationCode}锛涢敊璇俊鎭細{Stationinfo.remark}", "PCS"); } #endregion @@ -756,16 +790,16 @@ 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 + //{ + // #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) @@ -793,23 +827,29 @@ && x.location_state == LocationStateEnum.Stroge.ToString() && x.quantity < 5 && x.stationType == Work.drawingNo - && x.tray_type == ((wheel == null ? wheel1.e : wheel.e) < 1100 ? "SmallTray" : "LargeTray") + //&& 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"); - //} + #region 瑙﹀彂NG浠诲姟 + var NG = Stations.Where(x => x.enable && x.stationCode == NGStation && x.location_state == LocationStateEnum.Stroge.ToString() && x.quantity > 0).FirstOrDefault(); + if (NG != null) + { + agvtask(stationinfoRepository, NG, Work, "TaskType_OutsourceInbound"); + continue; + } + + #endregion + Stationinfo = Stations.Where(x => x.enable && x.stationCode == NGStation && x.location_state == LocationStateEnum.Stroge.ToString() && x.quantity == 0).FirstOrDefault(); } if (Stationinfo != null) { #region 鎵樼洏绫诲瀷涓嶄竴鑷撮渶鏇存崲鎵樼洏 - if (Stationinfo.tray_type != ((wheel == null ? wheel1.e : wheel.e) < 1100 ? "SmallTray" : "LargeTray")) + //if (Stationinfo.tray_type != ((wheel == null ? wheel1.e : wheel.e) < 1100 ? "SmallTray" : "LargeTray")) + if (Stationinfo.tray_type != "LargeTray" && (wheel == null ? wheel1.e : wheel.e) > 1100) { Stationinfo.location_state = LocationStateEnum.Abnormal.ToString(); Stationinfo.tray_type = Stationinfo.tray_type == "SmallTray" ? "SmallTray/LargeTray" : "LargeTray/SmallTray"; @@ -834,10 +874,30 @@ } #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);//鎶ヨ + if (list.Count > 0 && 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); + WriteDBLog.Error(name + "鎶ヨ", $"璐т綅缂栧彿锛歿Stationinfo.stationCode}锛涢敊璇俊鎭細{Stationinfo.remark}", "PCS"); + //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); + WriteDBLog.Error(name + "鎶ヨ", $"璐т綅缂栧彿锛歿Stationinfo.stationCode}锛涢敊璇俊鎭細{Stationinfo.remark}", "PCS"); + } #endregion //缂撳瓨鏋朵笂杞﹁疆鏁伴噺涓嶴N鍙锋暟閲忎笉涓�鑷� @@ -955,7 +1015,7 @@ //int CompeletedNum = Convert.ToInt32(mes_Head.quantity) - Convert.ToInt32(mes_Head.finishNum); //if (mes_Head.quantity <= 50) tasktype = "TaskType_OutsourceInbound"; - if (tasktype == "TaskType_OutsourceInbound") + if (tasktype == "TaskType_OutsourceInbound" || !string.IsNullOrEmpty(Work.area)) TargetLocation = StationTask.GetEmptyLocation(stationinfoRepository); else if (tasktype == "TaskType_Inbound") TargetLocation = GetLocation.GetEmptyLocation(stationinfoRepository, Work, stationinfo); -- Gitblit v1.9.3