huanghongfeng
2025-01-24 829eabf256e29392ca63f6da48829dba3b075dfe
´úÂë¹ÜÀí/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/CommonConveyorLineJob.cs
@@ -73,7 +73,6 @@
                CommonConveyorLine conveyorLine = (CommonConveyorLine)context.JobDetail.JobDataMap.Get("JobParams");
                if (conveyorLine != null)
                {
                    WriteLog.GetLog("Job日志运行").Write(conveyorLine.DeviceCode + "运行日志,开始时间" + DateTime.Now, "Job日志运行");
                    if (conveyorLine.DeviceCode == "1002")
                    {
                        RequestInbound(conveyorLine);   //一楼C,B区业务
@@ -84,20 +83,17 @@
                    }
                    if (conveyorLine.DeviceCode == "1004")
                    {
                        RequestInbound3(conveyorLine);   //一楼C,B区业务
                        RequestInbound3(conveyorLine);
                    }
                }
                WriteLog.GetLog("Job日志运行").Write(conveyorLine.DeviceCode + "运行日志,结束时间" + DateTime.Now, "Job日志运行");
                //RequestInNextAddress(conveyorLine);
            }
            catch (Exception ex)
            {
                //Console.Out.WriteLine(nameof(CommonConveyorLineJob) + ":" + ex.ToString());
                WriteLog.Write_Log("输送线交互", "错误信息", "错误", new { ä¿¡æ¯ = ex.Message });
            }
            finally
            {
@@ -109,8 +105,8 @@
        public void RequestInbound(CommonConveyorLine conveyorLine)
        {
            //1楼输送线判断
            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");  //判断巷道
            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 
@@ -123,11 +119,6 @@
            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"); //原材料出库    è¯»å–条码选库区出库
        }
        public void RequestInbound3(CommonConveyorLine conveyorLine)
@@ -249,58 +240,67 @@
        }
        //新的巷道判断
        private void HandleEvent2(CommonConveyorLine conveyorLine, string eventTag, string barcodeTag, string writeTag)
        private void HandleEvent2(CommonConveyorLine conveyorLine, string eventTag, string barcodeTag, string writeTag,string Platform)
        {
            byte events = conveyorLine.Communicator.Read<byte>(eventTag); // è¯»å–事件
            if (events == 1)
            string barcode = conveyorLine.Communicator.Read<string>(barcodeTag).Trim(); // è¯»å–条码
            if (events == 1 && barcode !="NoRead" && barcode !="" && barcode != null)
            {
                string barcode = conveyorLine.Communicator.Read<string>(barcodeTag).Trim(); // è¯»å–条码
                if (barcode != "1" || barcode != "0")
                WebResponseContent content = _taskService.ToPlatform(barcode);
                if (content != null)
                {
                    WebResponseContent content = _taskService.ToPlatform(barcode);
                    if (content != null)
                    if (content.Status)
                    {
                        if (content.Status)
                        if (content.Data != null)
                        {
                            if (content.Data != null)
                            if (content.Data.ToString() == "1")
                            {
                                if (content.Data.ToString() == "1")
                                if (conveyorLine.Communicator.Read<string>("PLC_WCS_C._03_PLC_LPN") == "")
                                {
                                    if (conveyorLine.Communicator.Read<string>("PLC_WCS_C._03_PLC_LPN") == "")
                                    // å†™å…¥å޻向2号堆垛机
                                    bool result = conveyorLine.Communicator.Write(writeTag, (byte)1);   //写入去向为长巷道
                                    if (result)
                                    {
                                        // å†™å…¥å޻向2号堆垛机
                                        bool result = conveyorLine.Communicator.Write(writeTag, (byte)1);   //写入去向为长巷道
                                        if (result)
                                        {
                                            WriteLog.GetLog("PLC日志").Write($"条码{barcode},写入去向:1", "去向");
                                        }
                                        wcs_PLCto01(Platform + ":成功信息", "成功", $"条码{barcode},写入去向:1");
                                    }
                                }
                                else if (content.Data.ToString() == "3")
                                else
                                {
                                    wcs_PLCto01(Platform + ":错误信息", "错误", $"条码:{barcode},原因:当前需写入去向:1,但读取输送线“堆垛机取货站台”有条码,不可写入去向");
                                }
                            }
                            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);   //写入去向为短巷道
                                    if (result)
                                    {
                                        // å†™å…¥å޻向2号堆垛机
                                        bool result = conveyorLine.Communicator.Write(writeTag, (byte)3);   //写入去向为短巷道
                                        if (result)
                                        {
                                            WriteLog.GetLog("PLC日志").Write($"条码{barcode},写入去向:3", "去向");
                                        }
                                        wcs_PLCto01(Platform + ":成功信息", "成功", $"条码{barcode},写入去向:3");
                                    }
                                }
                                else
                                {
                                    wcs_PLCto01(Platform + ":错误信息", "错误", $"条码:{barcode},原因:当前需写入去向:3,但读取输送线“堆垛机取货站台”有条码,不可写入去向");
                                }
                            }
                            else
                            {
                                wcs_PLCto01(Platform + ":错误信息", "错误", $"条码:{barcode},申请入库失败:未获取到去向");
                            }
                        }
                    }
                }
                else if (barcode == "1")
                {
                    bool result = conveyorLine.Communicator.Write(writeTag, (byte)1);   //空托去向
                    if (result)
                    else
                    {
                        WriteLog.GetLog("PLC日志").Write("空托入库,写入去向:1", "去向");
                        wcs_PLCto01(Platform + ":错误信息", "错误", $"条码:{barcode},申请入库失败:{content.Message}");
                    }
                }
            }
            else
            {
                wcs_PLCto01(Platform+":错误信息", "错误", $"读取到输送线,申请:{events},条码:{barcode}");
            }
        }
@@ -308,63 +308,26 @@
        private void CheckForEmptyPallet(CommonConveyorLine conveyorLine, string eventTag, string barcodeTag, string plcput, string Loc)
        {
            try
            {
                Byte events = conveyorLine.Communicator.Read<Byte>(eventTag);  // è¯»å–事件
                if (events == 1)        //1为空,0为有
                {
                    string barcode = conveyorLine.Communicator.Read<string>(barcodeTag); // è¯»å–条码
                    if (barcode == "")
                    {
                        WriteLog.GetLog("PLC日志出库日志").Write($"读取到出库口补空托信号:{events}", "需要空托");
                        // ç”Ÿæˆå †åž›æœºå–空托任务
                        byte plcputts = conveyorLine.Communicator.Read<byte>(plcput);
                        if (plcputts != 1)
                        {
                            if ((_taskService.RequestWMSTask2("", Loc)).Status)
                            {
                                WriteLog.GetLog("PLC日志出库日志").Write($"已生成空托出库任务:{events}", "需要空托");
                            }
                            else
                            {
                                WriteLog.GetLog("PLC日志出库日志").Write($"未生成空托出库任务:{events}", "需要空托");
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw;
            }
        }
        //用于判断是否出空托 D区
        private void CheckForEmptyPallet2(CommonConveyorLine conveyorLine, string eventTag, string barcodeTag, string plcput, string Loc)
        {
            Byte events = conveyorLine.Communicator.Read<Byte>(eventTag);  // è¯»å–事件
            if (events == 1)        //1为空,0为有
            {
                string barcode = conveyorLine.Communicator.Read<string>(barcodeTag); // è¯»å–条码
                if (barcode != "1" || barcode != "0")
                WebResponseContent content = _taskService.RequestWMSTask2("", Loc);
                // ç”Ÿæˆå †åž›æœºå–空托任务
                if (content.Status)
                {
                    WriteLog.GetLog("PLC日志出库日志").Write($"读取到原材料出库信息,条码信息:{barcode}", "原材料出库");
                    byte outCount = conveyorLine.Communicator.Read<byte>(plcput);
                    if ((_taskService.RequestWMSTask3(barcode, outCount, Loc)).Status)
                    {
                        //写入输送线清除信息
                        WriteLog.GetLog("PLC日志出库日志").Write($"已生成原材料出库任务,条码信息:{barcode}", "原材料出库");
                    }
                    else
                    {
                        WriteLog.GetLog("PLC日志出库日志").Write($"未生成原材料出库任务,条码信息:{barcode}", "原材料出库");
                    }
                    wcs_PLCto02(Loc + ":成功信息", "成功", $"已生成空托出库任务");
                }
                else
                {
                    wcs_PLCto02(Loc + ":错误信息", "错误", $"未生成空托出库任务,错误信息:{content.Message}");
                }
            }
            else
            {
                wcs_PLCto02(Loc + ":错误信息", "错误", $"读取到输送线,申请:{events}");
            }
        }
        //用于判断入库站台
        private void ProcessConveyorEvent(CommonConveyorLine conveyorLine, string eventTag, string barcodeTag, string taskCode, string writeTag)
@@ -372,41 +335,31 @@
            byte eventStatus = conveyorLine.Communicator.Read<byte>(eventTag);
            if (eventStatus == 1)
            {
                WriteLog.GetLog("PLC入库站台日志").Write($"读取到输送线申请入库信息EVENT为:{eventStatus},站台编号为:{taskCode}", "站台信息");
                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 ((_taskService.ToPlatform(barcode)).Status)
                        {
                            WriteLog.GetLog("PLC入库站台日志").Write($"组盘成功,站台编号为:{taskCode}", "站台信息");
                        }
                    }*/
                    // æ‹¿å–托盘条码申请入库信息
                    wcs_PLCto03("去向清除", "成功", $"地址:{writeTag},去向清除为:0");
                    WebResponseContent content = _taskService.RequestWMSTask(barcode, taskCode); // ç”³è¯·å…¥åº“,生成堆垛机任务
                    if (content != null)
                    {
                        if (content.Status)
                        {
                            WriteLog.GetLog("PLC入库站台日志").Write($"申请入库成功,站台编号为:{taskCode}", "站台信息");
                            wcs_PLCto03(taskCode + ":成功信息", "成功", $"条码:{barcode},申请入库成功");
                        }
                        else
                        {
                            WriteLog.GetLog("PLC入库站台日志").Write($"申请入库失败,站台编号为:{taskCode}", "站台信息");
                            wcs_PLCto03(taskCode+ ":错误信息", "错误", $"条码:{barcode},申请入库失败,错误信息:{content.Message}");
                        }
                    }
                    else
                    {
                        wcs_PLCto03(taskCode + ":错误信息", "错误", $"条码:{barcode},申请入库失败,错误信息content返回值为空");
                    }
                }
                else
                {
                    WriteLog.GetLog("PLC入库站台日志").Write($"读取到输送线信息为空,站台编号为:{taskCode}", "站台信息");
                    wcs_PLCto03(taskCode + ":错误信息", "错误", $"读取到输送线信息为空");
                }
            }
            else if (eventStatus == 6)
@@ -416,61 +369,59 @@
                    WebResponseContent content = _taskService.RequestWMSTask4();
                    if (content != null)
                    {
                        if (content.Status)
                        if(content.Status && content.Data != null)
                        {
                            if (content.Data != null)
                            if (content.Data.ToString() == "1")
                            {
                                if (content.Data.ToString() == "1")
                                if (conveyorLine.Communicator.Write(writeTag, (byte)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}", "空托入库去向");
                                        }
                                    }
                                    wcs_PLCto04(taskCode + ":成功信息", "成功", $"写入成功,去向:1");
                                }
                                else if (content.Data.ToString() == "3")
                                else
                                {
                                    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}", "空托入库去向");
                                        }
                                    }
                                    wcs_PLCto04(taskCode + ":错误信息", "错误", $"写入失败,去向:1");
                                }
                            }
                            else if (content.Data.ToString() == "3")
                            {
                                if (conveyorLine.Communicator.Write(writeTag, (byte)3))
                                {
                                    wcs_PLCto04(taskCode + ":成功信息", "成功", $"写入成功,去向:3");
                                }
                                else
                                {
                                    wcs_PLCto04(taskCode + ":错误信息", "错误", $"写入失败,去向:3");
                                }
                            }
                            else
                            {
                                wcs_PLCto04(taskCode + ":错误信息", "错误", $"未找到写入去向");
                            }
                        }
                        else
                        {
                            wcs_PLCto04(taskCode + ":错误信息", "错误", $"申请入库失败,错误信息:{content.Message}");
                        }
                    }
                    else
                    {
                        wcs_PLCto04(taskCode + ":错误信息", "错误", $"申请入库失败,错误信息:content返回值为空");
                    }
                }
                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))
                    {
                        if (conveyorLine.Communicator.Write(writeTag, (byte)1))
                        {
                            WriteLog.GetLog("PLC入库站台日志").Write($"写入成功,去向:1,站台编号为:{taskCode}", "空托入库去向");
                        }
                        else
                        {
                            WriteLog.GetLog("PLC入库站台日志").Write($"写入失败,去向:1,站台编号为:{taskCode}", "空托入库去向");
                        }
                        wcs_PLCto04(taskCode + ":成功信息", "成功", $"写入失败,去向:1");
                    }
                    else
                    {
                        wcs_PLCto04(taskCode + ":错误信息", "错误", $"写入失败,去向:1");
                    }
                }
            }
        }
        public bool SetLine(CommonConveyorLine conveyorLine, string DeviceProDataBlock, byte Pali)
@@ -490,5 +441,27 @@
        {
            WriteLog.GetLog("堆垛机与plc交互信号").Write($"站台编号:{sourceAddress},信息:{message}", $"{sourceAddress}");
        }
        public void wcs_PLCto01(string SCLLinStack, string Logtype, string Magessadd)
        {
            WriteLog.Write_Log("一楼扫码站台", SCLLinStack, Logtype, new { ä¿¡æ¯ = Magessadd });
        }
        public void wcs_PLCto02(string SCLLinStack, string Logtype, string Magessadd)
        {
            WriteLog.Write_Log("一楼补空托", SCLLinStack, Logtype, new { ä¿¡æ¯ = Magessadd });
        }
        public void wcs_PLCto03(string SCLLinStack, string Logtype, string Magessadd)
        {
            WriteLog.Write_Log("入库站台", SCLLinStack, Logtype, new { ä¿¡æ¯ = Magessadd });
        }
        public void wcs_PLCto04(string SCLLinStack, string Logtype, string Magessadd)
        {
            WriteLog.Write_Log("顶楼空托回库", SCLLinStack, Logtype, new { ä¿¡æ¯ = Magessadd });
        }
    }
}