From c6babb9834248e2bc8fa6c037b3fb3e6ea4dc524 Mon Sep 17 00:00:00 2001
From: wangxinhui <wangxinhui@hnkhzn.com>
Date: 星期五, 03 一月 2025 14:57:52 +0800
Subject: [PATCH] 更新代码

---
 代码管理/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/Controllers/AGVController.cs |   54 +++++++++++++++++++++++++++++++++++++++++++++---------
 1 files changed, 45 insertions(+), 9 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 0cf13a6..000b58c 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"
@@ -41,17 +41,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);
@@ -79,8 +85,8 @@
             {
                 if (agvUpdateModel == null) throw new Exception("鏈幏鍙栧埌璇锋眰鍙傛暟");
                 agvResponseContent.ReqCode = agvUpdateModel.ReqCode;
-                var task = _taskRepository.QueryFirst(x => agvUpdateModel.TaskCode.ObjToInt() == x.TaskNum);
-                if (task == null) throw new Exception("鏈壘鍒颁换鍔�");
+                var task = _taskRepository.QueryFirst(x => agvUpdateModel.TaskCode == x.AgvTaskNum);
+                if (task == null) throw new Exception($"鏈壘鍒颁换鍔�,浠诲姟鍙枫�恵agvUpdateModel.TaskCode}銆�");
                 switch (agvUpdateModel.Method)
                 {
                     case "start":
@@ -92,17 +98,44 @@
                             if (!content.Status) throw new Exception(content.Message);
                             task.TaskState = TaskStatusEnum.AGV_Finish.ObjToInt();
                             var up = _taskRepository.DeleteAndMoveIntoHty(task, OperateTypeEnum.鑷姩瀹屾垚);
+                            _taskService.TaskCompleted(task.TaskNum);
                             agvResponseContent.Code = up ? "0" : "1";
                             agvResponseContent.Message = up ? "鎴愬姛" : "澶辫触";
                             return agvResponseContent;
                         }
                         break;
+                    case "getSafetySignal"://瀹夊叏淇″彿鐢宠
+                        {
+                            if (task.TaskType == TaskTypeEnum.Outbound.ObjToInt())
+                            {
+                                var content = TakeRequest(task.CurrentAddress);
+                                if (!content.Status) throw new Exception(content.Message);
+                            }
+                            else
+                            {
+                                var content = PutRequest(task.NextAddress, task.PalletType);
+                                if (!content.Status) throw new Exception(content.Message);
+                            }
+                            task.TaskState = TaskStatusEnum.AGV_WaitToExecute.ObjToInt();
+                            var up = _taskRepository.UpdateData(task);
+                            agvResponseContent.Code = up ? "0" : "1";
+                            agvResponseContent.Message = up ? "鎴愬姛" : "澶辫触";
+                            return agvResponseContent;
+                        }
                     case "end"://鍏ュ簱鏍规嵁杩欎釜淇″彿鍒ゆ柇鏀捐揣瀹屾垚
                         if (task.TaskType != TaskTypeEnum.Outbound.ObjToInt())
                         {
-                            var content = PutFinish(task.CurrentAddress);
+                            var content = PutFinish(task.NextAddress);
                             if (!content.Status) throw new Exception(content.Message);
+                            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.DeviceCode = "SC01_CSJ";
                             var up = _taskRepository.UpdateData(task);
                             agvResponseContent.Code = up ? "0" : "1";
                             agvResponseContent.Message = up ? "鎴愬姛" : "澶辫触";
@@ -134,7 +167,7 @@
         /// <param name="code"></param>
         /// <param name="palletType"></param>
         /// <returns></returns>
-        //[HttpPost, HttpGet, Route("PutRequest"), AllowAnonymous]
+        [HttpPost, HttpGet, Route("PutRequest"), AllowAnonymous]
         public WebResponseContent PutRequest(string code, int palletType)
         {
             try
@@ -160,7 +193,6 @@
                 else
                 {
                     otherDevice.SetValue(GroundStationDBName.W_PutRequest, true, stationManger.StationCode);
-                    otherDevice.SetValue(GroundStationDBName.W_PutPalletType, (short)palletType, stationManger.StationCode);
                     Thread.Sleep(1000);
                     canPut = otherDevice.GetValue<GroundStationDBName, bool>(GroundStationDBName.R_IsCanPut, stationManger.StationCode);
                     if (canPut)
@@ -185,6 +217,7 @@
         /// </summary>
         /// <param name="code"></param>
         /// <returns></returns>
+        [HttpPost, HttpGet, Route("PutFinish"), AllowAnonymous]
         public WebResponseContent PutFinish(string code)
         {
             try
@@ -217,6 +250,7 @@
         /// </summary>
         /// <param name="code"></param>
         /// <returns></returns>
+        [HttpPost, HttpGet, Route("TakeRequest"), AllowAnonymous]
         public WebResponseContent TakeRequest(string code)
         {
             try
@@ -266,6 +300,7 @@
         /// </summary>
         /// <param name="code"></param>
         /// <returns></returns>
+        [HttpPost, HttpGet, Route("TakeFinish"), AllowAnonymous]
         public WebResponseContent TakeFinish(string code)
         {
             try
@@ -283,7 +318,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