From 58a1b8b7db72225e0c2acca4f76399899f1bda4f Mon Sep 17 00:00:00 2001
From: wankeda <Administrator@DESKTOP-HAU3ST3>
Date: 星期五, 09 一月 2026 15:14:41 +0800
Subject: [PATCH] 1

---
 WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs |  116 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 114 insertions(+), 2 deletions(-)

diff --git a/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs b/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs
index f23c609..9b21e9b 100644
--- a/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs
+++ b/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs
@@ -258,6 +258,63 @@
         }
 
         /// <summary>
+        /// 鎺ユ敹鎴愬搧锛岃緟鏂欙紝鑽按WMS浠诲姟淇℃伅
+        /// </summary>
+        /// <param name="taskDTOs">WMS浠诲姟瀵硅薄闆嗗悎</param>
+        /// <returns>杩斿洖澶勭悊缁撴灉</returns>
+        public WebResponseContent ReceiveWMSCPTask([NotNull] List<WMSTaskDTO> taskDTOs)
+        {
+            WebResponseContent content = new WebResponseContent();
+            try
+            {
+                bool flag = false;
+                List<Dt_Task> tasks = new List<Dt_Task>();
+                List<Dt_Task> tasksOld = BaseDal.QueryData();
+                List<Dt_Router> routersAll = _routerRepository.QueryData();
+                List<Dt_StationManger> stationMangers = _stationMangerRepository.QueryData();
+                foreach (var item in taskDTOs)
+                {
+                    if (tasksOld.FirstOrDefault(x => x.TaskNum == item.TaskNum || x.PalletCode == item.PalletCode) != null)
+                    {
+                        flag = true;
+                        continue;
+                    }
+                    Dt_Task task = _mapper.Map<Dt_Task>(item);
+                    task.Creater = "WMS";
+                    task.TaskState = (int)TaskStatusEnum.New;
+
+                    Dt_Router? router;
+
+                    TaskTypeGroup taskTypeGroup = item.TaskType.GetTaskTypeGroup();
+                    Dt_StationManger? stationManger;
+                    if (taskTypeGroup == TaskTypeGroup.InboundGroup)
+                    {
+                        stationManger = stationMangers.FirstOrDefault(x => x.StationCode == item.NextAddress || x.StationDeviceCode == item.SourceAddress);
+                        task.DeviceCode = stationManger.StationDeviceCode;
+                    }
+                    else
+                    {
+                        stationManger = stationMangers.FirstOrDefault(x => x.StationCode == item.NextAddress || x.StationDeviceCode == item.NextAddress);
+                        task.TaskState = TaskStatusEnum.SC_Execute.ObjToInt();
+                        task.DeviceCode = task.Roadway;
+                        //鍑哄簱
+                    }
+                    tasks.Add(task);
+                }
+                BaseDal.AddData(tasks);
+
+                _taskExecuteDetailService.AddTaskExecuteDetail(tasks.Select(x => x.TaskNum).ToList(), "鎺ユ敹WMS浠诲姟");
+
+                content = (flag || tasks.Count > 0) ? WebResponseContent.Instance.OK("鎴愬姛") : WebResponseContent.Instance.Error("澶辫触");
+            }
+            catch (Exception ex)
+            {
+                content = WebResponseContent.Instance.Error($"浠诲姟鎺ユ敹閿欒,閿欒淇℃伅:{ex.Message}");
+            }
+            return content;
+        }
+
+        /// <summary>
         /// 鏍规嵁鎵樼洏鍙枫�佽捣濮嬪湴鍧�鍚慦MS璇锋眰浠诲姟
         /// </summary>
         /// <param name="palletCode">鎵樼洏鍙�</param>
@@ -354,7 +411,7 @@
         /// <param name="palletCode"></param>
         /// <param name="sourceAddress"></param>
         /// <returns></returns>
-        public WebResponseContent RequestWMSTaskSimple(string palletCode, string sourceAddress)
+        public WebResponseContent RequestWMSTaskSimple(string palletCode, string sourceAddress, int heightType)
         {
             WebResponseContent content = new WebResponseContent();
             try
@@ -364,7 +421,7 @@
                 {
                     return WebResponseContent.Instance.Error($"鏈壘鍒癢MSApi鍦板潃");
                 }
-                string responseStr = HttpHelper.Get($"{address}/api/Task/DeviceRequestInboundTaskSimple?stationCode={sourceAddress}&palletCode={palletCode}");
+                string responseStr = HttpHelper.Get($"{address}/api/Task/DeviceRequestInboundTaskSimple?stationCode={sourceAddress}&palletCode={palletCode}&heightType={heightType}");
                 WebResponseContent? responseContent = JsonConvert.DeserializeObject<WebResponseContent>(responseStr);
                 if (responseContent != null && responseContent.Status && responseContent.Data != null)
                 {
@@ -383,6 +440,61 @@
             return content;
         }
 
+
+        public WebResponseContent CPRequestWMSTaskSimple(string palletCode, string sourceAddress, int heightType, string courceAddress)
+        {
+            WebResponseContent content = new WebResponseContent();
+            try
+            {
+                string address = AppSettings.Get("WMSApiAddress");
+                if (string.IsNullOrEmpty(address))
+                {
+                    return WebResponseContent.Instance.Error($"鏈壘鍒癢MSApi鍦板潃");
+                }
+                string responseStr = HttpHelper.Get($"{address}/api/Task/CPDeviceRequestInboundTaskSimple?stationCode={sourceAddress}&palletCode={palletCode}&heightType={heightType}&courceAddress={courceAddress}");
+                WebResponseContent? responseContent = JsonConvert.DeserializeObject<WebResponseContent>(responseStr);
+                if (responseContent != null && responseContent.Status && responseContent.Data != null)
+                {
+                    WMSTaskDTO? taskDTO = JsonConvert.DeserializeObject<WMSTaskDTO>(responseContent.Data.ToString());
+                    if (taskDTO != null)
+                    {
+                        content = ReceiveWMSTask(new List<WMSTaskDTO> { taskDTO });
+                    }
+                }
+
+            }
+            catch (Exception ex)
+            {
+                content = WebResponseContent.Instance.Error(ex.Message);
+            }
+            return content;
+        }
+
+        public WebResponseContent ApplyLocation(string palletCode)
+        {
+            WebResponseContent content = new WebResponseContent();
+            try
+            {
+                string address = AppSettings.Get("WMSApiAddress");
+                if (string.IsNullOrEmpty(address))
+                {
+                    return WebResponseContent.Instance.Error($"鏈壘鍒癢MSApi鍦板潃");
+                }
+                string responseStr = HttpHelper.Get($"{address}/api/Task/ApplyLocation?palletCode={palletCode}");
+                WebResponseContent? responseContent = JsonConvert.DeserializeObject<WebResponseContent>(responseStr);
+                if (responseContent != null && responseContent.Status && responseContent.Data != null)
+                {
+                    return responseContent;
+                }
+
+            }
+            catch (Exception ex)
+            {
+                content = WebResponseContent.Instance.Error(ex.Message);
+            }
+            return content;
+        }
+
         /// <summary>
         /// 
         /// </summary>

--
Gitblit v1.9.3