|
|
|
@ -5,9 +5,13 @@ using Service.Charger.Client;
|
|
|
|
|
using Service.Charger.Msg.Charger.Resp;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Diagnostics;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using Common.Const;
|
|
|
|
|
using Entity.DbModel.Station;
|
|
|
|
|
using Repository.Station;
|
|
|
|
|
|
|
|
|
|
namespace Service.Charger.Handler
|
|
|
|
|
{
|
|
|
|
@ -17,6 +21,74 @@ namespace Service.Charger.Handler
|
|
|
|
|
{
|
|
|
|
|
private static readonly ILog Log = LogManager.GetLogger(typeof(UpAlarmHandler));
|
|
|
|
|
|
|
|
|
|
private EquipAlarmRecordRepository EquipAlarmRecordRepository { get; set; }
|
|
|
|
|
private EquipAlarmProcessRecordRepository EquipAlarmProcessRecordRepository { get; set; }
|
|
|
|
|
private EquipAlarmDefineRepository EquipAlarmDefineRepository { get; set; }
|
|
|
|
|
|
|
|
|
|
public UpAlarmHandler(
|
|
|
|
|
EquipAlarmRecordRepository _EquipAlarmRecordRepository,
|
|
|
|
|
EquipAlarmProcessRecordRepository _EquipAlarmProcessRecordRepository,
|
|
|
|
|
EquipAlarmDefineRepository _EquipAlarmDefineRepository)
|
|
|
|
|
{
|
|
|
|
|
EquipAlarmRecordRepository = _EquipAlarmRecordRepository;
|
|
|
|
|
EquipAlarmProcessRecordRepository = _EquipAlarmProcessRecordRepository;
|
|
|
|
|
EquipAlarmDefineRepository = _EquipAlarmDefineRepository;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 报警数据处理
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="svalue">报警类型</param>
|
|
|
|
|
/// <param name="equipCode">报警编码</param>
|
|
|
|
|
/// <param name="sn">设备编码</param>
|
|
|
|
|
private void AlarmMsg(bool bvalue, string equipCode, string sn)
|
|
|
|
|
{
|
|
|
|
|
if (bvalue)
|
|
|
|
|
{
|
|
|
|
|
var define = EquipAlarmDefineRepository.QueryByClause(i => i.EquipCode == equipCode);
|
|
|
|
|
//查询数据表中是否有此报警信息,有则不用处理,无则添加实时报警
|
|
|
|
|
EquipAlarmRecord equipAlarm =
|
|
|
|
|
EquipAlarmRecordRepository.QueryByClause(i => i.ErrorCode == sn + define.ErrorCode);
|
|
|
|
|
if (equipAlarm == null) //实时报警表中没有这条报警信息
|
|
|
|
|
{
|
|
|
|
|
EquipAlarmRecord record = new EquipAlarmRecord()
|
|
|
|
|
{
|
|
|
|
|
EquipTypeCode = equipAlarm.EquipTypeCode,
|
|
|
|
|
EquipCode = sn,
|
|
|
|
|
ErrorCode = equipAlarm.ErrorCode,
|
|
|
|
|
ErrorLevel = equipAlarm.ErrorLevel,
|
|
|
|
|
ErrorMsg = equipAlarm.ErrorMsg,
|
|
|
|
|
ProcessMethod = equipAlarm.ProcessMethod,
|
|
|
|
|
StartTime = DateTime.Now
|
|
|
|
|
};
|
|
|
|
|
EquipAlarmRecordRepository.Insert(record);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
var define = EquipAlarmDefineRepository.QueryByClause(i => i.EquipCode == equipCode);
|
|
|
|
|
//查询数据表中是否有此报警信息,有则不用处理,无则添加实时报警
|
|
|
|
|
EquipAlarmRecord equipAlarm =
|
|
|
|
|
EquipAlarmRecordRepository.QueryByClause(i => i.ErrorCode == sn + define.ErrorCode);
|
|
|
|
|
if (equipAlarm != null) //报警消除实时报警里面数据还有此报警
|
|
|
|
|
{
|
|
|
|
|
EquipAlarmProcessRecord EquipAlarmProcessRecord = new EquipAlarmProcessRecord();
|
|
|
|
|
EquipAlarmProcessRecord.EquipTypeCode = equipAlarm.EquipTypeCode;
|
|
|
|
|
EquipAlarmProcessRecord.EquipCode = equipAlarm.EquipCode;
|
|
|
|
|
EquipAlarmProcessRecord.ErrorCode = equipAlarm.ErrorCode;
|
|
|
|
|
EquipAlarmProcessRecord.ErrorLevel = equipAlarm.ErrorLevel;
|
|
|
|
|
EquipAlarmProcessRecord.ErrorMsg = equipAlarm.ErrorMsg;
|
|
|
|
|
EquipAlarmProcessRecord.ProcessMethod = equipAlarm.ProcessMethod;
|
|
|
|
|
EquipAlarmProcessRecord.StartTime = equipAlarm.StartTime;
|
|
|
|
|
EquipAlarmProcessRecord.ProcessTime = DateTime.Now;
|
|
|
|
|
|
|
|
|
|
EquipAlarmProcessRecordRepository.Insert(EquipAlarmProcessRecord);
|
|
|
|
|
|
|
|
|
|
EquipAlarmRecordRepository.Delete(equipAlarm);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void ChannelRead0(IChannelHandlerContext ctx, UpAlarm msg)
|
|
|
|
|
{
|
|
|
|
|
if (ClientMgr.TryGetClient(ctx.Channel, out string sn, out var client))
|
|
|
|
@ -257,4 +329,4 @@ namespace Service.Charger.Handler
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|