From a5ca8352f035f95d23717e49b74a6c6aea8a9fc9 Mon Sep 17 00:00:00 2001 From: huangxiaoqiang <1247017146@qq.com> Date: 星期三, 02 四月 2025 16:03:12 +0800 Subject: [PATCH] 添加MOM异常信息页面,OCV管理页面,优化WCS不能添加用户信息问题,优化分容空框回流写入线体信息失败问题 --- CodeManagement/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerStationJob/CommonStackerStationCraneJob.cs | 128 ++++++++++++++++++++++++++++++++++++++---- 1 files changed, 114 insertions(+), 14 deletions(-) diff --git a/CodeManagement/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerStationJob/CommonStackerStationCraneJob.cs b/CodeManagement/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerStationJob/CommonStackerStationCraneJob.cs index f197e7e..7bc6ebb 100644 --- a/CodeManagement/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerStationJob/CommonStackerStationCraneJob.cs +++ b/CodeManagement/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerStationJob/CommonStackerStationCraneJob.cs @@ -1,4 +1,4 @@ -锘縰sing HslCommunication; +锘縰sing Masuit.Tools.Systems; using Newtonsoft.Json; using Quartz; using System.Diagnostics.CodeAnalysis; @@ -9,20 +9,17 @@ using WIDESEAWCS_Core.Caches; using WIDESEAWCS_Core.Helper; using WIDESEAWCS_Core.HttpContextUser; -using WIDESEAWCS_DTO.MOM; using WIDESEAWCS_IProcessRepository; using WIDESEAWCS_ITaskInfoRepository; using WIDESEAWCS_ITaskInfoService; -using WIDESEAWCS_Model; using WIDESEAWCS_Model.Models; using WIDESEAWCS_QuartzJob; using WIDESEAWCS_QuartzJob.DeviceBase; -using WIDESEAWCS_QuartzJob.Models; using WIDESEAWCS_QuartzJob.Service; using WIDESEAWCS_QuartzJob.StackerCrane.Enum; using WIDESEAWCS_SignalR; +using WIDESEAWCS_Tasks.ConveyorLineJob; using WIDESEAWCS_Tasks.StackerCraneJob; -using WIDESEAWCS_Common; namespace WIDESEAWCS_Tasks { @@ -76,15 +73,15 @@ bool sendFlag = commonStackerCrane.SendCommand(stackerCraneTaskCommand); if (sendFlag) { - StringBuilder builder = new StringBuilder(); - builder.AppendLine(); - builder.AppendLine($"銆恵commonStackerCrane.DeviceName}銆戝爢鍨涙満鐘舵�侊細銆恵commonStackerCrane.StackerCraneStatusDes}銆�,鏃堕棿锛氥�恵DateTime.Now}銆�"); - builder.AppendLine($"銆恵commonStackerCrane.DeviceName}銆戞墜鑷姩鐘舵�侊細銆恵commonStackerCrane.StackerCraneAutoStatusDes}銆�,鏃堕棿锛氥�恵DateTime.Now}銆�"); - builder.AppendLine($"銆恵commonStackerCrane.DeviceName}銆戜綔涓氱姸鎬侊細銆恵commonStackerCrane.StackerCraneWorkStatusDes}銆�,鏃堕棿锛氥�恵DateTime.Now}銆�"); - builder.AppendLine($"銆恵commonStackerCrane.DeviceName}銆戜笅鍙戜换鍔℃垚鍔�,銆恵JsonConvert.SerializeObject(stackerCraneTaskCommand, Formatting.Indented)}銆�"); - builder.AppendLine($"鏃堕棿锛氥�恵DateTime.Now}銆�"); - builder.AppendLine(); - ConsoleHelper.WriteColorLine(builder, ConsoleColor.Blue); + //StringBuilder builder = new StringBuilder(); + //builder.AppendLine(); + //builder.AppendLine($"銆恵commonStackerCrane.DeviceName}銆戝爢鍨涙満鐘舵�侊細銆恵commonStackerCrane.StackerCraneStatusDes}銆�,鏃堕棿锛氥�恵DateTime.Now}銆�"); + //builder.AppendLine($"銆恵commonStackerCrane.DeviceName}銆戞墜鑷姩鐘舵�侊細銆恵commonStackerCrane.StackerCraneAutoStatusDes}銆�,鏃堕棿锛氥�恵DateTime.Now}銆�"); + //builder.AppendLine($"銆恵commonStackerCrane.DeviceName}銆戜綔涓氱姸鎬侊細銆恵commonStackerCrane.StackerCraneWorkStatusDes}銆�,鏃堕棿锛氥�恵DateTime.Now}銆�"); + //builder.AppendLine($"銆恵commonStackerCrane.DeviceName}銆戜笅鍙戜换鍔℃垚鍔�,銆恵JsonConvert.SerializeObject(stackerCraneTaskCommand, Formatting.Indented)}銆�"); + //builder.AppendLine($"鏃堕棿锛氥�恵DateTime.Now}銆�"); + //builder.AppendLine(); + //ConsoleHelper.WriteColorLine(builder, ConsoleColor.Blue); commonStackerCrane.LastTaskType = task.TaskType; _taskService.UpdateTaskStatusToNext(task.TaskNum); } @@ -151,6 +148,47 @@ str = $"{commonStackerCrane.DeviceName}銆慦MS|WCS浠诲姟瀹屾垚锛氥�恵content.Status}銆�,鍫嗗灈鏈哄畬鎴愪俊鍙峰啓鍏ワ細銆恵isWorkType}銆�,浠诲姟鍙凤細銆恵e.TaskNum}銆戞椂闂淬�恵DateTime.Now}銆�"; WriteInfo(commonStackerCrane.DeviceName, str); ConsoleHelper.WriteColorLine(str, ConsoleColor.Blue); + + if (content.Status) + { + var task = content.Data as Dt_Task; + if (task.TaskType == (int)TaskOutboundTypeEnum.Outbound && task.TargetAddress == "001-000-001") + { + Dt_StationManager stationManager = _stationManagerRepository.QueryFirst(x => x.Roadway == task.Roadway && x.stationLocation == task.TargetAddress); + IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == stationManager.stationPLC); + if (device != null) + { + str = $"鍐欏叆瀹屾垚锛岀粰绾夸綋鍐欏叆涓嬮檷淇″彿"; + WriteInfo(commonStackerCrane.DeviceName, str); + ConsoleHelper.WriteColorLine(str, ConsoleColor.Blue); + + // 鑾峰彇杈撻�佺嚎瀵硅薄 + CommonConveyorLine_After conveyorLine = (CommonConveyorLine_After)device; + + // 鑾峰彇鍗忚鍦板潃 + var proAddress = conveyorLine.DeviceProDTOs + .FirstOrDefault(x => x.DeviceChildCode == stationManager.stationChildCode && x.DeviceProParamName == ConveyorLineDBName_After.InteractiveSignal.ToString()) + ?.DeviceProAddress; + + if (proAddress == null) + { + str = "鏈壘鍒板崗璁湴鍧�"; + WriteInfo(commonStackerCrane.DeviceName, str); + ConsoleHelper.WriteColorLine(str, ConsoleColor.Red); + return; + } + + string address = proAddress.Contains(".0") ? proAddress : proAddress + ".0"; + + // 鍐欏叆 false 淇″彿 + WriteSignal(conveyorLine, address, false, commonStackerCrane.DeviceName); + } + else + { + _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"鏈壘鍒板嚭搴撶珯鍙般�恵task.NextAddress}銆戝搴旂殑閫氳瀵硅薄锛屾棤娉曟竻闄ゅ嚭搴撶珯鍙伴《鍗囩姸鎬�"); + } + } + } } } } @@ -192,6 +230,27 @@ if (task != null && task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup) { + if (task.TaskType == (int)TaskOutboundTypeEnum.Outbound && task.TargetAddress == "001-000-001") + { + Dt_StationManager stationManager = _stationManagerRepository.QueryFirst(x => x.Roadway == task.Roadway && x.stationLocation == task.TargetAddress); + IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == stationManager.stationPLC); + if (device != null) + { + CommonConveyorLine_After conveyorLine = (CommonConveyorLine_After)device; + var proAddress = conveyorLine.DeviceProDTOs.Where(x => x.DeviceChildCode == stationManager.stationChildCode).Where(x => x.DeviceProParamName == ConveyorLineDBName_After.InteractiveSignal.ToString()).FirstOrDefault().DeviceProAddress; + string? str = proAddress; + if (!proAddress.Contains(".0")) + { + str = proAddress + ".0"; + } + conveyorLine.Communicator.Write(str, true); + } + else + { + _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"鏈壘鍒板嚭搴撶珯鍙般�恵task.NextAddress}銆戝搴旂殑閫氳瀵硅薄锛屾棤娉曞垽鏂嚭搴撶珯鍙版槸鍚﹁鍗犵敤"); + return null; + } + } // 妫�鏌ュ綋鍓嶅嚭搴撲换鍔$珯鍙版槸鍚﹀厑璁告斁璐� var occupiedStation = OutTaskStationIsOccupied(task); if (occupiedStation == null) @@ -321,5 +380,46 @@ return stackerCraneTaskCommand; } + + /// <summary> + /// 鍐欏叆淇″彿骞堕獙璇佸啓鍏ョ粨鏋� + /// </summary> + /// <param name="conveyorLine">杈撻�佺嚎瀵硅薄</param> + /// <param name="address">鍗忚鍦板潃</param> + /// <param name="signal">淇″彿鍊�</param> + /// <param name="deviceName">璁惧鍚嶇О</param> + void WriteSignal(CommonConveyorLine_After conveyorLine, string address, bool signal, string deviceName) + { + string str = string.Empty; + + // 鍐欏叆淇″彿 + conveyorLine.Communicator.Write(address, signal); + + // 楠岃瘉鍐欏叆缁撴灉锛屾渶澶氶噸璇�5娆� + for (int i = 0; i < 5; i++) + { + var isWrite = conveyorLine.Communicator.Read<bool>(address); + if (isWrite == signal) + { + break; + } + conveyorLine.Communicator.Write(address, signal); + } + + // 鏈�缁堥獙璇佸啓鍏ョ粨鏋� + var finalWrite = conveyorLine.Communicator.Read<bool>(address); + if (finalWrite == signal) + { + str = $"{address}-鍐欏叆{signal}鎴愬姛"; + ConsoleHelper.WriteColorLine(str, ConsoleColor.Blue); + WriteInfo(deviceName, str); + } + else + { + str = $"{address}-鍐欏叆{signal}澶辫触"; + ConsoleHelper.WriteColorLine(str, ConsoleColor.Red); + WriteInfo(deviceName, str); + } + } } } \ No newline at end of file -- Gitblit v1.9.3