1
wanshenmean
2025-03-23 9843b47612ee6ab23e3e36bf74b14c11354997af
CodeManagement/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerStationJob/CommonStackerStationCraneJob.cs
@@ -1,4 +1,4 @@
using HslCommunication;
using Masuit.Tools.Systems;
using Newtonsoft.Json;
using Quartz;
using System.Diagnostics.CodeAnalysis;
@@ -9,20 +9,17 @@
using WIDESEAWCS_Core.Caches;
using WIDESEAWCS_Core.Helper;
using WIDESEAWCS_Core.HttpContextUser;
using WIDESEAWCS_DTO.MOM;
using WIDESEAWCS_IProcessRepository;
using WIDESEAWCS_ITaskInfoRepository;
using WIDESEAWCS_ITaskInfoService;
using WIDESEAWCS_Model;
using WIDESEAWCS_Model.Models;
using WIDESEAWCS_QuartzJob;
using WIDESEAWCS_QuartzJob.DeviceBase;
using WIDESEAWCS_QuartzJob.Models;
using WIDESEAWCS_QuartzJob.Service;
using WIDESEAWCS_QuartzJob.StackerCrane.Enum;
using WIDESEAWCS_SignalR;
using WIDESEAWCS_Tasks.ConveyorLineJob;
using WIDESEAWCS_Tasks.StackerCraneJob;
using WIDESEAWCS_Common;
namespace WIDESEAWCS_Tasks
{
@@ -151,6 +148,28 @@
                    str = $"{commonStackerCrane.DeviceName}】WMS|WCS任务完成:【{content.Status}】,堆垛机完成信号写入:【{isWorkType}】,任务号:【{e.TaskNum}】时间【{DateTime.Now}】";
                    WriteInfo(commonStackerCrane.DeviceName, str);
                    ConsoleHelper.WriteColorLine(str, ConsoleColor.Blue);
                    if (content.Status)
                    {
                        var task = content.Data as Dt_Task;
                        Dt_StationManager stationManager = _stationManagerRepository.QueryFirst(x => x.Roadway == task.Roadway && x.stationLocation == task.TargetAddress);
                        IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == stationManager.stationPLC);
                        if (device != null)
                        {
                            CommonConveyorLine_After conveyorLine = (CommonConveyorLine_After)device;
                            var proAddress = conveyorLine.DeviceProDTOs.Where(x => x.DeviceChildCode == stationManager.stationChildCode).Where(x => x.DeviceProParamName == ConveyorLineDBName_After.InteractiveSignal.ToString()).FirstOrDefault().DeviceProAddress;
                            string? address = proAddress;
                            if (!proAddress.Contains(".0"))
                            {
                                address = proAddress + ".0";
                            }
                            conveyorLine.Communicator.Write(str, false);
                        }
                        else
                        {
                            _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"未找到出库站台【{task.NextAddress}】对应的通讯对象,无法清除出库站台顶升状态");
                        }
                    }
                }
            }
        }
@@ -192,16 +211,20 @@
            if (task != null && task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup)
            {
                if (task.TaskType == (int)TaskOutboundTypeEnum.Outbound)
                if (task.TaskType == (int)TaskOutboundTypeEnum.Outbound)
                {
                    Dt_StationManager stationManager = _stationManagerRepository.QueryFirst(x => x.Roadway == task.Roadway && x.stationLocation == task.TargetAddress);
                    IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == stationManager.stationPLC);
                    if (device != null)
                    {
                        CommonConveyorLine_After conveyorLine = (CommonConveyorLine_After)device;
                        string str = conveyorLine.DeviceProDTOs.Where(x => x.DeviceChildCode == stationManager.stationChildCode).Select(x => x.DeviceProAddress) + ".0";
                        var proAddress = conveyorLine.DeviceProDTOs.Where(x => x.DeviceChildCode == stationManager.stationChildCode).Where(x => x.DeviceProParamName == ConveyorLineDBName_After.InteractiveSignal.ToString()).FirstOrDefault().DeviceProAddress;
                        string? str = proAddress;
                        if (!proAddress.Contains(".0"))
                        {
                            str = proAddress + ".0";
                        }
                        conveyorLine.Communicator.Write(str, true);
                        return task;
                    }
                    else
                    {
@@ -209,20 +232,17 @@
                        return null;
                    }
                }
                // 检查当前出库任务站台是否允许放货
                var occupiedStation = OutTaskStationIsOccupied(task);
                if (occupiedStation == null)
                {
                    // 如果当前出库任务站台不允许放货,排除当前任务,查找其他出库任务
                    ConsoleHelper.WriteErrorLine($"任务号:【{task.TaskNum}】出库地址:【{task.NextAddress}】不允许放货");
                    task = FindAnotherOutboundTask(commonStackerCrane.DeviceCode, task);
                }
                else
                {
                    // 检查当前出库任务站台是否允许放货
                    var occupiedStation = OutTaskStationIsOccupied(task);
                    if (occupiedStation == null)
                    {
                        // 如果当前出库任务站台不允许放货,排除当前任务,查找其他出库任务
                        ConsoleHelper.WriteErrorLine($"任务号:【{task.TaskNum}】出库地址:【{task.NextAddress}】不允许放货");
                        task = FindAnotherOutboundTask(commonStackerCrane.DeviceCode, task);
                    }
                    else
                    {
                        return task;
                    }
                    return task;
                }
                if (task == null)