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/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs |   51 ++++++++++++++++++++++++++++++++++++++-------------
 1 files changed, 38 insertions(+), 13 deletions(-)

diff --git a/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs
index bfa2c3b..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
                         {
@@ -118,12 +119,7 @@
                     }
                     else if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.InboundGroup)
                     {
-                        if (task.SourceAddress == "1359-4")
-                        {
-                            task.TaskState = (int)TaskInStatusEnum.InNew;
-                            task.CurrentAddress = item.SourceAddress;
-                        }
-                        else
+                        if (task.SourceAddress != "1359-4")
                         {
                             List<Dt_Router> routers = _routerService.QueryNextRoutes(item.SourceAddress, item.TargetAddress);
                             if (routers.Count > 0)
@@ -132,6 +128,11 @@
                                 task.CurrentAddress = item.SourceAddress;
                                 task.NextAddress = routers.FirstOrDefault().ChildPosi;
                             }
+                        }
+                        else
+                        {
+                            task.CurrentAddress = "002-021-001";
+                            task.NextAddress = item.TargetAddress;
                         }
                     }
                     tasks.Add(task);
@@ -160,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);
@@ -829,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

--
Gitblit v1.9.3