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 | 193 +++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 188 insertions(+), 5 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 5e75a4c..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,6 +63,7 @@
private readonly IAgvStationService _gvStationService;
private readonly IServiceProvider _serviceProvider;
private static bool _isMonitoring = false;
+ private readonly IRepository<DeviceAlarmLog> _deviceAlarmLog;
//private static CancellationTokenSource _cancellationTokenSource;
// 鍦ㄧ被绾у埆娣诲姞鐙珛鐨勭洃鎺х姸鎬�
@@ -74,10 +77,11 @@
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;
}
@@ -693,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";
@@ -838,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