From 06f5f3e474bb8d9e255a899b62d16f671cfdb940 Mon Sep 17 00:00:00 2001
From: wangxinhui <wangxinhui@hnkhzn.com>
Date: 星期四, 26 六月 2025 17:34:33 +0800
Subject: [PATCH] 代码更新

---
 代码管理/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_Completed.cs |  138 ++++++++++++++++++++++++++++++++++++++++------
 1 files changed, 120 insertions(+), 18 deletions(-)

diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_Completed.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_Completed.cs"
index 5d4650e..a57f13c 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_Completed.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_Completed.cs"
@@ -1,8 +1,10 @@
-锘縰sing System;
+锘縰sing Newtonsoft.Json;
+using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
+using WIDESEA_Common.APIEnum;
 using WIDESEA_Common.CommonEnum;
 using WIDESEA_Common.LocationEnum;
 using WIDESEA_Common.OtherEnum;
@@ -17,22 +19,122 @@
 {
     public partial class TaskService
     {
-        //public WebResponseContent TaskCompleted(int taskNum)
-        //{
-        //    try
-        //    {
-        //        Dt_Task task = Repository.QueryFirst(x => x.TaskNum == taskNum);
-        //        if (task == null)
-        //        {
-        //            return WebResponseContent.Instance.Error($"鏈壘鍒颁换鍔′俊鎭�");
-        //        }
-        //        if(task.TaskType.get)
-               
-        //    }
-        //    catch (Exception ex)
-        //    {
-        //        return WebResponseContent.Instance.Error(ex.Message);
-        //    }
-        //}
+        public async Task<WebResponseContent> TaskCompleted(int taskNum)
+        {
+            try
+            {
+                Dt_Task task = await Repository.QueryFirstAsync(x => x.TaskNum == taskNum);
+                if (task == null)
+                {
+                    return await Task.FromResult(WebResponseContent.Instance.Error($"鏈壘鍒颁换鍔′俊鎭�"));
+                }
+                if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.InboundGroup)
+                {
+                    return await Task.FromResult(InboundTaskCompleted(taskNum));
+                }
+                else if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup)
+                {
+                    return await Task.FromResult(OutboundTaskCompleted(taskNum));
+                }
+                else if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.RelocationGroup)
+                {
+                    return await Task.FromResult(RelocationTaskCompleted(task));
+                }
+                else
+                {
+                    return await Task.FromResult(WebResponseContent.Instance.Error($"鏈壘鍒拌绫诲瀷浠诲姟,浠诲姟绫诲瀷:{task.TaskType}"));
+                }
+            }
+            catch (Exception ex)
+            {
+                return await Task.FromResult(WebResponseContent.Instance.Error(ex.Message));
+            }
+        }
+
+        /// <summary>
+        /// 浠诲姟淇℃伅鎺ㄩ�佽嚦WCS
+        /// </summary>
+        /// <returns></returns>
+        public WebResponseContent PushTasksToWCSSingle(int taskNum, string agvDescription = "", string agvtaskNum = "")
+        {
+            try
+            {
+                Dt_Task task = BaseDal.QueryFirst(x => x.TaskNum == taskNum);
+                if (task == null)
+                {
+                    return WebResponseContent.Instance.Error($"閿欒,鏈壘鍒拌浠诲姟淇℃伅");
+                }
+
+                List<WMSTaskDTO> taskDTOs = new List<WMSTaskDTO> { _mapper.Map<WMSTaskDTO>(task) };
+                taskDTOs.ForEach(x =>
+                {
+                    x.AGVArea = agvDescription;
+                    x.AGVTaskNum = agvtaskNum;
+                });
+
+                string url = AppSettings.Get("WCS");
+                if (string.IsNullOrEmpty(url))
+                {
+                    throw new Exception($"鏈壘鍒癢CSAApi鍦板潃,璇锋鏌ラ厤缃枃浠�");
+                }
+                string response = HttpHelper.Post($"{url}/api/Task/ReceiveTask", taskDTOs.Serialize());
+
+                return JsonConvert.DeserializeObject<WebResponseContent>(response) ?? WebResponseContent.Instance.Error("杩斿洖閿欒");
+            }
+            catch (Exception ex)
+            {
+                return WebResponseContent.Instance.Error(ex.Message);
+            }
+        }
+
+        /// <summary>
+        /// 淇敼浠诲姟鐘舵��
+        /// </summary>
+        /// <param name="task"></param>
+        /// <returns></returns>
+        public WebResponseContent UpdateTaskInfo(WCSTaskDTO task)
+        {
+            try
+            {
+                Dt_Task wmsTask = BaseDal.QueryFirst(x=>x.TaskNum == task.TaskNum);
+                if (wmsTask != null)
+                {
+                    wmsTask.TaskStatus = task.TaskState;
+                    wmsTask.CurrentAddress = task.CurrentAddress;
+                    wmsTask.NextAddress = task.NextAddress;
+                    wmsTask.Dispatchertime = task.Dispatchertime;
+                    BaseDal.UpdateData(wmsTask);
+                }
+                return WebResponseContent.Instance.OK();
+            }
+            catch(Exception ex)
+            {
+                return WebResponseContent.Instance.Error(ex.Message);
+            }
+        }
+        /// <summary>
+        /// 鍥炶皟wcs鎵嬪姩瀹屾垚浠诲姟
+        /// </summary>
+        /// <param name="taskNum"></param>
+        /// <returns></returns>
+        public WebResponseContent FeedBackWCSTaskCompleted(int taskNum)
+        {
+            try
+            {
+                Dt_ApiInfo? url = _apiInfoRepository.QueryData(x => x.ApiCode == APIEnum.FeedBackWCSTaskCompleted.ToString()).First();
+                string? apiAddress = url.ApiAddress;
+                if (string.IsNullOrEmpty(apiAddress))
+                {
+                    return WebResponseContent.Instance.Error($"{taskNum},鏈壘鍒癢CS浠诲姟瀹屾垚鎺ュ彛,璇锋鏌ユ帴鍙i厤缃�");
+                }
+                string responseStr = HttpHelper.Get(apiAddress + "?taskNum=" + taskNum);
+                WebResponseContent content = JsonConvert.DeserializeObject<WebResponseContent>(responseStr) ?? WebResponseContent.Instance.Error("鏈壘鍒颁换鍔″畬鎴愯繑鍥炲��");
+                return content;
+            }
+            catch (Exception ex)
+            {
+                return WebResponseContent.Instance.Error(ex.Message);
+            }
+        }
     }
 }

--
Gitblit v1.9.3