From 0e674f770d785bfd24b5034456c2502dcc6671d2 Mon Sep 17 00:00:00 2001 From: huangxiaoqiang <huangxiaoqiang@hnkhzn.com> Date: 星期二, 17 六月 2025 16:56:50 +0800 Subject: [PATCH] 代码提交 --- 项目代码/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/CommonConveyorLineJob.cs | 211 ++++++++++++++-------------------------------------- 1 files changed, 56 insertions(+), 155 deletions(-) diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/CommonConveyorLineJob.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/CommonConveyorLineJob.cs" index dad3669..e967125 100644 --- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/CommonConveyorLineJob.cs" +++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/CommonConveyorLineJob.cs" @@ -15,9 +15,12 @@ *----------------------------------------------------------------*/ #endregion << 鐗� 鏈� 娉� 閲� >> +using AngleSharp.Dom; using Autofac.Core; using AutoMapper; using HslCommunication; +using Microsoft.CodeAnalysis.CSharp.Syntax; +using Newtonsoft.Json; using OfficeOpenXml.FormulaParsing.Excel.Functions.Text; using Quartz; using System.Reflection; @@ -113,8 +116,7 @@ #endregion 璋冪敤浜嬩欢鎬荤嚎閫氱煡鍓嶇 // 灏嗕氦浜掍俊鍙疯浆鎹负甯冨皵鏁扮粍 - var writeInteractiveSignal = command.InteractiveSignal; - var structs = BitConverter.GetBytes(writeInteractiveSignal).Reverse().ToArray().ToBoolArray(); + var structs = BitConverter.GetBytes(command.InteractiveSignal).Reverse().ToArray().ToBoolArray(); // 鑾峰彇璁惧鍗忚璇︽儏 List<DeviceProtocolDetailDTO>? deviceProtocolDetails = conveyorLine.DeviceProtocolDetailDTOs.Where(x => x.DeviceProParamName == nameof(ConveyorLineTaskCommand.InteractiveSignal)).ToList(); @@ -130,7 +132,7 @@ MethodInfo? method = GetType().GetMethod(item.ProtocolDetailType); if (method != null) { - method.Invoke(this, new object[] { conveyorLine, station.stationName }); + method.Invoke(this, new object[] { conveyorLine, station }); } } } @@ -149,107 +151,81 @@ /// <param name="conveyorLine">杈撻�佺嚎瀹炰緥瀵硅薄</param> /// <param name="command">璇诲彇鐨勮姹備俊鎭�</param>Request outbound /// <param name="childDeviceCode">瀛愯澶囩紪鍙�</param> - public async Task RequestInbound(CommonConveyorLine conveyorLine, string childDeviceCode) + public async Task RequestInbound(CommonConveyorLine conveyorLine, Dt_StationManager station) { try { // 杈撳嚭淇℃伅锛岃〃绀虹珯鍙拌姹傚彇璐� - var log = $"銆恵conveyorLine._deviceName}銆戠珯鍙般�恵childDeviceCode}銆戣姹傚彇璐�"; - ConsoleHelper.WriteWarningLine(log); - // 鎺ㄩ�侀�氱煡鍒板墠绔疭ignIR - await _noticeService.Logs(userTokenIds, new { conveyorLine.DeviceName, log = log, time = DateTime.Now.ToString("G"), color = "Red" }); - WriteInfo(conveyorLine.DeviceName, log); + var log = $"銆恵conveyorLine._deviceName}銆戠珯鍙般�恵station.stationName}銆戣姹傚彇璐�"; + await LogAndWarn(conveyorLine.DeviceName, log); // 鑾峰彇鎵�鏈変换鍔℃簮鍦板潃 - List<string> task = _taskService.QueryConveyorLineTaskSourceAddress(); + List<string> taskSourceAddress = _taskService.QueryConveyorLineTask(); + if (_taskService.QueryConveyorLineTask(station.stationName) != null) + { + ConveyorLineSendFinish(conveyorLine, station.stationName); + await LogAndWarn(conveyorLine.DeviceName, $"銆恵conveyorLine._deviceName}銆戠珯鍙般�恵station.stationName}銆戝瓨鍦ㄤ换鍔�"); + return; + } // 鏍规嵁璁惧缂栧彿鍜屼换鍔℃簮鍦板潃鏌ヨ鎵�鏈夋湭鎵ц鐨勪换鍔� - List<Dt_StationManager> childDeviceCodes = _stationManagerService.QuerypLatform(conveyorLine.DeviceCode, task); //瀵瑰簲姣忎釜ip鎵惧叏閮ㄧ殑涓嬫枡绔欑偣涓庡灚鏉垮洖鏀剁偣绔欏彴鐐� + List<Dt_StationManager> childDeviceCodes = _stationManagerService.QueryPlatform(station, taskSourceAddress); //瀵瑰簲姣忎釜ip鎵惧叏閮ㄧ殑涓嬫枡绔欑偣涓庡灚鏉垮洖鏀剁偣绔欏彴鐐� - + if(childDeviceCodes.Count()==0|| childDeviceCodes == null) + { + ConveyorLineSendFinish(conveyorLine, station.stationName); + await LogAndWarn(conveyorLine.DeviceName, $"銆恵conveyorLine._deviceName}銆戠珯鍙般�恵station.stationName}銆戞湭鎵惧埌鍙墠寰�绔欏彴"); + return; + } + foreach (var item in childDeviceCodes) { - ConveyorLineTaskCommand command = conveyorLine.ReadCustomer<ConveyorLineTaskCommand>(item.stationName); - if (command != null) + IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == item.DeviceCode); + if (device != null) { - var structs = BitConverter.GetBytes(command.InteractiveSignal).Reverse().ToArray().ToBoolArray(); - if (structs[1]) + CommonConveyorLine commonConveyorLine = (CommonConveyorLine)device; + ConveyorLineTaskCommand command = commonConveyorLine.ReadCustomer<ConveyorLineTaskCommand>(item.stationName); + if (command != null) { - if (item.stationMaterial == (int)AgvStationEnum.PadRecycle) - { - RequestHcdbst(conveyorLine, item.stationArea, item.stationName, item.stationRemark); - return; - } - else + var structs = BitConverter.GetBytes(command.InteractiveSignal).Reverse().ToArray().ToBoolArray(); + if (structs[2]) { Dt_Task taskDTO = new Dt_Task() { TaskNum = _taskRepository.GetTaskNo().Result, Grade = 1, Roadway = item.stationArea.ToString(), - SourceAddress = childDeviceCode, + SourceAddress = station.stationName, + CurrentAddress= station.stationName, TargetAddress = item.stationName, + NextAddress = item.stationName, TaskState = (int)AGVTaskStatusEnum.AGVNew, - TaskType = item.stationMaterial, + TaskType = (int)AGVTaskTypeEnum.AGVCarry, + AGVName = item.stationArea switch + { + 1 => "AGV01", + 4 => "AGV03", + _ => "AGV02", + } }; _taskService.ReceiveWMSTask(new List<Dt_Task> { taskDTO }); + ConveyorLineSendFinish(conveyorLine,station.stationName); return; } - } - else - { - WriteInfo(conveyorLine.DeviceName, $"绔欏彴{item.stationName}鐘舵�佷笉鍙敤{structs[2]}"); - } - } - else - { - WriteInfo(conveyorLine.DeviceName, $"閫氳杩炴帴閿欒锛寋item.stationName}鏈壘鍒拌鍙栨ā鍧楀湴鍧�"); - } - } - - } - catch (Exception ex) - { - WriteInfo(conveyorLine.DeviceName, ex.Message); - } - } - - /// <summary> - /// 鏍规嵁agv涓嬫枡浠诲姟锛屾妸鏂欐斁鑷充笂鏂欏彛鎴栫紦瀛樹綅 - /// </summary> - /// <param name="conveyorLine">杈撻�佺嚎瀹炰緥瀵硅薄</param> - /// <param name="childDeviceCode">瀛愯澶囩紪鍙�</param> - public void RequestOutbound(CommonConveyorLine conveyorLine, string childDeviceCode) - { - try - { - List<Dt_StationManager> station = _stationManagerService.QuerypLatformarer(conveyorLine.DeviceCode); - foreach (var item in station) - { - ConveyorLineTaskCommand command = conveyorLine.ReadCustomer<ConveyorLineTaskCommand>(item.stationName); - if (command != null) - { - var structs = BitConverter.GetBytes(command.InteractiveSignal).Reverse().ToArray().ToBoolArray(); - if (structs[2]) - { - if (item.stationMaterial == (int)AgvStationEnum.BoardLoad) + else { - //Dt_Task agvstack= _taskService.QueryConveyorLineTaskRoadway(AGVStationitem.stationArea); - //if(agvstack != null) - //{ - // _taskService.UpdateTargetAddress(agvstack.TaskId, AGVStationitem.stationName); - //} - //else - //{ - // //鍘绘壘缂撳瓨鍖哄簱瀛� - // RequestHcst(conveyorLine, AGVStationitem.stationArea, AGVStationitem.stationName, AGVStationitem.stationRemark); - //} + await LogAndWarn(conveyorLine.DeviceName, $"绔欏彴{item.stationName}鐘舵�佷笉鍙敤{structs[2]}"); } } else { - WriteInfo(conveyorLine.DeviceName, $"绔欏彴{item.stationName}鐘舵�佷笉鍙敤{structs[2]}"); + WriteInfo(conveyorLine.DeviceName, $"閫氳杩炴帴閿欒锛寋item.stationName}鏈壘鍒拌鍙栨ā鍧楀湴鍧�"); } + } + else + { + var logerror = $"銆恵conveyorLine.DeviceName}銆戠珯鍙帮細銆恵item.stationName}銆戞湭閰嶇疆璁惧琛ㄥご"; + await LogAndWarn(conveyorLine.DeviceName, logerror); } } } @@ -258,88 +234,6 @@ WriteInfo(conveyorLine.DeviceName, ex.Message); } } - - public void RequestHcst(CommonConveyorLine conveyorLine,int Station_Area,string Station_names,string Station_remark) - { - List<Dt_StationManager> AGVStationListdata = _stationManagerService.QuerypLatformmaterial(Station_Area); //鏌ュ嚭缂撳瓨浣� - if (Station_remark != null) //鎵惧瀵瑰簲鐨勬斁璐х珯鍙� - { - AGVStationListdata = _stationManagerService.QuerypStation_Area2(Station_remark); - } - foreach (var item in AGVStationListdata) - { - ConveyorLineTaskCommand command = conveyorLine.ReadCustomer<ConveyorLineTaskCommand>(item.stationName); - if (command != null) - { - var structs = BitConverter.GetBytes(command.InteractiveSignal).Reverse().ToArray().ToBoolArray(); - if (structs[1]) - { - if (_taskService.QueryConveyorLinetaeersuadd(item.stationName)) - { - Dt_Task taskDTO = new Dt_Task() - { - TaskNum = _taskRepository.GetTaskNo().Result, - Grade = 1, - Roadway = item.stationArea.ToString(), - SourceAddress = item.stationName, - CurrentAddress = item.stationName, - TaskState = (int)TaskInStatusEnum.InNew, - TaskType = (int)item.stationMaterial, - TargetAddress = Station_names, - NextAddress = Station_names, - }; - _taskService.ReceiveWMSTask(new List<Dt_Task> { taskDTO }); - } - } - else - { - WriteInfo(conveyorLine.DeviceName, $"閫氳杩炴帴閿欒锛寋item.stationName}鏈壘鍒拌鍙栨ā鍧楀湴鍧�"); - } - } - } - } - - public void RequestHcdbst(CommonConveyorLine conveyorLine, int Station_Area, string Station_names,string Station_remark) - { - List<Dt_StationManager> AGVStationListdata = _stationManagerService.QuerypStation_Area(Station_Area); //鏌ュ嚭缂撳瓨浣� - if(Station_remark !=null) //鎵惧瀵瑰簲鐨勬斁璐х珯鍙� - { - AGVStationListdata= _stationManagerService.QuerypStation_Area2(Station_remark); - } - - foreach (var item in AGVStationListdata) - { - ConveyorLineTaskCommand command = conveyorLine.ReadCustomer<ConveyorLineTaskCommand>(item.stationName); - if (command != null) - { - var structs = BitConverter.GetBytes(command.InteractiveSignal).Reverse().ToArray().ToBoolArray(); - if (structs[1]) - { - if (_taskService.QueryConveyorLinetaeersuadd(item.stationName)) - { - Dt_Task taskDTO = new Dt_Task() - { - TaskNum = _taskRepository.GetTaskNo().Result, - Grade = 1, - Roadway = item.stationArea.ToString(), - SourceAddress = Station_names, - CurrentAddress = Station_names, - TaskState = (int)TaskInStatusEnum.InNew, - TaskType = (int)item.stationMaterial, - TargetAddress = item.stationName, - NextAddress = item.stationName, - }; - _taskService.ReceiveWMSTask(new List<Dt_Task> { taskDTO }); - } - } - else - { - WriteInfo(conveyorLine.DeviceName, $"璇诲彇鏀捐揣淇″彿涓猴細{structs[2]}"); - } - } - } - } - /// <summary> /// 杈撻�佺嚎浜や簰瀹屾垚 /// </summary> @@ -353,5 +247,12 @@ conveyorLine.Communicator.Write(devicePro.DeviceProAddress, true); } + + public async Task LogAndWarn(string deviceName, string log, string color = "red") + { + ConsoleHelper.WriteWarningLine(log); + await _noticeService.Logs(userTokenIds, new { deviceName, log = log, time = DateTime.Now.ToString("G"), color = color }); + WriteInfo(deviceName, log); + } } } -- Gitblit v1.9.3