1
huangxiaoqiang
2026-02-25 02a4fdd78cef9c7d2a26bfb9aa187179cf0baac3
Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs
@@ -178,16 +178,23 @@
                        IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == stationinfo.stationPLC);
                        if (device != null)
                        {
                            if (device.DeviceCode == "1024" || device.DeviceCode == "1023")
                            {
                                CommonConveyorLine_NewCW conveyorLine = (CommonConveyorLine_NewCW)device;
                                conveyorLine.SetValue(ConveyorLineDBName_After.ConveyorLineTargetAddress, Convert.ToInt16(4000), stationinfo.stationChildCode);
                                Thread.Sleep(100);
                                conveyorLine.SetValue(ConveyorLineDBName_After.ConveyorLineTaskNum, 1000, stationinfo.stationChildCode);
                            }
                            else
                            {
                            CommonConveyorLine_CW conveyorLine = (CommonConveyorLine_CW)device;
                            conveyorLine.SetValue(ConveyorLineDBName_After.ConveyorLineTargetAddress, Convert.ToInt16(4000), stationinfo.stationChildCode);
                            Thread.Sleep(100);
                            conveyorLine.SetValue(ConveyorLineDBName_After.ConveyorLineTaskNum, 1000, stationinfo.stationChildCode);
                        }
                        }
                        WriteInfo(commonStackerCrane.DeviceName, $"【手动出库记录】任务号【{e.TaskNum}】托盘号【{task.PalletCode}】");
                    }
                    if (commonStackerCrane.DeviceCode.Contains("GW") && task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup)
                    {
@@ -281,7 +288,7 @@
                    _noticeService.Logs(userTokenIds, new { commonStackerCrane.DeviceName, log = log, time = DateTime.Now.ToString("G"), color = "red" });
                    WriteInfo(commonStackerCrane.DeviceName, log);
                    task = FindAnotherOutboundTask(commonStackerCrane.DeviceCode, task.TaskId);
                    task = FindAnotherOutboundTask(commonStackerCrane.DeviceCode, task);
                    if (task == null)
                    {
@@ -319,10 +326,21 @@
                        device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == router.ChildPosiDeviceCode);
                        if (device != null)
                        {
                            if (device.DeviceCode == "1024" || device.DeviceCode == "1023")
                            {
                                CommonConveyorLine_NewCW conveyorLine = (CommonConveyorLine_NewCW)device;
                                if (conveyorLine.IsOccupied(task.NextAddress))//出库站台未被占用
                                {
                                    return task;
                                }
                            }
                            else
                            {
                            CommonConveyorLine_CW conveyorLine = (CommonConveyorLine_CW)device;
                            if (conveyorLine.IsOccupied(task.NextAddress))//出库站台未被占用
                            {
                                return task;
                                }
                            }
                        }
                        else
@@ -395,11 +413,11 @@
        /// <param name="deviceCode">设备代码</param>
        /// <param name="excludedTaskId">要排除的任务ID</param>
        /// <returns></returns>
        private Dt_Task? FindAnotherOutboundTask(string deviceCode, int excludedTaskId)
        private Dt_Task? FindAnotherOutboundTask(string deviceCode, Dt_Task task)
        {
            // 先获取所有符合条件(排除指定任务ID)的出库任务列表
            var allOutboundTasks = _taskService.QueryAllOutboundTasks(deviceCode);
            var availableTasks = allOutboundTasks?.Where(t => excludedTaskId != t.TaskId && t.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup).ToList();
            var availableTasks = allOutboundTasks?.Where(t => t.TargetAddress != task.TargetAddress && t.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup).ToList();
            if (availableTasks == null || availableTasks.Count == 0)
            {