From 874ceff175a7308da045943fb7def1f6c6560a51 Mon Sep 17 00:00:00 2001 From: dengjunjie <dengjunjie@hnkhzn.com> Date: 星期二, 26 三月 2024 11:31:08 +0800 Subject: [PATCH] 优化NG任务触发逻辑 --- 代码管理/PCS/WCS_Server/WIDESEA_WCS/Common/Gantry.cs | 99 ++++++++++++++++++++++++++++++------------------- 1 files changed, 61 insertions(+), 38 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 d0c8b7a..f78df0c 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" @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Security.Cryptography.Xml; using System.Text; using System.Threading.Tasks; using System.Xml.Linq; @@ -407,7 +408,7 @@ 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); @@ -418,7 +419,7 @@ #endregion continue; } - var Head = mes_HeadRepository.FindFirst(x => x.jobID == Detail.jobID); + var Head = mes_HeadRepository.FindFirst(x => x.jobID == Detail.jobID && x.processCode == "17"); if (Head == null) { #region 鏃ュ織璁板綍 @@ -600,23 +601,34 @@ if (Stationinfo == null) { #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) + //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 瑙﹀彂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, stationinfo, (wheel == null ? wheel1.e : wheel.e), name == "3鍗曞厓涓嬫枡鍖�" ? "TaskType_OutsourceInbound" : "TaskType_Inbound"); + if (NG.stationType != mes_Head.drawingNo) + agvtask(stationinfoRepository, NG, (wheel == null ? wheel1.e : wheel.e), "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"); - // } - //} + 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 @@ -695,29 +707,31 @@ else if ((Int16)PartStatus == 2) { dt_stationinfo Stationinfo = null; - if (mes_Detail.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.tray_type == ((wheel == null ? wheel1.e : wheel.e) < 1100 ? "SmallTray" : "LargeTray") - && x.Number == mes_Detail.jobID - && x.heatNumber == mes_Detail.heatID).FirstOrDefault(); - } - else - { - Stationinfo = Stations - .Where(x => x.enable - && x.stationCode == NGStation - && x.location_state == LocationStateEnum.Stroge.ToString() - && x.quantity < 5 - && x.stationType == mes_Head.drawingNo - && x.tray_type == ((wheel == null ? wheel1.e : wheel.e) < 1100 ? "SmallTray" : "LargeTray") - && x.Number == mes_Detail.jobID).FirstOrDefault(); - } + //if (mes_Detail.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.tray_type == ((wheel == null ? wheel1.e : wheel.e) < 1100 ? "SmallTray" : "LargeTray") + //&& x.Number == mes_Detail.jobID + //&& x.heatNumber == mes_Detail.heatID).FirstOrDefault(); + //} + //else + //{ + //var tray_type = "SmallTray"; + //if ((wheel == null ? wheel1.e : wheel.e) > 1100) tray_type = "LargeTray"; + Stationinfo = Stations + .Where(x => x.enable + && x.stationCode == NGStation + && x.location_state == LocationStateEnum.Stroge.ToString() + && x.quantity < 5 + && x.stationType == mes_Head.drawingNo + && x.tray_type == ((wheel == null ? wheel1.e : wheel.e) < 1100 ? "SmallTray" : "LargeTray") + /*&& x.Number == mes_Detail.jobID*/).FirstOrDefault(); + //} if (Stationinfo == null) { @@ -864,10 +878,19 @@ var task = agvtaskRepository.Find(x => x.agv_fromaddress == stationinfo.stationCode).FirstOrDefault(); if (task != null) return; - var mes_Head = mes_HeadRepository.FindFirst(x => x.jobID == stationinfo.Number); + 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; + } dt_stationinfo TargetLocation = null; 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") @@ -895,7 +918,7 @@ agv_TrayStatus = stationinfo.tray_status }; agvtaskRepository.Add(agvtask, true); - stationinfo.location_state = LocationStateEnum.Busy.ToString(); + stationinfo.location_state = LocationStateEnum.InBusy.ToString(); stationinfoRepository.Update(stationinfo, true); TargetLocation.location_state = LocationStateEnum.InBusy.ToString(); TargetLocation.stationType = agvtask.agv_materielid; -- Gitblit v1.9.3