From 17ebb89cedba6f039f978447110f1189c9d41039 Mon Sep 17 00:00:00 2001 From: CZ Date: Thu, 27 Jun 2024 16:04:03 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=85=E7=94=B5=E6=9C=BA=E6=95=85=E9=9A=9C?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E4=BF=9D=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Entity/DbModel/Station/EquipAlarmDefine.cs | 72 +++++++++ .../Station/EquipAlarmProcessRecord.cs | 86 ++++++++++ Entity/DbModel/Station/EquipAlarmRecord.cs | 80 ++++++++++ .../Station/EquipAlarmDefineRepository.cs | 13 ++ .../EquipAlarmProcessRecordRepository.cs | 13 ++ .../Station/EquipAlarmRecordRepository.cs | 13 ++ .../Handler/UploadRemoteSignalDataHandler.cs | 149 +++++++++++++++++- 7 files changed, 424 insertions(+), 2 deletions(-) create mode 100644 Entity/DbModel/Station/EquipAlarmDefine.cs create mode 100644 Entity/DbModel/Station/EquipAlarmProcessRecord.cs create mode 100644 Entity/DbModel/Station/EquipAlarmRecord.cs create mode 100644 Repository/Station/EquipAlarmDefineRepository.cs create mode 100644 Repository/Station/EquipAlarmProcessRecordRepository.cs create mode 100644 Repository/Station/EquipAlarmRecordRepository.cs diff --git a/Entity/DbModel/Station/EquipAlarmDefine.cs b/Entity/DbModel/Station/EquipAlarmDefine.cs new file mode 100644 index 0000000..95b84d4 --- /dev/null +++ b/Entity/DbModel/Station/EquipAlarmDefine.cs @@ -0,0 +1,72 @@ +using SqlSugar; + +namespace Entity.DbModel.Station; + +/// +///设备报警记录 +/// +[SugarTable("equip_alarm_define")] +public partial class EquipAlarmDefine : BaseModel +{ + public EquipAlarmDefine() + { + } + + /// + /// Desc:id + /// Default: + /// Nullable:False + /// + [SugarColumn(IsPrimaryKey = true, IsIdentity = true, ColumnName = "id")] + public int Id { get; set; } + + /// + /// Desc:设备类型编码 + /// Default: + /// Nullable:True + /// + [SugarColumn(ColumnName = "equip_type_code")] + public int EquipTypeCode { get; set; } + + /// + /// Desc:设备编码 + /// Default: + /// Nullable:True + /// + [SugarColumn(ColumnName = "equip_code")] + public string EquipCode { get; set; } + + /// + /// Desc:报警编码 + /// Default: + /// Nullable:True + /// + [SugarColumn(ColumnName = "error_code")] + public string ErrorCode { get; set; } + + /// + /// Desc:报警等级 + /// Default: + /// Nullable:True + /// + [SugarColumn(ColumnName = "error_level")] + public string ErrorLevel { get; set; } + + /// + /// Desc:报警描述 + /// Default: + /// Nullable:True + /// + [SugarColumn(ColumnName = "error_msg")] + public string ErrorMsg { get; set; } + + /// + /// Desc:处理方法 + /// Default: + /// Nullable:True + /// + [SugarColumn(ColumnName = "process_method")] + public string ProcessMethod { get; set; } + + +} \ No newline at end of file diff --git a/Entity/DbModel/Station/EquipAlarmProcessRecord.cs b/Entity/DbModel/Station/EquipAlarmProcessRecord.cs new file mode 100644 index 0000000..9e00eb0 --- /dev/null +++ b/Entity/DbModel/Station/EquipAlarmProcessRecord.cs @@ -0,0 +1,86 @@ +using SqlSugar; + +namespace Entity.DbModel.Station; + +/// + ///设备报警处理记录 + /// + [SugarTable("equip_alarm_process_record")] + public partial class EquipAlarmProcessRecord : BaseModel + { + public EquipAlarmProcessRecord() + { + } + + /// + /// Desc:id + /// Default: + /// Nullable:False + /// + [SugarColumn(ColumnName = "id")] + public int Id { get; set; } + + /// + /// Desc:设备类型编码 + /// Default: + /// Nullable:True + /// + [SugarColumn(ColumnName = "equip_type_code")] + public int EquipTypeCode { get; set; } + + /// + /// Desc:设备编码 + /// Default: + /// Nullable:True + /// + [SugarColumn(ColumnName = "equip_code")] + public string EquipCode { get; set; } + + /// + /// Desc:报警编码 + /// Default: + /// Nullable:True + /// + [SugarColumn(ColumnName = "error_code")] + public string ErrorCode { get; set; } + + /// + /// Desc:报警等级 + /// Default: + /// Nullable:True + /// + [SugarColumn(ColumnName = "error_level")] + public string ErrorLevel { get; set; } + + /// + /// Desc:报警描述 + /// Default: + /// Nullable:True + /// + [SugarColumn(ColumnName = "error_msg")] + public string ErrorMsg { get; set; } + + /// + /// Desc:处理方法 + /// Default: + /// Nullable:True + /// + [SugarColumn(ColumnName = "process_method")] + public string ProcessMethod { get; set; } + /// + /// Desc:开始时间 + /// Default: + /// Nullable:True + /// + [SugarColumn(ColumnName = "start_time")] + public DateTime? StartTime { get; set; } + /// + /// Desc:处理时间 + /// Default: + /// Nullable:True + /// + [SugarColumn(ColumnName = "process_time")] + public DateTime? ProcessTime { get; set; } + + + } \ No newline at end of file diff --git a/Entity/DbModel/Station/EquipAlarmRecord.cs b/Entity/DbModel/Station/EquipAlarmRecord.cs new file mode 100644 index 0000000..75e8fa8 --- /dev/null +++ b/Entity/DbModel/Station/EquipAlarmRecord.cs @@ -0,0 +1,80 @@ +using SqlSugar; + +namespace Entity.DbModel.Station; + +/// +///设备报警记录 +/// +[SugarTable("equip_alarm_record")] +public partial class EquipAlarmRecord : BaseModel +{ + public EquipAlarmRecord() + { + } + + /// + /// Desc:id + /// Default: + /// Nullable:False + /// + [SugarColumn(IsPrimaryKey = true, IsIdentity = true, ColumnName = "id")] + public int Id { get; set; } + + /// + /// Desc:设备类型编码 + /// Default: + /// Nullable:True + /// + [SugarColumn(ColumnName = "equip_type_code")] + public int EquipTypeCode { get; set; } + + /// + /// Desc:设备编码 + /// Default: + /// Nullable:True + /// + [SugarColumn(ColumnName = "equip_code")] + public string EquipCode { get; set; } + + /// + /// Desc:报警编码 + /// Default: + /// Nullable:True + /// + [SugarColumn(ColumnName = "error_code")] + public string ErrorCode { get; set; } + + /// + /// Desc:报警等级 + /// Default: + /// Nullable:True + /// + [SugarColumn(ColumnName = "error_level")] + public string ErrorLevel { get; set; } + + /// + /// Desc:报警描述 + /// Default: + /// Nullable:True + /// + [SugarColumn(ColumnName = "error_msg")] + public string ErrorMsg { get; set; } + + /// + /// Desc:处理方法 + /// Default: + /// Nullable:True + /// + [SugarColumn(ColumnName = "process_method")] + public string ProcessMethod { get; set; } + + /// + /// Desc:开始时间 + /// Default: + /// Nullable:True + /// + [SugarColumn(ColumnName = "start_time")] + public DateTime? StartTime { get; set; } + + +} \ No newline at end of file diff --git a/Repository/Station/EquipAlarmDefineRepository.cs b/Repository/Station/EquipAlarmDefineRepository.cs new file mode 100644 index 0000000..8e4f2b3 --- /dev/null +++ b/Repository/Station/EquipAlarmDefineRepository.cs @@ -0,0 +1,13 @@ +using Entity.DbModel.Station; +using HybirdFrameworkCore.Autofac.Attribute; +using SqlSugar; + +namespace Repository.Station; + +[Scope] +public class EquipAlarmDefineRepository : BaseRepository +{ + public EquipAlarmDefineRepository(ISqlSugarClient sqlSugar) : base(sqlSugar) + { + } +} \ No newline at end of file diff --git a/Repository/Station/EquipAlarmProcessRecordRepository.cs b/Repository/Station/EquipAlarmProcessRecordRepository.cs new file mode 100644 index 0000000..8cd9b8f --- /dev/null +++ b/Repository/Station/EquipAlarmProcessRecordRepository.cs @@ -0,0 +1,13 @@ +using Entity.DbModel.Station; +using HybirdFrameworkCore.Autofac.Attribute; +using SqlSugar; + +namespace Repository.Station; + +[Scope] +public class EquipAlarmProcessRecordRepository : BaseRepository +{ + public EquipAlarmProcessRecordRepository(ISqlSugarClient sqlSugar) : base(sqlSugar) + { + } +} \ No newline at end of file diff --git a/Repository/Station/EquipAlarmRecordRepository.cs b/Repository/Station/EquipAlarmRecordRepository.cs new file mode 100644 index 0000000..40a71f6 --- /dev/null +++ b/Repository/Station/EquipAlarmRecordRepository.cs @@ -0,0 +1,13 @@ +using Entity.DbModel.Station; +using HybirdFrameworkCore.Autofac.Attribute; +using SqlSugar; + +namespace Repository.Station; + +[Scope] +public class EquipAlarmRecordRepository : BaseRepository +{ + public EquipAlarmRecordRepository(ISqlSugarClient sqlSugar) : base(sqlSugar) + { + } +} \ No newline at end of file diff --git a/Service/Charger/Handler/UploadRemoteSignalDataHandler.cs b/Service/Charger/Handler/UploadRemoteSignalDataHandler.cs index b2277ce..2120ddb 100644 --- a/Service/Charger/Handler/UploadRemoteSignalDataHandler.cs +++ b/Service/Charger/Handler/UploadRemoteSignalDataHandler.cs @@ -10,6 +10,9 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using Common.Const; +using Entity.DbModel.Station; +using Repository; using Repository.Station; namespace Service.Charger.Handler @@ -24,10 +27,18 @@ namespace Service.Charger.Handler { private static readonly ILog Log = LogManager.GetLogger(typeof(UploadRemoteSignalDataHandler)); private BinInfoRepository BinInfoRepository { get; set; } - - public UploadRemoteSignalDataHandler(BinInfoRepository _binInfoRepository) + private EquipAlarmRecordRepository EquipAlarmRecordRepository { get; set; } + private EquipAlarmProcessRecordRepository EquipAlarmProcessRecordRepository { get; set; } + private EquipAlarmDefineRepository EquipAlarmDefineRepository { get; set; } + public UploadRemoteSignalDataHandler(BinInfoRepository _binInfoRepository, + EquipAlarmRecordRepository _EquipAlarmRecordRepository, + EquipAlarmProcessRecordRepository _EquipAlarmProcessRecordRepository, + EquipAlarmDefineRepository _EquipAlarmDefineRepository) { BinInfoRepository = _binInfoRepository; + EquipAlarmRecordRepository = _EquipAlarmRecordRepository; + EquipAlarmProcessRecordRepository = _EquipAlarmProcessRecordRepository; + EquipAlarmDefineRepository = _EquipAlarmDefineRepository; } protected override void ChannelRead0(IChannelHandlerContext ctx, UploadRemoteSignalData msg) @@ -50,6 +61,140 @@ namespace Service.Charger.Handler { BinInfoRepository.Update(i => i.ChargeStatus == 4, i => i.ChargerNo == sn); } + + #region 充电机故障显示 +//不准确,注释 +//if(sn=="C2008") + //if (msg.TotalWarning||msg.TotalError) + { + var lstEquipAlarmDefine = EquipAlarmDefineRepository.QueryListByClause(i => i.EquipCode == "充电机"); + + List lstAlarm = new List(); + + if (msg.EmergencyStop)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="1").ToList()[0].ErrorCode); + if (msg.SmokeFault)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="2").ToList()[0].ErrorCode); + if (msg.ChargeACInputCircuitBreakerFault)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="3").ToList()[0].ErrorCode); + if (msg.DcBusPositElecContactorRefuFault)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="4").ToList()[0].ErrorCode); + if (msg.DcBusNegatElecContactorRefuFault)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="5").ToList()[0].ErrorCode); + if (msg.DcBusPositElecFusesFault)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="6").ToList()[0].ErrorCode); + if (msg.DDcBusNegatElecFusesFault)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="7").ToList()[0].ErrorCode); + if (msg.ChargingInterfaceLockError)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="8").ToList()[0].ErrorCode); + if (msg.ChargerFanError)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="9").ToList()[0].ErrorCode); + if (msg.ArresterError)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="10").ToList()[0].ErrorCode); + if (msg.InsulationDetectionAlarm)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="11").ToList()[0].ErrorCode); + if (msg.InsulationDetectionError)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="12").ToList()[0].ErrorCode); + if (msg.BatteryPolarityReverseError)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="13").ToList()[0].ErrorCode); + if (msg.VeConGuidanceFailure)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="14").ToList()[0].ErrorCode); + if (msg.ChargingOverTempError)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="15").ToList()[0].ErrorCode); + if (msg.InterfaceOverFaulty)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="16").ToList()[0].ErrorCode); + if (msg.ChargingGunNotHomingError)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="17").ToList()[0].ErrorCode); + if (msg.BmsConnError)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="18").ToList()[0].ErrorCode); + if (msg.ChargerInputOverVoltageError)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="19").ToList()[0].ErrorCode); + if (msg.ChargerInputUnderVoltageError)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="20").ToList()[0].ErrorCode); + if (msg.DcBusOutputOverVoltageError)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="21").ToList()[0].ErrorCode); + if (msg.DcBusOutputUnderVoltageError)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="22").ToList()[0].ErrorCode); + if (msg.DcBusOutputOverCurrentError)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="23").ToList()[0].ErrorCode); + if (msg.VehicleConnStatus)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="24").ToList()[0].ErrorCode); + if (msg.ChargeStationGunHolderStatus)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="25").ToList()[0].ErrorCode); + if (msg.ChargingInterfaceLockStatus)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="26").ToList()[0].ErrorCode); + if (msg.PositiveDcTransmissionContactorStatus)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="27").ToList()[0].ErrorCode); + if (msg.NegativeDcTransmissionContactorStatus)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="28").ToList()[0].ErrorCode); + if (msg.EntranceGuardError)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="29").ToList()[0].ErrorCode); + if (msg.PConA3dhesionFailure)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="30").ToList()[0].ErrorCode); + if (msg.NConadhesionFailure)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="31").ToList()[0].ErrorCode); + if (msg.ReliefCircuitError)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="32").ToList()[0].ErrorCode); + if (msg.ConActivated)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="33").ToList()[0].ErrorCode); + if (msg.ConAdhesionFailure)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="34").ToList()[0].ErrorCode); + if (msg.AuxiliaryPowerError)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="35").ToList()[0].ErrorCode); + if (msg.ModuleOutputReverseError)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="36").ToList()[0].ErrorCode); + if (msg.AcContactorStatus)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="37").ToList()[0].ErrorCode); + if (msg.ChargingGunOverTempWarning)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="38").ToList()[0].ErrorCode); + if (msg.ChargerOverTempWarning)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="39").ToList()[0].ErrorCode); + if (msg.MeterConnError)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="40").ToList()[0].ErrorCode); + if (msg.MeterDataError)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="41").ToList()[0].ErrorCode); + if (msg.WaterloggingWarning)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="42").ToList()[0].ErrorCode); + if (msg.ReversePowerWarning)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="43").ToList()[0].ErrorCode); + if (msg.BatteryPackAuxiliaryPowerStatus)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="44").ToList()[0].ErrorCode); + + + //查询当前充电机的实时报警信息 + var lstNowEquipAlarmRecord = EquipAlarmRecordRepository.QueryListByClause(i => i.EquipCode == sn); + var sqllstAlarm=lstNowEquipAlarmRecord.Select(obj => obj.ErrorCode).ToList();//当前报警列表 + + // 找出实时报警中存在但数据库中不存在的元素 + List uniqueToList1 = lstAlarm.Except(sqllstAlarm).ToList(); + + // 找出数据库中存在但实时报警中不存在的元素 + List uniqueToList2 = sqllstAlarm.Except(lstAlarm).ToList(); + if (uniqueToList1.Count > 0) + {//这里要添加新的报警数据 + foreach (var errorCode in uniqueToList1) + { + EquipAlarmDefine? alarmDefine = EquipAlarmDefineRepository.QueryByClause(i=>i.ErrorCode==errorCode.Replace(sn,"")); + if (alarmDefine != null) + { + EquipAlarmRecord record = new EquipAlarmRecord() + { + EquipTypeCode = alarmDefine.EquipTypeCode, + EquipCode = sn, + ErrorCode = errorCode, + ErrorLevel = alarmDefine.ErrorLevel, + ErrorMsg = alarmDefine.ErrorMsg, + ProcessMethod = alarmDefine.ProcessMethod, + StartTime= DateTime.Now + }; + EquipAlarmRecordRepository.Insert(record); + } + } + } + else if (uniqueToList2.Count > 0) + { + //这些是要清除实时报警,并且处理记录的。 + // 使用LINQ找出ErrorCode在uniqueToList2中的EquipAlarmRecord对象 + List filteredObjectList = lstNowEquipAlarmRecord + .Where(obj => uniqueToList2.Contains(obj.ErrorCode)) + .ToList(); + foreach (var VARIABLE in filteredObjectList) + { + EquipAlarmProcessRecord EquipAlarmProcessRecord = new EquipAlarmProcessRecord(); + EquipAlarmProcessRecord.EquipTypeCode = VARIABLE.EquipTypeCode; + EquipAlarmProcessRecord.EquipCode = VARIABLE.EquipCode; + EquipAlarmProcessRecord.ErrorCode = VARIABLE.ErrorCode; + EquipAlarmProcessRecord.ErrorLevel = VARIABLE.ErrorLevel; + EquipAlarmProcessRecord.ErrorMsg = VARIABLE.ErrorMsg; + EquipAlarmProcessRecord.ProcessMethod = VARIABLE.ProcessMethod; + EquipAlarmProcessRecord.StartTime = VARIABLE.StartTime; + EquipAlarmProcessRecord.ProcessTime=DateTime.Now; + + EquipAlarmProcessRecordRepository.Insert(EquipAlarmProcessRecord); + } + EquipAlarmRecordRepository.Delete(filteredObjectList); + } + } + //else + //{ + /*var lstNowEquipAlarmRecord = EquipAlarmRecordRepository.QueryListByClause(i => i.EquipCode == sn); + if (lstNowEquipAlarmRecord.Count > 0) + { + foreach (var VARIABLE in lstNowEquipAlarmRecord) + { + EquipAlarmProcessRecord EquipAlarmProcessRecord = new EquipAlarmProcessRecord(); + EquipAlarmProcessRecord.EquipTypeCode = VARIABLE.EquipTypeCode; + EquipAlarmProcessRecord.EquipCode = VARIABLE.EquipCode; + EquipAlarmProcessRecord.ErrorCode = VARIABLE.ErrorCode; + EquipAlarmProcessRecord.ErrorLevel = VARIABLE.ErrorLevel; + EquipAlarmProcessRecord.ErrorMsg = VARIABLE.ErrorMsg; + EquipAlarmProcessRecord.ProcessMethod = VARIABLE.ProcessMethod; + EquipAlarmProcessRecord.StartTime = VARIABLE.StartTime; + EquipAlarmProcessRecord.ProcessTime=DateTime.Now; + + EquipAlarmProcessRecordRepository.Insert(EquipAlarmProcessRecord); + } + } + EquipAlarmRecordRepository.Delete(i=>i.Id>0);*/ + //} + + #endregion } } }