huanghongfeng
2024-11-22 426848306ad9233db96e4b3fc68a881c15f0b0b0
´úÂë¹ÜÀí/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/CommonConveyorLineJob.cs
@@ -21,6 +21,7 @@
using OfficeOpenXml.FormulaParsing.Excel.Functions.Math;
using OfficeOpenXml.FormulaParsing.Excel.Functions.Text;
using Quartz;
using SqlSugar;
using StackExchange.Profiling.Internal;
using System;
using System.Collections.Generic;
@@ -71,14 +72,24 @@
                CommonConveyorLine conveyorLine = (CommonConveyorLine)context.JobDetail.JobDataMap.Get("JobParams");
                if ( conveyorLine != null )
                {
                    if(conveyorLine.DeviceCode == "1002")
                    WriteLog.GetLog("Job日志运行").Write(conveyorLine.DeviceCode + "运行日志,开始时间" + DateTime.Now, "Job日志运行");
                    if (conveyorLine.DeviceCode == "1002")
                    {
                        RequestInbound(conveyorLine);   //一楼C,B区业务
                    }
                    /*if (conveyorLine.DeviceCode == "1003")
                    {
                        _taskService.RequestWMSTask3("FK240711D2",1, "R02-002-027-011-01");
                    }*/
                    if (conveyorLine.DeviceCode == "1004")
                    {
                        RequestInbound3(conveyorLine);   //一楼C,B区业务
                    }
                }
                WriteLog.GetLog("Job日志运行").Write(conveyorLine.DeviceCode+"运行日志,结束时间"+DateTime.Now, "Job日志运行");
                //RequestInNextAddress(conveyorLine);
@@ -110,14 +121,14 @@
        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");  //判断入库巷道
            //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巷道 ç«™å°äº‹ä»¶ å…¥ç©º
            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"); //写入输送线去向
            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"); //原材料出库    è¯»å–条码选库区出库
            //ConveyorLineInFinish(conveyorLine); //用于写入输送线条码信息,暂时未用
            //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"); //原材料出库    è¯»å–条码选库区出库
        }
        public void RequestInbound3(CommonConveyorLine conveyorLine)
@@ -140,10 +151,10 @@
                    Dt_Task task = _taskService.IngStackerCraneTask2(conveyorLine.DeviceCode);
                    if(task != null && task.TaskType==(int)TaskOutboundTypeEnum.Outbound)
                    {
                        byte PalletType = 2;
                        if (task.TargetAddress == "R02-002-027-001-01" || task.TargetAddress == "R01-002-041-001-01")
                        byte PLCtypeTo = 1;
                        if (task.TargetAddress == "R02-002-027-011-01")
                        {
                            PalletType = 1;
                            PLCtypeTo = 2;
                        }
                        DeviceProDTO? deviceProDTO3 = GetDeviceProDTO(conveyorLine, SCAddress, "W_PalletBarcode");          //写入条码
                        DeviceProDTO? deviceProDTO4 = GetDeviceProDTO(conveyorLine, SCAddress, "W_PalletLayers");           //层数
@@ -151,7 +162,7 @@
                        DeviceProDTO? deviceProDTO6 = GetDeviceProDTO(conveyorLine, SCAddress, "W_Destination");           //类型
                        if (deviceProDTO3 != null && deviceProDTO4 != null && deviceProDTO5 != null && deviceProDTO6 != null)
                        {
                            if (SetLinestring(conveyorLine, deviceProDTO3.DeviceProDataBlock, task.PalletCode) && SetLine(conveyorLine, deviceProDTO4.DeviceProDataBlock, (byte)task.PalletCodequantity) && SetLine(conveyorLine, deviceProDTO5.DeviceProDataBlock, PalletType) && SetLine(conveyorLine, deviceProDTO6.DeviceProDataBlock, (byte)task.PLCTo))
                            if (SetLinestring(conveyorLine, deviceProDTO3.DeviceProDataBlock, task.PalletCode) && SetLine(conveyorLine, deviceProDTO4.DeviceProDataBlock, (byte)task.PalletCodequantity) && SetLine(conveyorLine, deviceProDTO5.DeviceProDataBlock, PLCtypeTo) && SetLine(conveyorLine, deviceProDTO6.DeviceProDataBlock, (byte)task.PLCTo))
                            {
                                LogSignalStatus($"写入放货完成信息,托盘条码,层数,类型信息成功", deviceProDTO2.DeviceChildCode);
@@ -243,53 +254,56 @@
        //新的巷道判断
        private void HandleEvent2(CommonConveyorLine conveyorLine, string eventTag, string barcodeTag, string writeTag)
        {
            try
            byte events = conveyorLine.Communicator.Read<byte>(eventTag); // è¯»å–事件
            if (events == 1)
            {
                byte events = conveyorLine.Communicator.Read<byte>(eventTag); // è¯»å–事件
                if (events == 1)
                string barcode = conveyorLine.Communicator.Read<string>(barcodeTag).Trim(); // è¯»å–条码
                if (barcode != "1" || barcode != "0")
                {
                    string barcode = conveyorLine.Communicator.Read<string>(barcodeTag); // è¯»å–条码
                    if (barcode != "1" || barcode != "0")
                    WebResponseContent content = _taskService.ToPlatform(barcode);
                    if(content != null)
                    {
                        WebResponseContent content = _taskService.ToPlatform(barcode);
                        if ((int)content.Data == 1)
                        if (content.Status)
                        {
                            if (conveyorLine.Communicator.Read<string>("PLC_WCS_B._01_PLC_LPN") == "")
                            if(content.Data != null)
                            {
                                // å†™å…¥å޻向2号堆垛机
                                bool result = conveyorLine.Communicator.Write(writeTag, (byte)1);   //写入去向为长巷道
                                if (result)
                                if (content.Data.ToString() == "1")
                                {
                                    WriteLog.GetLog("PLC日志").Write($"条码{barcode},写入去向:1", "去向");
                                    if (conveyorLine.Communicator.Read<string>("PLC_WCS_C._03_PLC_LPN") == "")
                                    {
                                        // å†™å…¥å޻向2号堆垛机
                                        bool result = conveyorLine.Communicator.Write(writeTag, (byte)1);   //写入去向为长巷道
                                        if (result)
                                        {
                                            WriteLog.GetLog("PLC日志").Write($"条码{barcode},写入去向:1", "去向");
                                        }
                                    }
                                }
                                else if (content.Data.ToString() == "3")
                                {
                                    if (conveyorLine.Communicator.Read<string>("PLC_WCS_B._01_PLC_LPN") == "")
                                    {
                                        // å†™å…¥å޻向2号堆垛机
                                        bool result = conveyorLine.Communicator.Write(writeTag, (byte)3);   //写入去向为短巷道
                                        if (result)
                                        {
                                            WriteLog.GetLog("PLC日志").Write($"条码{barcode},写入去向:3", "去向");
                                        }
                                    }
                                }
                            }
                        }else if ((int)content.Data == 3)
                        {
                            if (conveyorLine.Communicator.Read<string>("PLC_WCS_C._03_PLC_LPN") == "")
                            {
                                // å†™å…¥å޻向2号堆垛机
                                bool result = conveyorLine.Communicator.Write(writeTag, (byte)3);   //写入去向为短巷道
                                if (result)
                                {
                                    WriteLog.GetLog("PLC日志").Write($"条码{barcode},写入去向:3", "去向");
                                }
                            }
                        }
                    }else if (barcode == "1")
                    {
                        bool result = conveyorLine.Communicator.Write(writeTag, (byte)1);   //空托去向
                        if (result)
                        {
                            WriteLog.GetLog("PLC日志").Write("空托入库,写入去向:1", "去向");
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw;
                else if (barcode == "1")
                {
                    bool result = conveyorLine.Communicator.Write(writeTag, (byte)1);   //空托去向
                    if (result)
                    {
                        WriteLog.GetLog("PLC日志").Write("空托入库,写入去向:1", "去向");
                    }
                }
            }
        }
        
@@ -362,23 +376,23 @@
            if (eventStatus == 1)
            {
                WriteLog.GetLog("PLC入库站台日志").Write($"读取到输送线申请入库信息EVENT为:{eventStatus},站台编号为:{taskCode}", "站台信息");
                string barcode = conveyorLine.Communicator.Read<string>(barcodeTag);
                if(barcode == "1")
                string barcode = conveyorLine.Communicator.Read<string>(barcodeTag).Trim();
                /*if(barcode == "1")
                {
                    string currentTime = DateTime.Now.ToString("HHmmss");
                    barcode = "KTP" + currentTime;
                }
                }*/
                if (barcode != null)
                {
                    bool result = conveyorLine.Communicator.Write(writeTag, (byte)0);
                    if(taskCode== "R01-003-042-001-01")
                    /*if(taskCode== "R01-003-042-001-01")
                    {
                        if ((_taskService.ToPlatform(barcode)).Status)
                        {
                            WriteLog.GetLog("PLC入库站台日志").Write($"组盘成功,站台编号为:{taskCode}", "站台信息");
                        }
                    }
                    }*/
                    // æ‹¿å–托盘条码申请入库信息
                    WebResponseContent content = _taskService.RequestWMSTask(barcode, taskCode); // ç”³è¯·å…¥åº“,生成堆垛机任务
                    if (content !=null)