wanshenmean
2025-03-20 2f29f4bb2f2a98f090e56ad82ae11cf88f4c14fd
CodeManagement/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob_GW/GWTask/RequestInbound.cs
@@ -4,6 +4,7 @@
using WIDESEAWCS_Common.TaskEnum;
using WIDESEAWCS_Core;
using WIDESEAWCS_Core.Helper;
using WIDESEAWCS_DTO.MOM;
using WIDESEAWCS_DTO.TaskInfo;
using WIDESEAWCS_DTO.WMS;
using WIDESEAWCS_Model.Models;
@@ -216,7 +217,53 @@
        {
            if (command.ConveyorLineBarcode != "NoRead")
            {
                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;
                if (wmsBase == null || ipAddress == null)
                {
                    throw new InvalidOperationException("MOM IP 未配置");
                }
                var stationManager=_stationManagerRepository.QueryFirst(x=>x.stationChildCode == childDeviceCode);
                TrayCellsStatusDto trayCells = new TrayCellsStatusDto()
                {
                    Software = "WMS",
                    TrayBarcode = command.ConveyorLineBarcode,
                    EquipmentCode = stationManager.stationEquipMOM,
                    SessionId = Guid.NewGuid().ToString(),
                    EmployeeNo = "MITest",
                    SceneType = "4",
                    RequestTime = TimeZoneInfo.ConvertTimeToUtc(DateTime.Now).ToString("yyyy-MM-ddTHH:mm:ss.fffZ")
                };
                
                var MOMIpAddress = wmsBase + ipAddress;
                var result = HttpHelper.PostAsync(MOMIpAddress, trayCells.ToJsonString()).Result;
                WriteInfo("入站校验", $"【{stationManager.stationChildCode}】入站校验请求参数【{trayCells.ToJsonString()}】");
                WriteInfo("入站校验", "");
                WriteInfo("入站校验", $"【{stationManager.stationChildCode}】入站校验返回参数【{result}】");
                ResultTrayCellsStatus result1 = JsonConvert.DeserializeObject<ResultTrayCellsStatus>(result);
                if (result1.Success)
                {
                    var serialNosError = result1.SerialNos.Where(x => x.SerialNoStatus != 1 && x.SerialNoStatus != 4).ToList();
                    if (serialNosError.Count > 0)
                    {
                        if (result1.ProcessCode == "AG01")
                        {
                            var strings = new List<string>() { "2234", "2226", "2218" };
                            foreach (var item in strings)
                            {
                                var station = _stationManagerRepository.QueryFirst(x => x.productLine == result1.ProductionLine && x.stationChildCode == item);
                                if(station != null)
                                {
                                    //发送到分容
                                }
                            }
                        }
                    }
                    else
                    {
                var taskDTO = CreateEmptyTrayTaskDto(command.ConveyorLineBarcode, childDeviceCode);
                if (_taskRepository.QueryFirst(x => x.PalletCode == taskDTO.PalletCode) != null)
@@ -236,6 +283,36 @@
                        _taskService.UpdateTaskStatusToNext(task);
                    }
                }
                    }
                }
                else
                {
                    ConsoleHelper.WriteErrorLine(result1.MOMMessage);
                }
                //var taskDTO = CreateEmptyTrayTaskDto(command.ConveyorLineBarcode, childDeviceCode);
                //if (_taskRepository.QueryFirst(x => x.PalletCode == taskDTO.PalletCode) != null)
                //{
                //    WriteInfo(conveyorLine.DeviceName, "当前托盘存在任务");
                //    return;
                //}
                //var content = CreateAndSendTask(taskDTO);
                //if (content.Status)
                //{
                //    var task = _taskService.QueryConveyorLineTask(conveyorLine.DeviceCode, childDeviceCode);
                //    if (task != null)
                //    {
                //        var taskCommand = MapTaskCommand(task, command);
                //        conveyorLine.SendCommand(taskCommand, childDeviceCode);
                //        _taskService.UpdateTaskStatusToNext(task);
                //    }
                //}
                //}
            }
        }