From 8fdc52a8c81a422d97f421ec133b0d2f2340bfd1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=83=AD=E7=9D=BF?= <774114798@qq.com> Date: Thu, 12 Dec 2024 17:18:43 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A3=85=E7=BD=AE=E7=89=88=E6=9C=AC=E5=8E=86?= =?UTF-8?q?=E5=8F=B2=E8=AE=B0=E5=BD=95=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BoardCardInfoAppService.cs | 57 +++++++++++++++++ .../IProtectionDeviceAppService.cs | 7 ++- .../ProtectionDeviceAppService.cs | 63 +++++++++++++++++++ .../BoardCardSolftVersionOutput.cs | 40 ++++++++++++ .../ProtectionDeviceSolfVersionOutput.cs | 24 +++++++ .../ProtectionDeviceDataCenter.cs | 6 +- .../ProtectionDeviceRunInfoHandle.cs | 12 +++- 7 files changed, 203 insertions(+), 6 deletions(-) create mode 100644 src/YunDa.Application/YunDa.ISAS.DataTransferObject/GeneralInformation/ProtectionDeviceInfoDto/HistoryData/BoardCardSolftVersionOutput.cs create mode 100644 src/YunDa.Application/YunDa.ISAS.DataTransferObject/GeneralInformation/ProtectionDeviceInfoDto/HistoryData/ProtectionDeviceSolfVersionOutput.cs diff --git a/src/YunDa.Application/YunDa.ISAS.Application/GeneralInformation/ProtectionDevice/BoardCardDevice/BoardCardInfoAppService.cs b/src/YunDa.Application/YunDa.ISAS.Application/GeneralInformation/ProtectionDevice/BoardCardDevice/BoardCardInfoAppService.cs index ea7280a..c666256 100644 --- a/src/YunDa.Application/YunDa.ISAS.Application/GeneralInformation/ProtectionDevice/BoardCardDevice/BoardCardInfoAppService.cs +++ b/src/YunDa.Application/YunDa.ISAS.Application/GeneralInformation/ProtectionDevice/BoardCardDevice/BoardCardInfoAppService.cs @@ -528,7 +528,64 @@ namespace YunDa.ISAS.Application.GeneralInformation return rst; } + /// + /// 查询板卡历史版本数据 + /// + /// + /// + [ShowApi] + [AbpAllowAnonymous] + [DisableAuditing] + [HttpGet] + public RequestResult> FindHistorySoftVersionByEquipmentInfoId(Guid? equipmentInfoId) + { + RequestResult> rst = (); + try + { + List historys = new List(); + var protectionDevice = _protectionDeviceInfoRepository.GetAllIncluding(t => t.EquipmentInfo) + .FirstOrDefault(t => t.EquipmentInfoId == equipmentInfoId); + if (protectionDevice != null) + { + var boards = _boardCardHistoryRepository.GetAll() + .Where(t => t.ProtectionDeviceInfoId == protectionDevice.Id) + .OrderByDescending(t => t.RecodeDate); + foreach ( var board in boards) + { + BoardCardSolftVersionOutput boardCardSolftVersionOutput = new BoardCardSolftVersionOutput(); + if (string.IsNullOrEmpty( board.ContentNewJson)) + { + if (!string.IsNullOrEmpty(board.ContentJson)) + { + boardCardSolftVersionOutput = JsonConvert.DeserializeObject(board.ContentJson); + boardCardSolftVersionOutput.RecodeDate = board.RecodeDate; + } + } + else + { + boardCardSolftVersionOutput = JsonConvert.DeserializeObject(board.ContentNewJson); + boardCardSolftVersionOutput.RecodeDate = board.RecodeDate; + } + if (boardCardSolftVersionOutput.RecodeDate.HasValue) + { + historys.Add(boardCardSolftVersionOutput); + } + } + rst.Flag = true; + rst.ResultData = historys; + rst.TotalCount = historys.Count; + } + } + catch (Exception ex) + { + rst.Message = ex.Message; + rst.Flag = false; + Log4Helper.Error(this.GetType(), "保护装置信息管理服务", ex); + } + + return rst; + } public RequestResult GetProtectionDeviceQRcode(Guid id) { RequestResult rst = new RequestResult(); diff --git a/src/YunDa.Application/YunDa.ISAS.Application/GeneralInformation/ProtectionDevice/IProtectionDeviceAppService.cs b/src/YunDa.Application/YunDa.ISAS.Application/GeneralInformation/ProtectionDevice/IProtectionDeviceAppService.cs index a482b08..5ae3aca 100644 --- a/src/YunDa.Application/YunDa.ISAS.Application/GeneralInformation/ProtectionDevice/IProtectionDeviceAppService.cs +++ b/src/YunDa.Application/YunDa.ISAS.Application/GeneralInformation/ProtectionDevice/IProtectionDeviceAppService.cs @@ -24,7 +24,12 @@ namespace YunDa.ISAS.Application.GeneralInformation /// /// RequestResult> FindHistoryDataByEquipmentInfoId(Guid? equipmentInfoId); - + /// + /// 查询历史保护装置版本信息 + /// + /// + /// + RequestResult> FindHistorySoftVersionDataByEquipmentInfoId(Guid? equipmentInfoId); /// /// 获取所有保护装置 /// diff --git a/src/YunDa.Application/YunDa.ISAS.Application/GeneralInformation/ProtectionDevice/ProtectionDeviceAppService.cs b/src/YunDa.Application/YunDa.ISAS.Application/GeneralInformation/ProtectionDevice/ProtectionDeviceAppService.cs index 692405b..2083683 100644 --- a/src/YunDa.Application/YunDa.ISAS.Application/GeneralInformation/ProtectionDevice/ProtectionDeviceAppService.cs +++ b/src/YunDa.Application/YunDa.ISAS.Application/GeneralInformation/ProtectionDevice/ProtectionDeviceAppService.cs @@ -597,6 +597,69 @@ namespace YunDa.ISAS.Application.GeneralInformation return rst; } + /// + /// 查询保护装置历史版本信息 + /// + /// + /// + [ShowApi] + [AbpAllowAnonymous] + [DisableAuditing] + [HttpGet] + public RequestResult> FindHistorySoftVersionDataByEquipmentInfoId(Guid? equipmentInfoId) + { + RequestResult> rst = new(); + try + { + List historys = new List(); + var protectionDevice = _protectionDeviceInfoRepository.GetAllIncluding(t => t.EquipmentInfo) + .FirstOrDefault(t => t.EquipmentInfoId == equipmentInfoId); + if (protectionDevice != null) + { + var entitys = _protectionDeviceHistoryRepository.GetAll() + .Where(t => t.ProtectionDeviceInfoId == protectionDevice.Id) + .OrderBy(t => t.RecodeDate) + ; + foreach ( var entity in entitys ) + { + ProtectionDeviceSolfVersionOutput protectionDeviceSolfVersionOutput = new(); + if (string.IsNullOrWhiteSpace(entity.ContentNewJson)) + { + if (!string.IsNullOrWhiteSpace(entity.ContentJson)) + { + ProtectionDeviceInfo history = JsonConvert.DeserializeObject(entity.ContentJson); + protectionDeviceSolfVersionOutput.BaselineBoardVersion = history.BaselineBoardVersion; + protectionDeviceSolfVersionOutput.HardwareVersion = history.HardwareVersion; + protectionDeviceSolfVersionOutput.RecodeDate = entity.RecodeDate; + } + } + else + { + ProtectionDeviceInfo history = JsonConvert.DeserializeObject(entity.ContentNewJson); + protectionDeviceSolfVersionOutput.BaselineBoardVersion = history.BaselineBoardVersion; + protectionDeviceSolfVersionOutput.HardwareVersion = history.HardwareVersion; + protectionDeviceSolfVersionOutput.RecodeDate = entity.RecodeDate; + } + if (!string.IsNullOrWhiteSpace( protectionDeviceSolfVersionOutput.BaselineBoardVersion)) + { + historys.Add(protectionDeviceSolfVersionOutput); + } + } + rst.Flag = true; + rst.ResultData = historys; + } + } + catch (Exception ex) + { + rst.Message = ex.Message; + rst.Flag = false; + Log4Helper.Error(this.GetType(), "保护装置信息管理服务", ex); + } + + return rst; + } + + public RequestResult GetProtectionDeviceQRcode(Guid id) { RequestResult rst = new RequestResult(); diff --git a/src/YunDa.Application/YunDa.ISAS.DataTransferObject/GeneralInformation/ProtectionDeviceInfoDto/HistoryData/BoardCardSolftVersionOutput.cs b/src/YunDa.Application/YunDa.ISAS.DataTransferObject/GeneralInformation/ProtectionDeviceInfoDto/HistoryData/BoardCardSolftVersionOutput.cs new file mode 100644 index 0000000..405ffa3 --- /dev/null +++ b/src/YunDa.Application/YunDa.ISAS.DataTransferObject/GeneralInformation/ProtectionDeviceInfoDto/HistoryData/BoardCardSolftVersionOutput.cs @@ -0,0 +1,40 @@ +using Abp.AutoMapper; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using YunDa.SOMS.Entities.GeneralInformation; + +namespace YunDa.SOMS.DataTransferObject.GeneralInformation.ProtectionDeviceInfoDto.HistoryData +{ + [AutoMapFrom(typeof(BoardCardInfo))] + public class BoardCardSolftVersionOutput + { + /// + /// 记录时间 + /// + public virtual DateTime? RecodeDate { get; set; } + public string HardwareVersion { get; set; } // 硬件版本 + + public string InterfaceVersion { get; set; } // 接口程序版本 + + public string InterfaceChecksum { get; set; } // 接口程序校验码 + + public string DatabaseVersion { get; set; } // 数据库版本 + + public string ProtectionVersion { get; set; } // 保护程序版本 + + public string ProtectionChecksum { get; set; } // 保护程序校验码 + + public string BootVersion { get; set; } // BOOT 版本 + + public string Iec61850Version { get; set; } // IEC 61850 版本 + + public string FpgaVersion { get; set; } // FPGA 版本 + + public string CidChecksum { get; set; } // CID 校验码 + + public string CcdChecksum { get; set; } // CCD 校验码 + } +} diff --git a/src/YunDa.Application/YunDa.ISAS.DataTransferObject/GeneralInformation/ProtectionDeviceInfoDto/HistoryData/ProtectionDeviceSolfVersionOutput.cs b/src/YunDa.Application/YunDa.ISAS.DataTransferObject/GeneralInformation/ProtectionDeviceInfoDto/HistoryData/ProtectionDeviceSolfVersionOutput.cs new file mode 100644 index 0000000..e018164 --- /dev/null +++ b/src/YunDa.Application/YunDa.ISAS.DataTransferObject/GeneralInformation/ProtectionDeviceInfoDto/HistoryData/ProtectionDeviceSolfVersionOutput.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace YunDa.SOMS.DataTransferObject.GeneralInformation.ProtectionDeviceInfoDto.HistoryData +{ + public class ProtectionDeviceSolfVersionOutput + { + /// + /// 记录时间 + /// + public virtual DateTime? RecodeDate { get; set; } + /// + /// 基线版本 + /// + public virtual string BaselineBoardVersion { get; set; } + /// + /// 硬件版本 + /// + public virtual string HardwareVersion { get; set; } + } +} diff --git a/src/YunDa.Server/Yunda.ISAS.DataMonitoringServer/ProtectionDeviceHandle/ProtectionDeviceDataCenter.cs b/src/YunDa.Server/Yunda.ISAS.DataMonitoringServer/ProtectionDeviceHandle/ProtectionDeviceDataCenter.cs index 3247484..59c050d 100644 --- a/src/YunDa.Server/Yunda.ISAS.DataMonitoringServer/ProtectionDeviceHandle/ProtectionDeviceDataCenter.cs +++ b/src/YunDa.Server/Yunda.ISAS.DataMonitoringServer/ProtectionDeviceHandle/ProtectionDeviceDataCenter.cs @@ -97,6 +97,7 @@ namespace Yunda.SOMS.DataMonitoringServer.ProtectionDeviceHandle MonitoringEventBus.LogHandler($"装置地址:{device.DeviceAddr},ip:{device.GatewayIP1} 启动成功", "装置定值"); _processes.Add(process); } + device.IsOnline = true; } else if(IsDeviceOnline(device.GatewayIP2)) @@ -112,13 +113,14 @@ namespace Yunda.SOMS.DataMonitoringServer.ProtectionDeviceHandle MonitoringEventBus.LogHandler($"装置地址:{device.DeviceAddr},ip:{device.GatewayIP2} 启动成功", "装置定值"); _processes.Add(process); } + device.IsOnline = true; + } else { device.IsOnline = false; MonitoringEventBus.LogHandler($"装置地址:{device.DeviceAddr},ip1:{device.GatewayIP1},ip2:{device.GatewayIP2} {(online ? "在线" : "离线")}", "装置状态"); } - device.IsOnline = true; } catch (Exception ex) @@ -180,7 +182,7 @@ namespace Yunda.SOMS.DataMonitoringServer.ProtectionDeviceHandle { try { - if (ipAddress == "127.0.0.1"|| ipAddress == "localhost") + if (ipAddress == "127.0.0.1"|| ipAddress == "localhost" || string.IsNullOrWhiteSpace(ipAddress)) { return false; } diff --git a/src/YunDa.Server/Yunda.ISAS.DataMonitoringServer/ProtectionDeviceHandle/ProtectionDeviceRunInfoHandle.cs b/src/YunDa.Server/Yunda.ISAS.DataMonitoringServer/ProtectionDeviceHandle/ProtectionDeviceRunInfoHandle.cs index 3662931..dd13bb1 100644 --- a/src/YunDa.Server/Yunda.ISAS.DataMonitoringServer/ProtectionDeviceHandle/ProtectionDeviceRunInfoHandle.cs +++ b/src/YunDa.Server/Yunda.ISAS.DataMonitoringServer/ProtectionDeviceHandle/ProtectionDeviceRunInfoHandle.cs @@ -89,12 +89,13 @@ namespace Yunda.SOMS.DataMonitoringServer.ProtectionDeviceHandle device.LastComTime = DateTime.Now; if (!device.IsOnline) { + device.IsOnline = true; await _protectionDeviceCommInfoRedis.HashSetUpdateOneAsync(protectionDeviceCommInfoRedisKey, device.DeviceAddr.ToString(), device); - await _protectionDeviceCommInfoRedis.PublishAsync(protectionDeviceCommInfoRedisChannel, device); } - device.IsOnline = true; + await _protectionDeviceCommInfoRedis.PublishAsync(protectionDeviceCommInfoRedisChannel, device); + } - + _commCount++; if (_commCount == 10) { @@ -110,6 +111,11 @@ namespace Yunda.SOMS.DataMonitoringServer.ProtectionDeviceHandle await _protectionDeviceCommInfoRedis.HashSetUpdateOneAsync(protectionDeviceCommInfoRedisKey, item.DeviceAddr.ToString(), item); await _protectionDeviceCommInfoRedis.PublishAsync(protectionDeviceCommInfoRedisChannel, item); } +//#if DEBUG + +// item.IsOnline = true; +// await _protectionDeviceCommInfoRedis.PublishAsync(protectionDeviceCommInfoRedisChannel, item); +//#endif } } catch (Exception ex)