wanshenmean
2026-02-28 c3de7bb2097aa347a1f92c2f640d18753aff633a
Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineNewJob/ConveyorLineDispatchHandler.cs
@@ -96,11 +96,7 @@
                if (string.Equals(task.NextAddress, ConstraintMachineName, StringComparison.Ordinal))
                {
                    ConstraintMachine? constraint = devices.OfType<ConstraintMachine>().FirstOrDefault(d => d.DeviceName == ConstraintMachineName);
                    if (constraint == null)
                    {
                        // 处理 processing 为空的情况(可根据实际业务需求添加处理逻辑)
                        return;
                    }
                    if (constraint == null) return;
                    ProcessDeviceRequest(conveyorLine, constraint, childDeviceCode,
                    () => constraint.GetValue<ConstraintMachineDBName, bool>(ConstraintMachineDBName.MaterialRequestUpper),
@@ -110,11 +106,7 @@
                else if (string.Equals(task.NextAddress, PinMachineName, StringComparison.Ordinal))
                {
                    PinMachine? pinMachine = devices.OfType<PinMachine>().FirstOrDefault(d => d.DeviceName == PinMachineName);
                    if (pinMachine == null)
                    {
                        // 处理 pinMachine 为空的情况(可根据实际业务需求添加处理逻辑)
                        return;
                    }
                    if (pinMachine == null) return;
                    ProcessDeviceRequest(conveyorLine, pinMachine, childDeviceCode,
                    () => pinMachine.GetValue<PinMachineDBName, bool>(PinMachineDBName.MaterialRequestUpper),
@@ -123,10 +115,10 @@
                }
                Dt_Task? newTask = _taskService.UpdatePosition(task.TaskNum, task.CurrentAddress);
                //if (newTask != null)
                //{
                //    _taskService.UpdateTaskStatusToNext(task);
                //}
                if (newTask != null)
                {
                    _taskService.UpdateTaskStatusToNext(task);
                }
            }
        }
@@ -158,9 +150,14 @@
            Dt_Task task = _taskService.QueryConveyorLineTask(conveyorLine.DeviceCode, childDeviceCode);
            if (task != null)
            {
                ConveyorLineTaskCommandNew taskCommand = _mapper.Map<ConveyorLineTaskCommandNew>(task);
                taskCommand.WCS_ACK = command.WCS_ACK;
                conveyorLine.SendCommand(taskCommand, childDeviceCode);
                //ConveyorLineTaskCommandNew taskCommand = _mapper.Map<ConveyorLineTaskCommandNew>(task);
                //taskCommand.WCS_ACK = command.WCS_ACK;
                //conveyorLine.SendCommand(taskCommand, childDeviceCode);
                conveyorLine.SetValue(ConveyorLineDBNameNew.TaskNo, task.TaskNum, childDeviceCode);
                conveyorLine.SetValue(ConveyorLineDBNameNew.Barcode, task.PalletCode, childDeviceCode);
                conveyorLine.SetValue(ConveyorLineDBNameNew.Target, task.TargetAddress, childDeviceCode);
                conveyorLine.SetValue(ConveyorLineDBNameNew.WCS_ACK, 1, childDeviceCode);
                _taskService.UpdateTaskStatusToNext(task);
            }
@@ -210,6 +207,7 @@
                }
                Dt_Task? newTask = _taskService.UpdatePosition(task.TaskNum, task.CurrentAddress);
            }
        }
@@ -227,101 +225,6 @@
                conveyorLine.SetValue(ConveyorLineDBNameNew.WCS_ACK, 1, childDeviceCode);
                WebResponseContent content = _taskService.UpdateTaskStatusToNext(task);
                Console.Out.WriteLine(content.Serialize());
            }
        }
        /// <summary>
        /// 入库拘束机请求处理
        /// </summary>
        /// <param name="conveyorLine"></param>
        /// <param name="command"></param>
        /// <param name="constraint"></param>
        /// <param name="childDeviceCode"></param>
        public void InboundConstraintMachineRequest(CommonConveyorLine conveyorLine, ConveyorLineTaskCommandNew command, ConstraintMachine? constraint, string childDeviceCode)
        {
            //入库拘束机请求处理逻辑
            bool materialReq = constraint.GetValue<ConstraintMachineDBName, bool>(ConstraintMachineDBName.MaterialRequestUpper);
            bool outputReq = constraint.GetValue<ConstraintMachineDBName, bool>(ConstraintMachineDBName.OutputRequestUpper);
            if (materialReq)
            {
                conveyorLine.SetValue(ConveyorLineDBNameNew.Target, 1, childDeviceCode);
                conveyorLine.SetValue(ConveyorLineDBNameNew.WCS_ACK, 1, childDeviceCode);
            }
            else
            {
                constraint.SetValue(ConstraintMachineDBName.ConstraintTrayOutputReadyUpper, outputReq ? 1 : 0);
            }
        }
        /// <summary>
        /// 入库插拔钉机请求处理
        /// </summary>
        /// <param name="conveyorLine"></param>
        /// <param name="command"></param>
        /// <param name="pinMachine"></param>
        /// <param name="childDeviceCode"></param>
        public void InboundPinMachineRequest(CommonConveyorLine conveyorLine, ConveyorLineTaskCommandNew command, PinMachine? pinMachine, string childDeviceCode)
        {
            //入库插拔钉机请求处理逻辑
            bool materialReq = pinMachine.GetValue<PinMachineDBName, bool>(PinMachineDBName.MaterialRequestUpper);
            bool outputReq = pinMachine.GetValue<PinMachineDBName, bool>(PinMachineDBName.OutputRequestUpper);
            if (materialReq)
            {
                conveyorLine.SetValue(ConveyorLineDBNameNew.Target, 1, childDeviceCode);
                conveyorLine.SetValue(ConveyorLineDBNameNew.WCS_ACK, 1, childDeviceCode);
            }
            else
            {
                pinMachine.SetValue(PinMachineDBName.PlugPinTrayOutputReadyUpper, outputReq ? 1 : 0);
            }
        }
        /// <summary>
        /// 出库拘束机请求处理
        /// </summary>
        /// <param name="conveyorLine"></param>
        /// <param name="command"></param>
        /// <param name="constraint"></param>
        /// <param name="childDeviceCode"></param>
        public void OutConstraintMachineRequest(CommonConveyorLine conveyorLine, ConveyorLineTaskCommandNew command, ConstraintMachine? constraint, string childDeviceCode)
        {
            //出库拘束机请求处理逻辑
            bool materialReq = constraint.GetValue<ConstraintMachineDBName, bool>(ConstraintMachineDBName.MaterialRequestLower);
            bool outputReq = constraint.GetValue<ConstraintMachineDBName, bool>(ConstraintMachineDBName.OutputRequestLower);
            if (materialReq)
            {
                conveyorLine.SetValue(ConveyorLineDBNameNew.Target, 1, childDeviceCode);
                conveyorLine.SetValue(ConveyorLineDBNameNew.WCS_ACK, 1, childDeviceCode);
            }
            else
            {
                constraint.SetValue(ConstraintMachineDBName.ConstraintTrayOutputReadyLower, outputReq ? 1 : 0);
            }
        }
        /// <summary>
        /// 出库插拔钉机请求处理
        /// </summary>
        /// <param name="conveyorLine"></param>
        /// <param name="command"></param>
        /// <param name="pinMachine"></param>
        /// <param name="childDeviceCode"></param>
        public void OutPinMachineRequest(CommonConveyorLine conveyorLine, ConveyorLineTaskCommandNew command, PinMachine? pinMachine, string childDeviceCode)
        {
            //出库插拔钉机请求处理逻辑
            bool materialReq = pinMachine.GetValue<PinMachineDBName, bool>(PinMachineDBName.MaterialRequestLower);
            bool outputReq = pinMachine.GetValue<PinMachineDBName, bool>(PinMachineDBName.OutputRequestLower);
            if (materialReq)
            {
                conveyorLine.SetValue(ConveyorLineDBNameNew.Target, 1, childDeviceCode);
                conveyorLine.SetValue(ConveyorLineDBNameNew.WCS_ACK, 1, childDeviceCode);
            }
            else
            {
                pinMachine.SetValue(PinMachineDBName.PlugPinTrayOutputReadyLower, outputReq ? 1 : 0);
            }
        }