分支自 SuZhouGuanHong/TaiYuanTaiZhong

dengjunjie
2024-05-21 2d3d006620bb15a2350c516f050058e5f84c7bf8
´úÂë¹ÜÀí/PCS/WCS_Server/WIDESEA_WCS/Common/Gantry.cs
@@ -12,6 +12,7 @@
using WIDESEA_Comm.LogInfo;
using WIDESEA_Comm.TaskNo;
using WIDESEA_Core.EFDbContext;
using WIDESEA_Core.Extensions;
using WIDESEA_Core.FreeDB;
using WIDESEA_Entity.DomainModels;
using WIDESEA_WCS.IRepositories;
@@ -34,6 +35,7 @@
        /// <param name="client"></param>
        public void QueryWheeldata(PLCClient client)
        {
            string namea = "";
            try
            {
                VOLContext Context = new VOLContext();
@@ -48,6 +50,7 @@
                List<string> names = new List<string>() { "1单元辊道下料查询车轮", "2单元辊道下料查询车轮", "3单元辊道下料查询车轮", "辊道上料查询车轮" };
                foreach (string name in names)
                {
                    namea = name;
                    var details = plcRepository.Find(x => x.plcdetail_iotype == plc.plcinfo_iotyep && x.plcdetail_number == name).ToList();
                    var on = DBExtension.Read(details.Where(x => x.plcdetail_name == "R_oi_on").First(), client);
                    if ((byte)on == 1)
@@ -66,7 +69,8 @@
                            client.WriteByOrder("W_i_status", (byte)2, name);
                            client.WriteByOrder("R_oi_on", (byte)0, name);
                            #region æ—¥å¿—记录
                            WriteDBLog.Error(name, $"读取桁架信息:\n车轮SN:{wp_id}\n\n写入桁架信息:\nW_i_status:2\nR_oi_on:0\n\n未查询到工单信息", "PCS");
                            //WriteDBLog.Error(name, $"读取桁架信息:\n车轮SN:{wp_id}\n\n写入桁架信息:\nW_i_status:2\nR_oi_on:0\n\n未查询到工单信息", "PCS");
                            WriteLog.Write_Log(name, wp_id, "错误信息!", $"读取桁架信息:\n车轮SN:{wp_id}\n\n写入桁架信息:\nW_i_status:2\nR_oi_on:0\n\n未查询到工单信息");
                            #endregion
                            continue;
                        }
@@ -107,7 +111,8 @@
                                client.WriteByOrder("W_i_status", (byte)2, name);
                                client.WriteByOrder("R_oi_on", (byte)0, name);
                                #region æ—¥å¿—记录
                                WriteDBLog.Error(name, $"读取桁架信息:\n轮型ID:{wp_type}\n\n写入桁架信息:\nW_i_status:2\nR_oi_on:0\n\n未查询到机加工车轮信息", "PCS");
                                //WriteDBLog.Error(name, $"读取桁架信息:\n轮型ID:{wp_type}\n\n写入桁架信息:\nW_i_status:2\nR_oi_on:0\n\n未查询到机加工车轮信息", "PCS");
                                WriteLog.Write_Log(name, wp_id, "错误信息!", $"读取桁架信息:\n轮型ID:{wp_type}\n\n写入桁架信息:\nW_i_status:2\nR_oi_on:0\n\n未查询到机加工车轮信息");
                                #endregion
                            }
                            else
@@ -124,7 +129,17 @@
                                client.WriteByOrder("W_i_parameter_h", geometry == null ? (float)geometry1.h : (float)geometry.h, name);
                                client.WriteByOrder("R_oi_on", (byte)0, name);
                                #region æ—¥å¿—记录
                                WriteDBLog.Success(name, $"读取桁架信息:\n轮型ID:{wp_type}\n\n写入桁架信息:\nW_i_status:1" + $"\n" +
                                //WriteDBLog.Success(name, $"读取桁架信息:\n轮型ID:{wp_type}\n\n写入桁架信息:\nW_i_status:1" + $"\n" +
                                //    $"a:{(geometry == null ? (float)geometry1.a : (float)geometry.a)}\n" +
                                //    $"b:{(geometry == null ? (float)geometry1.b : (float)geometry.b)}\n" +
                                //    $"c:{(geometry == null ? (float)geometry1.c : (float)geometry.c)}\n" +
                                //    $"d:{(geometry == null ? (float)geometry1.d : (float)geometry.d)}\n" +
                                //    $"e:{(geometry == null ? (float)geometry1.e : (float)geometry.e)}\n" +
                                //    $"f:{(geometry == null ? (float)geometry1.f : (float)geometry.f)}\n" +
                                //    $"g:{(geometry == null ? (float)geometry1.g : (float)geometry.g)}\n" +
                                //    $"h:{(geometry == null ? (float)geometry1.h : (float)geometry.h)}\n" +
                                //    $"R_oi_on:0", "PCS");
                                WriteLog.Write_Log(name, wp_id, "写入信息!", $"读取桁架信息:\n轮型ID:{wp_type}\n\n写入桁架信息:\nW_i_status:1" + $"\n" +
                                    $"a:{(geometry == null ? (float)geometry1.a : (float)geometry.a)}\n" +
                                    $"b:{(geometry == null ? (float)geometry1.b : (float)geometry.b)}\n" +
                                    $"c:{(geometry == null ? (float)geometry1.c : (float)geometry.c)}\n" +
@@ -133,7 +148,7 @@
                                    $"f:{(geometry == null ? (float)geometry1.f : (float)geometry.f)}\n" +
                                    $"g:{(geometry == null ? (float)geometry1.g : (float)geometry.g)}\n" +
                                    $"h:{(geometry == null ? (float)geometry1.h : (float)geometry.h)}\n" +
                                    $"R_oi_on:0", "PCS");
                                    $"R_oi_on:0");
                                #endregion
                            }
                        }
@@ -146,7 +161,8 @@
                                client.WriteByOrder("W_i_status", (byte)2, name);
                                client.WriteByOrder("R_oi_on", (byte)0, name);
                                #region æ—¥å¿—记录
                                WriteDBLog.Error(name, $"读取桁架信息:\n轮型ID:{wp_type}\n\n写入桁架信息:\nW_i_status:2\nR_oi_on:0\n\n未查询到检测线车轮信息", "PCS");
                                //WriteDBLog.Error(name, $"读取桁架信息:\n轮型ID:{wp_type}\n\n写入桁架信息:\nW_i_status:2\nR_oi_on:0\n\n未查询到检测线车轮信息", "PCS");
                                WriteLog.Write_Log(name, wp_id, "错误信息!", $"读取桁架信息:\n轮型ID:{wp_type}\n\n写入桁架信息:\nW_i_status:2\nR_oi_on:0\n\n未查询到检测线车轮信息");
                                #endregion
                            }
                            else
@@ -162,7 +178,17 @@
                                client.WriteByOrder("W_i_parameter_h", geometry == null ? (float)geometry1.h : (float)geometry.h, name);
                                client.WriteByOrder("R_oi_on", (byte)0, name);
                                #region æ—¥å¿—记录
                                WriteDBLog.Success(name, $"读取桁架信息:\n轮型ID:{wp_type}\n\n写入桁架信息:\nW_i_status:1" + $"\n" +
                                //WriteDBLog.Success(name, $"读取桁架信息:\n轮型ID:{wp_type}\n\n写入桁架信息:\nW_i_status:1" + $"\n" +
                                //    $"a:{(geometry == null ? (float)geometry1.a : (float)geometry.a)}\n" +
                                //    $"b:{(geometry == null ? (float)geometry1.b : (float)geometry.b)}\n" +
                                //    $"c:{(geometry == null ? (float)geometry1.c : (float)geometry.c)}\n" +
                                //    $"d:{(geometry == null ? (float)geometry1.d : (float)geometry.d)}\n" +
                                //    $"e:{(geometry == null ? (float)geometry1.e : (float)geometry.e)}\n" +
                                //    $"f:{(geometry == null ? (float)geometry1.f : (float)geometry.f)}\n" +
                                //    $"g:{(geometry == null ? (float)geometry1.g : (float)geometry.g)}\n" +
                                //    $"h:{(geometry == null ? (float)geometry1.h : (float)geometry.h)}\n" +
                                //    $"R_oi_on:0", "PCS");
                                WriteLog.Write_Log(name, wp_id, "写入信息!", $"读取桁架信息:\n轮型ID:{wp_type}\n\n写入桁架信息:\nW_i_status:1" + $"\n" +
                                    $"a:{(geometry == null ? (float)geometry1.a : (float)geometry.a)}\n" +
                                    $"b:{(geometry == null ? (float)geometry1.b : (float)geometry.b)}\n" +
                                    $"c:{(geometry == null ? (float)geometry1.c : (float)geometry.c)}\n" +
@@ -171,7 +197,7 @@
                                    $"f:{(geometry == null ? (float)geometry1.f : (float)geometry.f)}\n" +
                                    $"g:{(geometry == null ? (float)geometry1.g : (float)geometry.g)}\n" +
                                    $"h:{(geometry == null ? (float)geometry1.h : (float)geometry.h)}\n" +
                                    $"R_oi_on:0", "PCS");
                                    $"R_oi_on:0");
                                #endregion
                            }
                        }
@@ -181,7 +207,8 @@
            }
            catch (Exception ex)
            {
                WriteDBLog.Error("查询车轮数据", $"错误信息:{ex.Message}", "PCS");
                //WriteDBLog.Error("查询车轮数据", $"错误信息:{ex.Message}", "PCS");
                WriteLog.Write_Log("报错日志", namea, "错误信息!", $"错误信息:{ex.Message}");
            }
        }
        #endregion
@@ -193,6 +220,7 @@
        /// <param name="client"></param>
        public void QueryOrder(PLCClient client)
        {
            string namea = "";
            try
            {
                VOLContext Context = new VOLContext();
@@ -208,6 +236,7 @@
                List<string> names = new List<string>() { "1单元辊道下料查询订单", "2单元辊道下料查询订单", "3单元辊道下料查询订单", "辊道上料查询订单" };
                foreach (string name in names)
                {
                    namea = name;
                    var details = plcRepository.Find(x => x.plcdetail_iotype == plc.plcinfo_iotyep && x.plcdetail_number == name).ToList();
                    var on = DBExtension.Read(details.Where(x => x.plcdetail_name == "R_oi_on").First(), client);
                    //var on = DBExtension.Read(details.Where(x => x.plcdetail_name == "R_oi_on" && x.plcdetail_number == name).First(), client);
@@ -217,10 +246,11 @@
                        var wp_id = client.ReadByOrder<string>("R_o_wp_id", name);
                        if (string.IsNullOrEmpty(wp_id))
                        {
                            #region æ—¥å¿—记录
                            client.WriteByOrder("W_i_status", (byte)2, name);
                            client.WriteByOrder("R_oi_on", (byte)0, name);
                            WriteDBLog.Error(name, $"读取桁架信息:\n车轮SN:{wp_id}\n\n写入桁架信息:\nW_i_status:2\nR_oi_on:0\n\n车轮SN号为空", "PCS");
                            #region æ—¥å¿—记录
                            //WriteDBLog.Error(name, $"读取桁架信息:\n车轮SN:{wp_id}\n\n写入桁架信息:\nW_i_status:2\nR_oi_on:0\n\n车轮SN号为空", "PCS");
                            WriteLog.Write_Log(name, wp_id, "错误信息!", $"读取桁架信息:\n车轮SN:{wp_id}\n\n写入桁架信息:\nW_i_status:2\nR_oi_on:0\n\n车轮SN号为空");
                            #endregion
                            continue;
                        }
@@ -232,7 +262,8 @@
                            client.WriteByOrder("W_i_status", (byte)2, name);
                            client.WriteByOrder("R_oi_on", (byte)0, name);
                            #region æ—¥å¿—记录
                            WriteDBLog.Error(name, $"读取桁架信息:\n车轮SN:{wp_id}\n\n写入桁架信息:\nW_i_status:2\nR_oi_on:0\n\n未查询到工单详情", "PCS");
                            //WriteDBLog.Error(name, $"读取桁架信息:\n车轮SN:{wp_id}\n\n写入桁架信息:\nW_i_status:2\nR_oi_on:0\n\n未查询到工单详情", "PCS");
                            WriteLog.Write_Log(name, wp_id, "错误信息!", $"读取桁架信息:\n车轮SN:{wp_id}\n\n写入桁架信息:\nW_i_status:2\nR_oi_on:0\n\n未查询到工单详情");
                            #endregion
                            continue;
                        }
@@ -270,7 +301,8 @@
                                client.WriteByOrder("W_i_status", (byte)4, name);
                                client.WriteByOrder("R_oi_on", (byte)0, name);
                                #region æ—¥å¿—记录
                                WriteDBLog.Error(name, $"读取桁架信息:\n车轮SN:{wp_id}\n\n写入桁架信息:\nW_i_status:4\nR_oi_on:0\n\n手动入库模式未选择库区", "PCS");
                                //WriteDBLog.Error(name, $"读取桁架信息:\n车轮SN:{wp_id}\n\n写入桁架信息:\nW_i_status:4\nR_oi_on:0\n\n手动入库模式未选择库区", "PCS");
                                WriteLog.Write_Log(name, wp_id, "错误信息!", $"读取桁架信息:\n车轮SN:{wp_id}\n\n写入桁架信息:\nW_i_status:4\nR_oi_on:0\n\n手动入库模式未选择库区");
                                #endregion
                                continue;
                            }
@@ -283,7 +315,8 @@
                                client.WriteByOrder("W_i_status", (byte)2, name);
                                client.WriteByOrder("R_oi_on", (byte)0, name);
                                #region æ—¥å¿—记录
                                WriteDBLog.Error(name, $"读取桁架信息:\n车轮SN:{wp_id}\n轮型ID:{wp_type}\n\n写入桁架信息:\nW_i_status:2\nR_oi_on:0\n\n未查询到机加工车轮信息", "PCS");
                                //WriteDBLog.Error(name, $"读取桁架信息:\n车轮SN:{wp_id}\n轮型ID:{wp_type}\n\n写入桁架信息:\nW_i_status:2\nR_oi_on:0\n\n未查询到机加工车轮信息", "PCS");
                                WriteLog.Write_Log(name, wp_id, "错误信息!", $"读取桁架信息:\n车轮SN:{wp_id}\n轮型ID:{wp_type}\n\n写入桁架信息:\nW_i_status:2\nR_oi_on:0\n\n未查询到机加工车轮信息");
                                #endregion
                                continue;
                            }
@@ -306,10 +339,14 @@
                                //}
                                client.WriteByOrder("R_oi_on", (byte)0, name);
                                #region æ—¥å¿—记录
                                WriteDBLog.Success(name, $"读取桁架信息:\n车轮SN:{wp_id}\n轮型ID:{wp_type}\n\n写入桁架信息:\nW_i_status:1" +
                                WriteLog.Write_Log(name, wp_id, "写入信息!", $"读取桁架信息:\n车轮SN:{wp_id}\n轮型ID:{wp_type}\n\n写入桁架信息:\nW_i_status:1" +
                                    $"\nW_i_job_id:{Mes_Work.jobID}\nW_i_drawing_id:{Mes_Work.drawingNo}\nW_i_heat_id:{Mes_Work.heatID}\nW_i_batch_id:{Mes_Work.heatBatchID}" +
                                    $"\nW_i_skip_op_SJ1:{(name == "3单元辊道下料查询订单" ? true : mes_Head.skip_op_1)}\nW_i_skip_op_SJ2:{(name == "3单元辊道下料查询订单" ? true : mes_Head.skip_op_2)}" +
                                    $"\nW_i_skip_op_LT:{mes_Head.skip_op_3}\nR_oi_on:0", "PCS");
                                    $"\nW_i_skip_op_LT:{mes_Head.skip_op_3}\nR_oi_on:0");
                                //WriteDBLog.Success(name, $"读取桁架信息:\n车轮SN:{wp_id}\n轮型ID:{wp_type}\n\n写入桁架信息:\nW_i_status:1" +
                                //    $"\nW_i_job_id:{Mes_Work.jobID}\nW_i_drawing_id:{Mes_Work.drawingNo}\nW_i_heat_id:{Mes_Work.heatID}\nW_i_batch_id:{Mes_Work.heatBatchID}" +
                                //    $"\nW_i_skip_op_SJ1:{(name == "3单元辊道下料查询订单" ? true : mes_Head.skip_op_1)}\nW_i_skip_op_SJ2:{(name == "3单元辊道下料查询订单" ? true : mes_Head.skip_op_2)}" +
                                //    $"\nW_i_skip_op_LT:{mes_Head.skip_op_3}\nR_oi_on:0", "PCS");
                                #endregion
                            }
                        }
@@ -323,7 +360,8 @@
                                client.WriteByOrder("W_i_status", (byte)2, name);
                                client.WriteByOrder("R_oi_on", (byte)0, name);
                                #region æ—¥å¿—记录
                                WriteDBLog.Error(name, $"读取桁架信息:\n车轮SN:{wp_id}\n轮型ID:{wp_type}\n\n写入桁架信息:\nW_i_status:2\nR_oi_on:0\n\n未查询到检测线车轮信息", "PCS");
                                //WriteDBLog.Error(name, $"读取桁架信息:\n车轮SN:{wp_id}\n轮型ID:{wp_type}\n\n写入桁架信息:\nW_i_status:2\nR_oi_on:0\n\n未查询到检测线车轮信息", "PCS");
                                WriteLog.Write_Log(name, wp_id, "错误信息!", $"读取桁架信息:\n车轮SN:{wp_id}\n轮型ID:{wp_type}\n\n写入桁架信息:\nW_i_status:2\nR_oi_on:0\n\n未查询到检测线车轮信息");
                                #endregion
                                continue;
                            }
@@ -338,8 +376,10 @@
                                client.WriteByOrder("W_i_batch_id", Mes_Work.heatBatchID, name);
                                client.WriteByOrder("R_oi_on", (byte)0, name);
                                #region æ—¥å¿—记录
                                WriteDBLog.Success(name, $"读取桁架信息:\n车轮SN:{wp_id}\n轮型ID:{wp_type}\n\n写入桁架信息:\nW_i_status:1" + $"\nW_i_job_id:{Mes_Work.jobID}" +
                                    $"\nW_i_drawing_id:{mes_Head.drawingNo}\nW_i_heat_id:{Mes_Work.heatID}\nW_i_batch_id:{Mes_Work.heatBatchID}\nR_oi_on:0", "PCS");
                                WriteLog.Write_Log(name, wp_id, "写入信息!", $"读取桁架信息:\n车轮SN:{wp_id}\n轮型ID:{wp_type}\n\n写入桁架信息:\nW_i_status:1" + $"\nW_i_job_id:{Mes_Work.jobID}" +
                                    $"\nW_i_drawing_id:{mes_Head.drawingNo}\nW_i_heat_id:{Mes_Work.heatID}\nW_i_batch_id:{Mes_Work.heatBatchID}\nR_oi_on:0");
                                //WriteDBLog.Success(name, $"读取桁架信息:\n车轮SN:{wp_id}\n轮型ID:{wp_type}\n\n写入桁架信息:\nW_i_status:1" + $"\nW_i_job_id:{Mes_Work.jobID}" +
                                //    $"\nW_i_drawing_id:{mes_Head.drawingNo}\nW_i_heat_id:{Mes_Work.heatID}\nW_i_batch_id:{Mes_Work.heatBatchID}\nR_oi_on:0", "PCS");
                                #endregion
                            }
                        }
@@ -348,7 +388,8 @@
            }
            catch (Exception ex)
            {
                WriteDBLog.Error("查询车轮订单", $"错误信息:{ex.Message}", "PCS");
                //WriteDBLog.Error("查询车轮订单", $"错误信息:{ex.Message}", "PCS");
                WriteLog.Write_Log("报错日志", namea, "错误信息!", $"错误信息:{ex.Message}");
            }
        }
        #endregion
@@ -404,14 +445,6 @@
                        }
                        #endregion
                        var Stations = stationinfoRepository.Find(x => x.area == PipelineJob.area_code(name)).OrderBy(x => x.lastUpdateTime).ToList();
                        #region ä¸‹æ–™ä½æ˜¯å¦ä¸ºç©ºçŠ¶æ€åŒæ­¥ç»™æ¡æž¶
                        foreach (var station in Stations)
                        {
                            client.WriteByOrder(station.stationCode, station.location_state != LocationStateEnum.Stroge.ToString(), name);
                        }
                        #endregion
                        if (finished && !updatefinished)
                        {
@@ -449,7 +482,7 @@
                            #region åˆ¤æ–­åŒºåŸŸå·æ˜¯å¦ä¸€è‡´
                            var area = client.ReadByOrder<Int16>("place_prog", name);//放料完成的区域号
                            if (AreaNr != area)
                            {
                                Pipeline_client.WriteByOrder("W_AlarmSignal", (Int16)2, name);//报警
@@ -459,7 +492,7 @@
                            }
                            #endregion
                            var areaCode = PipelineJob.area_code(name);   //根据下料口单元名获取区域代码
                            var areaCode = Pipeline.area_code(name);   //根据下料口单元名获取区域代码
                            var station = stationinfoRepository.Find(x => x.area == areaCode && x.stationCode.Substring(x.stationCode.Length - 1, 1) == AreaNr.ToString()).FirstOrDefault();
                            if (station != null)
                            {
@@ -486,21 +519,6 @@
                                        throw new Exception($"{station.stationCode}已存在车轮SN号:{Wheel_SN}");
                                }
                                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)
                                {
                                    station.stationType = Mes_Work.drawingNo;
                                    station.Number = Mes_Work.workOrder;
                                    station.heatNumber = Mes_Work.heatID;
                                    station.tray_status = "StrogeTray";
                                }
                                var count = stationinfoRepository.Update(station, true);
                                if (count < 1)
                                    throw new Exception($"下料位信息更新失败!下料位编号:{station.stationCode}");
                                #region æ¸…空给桁架的下料信息
                                client.WriteByOrder("W_IndexNr", (Int16)0, name);//托盘上的第几个车轮
                                client.WriteByOrder("W_Storage_Type", (Int16)0, name);//托盘类型1-横放;2-竖放(暂时只有横放托盘)
@@ -516,6 +534,24 @@
                                //    $"写入桁架信息:\nW_Storage_update:{true}\nW_Enabl_Load:{false}", "PCS");
                                #endregion
                                #region è´§ä½çŠ¶æ€æ›´æ–°
                                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)
                                {
                                    station.stationType = Mes_Work.drawingNo;
                                    station.Number = Mes_Work.workOrder;
                                    station.heatNumber = Mes_Work.heatID;
                                    station.tray_status = "StrogeTray";
                                }
                                station.remark = "";
                                var count = stationinfoRepository.Update(station, true);
                                if (count < 1)
                                    throw new Exception($"下料位信息更新失败!下料位编号:{station.stationCode}");
                                #endregion
                                #region ä¿®æ”¹å·¥å•状态
                                var Detail = mes_DetailRepository.FindFirst(x => x.jobID == Mes_Work.jobID && x.SN == Mes_Work.SN);
                                Detail.Status = "下线";
@@ -525,6 +561,7 @@
                                    throw new Exception($"工单子表信息更新失败!车轮SN号:{Detail.SN}");
                                var Head = mes_HeadRepository.FindFirst(x => x.jobID == Detail.jobID);
                                Head.finishNum = Head.finishNum + 1;
                                if (Head.finishNum == Head.quantity) Head.FinishTime = DateTime.Now;
                                count = mes_HeadRepository.Update(Head, true);
                                if (count < 1)
                                    throw new Exception($"工单头表信息更新失败!工单号:{Head.jobID}");
@@ -532,11 +569,18 @@
                            }
                        }
                        var Stations = stationinfoRepository.Find(x => x.area == Pipeline.area_code(name)).OrderBy(x => x.lastUpdateTime).ToList();
                        #region ä¸‹æ–™ä½æ˜¯å¦ä¸ºç©ºçŠ¶æ€åŒæ­¥ç»™æ¡æž¶
                        foreach (var station in Stations)
                        {
                            client.WriteByOrder(station.stationCode, station.location_state != LocationStateEnum.Stroge.ToString(), name);
                        }
                        #endregion
                        var Request = (bool)DBExtension.Read(details.Where(x => x.plcdetail_name == "R_Request_Load").First(), client);
                        if (!Request) continue;
                        //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);//车轮类型
@@ -554,6 +598,7 @@
                            client.WriteByOrder("W_Enabl_Load", false, name);//信号为false桁架停止进入
                            //WriteDBLog.Error(name, $"读取桁架信息:\n车轮SN:{Wheel_id}\n\n未查询到工单信息", "PCS");
                            WriteLog.Write_Log(name + "申请放料异常", Wheel_id, "查询机加工工单", $"读取桁架信息:\n车轮SN号:{Wheel_id}未查询到工单信息\n写入桁架信息:\n是否允许下料:{false}");
                            continue;
                        }
@@ -570,8 +615,10 @@
                        #endregion
                        var wheel = PipelineJob.QueryMateriel(Work.drawingNo);
                        var wheel1 = PipelineJob.QueryMateriel1(Work.drawingNo);
                        var wheel = Pipeline.QueryMateriel(Work.drawingNo);
                        var wheel1 = Pipeline.QueryMateriel1(Work.drawingNo);
                        if (wheel == null && wheel1 == null)
                        {
                            #region æ—¥å¿—记录
@@ -581,6 +628,17 @@
                            #endregion
                            continue;
                        }
                        #region æ¢å›¾å·,下料口其他图号托盘全部入库
                        var stations = Stations.Where(x => x.enable && x.location_state == LocationStateEnum.Stroge.ToString() && x.quantity > 0 && x.stationType != Work.drawingNo).ToList();
                        foreach (var station in stations)
                        {
                            if (station.stationCode == NGStation || name == "3单元下料区")
                                agvtask(stationinfoRepository, station, Work, "TaskType_OutsourceInbound");
                            else
                                agvtask(stationinfoRepository, station, Work, "TaskType_Inbound");
                        }
                        #endregion
                        var PartStatus = DBExtension.Read(details.Where(x => x.plcdetail_name == "R_PartStatus").First(), client);//1:ok;2:nok
@@ -624,12 +682,9 @@
                            if (Stationinfo == null)
                            {
                                #region è§¦å‘NG任务
                                var NG = Stations.Where(x => x.enable && x.stationCode == NGStation && x.location_state == LocationStateEnum.Stroge.ToString() && x.quantity > 0).FirstOrDefault();
                                var NG = Stations.Where(x => x.enable && x.stationCode == NGStation && x.location_state == LocationStateEnum.Stroge.ToString() && x.Number != Work.workOrder && x.quantity > 0).FirstOrDefault();
                                if (NG != null)
                                {
                                    if (NG.stationType != Work.drawingNo || NG.Number != Work.workOrder)
                                        agvtask(stationinfoRepository, NG, Work, "TaskType_OutsourceInbound");
                                }
                                    agvtask(stationinfoRepository, NG, Work, "TaskType_OutsourceInbound");
                                #endregion
                                Stationinfo = Stations.Where(x => x.enable && x.stationCode != NGStation && x.location_state == LocationStateEnum.Stroge.ToString() && x.quantity == 0).FirstOrDefault();
@@ -640,9 +695,9 @@
                            {
                                #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");
                                //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 æ‰˜ç›˜è½¦è½®å †åž›ç¬¬å››ä¸ªæ—¶ä¸‹å‘另外一个炉号的入库任务
@@ -724,6 +779,8 @@
                                    client.WriteByOrder("W_IndexNr", (Int16)(Stationinfo.quantity + 1), name);//托盘上的第几个车轮
                                    client.WriteByOrder("W_Storage_Type", (Int16)1, name);//托盘类型1-横放;2-竖放(暂时只有横放托盘)
                                    client.WriteByOrder("W_Enabl_Load", true, name);//是否允许
                                    Stationinfo.remark = "桁架下料";
                                    stationinfoRepository.Update(Stationinfo, true);
                                    #region æ—¥å¿—记录
                                    //WriteDBLog.Success(name + "允许放料", $"读取桁架信息:\n车轮SN:{Wheel_id}\n轮型ID:{Wheel_Type}\n车轮状态:OK" +$"\n读取托盘光电信号:{PalletSignal}" +
                                    //    $"\n\n写入桁架信息:\n下料位号:{area}\n第几个车轮:{(Stationinfo.quantity + 1)}\n托盘类型:1\nW_Enabl_Load:true", "PCS");
@@ -740,7 +797,7 @@
                                #region æ²¡æ‰˜ç›˜å¯ç”¨,触发入库任务
                                if (!Stations.Where(x => x.enable && x.stationCode != NGStation && x.location_state != LocationStateEnum.Stroge.ToString()).Any())
                                {
                                    var station = Stations.Where(x => x.enable && x.stationCode != NGStation).OrderBy(x => x.lastUpdateTime).FirstOrDefault();
                                    var station = Stations.Where(x => x.enable && x.stationCode != NGStation && x.location_state == LocationStateEnum.Stroge.ToString()).OrderBy(x => x.lastUpdateTime).FirstOrDefault();
                                    agvtask(stationinfoRepository, station, Work, name == "3单元下料区" ? "TaskType_OutsourceInbound" : "TaskType_Inbound");
                                }
                                #endregion
@@ -782,6 +839,7 @@
                                    Stationinfo.tray_type = Stationinfo.tray_type == "SmallTray" ? "SmallTray/LargeTray" : "LargeTray/SmallTray";
                                    Stationinfo.remark = "托盘类型不一致需更换托盘";
                                    stationinfoRepository.Update(Stationinfo, true);
                                    continue;
                                }
                                #endregion
                                var Pipelinedetails = plcRepository.Find(x => x.plcdetail_iotype == Pipelineplc.plcinfo_iotyep && x.plcdetail_number == Stationinfo.stationCode).ToList();
@@ -835,6 +893,8 @@
                                    client.WriteByOrder("W_IndexNr", (Int16)(Stationinfo.quantity + 1), name);//托盘上的第几个车轮
                                    client.WriteByOrder("W_Storage_Type", (Int16)1, name);//托盘类型1-横放;2-竖放(暂时只有横放托盘)
                                    client.WriteByOrder("W_Enabl_Load", true, name);//是否允许
                                    Stationinfo.remark = "桁架下料";
                                    stationinfoRepository.Update(Stationinfo, true);
                                    #region æ—¥å¿—记录
                                    //WriteDBLog.Success(name + "允许放料", $"读取桁架信息:\n车轮SN:{Wheel_id}\n轮型ID:{Wheel_Type}\n车轮状态:NG" +$"\n读取托盘光电信号:{PalletSignal}" +
                                    //    $"\n\n写入桁架信息:\n下料位号:{area}\n第几个车轮:{(Stationinfo.quantity + 1)}\n托盘类型:1\nW_Enabl_Load:true", "PCS");
@@ -852,13 +912,15 @@
                    }
                    catch (Exception ex)
                    {
                        WriteDBLog.Error(name, $"错误信息:{ex.Message}", "PCS");
                        //WriteDBLog.Error(name, $"错误信息:{ex.Message}", "PCS");
                        WriteLog.Write_Log("报错日志", name, "错误信息!", $"错误信息:{ex.Message}");
                    }
                }
            }
            catch (Exception ex)
            {
                WriteDBLog.Error("下料区", $"错误信息:{ex.Message}", "PCS");
                //WriteDBLog.Error("下料区", $"错误信息:{ex.Message}", "PCS");
                WriteLog.Write_Log("报错日志", "下料区", "错误信息!", $"错误信息:{ex.Message}");
            }
        }
        #endregion
@@ -867,6 +929,8 @@
        {
            VOLContext Context = new VOLContext();
            Idt_agvtaskRepository agvtaskRepository = new dt_agvtaskRepository(Context);
            IVV_Mes_WorkinfoRepository workinfoRepository = new VV_Mes_WorkinfoRepository(Context);
            Work = workinfoRepository.Find(x => x.workOrder == stationinfo.Number && x.processCode == "17").FirstOrDefault();
            var task = agvtaskRepository.Find(x => x.agv_fromaddress == stationinfo.stationCode).FirstOrDefault();
            if (task != null) return;
            if (!string.IsNullOrEmpty(Work.area))