1
huanghongfeng
2024-12-02 e2a5657e3a0b8615bcd78a3149e5ba9ce5579bb8
´úÂë¹ÜÀí/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs
@@ -1,17 +1,26 @@
using Microsoft.AspNetCore.Components.Routing;
using Autofac.Core;
using Microsoft.AspNetCore.Components.Routing;
using Microsoft.AspNetCore.Hosting;
using OfficeOpenXml.FormulaParsing.Excel.Functions.RefAndLookup;
using Quartz;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Diagnostics.Eventing.Reader;
using System.Linq;
using System.Reflection.Metadata;
using System.Text;
using System.Threading.Tasks;
using WIDESEA_Common.Log;
using WIDESEAWCS_Common.TaskEnum;
using WIDESEAWCS_Core;
using WIDESEAWCS_Core.Enums;
using WIDESEAWCS_ITaskInfoRepository;
using WIDESEAWCS_ITaskInfoService;
using WIDESEAWCS_Model.Models;
using WIDESEAWCS_QuartzJob;
using WIDESEAWCS_QuartzJob.DeviceBase;
using WIDESEAWCS_QuartzJob.DTO;
using WIDESEAWCS_QuartzJob.Models;
using WIDESEAWCS_QuartzJob.Service;
using WIDESEAWCS_QuartzJob.StackerCrane.Enum;
@@ -42,6 +51,8 @@
                CommonStackerCrane commonStackerCrane = (CommonStackerCrane)context.JobDetail.JobDataMap.Get("JobParams");
                if (commonStackerCrane != null)
                {
                    Signalinteraction(commonStackerCrane);  //出库信号交互
                    Siganlinteraction2(commonStackerCrane); //入库信号交互
                    if (!commonStackerCrane.IsEventSubscribed)
                    {
                        commonStackerCrane.StackerCraneTaskCompletedEventHandler += CommonStackerCrane_StackerCraneTaskCompletedEventHandler;//订阅任务完成事件
@@ -105,7 +116,7 @@
        private Dt_Task? GetTask(CommonStackerCrane commonStackerCrane)
        {
            Dt_Task task;
            if (commonStackerCrane.LastTaskType == null)
            /*if (commonStackerCrane.LastTaskType == null)
            {
                task = _taskService.QueryStackerCraneTask(commonStackerCrane.DeviceCode);
            }
@@ -123,18 +134,43 @@
                {
                    task = _taskService.QueryStackerCraneOutTask(commonStackerCrane.DeviceCode);
                }
            }
            }*/
            task = _taskService.QueryStackerCraneTask(commonStackerCrane.DeviceCode);
            if (task != null && task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup)
            if (task != null && task.TaskType== (int)TaskOutboundTypeEnum.Outbound)
            {
                if (OutTaskStationIsOccupied(task) != null)
                string[] targetCodes = task.SourceAddress.Split("-");
                if (targetCodes[4] == "02")
                {
                    task = OutTaskMovelibrary(task);
                    if (task != null)
                    {
                        if (OutTaskStationIsOccupied(task) != null)
                        {
                            return task;
                        }
                    }
                }
                else
                {
                    if (OutTaskStationIsOccupied(task) != null)
                    {
                        return task;
                    }
                    task = _taskService.QueryStackerCraneInTask(commonStackerCrane.DeviceCode);
                }
                /*if (OutTaskStationIsOccupied(task) != null)
                {
                    return task;
                }
                else
                {
                    List<string> otherOutStaionCodes = _routerService.QueryNextRoutes(commonStackerCrane.DeviceCode, task.NextAddress).Select(x => x.ChildPosi).ToList();
                    List<Dt_Task> tasks = _taskService.QueryStackerCraneOutTasks(commonStackerCrane.DeviceCode, otherOutStaionCodes);
                    List<Dt_Task> tasks = _taskService.QueryStackerCraneOutTasks(commonStackerCrane.DeviceCode);
                    foreach (var item in tasks)
                    {
                        if (OutTaskStationIsOccupied(task) != null)
@@ -142,10 +178,9 @@
                            return task;
                        }
                    }
                    task = _taskService.QueryStackerCraneInTask(commonStackerCrane.DeviceCode);
                }
                    //task = _taskService.QueryStackerCraneInTask(commonStackerCrane.DeviceCode);
                }*/
            }
            return task;
        }
@@ -156,28 +191,904 @@
        /// <returns>如果未被占用,返回传入的任务信息,否则,返回null</returns>
        private Dt_Task? OutTaskStationIsOccupied([NotNull] Dt_Task task)
        {
            Dt_Router? router = _routerService.QueryNextRoutes(task.Roadway, task.NextAddress).FirstOrDefault();
            if (router != null)
            IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceProDTOs.Exists(x => x.DeviceChildCode == task.TargetAddress));
            if (device != null)
            {
                IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == router.ChildPosiDeviceCode);
                if (device != null)
                CommonConveyorLine conveyorLine = (CommonConveyorLine)device;
                DeviceProDTO? deviceProDTO = GetDeviceProDTO(conveyorLine, task.TargetAddress, "R_Event");    //根据堆垛机地址,地址名称找协议
                if (deviceProDTO != null)
                {
                    CommonConveyorLine conveyorLine = (CommonConveyorLine)device;
                    if (conveyorLine.IsOccupied(router.ChildPosi))//出库站台未被占用
                    int B_Event_Test = GetLine(conveyorLine, deviceProDTO.DeviceProDataBlock);        //判断输送线是否允许放货信号
                    if (B_Event_Test == 1)
                    {
                        return task;
                    }
                }
            }
            else
            {
                _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"未找到出库站台【{task.TargetAddress}】对应的通讯对象,无法判断出库站台是否被占用");
            }
            return null;
        }
        /// <summary>
        /// å‡ºåº“任务判断是否需要进行移库Move the library
        /// </summary>
        /// <param name="task">任务实体</param>
        /// <returns>如果未被占用,返回传入的任务信息,否则,返回null</returns>
        private Dt_Task? OutTaskMovelibrary([NotNull] Dt_Task task)
        {
            try
            {
                string[] targetCodes = task.SourceAddress.Split("-");
                if (targetCodes[1] == "001")
                {
                    targetCodes[1] = "002";
                }
                else if (targetCodes[1] == "004")
                {
                    targetCodes[1] = "003";
                }
                targetCodes[4] = "01";
                string SourceAddress = string.Join("-", targetCodes); //组装浅库位地址
                Dt_Task? tasks = _taskService.QueryStationIsOccupiedOutTasks(task.Roadway, SourceAddress).FirstOrDefault();
                if (tasks != null)
                {
                    return tasks;
                }
                else
                {
                    _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"未找到出库站台【{router.ChildPosiDeviceCode}】对应的通讯对象,无法判断出库站台是否被占用");
                    //向wms申请判断浅库位是否有货,是否需要进行移库
                    Dt_Task? taskst = _taskService.RequestWMSTaskMovelibrary(task);
                    if (taskst != null)
                    {
                        return taskst;
                    }
                }
            }
            catch (Exception ex)
            {
                throw;
            }
            return null;
        }
        public void Signalinteraction(CommonStackerCrane commonStackerCrane)
        {
            if (Applyrelease(commonStackerCrane)) //读取堆垛机放货申请
            {
                Dt_Task task = _taskService.IngStackerCraneTask2(commonStackerCrane.DeviceCode);
                if (task.TaskType == (int)TaskOutboundTypeEnum.Outbound)
                {
                    IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceProDTOs.Exists(x => x.DeviceChildCode == task.TargetAddress));
                    if (device != null)
                    {
                        CommonConveyorLine conveyorLine = (CommonConveyorLine)device;
                        DeviceProDTO? deviceProDTO = GetDeviceProDTO(conveyorLine, task.TargetAddress, "R_Event");    //根据堆垛机地址,地址名称找协议
                        if (deviceProDTO != null)
                        {
                            int B_Event_Test = GetLine(conveyorLine, deviceProDTO.DeviceProDataBlock);        //判断输送线是否允许放货信号
                            if (B_Event_Test == 1)
                            {
                                if (Releasespermitted(commonStackerCrane, task.TargetAddress,true))  //写入堆垛机允许放货信
                                {
                                    WriteLog.GetLog("堆垛机信号").Write($"站台编号:{task.TargetAddress},任务号:{task.TaskNum},信息:写入堆垛机允许放货信号成功:true", $"(放货)写入{task.TargetAddress}");
                                }
                                else
                                {
                                    WriteLog.GetLog("堆垛机信号").Write($"站台编号:{task.TargetAddress},任务号:{task.TaskNum},信息:写入堆垛机允许放货信号失败", $"(放货)写入{task.TargetAddress}");
                                }
                            }
                            else
                            {
                                if (Releasespermitted(commonStackerCrane, task.TargetAddress,false))  //写入堆垛机不允许放货信
                                {
                                    WriteLog.GetLog("堆垛机信号").Write($"站台编号:{task.TargetAddress},任务号:{task.TaskNum},信息:写入堆垛机不允许放货信号成功:false", $"(放货)写入{task.TargetAddress}");
                                }
                                else
                                {
                                    WriteLog.GetLog("堆垛机信号").Write($"站台编号:{task.TargetAddress},任务号:{task.TaskNum},信息:写入堆垛机不允许放货信号失败", $"(放货)写入{task.TargetAddress}");
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"未找到站台【{task.NextAddress}】信息,无法校验站台");
                Dt_Task task = _taskService.IngStackerCraneTask2(commonStackerCrane.DeviceCode);
                if (task !=null && task.TaskType == (int)TaskOutboundTypeEnum.Outbound)
                {
                    if (Completesignal(commonStackerCrane, task.TargetAddress))        //读取到放货完成信号
                    {
                        IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceProDTOs.Exists(x => x.DeviceChildCode == task.TargetAddress));
                        if (device != null)
                        {
                            CommonConveyorLine conveyorLine = (CommonConveyorLine)device;
                            if (task.TargetAddress == "R02-002-027-011-01" || task.TargetAddress == "R01-002-041-011-01")   //写入输送线去向
                            {
                                byte PLCtost = (byte)task.PLCTo;
                                if (PLCSignal2(conveyorLine, task.TargetAddress, "W_Destination", PLCtost))
                                {
                                    WriteLog.GetLog("输送线").Write($"站台编号:{task.TargetAddress},任务号:{task.TaskNum},信息:写入去向成功,去向为:{PLCtost}", $"出料口去向");
                                }
                                else
                                {
                                    WriteLog.GetLog("输送线").Write($"站台编号:{task.TargetAddress},任务号:{task.TaskNum},信息:写入去向失败,去向为:{PLCtost}", $"出料口去向");
                                }
                            }
                            if (PLCSignal(conveyorLine, task.TargetAddress, (byte)1)) //写入输送线 å †åž›æœºæ”¾è´§ ä¿¡å·
                            {
                                //读取输送线反馈  å †åž›æœºæ”¾ä¸‹ä¿¡å·
                                DeviceProDTO? deviceProDTO2 = GetDeviceProDTO(conveyorLine, task.TargetAddress, "R_StackerCraneLowered");    //输送线协议找读取信号
                                if (deviceProDTO2 != null)
                                {
                                    int B_TAKE = GetLine(conveyorLine, deviceProDTO2.DeviceProDataBlock);        //读取输送线的  å †åž›æœºæ”¾ä¸‹ ä¿¡å·
                                    WriteLog.GetLog("输送线").Write($"站台编号:{task.TargetAddress},任务号:{task.TaskNum},信息:读取到输送线-堆垛机放下信号:{B_TAKE}", $"(放货)读取{task.TargetAddress}");
                                    if (B_TAKE == 1)
                                    {
                                        if (task.TargetAddress == "R02-002-027-011-01" || task.TargetAddress == "R01-002-041-011-01")
                                        {
                                            DeviceProDTO? deviceProDTO3 = GetDeviceProDTO(conveyorLine, task.TargetAddress, "R_Destination");
                                            if (deviceProDTO3 != null)
                                            {
                                                int PLCwcstost = GetLine(conveyorLine, deviceProDTO3.DeviceProDataBlock);
                                                if (PLCwcstost == task.PLCTo)
                                                {
                                                    byte PLCtost2 = 0;
                                                    if (PLCSignal2(conveyorLine, task.TargetAddress, "W_Destination", PLCtost2))
                                                    {
                                                        WriteLog.GetLog("输送线").Write($"站台编号:{task.TargetAddress},任务号:{task.TaskNum},信息:清除去向成功", $"出料口去向");
                                                    }
                                                    else
                                                    {
                                                        WriteLog.GetLog("输送线").Write($"站台编号:{task.TargetAddress},任务号:{task.TaskNum},信息:清除去向失败", $"出料口去向");
                                                    }
                                                    // æ¸…除输送线
                                                    if (PLCSignal(conveyorLine, task.TargetAddress, (byte)0))
                                                    {
                                                        WriteLog.GetLog("输送线").Write($"站台编号:{task.TargetAddress},任务号:{task.TaskNum},信息:写入输送线清除-堆垛机放下信号成功", $"出料口去向");
                                                    }
                                                    else
                                                    {
                                                        WriteLog.GetLog("输送线").Write($"站台编号:{task.TargetAddress},任务号:{task.TaskNum},信息:写入输送线清除-堆垛机放下信号失败", $"出料口去向");
                                                    }
                                                    //堆垛机写完成
                                                    if (Releasespermitted4(commonStackerCrane, task.TargetAddress, true))
                                                    {
                                                        WriteLog.GetLog("堆垛机信号").Write($"站台编号:{task.TargetAddress},任务号:{task.TaskNum},信息:写入堆垛机放下信号成功:true", $"出料口去向");
                                                    }
                                                    else
                                                    {
                                                        WriteLog.GetLog("堆垛机信号").Write($"站台编号:{task.TargetAddress},任务号:{task.TaskNum},信息:写入堆垛机放下信号失败:true", $"出料口去向");
                                                    }
                                                }
                                                else
                                                {
                                                    WriteLog.GetLog("输送线").Write($"站台编号:{task.TargetAddress},任务号:{task.TaskNum},信息:去向比对不一致,输送线去向为:{PLCwcstost},wcs写入去向为:{task.PLCTo}", $"出料口去向");
                                                }
                                            }
                                        }
                                        if (task.TargetAddress != "R02-002-027-011-01" && task.TargetAddress != "R01-002-041-011-01")
                                        {
                                            // æ¸…除输送线
                                            if (PLCSignal(conveyorLine, task.TargetAddress, 0))
                                            {
                                                WriteLog.GetLog("输送线").Write($"站台编号:{task.TargetAddress},任务号:{task.TaskNum},信息:写入输送线清除-堆垛机放下信号成功", $"(放货)读取{task.TargetAddress}");
                                            }
                                            else
                                            {
                                                WriteLog.GetLog("输送线").Write($"站台编号:{task.TargetAddress},任务号:{task.TaskNum},信息:写入输送线清除-堆垛机放下信号失败", $"(放货)读取{task.TargetAddress}");
                                            }
                                            //堆垛机写完成
                                            if (Releasespermitted4(commonStackerCrane, task.TargetAddress, true))
                                            {
                                                WriteLog.GetLog("堆垛机信号").Write($"站台编号:{task.TargetAddress},任务号:{task.TaskNum},信息:写入堆垛机放下信号成功:true", $"(放货)写入{task.TargetAddress}");
                                            }
                                            else
                                            {
                                                WriteLog.GetLog("堆垛机信号").Write($"站台编号:{task.TargetAddress},任务号:{task.TaskNum},信息:写入堆垛机放下信号失败:true", $"(放货)写入{task.TargetAddress}");
                                            }
                                        }
                                    }
                                    else
                                    {
                                        // æ¸…除输送线
                                        if (PLCSignal(conveyorLine, task.TargetAddress, 0))
                                        {
                                            WriteLog.GetLog("输送线").Write($"站台编号:{task.TargetAddress},任务号:{task.TaskNum},信息:未读取到输送线反馈堆垛机完成反馈信号,重置为0", $"(放货)读取{task.TargetAddress}");
                                        }
                                        else
                                        {
                                            WriteLog.GetLog("输送线").Write($"站台编号:{task.TargetAddress},任务号:{task.TaskNum},信息:未读取到输送线反馈堆垛机完成反馈信号,重置为0", $"(放货)读取{task.TargetAddress}");
                                        }
                                    }
                                }
                            }
                            else
                            {
                                WriteLog.GetLog("输送线").Write($"站台编号:{task.TargetAddress},任务号:{task.TaskNum},信息:写入输送线0-堆垛机放下信号失败", $"(放货)写入{task.TargetAddress}");
                            }
                        }
                    }
                    else
                    {
                        WriteLog.GetLog("堆垛机信号").Write($"站台编号:{task.TargetAddress},任务号:{task.TaskNum},信息:未读取到堆垛机放货完成信号", $"(放货)写入{task.TargetAddress}");
                    }
                }
            }
            return null;
        }
        public void Siganlinteraction2(CommonStackerCrane commonStackerCrane)
        {
            Dt_Task task = _taskService.IngStackerCraneTask(commonStackerCrane.DeviceCode);
            if (task != null && task.TaskType == (int)TaskInboundTypeEnum.Inbound)
            {
                IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceProDTOs.Exists(x => x.DeviceChildCode == task.SourceAddress));
                if (device != null)
                {
                    CommonConveyorLine conveyorLine = (CommonConveyorLine)device;
                    DeviceProDTO? deviceProDTO = GetDeviceProDTO(conveyorLine, task.SourceAddress, "R_Event");    //根据堆垛机地址,地址名称找协议
                    if (deviceProDTO != null)
                    {
                        int B_Event_Test = GetLine(conveyorLine, deviceProDTO.DeviceProDataBlock);        //判断输送线是否允许取货信号
                        if (B_Event_Test == 1)
                        {
                            if (Releasespermitted2(commonStackerCrane, task.SourceAddress,true))  //写入堆垛机允许取货信号
                            {
                                WriteLog.GetLog("堆垛机信号").Write($"站台编号:{task.SourceAddress},信息:写入堆垛机允许取货信号成功:true", $"(取货)写入{task.SourceAddress}");
                            }
                            else
                            {
                                WriteLog.GetLog("堆垛机信号").Write($"站台编号:{task.SourceAddress},信息:写入堆垛机允许取货信号失败", $"(取货)写入{task.SourceAddress}");
                            }
                        }
                        else
                        {
                            if (Releasespermitted2(commonStackerCrane, task.SourceAddress,false))  //写入堆垛机允许取货信号
                            {
                                WriteLog.GetLog("堆垛机信号").Write($"站台编号:{task.SourceAddress},信息:未读取到输送线允许取货信号,写入堆垛机允许取货信号成功:false", $"(取货)写入{task.SourceAddress}");
                            }
                            else
                            {
                                WriteLog.GetLog("堆垛机信号").Write($"站台编号:{task.SourceAddress},信息:未读取到输送线允许取货信号,写入堆垛机允许取货信号失败", $"(取货)写入{task.SourceAddress}");
                            }
                        }
                    }
                    if (Completesignal2(commonStackerCrane, task.SourceAddress))    //读取堆垛机取货完成信号
                    {
                        if(PLCSignal2(conveyorLine, task.SourceAddress, "W_StackerCranePicked", 1))    //写入输送线取货完成信号
                        {
                            DeviceProDTO? deviceProDTO2 = GetDeviceProDTO(conveyorLine, task.SourceAddress, "R_StackerCranePicked");    //输送线协议找读取信号
                            if (deviceProDTO != null)
                            {
                                int B_TAKE = GetLine(conveyorLine, deviceProDTO2.DeviceProDataBlock);        //读取输送线的  å †åž›æœºå–èµ° ä¿¡å·
                                if (B_TAKE == 1)
                                {
                                    //写入给堆垛机,输送线的  å †åž›æœºå–èµ° ä¿¡å·
                                    if(Releasespermitted3(commonStackerCrane, task.SourceAddress,true))
                                    {
                                        WriteLog.GetLog("堆垛机信号").Write($"站台编号:{task.SourceAddress},信息:写入堆垛机取走信号成功:true", $"(取货)写入{task.SourceAddress}");
                                    }
                                    else
                                    {
                                        WriteLog.GetLog("堆垛机信号").Write($"站台编号:{task.SourceAddress},信息:写入堆垛机取走信号失败:true", $"(取货)写入{task.SourceAddress}");
                                    }
                                }
                                else
                                {
                                    if (Releasespermitted3(commonStackerCrane, task.SourceAddress,false))
                                    {
                                        WriteLog.GetLog("堆垛机信号").Write($"站台编号:{task.SourceAddress},信息:未读取输送线的堆垛机取走信号,写入堆垛机取走信号成功:false", $"(取货)写入{task.SourceAddress}");
                                    }
                                    else
                                    {
                                        WriteLog.GetLog("堆垛机信号").Write($"站台编号:{task.SourceAddress},信息:未读取输送线的堆垛机取走信号,写入堆垛机取走信号失败:false", $"(取货)写入{task.SourceAddress}");
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        if (PLCSignal2(conveyorLine, task.SourceAddress, "W_StackerCranePicked", 0))    //写入输送线清除信号
                        {
                            DeviceProDTO? deviceProDTO2 = GetDeviceProDTO(conveyorLine, task.SourceAddress, "R_StackerCranePicked");    //输送线协议找读取信号
                            if (deviceProDTO != null)
                            {
                                int B_TAKE = GetLine(conveyorLine, deviceProDTO2.DeviceProDataBlock);        //读取输送线的  å †åž›æœºå–èµ° ä¿¡å·
                                if (B_TAKE == 0)
                                {
                                    //写入给堆垛机,输送线的  å †åž›æœºå–èµ° ä¿¡å·
                                    if (Releasespermitted3(commonStackerCrane, task.SourceAddress, false))
                                    {
                                        WriteLog.GetLog("堆垛机信号").Write($"站台编号:{task.SourceAddress},信息:写入堆垛机取走信号成功:true", $"(取货)写入{task.SourceAddress}");
                                    }
                                    else
                                    {
                                        WriteLog.GetLog("堆垛机信号").Write($"站台编号:{task.SourceAddress},信息:写入堆垛机取走信号失败:true", $"(取货)写入{task.SourceAddress}");
                                    }
                                }
                                else
                                {
                                    if (Releasespermitted3(commonStackerCrane, task.SourceAddress, false))
                                    {
                                        WriteLog.GetLog("堆垛机信号").Write($"站台编号:{task.SourceAddress},信息:未读取输送线的堆垛机取走信号,写入堆垛机取走信号成功:false", $"(取货)写入{task.SourceAddress}");
                                    }
                                    else
                                    {
                                        WriteLog.GetLog("堆垛机信号").Write($"站台编号:{task.SourceAddress},信息:未读取输送线的堆垛机取走信号,写入堆垛机取走信号失败:false", $"(取货)写入{task.SourceAddress}");
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        //获取输送线实例
        public DeviceProDTO? GetDeviceProDTO(CommonConveyorLine conveyorLine,string SCAddress,string Interactivet)
        {
            return conveyorLine.DeviceProDTOs.FirstOrDefault(x => x.DeviceChildCode == SCAddress && x.DeviceProParamName == Interactivet);
        }
        //获取堆垛机例
        public DeviceProDTO? GetDeviceProDTO2(CommonStackerCrane commonStackerCrane, string DeviceName, string Interactivet)
        {
            return commonStackerCrane.DeviceProDTOs.FirstOrDefault(x => x.DeviceChildCode == DeviceName && x.DeviceProParamName == Interactivet);
        }
        //读取堆垛机申请放货信号
        public bool Applyrelease(CommonStackerCrane commonStackerCrane)
        {
            if (commonStackerCrane.DeviceCode == "SC02")
            {
                DeviceProDTO? deviceProDTO = GetDeviceProDTO2(commonStackerCrane, commonStackerCrane.DeviceCode, "DeliveryRequest_Bout");
                if (deviceProDTO != null)
                {
                    if(GetStacker(commonStackerCrane, deviceProDTO.DeviceProAddress).Status)
                    {
                        return true;
                    }
                }
                DeviceProDTO? deviceProDTO2 = GetDeviceProDTO2(commonStackerCrane, commonStackerCrane.DeviceCode, "DeliveryRequest_Dout");
                if (deviceProDTO2 != null)
                {
                    if (GetStacker(commonStackerCrane, deviceProDTO2.DeviceProAddress).Status)
                    {
                        return true;
                    }
                }
            }
            if (commonStackerCrane.DeviceCode == "SC01")
            {
                DeviceProDTO? deviceProDTO4 = GetDeviceProDTO2(commonStackerCrane, commonStackerCrane.DeviceCode, "DeliveryRequest_Cout");
                if (deviceProDTO4 != null)
                {
                    if (GetStacker(commonStackerCrane, deviceProDTO4.DeviceProAddress).Status)
                    {
                        return true;
                    }
                }
                DeviceProDTO? deviceProDTO3 = GetDeviceProDTO2(commonStackerCrane, commonStackerCrane.DeviceCode, "DeliveryRequest_Dout");
                if (deviceProDTO3 != null)
                {
                    if (GetStacker(commonStackerCrane, deviceProDTO3.DeviceProAddress).Status)
                    {
                        return true;
                    }
                }
                DeviceProDTO? deviceProDTO5 = GetDeviceProDTO2(commonStackerCrane, commonStackerCrane.DeviceCode, "DeliveryRequest_Aout");
                if (deviceProDTO5 != null)
                {
                    if(GetStacker(commonStackerCrane, deviceProDTO5.DeviceProAddress).Status)
                    {
                        return true;
                    }
                }
                DeviceProDTO? deviceProDTO6 = GetDeviceProDTO2(commonStackerCrane, commonStackerCrane.DeviceCode, "DeliveryRequest_A2in");  //空托出入库
                if (deviceProDTO6 != null)
                {
                    if (GetStacker(commonStackerCrane, deviceProDTO6.DeviceProAddress).Status)
                    {
                        return true;
                    }
                }
            }
            return false;
        }
        //写入堆垛机允许放货信号
        public bool Releasespermitted(CommonStackerCrane commonStackerCrane, string Destinationaddress,bool SCcrane)
        {
            if (Destinationaddress == "R02-002-027-001-01")
            {
                DeviceProDTO? deviceProDTO = GetDeviceProDTO2(commonStackerCrane, commonStackerCrane.DeviceCode, "DeliveryPermission_Bout");
                if (deviceProDTO != null)
                {
                    if(SetStacker(commonStackerCrane, deviceProDTO.DeviceProAddress, SCcrane).Status) { return true; }
                }
            }
            if (Destinationaddress == "R02-002-027-011-01")
            {
                DeviceProDTO? deviceProDTO = GetDeviceProDTO2(commonStackerCrane, commonStackerCrane.DeviceCode, "DeliveryPermission_Dout");
                if (deviceProDTO != null)
                {
                    if (SetStacker(commonStackerCrane, deviceProDTO.DeviceProAddress, SCcrane).Status) { return true; }
                }
            }
            //1号
            if (Destinationaddress == "R01-002-041-001-01")
            {
                DeviceProDTO? deviceProDTO = GetDeviceProDTO2(commonStackerCrane, commonStackerCrane.DeviceCode, "DeliveryPermission_Cout");
                if (deviceProDTO != null)
                {
                    if (SetStacker(commonStackerCrane, deviceProDTO.DeviceProAddress, SCcrane).Status) { return true; }
                }
            }
            if (Destinationaddress == "R01-002-041-011-01")
            {
                DeviceProDTO? deviceProDTO = GetDeviceProDTO2(commonStackerCrane, commonStackerCrane.DeviceCode, "DeliveryPermission_Dout");
                if (deviceProDTO != null)
                {
                    if (SetStacker(commonStackerCrane, deviceProDTO.DeviceProAddress, SCcrane).Status) { return true; }
                }
            }
            if (Destinationaddress == "R01-002-044-001-01")
            {
                DeviceProDTO? deviceProDTO = GetDeviceProDTO2(commonStackerCrane, commonStackerCrane.DeviceCode, "DeliveryPermission_Aout");
                if (deviceProDTO != null)
                {
                   if(SetStacker(commonStackerCrane, deviceProDTO.DeviceProAddress, SCcrane).Status) { return true; }
                }
            }
            if (Destinationaddress == "R01-002-043-001-01")
            {
                DeviceProDTO? deviceProDTO = GetDeviceProDTO2(commonStackerCrane, commonStackerCrane.DeviceCode, "DeliveryPermission_A2in");
                if (deviceProDTO != null)
                {
                    if (SetStacker(commonStackerCrane, deviceProDTO.DeviceProAddress, SCcrane).Status) { return true; }
                }
            }
            return false;
        }
        //读取堆垛机的放货完成信号
        public bool Completesignal(CommonStackerCrane commonStackerCrane,string Destinationaddress)
        {
            if (Destinationaddress == "R02-002-027-001-01")
            {
                DeviceProDTO? deviceProDTO = GetDeviceProDTO2(commonStackerCrane, commonStackerCrane.DeviceCode, "DeliveryCompleted_Bout");
                if (deviceProDTO != null)
                {
                    if(GetStacker(commonStackerCrane, deviceProDTO.DeviceProAddress).Status)
                    {
                        return true;
                    }
                }
            }
            if (Destinationaddress == "R02-002-027-011-01")
            {
                DeviceProDTO? deviceProDTO = GetDeviceProDTO2(commonStackerCrane, commonStackerCrane.DeviceCode, "DeliveryCompleted_Dout");
                if (deviceProDTO != null)
                {
                    if (GetStacker(commonStackerCrane, deviceProDTO.DeviceProAddress).Status)
                    {
                        return true;
                    }
                }
            }
            //1号
            if (Destinationaddress == "R01-002-041-001-01")
            {
                DeviceProDTO? deviceProDTO = GetDeviceProDTO2(commonStackerCrane, commonStackerCrane.DeviceCode, "DeliveryCompleted_Cout");
                if (deviceProDTO != null)
                {
                    if (GetStacker(commonStackerCrane, deviceProDTO.DeviceProAddress).Status)
                    {
                        return true;
                    }
                }
            }
            if (Destinationaddress == "R01-002-041-011-01")
            {
                DeviceProDTO? deviceProDTO = GetDeviceProDTO2(commonStackerCrane, commonStackerCrane.DeviceCode, "DeliveryCompleted_Dout");
                if (deviceProDTO != null)
                {
                    if (GetStacker(commonStackerCrane, deviceProDTO.DeviceProAddress).Status)
                    {
                        return true;
                    }
                }
            }
            if (Destinationaddress == "R01-002-044-001-01")
            {
                DeviceProDTO? deviceProDTO = GetDeviceProDTO2(commonStackerCrane, commonStackerCrane.DeviceCode, "DeliveryCompleted_Aout");
                if (deviceProDTO != null)
                {
                    if (GetStacker(commonStackerCrane, deviceProDTO.DeviceProAddress).Status)
                    {
                        return true;
                    }
                }
            }
            if (Destinationaddress == "R01-002-043-001-01")
            {
                DeviceProDTO? deviceProDTO = GetDeviceProDTO2(commonStackerCrane, commonStackerCrane.DeviceCode, "DeliveryCompleted_A2in");
                if (deviceProDTO != null)
                {
                    if (GetStacker(commonStackerCrane, deviceProDTO.DeviceProAddress).Status)
                    {
                        return true;
                    }
                }
            }
            return false;
        }
        //写入堆垛机放货确认信号
        public bool Releasespermitted4(CommonStackerCrane commonStackerCrane, string Destinationaddress, bool SCcrane)
        {
            if (Destinationaddress == "R02-002-027-001-01")
            {
                DeviceProDTO? deviceProDTO = GetDeviceProDTO2(commonStackerCrane, commonStackerCrane.DeviceCode, "DeliveryCompletion_Bout");
                if (deviceProDTO != null)
                {
                    if (SetStacker(commonStackerCrane, deviceProDTO.DeviceProAddress, SCcrane).Status) { return true; }
                }
            }
            if (Destinationaddress == "R02-002-027-011-01")
            {
                DeviceProDTO? deviceProDTO = GetDeviceProDTO2(commonStackerCrane, commonStackerCrane.DeviceCode, "DeliveryCompletion_Dout");
                if (deviceProDTO != null)
                {
                    if (SetStacker(commonStackerCrane, deviceProDTO.DeviceProAddress, SCcrane).Status) { return true; }
                }
            }
            //1号
            if (Destinationaddress == "R01-002-041-001-01")
            {
                DeviceProDTO? deviceProDTO = GetDeviceProDTO2(commonStackerCrane, commonStackerCrane.DeviceCode, "DeliveryCompletion_Cout");
                if (deviceProDTO != null)
                {
                    if (SetStacker(commonStackerCrane, deviceProDTO.DeviceProAddress, SCcrane).Status) { return true; }
                }
            }
            if (Destinationaddress == "R01-002-041-011-01")
            {
                DeviceProDTO? deviceProDTO = GetDeviceProDTO2(commonStackerCrane, commonStackerCrane.DeviceCode, "DeliveryCompletion_Dout");
                if (deviceProDTO != null)
                {
                    if (SetStacker(commonStackerCrane, deviceProDTO.DeviceProAddress, SCcrane).Status) { return true; }
                }
            }
            if (Destinationaddress == "R01-002-044-001-01")
            {
                DeviceProDTO? deviceProDTO = GetDeviceProDTO2(commonStackerCrane, commonStackerCrane.DeviceCode, "DeliveryCompletion_Aout");
                if (deviceProDTO != null)
                {
                    if (SetStacker(commonStackerCrane, deviceProDTO.DeviceProAddress, SCcrane).Status) { return true; }
                }
            }
            if (Destinationaddress == "R01-002-043-001-01")
            {
                DeviceProDTO? deviceProDTO = GetDeviceProDTO2(commonStackerCrane, commonStackerCrane.DeviceCode, "DeliveryCompletion_A2in");
                if (deviceProDTO != null)
                {
                    if (SetStacker(commonStackerCrane, deviceProDTO.DeviceProAddress, SCcrane).Status) { return true; }
                }
            }
            return false;
        }
        //写入堆垛机允许取货信号
        public bool Releasespermitted2(CommonStackerCrane commonStackerCrane, string Destinationaddress, bool SCcrane)
        {
            if (Destinationaddress == "R02-003-027-001-01")
            {
                DeviceProDTO? deviceProDTO = GetDeviceProDTO2(commonStackerCrane, commonStackerCrane.DeviceCode, "PickupRequest_Bin");
                if (deviceProDTO != null)
                {
                    if (SetStacker(commonStackerCrane, deviceProDTO.DeviceProAddress, SCcrane).Status) { return true; }
                }
            }
            if (Destinationaddress == "R02-003-027-011-01")
            {
                DeviceProDTO? deviceProDTO = GetDeviceProDTO2(commonStackerCrane, commonStackerCrane.DeviceCode, "PickupRequest_Din");
                if (deviceProDTO != null)
                {
                    if (SetStacker(commonStackerCrane, deviceProDTO.DeviceProAddress, SCcrane).Status) { return true; }
                }
            }
            //1号
            if (Destinationaddress == "R01-003-041-001-01")
            {
                DeviceProDTO? deviceProDTO = GetDeviceProDTO2(commonStackerCrane, commonStackerCrane.DeviceCode, "PickupRequest_Cin");
                if (deviceProDTO != null)
                {
                    if (SetStacker(commonStackerCrane, deviceProDTO.DeviceProAddress, SCcrane).Status) { return true; }
                }
            }
            if (Destinationaddress == "R01-003-041-011-01")
            {
                DeviceProDTO? deviceProDTO = GetDeviceProDTO2(commonStackerCrane, commonStackerCrane.DeviceCode, "PickupRequest_Din");
                if (deviceProDTO != null)
                {
                    if (SetStacker(commonStackerCrane, deviceProDTO.DeviceProAddress, SCcrane).Status) { return true; }
                }
            }
            if (Destinationaddress == "R01-002-042-001-01")
            {
                DeviceProDTO? deviceProDTO = GetDeviceProDTO2(commonStackerCrane, commonStackerCrane.DeviceCode, "PickupRequest_Ain");
                if (deviceProDTO != null)
                {
                    if (SetStacker(commonStackerCrane, deviceProDTO.DeviceProAddress, SCcrane).Status) { return true; }
                }
            }
            if (Destinationaddress == "R01-002-043-001-01")
            {
                DeviceProDTO? deviceProDTO = GetDeviceProDTO2(commonStackerCrane, commonStackerCrane.DeviceCode, "PickupRequest_A2in");
                if (deviceProDTO != null)
                {
                    if (SetStacker(commonStackerCrane, deviceProDTO.DeviceProAddress, SCcrane).Status) { return true; }
                }
            }
            return false;
        }
        //读取堆垛机取货完成信号
        public bool Completesignal2(CommonStackerCrane commonStackerCrane, string Destinationaddress)
        {
            if (Destinationaddress == "R02-003-027-001-01")
            {
                DeviceProDTO? deviceProDTO = GetDeviceProDTO2(commonStackerCrane, commonStackerCrane.DeviceCode, "PickupCompleted_Bin");
                if (deviceProDTO != null)
                {
                    if (GetStacker(commonStackerCrane, deviceProDTO.DeviceProAddress).Status)
                    {
                        return true;
                    }
                }
            }
            if (Destinationaddress == "R02-003-027-011-01")
            {
                DeviceProDTO? deviceProDTO = GetDeviceProDTO2(commonStackerCrane, commonStackerCrane.DeviceCode, "PickupCompleted_Din");
                if (deviceProDTO != null)
                {
                    if (GetStacker(commonStackerCrane, deviceProDTO.DeviceProAddress).Status)
                    {
                        return true;
                    }
                }
            }
            //1号
            if (Destinationaddress == "R01-003-041-001-01")
            {
                DeviceProDTO? deviceProDTO = GetDeviceProDTO2(commonStackerCrane, commonStackerCrane.DeviceCode, "PickupCompleted_Cin");
                if (deviceProDTO != null)
                {
                    if (GetStacker(commonStackerCrane, deviceProDTO.DeviceProAddress).Status)
                    {
                        return true;
                    }
                }
            }
            if (Destinationaddress == "R01-003-041-011-01")
            {
                DeviceProDTO? deviceProDTO = GetDeviceProDTO2(commonStackerCrane, commonStackerCrane.DeviceCode, "PickupCompleted_Din");
                if (deviceProDTO != null)
                {
                    if (GetStacker(commonStackerCrane, deviceProDTO.DeviceProAddress).Status)
                    {
                        return true;
                    }
                }
            }
            if (Destinationaddress == "R01-002-042-001-01")
            {
                DeviceProDTO? deviceProDTO = GetDeviceProDTO2(commonStackerCrane, commonStackerCrane.DeviceCode, "PickupCompleted_Ain");
                if (deviceProDTO != null)
                {
                    if (GetStacker(commonStackerCrane, deviceProDTO.DeviceProAddress).Status)
                    {
                        return true;
                    }
                }
            }
            if (Destinationaddress == "R01-002-043-001-01")
            {
                DeviceProDTO? deviceProDTO = GetDeviceProDTO2(commonStackerCrane, commonStackerCrane.DeviceCode, "PickupCompleted_A2in");
                if (deviceProDTO != null)
                {
                    if (GetStacker(commonStackerCrane, deviceProDTO.DeviceProAddress).Status)
                    {
                        return true;
                    }
                }
            }
            return false;
        }
        //写入堆垛机取货确认信号
        public bool Releasespermitted3(CommonStackerCrane commonStackerCrane, string Destinationaddress, bool SCcrane)
        {
            if (Destinationaddress == "R02-003-027-001-01")
            {
                DeviceProDTO? deviceProDTO = GetDeviceProDTO2(commonStackerCrane, commonStackerCrane.DeviceCode, "PickupCompletion_Bin");
                if (deviceProDTO != null)
                {
                    if (SetStacker(commonStackerCrane, deviceProDTO.DeviceProAddress, SCcrane).Status) { return true; }
                }
            }
            if (Destinationaddress == "R02-003-027-011-01")
            {
                DeviceProDTO? deviceProDTO = GetDeviceProDTO2(commonStackerCrane, commonStackerCrane.DeviceCode, "PickupCompletion_Din");
                if (deviceProDTO != null)
                {
                    if (SetStacker(commonStackerCrane, deviceProDTO.DeviceProAddress, SCcrane).Status) { return true; }
                }
            }
            //1号
            if (Destinationaddress == "R01-003-041-001-01")
            {
                DeviceProDTO? deviceProDTO = GetDeviceProDTO2(commonStackerCrane, commonStackerCrane.DeviceCode, "PickupCompletion_Cin");
                if (deviceProDTO != null)
                {
                    if (SetStacker(commonStackerCrane, deviceProDTO.DeviceProAddress, SCcrane).Status) { return true; }
                }
            }
            if (Destinationaddress == "R01-003-041-011-01")
            {
                DeviceProDTO? deviceProDTO = GetDeviceProDTO2(commonStackerCrane, commonStackerCrane.DeviceCode, "PickupCompletion_Din");
                if (deviceProDTO != null)
                {
                    if (SetStacker(commonStackerCrane, deviceProDTO.DeviceProAddress, SCcrane).Status) { return true; }
                }
            }
            if (Destinationaddress == "R01-002-042-001-01")
            {
                DeviceProDTO? deviceProDTO = GetDeviceProDTO2(commonStackerCrane, commonStackerCrane.DeviceCode, "PickupCompletion_Ain");
                if (deviceProDTO != null)
                {
                    if (SetStacker(commonStackerCrane, deviceProDTO.DeviceProAddress, SCcrane).Status) { return true; }
                }
            }
            if (Destinationaddress == "R01-002-043-001-01")
            {
                DeviceProDTO? deviceProDTO = GetDeviceProDTO2(commonStackerCrane, commonStackerCrane.DeviceCode, "PickupCompletion_A2in");
                if (deviceProDTO != null)
                {
                    if (SetStacker(commonStackerCrane, deviceProDTO.DeviceProAddress, SCcrane).Status) { return true; }
                }
            }
            return false;
        }
        //写入输送线放货完成信号,条码,层数,类型
        public bool PLCSignal(CommonConveyorLine conveyorLine,string TargetAddress,byte staLow)
        {
            //处理出库放料完成后逻辑
            DeviceProDTO? deviceProDTO2 = GetDeviceProDTO(conveyorLine, TargetAddress, "W_StackerCraneLowered");    //放货完成信号
            if (deviceProDTO2 != null)
            {
                if (SetLine(conveyorLine, deviceProDTO2.DeviceProDataBlock, staLow))
                {
                    return true;
                }
            }
            return false;
        }
        //写入输送线 å †åž›æœºå–货完成信号
        public bool PLCSignal2(CommonConveyorLine conveyorLine, string SourceAddress,string DeviceProParamName,Byte stock)
        {
            DeviceProDTO? deviceProDTO2 = GetDeviceProDTO(conveyorLine, SourceAddress, DeviceProParamName);    //取货完成信号
            if (deviceProDTO2 != null)
            {
                return SetLine(conveyorLine, deviceProDTO2.DeviceProDataBlock, stock);
            }
            return false;
        }
        /// <summary>
        /// æ ¹æ®åè®®ï¼Œåœ°å€ï¼Œå€¼ï¼Œå†™å…¥è¾“送线信息,
        /// </summary>
        /// <param name="conveyorLine"></param>
        /// <param name="DeviceProDataBlock"></param>
        /// <param name="Pali"></param>
        /// <returns></returns>
        public bool SetLine(CommonConveyorLine conveyorLine,string DeviceProDataBlock,byte Pali)
        {
            return conveyorLine.Communicator.Write(DeviceProDataBlock, Pali);
        }
        public bool SetLinestring(CommonConveyorLine conveyorLine, string DeviceProDataBlock, string Pali)
        {
            return conveyorLine.Communicator.Write(DeviceProDataBlock, Pali);
        }
        /// <summary>
        /// æ ¹åœ°å€è¯»å–输送线信息
        /// </summary>
        /// <param name="conveyorLine"></param>
        /// <param name="DeviceProDataBlock"></param>
        /// <returns></returns>
        public int GetLine(CommonConveyorLine conveyorLine, string DeviceProDataBlock)
        {
            return conveyorLine.Communicator.Read<byte>(DeviceProDataBlock);
        }
        /// <summary>
        /// è¯»å–堆垛机地址
        /// </summary>
        /// <param name="conveyorLine"></param>
        /// <param name="DeviceProDataBlock"></param>
        /// <returns></returns>
        public WebResponseContent GetStacker(CommonStackerCrane commonStackerCrane,string DeviceProDataBlock)
        {
            WebResponseContent content= new WebResponseContent();
            if (commonStackerCrane.Communicator.Read<bool>(DeviceProDataBlock))
            {
                return content.OK();
            }
            else
            {
                return content.Error();
            }
        }
        /// <summary>
        /// å†™å…¥å †åž›æœºä¿¡å·
        /// </summary>
        /// <param name="conveyorLine"></param>
        /// <param name="DeviceProDataBlock"></param>
        /// <returns></returns>
        public WebResponseContent SetStacker(CommonStackerCrane commonStackerCrane, string DeviceProDataBlock,bool Pali)
        {
            WebResponseContent content = new WebResponseContent();
            if (commonStackerCrane.Communicator.Write(DeviceProDataBlock, Pali))
            {
                return content.OK();
            }
            else
            {
                return content.Error();
            }
        }
        /// <summary>
@@ -190,76 +1101,76 @@
        {
            StackerCraneTaskCommand stackerCraneTaskCommand = new StackerCraneTaskCommand();
            stackerCraneTaskCommand.Barcode = task.PalletCode;
            stackerCraneTaskCommand.Barcode = ""; /*task.PalletCode;*/
            stackerCraneTaskCommand.TaskNum = task.TaskNum;
            stackerCraneTaskCommand.WorkType = 1;
            stackerCraneTaskCommand.TrayType = 0;
            if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.InboundGroup)//判断是否是入库任务
            {
                List<Dt_Router> routers = _routerService.QueryNextRoutes(task.CurrentAddress, task.Roadway);
                if (routers.Count > 0)
                string[] targetCodest = task.SourceAddress.Split("-");
                if (targetCodest.Length == 5)
                {
                    stackerCraneTaskCommand.StartRow = Convert.ToInt16(routers.FirstOrDefault().SrmRow);
                    stackerCraneTaskCommand.StartColumn = Convert.ToInt16(routers.FirstOrDefault().SrmColumn);
                    stackerCraneTaskCommand.StartLayer = Convert.ToInt16(routers.FirstOrDefault().SrmLayer);
                    string[] targetCodes = task.NextAddress.Split("-");
                    if (targetCodes.Length == 3)
                    {
                        stackerCraneTaskCommand.EndRow = Convert.ToInt16(targetCodes[0]);
                        stackerCraneTaskCommand.EndColumn = Convert.ToInt16(targetCodes[1]);
                        stackerCraneTaskCommand.EndLayer = Convert.ToInt16(targetCodes[2]);
                    }
                    else
                    {
                        //数据配置错误
                        _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"入库任务终点错误,起点:【{task.NextAddress}】");
                        return null;
                    }
                    stackerCraneTaskCommand.StartRow = Convert.ToInt16(targetCodest[1]);
                    stackerCraneTaskCommand.StartColumn = Convert.ToInt16(targetCodest[2]);
                    stackerCraneTaskCommand.StartLayer = Convert.ToInt16(targetCodest[3]);
                }
                else
                {
                    _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"未找到站台【{task.NextAddress}】信息,无法获取对应的堆垛机取货站台信息");
                    //数据配置错误
                    _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"入库起点错误,起点:【{task.SourceAddress}】");
                    return null;
                }
                string[] targetCodes = task.NextAddress.Split("-");
                if (targetCodes.Length == 5)
                {
                    stackerCraneTaskCommand.EndRow = Convert.ToInt16(targetCodes[1]);
                    stackerCraneTaskCommand.EndColumn = Convert.ToInt16(targetCodes[2]);
                    stackerCraneTaskCommand.EndLayer = Convert.ToInt16(targetCodes[3]);
                }
                else
                {
                    //数据配置错误
                    _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"入库任务终点错误,起点:【{task.NextAddress}】");
                    return null;
                }
            }
            else if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup)
            {
                List<Dt_Router> routers = _routerService.QueryNextRoutes(task.Roadway, task.TargetAddress);
                if (routers.Count > 0)
                string[] sourceCodes = task.CurrentAddress.Split("-");
                if (sourceCodes.Length == 5)
                {
                    stackerCraneTaskCommand.EndRow = Convert.ToInt16(routers.FirstOrDefault().SrmRow);
                    stackerCraneTaskCommand.EndColumn = Convert.ToInt16(routers.FirstOrDefault().SrmColumn);
                    stackerCraneTaskCommand.EndLayer = Convert.ToInt16(routers.FirstOrDefault().SrmLayer);
                    string[] sourceCodes = task.CurrentAddress.Split("-");
                    if (sourceCodes.Length == 3)
                    {
                        stackerCraneTaskCommand.StartRow = Convert.ToInt16(sourceCodes[0]);
                        stackerCraneTaskCommand.StartColumn = Convert.ToInt16(sourceCodes[1]);
                        stackerCraneTaskCommand.StartLayer = Convert.ToInt16(sourceCodes[2]);
                    }
                    else
                    {
                        //数据配置错误
                        _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"出库任务起点错误,起点:【{task.CurrentAddress}】");
                        return null;
                    }
                    stackerCraneTaskCommand.StartRow = Convert.ToInt16(sourceCodes[1]);
                    stackerCraneTaskCommand.StartColumn = Convert.ToInt16(sourceCodes[2]);
                    stackerCraneTaskCommand.StartLayer = Convert.ToInt16(sourceCodes[3]);
                }
                else
                {
                    _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"未找到站台【{task.NextAddress}】信息,无法获取对应的堆垛机放货站台信息");
                    //数据配置错误
                    _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"出库任务起点错误,起点:【{task.CurrentAddress}】");
                    return null;
                }
                string[] sourceCodest = task.TargetAddress.Split("-");
                if (sourceCodest.Length == 5)
                {
                    stackerCraneTaskCommand.EndRow = Convert.ToInt16(sourceCodest[1]);
                    stackerCraneTaskCommand.EndColumn = Convert.ToInt16(sourceCodest[2]);
                    stackerCraneTaskCommand.EndLayer = Convert.ToInt16(sourceCodest[3]);
                }
                else
                {
                    //数据配置错误
                    _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"出库任务终点错误,起点:【{task.TargetAddress}】");
                    return null;
                }
            }
            else if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.RelocationGroup)
            {
                string[] targetCodes = task.NextAddress.Split("-");
                if (targetCodes.Length == 3)
                if (targetCodes.Length == 5)
                {
                    stackerCraneTaskCommand.EndRow = Convert.ToInt16(targetCodes[0]);
                    stackerCraneTaskCommand.EndColumn = Convert.ToInt16(targetCodes[1]);
                    stackerCraneTaskCommand.EndLayer = Convert.ToInt16(targetCodes[2]);
                    stackerCraneTaskCommand.EndRow = Convert.ToInt16(targetCodes[1]);
                    stackerCraneTaskCommand.EndColumn = Convert.ToInt16(targetCodes[2]);
                    stackerCraneTaskCommand.EndLayer = Convert.ToInt16(targetCodes[3]);
                }
                else
                {
@@ -268,11 +1179,11 @@
                    return null;
                }
                string[] sourceCodes = task.CurrentAddress.Split("-");
                if (sourceCodes.Length == 3)
                if (sourceCodes.Length == 5)
                {
                    stackerCraneTaskCommand.StartRow = Convert.ToInt16(sourceCodes[0]);
                    stackerCraneTaskCommand.StartColumn = Convert.ToInt16(sourceCodes[1]);
                    stackerCraneTaskCommand.StartLayer = Convert.ToInt16(sourceCodes[2]);
                    stackerCraneTaskCommand.StartRow = Convert.ToInt16(sourceCodes[1]);
                    stackerCraneTaskCommand.StartColumn = Convert.ToInt16(sourceCodes[2]);
                    stackerCraneTaskCommand.StartLayer = Convert.ToInt16(sourceCodes[3]);
                }
                else
                {