1
huanghongfeng
2024-11-21 4cfeced9bc8985cdd89fdb540e6fe984f8469481
´úÂë¹ÜÀí/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;
@@ -75,7 +76,15 @@
                    {
                        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区业务
                    }
                }
@@ -97,11 +106,13 @@
        public void RequestInbound(CommonConveyorLine conveyorLine)
        {
            //1楼输送线判断
            HandleEvent(conveyorLine, "PLC_WCS_B._03_PLC_EVENT", "PLC_WCS_B._03_PLC_LPN", "WCS_PLC_B._03_WCS_TO");  //判断巷道
            HandleEvent(conveyorLine, "PLC_WCS_C._02_PLC_EVENT", "PLC_WCS_C._02_PLC_LPN", "WCS_PLC_C._02_WCS_TO");  //判断巷道
            HandleEvent2(conveyorLine, "PLC_WCS_B._03_PLC_EVENT", "PLC_WCS_B._03_PLC_LPN", "WCS_PLC_B._03_WCS_TO");  //判断巷道
            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_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
        }
@@ -120,11 +131,11 @@
        public void RequestInbound3(CommonConveyorLine conveyorLine)
        {
            ProcessConveyorEvent(conveyorLine, "PLC_WCS_A._02_PLC_EVENT", "PLC_WCS_A._02_PLC_LPN", "R02-003-043-011-01", "WCS_PLC_A._02_WCS_TO");// å¤„理 A21 ç«™å°äº‹ä»¶å…¥åº“
            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-003-042-011-01", "WCS_PLC_A._03_WCS_TO");// å¤„理 A22 ç«™å°äº‹ä»¶ å…¥æ–™
            //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"); //用于写入输送线条码信息,用于出库
            //ConveyorLineInFinish(conveyorLine,"R01-002-044-001-01"); //用于写入输送线条码信息,用于出库
        }
        public void ConveyorLineInFinish(CommonConveyorLine conveyorLine,string SCAddress)
@@ -196,11 +207,14 @@
                    {
                        if ((_taskService.ToPlatform(barcode)).Status)
                        {
                            // å†™å…¥å޻向2号堆垛机
                            bool result = conveyorLine.Communicator.Write(writeTag, (byte)1);   //原材料去向
                            if (result)
                            {
                                WriteLog.GetLog("PLC日志").Write("写入去向: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("写入去向:3", "去向");
                                }
                            }
                        }
                    }
@@ -235,7 +249,63 @@
            }
        }
        //用于判断是否补空托
        //新的巷道判断
        private void HandleEvent2(CommonConveyorLine conveyorLine, string eventTag, string barcodeTag, string writeTag)
        {
            byte events = conveyorLine.Communicator.Read<byte>(eventTag); // è¯»å–事件
            if (events == 1)
            {
                string barcode = conveyorLine.Communicator.Read<string>(barcodeTag).Trim(); // è¯»å–条码
                if (barcode != "1" || barcode != "0")
                {
                    WebResponseContent content = _taskService.ToPlatform(barcode);
                    if(content != null)
                    {
                        if (content.Status)
                        {
                            if(content.Data != null)
                            {
                                if (content.Data.ToString() == "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 (barcode == "1")
                {
                    bool result = conveyorLine.Communicator.Write(writeTag, (byte)1);   //空托去向
                    if (result)
                    {
                        WriteLog.GetLog("PLC日志").Write("空托入库,写入去向:1", "去向");
                    }
                }
            }
        }
        //用于判断是否补空托 A区
        private void CheckForEmptyPallet(CommonConveyorLine conveyorLine,string eventTag, string barcodeTag,string plcput,string Loc)
        {
@@ -262,8 +332,6 @@
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
@@ -273,7 +341,7 @@
            }
        }
        //用于判断是否出空托
        //用于判断是否出空托 D区
        private void CheckForEmptyPallet2(CommonConveyorLine conveyorLine, string eventTag, string barcodeTag, string plcput, string Loc)
        {
            Byte events = conveyorLine.Communicator.Read<Byte>(eventTag);  // è¯»å–事件
@@ -306,23 +374,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-011-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)