From e9b4a4107bdd7a7c737192827d4ee17e23c362f6 Mon Sep 17 00:00:00 2001
From: huangxiaoqiang <huangxiaoqiang@hnkhzn.com>
Date: 星期五, 21 三月 2025 14:23:15 +0800
Subject: [PATCH] 1

---
 CodeManagement/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob_GW/GWTask/RequestInbound.cs |  231 +++++++++++++++++++++++++++++++++++----------------------
 1 files changed, 140 insertions(+), 91 deletions(-)

diff --git a/CodeManagement/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob_GW/GWTask/RequestInbound.cs b/CodeManagement/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob_GW/GWTask/RequestInbound.cs
index 759cd2a..57ef8c9 100644
--- a/CodeManagement/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob_GW/GWTask/RequestInbound.cs
+++ b/CodeManagement/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob_GW/GWTask/RequestInbound.cs
@@ -9,6 +9,7 @@
 using WIDESEAWCS_DTO.WMS;
 using WIDESEAWCS_Model.Models;
 using WIDESEAWCS_QuartzJob;
+using WIDESEAWCS_QuartzJob.DeviceBase;
 using WIDESEAWCS_Tasks.ConveyorLineJob;
 using static Microsoft.EntityFrameworkCore.DbLoggerCategory.Database;
 
@@ -174,6 +175,7 @@
         private ConveyorLineTaskCommand_After MapTaskCommand(Dt_Task task, ConveyorLineTaskCommand_After command)
         {
             var comm = _mapper.Map<ConveyorLineTaskCommand_After>(task);
+            comm.ResponState = 1;
             comm.InteractiveSignal = command.InteractiveSignal;
             return comm;
         }
@@ -217,103 +219,150 @@
         {
             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)
-                        {
-                            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);
-                            }
-                        }
-                    }
-                    
-                }
-                else
-                {
-                    ConsoleHelper.WriteErrorLine(result1.MOMMessage);
-                }
-
-
-
-
-                //var taskDTO = CreateEmptyTrayTaskDto(command.ConveyorLineBarcode, childDeviceCode);
-
-                //if (_taskRepository.QueryFirst(x => x.PalletCode == taskDTO.PalletCode) != null)
+                //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)
                 //{
-                //    WriteInfo(conveyorLine.DeviceName, "褰撳墠鎵樼洏瀛樺湪浠诲姟");
-                //    return;
+                //    throw new InvalidOperationException("MOM IP 鏈厤缃�");
                 //}
-
-                //var content = CreateAndSendTask(taskDTO);
-                //if (content.Status)
+                //var stationManager=_stationManagerRepository.QueryFirst(x=>x.stationChildCode == childDeviceCode);
+                //TrayCellsStatusDto trayCells = new TrayCellsStatusDto()
                 //{
-                //    var task = _taskService.QueryConveyorLineTask(conveyorLine.DeviceCode, childDeviceCode);
-                //    if (task != null)
+                //    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)
                 //    {
-                //        var taskCommand = MapTaskCommand(task, command);
-                //        conveyorLine.SendCommand(taskCommand, childDeviceCode);
-                //        _taskService.UpdateTaskStatusToNext(task);
+                //        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)
+                //                {
+                //                    IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == station.stationPLC);
+                //                    if (device != null)
+                //                    {
+                //                        CommonConveyorLine_After CommonConveyorLine_After = (CommonConveyorLine_After)device;
+                //                        ConveyorLineTaskCommand_After conveyorLineAfter = CommonConveyorLine_After.ReadCustomer<ConveyorLineTaskCommand_After>((Convert.ToInt32(station.stationChildCode)).ToString());
+                //                    }
+                //                    //鍙戦�佸埌鍒嗗
+                //                }
+                //            }
+                //        }
                 //    }
+                //    else
+                //    {
+                //        var strings = new List<string>() { "2142", "2094", "2046" };
+
+                //        foreach (var item in strings)
+                //        {
+                //            var station = _stationManagerRepository.QueryFirst(x => x.productLine == result1.ProductionLine && x.stationChildCode == item);
+                //            if (station != null)
+                //            {
+                //                IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == station.stationPLC);
+                //                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)
+                //                    {
+                //                        Dt_Task task = new Dt_Task()
+                //                        {
+                //                            TaskNum = _taskRepository.GetTaskNo().Result,
+                //                            Grade = 1,
+                //                            PalletCode = command.ConveyorLineBarcode,
+                //                            Roadway = station.Roadway,
+                //                            SourceAddress = childDeviceCode,
+                //                            TargetAddress = station.stationChildCode,
+                //                            CurrentAddress = station.stationChildCode,
+                //                            NextAddress = station.stationChildCode,
+                //                            TaskState = (int)TaskInStatusEnum.InNew,
+                //                            ExceptionMessage = "",
+                //                            TaskId = 0,
+                //                            TaskType = (int)TaskInboundTypeEnum.InTray,
+                //                            ProductionLine = result1.ProductionLine,
+                //                        };
+                //                        _taskRepository.AddData(task);
+                //                        ConveyorLineTaskCommand_After taskCommand = _mapper.Map<ConveyorLineTaskCommand_After>(task);
+                //                        conveyorLine.SendCommand(taskCommand, childDeviceCode);
+                //                        conveyorLine.SetValue(ConveyorLineDBName_After.ResponState, 1, childDeviceCode);
+                //                        _taskService.UpdateTaskStatusToNext(task);
+                //                    }
+                //                }
+                //                //鍙戦�佸埌鍒嗗
+                //                return;
+                //            }
+                //        }
+                //        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);
+                //            }
+                //        }
+                //    }
+
                 //}
+                //else
+                //{
+                //    ConsoleHelper.WriteErrorLine(result1.MOMMessage);
                 //}
+
+
+                if (_taskRepository.QueryFirst(x => x.PalletCode == command.ConveyorLineBarcode) != null)
+                {
+                    WriteInfo(conveyorLine.DeviceName, "褰撳墠鎵樼洏瀛樺湪浠诲姟");
+                    return;
+                }
+
+
+                var taskDTO = CreateEmptyTrayTaskDto(command.ConveyorLineBarcode, childDeviceCode);
+
+
+                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);
+                        //conveyorLine.SetValue(ConveyorLineDBName_After.ResponState, 1, childDeviceCode);
+                        _taskService.UpdateTaskStatusToNext(task);
+                    }
+                }
             }
         }
 
@@ -330,7 +379,7 @@
 
             var config = _sys_ConfigService.GetConfigsByCategory(CateGoryConst.CONFIG_SYS_IPAddress);
             var wmsBase = config.FirstOrDefault(x => x.ConfigKey == SysConfigKeyConst.WMSIP_BASE)?.ConfigValue;
-            var requestTrayInTask = config.FirstOrDefault(x => x.ConfigKey == SysConfigKeyConst.RequestTrayInTask)?.ConfigValue;
+            var requestTrayInTask = config.FirstOrDefault(x => x.ConfigKey == SysConfigKeyConst.RequestTask)?.ConfigValue;
             if (wmsBase == null || requestTrayInTask == null)
             {
                 throw new InvalidOperationException("WMS IP 鏈厤缃�");

--
Gitblit v1.9.3