wanshenmean
2025-04-16 29f20b28392d212c04c0c40a512894f8622cfa53
CodeManagement/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob_GW/GWTask/RequestInbound.cs
@@ -1,5 +1,7 @@
using Masuit.Tools;
using Masuit.Tools.Systems;
using Newtonsoft.Json;
using System.Threading.Tasks;
using WIDESEAWCS_Common;
using WIDESEAWCS_Common.TaskEnum;
using WIDESEAWCS_Core;
@@ -164,7 +166,7 @@
                    AbNormalStationBZTask(conveyorLine, command, childDeviceCode);
                    break;
                case 1:
                    RequestWmsTask(conveyorLine, command, childDeviceCode);
                    RequestWmsTask(conveyorLine, command, childDeviceCode, stationManager);
                    break;
            }
        }
@@ -219,6 +221,7 @@
        {
            if (command.ConveyorLineBarcode != "NoRead")
            {
                #region
                //var config = _sys_ConfigService.GetConfigsByCategory(CateGoryConst.CONFIG_SYS_IPAddress);
                //var wmsBase = config.FirstOrDefault(x => x.ConfigKey == SysConfigKeyConst.MOMIP_BASE)?.ConfigValue;
                //var ipAddress = config.FirstOrDefault(x => x.ConfigKey == SysConfigKeyConst.TrayCellsStatus)?.ConfigValue;
@@ -226,7 +229,7 @@
                //{
                //    throw new InvalidOperationException("MOM IP 未配置");
                //}
                //var stationManager=_stationManagerRepository.QueryFirst(x=>x.stationChildCode == childDeviceCode);
                //var stationManager = _stationManagerRepository.QueryFirst(x => x.stationChildCode == childDeviceCode);
                //TrayCellsStatusDto trayCells = new TrayCellsStatusDto()
                //{
                //    Software = "WMS",
@@ -263,9 +266,18 @@
                //                    if (device != null)
                //                    {
                //                        CommonConveyorLine_After CommonConveyorLine_After = (CommonConveyorLine_After)device;
                //                        ConveyorLineTaskCommand_After conveyorLineAfter = CommonConveyorLine_After.ReadCustomer<ConveyorLineTaskCommand_After>((Convert.ToInt32(station.stationChildCode)).ToString());
                //                        ConveyorLineTaskCommand_After taskCommand = new ConveyorLineTaskCommand_After()
                //                        {
                //                            ConveyorLineTaskNum = Convert.ToInt32(1),
                //                            ConveyorLineTargetAddress = Convert.ToInt16(2234),
                //                            ConveyorLineBarcode = command.ConveyorLineBarcode.ToString(),
                //                        };
                //                        CommonConveyorLine_After.SendCommand(taskCommand, station.stationChildCode);
                //                        CommonConveyorLine_After.SetValue(ConveyorLineDBName_After.ResponState, 1, station.stationChildCode);
                //                    }
                //                    //发送到分容
                //                    return;
                //                }
                //            }
                //        }
@@ -283,9 +295,10 @@
                //                if (device != null)
                //                {
                //                    CommonConveyorLine_After CommonConveyorLine_After = (CommonConveyorLine_After)device;
                //                    ConveyorLineTaskCommand_After conveyorLineAfter = CommonConveyorLine_After.ReadCustomer<ConveyorLineTaskCommand_After>((Convert.ToInt32(station.stationChildCode)).ToString());
                //                    if (conveyorLineAfter.HasPallet == 0)
                //                    ConveyorLineTaskCommand_After conveyorLineAfter = CommonConveyorLine_After.ReadCustomer<ConveyorLineTaskCommand_After>(Convert.ToInt32(station.stationChildCode).ToString());
                //                    if (conveyorLineAfter.InteractiveSignal == 16)
                //                    {
                //                        var TaskNum = SnowFlake.LongId;
                //                        Dt_Task task = new Dt_Task()
                //                        {
                //                            TaskNum = _taskRepository.GetTaskNo().Result,
@@ -294,7 +307,7 @@
                //                            Roadway = station.Roadway,
                //                            SourceAddress = childDeviceCode,
                //                            TargetAddress = station.stationChildCode,
                //                            CurrentAddress = station.stationChildCode,
                //                            CurrentAddress = childDeviceCode,
                //                            NextAddress = station.stationChildCode,
                //                            TaskState = (int)TaskInStatusEnum.InNew,
                //                            ExceptionMessage = "",
@@ -339,7 +352,7 @@
                //{
                //    ConsoleHelper.WriteErrorLine(result1.MOMMessage);
                //}
                #endregion
                if (_taskRepository.QueryFirst(x => x.PalletCode == command.ConveyorLineBarcode) != null)
                {
@@ -359,7 +372,7 @@
                    {
                        var taskCommand = MapTaskCommand(task, command);
                        conveyorLine.SendCommand(taskCommand, childDeviceCode);
                        //conveyorLine.SetValue(ConveyorLineDBName_After.ResponState, 1, childDeviceCode);
                        conveyorLine.SetValue(ConveyorLineDBName_After.ResponState, 1, childDeviceCode);
                        _taskService.UpdateTaskStatusToNext(task);
                    }
                }
@@ -399,9 +412,19 @@
        /// <summary>
        /// 请求WMS任务
        /// </summary>
        private async void RequestWmsTask(CommonConveyorLine_GW conveyorLine, ConveyorLineTaskCommand_After command, string childDeviceCode)
        private async void RequestWmsTask(CommonConveyorLine_GW conveyorLine, ConveyorLineTaskCommand_After command, string childDeviceCode, Dt_StationManager stationManager)
        {
            if (command.ConveyorLineBarcode.IsNullOrEmpty()) return;
            var Hastask = _taskService.QueryBarCodeConveyorLineTask(command.ConveyorLineBarcode, childDeviceCode);
            if (Hastask != null)
            {
                ConveyorLineTaskCommand_After taskCommand = _mapper.Map<ConveyorLineTaskCommand_After>(Hastask);
                conveyorLine.SendCommand(taskCommand, childDeviceCode);
                conveyorLine.SetValue(ConveyorLineDBName_After.ResponState, 1, childDeviceCode);
                return;
            }
            var content = await _taskService.RequestWMSTask(command.ConveyorLineBarcode, childDeviceCode);
            if (content.Status)
            {
@@ -409,15 +432,16 @@
                if (task != null)
                {
                    ConveyorLineTaskCommand_After taskCommand = _mapper.Map<ConveyorLineTaskCommand_After>(task);
                    conveyorLine.SetValue(ConveyorLineDBName_After.ResponState, 1, childDeviceCode);
                    conveyorLine.SendCommand(taskCommand, childDeviceCode);
                    //ConveyorLineSendFinish(conveyorLine, childDeviceCode, ProtocalDetailValue, true);
                    conveyorLine.SetValue(ConveyorLineDBName_After.ResponState, 1, childDeviceCode);
                    _taskService.UpdateTaskStatusToNext(task);
                }
            }
            else
            {
                WriteInfo(conveyorLine.DeviceName, content.Message);
                conveyorLine.SetValue(ConveyorLineDBName_After.ConveyorLineTargetAddress, stationManager.stationNGChildCode, childDeviceCode);
                conveyorLine.SetValue(ConveyorLineDBName_After.ResponState, 1, childDeviceCode);
                ConsoleHelper.WriteErrorLine($"【{conveyorLine.DeviceName}】托盘号:【{command.ConveyorLineBarcode}】请求点位:【{childDeviceCode}】异常信息【{content.Message}】");
            }
        }