From 741cc4cde8bc475366891e795988a11153eae07c Mon Sep 17 00:00:00 2001
From: wangxinhui <wangxinhui@hnkhzn.com>
Date: 星期五, 10 一月 2025 22:48:39 +0800
Subject: [PATCH] Merge branch 'master' of http://115.159.85.185:8098/r/MeiRuiAn/HuaiAn

---
 代码管理/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs |   65 +++++++++++++++++++++++++++-----
 1 files changed, 55 insertions(+), 10 deletions(-)

diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs"
index 248436a..50fb3c7 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs"
@@ -116,7 +116,8 @@
                 Dt_Task task = BaseDal.QueryFirst(x => x.TaskNum == taskNum);
                 if (task != null)
                 {
-                    BaseDal.DeleteAndMoveIntoHty(task, App.User == null ? OperateTypeEnum.鑷姩瀹屾垚 : OperateTypeEnum.浜哄伐瀹屾垚);
+                    task.TaskState = TaskStatusEnum.Finish.ObjToInt();
+                    BaseDal.DeleteAndMoveIntoHty(task, App.User?.UserId == 0 ? OperateTypeEnum.鑷姩瀹屾垚 : OperateTypeEnum.浜哄伐瀹屾垚);
                 }
                 string? url = apiInfos.FirstOrDefault(x => x.ApiCode == APIEnum.FeedBackWMSTaskCompleted.ToString())?.ApiAddress;
                 if (string.IsNullOrEmpty(url))
@@ -169,7 +170,7 @@
                         Dt_StationManger stationManger;
                         if (taskTypeGroup == TaskTypeGroup.InboundGroup)
                         {
-                            stationManger = _stationMangerRepository.QueryFirst(x => x.StationCode == item.SourceAddress);
+                            stationManger = _stationMangerRepository.QueryFirst(x => x.StationCode == item.SourceAddress || x.StationDeviceCode == item.SourceAddress);
                         }
                         else
                         {
@@ -180,7 +181,7 @@
                             return WebResponseContent.Instance.Error($"鏈壘鍒扮珯鍙伴厤缃俊鎭�");
                         }
 
-                        List<Dt_Router> routers = _routerRepository.QueryData(x => x.InOutType == item.TaskType && (item.SourceAddress == x.StartPosi || item.RoadWay == x.StartPosi));
+                        List<Dt_Router> routers = _routerRepository.QueryData(x => x.InOutType == item.TaskType && (item.SourceAddress == x.StartPosi || item.RoadWay == x.StartPosi || item.RoadWay == x.ChildPosiDeviceCode || item.RoadWay == x.ChildPosi));
                         router = routers.FirstOrDefault();
                         if (router == null)
                         {
@@ -189,15 +190,28 @@
 
                         if (routers.Count == 1)
                         {
-                            if(taskTypeGroup == TaskTypeGroup.InboundGroup && item.TargetAddress == stationManger.StackerCraneCode)
+                            if (taskTypeGroup == TaskTypeGroup.InboundGroup && item.TargetAddress == stationManger.StackerCraneCode)
                             {
                                 task.NextAddress = router.NextPosi;
                                 task.DeviceCode = stationManger.StationDeviceCode;
                             }
+                            else if (item.TaskType == TaskTypeEnum.MesOutbound.ObjToInt())
+                            {
+                                task.NextAddress = router.NextPosi;
+                                task.DeviceCode = stationManger.StackerCraneCode;
+                            }
                             else
                             {
                                 task.NextAddress = item.TargetAddress;
-                                task.DeviceCode = stationManger.StationDeviceCode;
+                                if (item.RoadWay.Contains("AGV"))
+                                {
+                                    task.DeviceCode = item.RoadWay;
+                                    task.AgvTaskNum = task.DeviceCode + DateTime.Now.ToString("yyyyMMdd") + item.TaskNum;
+                                }
+                                else
+                                {
+                                    task.DeviceCode = stationManger.StationDeviceCode;
+                                }
                             }
                         }
                         else
@@ -210,7 +224,7 @@
                     {
                         if (taskTypeGroup == TaskTypeGroup.OutbondGroup)
                         {
-                            task.AgvTaskNum = "AGV-" + DateTime.Now.ToString("yyyyMMdd") + item.TaskNum;
+                            task.AgvTaskNum = item.AGVArea + DateTime.Now.ToString("yyyyMMdd") + item.TaskNum;
                             List<Dt_Router> routers = _routerRepository.QueryData(x => x.InOutType == item.TaskType && item.AGVArea == x.NextPosi);
                             if (routers.FirstOrDefault() == null)
                             {
@@ -224,7 +238,7 @@
                         }
                         else
                         {
-                            task.AgvTaskNum = "AGV-" + DateTime.Now.ToString("yyyyMMdd") + item.TaskNum;
+                            task.AgvTaskNum = item.AGVArea + DateTime.Now.ToString("yyyyMMdd") + item.TaskNum;
                             List<Dt_Router> routers = _routerRepository.QueryData(x => x.InOutType == item.TaskType && item.AGVArea == x.StartPosi);
                             if (routers.FirstOrDefault() == null)
                             {
@@ -275,8 +289,12 @@
                 {
                     return WebResponseContent.Instance.Error($"鏈壘鍒扮珯鍙颁俊鎭�");
                 }
-
-                string responseStr = HttpHelper.Get($"http://127.0.0.1:9293/api/Task/DeviceRequestInboundTask?stationCode={sourceAddress}&roadwayNo={stationManger.StackerCraneCode}&palletCode={palletCode}");
+                string address = AppSettings.Get("WMSApiAddress");
+                if (string.IsNullOrEmpty(address))
+                {
+                    return WebResponseContent.Instance.Error($"鏈壘鍒癢MSApi鍦板潃");
+                }
+                string responseStr = HttpHelper.Get($"{address}/api/Task/DeviceRequestInboundTask?stationCode={sourceAddress}&roadwayNo={stationManger.StackerCraneCode}&palletCode={palletCode}");
                 WebResponseContent? responseContent = JsonConvert.DeserializeObject<WebResponseContent>(responseStr);
                 if (responseContent != null && responseContent.Status && responseContent.Data != null)
                 {
@@ -295,6 +313,31 @@
             return content;
         }
 
+        public WebResponseContent RequestWMSAssignRoadway(int taskNum, List<string> roadwayNos)
+        {
+            WebResponseContent content = new WebResponseContent();
+            try
+            {
+                string address = AppSettings.Get("WMSApiAddress");
+                if (string.IsNullOrEmpty(address))
+                {
+                    return WebResponseContent.Instance.Error($"鏈壘鍒癢MSApi鍦板潃");
+                }
+                string responseStr = HttpHelper.Post($"{address}/api/Task/AssignRoadway?taskNum={taskNum}", roadwayNos.Serialize());
+                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>
         /// 鍚慦MS鐢宠鍒嗛厤璐т綅
         /// </summary>
@@ -303,7 +346,9 @@
         /// <returns></returns>
         public string? RequestAssignLocation(int taskNum, string roadwayNo)
         {
-            string responseStr = HttpHelper.Get($"http://127.0.0.1:9283/api/Task/AssignInboundTaskLocation?taskNum={taskNum}&roadwayNo={roadwayNo}");
+            string address = AppSettings.Get("WMSApiAddress");
+            if (string.IsNullOrEmpty(address)) throw new Exception("鏈壘鍒癢MSApi鍦板潃");
+            string responseStr = HttpHelper.Get($"{address}/api/Task/AssignInboundTaskLocation?taskNum={taskNum}&roadwayNo={roadwayNo}");
 
             WebResponseContent? responseContent = JsonConvert.DeserializeObject<WebResponseContent>(responseStr);
             if (responseContent != null && responseContent.Status && responseContent.Data != null)

--
Gitblit v1.9.3