From 5da3a276b7847187a7c155ee069d3cd4c9e58074 Mon Sep 17 00:00:00 2001
From: HuBingJie <3146306518@qq.com>
Date: 星期日, 07 十二月 2025 23:28:14 +0800
Subject: [PATCH] 1

---
 代码管理/WCS/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/RgvoperainformService.cs |  740 +++++++++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 701 insertions(+), 39 deletions(-)

diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/RgvoperainformService.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/RgvoperainformService.cs"
index dff6cb4..e2a6bc2 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/RgvoperainformService.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/RgvoperainformService.cs"
@@ -25,6 +25,7 @@
 using Newtonsoft.Json;
 using OfficeOpenXml.FormulaParsing.Excel.Functions.DateTime;
 using OfficeOpenXml.FormulaParsing.Excel.Functions.Text;
+using Quartz.Util;
 using SqlSugar;
 using System;
 using System.Collections.Generic;
@@ -40,6 +41,7 @@
 using System.Text;
 using System.Threading.Tasks;
 using WIDESEA_Comm.Http;
+using WIDESEA_Common.Log;
 using WIDESEAWCS_Core;
 using WIDESEAWCS_Core.BaseRepository;
 using WIDESEAWCS_Core.BaseServices;
@@ -54,13 +56,12 @@
 using WIDESEAWCS_QuartzJob.DTO;
 using WIDESEAWCS_QuartzJob.Models;
 using WIDESEAWCS_QuartzJob.Service;
-using WIDESEA_Common.Log;
 
 namespace WIDESEAWCS_TaskInfoService
 {
     public class RgvoperainformService : ServiceBase<Dt_Task_hty, ITask_HtyRepository>, IRgvoperainformService
     {
-        private readonly IAgvStationService _gvStationService;
+        private readonly IAgvStationService _agvStationService;
         private readonly IServiceProvider _serviceProvider;
         private static bool _isMonitoring = false;
         private readonly IRepository<DeviceAlarmLog> _deviceAlarmLog;
@@ -79,7 +80,7 @@
         private CancellationTokenSource _safetyDoorCancellationTokenSource;
         public RgvoperainformService(ITask_HtyRepository BaseDal, IAgvStationService agvStationService, IServiceProvider serviceProvider, IRepository<DeviceAlarmLog> deviceAlarmLog) : base(BaseDal)
         {
-            _gvStationService = agvStationService;
+            _agvStationService = agvStationService;
             _serviceProvider = serviceProvider;
             _deviceAlarmLog = deviceAlarmLog;
         }
@@ -663,7 +664,7 @@
             int zhi = 1002011;
             try
             {
-
+                
             switch (operationType)
             {
                 case "cs":          //鍒濆鍖�
@@ -727,7 +728,9 @@
                         //RgvOperationService.RgvSetLine(Commonstacker, RGV_Resetoperationxj3.DeviceProAddress, 0);
                         return webResponse.OK();
                 case "dz":          //鍦板潃
-                    DeviceProParamName = "RGV_RGVTasklocationt";
+
+                        if (!YiDongPD(Commonstacker, parameter)) { return webResponse.Error("鐩爣鍦板潃琚崰鐢ㄦ垨鏉′欢涓嶆弧瓒筹紝绂佹绉诲姩"); }
+                        DeviceProParamName = "RGV_RGVTasklocationt";
                     DeviceProParamType = "DeviceCommand";
                     zhi = parameter;
                         //鑾峰彇瀹炰緥
@@ -780,6 +783,657 @@
                 return webResponse.Error("璁惧鎿嶄綔澶辫触");
             }
 
+        }
+
+    /// <summary>
+    /// 1銆佸垽鏂瓙杞﹀尯鍩�
+    /// 2銆佸垽鏂瓙杞﹀綋鍓嶄綅缃�
+    /// 3銆佸垽鏂瓙杞﹁鍘荤殑浣嶇疆
+    /// 4銆佹牴鎹瓙杞﹁鍘荤殑涓鸿幏鍙栨瘝杞︿綅缃�
+    /// 
+    /// </summary>
+    /// <param name="device">瑕佺Щ鍔ㄧ殑璁惧</param>
+    /// <param name="parameter">瑕佸幓鐨勭洰鏍囧湴鍧�</param>
+    /// <returns></returns>
+
+        private bool YiDongPD(SpeStackerCrane Commonstacker, int parameter)
+        {
+
+            //鍏ュ簱璁惧
+            List<string> InDevices = new List<string> {  "RGV104", "RGV107" };
+            //鍑哄簱璁惧
+            List<string>  OutDevices = new List<string> {"RGV116", "RGV111"};
+
+            Dictionary<int, string> HCJ = new Dictionary<int, string>
+        {
+            { 1061, "HCJ106" },
+            { 1021, "HCJ102" },
+            { 1131, "HCJ113" },
+            { 1171, "HCJ117" },
+        };
+
+            AGVStation RGVTaskdevice = _agvStationService.Corridorequipment(Commonstacker.DeviceCode);   //鏍规嵁璁惧鑾峰彇鍒板唴瀹�
+
+            //鏍规嵁瀛愯溅鑾峰彇鍒版瘝杞﹁澶�
+            // 鏍规嵁瀛愯溅鑾峰彇鍒版瘝杞﹁澶�
+            AGVStation Mu1 = _agvStationService.GetMothervehicle(RGVTaskdevice.MotherCarDeviceCode);
+            AGVStation Mu2 = _agvStationService.GetMothervehicle(RGVTaskdevice.MotherCardeputy);
+
+            // 鑾峰彇瀛愯溅浣嶇疆
+            int zhicheWZ = GetzicheWZ(Commonstacker, Commonstacker.DeviceCode);
+
+            // 缁熶竴鐩爣鍗犵敤妫�鏌ワ紙鎵弿鍏跺畠 RGV 鏄惁鍦ㄥ悓涓�鐩爣鍦板潃锛�
+            bool IsAddressOccupied(int addr)
+            {
+                var allCodes = InDevices.Concat(OutDevices).Where(code => code != Commonstacker.DeviceCode).ToList();
+                foreach (var code in allCodes)
+                {
+                    var dev = Storage.Devices.FirstOrDefault(x => x.DeviceCode == code) as SpeStackerCrane;
+                    if (dev == null) continue;
+                    try
+                    {
+                        DeviceProDTO? locDto = RgvOperationService.GetRGVDeviceProDTO(dev, code, "RGVCurrentlocation", "RGVCurrentlocation");
+                        if (locDto == null) continue;
+                        int loc = RgvOperationService.GetLine(dev, locDto.DeviceProAddress);
+                        if (loc == addr) return true; // 鐩爣琚崰鐢�
+                    }
+                    catch
+                    {
+                        // 璇诲彇寮傚父涓嶅綋浣滃崰鐢紝閬垮厤璇嫆
+                    }
+                }
+                return false;
+            }
+
+            // 鐩爣琚叾浠� RGV 鍗犵敤鍒欑姝�
+            if (IsAddressOccupied(parameter)) return false;
+
+            if (RGVTaskdevice.Station_Area == 6) // 澶栦晶
+            {
+                if (zhicheWZ == RGVTaskdevice.WaitmomentOne) // 绛夊緟鐐�1
+                {
+                    // 鍒ゆ柇澶栦晶灏忚溅鏄惁鍦� HCJ 涓�
+                    var zichestation = _agvStationService.OutGetZicheDeepHCJ(RGVTaskdevice.HCJStorageaddress);
+                    int waiziche = GetEquipmentlocation(zichestation.ChildPosiDeviceCode);
+
+                    //鍒ゆ柇浼犺繘鏉ヨ澶囨槸鍚︽槸鍏ュ簱
+                    if (InDevices.Contains(Commonstacker.DeviceCode))
+                    {
+                        if (!((waiziche == zichestation.WaitmomentOne || waiziche == zichestation.WaitmomentTwo || waiziche == zichestation.MotherCardeputy || waiziche == zichestation.MotherCarDeviceCode || waiziche == 1021) && waiziche != zichestation.HCJStorageaddress))
+                        {
+                            return false;
+                        }
+                    }
+                    else
+                    {
+                        if (!((waiziche == zichestation.WaitmomentOne || waiziche == zichestation.WaitmomentTwo || waiziche == zichestation.MotherCardeputy || waiziche == zichestation.MotherCarDeviceCode || waiziche == 1171) && waiziche != zichestation.HCJStorageaddress))
+                        {
+                            return false;
+                        }
+                    }
+
+                    if (parameter == Mu1.ZicheMotherinlaw) //姣�1
+                    {
+                        int taraddress = parameter;
+                        int mu1 = GetEquipmentlocation(Mu1.ChildPosiDeviceCode);
+                        if (Mucheywhaddres(Mu1.ChildPosiDeviceCode))//鍒ゆ柇鏄惁鏈夎揣
+                        {
+                            if (mu1 == Mu1.ZicheMotherinlaw && mu1 != Mu1.Motherinlaw && !IsAddressOccupied(Mu1.ZicheMotherinlaw))
+                            {
+                                return true;
+                            }
+                            else
+                            {
+                                return false;
+                            }
+                        }
+                        else
+                        {
+                            return false;
+                        }
+                    }
+                    else if (parameter == Mu2.ZicheMotherinlaw) // 姣�2
+                    {
+                        int taraddress = parameter;
+                        int mu1 = GetEquipmentlocation(Mu1.ChildPosiDeviceCode);
+                        int mu2 = GetEquipmentlocation(Mu2.ChildPosiDeviceCode);
+
+                        if (Mucheywhaddres(Mu1.ChildPosiDeviceCode) && Mucheywhaddres(Mu2.ChildPosiDeviceCode))//鍒ゆ柇鏄惁鏈夎揣
+                        {
+                            if (mu1 == Mu1.Motherinlaw && mu1 != Mu1.ZicheMotherinlaw && mu2 == Mu2.ZicheMotherinlaw && mu2 != Mu2.Motherinlaw && !IsAddressOccupied(Mu1.ZicheMotherinlaw))
+                            {
+                                return true;
+                            }
+                            else
+                            {
+                                return false;
+                            }
+                        }
+                        else
+                        {
+                            return false;
+                        }
+                    }
+                    else if (parameter == RGVTaskdevice.HCJStorageaddress)
+                    {
+                        string hcj = HCJ[RGVTaskdevice.HCJStorageaddress];
+                        int mu2 = GetEquipmentlocation(Mu2.ChildPosiDeviceCode);
+
+                        if (Mucheywhaddres(Mu2.ChildPosiDeviceCode) && Mucheywhaddres(hcj))//鍒ゆ柇鏄惁鏈夎揣
+                        {
+                            if (mu2 != Mu2.ZicheMotherinlaw && mu2 == Mu2.Motherinlaw && !IsAddressOccupied(Mu2.ZicheMotherinlaw))
+                            {
+                                return true;
+                            }
+                            else
+                            {
+                                return false;
+                            }
+                        }
+                        else
+                        {
+                            return false;
+                        }
+                    }else if(parameter == 1021 || parameter == 1171)
+                    {
+                        if (RGVTaskdevice.ChildPosiDeviceCode == "RGV116" && Mucheywhaddres("HCJ102"))
+                        {
+                            return true;
+                        }
+                        string hcj = HCJ[parameter];
+                        int mu1 = GetEquipmentlocation(Mu1.ChildPosiDeviceCode);
+
+                        if (Mucheywhaddres(Mu1.ChildPosiDeviceCode) && Mucheywhaddres(hcj))//鍒ゆ柇鏄惁鏈夎揣
+                        {
+                            if (mu1 != Mu1.ZicheMotherinlaw && mu1 == Mu1.Motherinlaw && !IsAddressOccupied(Mu1.ZicheMotherinlaw))
+                            {
+                                return true;
+                            }
+                            else
+                            {
+                                return false;
+                            }
+                        }
+                        else
+                        {
+                            return false;
+                        }
+                    }
+                    else
+                    {
+                        int taraddress = parameter;
+                        int mu1 = GetEquipmentlocation(Mu1.ChildPosiDeviceCode);
+                        int mu2 = GetEquipmentlocation(Mu2.ChildPosiDeviceCode);
+
+                        if (Mucheywhaddres(Mu1.ChildPosiDeviceCode) && Mucheywhaddres(Mu2.ChildPosiDeviceCode))//鍒ゆ柇鏄惁鏈夎揣
+                        {
+                            if (mu1 == Mu1.Motherinlaw && mu1 != Mu1.ZicheMotherinlaw && mu2 == Mu2.Motherinlaw && mu2 != Mu2.ZicheMotherinlaw && !IsAddressOccupied(Mu1.ZicheMotherinlaw))
+                            {
+                                return true;
+                            }
+                            else
+                            {
+                                return false;
+                            }
+                        }
+                        else
+                        {
+                            return false;
+
+                        }
+                    }
+                }
+                else if (zhicheWZ == RGVTaskdevice.WaitmomentTwo) // 绛夊緟鐐�2
+                {
+                    // 鍒ゆ柇澶栦晶灏忚溅鏄惁鍦� HCJ 涓�
+                    var zichestation = _agvStationService.OutGetZicheDeepHCJ(RGVTaskdevice.HCJStorageaddress);
+                    int waiziche = GetEquipmentlocation(zichestation.ChildPosiDeviceCode);
+
+                    //鍒ゆ柇浼犺繘鏉ヨ澶囨槸鍚︽槸鍏ュ簱
+                    if (InDevices.Contains(Commonstacker.DeviceCode))
+                    {
+                        if (!((waiziche == zichestation.WaitmomentOne || waiziche == zichestation.WaitmomentTwo || waiziche == zichestation.MotherCardeputy || waiziche == zichestation.MotherCarDeviceCode || waiziche == 1021) && waiziche != zichestation.HCJStorageaddress))
+                        {
+                            return false;
+                        }
+                    }
+                    else
+                    {
+                        if (!((waiziche == zichestation.WaitmomentOne || waiziche == zichestation.WaitmomentTwo || waiziche == zichestation.MotherCardeputy || waiziche == zichestation.MotherCarDeviceCode || waiziche == 1171) && waiziche != zichestation.HCJStorageaddress))
+                        {
+                            return false;
+                        }
+                    }
+
+                    if (parameter == Mu1.ZicheMotherinlaw)
+                    {
+                        int taraddress = parameter;
+                        int mu1 = GetEquipmentlocation(Mu1.ChildPosiDeviceCode);
+                        if (Mucheywhaddres(Mu1.ChildPosiDeviceCode))//鍒ゆ柇鏄惁鏈夎揣
+                        {
+                            if (mu1 == Mu1.ZicheMotherinlaw && mu1 != Mu1.Motherinlaw && !IsAddressOccupied(Mu1.ZicheMotherinlaw))
+                            {
+                                return true;
+                            }
+                            else
+                            {
+                                return false;
+                            }
+                        }
+                        else
+                        {
+                            return false;
+                        }
+                    }
+                    else if (parameter == Mu2.ZicheMotherinlaw)
+                    {
+                        int taraddress = parameter;
+                        int mu1 = GetEquipmentlocation(Mu1.ChildPosiDeviceCode);
+                        int mu2 = GetEquipmentlocation(Mu2.ChildPosiDeviceCode);
+
+                        if (Mucheywhaddres(Mu1.ChildPosiDeviceCode) && Mucheywhaddres(Mu2.ChildPosiDeviceCode))//鍒ゆ柇鏄惁鏈夎揣
+                        {
+                            if (mu1 == Mu1.Motherinlaw && mu1 != Mu1.ZicheMotherinlaw && mu2 == Mu2.ZicheMotherinlaw && !IsAddressOccupied(Mu1.ZicheMotherinlaw))
+                            {
+                                return true;
+                            }
+                            else
+                            {
+                                return false;
+                            }
+                        }
+                        else
+                        {
+                            return false;
+                        }
+                    }
+                    else if (parameter == RGVTaskdevice.HCJStorageaddress)
+                    {
+                        string hcj = HCJ[RGVTaskdevice.HCJStorageaddress];
+                        int mu2 = GetEquipmentlocation(Mu2.ChildPosiDeviceCode);
+
+                        if (Mucheywhaddres(Mu2.ChildPosiDeviceCode) && Mucheywhaddres(hcj))//鍒ゆ柇鏄惁鏈夎揣
+                        {
+                            if (mu2 != Mu2.ZicheMotherinlaw && mu2 == Mu2.Motherinlaw && !IsAddressOccupied(Mu2.ZicheMotherinlaw))
+                            {
+                                return true;
+                            }
+                            else
+                            {
+                                return false;
+                            }
+                        }
+                        else
+                        {
+                            return false;
+                        }
+                    }
+                    else if (parameter == 1021 || parameter == 1171)
+                    {
+                        string hcj = HCJ[parameter];
+                        int mu1 = GetEquipmentlocation(Mu1.ChildPosiDeviceCode);
+                        int mu2 = GetEquipmentlocation(Mu2.ChildPosiDeviceCode);
+
+                        if (Mucheywhaddres(Mu1.ChildPosiDeviceCode) && Mucheywhaddres(Mu2.ChildPosiDeviceCode) && Mucheywhaddres(hcj))//鍒ゆ柇鏄惁鏈夎揣
+                        {
+                            if (mu1 != Mu1.ZicheMotherinlaw && mu1 == Mu1.Motherinlaw && mu2 != Mu2.ZicheMotherinlaw && mu2 == Mu2.Motherinlaw && !IsAddressOccupied(Mu1.ZicheMotherinlaw))
+                            {
+                                return true;
+                            }
+                            else
+                            {
+                                return false;
+                            }
+                        }
+                        else
+                        {
+                            return false;
+                        }
+                    }
+                    else
+                    {
+                        int taraddress = parameter;
+                        int mu1 = GetEquipmentlocation(Mu1.ChildPosiDeviceCode);
+                        int mu2 = GetEquipmentlocation(Mu2.ChildPosiDeviceCode);
+
+                        if (Mucheywhaddres(Mu1.ChildPosiDeviceCode) && Mucheywhaddres(Mu2.ChildPosiDeviceCode))//鍒ゆ柇鏄惁鏈夎揣
+                        {
+                            if (mu1 == Mu1.Motherinlaw && mu1 != Mu1.ZicheMotherinlaw && mu2 == Mu2.Motherinlaw && mu2 != Mu2.ZicheMotherinlaw && !IsAddressOccupied(Mu1.ZicheMotherinlaw))
+                            {
+                                return true;
+                            }
+                            else
+                            {
+                                return false;
+                            }
+                        }
+                        else
+                        {
+                            return false;
+
+                        }
+                    }
+                }
+            }
+            else if (RGVTaskdevice.Station_Area == 5) // 鍐呬晶
+            {
+                if (zhicheWZ == RGVTaskdevice.WaitmomentOne) // 绛夊緟鐐�1
+                {
+                    // 鍒ゆ柇澶栦晶灏忚溅鏄惁鍦� HCJ 涓�
+                    var zichestation = _agvStationService.OutGetZicheDeepHCJ(RGVTaskdevice.HCJStorageaddress);
+                    int waiziche = GetEquipmentlocation(zichestation.ChildPosiDeviceCode);
+
+                    //鍒ゆ柇浼犺繘鏉ヨ澶囨槸鍚︽槸鍏ュ簱
+                    if (InDevices.Contains(Commonstacker.DeviceCode))
+                    {
+                        if (!((waiziche == zichestation.WaitmomentOne || waiziche == zichestation.WaitmomentTwo || waiziche == zichestation.MotherCardeputy || waiziche == zichestation.MotherCarDeviceCode || waiziche == 1021) && waiziche != zichestation.HCJStorageaddress))
+                        {
+                            return false;
+                        }
+                    }
+                    else
+                    {
+                        if (!((waiziche == zichestation.WaitmomentOne || waiziche == zichestation.WaitmomentTwo || waiziche == zichestation.MotherCardeputy || waiziche == zichestation.MotherCarDeviceCode || waiziche == 1171) && waiziche != zichestation.HCJStorageaddress))
+                        {
+                            return false;
+                        }
+                    }
+
+                    if (parameter == Mu1.ZicheMotherinlaw) //姣�1
+                    {
+                        int taraddress = parameter;
+                        int mu1 = GetEquipmentlocation(Mu1.ChildPosiDeviceCode);
+                        if (Mucheywhaddres(Mu1.ChildPosiDeviceCode))//鍒ゆ柇鏄惁鏈夎揣
+                        {
+                            if (mu1 == Mu1.ZicheMotherinlaw && mu1 != Mu1.Motherinlaw && !IsAddressOccupied(Mu1.ZicheMotherinlaw))
+                            {
+                                return true;
+                            }
+                            else
+                            {
+                                return false;
+                            }
+                        }
+                        else
+                        {
+                            return false;
+                        }
+                    }
+                    else if (parameter == Mu2.ZicheMotherinlaw) // 姣�2
+                    {
+                        int taraddress = parameter;
+                        int mu1 = GetEquipmentlocation(Mu1.ChildPosiDeviceCode);
+                        int mu2 = GetEquipmentlocation(Mu2.ChildPosiDeviceCode);
+
+                        if (Mucheywhaddres(Mu1.ChildPosiDeviceCode) && Mucheywhaddres(Mu2.ChildPosiDeviceCode))//鍒ゆ柇鏄惁鏈夎揣
+                        {
+                            if (mu1 == Mu1.Motherinlaw && mu1 != Mu1.ZicheMotherinlaw && mu2 == Mu2.ZicheMotherinlaw && !IsAddressOccupied(Mu1.ZicheMotherinlaw))
+                            {
+                                return true;
+                            }
+                            else
+                            {
+                                return false;
+                            }
+                        }
+                        else
+                        {
+                            return false;
+                        }
+                    }else if (parameter == RGVTaskdevice.HCJStorageaddress)
+                    {
+                        string hcj = HCJ[RGVTaskdevice.HCJStorageaddress];
+                        if (Mucheywhaddres(hcj))
+                        {
+                            return true;
+                        }
+                    }
+                    else
+                    {
+                        int taraddress = parameter;
+                        int mu1 = GetEquipmentlocation(Mu1.ChildPosiDeviceCode);
+                        int mu2 = GetEquipmentlocation(Mu2.ChildPosiDeviceCode);
+
+                        if (Mucheywhaddres(Mu1.ChildPosiDeviceCode) && Mucheywhaddres(Mu2.ChildPosiDeviceCode))//鍒ゆ柇鏄惁鏈夎揣
+                        {
+                            if (mu1 == Mu1.Motherinlaw && mu1 != Mu1.ZicheMotherinlaw && mu2 == Mu2.Motherinlaw && mu2 != Mu2.ZicheMotherinlaw && !IsAddressOccupied(Mu1.ZicheMotherinlaw))
+                            {
+                                return true;
+                            }
+                            else
+                            {
+                                return false;
+                            }
+                        }
+                        else
+                        {
+                            return false;
+
+                        }
+                    }
+                }
+                else if (zhicheWZ == RGVTaskdevice.WaitmomentTwo) // 绛夊緟鐐�2
+                {
+                    // 鍒ゆ柇澶栦晶灏忚溅鏄惁鍦� HCJ 涓�
+                    var zichestation = _agvStationService.OutGetZicheDeepHCJ(RGVTaskdevice.HCJStorageaddress);
+                    int waiziche = GetEquipmentlocation(zichestation.ChildPosiDeviceCode);
+
+                    //鍒ゆ柇浼犺繘鏉ヨ澶囨槸鍚︽槸鍏ュ簱
+                    if (InDevices.Contains(Commonstacker.DeviceCode))
+                    {
+                        if (!((waiziche == zichestation.WaitmomentOne || waiziche == zichestation.WaitmomentTwo || waiziche == zichestation.MotherCardeputy || waiziche == zichestation.MotherCarDeviceCode || waiziche == 1021) && waiziche != zichestation.HCJStorageaddress))
+                        {
+                            return false;
+                        }
+                    }
+                    else
+                    {
+                        if (!((waiziche == zichestation.WaitmomentOne || waiziche == zichestation.WaitmomentTwo || waiziche == zichestation.MotherCardeputy || waiziche == zichestation.MotherCarDeviceCode || waiziche == 1171) && waiziche != zichestation.HCJStorageaddress))
+                        {
+                            return false;
+                        }
+                    }
+
+                    if (parameter == Mu1.ZicheMotherinlaw)
+                    {
+                        int taraddress = parameter;
+                        int mu1 = GetEquipmentlocation(Mu1.ChildPosiDeviceCode);
+                        if (Mucheywhaddres(Mu1.ChildPosiDeviceCode))//鍒ゆ柇鏄惁鏈夎揣
+                        {
+                            if (mu1 == Mu1.ZicheMotherinlaw && mu1 != Mu1.Motherinlaw && !IsAddressOccupied(Mu1.ZicheMotherinlaw))
+                            {
+                                return true;
+                            }
+                            else
+                            {
+                                return false;
+                            }
+                        }
+                        else
+                        {
+                            return false;
+                        }
+                    }
+                    else if (parameter == Mu2.ZicheMotherinlaw)
+                    {
+                        int taraddress = parameter;
+                        int mu1 = GetEquipmentlocation(Mu1.ChildPosiDeviceCode);
+                        int mu2 = GetEquipmentlocation(Mu2.ChildPosiDeviceCode);
+
+                        if (Mucheywhaddres(Mu1.ChildPosiDeviceCode) && Mucheywhaddres(Mu2.ChildPosiDeviceCode))//鍒ゆ柇鏄惁鏈夎揣
+                        {
+                            if (mu1 == Mu1.Motherinlaw && mu1 != Mu1.ZicheMotherinlaw && mu2 == Mu2.ZicheMotherinlaw && !IsAddressOccupied(Mu1.ZicheMotherinlaw))
+                            {
+                                return true;
+                            }
+                            else
+                            {
+                                return false;
+                            }
+                        }
+                        else
+                        {
+                            return false;
+                        }
+                    }
+                    else if (parameter == RGVTaskdevice.HCJStorageaddress)
+                    {
+                        string hcj = HCJ[RGVTaskdevice.HCJStorageaddress];
+                        int mu1 = GetEquipmentlocation(Mu1.ChildPosiDeviceCode);
+
+                        if (Mucheywhaddres(Mu1.ChildPosiDeviceCode)&&Mucheywhaddres(hcj))//鍒ゆ柇鏄惁鏈夎揣
+                        {
+                            if (mu1 != Mu1.ZicheMotherinlaw && mu1 == Mu1.Motherinlaw && !IsAddressOccupied(Mu1.ZicheMotherinlaw))
+                            {
+                                return true;
+                            }
+                            else
+                            {
+                                return false;
+                            }
+                        }
+                        else
+                        {
+                            return false;
+                        }
+                    }
+                    else
+                    {
+                        int taraddress = parameter;
+                        int mu1 = GetEquipmentlocation(Mu1.ChildPosiDeviceCode);
+                        int mu2 = GetEquipmentlocation(Mu2.ChildPosiDeviceCode);
+
+                        if (Mucheywhaddres(Mu1.ChildPosiDeviceCode) && Mucheywhaddres(Mu2.ChildPosiDeviceCode))//鍒ゆ柇鏄惁鏈夎揣
+                        {
+                            if (mu1 == Mu1.Motherinlaw && mu1 != Mu1.ZicheMotherinlaw && mu2 == Mu2.Motherinlaw && mu2 != Mu2.ZicheMotherinlaw && !IsAddressOccupied(Mu1.ZicheMotherinlaw))
+                            {
+                                return true;
+                            }
+                            else
+                            {
+                                return false;
+                            }
+                        }
+                        else
+                        {
+                            return false;
+
+                        }
+                    }
+                }
+            }
+
+            // 榛樿锛氭湭琚嫤鎴笖鐩爣鏈崰鐢� -> 鏀捐
+            return true;
+
+        }
+
+        /// <summary>
+        /// 浼犲叆璁惧锛岃繑鍥炲綋鍓嶈澶囦俊鎭�
+        /// </summary>
+        /// <param name="ChildPosiDeviceCode">璁惧</param>
+        /// <returns></returns>
+        public static int GetEquipmentInformation(string ChildPosiDeviceCode)
+        {
+            IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == ChildPosiDeviceCode);
+            SpeStackerCrane speStackerCrane = (SpeStackerCrane)device;
+            if (speStackerCrane == null)
+            {
+                Console.WriteLine($"璇诲彇鍒拌澶囦负绌�,璁惧缂栧彿锛歿ChildPosiDeviceCode},003");
+                return 0;
+            }
+            DeviceProDTO? deviceProDTOGZMS = speStackerCrane.DeviceProDTOs.FirstOrDefault(x => x.DeviceChildCode == ChildPosiDeviceCode && x.DeviceProParamName == "RgvCraneAutoStatus" && x.DeviceProParamType == "RgvCraneAutoStatus");
+            int GZMS = RGVGetLine(speStackerCrane, deviceProDTOGZMS.DeviceProAddress);
+
+            DeviceProDTO? deviceProDTORWZT = speStackerCrane.DeviceProDTOs.FirstOrDefault(x => x.DeviceChildCode == ChildPosiDeviceCode && x.DeviceProParamName == "RGV_Rgvtaskstutas" && x.DeviceProParamType == "RGV_Rgvtaskstutas");
+            int RWZT = RGVGetLine(speStackerCrane, deviceProDTORWZT.DeviceProAddress);
+
+            DeviceProDTO? deviceProDTOBJGC = speStackerCrane.DeviceProDTOs.FirstOrDefault(x => x.DeviceChildCode == ChildPosiDeviceCode && x.DeviceProParamName == "RGVStepprocess" && x.DeviceProParamType == "RGVStepprocess");
+            int BJGC = RGVGetLine(speStackerCrane, deviceProDTOBJGC.DeviceProAddress);
+
+            DeviceProDTO? deviceProDTOWZ = speStackerCrane.DeviceProDTOs.FirstOrDefault(x => x.DeviceChildCode == ChildPosiDeviceCode && x.DeviceProParamName == "RGVCurrentlocation" && x.DeviceProParamType == "RGVCurrentlocation");
+            int WZ = RGVGetLine(speStackerCrane, deviceProDTOWZ.DeviceProAddress);
+
+
+            if (GZMS == 1 && RWZT == 0 && BJGC == 0)
+            {
+                return WZ;
+            }
+            else
+            {
+                return 0;
+            }
+
+        }
+
+        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 = RGVGetLine(Commonstacker, deviceProDTO.DeviceProAddress);
+            if (MCGStatus == (int)RgvEquipmentStatus.NoCargo)
+            {
+                return true;
+            }
+            return false;
+        }
+
+        /// <summary>
+        /// RGV璁惧鐘舵��
+        /// </summary>
+        public enum RgvEquipmentStatus
+        {
+            /// <summary>
+            /// 鏃犺揣
+            /// </summary>
+            [Description("鏃犺揣")]
+            NoCargo,
+            /// <summary>
+            /// 鏈夎揣
+            /// </summary>
+            [Description("鏈夎揣")]
+            HasCargo,
+            /// <summary>
+            /// 鏈煡
+            /// </summary>
+            [Description("鏈煡")]
+            Unkonw = 6
+
+        }
+
+        /// <summary>
+        /// 浼犲叆璁惧锛岃幏鍙栧綋鍓嶄綅缃綅缃�
+        /// </summary>
+        /// <param name="ChildPosiDeviceCode">璁惧</param>
+        /// <returns></returns>
+        public static int GetEquipmentlocation(string ChildPosiDeviceCode)
+        {
+            IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == ChildPosiDeviceCode);
+            SpeStackerCrane speStackerCrane = (SpeStackerCrane)device;
+            if (speStackerCrane == null) return 0;
+            DeviceProDTO? deviceProDTO = speStackerCrane.DeviceProDTOs.FirstOrDefault(x => x.DeviceChildCode == ChildPosiDeviceCode && x.DeviceProParamName == "RGVCurrentlocation" && x.DeviceProParamType == "RGVCurrentlocation");
+            int MCGStatus = RGVGetLine(speStackerCrane, deviceProDTO.DeviceProAddress);
+            return MCGStatus;
+        }
+
+        public static int RGVGetLine(SpeStackerCrane Commonstacker, string DeviceProDataBlock)
+        {
+            return Commonstacker.Communicator.Read<short>(DeviceProDataBlock);
+        }
+
+        /// <summary>
+        /// 鑾峰彇鍒板瓙杞︿綅缃�
+        /// </summary>
+        /// <param name="commonstacker"></param>
+        /// <param name="deviceCode"></param>
+        /// <returns></returns>
+
+        private int GetzicheWZ(SpeStackerCrane commonstacker, string deviceCode)
+        {
+            DeviceProDTO? RGVCurrentlocation = RgvOperationService.GetRGVDeviceProDTO(commonstacker, commonstacker.DeviceCode, "RGVCurrentlocation", "RGVCurrentlocation");
+            return RgvOperationService.GetLine(commonstacker, RGVCurrentlocation.DeviceProAddress);
         }
 
 
@@ -935,40 +1589,48 @@
         private string HandleExternalRGVAlarm(int alarmCode)
         {
             var alarmMessages = new Dictionary<int, string>
-            {
-        {0, "鏃犳姤璀�"},
-        {1, "RGV灏忚溅鎬ュ仠琚寜涓�"},
-        {2, "姝h浆闆疯揪鎶ヨ"},
-        {3, "鍙嶈浆闆疯揪鎶ヨ"},
-        {4, "鍓嶈繘闄愪綅鎶ヨ"},
-        {5, "鍚庨��闄愪綅鎶ヨ"},
-        {6, ""},
-        {7, "PLC鎽稿潡鏁呴殰"},
-        {8, "PLC鎵╁睍妯″潡鏁呴殰"},
-        {9, "绉伴噸妯″潡鏁呴殰"},
-        {10, "鎵爜瀹氫綅鏁呴殰"},
-        {11, "RGV闀挎椂闂寸┖杞晠闅�"},
-        {12, "鐩殑鍦颁笉绛変簬瀹為檯浣嶇疆鏁呴殰"},
-        {13, "涓庢�绘帶閫氳鏁呴殰"},
-        {14, "鍓嶉浄杈惧睆钄借鍛�"},
-        {15, "鍚庨浄杈惧睆钄借鍛�"},
-        {16, "琛岃蛋鍙橀鍣ㄦ晠闅�"},
-        {17, "浼哥缉鍙夊彉棰戝櫒鏁呴殰"},
-        {18, "娑插帇鍗曞厓杩囪浇淇濇姢鏁呴殰"},
-        {19, "娑插帇涓婂崌瓒呮椂鎶ヨ"},
-        {20, "娑插帇涓嬮檷瓒呮椂鎶ヨ"},
-        {21, "浼哥缉鍙変几鍑鸿秴鏃舵姤璀�"},
-        {22, "浼哥缉鍙夌缉鍥炶秴鏃舵姤璀�"},
-        {23, "澶栧舰妫�娴嬫姤璀�"},
-        {24, "绉伴噸瓒呴噸鎶ヨ"},
-        {25, "璐у弶浼稿嚭鏋侀檺闄愪綅鎶ヨ"},
-        {26, "璐у弶缂╁洖鏋侀檺闄愪綅鎶ヨ"},
-        {27, "鍙栬揣鏃惰嚜韬湁璐х墿鎶ヨ"},
-        {28, "鏀捐揣鏃惰嚜韬棤璐х墿鎶ヨ"},
-        {29, "璐у弶鏈洖鍒板垵濮嬩綅鎶ヨ"},
-        {30, "瑙﹀彂浠呯Щ鍔ㄥ懡浠ゆ椂璐у弶涓嶅湪鍒濆浣嶆姤璀�"},
-                {31, "璐у弶鍒拌揪鍒濆浣嶄絾涓綅浼犳劅鍣ㄦ湭妫�娴嬪埌鎶ヨ"}
-            };
+{
+    {0, "鏃犳姤璀�"},
+    {1, "RGV灏忚溅鎬ュ仠琚寜涓�"},
+    {2, "姝h浆闆疯揪鎶ヨ"},
+    {3, "鍙嶈浆闆疯揪鎶ヨ"},
+    {4, "鍓嶈繘闄愪綅鎶ヨ"},
+    {5, "鍚庨��闄愪綅鎶ヨ"},
+    {6, ""},
+    {7, "PLC妯″潡鏁呴殰"},
+    {8, "PLC鎵╁睍妯″潡鏁呴殰"},
+    {9, "绉伴噸妯″潡鏁呴殰"},
+    {10, "鎵爜瀹氫綅鏁呴殰"},
+    {11, "RGV闀挎椂闂寸┖杞晠闅�"},
+    {12, "鐩殑鍦颁笉绛変簬瀹為檯浣嶇疆鏁呴殰"},
+    {13, "涓庢�绘帶閫氳鏁呴殰"},
+    {14, "鍓嶉浄杈惧睆钄借鍛�"},
+    {15, "鍚庨浄杈惧睆钄借鍛�"},
+    {16, "琛岃蛋鍙橀鍣ㄦ晠闅�"},
+    {17, "浼哥缉鍙夊彉棰戝櫒鏁呴殰"},
+    {18, "娑插帇鍗曞厓杩囪浇淇濇姢鏁呴殰"},
+    {19, "娑插帇涓婂崌瓒呮椂鎶ヨ"},
+    {20, "娑插帇涓嬮檷瓒呮椂鎶ヨ"},
+    {21, "浼哥缉鍙変几鍑鸿秴鏃舵姤璀�"},
+    {22, "浼哥缉鍙夌缉鍥炶秴鏃舵姤璀�"},
+    {23, "澶栧舰妫�娴嬫姤璀�"},
+    {24, "绉伴噸瓒呴噸鎶ヨ"},
+    {25, "璐у弶浼稿嚭鏋侀檺闄愪綅鎶ヨ"},
+    {26, "璐у弶缂╁洖鏋侀檺闄愪綅鎶ヨ"},
+    {27, "鍙栬揣鏃惰嚜韬湁璐х墿鎶ヨ"},
+    {28, "鏀捐揣鏃惰嚜韬棤璐х墿鎶ヨ"},
+    {29, "璐у弶鏈洖鍒板垵濮嬩綅鎶ヨ"},
+    {30, "瑙﹀彂浠呯Щ鍔ㄥ懡浠ゆ椂璐у弶涓嶅湪鍒濆浣嶆姤璀�"},
+    {31, "璐у弶鍒拌揪鍒濆浣嶄絾涓綅浼犳劅鍣ㄦ湭妫�娴嬪埌鎶ヨ"},
+    {32, "琛岃蛋杞存病鍒颁綅绂佹璐у弶浼稿嚭"},
+    {33, "鍙栬揣寮傚父鎶ヨ"},
+    {34, "鏀捐揣寮傚父鎶ヨ"},
+    {35, "澶栧瀷妫�娴�-鍓嶈秴鍑烘姤璀�"},
+    {36, "澶栧瀷妫�娴�-鍚庤秴鍑烘姤璀�"},
+    {37, "澶栧瀷妫�娴�-宸﹁秴鍑烘姤璀�"},
+    {38, "澶栧瀷妫�娴�-鍙宠秴鍑烘姤璀�"},
+    {39, "澶栧瀷妫�娴�-涓婅秴鍑烘姤璀�"}
+};
 
             return alarmMessages.ContainsKey(alarmCode) ? alarmMessages[alarmCode] : "鏈煡鎶ヨ浠g爜";
         }

--
Gitblit v1.9.3