From cdabe47ad8128c5006202e55c29746a617e988d6 Mon Sep 17 00:00:00 2001
From: 肖洋 <cathay_xy@163.com>
Date: 星期日, 22 十二月 2024 15:29:57 +0800
Subject: [PATCH] 添加静置NG入库功能,更新相关接口和配置,优化代码结构

---
 Code Management/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/appsettings.json                             |    4 
 Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/CommonConveyorLineJob.cs      |   89 ++++++++----
 Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Partial/RequestInTaskAsync.cs |    2 
 Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Common/Const/SysConfigKeyConst.cs                   |    5 
 Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/appsettings.json                             |    4 
 Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs             |  125 +++++++++++------
 Code Management/WMS/WIDESEA_WMSServer/WIDESEA_IStorageTaskService/Task/IDt_TaskService.cs            |    8 +
 Code Management/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/TaskController.cs                |   12 +
 Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs                      |   44 +++++-
 Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs      |   59 +++++---
 Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/Task/RequestInbound.cs        |   18 --
 11 files changed, 239 insertions(+), 131 deletions(-)

diff --git a/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Common/Const/SysConfigKeyConst.cs b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Common/Const/SysConfigKeyConst.cs
index 5bdf7d0..6840c2e 100644
--- a/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Common/Const/SysConfigKeyConst.cs
+++ b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Common/Const/SysConfigKeyConst.cs
@@ -69,6 +69,9 @@
         /// </summary>
         public const string RequestOutTaskToBZ = "RequestOutTaskToBZ";
 
-
+        /// <summary>
+        /// 闈欑疆NG鍏ュ簱
+        /// </summary>
+        public const string RequestInBoundTaskNG = "RequestInBoundTaskNG";
     }
 }
diff --git a/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/appsettings.json b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/appsettings.json
index 65c2be6..44f23f1 100644
--- a/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/appsettings.json
+++ b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/appsettings.json
@@ -13,8 +13,8 @@
   //杩炴帴瀛楃涓�
   //"ConnectionString": "HTI6FB1H05Krd07mNm9yBCNhofW6edA5zLs9TY~MNthRYW3kn0qKbMIsGp~3yyPDF1YZUCPBQx8U0Jfk4PH~ajNFXVIwlH85M3F~v_qKYQ3CeAz3q1mLVDn8O5uWt1~3Ut2V3KRkEwYHvW2oMDN~QIDXPxDgXN0R2oTIhc9dNu7QNaLEknblqmHhjaNSSpERdDVZIgHnMKejU_SL49tralBkZmDNi0hmkbL~837j1NWe37u9fJKmv91QPb~16JsuI9uu0EvNZ06g6PuZfOSAeFH9GMMIZiketdcJG3tHelo=",
   //"ConnectionString": "Data Source=127.0.0.1;Initial Catalog=WIDESEA_WCS2F08;User ID=sa;Password=P@ssw0rd;Integrated Security=False;Connect Timeout=30;Encrypt=False;TrustServerCertificate=True;ApplicationIntent=ReadWrite;MultiSubnetFailover=True",
-  "ConnectionString": "Data Source=192.168.20.251;Initial Catalog=WIDESEA_WCSDB;User ID=sa;Password=123456@gy;Integrated Security=False;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False",
-  //"ConnectionString": "Data Source=192.168.5.251;Initial Catalog=WIDESEAWCS_TEST;User ID=sa;Password=P@ssw0rd;Integrated Security=False;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False",
+  //"ConnectionString": "Data Source=192.168.20.251;Initial Catalog=WIDESEA_WCSDB;User ID=sa;Password=123456@gy;Integrated Security=False;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False",
+  "ConnectionString": "Data Source=192.168.5.251;Initial Catalog=WIDESEAWCS_TEST;User ID=sa;Password=P@ssw0rd;Integrated Security=False;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False",
   //璺ㄥ煙
   "Cors": {
     "PolicyName": "CorsIpAccess", //绛栫暐鍚嶇О
diff --git a/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs
index 9b1276e..3335a9f 100644
--- a/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs
+++ b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs
@@ -90,10 +90,11 @@
                     task.Creater = "WMS";
                     if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup)
                     {
-                        if (task.TargetAddress == "002-021-001")
+                        if (task.TargetAddress == "002-021-001" && task.Roadway.Contains("JZ") && task.TaskType == (int)TaskOutboundTypeEnum.OutTray)
                         {
                             task.TaskState = (int)TaskOutStatusEnum.OutNew;
                             task.CurrentAddress = item.SourceAddress;
+                            task.NextAddress = item.TargetAddress;
                         }
                         else
                         {
@@ -128,6 +129,11 @@
                                 task.NextAddress = routers.FirstOrDefault().ChildPosi;
                             }
                         }
+                        else
+                        {
+                            task.CurrentAddress = "002-021-001";
+                            task.NextAddress = item.TargetAddress;
+                        }
                     }
                     tasks.Add(task);
                 }
@@ -155,20 +161,31 @@
             WebResponseContent content = new WebResponseContent();
             try
             {
+
                 var hasTask = await BaseDal.QueryFirstAsync(x => x.PalletCode == palletCode);
                 if (hasTask != null)
                 {
                     return content.OK("褰撳墠鎵樼洏瀛樺湪浠诲姟");
                 }
 
-                var config = _sys_ConfigService.GetConfigsByCategory(CateGoryConst.CONFIG_SYS_IPAddress);
-                var wmsBase = config.FirstOrDefault(x => x.ConfigKey == SysConfigKeyConst.WMSIP_BASE)?.ConfigValue;
-                var requestTask = config.FirstOrDefault(x => x.ConfigKey == SysConfigKeyConst.RequestTask)?.ConfigValue;
-                if (wmsBase == null || requestTask == null)
+                var wmsIpAddrss = string.Empty;
+                var stationManager = _stationManagerRepository.QueryFirst(x => x.stationChildCode == sourceAddress);
+                if (stationManager.stationType == 5)
                 {
-                    throw new InvalidOperationException("WMS IP 鏈厤缃�");
+                    wmsIpAddrss = GetIpAddress(SysConfigKeyConst.WMSIP_BASE, SysConfigKeyConst.RequestInBoundTaskNG);
                 }
-                var wmsIpAddrss = wmsBase + requestTask;
+                else
+                {
+                    wmsIpAddrss = GetIpAddress(SysConfigKeyConst.WMSIP_BASE, SysConfigKeyConst.RequestTask);
+                }
+                //var config = _sys_ConfigService.GetConfigsByCategory(CateGoryConst.CONFIG_SYS_IPAddress);
+                //var wmsBase = config.FirstOrDefault(x => x.ConfigKey == SysConfigKeyConst.WMSIP_BASE)?.ConfigValue;
+                //var requestTask = config.FirstOrDefault(x => x.ConfigKey == SysConfigKeyConst.RequestTask)?.ConfigValue;
+                //if (wmsBase == null || requestTask == null)
+                //{
+                //    throw new InvalidOperationException("WMS IP 鏈厤缃�");
+                //}
+                //var wmsIpAddrss = wmsBase + requestTask;
 
                 var result = await HttpHelper.PostAsync(wmsIpAddrss, new { Position = sourceAddress, PalletCode = palletCode }.ToJsonString());
                 content = JsonConvert.DeserializeObject<WebResponseContent>(result);
@@ -824,5 +841,18 @@
         {
             return BaseDal.QueryFirst(x => x.PalletCode == barcode && x.NextAddress == nextAddress && (x.TaskState == (int)TaskInStatusEnum.Line_InExecuting || x.TaskState == (int)TaskOutStatusEnum.Line_OutExecuting), TaskOrderBy);
         }
+
+
+        private string GetIpAddress(string baseIp,string name)
+        {
+            var configz = _sys_ConfigService.GetConfigsByCategory(CateGoryConst.CONFIG_SYS_IPAddress);
+            var wcsBasez = configz.Where(x => x.ConfigKey == baseIp).FirstOrDefault()?.ConfigValue;
+            var address = configz.Where(x => x.ConfigKey == name).FirstOrDefault()?.ConfigValue;
+            if (wcsBasez == null || address == null)
+            {
+                throw new InvalidOperationException("WMS IP 鏈厤缃�");
+            }
+            return wcsBasez + address;
+        }
     }
 }
\ No newline at end of file
diff --git a/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/CommonConveyorLineJob.cs b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/CommonConveyorLineJob.cs
index 29da0ea..22255f1 100644
--- a/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/CommonConveyorLineJob.cs
+++ b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/CommonConveyorLineJob.cs
@@ -24,6 +24,7 @@
 using WIDESEAWCS_QuartzJob.Service;
 using WIDESEAWCS_SignalR;
 using WIDESEAWCS_Tasks.ConveyorLineJob;
+using static Microsoft.EntityFrameworkCore.DbLoggerCategory.Database;
 using ICacheService = WIDESEAWCS_Core.Caches.ICacheService;
 
 namespace WIDESEAWCS_Tasks
@@ -61,54 +62,76 @@
         public async Task Execute(IJobExecutionContext context)
         {
             string jobName = context.JobDetail.Key.Name;
-            if (MemoryLockManager.TryAcquireLock(jobName))
+            //if (MemoryLockManager.TryAcquireLock(jobName))
+            //{
+            try
             {
-                try
+                CommonConveyorLine conveyorLine = (CommonConveyorLine)context.JobDetail.JobDataMap.Get("JobParams");
+                if (conveyorLine != null)
                 {
-                    CommonConveyorLine conveyorLine = (CommonConveyorLine)context.JobDetail.JobDataMap.Get("JobParams");
-                    if (conveyorLine != null)
-                    {
-                        List<string> childDeviceCodes = _routerService.QueryAllPositions(conveyorLine.DeviceCode);
-                        var tasks = childDeviceCodes.Select(childDeviceCode => ProcessDeviceAsync(conveyorLine, childDeviceCode)).ToList();
-                        await Task.WhenAll(tasks);
+                    List<string> childDeviceCodes = _routerService.QueryAllPositions(conveyorLine.DeviceCode);
+                    var tasks = childDeviceCodes.Select(childDeviceCode => ProcessDeviceAsync(conveyorLine, childDeviceCode)).ToList();
+                    await Task.WhenAll(tasks);
 
-                        List<Dt_StationManager> stationManagers = _stationManagerService.GetAllStationByDeviceCode(conveyorLine.DeviceCode);
-                        foreach (var station in stationManagers)
+                    List<Dt_StationManager> stationManagers = _stationManagerService.GetAllStationByDeviceCode(conveyorLine.DeviceCode);
+                    foreach (var station in stationManagers)
+                    {
+                        if (station.stationType == 11)
                         {
-                            if (station.stationType == 11)
+                            ConveyorLineTaskCommand command = conveyorLine.ReadCustomer<ConveyorLineTaskCommand>(station.stationChildCode);
+                            ConveyorLineTaskCommandWrite commandWrite = conveyorLine.ReadCustomer<ConveyorLineTaskCommandWrite>(station.stationChildCode, "DeviceCommand");
+                            if (command != null && commandWrite != null)
                             {
-                                ConveyorLineTaskCommand command = conveyorLine.ReadCustomer<ConveyorLineTaskCommand>(station.stationChildCode);
-                                ConveyorLineTaskCommandWrite commandWrite = conveyorLine.ReadCustomer<ConveyorLineTaskCommandWrite>(station.stationChildCode, "DeviceCommand");
-                                if (command != null && commandWrite != null)
+                                var structs = BitConverter.GetBytes(commandWrite.WriteInteractiveSignal).Reverse().ToArray().ToBoolArray();
+                                if (structs[0] == true)
                                 {
-                                    var structs = BitConverter.GetBytes(commandWrite.WriteInteractiveSignal).Reverse().ToArray().ToBoolArray();
-                                    if (structs[0] == true)
+                                    ConsoleHelper.WriteWarningLine($"銆恵conveyorLine.DeviceName}銆戜换鍔″彿锛氥�恵command.TaskNum}銆�,鎵樼洏鏉$爜锛氥�恵command.Barcode}銆戝凡鍒拌揪銆恵station.stationChildCode}銆戠┖鎵樼洏璇锋眰鎵爜鍏ュ簱");
+                                    NGRequestTaskInbound(conveyorLine, command, station.stationChildCode, 0, station.stationLocation);
+                                }
+                                else
+                                {
+                                    ConveyorLineSendFinish(conveyorLine, station.stationChildCode, 0, false);
+                                }
+                            }
+                        }
+                        else if (station.stationType == 5)
+                        {
+                            ConveyorLineTaskCommand command = conveyorLine.ReadCustomer<ConveyorLineTaskCommand>(station.stationChildCode);
+                            ConveyorLineTaskCommandWrite commandWrite = conveyorLine.ReadCustomer<ConveyorLineTaskCommandWrite>(station.stationChildCode, "DeviceCommand");
+                            if (command != null && commandWrite != null)
+                            {
+                                var structs = BitConverter.GetBytes(commandWrite.WriteInteractiveSignal).Reverse().ToArray().ToBoolArray();
+                                if (structs[0] == true)
+                                {
+                                    if (_taskRepository.QueryData(x => x.SourceAddress == station.stationChildCode).Count() > 0)
                                     {
-                                        ConsoleHelper.WriteWarningLine($"銆恵conveyorLine.DeviceName}銆戜换鍔″彿锛氥�恵command.TaskNum}銆�,鎵樼洏鏉$爜锛氥�恵command.Barcode}銆戝凡鍒拌揪銆恵station.stationChildCode}銆戠┖鎵樼洏璇锋眰鎵爜鍏ュ簱");
-                                        NGRequestTaskInbound(conveyorLine, command, station.stationChildCode, 0, station.stationLocation);
+                                        return;
                                     }
-                                    else
-                                    {
-                                        ConveyorLineSendFinish(conveyorLine, station.stationChildCode, 0, false);
-                                    }
+                                    ConsoleHelper.WriteWarningLine($"銆恵conveyorLine.DeviceName}銆戜换鍔″彿锛氥�恵command.TaskNum}銆�,鎵樼洏鏉$爜锛氥�恵command.Barcode}銆戝凡鍒拌揪銆恵station.stationChildCode}銆戝紓甯稿彛璇锋眰鎵爜鍏ュ簱");
+                                    HandleNewTask(conveyorLine, command, station.stationChildCode, 0);
+                                }
+                                else
+                                {
+                                    ConveyorLineSendFinish(conveyorLine, station.stationChildCode, 0, false);
                                 }
                             }
                         }
                     }
                 }
-                catch (Exception ex)
-                {
-                    Console.Out.WriteLine(nameof(CommonConveyorLineJob) + ":" + ex.ToString());
-                }
-                finally
-                {
-                    MemoryLockManager.ReleaseLock(jobName);
-                }
             }
-            else
+            catch (Exception ex)
             {
-                ConsoleHelper.WriteErrorLine($"[CommonConveyorLineJob]銆恵jobName}銆戜换鍔″凡琚攣瀹氾紝鏃犳硶澶勭悊");
+                Console.Out.WriteLine(nameof(CommonConveyorLineJob) + ":" + ex.ToString());
             }
+            //    finally
+            //    {
+            //        MemoryLockManager.ReleaseLock(jobName);
+            //    }
+            //}
+            //else
+            //{
+            //    ConsoleHelper.WriteErrorLine($"[CommonConveyorLineJob]銆恵jobName}銆戜换鍔″凡琚攣瀹氾紝鏃犳硶澶勭悊");
+            //}
             return;
         }
 
@@ -361,7 +384,7 @@
             {
                 if (command.Barcode == task.PalletCode && childDeviceCode == task.NextAddress)
                 {
-                    conveyorLine.SetValue(ConveyorLineDBName.ConveyorLineTargetAddress, "1000", childDeviceCode);
+                    //conveyorLine.SetValue(ConveyorLineDBName.ConveyorLineTargetAddress, "1000", childDeviceCode);
 
                     ConsoleHelper.WriteWarningLine($"銆恵conveyorLine._deviceName}銆戜换鍔″彿锛氥�恵command.TaskNum}銆�,鎵樼洏鏉$爜锛氥�恵command.Barcode}銆戝凡鍒拌揪銆恵childDeviceCode}銆戣緭閫佺嚎鍏ュ簱瀹屾垚,涓嬩竴鐩爣鍦板潃銆愮瓑寰呭垎閰嶈揣浣�,骞跺啓鍏�1000銆�");
 
diff --git a/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/Task/RequestInbound.cs b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/Task/RequestInbound.cs
index 58c8266..ad7ba95 100644
--- a/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/Task/RequestInbound.cs
+++ b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/Task/RequestInbound.cs
@@ -79,19 +79,6 @@
                 default:
                     break;
             }
-
-            //if ((conveyorLine.DeviceCode == "1003" && childDeviceCode == "1016") || (conveyorLine.DeviceCode == "1005" && childDeviceCode == "1048"))
-            //{
-            //    await CreateAndSendEmptyTrayTask(conveyorLine, command, childDeviceCode, ProtocalDetailValue);
-            //}
-            //else if ((conveyorLine.DeviceCode == "1001" && childDeviceCode == "1088") || (conveyorLine.DeviceCode == "1004" && childDeviceCode == "1339"))
-            //{
-            //    await RequestWmsTask(conveyorLine, command, childDeviceCode, ProtocalDetailValue);
-            //}
-            //else if ((conveyorLine.DeviceCode == "1001" && childDeviceCode == "1068"))
-            //{
-            //    ConveyorLineOutFinish(conveyorLine, command, childDeviceCode, ProtocalDetailValue);
-            //}
         }
 
         /// <summary>
@@ -215,16 +202,17 @@
         /// </summary>
         private async Task RequestWmsTask(CommonConveyorLine conveyorLine, ConveyorLineTaskCommand command, string childDeviceCode, int ProtocalDetailValue)
         {
+
             var content = await _taskService.RequestWMSTask(command.Barcode, childDeviceCode);
             if (content.Status)
             {
                 var task = _taskService.QueryBarCodeConveyorLineTask(command.Barcode, childDeviceCode);
                 if (task != null)
                 {
-                    if (task.TargetAddress == childDeviceCode)
+                    if (task.SourceAddress == "1059-4")
                     {
 
-                        conveyorLine.SetValue(ConveyorLineDBName.ConveyorLineTargetAddress, "1000", childDeviceCode);
+                        //conveyorLine.SetValue(ConveyorLineDBName.ConveyorLineTargetAddress, "1000", childDeviceCode);
 
                         ConsoleHelper.WriteWarningLine($"銆恵conveyorLine._deviceName}銆戜换鍔″彿锛氥�恵task.TaskNum}銆�,鎵樼洏鏉$爜锛氥�恵task.PalletCode}銆戝凡鍒拌揪銆恵childDeviceCode}銆戣姹傛壂鐮佸叆搴�(瀹炵洏),涓嬩竴鐩爣鍦板潃銆恵1000}銆�");
                         ConveyorLineSendFinish(conveyorLine, childDeviceCode, ProtocalDetailValue, true);
diff --git a/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs
index 8ef6897..1e09dcf 100644
--- a/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs
+++ b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs
@@ -370,7 +370,7 @@
             stackerCraneTaskCommand.StartCommand = 1;
             if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.InboundGroup)//鍒ゆ柇鏄惁鏄叆搴撲换鍔�
             {
-                if (task.Roadway.Contains("JZ"))
+                if (task.SourceAddress == "1359-4" && task.Roadway.Contains("JZ"))
                 {
                     string[] souredCodes = task.CurrentAddress.Split("-");
                     if (souredCodes.Length == 3)
@@ -444,31 +444,46 @@
                 }
                 else
                 {
-                    List<Dt_Router> routers = _routerService.QueryNextRoutes(task.Roadway, task.TargetAddress);
-                    if (routers.Count > 0)
-                    {
-                        stackerCraneTaskCommand.EndRow = Convert.ToInt16(routers.FirstOrDefault().SrmRow);
-                        stackerCraneTaskCommand.EndColumn = Convert.ToInt16(routers.FirstOrDefault().SrmColumn);
-                        stackerCraneTaskCommand.EndLayer = Convert.ToInt16(routers.FirstOrDefault().SrmLayer);
 
-                        string[] sourceCodes = task.CurrentAddress.Split("-");
-                        if (sourceCodes.Length == 3)
-                        {
-                            stackerCraneTaskCommand.StartRow = Convert.ToInt16(sourceCodes[0]) % 2 != 0 ? (short)1 : (short)2;
-                            stackerCraneTaskCommand.StartColumn = Convert.ToInt16(sourceCodes[1]);
-                            stackerCraneTaskCommand.StartLayer = Convert.ToInt16(sourceCodes[2]);
-                        }
-                        else
-                        {
-                            //鏁版嵁閰嶇疆閿欒
-                            _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"鍑哄簱浠诲姟璧风偣閿欒锛岃捣鐐癸細銆恵task.CurrentAddress}銆�");
-                            return null;
-                        }
+                    if (task.TargetAddress == "002-021-001" && task.Roadway.Contains("JZ") && task.TaskType == (int)TaskOutboundTypeEnum.OutTray)
+                    {
+                        string[] endCodes = task.NextAddress.Split("-");
+                        stackerCraneTaskCommand.EndRow = Convert.ToInt16(endCodes[0]);
+                        stackerCraneTaskCommand.EndColumn = Convert.ToInt16(endCodes[1]);
+                        stackerCraneTaskCommand.EndLayer = Convert.ToInt16(endCodes[2]);
+                        string[] sourceCodes = task.SourceAddress.Split("-");
+                        stackerCraneTaskCommand.StartRow = Convert.ToInt16(sourceCodes[0]) % 2 != 0 ? (short)1 : (short)2;
+                        stackerCraneTaskCommand.StartColumn = Convert.ToInt16(sourceCodes[1]);
+                        stackerCraneTaskCommand.StartLayer = Convert.ToInt16(sourceCodes[2]);
                     }
                     else
                     {
-                        _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"鏈壘鍒扮珯鍙般�恵task.NextAddress}銆戜俊鎭紝鏃犳硶鑾峰彇瀵瑰簲鐨勫爢鍨涙満鏀捐揣绔欏彴淇℃伅");
-                        return null;
+                        List<Dt_Router> routers = _routerService.QueryNextRoutes(task.Roadway, task.TargetAddress);
+                        if (routers.Count > 0)
+                        {
+                            stackerCraneTaskCommand.EndRow = Convert.ToInt16(routers.FirstOrDefault().SrmRow);
+                            stackerCraneTaskCommand.EndColumn = Convert.ToInt16(routers.FirstOrDefault().SrmColumn);
+                            stackerCraneTaskCommand.EndLayer = Convert.ToInt16(routers.FirstOrDefault().SrmLayer);
+
+                            string[] sourceCodes = task.CurrentAddress.Split("-");
+                            if (sourceCodes.Length == 3)
+                            {
+                                stackerCraneTaskCommand.StartRow = Convert.ToInt16(sourceCodes[0]) % 2 != 0 ? (short)1 : (short)2;
+                                stackerCraneTaskCommand.StartColumn = Convert.ToInt16(sourceCodes[1]);
+                                stackerCraneTaskCommand.StartLayer = Convert.ToInt16(sourceCodes[2]);
+                            }
+                            else
+                            {
+                                //鏁版嵁閰嶇疆閿欒
+                                _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"鍑哄簱浠诲姟璧风偣閿欒锛岃捣鐐癸細銆恵task.CurrentAddress}銆�");
+                                return null;
+                            }
+                        }
+                        else
+                        {
+                            _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"鏈壘鍒扮珯鍙般�恵task.NextAddress}銆戜俊鎭紝鏃犳硶鑾峰彇瀵瑰簲鐨勫爢鍨涙満鏀捐揣绔欏彴淇℃伅");
+                            return null;
+                        }
                     }
                 }
             }
diff --git a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_IStorageTaskService/Task/IDt_TaskService.cs b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_IStorageTaskService/Task/IDt_TaskService.cs
index 82858a6..5338032 100644
--- a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_IStorageTaskService/Task/IDt_TaskService.cs
+++ b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_IStorageTaskService/Task/IDt_TaskService.cs
@@ -190,6 +190,14 @@
     Task<WebResponseContent> CreateAndSendOutboundTask(string locationCode, string palletCode);
 
     /// <summary>
+    /// 鎸囧畾浠诲姟鍑哄簱
+    /// </summary>
+    /// <param name="palletCode">鎵樼洏鍙�</param>
+    /// <param name="position">浣嶇疆</param>
+    /// <returns></returns>
+    Task<WebResponseContent> CreateAndSendInboundTask(string palletCode, string position);
+
+    /// <summary>
     /// 甯告俯琛ョ┖鎵樼洏鑷冲垎瀹�
     /// </summary>
     /// <param name="taskDTO"></param>
diff --git a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs
index 04de7fa..1764161 100644
--- a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs
+++ b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs
@@ -1,6 +1,7 @@
 锘縰sing Mapster;
 using Masuit.Tools;
 using System.Text.RegularExpressions;
+using System.Threading.Tasks;
 using WIDESEA_Core.Const;
 using WIDESEA_DTO.MOM;
 using WIDESEA_DTO.WMS;
@@ -285,7 +286,7 @@
         WebResponseContent content = new WebResponseContent();
         try
         {
-            if (task.TaskType == (int)TaskInboundTypeEnum.InNG)
+            if (task.TaskType == (int)TaskInboundTypeEnum.InNG || task.TaskType == (int)TaskInboundTypeEnum.InQuality)
             {
                 task.TaskState = (int)TaskInStatusEnum.SC_InFinish;
                 // 鍒涘缓鍘嗗彶浠诲姟瀹炰緥妯″瀷
@@ -430,6 +431,8 @@
                 area = _areaInfoRepository.QueryFirst(x => x.AreaID == 6);
             else if (boxing.ProcessCode == "OCVB")
                 area = _areaInfoRepository.QueryFirst(x => x.AreaID == 7);
+            else
+                area = _areaInfoRepository.QueryFirst(x => x.AreaID == loation.AreaId);
 
             if (area == null)
                 throw new Exception("鏈壘鍒板搴斿尯鍩熶俊鎭�");
@@ -537,6 +540,7 @@
             case (int)TaskInboundTypeEnum.Inbound:
             case (int)TaskInboundTypeEnum.InTray:
             case (int)TaskInboundTypeEnum.InNG:
+            case (int)TaskInboundTypeEnum.InQuality:
                 LogFactory.GetLog("浠诲姟瀹屾垚").InfoFormat(true, "鍏ュ簱浠诲姟", "");
                 return await CompleteInboundTaskAsync(task);
 
@@ -1332,65 +1336,82 @@
             var stockInfo = await _stockInfoRepository.QueryFirstNavAsync(x => x.PalletCode == palletCode);
             if (stockInfo == null)
             {
+                var taskOld = BaseDal.QueryFirst(x => x.PalletCode == palletCode);
+                if (!taskOld.IsNullOrEmpty())
+                {// 鍒涘缓WMS浠诲姟
+                    WMSTaskDTO taskDTO = new WMSTaskDTO()
+                    {
+                        TaskNum = taskOld.TaskNum.Value,
+                        Grade = 1,
+                        PalletCode = taskOld.PalletCode,
+                        RoadWay = taskOld.Roadway,
+                        SourceAddress = taskOld.CurrentAddress,
+                        TargetAddress = taskOld.TargetAddress,
+                        TaskState = taskOld.TaskState.Value,
+                        Id = 0,
+                        TaskType = taskOld.TaskType,
+                    };
+                    return content.OK(data: taskDTO);
+                }
                 var area = _areaInfoRepository.QueryFirst(x => x.AreaID == 2);
                 var station = _stationManagerRepository.QueryFirst(x => x.stationChildCode == position);
                 TrayCellsStatusDto trayCells = CreateTrayCellsStatusDto(area, palletCode);
                 content = await GetTrayCellStatusAsync(trayCells);
                 if (!content.Status) return content;
 
+                ConsoleHelper.WriteErrorLine(content.ToJsonString());
                 var result = JsonConvert.DeserializeObject<ResultTrayCellsStatus>(content.Data.ToString());
-                if (!result.Success)
+                if (result.SerialNos.Count > 0)
                 {
-                    if (result.SerialNos.Count <= 0)
+                    var location = await GetLocationDistributeAsync(station.Roadway);
+
+                    ConsoleHelper.WriteErrorLine(location.ToJsonString());
+                    // 鍒涘缓鏂颁换鍔″疄渚�
+                    var task = new Dt_Task
                     {
-                        var location = await GetLocationDistributeAsync(station.Roadway);
-                        // 鍒涘缓鏂颁换鍔″疄渚�
-                        var task = new Dt_Task
-                        {
-                            CurrentAddress = station.stationLocation,
-                            Grade = 1,
-                            Roadway = station.Roadway,
-                            TargetAddress = location.LocationCode,
-                            Dispatchertime = DateTime.Now,
-                            MaterialNo = "",
-                            NextAddress = location.LocationCode,
-                            OrderNo = null,
-                            PalletCode = palletCode,
-                            SourceAddress = position,
-                            TaskState = (int)TaskInStatusEnum.Line_InFinish,
-                            TaskType = (int)TaskInboundTypeEnum.Inbound,
-                            TaskNum = await BaseDal.GetTaskNo(),
-                            Creater = "Systeam"
-                        };
+                        CurrentAddress = station.stationLocation,
+                        Grade = 1,
+                        Roadway = station.Roadway,
+                        TargetAddress = location.LocationCode,
+                        Dispatchertime = DateTime.Now,
+                        MaterialNo = "",
+                        NextAddress = location.LocationCode,
+                        OrderNo = null,
+                        PalletCode = palletCode,
+                        SourceAddress = position,
+                        TaskState = (int)TaskInStatusEnum.Line_InFinish,
+                        TaskType = (int)TaskInboundTypeEnum.Inbound,
+                        TaskNum = await BaseDal.GetTaskNo(),
+                        Creater = "Systeam"
+                    };
 
-                        // 鍒涘缓WMS浠诲姟
-                        WMSTaskDTO taskDTO = new WMSTaskDTO()
-                        {
-                            TaskNum = task.TaskNum.Value,
-                            Grade = 1,
-                            PalletCode = task.PalletCode,
-                            RoadWay = task.Roadway,
-                            SourceAddress = task.SourceAddress,
-                            TargetAddress = task.Roadway,
-                            TaskState = task.TaskState.Value,
-                            Id = 0,
-                            TaskType = task.TaskType,
-                        };
+                    // 鍒涘缓WMS浠诲姟
+                    WMSTaskDTO taskDTO = new WMSTaskDTO()
+                    {
+                        TaskNum = task.TaskNum.Value,
+                        Grade = 1,
+                        PalletCode = task.PalletCode,
+                        RoadWay = task.Roadway,
+                        SourceAddress = task.SourceAddress,
+                        TargetAddress = task.TargetAddress,
+                        TaskState = task.TaskState.Value,
+                        Id = 0,
+                        TaskType = task.TaskType,
+                    };
 
-                        await _unitOfWorkManage.UseTranAsync(async () =>
-                        {
-                            // 娣诲姞浠诲姟鍒版暟鎹簱
-                            await BaseDal.AddDataAsync(task);
-                            // 鏇存柊搴撳瓨浣嶇疆鐘舵�佷负涓嶅彲鐢�
-                            location.LocationStatus = (int)LocationEnum.InStockDisable;
-                            await _locationRepository.UpdateDataAsync(location);
-                        });
+                    await _unitOfWorkManage.UseTranAsync(async () =>
+                    {
+                        // 娣诲姞浠诲姟鍒版暟鎹簱
+                        await BaseDal.AddDataAsync(task);
+                        // 鏇存柊搴撳瓨浣嶇疆鐘舵�佷负涓嶅彲鐢�
+                        location.LocationStatus = (int)LocationEnum.InStockDisable;
+                        await _locationRepository.UpdateDataAsync(location);
+                    });
 
-                        content.OK(data: taskDTO);
-                    }
-                    else
-                        content.Error(result.MOMMessage);
+                    content.OK(data: taskDTO);
                 }
+                else
+                    content.Error(result.MOMMessage);
             }
             else
             {
@@ -1688,6 +1709,14 @@
             var content = new WebResponseContent();
 
             // 鑾峰彇鐩爣鍦板潃鍜屾洿鏂颁换鍔$姸鎬�
+
+
+            input.Position = Regex.Replace(input.Position, @"-(\d+)", "");
+            if (Convert.ToInt32(input.Position) > 1999)
+            {
+                input.Position = (Convert.ToInt32(input.Position) - 1000).ToString();
+            }
+
             if (task.TaskType == (int)TaskInboundTypeEnum.InNG)
             {
                 // TODO 鏍规嵁宸烽亾鏌ユ壘瀵瑰簲NG鍙o紝鐜板湪榛樿鍘婚潤缃爢鍨涙満鐨勫紓甯稿彛璐т綅鍙�
@@ -1700,7 +1729,7 @@
             }
             else if (task.TaskType == (int)TaskInboundTypeEnum.InQuality)
             {
-                var stockInfo = _stockInfoRepository.QueryFirst(x => x.PalletCode == input.PalletCode);
+                var stockInfo = await _stockInfoRepository.QueryFirstNavAsync(x => x.PalletCode == input.PalletCode);
                 task.CurrentAddress = input.Position;
                 task.TargetAddress = stockInfo.LocationInfo.LocationCode;
                 task.NextAddress = stockInfo.LocationInfo.LocationCode;
diff --git a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Partial/RequestInTaskAsync.cs b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Partial/RequestInTaskAsync.cs
index 611c289..ecc7227 100644
--- a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Partial/RequestInTaskAsync.cs
+++ b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Partial/RequestInTaskAsync.cs
@@ -44,7 +44,7 @@
         //var station = stationManagers.Select(x => x.stationChildCode).ToList();
 
         //// 鑾峰彇WCSip鍦板潃鐩稿叧閰嶇疆
-        //var wcsIpAddrss = GetWCSIpAddress();
+        var wcsIpAddrss = GetWCSIpAddress();
         //if (wcsIpAddrss == null)
         //{
         //    throw new InvalidOperationException("WCS IP 鏈厤缃�");
diff --git a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/TaskController.cs b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/TaskController.cs
index 662da3a..e7c31d9 100644
--- a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/TaskController.cs
+++ b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/TaskController.cs
@@ -146,6 +146,18 @@
     }
 
     /// <summary>
+    /// 闈欑疆NG鍏ュ簱
+    /// </summary>
+    /// <param name="locationCode">璐т綅鍙�</param>
+    /// <param name="palletCode">鎵樼洏鍙�</param>
+    /// <returns></returns>
+    [HttpPost, AllowAnonymous, Route("RequestInBoundTaskNG")]
+    public async Task<WebResponseContent> RequestInBoundTaskNG([FromBody] RequestTaskDto input)
+    {
+        return await Service.CreateAndSendInboundTask(input.PalletCode, input.Position);
+    }
+
+    /// <summary>
     /// 甯告俯琛ョ┖鎵樼洏鑷冲垎瀹�
     /// </summary>
     /// <param name="input">璇锋眰鏁版嵁</param>
diff --git a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/appsettings.json b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/appsettings.json
index 6a31190..e36aa41 100644
--- a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/appsettings.json
+++ b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/appsettings.json
@@ -10,9 +10,9 @@
   "MainDB": "DB_WIDESEA", //褰撳墠椤圭洰鐨勪富搴擄紝鎵�瀵瑰簲鐨勮繛鎺ュ瓧绗︿覆鐨凟nabled蹇呴』涓簍rue
   //杩炴帴瀛楃涓�
   //"ConnectionString": "HTI6FB1H05Krd07mNm9yBCNhofW6edA5zLs9TY~MNthRYW3kn0qKbMIsGp~3yyPDF1YZUCPBQx8U0Jfk4PH~ajNFXVIwlH85M3F~v_qKYQ3CeAz3q1mLVDn8O5uWt1~3Ut2V3KRkEwYHvW2oMDN~QIDXPxDgXN0R2oTIhc9dNu7QNaLEknblqmHhjaNSSpERdDVZIgHnMKejU_SL49tralBkZmDNi0hmkbL~837j1NWe37u9fJKmv91QPb~16JsuI9uu0EvNZ06g6PuZfOSAeFH9GMMIZiketdcJG3tHelo=",
-  //"ConnectionString": "Data Source=192.168.5.251;Initial Catalog=WIDESEA_WMSDB_BBMain;User ID=sa;Password=P@ssw0rd;Integrated Security=False;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False",
+  "ConnectionString": "Data Source=192.168.5.251;Initial Catalog=WIDESEA_WMSDB_BBMain;User ID=sa;Password=P@ssw0rd;Integrated Security=False;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False",
   //"ConnectionString": "Data Source=127.0.0.1;Initial Catalog=WIDESEA_WMS2F08;User ID=sa;Password=P@ssw0rd;Integrated Security=False;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False",
-  "ConnectionString": "Data Source=.\\LIULEI;Initial Catalog=WIDESEA_WMSDB_BBMain;User ID=sa;Password=123456;Integrated Security=False;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False",
+  //"ConnectionString": "Data Source=.\\LIULEI;Initial Catalog=WIDESEA_WMSDB_BBMain;User ID=sa;Password=123456;Integrated Security=False;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False",
   //"ConnectionString": "Data Source=192.168.20.251;Initial Catalog=WIDESEA_WMSDB;User ID=sa;Password=123456@gy;Integrated Security=False;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False",
 
   //璺ㄥ煙

--
Gitblit v1.9.3