分支自 SuZhouGuanHong/TaiYuanTaiZhong

dengjunjie
2024-05-25 8554717a7abbe2889ae1d835857661dc8b91aa68
优化自动切换大小托盘
已修改7个文件
已添加2个文件
已重命名1个文件
251 ■■■■ 文件已修改
代码管理/PCS/WCS_Server/WIDESEA_Comm/StateEnum/LocationStateEnum.cs 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
代码管理/PCS/WCS_Server/WIDESEA_WCS/Common/Gantry.cs 55 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
代码管理/PCS/WCS_Server/WIDESEA_WCS/Jobs/Task/AutoTaskJob.cs 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
代码管理/PCS/WCS_Server/WIDESEA_WCS/JobsPart/Common/ReplaceTray.cs 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
代码管理/WMS/WMS_Server/WIDESEA_Comm/StateEnum/LocationStateEnum.cs 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
代码管理/WMS/WMS_Server/WIDESEA_WMS/Common/AGVTask/AGVServer.cs 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
代码管理/WMS/WMS_Server/WIDESEA_WMS/Common/QueueTask/ReplaceTray.cs 143 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
代码管理/WMS/WMS_Server/WIDESEA_WMS/Services/system/Partial/dt_stationinfoService.cs 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
代码管理/WMS/WMS_Server/WIDESEA_WebApi/Controllers/JobQueueTask.cs 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
代码管理/WMS/WMS_Server/WIDESEA_WebApi/Controllers/JobSendTask.cs 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
´úÂë¹ÜÀí/PCS/WCS_Server/WIDESEA_Comm/StateEnum/LocationStateEnum.cs
@@ -35,6 +35,10 @@
        /// <summary>
        /// æ¡æž¶ä¸‹æ–™
        /// </summary>
        Load
        Load,
        /// <summary>
        /// æ‰˜ç›˜åˆ‡æ¢
        /// </summary>
        Trayswitching
    }
}
´úÂë¹ÜÀí/PCS/WCS_Server/WIDESEA_WCS/Common/Gantry.cs
@@ -590,8 +590,6 @@
                            WriteLog.Write_Log(name + "申请放料异常", "车轮SN号为空", "", $"读取桁架信息:\n车轮SN号:{Wheel_id}为空");
                            continue;
                        }
                        var Work = workinfoRepository.Find(x => x.SN == Wheel_id && x.processCode == "17").FirstOrDefault();
                        if (Work == null)
                        {
@@ -600,22 +598,7 @@
                            WriteLog.Write_Log(name + "申请放料异常", Wheel_id, "查询机加工工单", $"读取桁架信息:\n车轮SN号:{Wheel_id}未查询到工单信息\n写入桁架信息:\n是否允许下料:{false}");
                            continue;
                        }
                        #endregion
                        #region MyRegion
                        //var currentAreaNr = (Int16)DBExtension.Read(details.Where(x => x.plcdetail_name == "W_Are00aNr").First(), client);
                        //var currentAreaCode = PipelineJob.area_code(name);   //根据下料口单元名获取区域代码
                        //var currentStation = stationinfoRepository.FindFirst(x => x.area == currentAreaCode && x.stationCode.Substring(x.stationCode.Length - 1, 1) == currentAreaNr.ToString());
                        //if (!currentStation.enable || currentStation.location_state == LocationStateEnum.Empty.ToString())
                        //    client.WriteByOrder("W_Enabl_Load", false, name);//信号为false桁架停止进入
                        #endregion
                        var wheel = Pipeline.QueryMateriel(Work.drawingNo);
                        var wheel1 = Pipeline.QueryMateriel1(Work.drawingNo);
@@ -639,6 +622,21 @@
                                agvtask(stationinfoRepository, station, Work, "TaskType_Inbound");
                        }
                        #endregion
                        #region æ‰˜ç›˜ç±»åž‹ä¸ä¸€è‡´éœ€æ›´æ¢æ‰˜ç›˜
                        foreach (var Stationinfo in Stations)
                        {
                            if (Stationinfo.tray_type != "LargeTray" && (wheel == null ? wheel1.e : wheel.e) > 1100)
                            {
                                client.WriteByOrder("W_Enabl_Load", false, name);//信号为false桁架停止进入
                                Stationinfo.location_state = LocationStateEnum.Trayswitching.ToString();
                                Stationinfo.remark = "托盘类型不一致需更换托盘";
                                stationinfoRepository.Update(Stationinfo, x => new { x.location_state }, true);
                            }
                        }
                        #endregion
                        Stations = stationinfoRepository.Find(x => x.area == Pipeline.area_code(name)).OrderBy(x => x.lastUpdateTime).ToList();
                        var PartStatus = DBExtension.Read(details.Where(x => x.plcdetail_name == "R_PartStatus").First(), client);//1:ok;2:nok
@@ -708,18 +706,6 @@
                                        agvtask(stationinfoRepository, stationinfo, Work, name == "3单元下料区" ? "TaskType_OutsourceInbound" : "TaskType_Inbound");
                                }
                                #endregion
                                #region æ‰˜ç›˜ç±»åž‹ä¸ä¸€è‡´éœ€æ›´æ¢æ‰˜ç›˜
                                if (Stationinfo.tray_type != "LargeTray" && (wheel == null ? wheel1.e : wheel.e) > 1100)
                                {
                                    client.WriteByOrder("W_Enabl_Load", false, name);//信号为false桁架停止进入
                                    Stationinfo.location_state = LocationStateEnum.Abnormal.ToString();
                                    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();
@@ -831,17 +817,6 @@
                            }
                            if (Stationinfo != null)
                            {
                                #region æ‰˜ç›˜ç±»åž‹ä¸ä¸€è‡´éœ€æ›´æ¢æ‰˜ç›˜
                                //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";
                                    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();
                                var PalletSignal = (Int16)DBExtension.Read(Pipelinedetails.Where(x => x.plcdetail_name == "R_PalletSignal").First(), Pipeline_client);//读取托盘信号:1:有,2无
                                var MaterialSignal = (Int16)DBExtension.Read(Pipelinedetails.Where(x => x.plcdetail_name == "R_MaterialSignal").First(), Pipeline_client);//读取货物信号:1:有,2无
´úÂë¹ÜÀí/PCS/WCS_Server/WIDESEA_WCS/Jobs/Task/AutoTaskJob.cs
@@ -30,10 +30,9 @@
        private void DoAction(IJobExecutionContext context)
        {
            //EmptyTray.EmptyTrayIn();//空托叠盘入库
            StationTask.CreateTask();//入库
            OutboundTask.CreateOutboundTask();//出库
            ReplaceTray.ReplaceTrayTask();//更换托盘
            //ReplaceTray.ReplaceTrayTask();//更换托盘
            RestockHCJ.HCJGetBarcode();//更新队列
            EmptyTrayTask.CreateEmptyTrayTask();//创建补空托
            AutoUpdateWork.FinishMesWork();//处理工单
´úÂë¹ÜÀí/PCS/WCS_Server/WIDESEA_WCS/JobsPart/Common/ReplaceTray.cs
@@ -58,7 +58,7 @@
                VOLContext context = new VOLContext(); 
                Idt_stationinfoRepository stationinfoRepository = new dt_stationinfoRepository(context);
                Idt_agvtaskRepository agvtaskRepository = new dt_agvtaskRepository(context);//"Abnormal" 
                var stations = stationinfoRepository.Find(x => (x.stationCode.Contains("X") || x.stationCode.Contains("W01001004") || x.stationCode.Contains("W01001005")) && x.location_state == LocationStateEnum.Abnormal.ToString() && (x.tray_type == "SmallTray/LargeTray" || x.tray_type == "LargeTray/SmallTray") && x.enable).ToList();
                var stations = stationinfoRepository.Find(x => (x.stationCode.Contains("X") || x.stationCode.Contains("W01001004") || x.stationCode.Contains("W01001005")) && x.location_state == LocationStateEnum.Trayswitching.ToString() && x.enable).ToList();
                foreach (var station in stations)
                {
                    if (agvtaskRepository.Find(x => x.agv_fromaddress == station.stationCode || x.agv_toaddress == station.stationCode).Any()) continue;
´úÂë¹ÜÀí/WMS/WMS_Server/WIDESEA_Comm/StateEnum/LocationStateEnum.cs
@@ -31,6 +31,14 @@
        /// <summary>
        /// å¼‚常
        /// </summary>
        Abnormal
        Abnormal,
        /// <summary>
        /// æ¡æž¶ä¸‹æ–™
        /// </summary>
        Load,
        /// <summary>
        /// æ‰˜ç›˜åˆ‡æ¢
        /// </summary>
        Trayswitching
    }
}
´úÂë¹ÜÀí/WMS/WMS_Server/WIDESEA_WMS/Common/AGVTask/AGVServer.cs
@@ -25,7 +25,6 @@
        /// </summary>
        public static void SendAgvTask()
        {
            WriteLog.Write_Log("自动下发任务", "SendAgvTask", "");
            Respone respone = new Respone();
            RequestTask requestTask = new RequestTask();
            string postJson = string.Empty;
´úÂë¹ÜÀí/WMS/WMS_Server/WIDESEA_WMS/Common/QueueTask/ReplaceTray.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,143 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography.Xml;
using System.Text;
using System.Threading.Tasks;
using WIDESEA_Comm;
using WIDESEA_Comm.LogInfo;
using WIDESEA_Comm.TaskNo;
using WIDESEA_Common;
using WIDESEA_Core.BaseProvider;
using WIDESEA_Core.EFDbContext;
using WIDESEA_Core.ManageUser;
using WIDESEA_Entity.DomainModels;
using WIDESEA_WCS.IRepositories;
using WIDESEA_WCS.Repositories;
using WIDESEA_WMS.IRepositories;
using WIDESEA_WMS.Repositories;
using static FreeSql.Internal.GlobalFilter;
using static System.Collections.Specialized.BitVector32;
namespace WIDESEA_WMS.Common
{
    public class QueueTask
    {
        /// <summary>
        /// åˆ›å»ºæ›´æ¢æ‰˜ç›˜ä»»åŠ¡,需修改
        /// </summary>
        public static void ReplaceTrayTask()
        {
            try
            {
                VOLContext context = new VOLContext();
                Idt_stationinfoRepository stationinfoRepository = new dt_stationinfoRepository(context);
                Idt_agvtaskRepository agvtaskRepository = new dt_agvtaskRepository(context);
                IVV_Mes_WorkinfoRepository workinfoRepository = new VV_Mes_WorkinfoRepository(context);
                var stations = stationinfoRepository.Find(x => (x.stationCode.Contains("X") || x.stationCode.Contains("W01001004") || x.stationCode.Contains("W01001005")) && x.location_state == LocationStateEnum.Trayswitching.ToString() && x.enable).ToList();
                foreach (var station in stations)
                {
                    var task = agvtaskRepository.Find(x => x.agv_toaddress == station.stationCode).FirstOrDefault();
                    if (task != null)
                    {
                        if (task.agv_taskstate != AGVTaskStateEnum.Queue.ToString()) continue;
                        task.agv_Traytype = station.tray_type == TrayTypeEnum.SmallTray.ToString() ? TrayTypeEnum.LargeTray.ToString() : TrayTypeEnum.SmallTray.ToString();
                        agvtaskRepository.Update(task, x => new { x.agv_Traytype }, true);
                    }
                    else if (!agvtaskRepository.Find(x => x.agv_fromaddress == station.stationCode).Any())
                    {
                        #region ä¸ºç©ºæ‰˜å¹¶ä¸”数量为0,创建取空托任务
                        if (station.tray_status == TrayStateEnum.EmptyTray.ToString() && station.quantity == 0)
                        {
                            dt_agvtask agvtask = new dt_agvtask()
                            {
                                agv_fromaddress = station.stationCode,
                                agv_id = Guid.NewGuid(),
                                agv_tasknum = IdenxManager.GetTaskNo("KH-", "WMS"),
                                agv_grade = 1,
                                agv_createtime = DateTime.Now,
                                agv_taskstate = AGVTaskStateEnum.Queue.ToString(),
                                agv_qty = 1,
                                StarQuantity = 0,
                                EndQuantity = 0,
                                agv_tasktype = AGVTaskTypeEnum.TaskType_EmptyPallet.ToString(),
                                agv_toaddress = "",
                                agv_userid = "WMS",
                                agv_TrayStatus = station.tray_status,
                                agv_Traytype = station.tray_type
                            };
                            agvtaskRepository.Add(agvtask, true);
                            station.location_state = LocationStateEnum.Busy.ToString();
                        }
                        #endregion
                        #region åˆ›å»ºå…¥åº“任务
                        else if (station.location_state == LocationStateEnum.Stroge.ToString() && station.quantity > 0)
                        {
                            var Work = workinfoRepository.Find(x => x.workOrder == station.Number && x.processCode == "17").FirstOrDefault();
                            if (Work == null) throw new Exception($"未找到货位{station.stationCode}的机加工工单信息!");
                            dt_agvtask agvtask = new dt_agvtask()
                            {
                                agv_fromaddress = station.stationCode,
                                agv_id = Guid.NewGuid(),
                                agv_tasknum = IdenxManager.GetTaskNo("KH-", "WMS"),
                                agv_grade = 1,
                                agv_createtime = DateTime.Now,
                                agv_taskstate = AGVTaskStateEnum.Queue.ToString(),
                                agv_materielid = station.stationType,
                                agv_qty = station.quantity,
                                agv_tasktype = station.stationCode.Contains("3") ? AGVTaskTypeEnum.TaskType_OutsourceInbound.ToString() : AGVTaskTypeEnum.TaskType_Inbound.ToString(),
                                agv_toaddress = "",
                                agv_userid = "WMS",
                                bindSN = station.bindSN,
                                agv_worktype = Convert.ToInt32(Work.processCode),
                                agv_materbarcode = Work.materialCode,
                                agv_Traytype = station.tray_type,
                                jobID = station.Number,
                                agv_TrayStatus = station.tray_status
                            };
                            agvtaskRepository.Add(agvtask, true);
                            station.location_state = LocationStateEnum.InBusy.ToString();
                        }
                        #endregion
                    }
                    station.tray_type = station.tray_type == TrayTypeEnum.SmallTray.ToString() ? TrayTypeEnum.LargeTray.ToString() : TrayTypeEnum.SmallTray.ToString();
                    stationinfoRepository.Update(station, x => new { x.location_state, x.tray_type }, true);
                }
            }
            catch (Exception ex)
            {
                WriteDBLog.Error("创建更换空盘任务", $"错误信息:{ex.Message}", "PCS");
            }
        }
        /// <summary>
        /// åˆ›å»ºå®Œæ•´çš„补空托任务
        /// </summary>
        /// <param name="agvtask"></param>
        public static void CreatePartQueue(Idt_agvtaskRepository agvtaskRepository, dt_agvtask agvtask, string type = "")
        {
            //if (agvtask.agv_fromaddress.Contains("X") || agvtask.agv_fromaddress.Contains("W01001004") || agvtask.agv_fromaddress.Contains("W01001005"))
            //{
            dt_agvtask taskPart = new dt_agvtask()
            {
                agv_fromaddress = "",
                agv_id = Guid.NewGuid(),
                agv_tasknum = agvtask.agv_tasknum + "_1",
                agv_grade = 1,
                agv_createtime = DateTime.Now,
                agv_taskstate = "Queue",
                agv_qty = 1,
                agv_tasktype = "TaskType_EmptyPallet",
                agv_toaddress = agvtask.agv_fromaddress,
                agv_userid = "系统",
                agv_TrayStatus = agvtask.agv_TrayStatus,
                agv_Traytype = type,
            };
            agvtaskRepository.Add(taskPart, true);
            WriteDBLog.Success("创建更换空盘任务", $"任务编号:{taskPart.agv_tasknum}", "PCS");
            //}
        }
    }
}
´úÂë¹ÜÀí/WMS/WMS_Server/WIDESEA_WMS/Services/system/Partial/dt_stationinfoService.cs
@@ -111,20 +111,25 @@
            VOLContext context = new VOLContext();
            Idt_agvtaskRepository agvtaskRepository = new dt_agvtaskRepository(context);
            IVV_Mes_WorkinfoRepository workinfoRepository = new VV_Mes_WorkinfoRepository(context);
            string completor = UserContext.Current.UserName;
            foreach (var Key in saveModel.DelKeys)
            {
                try
                {
                    var station = repository.Find(x => x.id.ToString() == Key.ToString()).FirstOrDefault();
                    if (!station.stationCode.Contains("X")) throw new Exception($"无{station.stationCode}使用权限!");
                    if (!station.stationCode.Contains("X") && !station.stationCode.Contains("W01001004") && !station.stationCode.Contains("W01001005")) throw new Exception($"无{station.stationCode}使用权限!");
                    if (!station.enable) throw new Exception($"{station.stationCode}未启用!");
                    if (station.location_state == LocationStateEnum.Abnormal.ToString()) throw new Exception($"{station.stationCode}状态异常!");
                    if (station.location_state == LocationStateEnum.Empty.ToString()) throw new Exception($"{station.stationCode}状态为空!");
                    if (station.remark == "桁架下料") throw new Exception($"{station.stationCode}桁架正在下料!");
                    if (agvtaskRepository.Find(x => x.agv_toaddress == station.stationCode).Any()) throw new Exception($"{station.stationCode}存在任务!");
                    
                    if (!agvtaskRepository.Find(x => x.agv_fromaddress == station.stationCode).Any())
                    var task = agvtaskRepository.Find(x => x.agv_toaddress == station.stationCode).FirstOrDefault();
                    if (task != null)
                    {
                        if (task.agv_taskstate != AGVTaskStateEnum.Queue.ToString()) throw new Exception($"{station.stationCode}存在任务!");
                        task.agv_Traytype = station.tray_type == TrayTypeEnum.SmallTray.ToString() ? TrayTypeEnum.LargeTray.ToString() : TrayTypeEnum.SmallTray.ToString();
                        agvtaskRepository.Update(task, x => new { x.agv_Traytype }, true);
                    }
                    else if (!agvtaskRepository.Find(x => x.agv_fromaddress == station.stationCode).Any())
                    {
                        #region ä¸ºç©ºæ‰˜å¹¶ä¸”数量为0,创建取空托任务
                        if (station.tray_status == TrayStateEnum.EmptyTray.ToString() && station.quantity == 0)
´úÂë¹ÜÀí/WMS/WMS_Server/WIDESEA_WebApi/Controllers/JobQueueTask.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,14 @@
using Pomelo.AspNetCore.TimedJob;
using WIDESEA_WMS.Common;
namespace WIDESEA_WebApi.Controllers
{
    public class JobQueueTask : Job
    {
        [Invoke(Begin = "2024-01-01 00:00", Interval = 1000 * 2, /*IsEnabled = true,*/ SkipWhileExecuting = true)]
        public void QueueTaskTiem()
        {
            QueueTask.ReplaceTrayTask();
        }
    }
}
´úÂë¹ÜÀí/WMS/WMS_Server/WIDESEA_WebApi/Controllers/JobSendTask.cs
ÎļþÃû´Ó ´úÂë¹ÜÀí/WMS/WMS_Server/WIDESEA_WebApi/Controllers/JobTask.cs ÐÞ¸Ä
@@ -7,10 +7,10 @@
namespace WIDESEA_WebApi.Controllers
{
    public class JobTask : Job
    public class JobSendTask : Job
    {
        [Invoke(Begin = "2024-01-01 00:00", Interval = 1000 * 5, /*IsEnabled = true,*/ SkipWhileExecuting = true)]
        public void TaskTime()
        public void SendTaskTime()
        {
            AGVServer.SendFromaddress();
            AGVServer.SendToaddress();