From dea22f4759b5c8a4f79a3e93e5af1741f5e00ae4 Mon Sep 17 00:00:00 2001
From: Admin <Admin@ADMIN>
Date: 星期四, 26 三月 2026 19:51:02 +0800
Subject: [PATCH] 接口更新

---
 项目代码/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/WMSTaskService.cs |   68 +++++++++++++++++----------------
 1 files changed, 35 insertions(+), 33 deletions(-)

diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/WMSTaskService.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/WMSTaskService.cs"
index 1de7519..e011e25 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/WMSTaskService.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/WMSTaskService.cs"
@@ -158,14 +158,21 @@
             ApiResponse apiResponse = new ApiResponse();
             try
             {
-                IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == "1002");
-                if (device == null) return apiResponse.ErrorResponse("WCS鏈兘鑾峰彇鍒板簱鍙e疄渚�");
-                CommonConveyorLine conveyorLine = (CommonConveyorLine)device;
+                
 
                 Dictionary<string, int> portStatusDict = new Dictionary<string, int>();
 
                 foreach (string DeStateName in datas)
                 {
+                    string DeciceCodes = "1003";
+                    if (DeStateName.StartsWith("C")) DeciceCodes = "1004";
+
+
+                    IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == DeciceCodes);
+                    if (device == null) return apiResponse.ErrorResponse("WCS鏈兘鑾峰彇鍒板簱鍙e疄渚�");
+                    CommonConveyorLine conveyorLine = (CommonConveyorLine)device;
+
+
                     //鏄惁鍙繘鍑�
                     DeviceProDTO? deviceProDTO = conveyorLine.DeviceProDTOs.FirstOrDefault(x => x.DeviceChildCode == DeStateName && x.DeviceProParamName == "PermitHandShake");
                     //鏄惁鏈夎揣
@@ -173,8 +180,10 @@
                     if (deviceProDTO == null || StationNumProDTO ==null) return apiResponse.ErrorResponse($"WCS鏈壘鍒板簱鍙o細{DeStateName},瀵瑰簲鐨勫崗璁�");
 
                     int statusValue = 0;
-                    int portStatus = conveyorLine.Communicator.Read<int>(deviceProDTO.DeviceProAddress);
-                    int StationStatus = conveyorLine.Communicator.Read<int>(StationNumProDTO.DeviceProAddress);
+                    //1鍏佽鍙�  2鍏佽鏀�
+                    int portStatus = conveyorLine.Communicator.Read<ushort>(deviceProDTO.DeviceProAddress);
+                    //鏄惁鏈夎揣
+                    int StationStatus = conveyorLine.Communicator.Read<ushort>(StationNumProDTO.DeviceProAddress);
 
                     //鏈夎揣锛屽彲杩涗俊鍙�
                     statusValue = ((portStatus == 1 && StationStatus == 1) || (portStatus == 2 && StationStatus == 0)) ? 1 : (portStatus == 0) ? 0 : 0;
@@ -240,52 +249,45 @@
             ApiResponse apiResponse = new ApiResponse();
             try
             {
-                IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == "1002");
+                string DeciceCodes = "1003";
+                if (agvUpdateRequest.warehousenumber.StartsWith("C")) DeciceCodes = "1004";
+
+                IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == DeciceCodes);
                 if (device == null) return apiResponse.ErrorResponse("WCS鏈兘鑾峰彇鍒板簱鍙e疄渚�");
                 CommonConveyorLine conveyorLine = (CommonConveyorLine)device;
-
-
-
-                
 
                 //鏄惁鍙繘鍑�
                 DeviceProDTO? HandShake = conveyorLine.DeviceProDTOs.FirstOrDefault(x => x.DeviceChildCode == agvUpdateRequest.warehousenumber && x.DeviceProParamName == "HandShake");
                 if (HandShake == null) return apiResponse.ErrorResponse($"WCS鏈壘鍒板簱鍙o細{agvUpdateRequest.warehousenumber},瀵瑰簲鐨勫崗璁�");
                 
-
-
                 if (agvUpdateRequest.agvstatus == 1)
                 {
-
-
-                    //鏄惁鍙繘鍑�
-                    DeviceProDTO? deviceProDTO = conveyorLine.DeviceProDTOs.FirstOrDefault(x => x.DeviceChildCode == agvUpdateRequest.warehousenumber && x.DeviceProParamName == "PermitHandShake");
-                    //鏄惁鏈夎揣
-                    DeviceProDTO? StationNumProDTO = conveyorLine.DeviceProDTOs.FirstOrDefault(x => x.DeviceChildCode == agvUpdateRequest.warehousenumber && x.DeviceProParamName == "StationNum");
-                    if (deviceProDTO == null || StationNumProDTO == null) return apiResponse.ErrorResponse($"WCS鏈壘鍒板簱鍙o細{agvUpdateRequest.warehousenumber},瀵瑰簲鐨勫崗璁�");
-                    int statusValue = 0;
-                    int portStatus = conveyorLine.Communicator.Read<int>(deviceProDTO.DeviceProAddress);
-                    int StationStatus = conveyorLine.Communicator.Read<int>(StationNumProDTO.DeviceProAddress);
-                    //鏈夎揣锛屽彲杩涗俊鍙�
-                    statusValue = ((portStatus == 1 && StationStatus == 1) || (portStatus == 2 && StationStatus == 0)) ? 1 : (portStatus == 0) ? 0 : 0;
-
-                    if (statusValue == 1)
-
-                    {//鍐欏叆杈撻�佺嚎淇″彿
-                        bool HandShakebool = conveyorLine.Communicator.Write<short>(HandShake.DeviceProAddress, 1);
-                        if (HandShakebool)
+                    //鍐欏叆plc锛宎gv杩涘叆淇″彿
+                    bool HandShakebool = conveyorLine.Communicator.Write<short>(HandShake.DeviceProAddress, 1);
+                    if (HandShakebool)
+                    {
+                        //鏄惁鍙繘鍑�    1鍏佽鍙�  2鍏佽鏀�
+                        DeviceProDTO? deviceProDTO = conveyorLine.DeviceProDTOs.FirstOrDefault(x => x.DeviceChildCode == agvUpdateRequest.warehousenumber && x.DeviceProParamName == "PermitHandShake");
+                        //鏄惁鏈夎揣
+                        DeviceProDTO? StationNumProDTO = conveyorLine.DeviceProDTOs.FirstOrDefault(x => x.DeviceChildCode == agvUpdateRequest.warehousenumber && x.DeviceProParamName == "StationNum");
+                        if (deviceProDTO == null || StationNumProDTO == null) return apiResponse.ErrorResponse($"WCS鏈壘鍒板簱鍙o細{agvUpdateRequest.warehousenumber},瀵瑰簲鐨勫崗璁�");
+                        int statusValue = 0;
+                        int portStatus = conveyorLine.Communicator.Read<ushort>(deviceProDTO.DeviceProAddress);
+                        int StationStatus = conveyorLine.Communicator.Read<ushort>(StationNumProDTO.DeviceProAddress);
+                        //鏈夎揣锛屽彲杩涗俊鍙�
+                        statusValue = ((portStatus == 1 && StationStatus == 1) || (portStatus == 2 && StationStatus == 0)) ? 1 : (portStatus == 0) ? 0 : 0;
+                        if (statusValue == 1)
                         {
                             return apiResponse.SuccessResponse();
                         }
                         else
                         {
-                            return apiResponse.ErrorResponse("agv鍐欏叆plc鐢宠澶辫触");
+                            return apiResponse.ErrorResponse("璇诲彇plc涓嶅彲杩涘叆淇℃伅");
                         }
-
                     }
                     else
                     {
-                        return apiResponse.ErrorResponse("璇诲彇plc涓嶅彲杩涘叆淇℃伅");
+                        return apiResponse.ErrorResponse("鍐欏叆plc杩涘叆淇″彿澶辫触");
                     }
                 }
                 else if(agvUpdateRequest.agvstatus == 2)

--
Gitblit v1.9.3