分支自 SuZhouGuanHong/TaiYuanTaiZhong

dengjunjie
2024-04-27 0b5ccdca6263cf7a2cee460f30c76ef1efea2811
´úÂë¹ÜÀí/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;
@@ -78,12 +79,6 @@
                ///查找上料区的货位
                var Stations = stationinfoRepository.Find(x => x.area == area_code(number)).OrderBy(x => x.lastUpdateTime);//根据时间先后排序
                //缓存架未启用禁止桁架进入
                //foreach (var station in Stations)
                //{
                //    if (!station.enable || station.location_state != LocationStateEnum.Stroge.ToString())
                //        Gantry_client.WriteByOrder("W_RequestUnload", false, number);//信号为false桁架停止进入
                //}
                var Station = Stations?.Where(x => x.enable && x.location_state == LocationStateEnum.Stroge.ToString() && x.quantity > 0).OrderBy(x => x.quantity).FirstOrDefault();
                if (Station != null)
@@ -106,7 +101,6 @@
                        WriteDBLog.Error("上料区", $"写入桁架信息:\nW_RequestUnload:false\n\n{Station.stationCode}车轮数量与SN号数量不一致", "PCS");
                        #endregion
                        return;
                        //throw new Exception("上料位车轮数量与SN号数量不一致,上料位编号:" + Station.stationCode);
                    }
                    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无
@@ -117,11 +111,11 @@
                    {
                        if (AreaNr == 0)
                        {
                            Gantry_client.WriteByOrder("W_Wheel_Type", (Int16)Convert.ToInt16(QueryMateriel(Station.stationType) == null ? QueryMateriel1(Station.stationType).TypeId : QueryMateriel(Station.stationType).TypeId), number);//车轮类型
                            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 æ—¥å¿—记录
@@ -149,7 +143,6 @@
                            Station.location_state = LocationStateEnum.Abnormal.ToString();
                            Station.remark = $"未查询到SN号:{SNS[SNS.Length - 1]}的订单";
                            stationinfoRepository.Update(Station, true);
                            //throw new Exception($"未查询到SN号:{SNS[SNS.Length - 1]}的订单,上料位编号:{Station.stationCode}");
                            WriteDBLog.Error("上料区信息查询", $"写入桁架信息:\nW_RequestUnload:false\n\n{Station.stationCode}未查询到SN号:{SNS[SNS.Length - 1]}的订单", "PCS");
                            return;
                        }
@@ -167,7 +160,6 @@
                        if (Station.quantity <= 0)
                        {
                            Station.stationType = string.Empty;
                            //Station.location_state = LocationStateEnum.Empty.ToString();
                            Station.Number = string.Empty;
                            Station.heatNumber = string.Empty;
                            Station.tray_status = "EmptyTray";
@@ -176,7 +168,6 @@
                        if (count < 1)
                        {
                            WriteDBLog.Error("取料完成", $"上料位信息更新失败!上料位编号:{Station.stationCode}", "PCS");
                            //throw new Exception($"上料位信息更新失败!上料位编号:{Station.stationCode}");
                            return;
                        }
@@ -185,7 +176,6 @@
                        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);//货位状态更新
@@ -219,7 +209,6 @@
            catch (Exception ex)
            {
                WriteDBLog.Error("上料区", $"错误信息:{ex.Message}", "PCS");
                //WritePCSLog.LogAdd(requestin.AreaNr.ToString(), respone.success == 1 ? "成功 " : "失败", "WMS", "AGV", json, JsonConvert.SerializeObject(respone), remark, "检测线上料区", ex.Message);
            }
        }
        /// <summary>
@@ -239,12 +228,13 @@
                List<string> stationCodes = new List<string>() { "S01001001", "S01001002", "W01001001", "W01001002", "W01001003" };
                foreach (var stationCode in stationCodes)
                {
                    if (agvtaskService.Find(x => x.agv_fromaddress == stationCode || x.agv_toaddress == stationCode).Any())
                    if (agvtaskService.Find(x => x.agv_fromaddress == stationCode /*|| x.agv_toaddress == stationCode*/).Any())
                        continue;
                    var station = stationinfoRepository.Find(x => x.stationCode == stationCode && x.enable).FirstOrDefault();
                    if (station == null) continue;
                    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();
                    if (PalletSignal == 1 && MaterialSignal == 2 && (station.stationCode.Contains("S0100100") ? station.tray_status == "EmptyTray" : true))
                    {
                        var area = station.tray_type == "SmallTray" ? "11" : "10";
@@ -262,31 +252,17 @@
                            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)
                        .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;
                            }
                        }
                        #region ç©ºæ‰˜å ç›˜
                        var EmptyStations = stationinfoRepository.Find(x => x.stationCode.Contains("DD") && x.quantity < 5 && x.enable).ToList();
                        var EmptyStation = EmptyStations.Where(x => x.tray_type == station.tray_type && x.location_state == LocationStateEnum.Stroge.ToString()).FirstOrDefault();
                        if (EmptyStation == null)
                            EmptyStation = EmptyStations.Where(x => x.location_state == LocationStateEnum.Empty.ToString()).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)//查找库内空托盘
                            EmptyStation = GetStation.EmptyPalletStation(area);
                        if (EmptyStation != null)
                        {
@@ -359,7 +335,7 @@
                        if (Station.location_state == LocationStateEnum.Stroge.ToString() && PalletSignal != 1)
                        {
                            Station.location_state = LocationStateEnum.Abnormal.ToString();
                            Station.remark = "货位有货,光电检测无托盘";
                            Station.remark = "光电检测无托盘";
                            stationinfoRepository.Update(Station, true);
                            client.WriteByOrder("W_AlarmSignal", (Int16)2, name);//报警
                            WriteDBLog.Error(name + "报警", $"货位编号:{Station.stationCode};错误信息:{Station.remark}", "PCS");
@@ -368,7 +344,7 @@
                        if (Station.location_state == LocationStateEnum.Empty.ToString() && (PalletSignal == 1 || MaterialSignal == 1))//系统货位为空,光电检测有料
                        {
                            Station.location_state = LocationStateEnum.Abnormal.ToString();
                            Station.remark = "货位无货,光电检测有料";
                            Station.remark = "光电检测有料";
                            stationinfoRepository.Update(Station, true);
                            client.WriteByOrder("W_AlarmSignal", (Int16)2, name);//报警
                            WriteDBLog.Error(name + "报警", $"货位编号:{Station.stationCode};错误信息:{Station.remark}", "PCS");