From e4be26c0c229a941cfa5182f0daf785a59067288 Mon Sep 17 00:00:00 2001
From: hutongqing <hutongqing@hnkhzn.com>
Date: 星期六, 04 一月 2025 10:34:43 +0800
Subject: [PATCH] PDA自动更新

---
 代码管理/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/Controllers/AGVController.cs |   40 ++++++++++++++++++++++++++--------------
 1 files changed, 26 insertions(+), 14 deletions(-)

diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/Controllers/AGVController.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/Controllers/AGVController.cs"
index b4abb72..41866de 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/Controllers/AGVController.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/Controllers/AGVController.cs"
@@ -29,6 +29,9 @@
             _taskService = taskService;
             _taskRepository = taskRepository;
         }
+
+        
+
         /// <summary>
         /// 瀹夊叏淇″彿鐢宠 AGV-WCS
         /// </summary>
@@ -41,23 +44,23 @@
             agvResponseContent.ReqCode = secureApplyModel.ReqCode;
             try
             {
-                var task = _taskRepository.QueryFirst(x => secureApplyModel.TaskCode.ObjToInt() == x.TaskNum);
+                var task = _taskRepository.QueryFirst(x => secureApplyModel.TaskCode == x.AgvTaskNum);
                 if (task == null) throw new Exception("鏈壘鍒颁换鍔�");
                 if (task.TaskType == TaskTypeEnum.Outbound.ObjToInt())
                 {
                     var content = TakeRequest(task.CurrentAddress);
-                    if (!content.Status)
-                    {
-                        throw new Exception(content.Message);
-                    }
+                    //if (!content.Status)
+                    //{
+                    //    throw new Exception(content.Message);
+                    //}
                 }
                 else
                 {
                     var content = PutRequest(task.NextAddress, task.PalletType);
-                    if (!content.Status)
-                    {
-                        throw new Exception(content.Message);
-                    }
+                    //if (!content.Status)
+                    //{
+                    //    throw new Exception(content.Message);
+                    //}
                 }
                 task.TaskState = TaskStatusEnum.AGV_WaitToExecute.ObjToInt();
                 var up = _taskRepository.UpdateData(task);
@@ -109,12 +112,12 @@
                             if (task.TaskType == TaskTypeEnum.Outbound.ObjToInt())
                             {
                                 var content = TakeRequest(task.CurrentAddress);
-                                if (!content.Status) throw new Exception(content.Message);
+                                //if (!content.Status) throw new Exception(content.Message);
                             }
                             else
                             {
                                 var content = PutRequest(task.NextAddress, task.PalletType);
-                                if (!content.Status) throw new Exception(content.Message);
+                                //if (!content.Status) throw new Exception(content.Message);
                             }
                             task.TaskState = TaskStatusEnum.AGV_WaitToExecute.ObjToInt();
                             var up = _taskRepository.UpdateData(task);
@@ -127,9 +130,15 @@
                         {
                             var content = PutFinish(task.NextAddress);
                             if (!content.Status) throw new Exception(content.Message);
-                            task.CurrentAddress = task.NextAddress;
+                            Dt_StationManger dt_Station = _stationMangerRepository.QueryFirst(x => x.AGVStationCode == task.NextAddress);
+                            if (dt_Station == null)
+                            {
+                                throw new Exception($"{task.NextAddress}AGV绔欏彴鏈畾涔�");
+                            }
+                            task.CurrentAddress = dt_Station.StationCode;
                             task.NextAddress = "";
-                            task.TaskState = TaskStatusEnum.SC_Execute.ObjToInt();
+                            task.TaskState = TaskStatusEnum.AGV_Finish.ObjToInt();
+                            task.DeviceCode = "SC01_CSJ";
                             var up = _taskRepository.UpdateData(task);
                             agvResponseContent.Code = up ? "0" : "1";
                             agvResponseContent.Message = up ? "鎴愬姛" : "澶辫触";
@@ -182,6 +191,7 @@
                 bool canPut = otherDevice.GetValue<GroundStationDBName, bool>(GroundStationDBName.R_IsCanPut, stationManger.StationCode);
                 if (canPut)
                 {
+                    otherDevice.SetValue(GroundStationDBName.W_PutRequest, true, stationManger.StationCode);
                     return WebResponseContent.Instance.OK();
                 }
                 else
@@ -265,6 +275,7 @@
                 bool canPut = otherDevice.GetValue<GroundStationDBName, bool>(GroundStationDBName.R_IsCanTake, stationManger.StationCode);
                 if (canPut)
                 {
+                    otherDevice.SetValue(GroundStationDBName.W_TakeRequest, true, stationManger.StationCode);
                     return WebResponseContent.Instance.OK();
                 }
                 else
@@ -312,7 +323,8 @@
 
                 OtherDevice otherDevice = (OtherDevice)device;
                 otherDevice.SetValue(GroundStationDBName.W_TakeFinish, true, stationManger.StationCode);
-
+                Thread.Sleep(1000);
+                otherDevice.SetValue(GroundStationDBName.W_TakeFinish, false, stationManger.StationCode);
                 return WebResponseContent.Instance.OK();
             }
             catch (Exception ex)

--
Gitblit v1.9.3