1
huanghongfeng
2024-11-26 87d873ad509b4c927ac19aebaa3622fe9374626b
´úÂë¹ÜÀí/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/CommonConveyorLineJob.cs
@@ -20,6 +20,7 @@
using OfficeOpenXml.FormulaParsing.Excel.Functions.DateTime;
using OfficeOpenXml.FormulaParsing.Excel.Functions.Math;
using OfficeOpenXml.FormulaParsing.Excel.Functions.Text;
using OfficeOpenXml.Packaging.Ionic.Zip;
using Quartz;
using SqlSugar;
using StackExchange.Profiling.Internal;
@@ -66,21 +67,21 @@
        public Task Execute(IJobExecutionContext context)
        {
            try
            {
                CommonConveyorLine conveyorLine = (CommonConveyorLine)context.JobDetail.JobDataMap.Get("JobParams");
                if ( conveyorLine != null )
                if (conveyorLine != null)
                {
                    WriteLog.GetLog("Job日志运行").Write(conveyorLine.DeviceCode + "运行日志,开始时间" + DateTime.Now, "Job日志运行");
                    if (conveyorLine.DeviceCode == "1002")
                    {
                        RequestInbound(conveyorLine);   //一楼C,B区业务
                    }
                    /*if (conveyorLine.DeviceCode == "1003")
                    if (conveyorLine.DeviceCode == "1003")
                    {
                        _taskService.RequestWMSTask3("FK240711D2",1, "R02-002-027-011-01");
                    }*/
                        RequestInbound2(conveyorLine);
                    }
                    if (conveyorLine.DeviceCode == "1004")
                    {
                        RequestInbound3(conveyorLine);   //一楼C,B区业务
@@ -89,7 +90,7 @@
                }
                WriteLog.GetLog("Job日志运行").Write(conveyorLine.DeviceCode+"运行日志,结束时间"+DateTime.Now, "Job日志运行");
                WriteLog.GetLog("Job日志运行").Write(conveyorLine.DeviceCode + "运行日志,结束时间" + DateTime.Now, "Job日志运行");
                //RequestInNextAddress(conveyorLine);
@@ -112,8 +113,6 @@
            HandleEvent2(conveyorLine, "PLC_WCS_C._02_PLC_EVENT", "PLC_WCS_C._02_PLC_LPN", "WCS_PLC_C._02_WCS_TO");  //判断巷道
            CheckForEmptyPallet(conveyorLine, "PLC_WCS_B._02_PLC_EVENT", "PLC_WCS_B._02_PLC_LPN", "PLC_WCS_B._02_PLC_PUT", "R02-002-027-001-01"); //判断是否取空托出库
            CheckForEmptyPallet(conveyorLine, "PLC_WCS_C._01_PLC_EVENT", "PLC_WCS_C._01_PLC_LPN", "PLC_WCS_C._01_PLC_PUT", "R01-002-041-001-01"); //判断是否取空托出库
            ProcessConveyorEvent(conveyorLine, "PLC_WCS_B._01_PLC_EVENT", "PLC_WCS_B._01_PLC_LPN", "R02-003-027-001-01", "WCS_PLC_B._03_WCS_TO");// å¤„理 B 
            ProcessConveyorEvent(conveyorLine, "PLC_WCS_C._03_PLC_EVENT", "PLC_WCS_C._03_PLC_LPN", "R01-003-041-001-01", "WCS_PLC_C._02_WCS_TO");// å¤„理 C
        }
@@ -121,11 +120,11 @@
        public void RequestInbound2(CommonConveyorLine conveyorLine)
        {
            //顶楼楼输送线判断
            //HandleEvent(conveyorLine, "PLC_WCS_D._05_PLC_EVENT", "PLC_WCS_D._05_PLC_LPN", "WCS_PLC_D._05_WCS_TO");  //判断入库巷道
            //ProcessConveyorEvent(conveyorLine, "PLC_WCS_D._01_PLC_EVENT", "PLC_WCS_D._01_PLC_LPN", "R02-003-027-011-01", "WCS_PLC_D._05_WCS_TO");// å¤„理 1巷道 ç«™å°äº‹ä»¶å…¥ç©º
            //ProcessConveyorEvent(conveyorLine, "PLC_WCS_D._03_PLC_EVENT", "PLC_WCS_D._03_PLC_LPN", "R01-003-041-011-01", "WCS_PLC_D._05_WCS_TO");// å¤„理 2巷道 ç«™å°äº‹ä»¶ å…¥ç©º
            ConveyorLineInFinish(conveyorLine, "R02-002-027-011-01"); //写入输送线去向
            ProcessConveyorEvent(conveyorLine, "PLC_WCS_D._01_PLC_EVENT", "PLC_WCS_D._01_PLC_LPN", "R01-003-041-011-01", "WCS_PLC_D._01_WCS_TO");// å¤„理 1巷道 ç«™å°äº‹ä»¶å…¥ç©º
            ProcessConveyorEvent(conveyorLine, "PLC_WCS_D._03_PLC_EVENT", "PLC_WCS_D._03_PLC_LPN", "R02-003-027-011-01", "WCS_PLC_D._03_WCS_TO");// å¤„理 2巷道 ç«™å°äº‹ä»¶ å…¥ç©º
            //ConveyorLineInFinish(conveyorLine, "R02-002-027-011-01"); //写入输送线去向
            //CheckForEmptyPallet2(conveyorLine, "PLC_WCS_D._02_PLC_EVENT", "PLC_WCS_D._02_PLC_LPN", "PLC_WCS_D._02_PLC_PUT", "R02-002-027-011-01"); //原材料出库    è¯»å–条码选库区出库
            //CheckForEmptyPallet2(conveyorLine, "PLC_WCS_D._04_PLC_EVENT", "PLC_WCS_D._04_PLC_LPN", "PLC_WCS_D._04_PLC_PUT", "R01-002-041-011-01"); //原材料出库    è¯»å–条码选库区出库
@@ -135,21 +134,19 @@
        {
            ProcessConveyorEvent(conveyorLine, "PLC_WCS_A._02_PLC_EVENT", "PLC_WCS_A._02_PLC_LPN", "R01-002-043-001-01", "WCS_PLC_A._02_WCS_TO");// å¤„理 A21 ç«™å°äº‹ä»¶å…¥åº“
            //ProcessConveyorEvent(conveyorLine, "PLC_WCS_A._03_PLC_EVENT", "PLC_WCS_A._03_PLC_LPN", "R01-002-042-001-01", "WCS_PLC_A._03_WCS_TO");// å¤„理 A22 ç«™å°äº‹ä»¶ å…¥æ–™
            //ConveyorLineInFinish(conveyorLine,"R01-002-044-001-01"); //用于写入输送线条码信息,用于出库
            ProcessConveyorEvent(conveyorLine, "PLC_WCS_A._03_PLC_EVENT", "PLC_WCS_A._03_PLC_LPN", "R01-002-042-001-01", "WCS_PLC_A._03_WCS_TO");// å¤„理 A22 ç«™å°äº‹ä»¶ å…¥æ–™
        }
        public void ConveyorLineInFinish(CommonConveyorLine conveyorLine,string SCAddress)
        public void ConveyorLineInFinish(CommonConveyorLine conveyorLine, string SCAddress)
        {
            DeviceProDTO? deviceProDTO2 = GetDeviceProDTO(conveyorLine,SCAddress, "R_StackerCraneLowered");    //读取输送线 â€œå †åž›æœºæ”¾ä¸‹â€ ä¿¡å·
            if ( deviceProDTO2 != null )
            DeviceProDTO? deviceProDTO2 = GetDeviceProDTO(conveyorLine, SCAddress, "R_StackerCraneLowered");    //读取输送线 â€œå †åž›æœºæ”¾ä¸‹â€ ä¿¡å·
            if (deviceProDTO2 != null)
            {
                byte strsd = GetLine(conveyorLine, deviceProDTO2.DeviceChildCode);
                if (strsd == 1)
                {
                    Dt_Task task = _taskService.IngStackerCraneTask2(conveyorLine.DeviceCode);
                    if(task != null && task.TaskType==(int)TaskOutboundTypeEnum.Outbound)
                    if (task != null && task.TaskType == (int)TaskOutboundTypeEnum.Outbound)
                    {
                        byte PLCtypeTo = 1;
                        if (task.TargetAddress == "R02-002-027-011-01")
@@ -182,7 +179,7 @@
                    }
                }
            }
        }
        //获取输送线实例
        public DeviceProDTO? GetDeviceProDTO(CommonConveyorLine conveyorLine, string SCAddress, string Interactivet)
@@ -197,7 +194,7 @@
        /// <param name="eventTag"></param>
        /// <param name="barcodeTag"></param>
        /// <param name="writeTag"></param>
        private void HandleEvent(CommonConveyorLine conveyorLine,string eventTag, string barcodeTag, string writeTag)
        private void HandleEvent(CommonConveyorLine conveyorLine, string eventTag, string barcodeTag, string writeTag)
        {
            try
            {
@@ -205,11 +202,11 @@
                if (events == 1)
                {
                    string barcode = conveyorLine.Communicator.Read<string>(barcodeTag); // è¯»å–条码
                    if(barcode != "1" || barcode != "0")
                    if (barcode != "1" || barcode != "0")
                    {
                        if ((_taskService.ToPlatform(barcode)).Status)
                        {
                            if(conveyorLine.Communicator.Read<string>("PLC_WCS_B._01_PLC_LPN")=="")
                            if (conveyorLine.Communicator.Read<string>("PLC_WCS_B._01_PLC_LPN") == "")
                            {
                                // å†™å…¥å޻向2号堆垛机
                                bool result = conveyorLine.Communicator.Write(writeTag, (byte)3);   //原材料去向
@@ -261,11 +258,11 @@
                if (barcode != "1" || barcode != "0")
                {
                    WebResponseContent content = _taskService.ToPlatform(barcode);
                    if(content != null)
                    if (content != null)
                    {
                        if (content.Status)
                        {
                            if(content.Data != null)
                            if (content.Data != null)
                            {
                                if (content.Data.ToString() == "1")
                                {
@@ -282,7 +279,7 @@
                                else if (content.Data.ToString() == "3")
                                {
                                    if (conveyorLine.Communicator.Read<string>("PLC_WCS_B._01_PLC_LPN") == "")
                                    if (conveyorLine.Communicator.Read<string>("PLC_WCS_B._01_PLC_LPN") == "")
                                    {
                                        // å†™å…¥å޻向2号堆垛机
                                        bool result = conveyorLine.Communicator.Write(writeTag, (byte)3);   //写入去向为短巷道
@@ -306,9 +303,9 @@
                }
            }
        }
        //用于判断是否补空托 A区
        private void CheckForEmptyPallet(CommonConveyorLine conveyorLine,string eventTag, string barcodeTag,string plcput,string Loc)
        private void CheckForEmptyPallet(CommonConveyorLine conveyorLine, string eventTag, string barcodeTag, string plcput, string Loc)
        {
            try
@@ -317,11 +314,11 @@
                if (events == 1)        //1为空,0为有
                {
                    string barcode = conveyorLine.Communicator.Read<string>(barcodeTag); // è¯»å–条码
                    if(barcode == "")
                    if (barcode == "")
                    {
                        WriteLog.GetLog("PLC日志出库日志").Write($"读取到出库口补空托信号:{events}", "需要空托");
                        // ç”Ÿæˆå †åž›æœºå–空托任务
                        byte plcputts = conveyorLine.Communicator.Read<byte>(plcput);
                        byte plcputts = conveyorLine.Communicator.Read<byte>(plcput);
                        if (plcputts != 1)
                        {
                            if ((_taskService.RequestWMSTask2("", Loc)).Status)
@@ -355,7 +352,7 @@
                    WriteLog.GetLog("PLC日志出库日志").Write($"读取到原材料出库信息,条码信息:{barcode}", "原材料出库");
                    byte outCount = conveyorLine.Communicator.Read<byte>(plcput);
                    if ((_taskService.RequestWMSTask3(barcode, outCount,Loc)).Status)
                    if ((_taskService.RequestWMSTask3(barcode, outCount, Loc)).Status)
                    {
                        //写入输送线清除信息
                        WriteLog.GetLog("PLC日志出库日志").Write($"已生成原材料出库任务,条码信息:{barcode}", "原材料出库");
@@ -366,11 +363,11 @@
                    }
                }
            }
        }
        //用于判断入库站台
        private void ProcessConveyorEvent(CommonConveyorLine conveyorLine, string eventTag, string barcodeTag, string taskCode,string writeTag)
        private void ProcessConveyorEvent(CommonConveyorLine conveyorLine, string eventTag, string barcodeTag, string taskCode, string writeTag)
        {
            byte eventStatus = conveyorLine.Communicator.Read<byte>(eventTag);
            if (eventStatus == 1)
@@ -395,7 +392,7 @@
                    }*/
                    // æ‹¿å–托盘条码申请入库信息
                    WebResponseContent content = _taskService.RequestWMSTask(barcode, taskCode); // ç”³è¯·å…¥åº“,生成堆垛机任务
                    if (content !=null)
                    if (content != null)
                    {
                        if (content.Status)
                        {
@@ -412,6 +409,69 @@
                    WriteLog.GetLog("PLC入库站台日志").Write($"读取到输送线信息为空,站台编号为:{taskCode}", "站台信息");
                }
            }
            else if (eventStatus == 6)
            {
                if (taskCode == "R02-003-027-011-01")
                {
                    WebResponseContent content = _taskService.RequestWMSTask4();
                    if (content != null)
                    {
                        if (content.Status)
                        {
                            if (content.Data != null)
                            {
                                if (content.Data.ToString() == "1")
                                {
                                    if (conveyorLine.Communicator.Read<string>("PLC_WCS_D._01_PLC_LPN") == "")
                                    {
                                        if (conveyorLine.Communicator.Write(writeTag, (byte)1))
                                        {
                                            WriteLog.GetLog("PLC入库站台日志").Write($"写入成功,去向:1,站台编号为:{taskCode}", "空托入库去向");
                                        }
                                        else
                                        {
                                            WriteLog.GetLog("PLC入库站台日志").Write($"写入失败,去向:1,站台编号为:{taskCode}", "空托入库去向");
                                        }
                                    }
                                }
                                else if (content.Data.ToString() == "3")
                                {
                                    if (conveyorLine.Communicator.Read<string>("PLC_WCS_D._03_PLC_LPN") == "")
                                    {
                                        if (conveyorLine.Communicator.Write(writeTag, (byte)3))
                                        {
                                            WriteLog.GetLog("PLC入库站台日志").Write($"写入成功,去向:3,站台编号为:{taskCode}", "空托入库去向");
                                        }
                                        else
                                        {
                                            WriteLog.GetLog("PLC入库站台日志").Write($"写入失败,去向:3,站台编号为:{taskCode}", "空托入库去向");
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                else if (taskCode == "R01-003-041-011-01")
                {
                    if (conveyorLine.Communicator.Read<string>("PLC_WCS_D._03_PLC_LPN") == "")
                    {
                        if (conveyorLine.Communicator.Write(writeTag, (byte)1))
                        {
                            WriteLog.GetLog("PLC入库站台日志").Write($"写入成功,去向:1,站台编号为:{taskCode}", "空托入库去向");
                        }
                        else
                        {
                            WriteLog.GetLog("PLC入库站台日志").Write($"写入失败,去向:1,站台编号为:{taskCode}", "空托入库去向");
                        }
                    }
                }
            }
        }
        public bool SetLine(CommonConveyorLine conveyorLine, string DeviceProDataBlock, byte Pali)
        {
@@ -421,7 +481,7 @@
        {
            return conveyorLine.Communicator.Write(DeviceProDataBlock, Pali);
        }
        public byte GetLine(CommonConveyorLine conveyorLine, string DeviceProDataBlock)
        {
            return conveyorLine.Communicator.Read<byte>(DeviceProDataBlock);