From 28110912ca4803e5793f181517d7bf2d7a5ea2ad Mon Sep 17 00:00:00 2001
From: HuBingJie <3146306518@qq.com>
Date: 星期五, 05 十二月 2025 00:32:49 +0800
Subject: [PATCH] 1

---
 代码管理/WCS/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/RgvoperainformService.cs |  362 +++++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 307 insertions(+), 55 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 496ee36..dff6cb4 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"
@@ -1,4 +1,4 @@
-锘�#region << 鐗� 鏈� 娉� 閲� >>
+#region << 鐗� 鏈� 娉� 閲� >>
 /*----------------------------------------------------------------
  * 鍛藉悕绌洪棿锛歐IDESEAWCS_TaskInfoService
  * 鍒涘缓鑰咃細鑳$搴�
@@ -41,6 +41,7 @@
 using System.Threading.Tasks;
 using WIDESEA_Comm.Http;
 using WIDESEAWCS_Core;
+using WIDESEAWCS_Core.BaseRepository;
 using WIDESEAWCS_Core.BaseServices;
 using WIDESEAWCS_Core.Enums;
 using WIDESEAWCS_DTO.Enum;
@@ -53,6 +54,7 @@
 using WIDESEAWCS_QuartzJob.DTO;
 using WIDESEAWCS_QuartzJob.Models;
 using WIDESEAWCS_QuartzJob.Service;
+using WIDESEA_Common.Log;
 
 namespace WIDESEAWCS_TaskInfoService
 {
@@ -61,40 +63,42 @@
         private readonly IAgvStationService _gvStationService;
         private readonly IServiceProvider _serviceProvider;
         private static bool _isMonitoring = false;
+        private readonly IRepository<DeviceAlarmLog> _deviceAlarmLog;
         //private static CancellationTokenSource _cancellationTokenSource;
-        
+
         // 鍦ㄧ被绾у埆娣诲姞鐙珛鐨勭洃鎺х姸鎬�
         private bool _isOutboundMonitoring = false;
         private bool _isInboundMonitoring = false;
         private bool _isSafetyDoorMonitoring = false;
+        private bool _isPlatformMonitoring = false;
 
+        // 鍦ㄧ被鐨勫瓧娈靛尯
+        private CancellationTokenSource? _platformCancellationTokenSource;
         private CancellationTokenSource _outboundCancellationTokenSource;
         private CancellationTokenSource _inboundCancellationTokenSource;
         private CancellationTokenSource _safetyDoorCancellationTokenSource;
-        public RgvoperainformService(ITask_HtyRepository BaseDal, IAgvStationService agvStationService, IServiceProvider serviceProvider) : base(BaseDal)
+        public RgvoperainformService(ITask_HtyRepository BaseDal, IAgvStationService agvStationService, IServiceProvider serviceProvider, IRepository<DeviceAlarmLog> deviceAlarmLog) : base(BaseDal)
         {
             _gvStationService = agvStationService;
             _serviceProvider = serviceProvider;
+            _deviceAlarmLog = deviceAlarmLog;
         }
 
 
         //=================================================璇诲彇璁惧淇℃伅==========================================================
 
-
-
-
-
         /// <summary>
-        /// 鑾峰彇璁惧鐘舵�侊紙鏀寔鍑哄簱銆佸叆搴撳拰瀹夊叏闂ㄧ嫭绔嬬洃鎺э級
+        /// 鑾峰彇璁惧鐘舵�侊紙鏀寔鍑哄簱銆佸叆搴撱�佸畨鍏ㄩ棬鍜岀珯鍙扮嫭绔嬬洃鎺э級
         /// </summary>
         /// <param name="off">0:鍋滄 1:鍚姩 2:浠呮煡璇�</param>
-        /// <param name="monitorType">鐩戞帶绫诲瀷锛歰utbound-鍑哄簱 inbound-鍏ュ簱 safetydoor-瀹夊叏闂� all-鍏ㄩ儴</param>
+        /// <param name="monitorType">鐩戞帶绫诲瀷锛歰utbound-鍑哄簱 inbound-鍏ュ簱 safetydoor-瀹夊叏闂� platform-绔欏彴 all-鍏ㄩ儴</param>
         /// <returns></returns>
         public WebResponseContent GetDeviceStatusDto(int off, string monitorType = "outbound")
         {
             bool isOutbound = monitorType == "outbound" || monitorType == "all";//鍑哄簱
             bool isInbound = monitorType == "inbound" || monitorType == "all";//鍏ュ簱
             bool isSafetyDoor = monitorType == "safetydoor" || monitorType == "all";//瀹夊叏闂�
+            bool isPlatform = monitorType == "platform" || monitorType == "all";//绔欏彴
 
             if (off == 1)
             {
@@ -120,6 +124,13 @@
                     _ = Task.Run(async () => await StartDeviceMonitoring(_safetyDoorCancellationTokenSource.Token, "safetydoor"));
                 }
 
+                if (isPlatform && !_isPlatformMonitoring)
+                {
+                    _isPlatformMonitoring = true;
+                    _platformCancellationTokenSource = new CancellationTokenSource();
+                    _ = Task.Run(async () => await StartDeviceMonitoring(_platformCancellationTokenSource.Token, "platform"));
+                }
+
                 var immediateData = GetImmediateDeviceData(monitorType);
                 string message = GetMonitorStatusMessage(monitorType);
                 return WebResponseContent.Instance.OK($"璁惧鐘舵�佺洃鎺у凡鍚姩 - {message}", immediateData);
@@ -143,6 +154,12 @@
                 {
                     _isSafetyDoorMonitoring = false;
                     _safetyDoorCancellationTokenSource?.Cancel();
+                }
+
+                if (isPlatform && _isPlatformMonitoring)
+                {
+                    _isPlatformMonitoring = false;
+                    _platformCancellationTokenSource?.Cancel();
                 }
 
                 var finalData = GetImmediateDeviceData(monitorType);
@@ -212,6 +229,9 @@
                 case "safetydoor":
                     _isSafetyDoorMonitoring = false;
                     break;
+                case "platform":
+                    _isPlatformMonitoring = false;
+                    break;
             }
         }
 
@@ -236,7 +256,14 @@
                 ["MaterialIn"] = new List<string> { "RGV101" },
 
                 // 瀹夊叏闂ㄨ澶�
-                ["SafetyDoor"] = new List<string> { "HCJ2000" }, // 瀹夊叏闂�
+                ["SafetyDoor"] = new List<string> { "HCJ2000" },
+
+                // 绔欏彴璁惧 - 鏍规嵁鎮ㄦ彁渚涚殑鍗忚娣诲姞鎵�鏈夌珯鍙�
+                //        ["Platform"] = new List<string> {
+                //    "1001", "1002", "2016", "2017", "2018", "2019", "1021", "1061", "1131", "1171"
+                //}
+                ["Platform"] = new List<string> { "HCJ2000" },
+
             };
 
             // 璁惧绫诲瀷瀵瑰簲鐨勫弬鏁伴厤缃�
@@ -339,6 +366,13 @@
             ("ResetStatus", "ReadDeviceCommand", "瀹夊叏闂ㄥ浣嶇姸鎬�"),
             ("AlarmSummary", "DeviceCommand", "鎶ヨ淇℃伅"),
             ("OpenDoor", "DeviceCommand", "寮�闂ㄤ俊鎭�")
+        },
+
+                // 绔欏彴璁惧鍙傛暟閰嶇疆 - 鏍规嵁鎮ㄦ彁渚涚殑鍗忚娣诲姞
+                ["Platform"] = new List<(string, string, string)>
+        {
+            ("HCJ_GoodsStatus", "ReadDeviceCommand", "鍏夌數淇″彿"),
+            ("DoorRequest", "DeviceCommand", "浠诲姟id")
         }
             };
 
@@ -352,13 +386,13 @@
                 {
                     "outbound" => group.Key == "MotherCar" || group.Key == "TransferCar" || group.Key == "MaterialOut",
                     "inbound" => group.Key == "MaterialIn" || group.Key == "InboundMotherCar" || group.Key == "InboundTransferCar",
-                    "safetydoor" => group.Key == "SafetyDoor", // 瀹夊叏闂ㄧ洃鎺х被鍨�
+                    "safetydoor" => group.Key == "SafetyDoor",
+                    "platform" => group.Key == "Platform", // 绔欏彴鐩戞帶绫诲瀷
                     "all" => true,
                     _ => group.Key == "MotherCar" || group.Key == "TransferCar" || group.Key == "MaterialOut"
                 };
             }).ToDictionary(x => x.Key, x => x.Value);
 
-            int i = 0;
             // 閬嶅巻绛涢�夊悗鐨勮澶囩粍
             foreach (var deviceGroup in filteredDeviceGroups)
             {
@@ -413,57 +447,83 @@
                     }
                     else if (device is CommonConveyorLine conveyorLine)
                     {
-                        // 澶勭悊瀹夊叏闂ㄨ澶囷紙CommonConveyorLine 绫诲瀷锛�
-                        // 鍒涘缓涓変釜瀹夊叏闂ㄨ澶囩殑鏁版嵁
-                        List<string> safetyDoorList = new List<string> { "AQM001", "AQM002", "AQM003" };
-
-                        // 涓烘瘡涓畨鍏ㄩ棬鍒涘缓鏁版嵁
-                        foreach (string safetyDoorCode in safetyDoorList)
+                        // 澶勭悊瀹夊叏闂ㄨ澶囧拰绔欏彴璁惧锛圕ommonConveyorLine 绫诲瀷锛�
+                        if (deviceType == "SafetyDoor")
                         {
-                            var deviceData = new Dictionary<string, int>();
+                            // 瀹夊叏闂ㄨ澶囧鐞嗛�昏緫锛堜繚鎸佷笉鍙橈級
+                            List<string> safetyDoorList = new List<string> { "AQM001", "AQM002", "AQM003" };
 
-                            // 閬嶅巻璇ヨ澶囩殑鎵�鏈夊弬鏁�
-                            foreach (var param in deviceParams)
+                            foreach (string safetyDoorCode in safetyDoorList)
                             {
-                                try
-                                {
-                                    // 浣跨敤瀹夊叏闂ㄥ悕绉版煡璇㈠搴旂殑鍙傛暟
-                                    DeviceProDTO? devicePro = GetSafetyDoorDeviceProDTO(
-                                        conveyorLine, safetyDoorCode, param.DeviceProParamName, param.DeviceProParamType);
+                                var deviceData = new Dictionary<string, int>();
 
-                                    if (devicePro != null)
-                                    {
-                                        // 瀵逛簬 CommonConveyorLine 绫诲瀷锛屼娇鐢ㄩ�氱敤鐨勬暟鎹鍙栨柟娉�
-                                        int res = ReadCommonConveyorLineData(conveyorLine, devicePro.DeviceProAddress);
-                                        deviceData[param.DeviceProRemark] = res;
-                                    }
-                                    else
-                                    {
-                                        deviceData[param.DeviceProRemark] = -1; // 浣跨敤 -1 琛ㄧず鏌ヨ澶辫触
-                                    }
-                                }
-                                catch (Exception)
+                                foreach (var param in deviceParams)
                                 {
-                                    deviceData[param.DeviceProRemark] = -1; // 浣跨敤 -1 琛ㄧず鏌ヨ寮傚父
+                                    try
+                                    {
+                                        DeviceProDTO? devicePro = GetSafetyDoorDeviceProDTO(
+                                            conveyorLine, safetyDoorCode, param.DeviceProParamName, param.DeviceProParamType);
+
+                                        if (devicePro != null)
+                                        {
+                                            int res = ReadCommonConveyorLineData(conveyorLine, devicePro.DeviceProAddress);
+                                            deviceData[param.DeviceProRemark] = res;
+                                        }
+                                        else
+                                        {
+                                            deviceData[param.DeviceProRemark] = -1;
+                                        }
+                                    }
+                                    catch (Exception)
+                                    {
+                                        deviceData[param.DeviceProRemark] = -1;
+                                    }
                                 }
+
+                                finalResult[safetyDoorCode] = deviceData;
                             }
+                        }
 
-                            // 灏嗗綋鍓嶅畨鍏ㄩ棬璁惧鐨勬暟鎹坊鍔犲埌鏈�缁堢粨鏋滀腑锛屼娇鐢ㄥ畨鍏ㄩ棬鍚嶇О浣滀负key
-                            finalResult[safetyDoorCode] = deviceData;
+                        if (deviceType == "Platform")
+                        {
+                            // 瀹夊叏闂ㄨ澶囧鐞嗛�昏緫锛堜繚鎸佷笉鍙橈級
+                            List<string> PlatformList = new List<string> { "1001", "1002", "2016", "2017", "2018", "2019", "1021", "1061", "1131", "1171" };
+
+                            foreach (string Platform in PlatformList)
+                            {
+                                var deviceData = new Dictionary<string, int>();
+
+                                foreach (var param in deviceParams)
+                                {
+                                    try
+                                    {
+                                        DeviceProDTO? devicePro = GetSafetyDoorDeviceProDTO(
+                                            conveyorLine, Platform, param.DeviceProParamName, param.DeviceProParamType);
+
+                                        if (devicePro != null)
+                                        {
+                                            int res = ReadCommonConveyorLineData(conveyorLine, devicePro.DeviceProAddress);
+                                            deviceData[param.DeviceProRemark] = res;
+                                        }
+                                        else
+                                        {
+                                            deviceData[param.DeviceProRemark] = -1;
+                                        }
+                                    }
+                                    catch (Exception)
+                                    {
+                                        deviceData[param.DeviceProRemark] = -1;
+                                    }
+                                }
+
+                                finalResult[Platform] = deviceData;
+                            }
                         }
                     }
                     else
                     {
                         // 鍗充娇璁惧涓嶅瓨鍦ㄦ垨涓嶆槸鏀寔鐨勭被鍨嬶紝涔熷垱寤轰竴涓┖瀛楀吀
                         finalResult[deviceChildCode] = new Dictionary<string, int>();
-                        /*if (device != null)
-                        {
-                            Console.WriteLine($"璀﹀憡锛氳澶� {deviceChildCode} 绫诲瀷 {device.GetType().Name} 涓嶆敮鎸侊紝鏃犳硶璇诲彇鏁版嵁");
-                        }
-                        else
-                        {
-                            Console.WriteLine($"璀﹀憡锛氳澶� {deviceChildCode} 涓嶅瓨鍦�");
-                        }*/
                     }
                 }
             }
@@ -483,7 +543,8 @@
                 "outbound" => $"鍑哄簱鐩戞帶: {(_isOutboundMonitoring ? "杩愯涓�" : "宸插仠姝�")}",
                 "inbound" => $"鍏ュ簱鐩戞帶: {(_isInboundMonitoring ? "杩愯涓�" : "宸插仠姝�")}",
                 "safetydoor" => $"瀹夊叏闂ㄧ洃鎺�: {(_isSafetyDoorMonitoring ? "杩愯涓�" : "宸插仠姝�")}",
-                "all" => $"鍑哄簱鐩戞帶: {(_isOutboundMonitoring ? "杩愯涓�" : "宸插仠姝�")}, 鍏ュ簱鐩戞帶: {(_isInboundMonitoring ? "杩愯涓�" : "宸插仠姝�")}, 瀹夊叏闂ㄧ洃鎺�: {(_isSafetyDoorMonitoring ? "杩愯涓�" : "宸插仠姝�")}",
+                "platform" => $"绔欏彴鐩戞帶: {(_isPlatformMonitoring ? "杩愯涓�" : "宸插仠姝�")}", // 绔欏彴鐩戞帶鐘舵��
+                "all" => $"鍑哄簱鐩戞帶: {(_isOutboundMonitoring ? "杩愯涓�" : "宸插仠姝�")}, 鍏ュ簱鐩戞帶: {(_isInboundMonitoring ? "杩愯涓�" : "宸插仠姝�")}, 瀹夊叏闂ㄧ洃鎺�: {(_isSafetyDoorMonitoring ? "杩愯涓�" : "宸插仠姝�")}, 绔欏彴鐩戞帶: {(_isPlatformMonitoring ? "杩愯涓�" : "宸插仠姝�")}",
                 _ => $"鍑哄簱鐩戞帶: {(_isOutboundMonitoring ? "杩愯涓�" : "宸插仠姝�")}"
             };
         }
@@ -500,11 +561,11 @@
                 "outbound" => "鍑哄簱",
                 "inbound" => "鍏ュ簱",
                 "safetydoor" => "瀹夊叏闂�",
+                "platform" => "绔欏彴", // 绔欏彴鏄剧ず鍚嶇О
                 "all" => "鍏ㄩ儴",
                 _ => "鍑哄簱"
             };
         }
-
 
         /// <summary>
         /// 璇诲彇璁惧淇℃伅
@@ -517,7 +578,6 @@
             return Commonstacker.Communicator.Read<short>(DeviceProDataBlock);
         }
 
-
         /// <summary>
         /// 鏌ヨ瀹夊叏闂ㄨ澶�
         /// </summary>
@@ -528,6 +588,19 @@
         public static DeviceProDTO? GetSafetyDoorDeviceProDTO(CommonConveyorLine Commonstacker, string SCAddress, string DeviceProParamName, string DeviceProParamType)
         {
             return Commonstacker.DeviceProDTOs.FirstOrDefault(x => x.DeviceChildCode == SCAddress && x.DeviceProParamName == DeviceProParamName && x.DeviceProParamType == DeviceProParamType);
+        }
+
+        /// <summary>
+        /// 鏌ヨ绔欏彴璁惧
+        /// </summary>
+        /// <param name="Commonstacker"></param>
+        /// <param name="PlatformCode">绔欏彴缂栧彿</param>
+        /// <param name="DeviceProParamName">鍙傛暟鍚嶇О</param>
+        /// <param name="DeviceProParamType">鍙傛暟绫诲瀷</param>
+        /// <returns></returns>
+        public static DeviceProDTO? GetPlatformDeviceProDTO(CommonConveyorLine Commonstacker, string PlatformCode, string DeviceProParamName, string DeviceProParamType)
+        {
+            return Commonstacker.DeviceProDTOs.FirstOrDefault(x => x.DeviceChildCode == PlatformCode && x.DeviceProParamName == DeviceProParamName && x.DeviceProParamType == DeviceProParamType);
         }
 
         //=================================================璇诲彇璁惧淇℃伅==========================================================
@@ -624,12 +697,35 @@
                     DeviceProParamName = "RGV_Risingsignalplace";
                     DeviceProParamType = "DeviceCommand";
                     zhi = parameter;
-                    break;
-                case "xj":          //涓嬮檷
+                    DeviceProDTO? RGV_Resetoperationss1 = RgvOperationService.GetRGVDeviceProDTO(Commonstacker, deviceName, DeviceProParamName, DeviceProParamType);        //涓婂崌
+                    RgvOperationService.RgvSetLine(Commonstacker, RGV_Resetoperationss1.DeviceProAddress, (short)zhi);
+                    //DeviceProDTO? RGV_Resetoperationss2 = RgvOperationService.GetRGVDeviceProDTO(Commonstacker, deviceName, "RGV_Risingsignalplace", "ReadDeviceCommand");        //涓婂崌鍒颁綅淇″彿
+                    //    int resss = 0;
+                    //    while (resss == 0)
+                    //    {
+                    //        Thread.Sleep(2000);
+                    //        resss = RgvOperationService.GetLine(Commonstacker, RGV_Resetoperationss2.DeviceProAddress);
+                    //    }
+                    //    DeviceProDTO? RGV_Resetoperationss3 = RgvOperationService.GetRGVDeviceProDTO(Commonstacker, deviceName, DeviceProParamName, DeviceProParamType);        //涓婂崌
+                    //    RgvOperationService.RgvSetLine(Commonstacker, RGV_Resetoperationss3.DeviceProAddress, 0);
+                        return webResponse.OK();
+
+                    case "xj":          //涓嬮檷
                     DeviceProParamName = "RGV_Descentsignal";
                     DeviceProParamType = "DeviceCommand";
                     zhi = parameter;
-                    break;
+                        DeviceProDTO? RGV_Resetoperationxj1 = RgvOperationService.GetRGVDeviceProDTO(Commonstacker, deviceName, DeviceProParamName, DeviceProParamType);        //涓嬮檷
+                        RgvOperationService.RgvSetLine(Commonstacker, RGV_Resetoperationxj1.DeviceProAddress, (short)zhi);
+                        //DeviceProDTO? RGV_Resetoperationxj2 = RgvOperationService.GetRGVDeviceProDTO(Commonstacker, deviceName, "RGV_Descentsignal", "ReadDeviceCommand");        //涓嬮檷鍒颁綅淇″彿
+                        //int resxj = 0;
+                        //while (resxj == 0)
+                        //{
+                        //    Thread.Sleep(2000);
+                        //    resxj = RgvOperationService.GetLine(Commonstacker, RGV_Resetoperationxj2.DeviceProAddress);
+                        //}
+                        //DeviceProDTO? RGV_Resetoperationxj3 = RgvOperationService.GetRGVDeviceProDTO(Commonstacker, deviceName, DeviceProParamName, DeviceProParamType);        //涓婂崌
+                        //RgvOperationService.RgvSetLine(Commonstacker, RGV_Resetoperationxj3.DeviceProAddress, 0);
+                        return webResponse.OK();
                 case "dz":          //鍦板潃
                     DeviceProParamName = "RGV_RGVTasklocationt";
                     DeviceProParamType = "DeviceCommand";
@@ -769,6 +865,162 @@
                 return webResponse.Error("璁惧鎿嶄綔澶辫触");
             }
 }
+
+        /// <summary>
+        /// 鏌ョ湅鎶ヨ
+        /// </summary>
+        public WebResponseContent LogAlarmToDatabase(string JobDeviceName)
+        {
+            // 璁惧鍒嗙被 - 鍚堝苟鐗堟湰
+            var deviceCategories = new Dictionary<string, List<string>>
+            {
+                ["MotherCar"] = new List<string> { "RGV112", "RGV110", "RGV114", "RGV115", "RGV103", "RGV105", "RGV108", "RGV109" },
+                ["TransferCar"] = new List<string> { "RGV116", "RGV111", "RGV104", "RGV107" },
+                ["ExternalRGV"] = new List<string> { "RGV118", "RGV101" }
+            };
+
+            WebResponseContent webResponse = new WebResponseContent();
+            string DeviceName = JobDeviceName;    //璁惧鍚嶇О
+            IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == DeviceName);
+            if (device == null) return webResponse.Error();
+            SpeStackerCrane Commonstacker = (SpeStackerCrane)device;
+            DeviceProDTO? RGV_Resetoperation = RgvOperationService.GetRGVDeviceProDTO(Commonstacker, DeviceName, "RGV_Faultcode", "ReadDeviceCommand");
+            DeviceProDTO? RGVCurrentlocation = RgvOperationService.GetRGVDeviceProDTO(Commonstacker, DeviceName, "RGVCurrentlocation", "RGVCurrentlocation");
+            DeviceProDTO? RGV_Rgvtaskid = RgvOperationService.GetRGVDeviceProDTO(Commonstacker, DeviceName, "RGV_Rgvtaskid", "ReadDeviceCommand");
+
+
+            int baoj = RgvOperationService.GetLine(Commonstacker, RGV_Resetoperation.DeviceProAddress);
+
+            if (baoj<=0)
+            {
+                return null;
+            }
+            int Currentlocation = RgvOperationService.GetLine(Commonstacker, RGVCurrentlocation.DeviceProAddress);
+            int Rgvtaskid = RgvOperationService.GetLine(Commonstacker, RGV_Rgvtaskid.DeviceProAddress);
+
+            string alarmMessage = "";
+            if (deviceCategories["MotherCar"].Contains(DeviceName))
+            {
+                // 姣嶈溅涓撶敤鎶ヨ澶勭悊閫昏緫
+                alarmMessage = HandleMotherCarAlarm(baoj);
+            }
+            else if (deviceCategories["TransferCar"].Contains(DeviceName))
+            {
+                // 瀛愯溅涓撶敤鎶ヨ澶勭悊閫昏緫
+                alarmMessage = HandleTransferCarAlarm(baoj);
+            }
+            else if (deviceCategories["ExternalRGV"].Contains(DeviceName))
+            {
+                // 澶栧彛RGV涓撶敤鎶ヨ澶勭悊閫昏緫
+                alarmMessage = HandleExternalRGVAlarm(baoj);
+            }
+            
+            // 鍐欏叆鏂囨湰鏃ュ織锛堟寜璁惧鍒嗙粍/鎸夋棩鍒囧垎锛�
+            var logContent = $"璁惧:{DeviceName} | 鎶ヨ鐮�:{baoj} | 鎶ヨ鎻忚堪:{alarmMessage} | 褰撳墠浣嶇疆:{Currentlocation} | 浠诲姟鍙�:{Rgvtaskid}";
+            // groupName: Alarm锛宭ogName: 璁惧鍚�
+            WriteLog.Write_Log("Alarm", DeviceName, logContent, new
+            {
+                DeviceCode = DeviceName,
+                AlarmCode = baoj,
+                AlarmContent = alarmMessage,
+                DeviceLocation = Currentlocation,
+                TaskNum = Rgvtaskid,
+                Time = DateTime.Now
+            });
+            return webResponse.OK();
+        }
+
+
+        // 鎶ヨ浠g爜鏄犲皠鏂规硶
+        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, "璐у弶鍒拌揪鍒濆浣嶄絾涓綅浼犳劅鍣ㄦ湭妫�娴嬪埌鎶ヨ"}
+            };
+
+            return alarmMessages.ContainsKey(alarmCode) ? alarmMessages[alarmCode] : "鏈煡鎶ヨ浠g爜";
+        }
+
+
+        private string HandleTransferCarAlarm(int alarmCode)
+        {
+            var alarmMessages = new Dictionary<int, string>
+    {
+        {0, "鏃犳姤璀�"},
+        {1, "RGV灏忚溅鎬ュ仠琚寜涓�"},
+        {2, "鍓嶈繘闄愪綅鎶ヨ"},
+        {3, "鍚庨��闄愪綅鎶ヨ"},
+        {4, "PLC鎽稿潡鏁呴殰"},
+        {5, "PLC鎵╁睍妯″潡鏁呴殰"},
+        {6, "鎵爜瀹氫綅鏁呴殰"},
+        {7, "RGV闀挎椂闂寸┖杞晠闅�"},
+        {8, "鐩殑鍦颁笉绛変簬瀹為檯浣嶇疆鏁呴殰"},
+        {9, "涓庢�绘帶閫氳鏁呴殰"},
+        {10, "琛岃蛋鍙橀鍣ㄦ晠闅�"},
+        {11, "娑插帇鍗曞厓杩囪浇淇濇姢鏁呴殰"},
+        {12, "娑插帇涓婂崌瓒呮椂鎶ヨ"},
+        {13, "娑插帇涓嬮檷瓒呮椂鎶ヨ"},
+        {14, "鍙栬揣鏃惰嚜韬湁璐х墿鎶ヨ"},
+        {15, "鏀捐揣鏃惰嚜韬棤璐х墿鎶ヨ"},
+        {16, "鍙栬揣妫�娴嬩笉鍒拌揣鐗╂姤璀�"}
+    };
+
+            return alarmMessages.ContainsKey(alarmCode) ? alarmMessages[alarmCode] : "鏈煡鎶ヨ浠g爜";
+        }
+
+        private string HandleMotherCarAlarm(int alarmCode)
+        {
+            var alarmMessages = new Dictionary<int, string>
+    {
+        {0, "鏃犳姤璀�"},
+        {1, "RGV灏忚溅鎬ュ仠琚寜涓�"},
+        {2, "鍓嶈繘闄愪綅鎶ヨ"},
+        {3, "鍚庨��闄愪綅鎶ヨ"},
+        {4, "PLC鎽稿潡鏁呴殰"},
+        {5, "PLC鎵╁睍妯″潡鏁呴殰"},
+        {6, "RGV闀挎椂闂寸┖杞晠闅�"},
+        {7, "鐩殑鍦颁笉绛変簬瀹為檯浣嶇疆鏁呴殰"},
+        {8, "涓庢�绘帶閫氳鏁呴殰"},
+        {9, "琛岃蛋鍙橀鍣ㄦ晠闅�"},
+        {10, "鍙栬揣鏃惰嚜韬湁璐х墿鎶ヨ"},
+        {11, "鏀捐揣鏃惰嚜韬棤璐х墿鎶ヨ"},
+        {12, "鍋滄鏃朵綅缃繃鍐叉姤璀�"}
+    };
+
+            return alarmMessages.ContainsKey(alarmCode) ? alarmMessages[alarmCode] : "鏈煡鎶ヨ浠g爜";
+        }
     }
 }
     
\ No newline at end of file

--
Gitblit v1.9.3