分支自 SuZhouGuanHong/TaiYuanTaiZhong

dengjunjie
2024-03-26 874ceff175a7308da045943fb7def1f6c6560a51
´úÂë¹ÜÀí/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;
@@ -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)
                                {
                                    agvtask(stationinfoRepository, stationinfo, (wheel == null ? wheel1.e : wheel.e), name == "3单元下料区" ? "TaskType_OutsourceInbound" : "TaskType_Inbound");
                                }
                                #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 è§¦å‘NG任务
                                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");
                                }
                                #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
@@ -695,8 +707,22 @@
                        else if ((Int16)PartStatus == 2)
                        {
                            dt_stationinfo Stationinfo = null;
                            if (mes_Detail.heatID != 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
                            //{
                            //var tray_type = "SmallTray";
                            //if ((wheel == null ? wheel1.e : wheel.e) > 1100) tray_type = "LargeTray";
                                Stationinfo = Stations
                            .Where(x => x.enable
                            && x.stationCode == NGStation
@@ -704,20 +730,8 @@
                            && 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();
                            }
                        /*&& 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;