From f679f58dba34055bd579a603762c13fbe1650c9b Mon Sep 17 00:00:00 2001
From: Admin <Admin@ADMIN>
Date: 星期一, 23 三月 2026 13:14:20 +0800
Subject: [PATCH] 最新

---
 项目代码/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/WMSTaskService.cs |   91 +++++++++++++++++++++++++++++++++++++++------
 1 files changed, 79 insertions(+), 12 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 e852777..1de7519 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,23 +158,28 @@
             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;
+                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)
                 {
-                    //鏆傛椂鏁版嵁
-                    portStatusDict[DeStateName] = 1;
+                    //鏄惁鍙繘鍑�
+                    DeviceProDTO? deviceProDTO = conveyorLine.DeviceProDTOs.FirstOrDefault(x => x.DeviceChildCode == DeStateName && x.DeviceProParamName == "PermitHandShake");
+                    //鏄惁鏈夎揣
+                    DeviceProDTO? StationNumProDTO = conveyorLine.DeviceProDTOs.FirstOrDefault(x => x.DeviceChildCode == DeStateName && x.DeviceProParamName == "StationNum");
+                    if (deviceProDTO == null || StationNumProDTO ==null) return apiResponse.ErrorResponse($"WCS鏈壘鍒板簱鍙o細{DeStateName},瀵瑰簲鐨勫崗璁�");
 
-                    /*DeviceProDTO? deviceProDTO = conveyorLine.DeviceProDTOs.FirstOrDefault(x => x.DeviceChildCode == DeStateName && x.DeviceProParamName == "StationFree");
-                    if (deviceProDTO == null) return apiResponse.ErrorResponse($"WCS鏈壘鍒板簱鍙o細{DeStateName},瀵瑰簲鐨勫崗璁�");
-                    conveyorLine.Communicator.Read<bool>(deviceProDTO.DeviceProAddress);
-                    bool portStatus = conveyorLine.Communicator.Read<bool>(deviceProDTO.DeviceProAddress);
-                    int statusValue = portStatus ? 1 : 0;
-                    portStatusDict[DeStateName] = statusValue;*/
+                    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;
+
+                    portStatusDict[DeStateName] = statusValue;
                 }
 
                 return apiResponse.SuccessResponse(portStatusDict);
@@ -235,9 +240,71 @@
             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;
 
 
-                return apiResponse.SuccessResponse();
+
+                
+
+                //鏄惁鍙繘鍑�
+                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)
+                        {
+                            return apiResponse.SuccessResponse();
+                        }
+                        else
+                        {
+                            return apiResponse.ErrorResponse("agv鍐欏叆plc鐢宠澶辫触");
+                        }
+
+                    }
+                    else
+                    {
+                        return apiResponse.ErrorResponse("璇诲彇plc涓嶅彲杩涘叆淇℃伅");
+                    }
+                }
+                else if(agvUpdateRequest.agvstatus == 2)
+                {
+                    //鍐欏叆杈撻�佺嚎淇″彿
+                    bool portStatus = conveyorLine.Communicator.Write<short>(HandShake.DeviceProAddress, 0);
+                    if (portStatus)
+                    {
+                        return apiResponse.SuccessResponse();
+                    }
+                    else
+                    {
+                        return apiResponse.ErrorResponse("鍐欏叆plc娓呴櫎淇″彿澶辫触");
+                    }
+                }
+                else
+                {
+                    return apiResponse.ErrorResponse($"agv瀵瑰簲鐨勭敵璇烽敊璇紝瀛楁锛歛gvstatus锛岀敵璇风殑鍊硷細{agvUpdateRequest.agvstatus}");
+                }
             }
             catch (Exception ex)
             {

--
Gitblit v1.9.3