From 8c8a68df710d568f5f2b358c1e8c4b4799547d0b Mon Sep 17 00:00:00 2001
From: huanghongfeng <huanghongfeng@hnkhzn.com>
Date: 星期五, 31 十月 2025 15:24:34 +0800
Subject: [PATCH] 安全门,出入库

---
 代码管理/WCS/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/SpeStackerCraneJob/GetDeviceAddress.cs |  261 ++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 251 insertions(+), 10 deletions(-)

diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/SpeStackerCraneJob/GetDeviceAddress.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/SpeStackerCraneJob/GetDeviceAddress.cs"
index 2c5c8fb..f8adeee 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/SpeStackerCraneJob/GetDeviceAddress.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/SpeStackerCraneJob/GetDeviceAddress.cs"
@@ -9,10 +9,12 @@
 using WIDESEA_Common.Log;
 using System.Xml.Linq;
 using SixLabors.ImageSharp;
+using WIDESEAWCS_QuartzJob.Service;
+using OfficeOpenXml.FormulaParsing.Excel.Functions.Text;
 
 namespace WIDESEAWCS_Tasks.StackerCraneJob
 {
-
+    
 
     public class GetDeviceAddress
     {
@@ -25,9 +27,30 @@
         {
             IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == ChildPosiDeviceCode);
             SpeStackerCrane speStackerCrane = (SpeStackerCrane)device;
-            GetStackerObject getStackerObject = new GetStackerObject(speStackerCrane);
-            return getStackerObject.RGVCurrentlocation;
+            if (speStackerCrane == null) return 0;
+            DeviceProDTO? deviceProDTO = speStackerCrane.DeviceProDTOs.FirstOrDefault(x => x.DeviceChildCode == ChildPosiDeviceCode && x.DeviceProParamName == "RGVCurrentlocation" && x.DeviceProParamType == "RGVCurrentlocation");
+            int MCGStatus = GetDeviceAddress.RGVGetLine(speStackerCrane, deviceProDTO.DeviceProAddress);
+            return MCGStatus;
         }
+
+        /// <summary>
+        /// 浼犲叆璁惧锛岃繑鍥炶澶囦俊鎭�
+        /// </summary>
+        /// <param name="ChildPosiDeviceCode">璁惧</param>
+        /// <returns></returns>
+        public static GetStackerObject GetChildDeviceCode(string ChildPosiDeviceCode)
+        {
+            IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == ChildPosiDeviceCode);
+            SpeStackerCrane speStackerCrane = (SpeStackerCrane)device;
+            if (speStackerCrane == null)
+            {
+                Console.WriteLine($"璇诲彇鍒拌澶囦负绌�,璁惧缂栧彿锛歿ChildPosiDeviceCode},002");
+                return null;
+            }
+            GetStackerObject getStackerObject = new GetStackerObject(speStackerCrane);
+            return getStackerObject;
+        }
+
 
         /// <summary>
         /// 浼犲叆璁惧锛岃繑鍥炲綋鍓嶈澶囦俊鎭�
@@ -38,9 +61,14 @@
         {
             IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == ChildPosiDeviceCode);
             SpeStackerCrane speStackerCrane = (SpeStackerCrane)device;
+            if (speStackerCrane == null)
+            {
+                Console.WriteLine($"璇诲彇鍒拌澶囦负绌�,璁惧缂栧彿锛歿ChildPosiDeviceCode},003");
+                return 0;
+            }
             GetStackerObject getStackerObject = new GetStackerObject(speStackerCrane);
             if (getStackerObject.RgvCraneAutoStatusValue == RgvCraneAutoStatus.Automatic &&
-                        getStackerObject.StaclerkJobJobStatusValue == RgvJobCraneStatus.Ready && getStackerObject.RgvCraneWorkStatusValue == RGVStepprocess.NoAction)
+                        getStackerObject.StaclerkJobJobStatusValue == RGV_Rgvtaskstutas.Ready && getStackerObject.RgvCraneWorkStatusValue == RGVStepprocess.NoAction)
             {
                 return getStackerObject.RGVCurrentlocation;
             }
@@ -60,9 +88,14 @@
         {
             IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == ChildPosiDeviceCode);
             SpeStackerCrane speStackerCrane = (SpeStackerCrane)device;
+            if (speStackerCrane == null)
+            {
+                Console.WriteLine($"璇诲彇鍒拌澶囦负绌�,璁惧缂栧彿锛歿ChildPosiDeviceCode},004");
+                return 0;
+            }
             GetStackerObject getStackerObject = new GetStackerObject(speStackerCrane);
             if (getStackerObject.RgvCraneAutoStatusValue == RgvCraneAutoStatus.Automatic &&
-                        getStackerObject.StaclerkJobJobStatusValue == RgvJobCraneStatus.Ready && getStackerObject.RgvCraneWorkStatusValue == RGVStepprocess.NoAction && getStackerObject.RgvCraneStatusValue == RgvEquipmentStatus.NoCargo)
+                        getStackerObject.StaclerkJobJobStatusValue == RGV_Rgvtaskstutas.Ready && getStackerObject.RgvCraneWorkStatusValue == RGVStepprocess.NoAction && getStackerObject.RgvCraneStatusValue == RgvEquipmentStatus.NoCargo)
             {
                 return getStackerObject.RGVCurrentlocation;
             }
@@ -83,9 +116,14 @@
         {
             IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == ChildPosiDeviceCode);
             SpeStackerCrane speStackerCrane = (SpeStackerCrane)device;
+            if (speStackerCrane == null)
+            {
+                Console.WriteLine($"璇诲彇鍒拌澶囦负绌�,璁惧缂栧彿锛歿ChildPosiDeviceCode},005");
+                return false;
+            }
             GetStackerObject getStackerObject = new GetStackerObject(speStackerCrane);
             if (getStackerObject.RgvCraneAutoStatusValue == RgvCraneAutoStatus.Automatic &&
-                        getStackerObject.StaclerkJobJobStatusValue == RgvJobCraneStatus.Ready && getStackerObject.RgvCraneWorkStatusValue == RGVStepprocess.NoAction)
+                        getStackerObject.StaclerkJobJobStatusValue == RGV_Rgvtaskstutas.Ready && getStackerObject.RgvCraneWorkStatusValue == RGVStepprocess.NoAction)
             {
                 return true;
             }
@@ -103,7 +141,7 @@
         /// <param name="SCAddress"></param>
         /// <param name="Interactivet"></param>
         /// <returns></returns>
-        public static DeviceProDTO? GetDeviceProDTO(CommonStackerCrane Commonstacker, string SCAddress, string Interactivet)
+        public static DeviceProDTO? GetDeviceProDTO(CommonConveyorLine Commonstacker, string SCAddress, string Interactivet)
         {
             return Commonstacker.DeviceProDTOs.FirstOrDefault(x => x.DeviceChildCode == SCAddress && x.DeviceProParamName == Interactivet && x.DeviceProParamType == "ReadDeviceCommand");
         }
@@ -117,7 +155,7 @@
         /// <returns></returns>
         public static DeviceProDTO? GetRGVDeviceProDTO(SpeStackerCrane Commonstacker, string SCAddress, string Interactivet)
         {
-            return Commonstacker.DeviceProDTOs.FirstOrDefault(x => x.DeviceChildCode == SCAddress && x.DeviceProParamName == Interactivet && x.DeviceProParamType == "ReadDeviceCommand");
+            return Commonstacker.DeviceProDTOs.FirstOrDefault(x => x.DeviceChildCode == SCAddress && x.DeviceProParamName == Interactivet && x.DeviceProParamType == "RGV_Rgvtaskstutas");
         }
         /// <summary>
         /// 璇诲彇璁惧淇℃伅
@@ -125,7 +163,7 @@
         /// <param name="conveyorLine"></param>
         /// <param name="DeviceProDataBlock"></param>
         /// <returns></returns>
-        public static int GetLine(CommonStackerCrane Commonstacker, string DeviceProDataBlock)
+        public static int GetLine(CommonConveyorLine Commonstacker, string DeviceProDataBlock)
         {
             return Commonstacker.Communicator.Read<short>(DeviceProDataBlock);
         }
@@ -156,7 +194,7 @@
         {
             //鑾峰彇闇�瑕佸尯鍒嗘槸鍚﹀幓鍏ュ簱涓庡幓涓嶅悎鏍艰浇璐у彴浠诲姟
             IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == "HCJ2000");
-            CommonStackerCrane Commonstacker = (CommonStackerCrane)device;
+            CommonConveyorLine Commonstacker = (CommonConveyorLine)device;
             DeviceProDTO? deviceProDTO = GetDeviceProDTO(Commonstacker, Platformnumber.ToString(), "HCJ_GoodsStatus");
             int HCJGStatus = GetLine(Commonstacker, deviceProDTO.DeviceProAddress);
             if (HCJGStatus == 0)    //涓烘棤璐�
@@ -168,5 +206,208 @@
                 return false;
             }
         }
+
+        /// <summary>
+        /// 鍒ゆ柇璁惧鏄惁鏈夎揣
+        /// </summary>
+        public static bool Mucheywhaddres(string DeviceCode)
+        {
+            IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == DeviceCode);
+            SpeStackerCrane Commonstacker = (SpeStackerCrane)device;
+
+            DeviceProDTO? deviceProDTO = Commonstacker.DeviceProDTOs.FirstOrDefault(x => x.DeviceChildCode == DeviceCode && x.DeviceProParamName == "RgvEquipmentStatus" && x.DeviceProParamType == "RgvEquipmentStatus");
+            int MCGStatus = GetDeviceAddress.RGVGetLine(Commonstacker, deviceProDTO.DeviceProAddress);
+            if(MCGStatus== (int)RgvEquipmentStatus.NoCargo)
+            {
+                return true;
+            }
+            return false;
+        }
+
+        /// <summary>
+        /// 鍒ゆ柇3涓珯鍙�
+        /// </summary>
+        public static bool AQMStatus(List<AGVStation> aGVStatList)
+        {
+            try
+            {
+                IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == "HCJ2000");
+                CommonConveyorLine Commonstacker = (CommonConveyorLine)device;
+                foreach (var item in aGVStatList)
+                {
+                    DeviceProDTO? deviceProDTO = GetDeviceProDTO(Commonstacker, item.Station_code.ToString(), "HCJ_GoodsStatus");
+                    int HCJGStatus = GetLine(Commonstacker, deviceProDTO.DeviceProAddress);
+                    if (HCJGStatus != 0)    //涓烘棤璐�
+                    {
+                        return false;
+                    }
+                }
+                return true;
+            }
+            catch (Exception ex)
+            {
+                return false;
+                throw;
+            }
+            
+        }
+
+        public static List<string> StationareaList = new List<string>() { "RGV111", "RGV116", "RGV110", "RGV112", "RGV114", "RGV115","RGV118" };
+        public static List<string> InStationareaList = new List<string>() { "RGV101", "RGV103", "RGV105", "RGV108", "RGV109", "RGV104","RGV107" };
+
+        public static bool OutbounMotherChildCartbool(string DeviceChildCode)
+        {
+            if (StationareaList.Contains(DeviceChildCode))
+            {
+                return true;
+            }
+            else
+            {
+                return false;
+            }
+        }
+
+        public static bool OutbounMotherChildCartbool2(string DeviceChildCode)
+        {
+            if (DeviceChildCode=="RGV104" || DeviceChildCode == "RGV107")
+            {
+                return true;
+            }
+            else
+            {
+                return false;
+            }
+        }
+
+        /// <summary>
+        /// 璇诲彇瀛愭槸鍚︿负鎵嬪姩
+        /// </summary>
+        public static bool OutRGVStatice()
+        {
+            bool rgvbool=true;
+            foreach (string AGVStation in StationareaList)
+            {
+                IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == AGVStation);
+                if (device == null)  continue;
+                SpeStackerCrane Commonstacker = (SpeStackerCrane)device;
+
+                DeviceProDTO? deviceProDTO = Commonstacker.DeviceProDTOs.FirstOrDefault(x => x.DeviceChildCode == AGVStation && x.DeviceProParamName == "RgvCraneAutoStatus" && x.DeviceProParamType == "RgvCraneAutoStatus");
+                int RGVState = GetDeviceAddress.RGVGetLine(Commonstacker, deviceProDTO.DeviceProAddress);
+                if (RGVState == 1)
+                {
+                   return false;
+                }
+            }
+            return rgvbool;
+        }
+
+        public static bool InRGVStatice()
+        {
+            bool rgvbool = true;
+            foreach (string AGVStation in InStationareaList)
+            {
+                IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == AGVStation);
+                if (device == null)  continue;
+                SpeStackerCrane Commonstacker = (SpeStackerCrane)device;
+
+                DeviceProDTO? deviceProDTO = Commonstacker.DeviceProDTOs.FirstOrDefault(x => x.DeviceChildCode == AGVStation && x.DeviceProParamName == "RgvCraneAutoStatus" && x.DeviceProParamType == "RgvCraneAutoStatus");
+                int RGVState = GetDeviceAddress.RGVGetLine(Commonstacker, deviceProDTO.DeviceProAddress);
+                if (RGVState == 1)
+                {
+                    return false;
+                }
+            }
+            return rgvbool;
+        }
+
+        /// <summary>
+        /// 鍑哄簱锛岃鍙朢GV鏄惁涓虹┖闂�
+        /// </summary>
+        /// <returns></returns>
+        public static bool OutRGVRGVStepprocess()
+        {
+            bool rgvbool = true;
+            foreach (string AGVStation in StationareaList)
+            {
+                IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == AGVStation);
+                if (device == null)  continue;
+                SpeStackerCrane Commonstacker = (SpeStackerCrane)device;
+
+                DeviceProDTO? deviceProDTO = Commonstacker.DeviceProDTOs.FirstOrDefault(x => x.DeviceChildCode == AGVStation && x.DeviceProParamName == "RGVStepprocess" && x.DeviceProParamType == "RGVStepprocess");
+                int RGVState = GetDeviceAddress.RGVGetLine(Commonstacker, deviceProDTO.DeviceProAddress);
+                if (RGVState != 0)
+                {
+                   return false;
+                }
+            }
+            return rgvbool;
+        }
+
+        public static bool InRGVRGVStepprocess()
+        {
+            bool rgvbool = true;
+            foreach (string AGVStation in InStationareaList)
+            {
+                IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == AGVStation);
+                if (device == null)  continue;
+                SpeStackerCrane Commonstacker = (SpeStackerCrane)device;
+
+                DeviceProDTO? deviceProDTO = Commonstacker.DeviceProDTOs.FirstOrDefault(x => x.DeviceChildCode == AGVStation && x.DeviceProParamName == "RGVStepprocess" && x.DeviceProParamType == "RGVStepprocess");
+                int RGVState = GetDeviceAddress.RGVGetLine(Commonstacker, deviceProDTO.DeviceProAddress);
+                if (RGVState != 0)
+                {
+                   return false;
+                }
+            }
+            return rgvbool;
+        }
+
+        public static bool WriteSecurityDoorpolice(string DeviceCode,string WriteType,int Writevalue)
+        {
+            try
+            {
+                IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == "HCJ2000");
+                if (device == null) return false;
+                CommonConveyorLine commonConveyorLine = (CommonConveyorLine)device;
+                DeviceProDTO? deviceProDTO = commonConveyorLine.DeviceProDTOs.FirstOrDefault(x => x.DeviceChildCode == DeviceCode && x.DeviceProParamName == WriteType && x.DeviceProParamType == "DeviceCommand");
+                return commonConveyorLine.Communicator.Write<short>(deviceProDTO.DeviceProAddress, (short)Writevalue);
+            }
+            catch (Exception)
+            {
+                return false;
+                throw;
+            }
+        }
+
+
+        public static List<string> AQMListdata = new List<string>() { "AQM001", "AQM002"};
+        /// <summary>
+        /// 鍒ゆ柇瀹夊叏闂ㄧ姸鎬�
+        /// </summary>
+        /// <param name="aqmtype">1涓哄嚭搴撳畨鍏ㄩ棬3鍙凤紝2涓哄叆搴撳畨鍏ㄩ棬鍒ゆ柇</param>
+        /// <returns></returns>
+        public static bool ReadAqmDecicStice(int aqmtype)
+        {
+            IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == "HCJ2000");
+            CommonConveyorLine commonConveyorLine = (CommonConveyorLine)device;
+            if (aqmtype == 1)
+            {
+                DeviceProDTO? deviceProDTO = commonConveyorLine.DeviceProDTOs.FirstOrDefault(x => x.DeviceChildCode == "AQM003" && x.DeviceProParamName == "IndicatorStatus" && x.DeviceProParamType == "ReadDeviceCommand");
+                short AQMldeng = commonConveyorLine.Communicator.Read<short>(deviceProDTO.DeviceProDataBlock);
+                if (AQMldeng == 2) return false;
+            }
+            else
+            {
+                foreach (string aqmname in AQMListdata)
+                {
+                    DeviceProDTO? deviceProDTO = commonConveyorLine.DeviceProDTOs.FirstOrDefault(x => x.DeviceChildCode == aqmname && x.DeviceProParamName == "IndicatorStatus" && x.DeviceProParamType == "ReadDeviceCommand");
+                    short AQMldeng = commonConveyorLine.Communicator.Read<short>(deviceProDTO.DeviceProDataBlock);
+                    if (AQMldeng == 2) return false;
+                }
+            }
+            return true;
+        }
+
+
     }
 }

--
Gitblit v1.9.3