huangxiaoqiang
2025-03-26 6e380a6002fb7675f8795d8c223801cf6ec67347
CodeManagement/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/Task/RequestInbound.cs
@@ -1,6 +1,8 @@
using HslCommunication;
using Mapster;
using Microsoft.AspNetCore.Mvc.ModelBinding.Validation;
using Microsoft.CodeAnalysis;
using Microsoft.VisualBasic;
using Newtonsoft.Json;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
@@ -148,12 +150,12 @@
            {
                string isTrue = string.Empty;
                //ResultTrayCellsStatus result = GetResultTrayCellsStatus(command, stationManager);
                ResultTrayCellsStatus result = GetResultTrayCellsStatus(command, stationManager);
                List<string> strings = stationManager.Roadway.Split(",").ToList();
                foreach (string item in strings)
                {
                    isTrue = RequestInboundPlatform(item, "ZJ-11", true);
                    isTrue = RequestInboundPlatform(item, result.ProductionLine, true);
                    if (isTrue != null)
                    {
                        break;
@@ -174,7 +176,7 @@
                        TaskState = (int)TaskOutStatusEnum.OutNew,
                        Id = 0,
                        TaskType = (int)TaskOutboundTypeEnum.TrayInToOut,
                        ProductionLine = "ZJ-11",
                        ProductionLine = result.ProductionLine,
                    };
                }
                else
@@ -283,47 +285,47 @@
        {
            string isTrue = string.Empty;
            //ResultTrayCellsStatus result = GetResultTrayCellsStatus(command, stationManager);
            ResultTrayCellsStatus result = GetResultTrayCellsStatus(command, stationManager);
            //List<string> strings = stationManager.Roadway.Split(",").ToList();
            //foreach (string item in strings)
            //{
            //    isTrue = RequestInboundPlatform(conveyorLine, item, result.ProductionLine, false);
            //    if (isTrue != null)
            //    {
            //        break;
            //    }
            //}
            //if (isTrue != null && isTrue != string.Empty)
            //{
            //    WMSTaskDTO taskDTO = new WMSTaskDTO
            //    {
            //        TaskNum = _taskRepository.GetTaskNo().Result,
            //        Grade = 1,
            //        PalletCode = command.Barcode,
            //        RoadWay = childDeviceCode,
            //        SourceAddress = childDeviceCode,
            //        TargetAddress = isTrue,
            //        TaskState = (int)TaskOutStatusEnum.OutNew,
            //        Id = 2,
            //        TaskType = (int)TaskOutboundTypeEnum.InToOut,
            //        ProductionLine = result.ProductionLine,
            //    };
            //    var Taskcontent = _taskService.ReceiveWMSTask(new List<WMSTaskDTO> { taskDTO });
            //    if (Taskcontent.Status)
            //    {
            //        ExecuteConveyorLineTask(conveyorLine, command, ProtocalDetailValue, childDeviceCode);
            //    }
            List<string> strings = stationManager.Roadway.Split(",").ToList();
            foreach (string item in strings)
            {
                isTrue = RequestInboundPlatform(item, result.ProductionLine, false);
                if (isTrue != null)
                {
                    break;
                }
            }
            if (isTrue != null && isTrue != string.Empty)
            {
                WMSTaskDTO taskDTO = new WMSTaskDTO
                {
                    TaskNum = _taskRepository.GetTaskNo().Result,
                    Grade = 1,
                    PalletCode = command.Barcode,
                    RoadWay = childDeviceCode,
                    SourceAddress = childDeviceCode,
                    TargetAddress = isTrue,
                    TaskState = (int)TaskOutStatusEnum.OutNew,
                    Id = 2,
                    TaskType = (int)TaskOutboundTypeEnum.InToOut,
                    ProductionLine = result.ProductionLine,
                };
                var Taskcontent = _taskService.ReceiveWMSTask(new List<WMSTaskDTO> { taskDTO });
                if (Taskcontent.Status)
                {
                    ExecuteConveyorLineTask(conveyorLine, command, ProtocalDetailValue, childDeviceCode);
                }
            //}
            //else
            //{
            }
            else
            {
                var Taskcontent = await _taskService.RequestWMSTask(command.Barcode, childDeviceCode);
                if (Taskcontent.Status)
                {
                    ExecuteConveyorLineTask(conveyorLine, command, ProtocalDetailValue, childDeviceCode);
                }
            //}
            }
            #region
            //if (Taskcontent.Status)
@@ -388,7 +390,6 @@
            #endregion
        }
        /// <summary>
        /// 成化入静置
        /// </summary>
@@ -406,25 +407,40 @@
            var serialNosError = resultTrayCellsStatus.SerialNos.Where(x => x.SerialNoStatus != 1 && x.SerialNoStatus != 4).ToList();
            if (serialNosError.Count > 0)
            {
                //空框逻辑
                //NG流程
                var platform = _platFormRepository.QueryFirst(x => x.ProductionLine == resultTrayCellsStatus.ProductionLine);
                ConveyorLineTaskCommand conveyorLineTaskCommand = new ConveyorLineTaskCommand()
                {
                    TaskNum = 1,
                    TargetAddress=Convert.ToInt32( platform.Capacity),
                    Barcode= resultTrayCellsStatus.TrayBarcode,
                };
                conveyorLine.SendCommand(conveyorLineTaskCommand, childDeviceCode);
                ConveyorLineSendFinish(conveyorLine, childDeviceCode, ProtocalDetailValue, true);
                ConsoleHelper.WriteSuccessLine($"MOM数据异常,送至二封【{resultTrayCellsStatus.ProductionLine}】异常口【{Convert.ToInt32(platform.Capacity)}】");
                return;
            }
            if (resultTrayCellsStatus.SerialNos.Count == 0)
            {
                var Traycontent = await _taskService.RequestWMSTask(command.Barcode, childDeviceCode);
                if (Traycontent.Status)
                {
                    ConsoleHelper.WriteSuccessLine("化成空框请求回流静置");
                    ExecuteConveyorLineTask(conveyorLine, command, ProtocalDetailValue, childDeviceCode);
                    return;
                }
            }
            else
            {
                var configz = _sys_ConfigService.GetConfigsByCategory(CateGoryConst.CONFIG_SYS_IPAddress);
                var wmsbase = configz.Where(x => x.ConfigKey == SysConfigKeyConst.WMSIP_BASE).FirstOrDefault()?.ConfigValue;
                var address = configz.Where(x => x.ConfigKey == SysConfigKeyConst.GetJZStockInfo).FirstOrDefault()?.ConfigValue;
                var address = configz.Where(x => x.ConfigKey == SysConfigKeyConst.QueryStockInfoForRealTrayJZAsync).FirstOrDefault()?.ConfigValue;
                if (wmsbase == null || address == null)
                {
                    throw new InvalidOperationException("WMS IP 未配置");
                }
                var wmsIpAddrss = wmsbase + address;
                var result = await HttpHelper.PostAsync(wmsIpAddrss);
                var result = await HttpHelper.PostAsync(wmsIpAddrss, new { ProductLine = resultTrayCellsStatus.ProductionLine }.ToJsonString());
                var StockInfocontent = JsonConvert.DeserializeObject<WebResponseContent>(result);
                if (StockInfocontent.Status)
                {
@@ -440,24 +456,34 @@
                            {
                                ConsoleHelper.WriteSuccessLine("化成实托请求入静置");
                                ExecuteConveyorLineTask(conveyorLine, command, ProtocalDetailValue, childDeviceCode);
                                return;
                            }
                            else
                            {
                                ConsoleHelper.WriteWarningLine("出库任务未完成");
                                return;
                            }
                        }
                        else if (task != null && task.TaskState == (int)TaskOutStatusEnum.SC_OutExecuting)
                        {
                            ConsoleHelper.WriteWarningLine("已存在静置出库任务");
                            return;
                        }
                        else
                        {
                            ExecuteConveyorLineTask(conveyorLine, command, ProtocalDetailValue, childDeviceCode);
                            var Task = await _taskService.RequestWMSTask(command.Barcode, childDeviceCode);
                            if (Task.Status)
                            {
                                ExecuteConveyorLineTask(conveyorLine, command, ProtocalDetailValue, childDeviceCode);
                            }
                            return;
                        }
                    }
                    else
                    {
                        WriteInfo(conveyorLine.DeviceName, Taskcontent.Message);
                        return;
                    }
                }
                else
                {
@@ -482,7 +508,7 @@
                            RoadWay = isTrue,
                            SourceAddress = childDeviceCode,
                            TargetAddress = isTrue,
                            TaskState = (int)TaskOutStatusEnum.OutNew,
                            TaskState = (int)TaskOutStatusEnum.SC_OutFinish,
                            Id = 2,
                            TaskType = (int)TaskOutboundTypeEnum.InToOut,
                            ProductionLine = resultTrayCellsStatus.ProductionLine,
@@ -491,14 +517,23 @@
                        if (Taskcontent.Status)
                        {
                            ExecuteConveyorLineTask(conveyorLine, command, ProtocalDetailValue, childDeviceCode);
                            return;
                        }
                        else
                        {
                            WriteInfo(conveyorLine.DeviceName, Taskcontent.Message);
                            return;
                        }
                    }
                    else
                    {
                        var Task = await _taskService.RequestWMSTask(command.Barcode, childDeviceCode);
                        if (Task.Status)
                        {
                            ExecuteConveyorLineTask(conveyorLine, command, ProtocalDetailValue, childDeviceCode);
                        }
                        ConsoleHelper.WriteWarningLine("二封缓存位已满");
                        return;
                    }
                }
@@ -515,7 +550,7 @@
                {
                    conveyorLine.SetValue(ConveyorLineDBName.WriteConveyorLineTargetAddress, "1000", childDeviceCode);
                    var log = $"【{conveyorLine._deviceName}】任务号:【{task.TaskNum}】,托盘条码:【{task.PalletCode}】已到达【{childDeviceCode}】请求扫码入库(实盘),下一目标地址【{1000}】";
                    var log = $"【{conveyorLine._deviceName}】任务号:【{task.TaskNum}】,托盘条码:【{task.PalletCode}】已到达【{childDeviceCode}】请求扫码入库(实盘or空盘),下一目标地址【{1000}】";
                    ConsoleHelper.WriteWarningLine(log);
                    _noticeService.Logs(userTokenIds, new { conveyorLine.DeviceName, log = log, time = DateTime.Now.ToString("G"), color = "red" });