From b466b3135cd7f3b08f570efda0ffb691daff5270 Mon Sep 17 00:00:00 2001
From: wangxinhui <wangxinhui@hnkhzn.com>
Date: 星期五, 05 十二月 2025 18:15:16 +0800
Subject: [PATCH] 一期输送线代码及AGV请求等

---
 项目代码/WCSServices/WIDESEAWCS_Server/Controllers/AGV/AGVController.cs |   68 ++++++++++++++++++++++++++++++++++
 1 files changed, 68 insertions(+), 0 deletions(-)

diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCSServices/WIDESEAWCS_Server/Controllers/AGV/AGVController.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCSServices/WIDESEAWCS_Server/Controllers/AGV/AGVController.cs"
index 9dac38a..8b7602e 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCSServices/WIDESEAWCS_Server/Controllers/AGV/AGVController.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCSServices/WIDESEAWCS_Server/Controllers/AGV/AGVController.cs"
@@ -15,6 +15,7 @@
 using WIDESEAWCS_Core.LogHelper;
 using WIDESEAWCS_DTO;
 using WIDESEAWCS_DTO.Agv;
+using WIDESEAWCS_DTO.TaskInfo;
 using WIDESEAWCS_IBasicInfoRepository;
 using WIDESEAWCS_ITaskInfoRepository;
 using WIDESEAWCS_ITaskInfoService;
@@ -86,6 +87,73 @@
             }
             return content;
         }
+        /// <summary>
+        /// AGV浠诲姟璇锋眰
+        /// </summary>
+        /// <returns></returns>
+        [HttpPost, HttpGet, Route("WorkRequest"), AllowAnonymous]
+        public AgvTaskReqContent WorkRequest([FromBody] AgvTaskRequestDTO agvTaskRequestDTO)
+        {
+            AgvTaskReqContent content = new AgvTaskReqContent();
+            try
+            {
+                //鑾峰彇浠诲姟
+                Dt_Task? taskExist = _taskRepository.QueryFirst(x=>x.PalletCode==agvTaskRequestDTO.ContainerCode) ?? throw new Exception($"鏈壘鍒版枡绠眥agvTaskRequestDTO.ContainerCode}浠诲姟");
+                //鑾峰彇绔欏彴
+                Dt_StationManger? stationManger = _stationMangerRepository.QueryFirst(x => x.StationCode == agvTaskRequestDTO.PositionId) ?? throw new Exception($"鏈壘鍒皗agvTaskRequestDTO.PositionId}绔欏彴浣嶇疆");
+                IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == stationManger.StationDeviceCode) ?? throw new Exception($"鏈壘鍒板搴旇澶噞stationManger.StationDeviceCode}");
 
+                OtherDevice commonConveyorLine = (OtherDevice)device;
+
+                if (stationManger.StationType==StationTypeEnum.StationType_OnlyOutbound.ObjToInt())
+                {
+                    short IsPut = commonConveyorLine.Communicator.Read<short>("0");
+                    if (IsPut != 256) throw new Exception($"{agvTaskRequestDTO.PositionId}绂佹鏀剧");
+                }
+                else
+                {
+                    short IsTake = commonConveyorLine.Communicator.Read<short>("11");
+                    if (IsTake != 256) throw new Exception($"{agvTaskRequestDTO.PositionId}绂佹鍙栫");
+                }
+                content.OK();
+            }
+            catch (Exception ex)
+            {
+                content.Error(ex.Message);
+            }
+            return content;
+        }
+        /// <summary>
+        /// AGV浣滀笟瀹屾垚
+        /// </summary>
+        /// <returns></returns>
+        [HttpPost, HttpGet, Route("WorkFinish"), AllowAnonymous]
+        public AgvTaskReqContent WorkFinish([FromBody] AgvTaskRequestDTO agvTaskRequestDTO)
+        {
+            AgvTaskReqContent content = new AgvTaskReqContent();
+            try
+            {
+                //鑾峰彇绔欏彴
+                Dt_StationManger? stationManger = _stationMangerRepository.QueryFirst(x => x.StationCode == agvTaskRequestDTO.PositionId) ?? throw new Exception($"鏈壘鍒皗agvTaskRequestDTO.PositionId}绔欏彴浣嶇疆");
+                IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == stationManger.StationDeviceCode) ?? throw new Exception($"鏈壘鍒板搴旇澶噞stationManger.StationDeviceCode}");
+
+                OtherDevice commonConveyorLine = (OtherDevice)device;
+
+                if (stationManger.StationType == StationTypeEnum.StationType_OnlyOutbound.ObjToInt())
+                {
+                    commonConveyorLine.Communicator.Write("21", (short)256);
+                }
+                else
+                {
+                    commonConveyorLine.Communicator.Write("23", (short)256);
+                }
+                content.OK();
+            }
+            catch (Exception ex)
+            {
+                content.Error(ex.Message);
+            }
+            return content;
+        }
     }
 }

--
Gitblit v1.9.3