|
|
@ -1,6 +1,9 @@
|
|
|
|
using DotNetty.Transport.Channels;
|
|
|
|
using Common.Const;
|
|
|
|
|
|
|
|
using DotNetty.Transport.Channels;
|
|
|
|
|
|
|
|
using Entity.DbModel.Station;
|
|
|
|
using HybirdFrameworkCore.Autofac.Attribute;
|
|
|
|
using HybirdFrameworkCore.Autofac.Attribute;
|
|
|
|
using log4net;
|
|
|
|
using log4net;
|
|
|
|
|
|
|
|
using Repository.Station;
|
|
|
|
using Service.Fire.Client;
|
|
|
|
using Service.Fire.Client;
|
|
|
|
using Service.Fire.Common;
|
|
|
|
using Service.Fire.Common;
|
|
|
|
using Service.Fire.Msg.Fire.Req;
|
|
|
|
using Service.Fire.Msg.Fire.Req;
|
|
|
@ -18,17 +21,130 @@ namespace Service.Fire.Handler;
|
|
|
|
public class DataNoAddresReqHandler : SimpleChannelInboundHandler<DataNoAddresReq>, IBaseHandler
|
|
|
|
public class DataNoAddresReqHandler : SimpleChannelInboundHandler<DataNoAddresReq>, IBaseHandler
|
|
|
|
{
|
|
|
|
{
|
|
|
|
private static readonly ILog Log = LogManager.GetLogger(typeof(DataNoAddresReqHandler));
|
|
|
|
private static readonly ILog Log = LogManager.GetLogger(typeof(DataNoAddresReqHandler));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public EquipAlarmDefineRepository _equipAlarmDefineRepository { get; set; }
|
|
|
|
|
|
|
|
public EquipAlarmRecordRepository _equipAlarmRecordRepository { get; set; }
|
|
|
|
|
|
|
|
public EquipAlarmProcessRecordRepository _equipAlarmProcessRecordRepository { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public DataNoAddresReqHandler(EquipAlarmDefineRepository equipAlarmDefineRepository,
|
|
|
|
|
|
|
|
EquipAlarmRecordRepository equipAlarmRecordRepository,
|
|
|
|
|
|
|
|
EquipAlarmProcessRecordRepository equipAlarmProcessRecordRepository)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
_equipAlarmDefineRepository = equipAlarmDefineRepository;
|
|
|
|
|
|
|
|
_equipAlarmRecordRepository = equipAlarmRecordRepository;
|
|
|
|
|
|
|
|
_equipAlarmProcessRecordRepository = equipAlarmProcessRecordRepository;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected override void ChannelRead0(IChannelHandlerContext ctx, DataNoAddresReq msg)
|
|
|
|
protected override void ChannelRead0(IChannelHandlerContext ctx, DataNoAddresReq msg)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (FireMgr.TryGetClient(ctx.Channel, out var sn, out var client))
|
|
|
|
if (FireMgr.TryGetClient(ctx.Channel, out var sn, out var client))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Log.Info($"receive {msg} from {sn}");
|
|
|
|
Log.Info($"receive {msg} from {sn}");
|
|
|
|
|
|
|
|
|
|
|
|
string datatime = (new DateTime(2000 + msg.Years, msg.Month, msg.Day, msg.Hour, msg.Minute, msg.Seconds)).ToString();
|
|
|
|
if (msg.Building == 1) //1栋左
|
|
|
|
string functionalAttribute = FireConst.FunctionalAttribute(msg.FunctionalAttribute);
|
|
|
|
{
|
|
|
|
string informationType = FireConst.InformationType(msg.InformationType);
|
|
|
|
if (msg.DeviceStatus == 0x05) //火警
|
|
|
|
string deviceStatus = FireConst.DeviceStatus(msg.DeviceStatus);
|
|
|
|
{
|
|
|
|
string deviceType = FireConst.DeviceType(msg.DeviceType);
|
|
|
|
Troubleshoot("85", true);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (msg.DeviceStatus == 0x00) //火警消除
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Troubleshoot("85", false);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (msg.DeviceType == 0xED) //气体现场动作
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Troubleshoot("86", true);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else //报警消除
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Troubleshoot("86", false);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (msg.Building == 2) //2栋右
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (msg.DeviceStatus == 0x05) //火警
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Troubleshoot("87", true);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (msg.DeviceStatus == 0x00) //火警消除
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Troubleshoot("87", false);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (msg.DeviceType == 0xED) //气体现场动作
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Troubleshoot("88", true);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else //报警消除
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Troubleshoot("85", false);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
|
|
/// 处理报警方法
|
|
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
/// <param name="errorCode">报警编码</param>
|
|
|
|
|
|
|
|
/// <param name="isAlarm">是否存在报警</param>
|
|
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
|
|
public bool Troubleshoot(string errorCode, bool isAlarm)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (isAlarm) //存在报警
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
EquipAlarmDefine EquipAlarmDefine =
|
|
|
|
|
|
|
|
_equipAlarmDefineRepository.QueryByClause(i =>
|
|
|
|
|
|
|
|
i.ErrorCode == errorCode && i.EquipTypeCode == (int)EquipmentType.Fire);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (EquipAlarmDefine!=null)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var isfault=_equipAlarmRecordRepository.QueryByClause(i =>
|
|
|
|
|
|
|
|
i.ErrorCode == errorCode && i.EquipTypeCode == (int)EquipmentType.Fire);
|
|
|
|
|
|
|
|
if (isfault!=null) //判断这个报警是否已经添加了
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
EquipAlarmRecord EquipAlarmRecord = new EquipAlarmRecord()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
EquipTypeCode = EquipAlarmDefine.EquipTypeCode,
|
|
|
|
|
|
|
|
EquipCode = EquipAlarmDefine.EquipCode,
|
|
|
|
|
|
|
|
ErrorCode = EquipAlarmDefine.ErrorCode,
|
|
|
|
|
|
|
|
ErrorLevel = EquipAlarmDefine.ErrorLevel,
|
|
|
|
|
|
|
|
ErrorMsg = EquipAlarmDefine.ErrorMsg,
|
|
|
|
|
|
|
|
StartTime = DateTime.Now,
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
_equipAlarmRecordRepository.Insert(EquipAlarmRecord); //添加故障处理
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
EquipAlarmRecord EquipAlarmRecord =
|
|
|
|
|
|
|
|
_equipAlarmRecordRepository.QueryByClause(i =>
|
|
|
|
|
|
|
|
i.ErrorCode == errorCode && i.EquipTypeCode == (int)EquipmentType.Fire);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (EquipAlarmRecord != null)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
EquipAlarmProcessRecord EquipAlarmProcessRecord = new EquipAlarmProcessRecord()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
EquipTypeCode = EquipAlarmRecord.EquipTypeCode,
|
|
|
|
|
|
|
|
EquipCode = EquipAlarmRecord.EquipCode,
|
|
|
|
|
|
|
|
ErrorCode = EquipAlarmRecord.ErrorCode,
|
|
|
|
|
|
|
|
ErrorLevel = EquipAlarmRecord.ErrorLevel,
|
|
|
|
|
|
|
|
ErrorMsg = EquipAlarmRecord.ErrorMsg,
|
|
|
|
|
|
|
|
StartTime = EquipAlarmRecord.StartTime,
|
|
|
|
|
|
|
|
ProcessTime = DateTime.Now,
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
_equipAlarmProcessRecordRepository.Insert(EquipAlarmProcessRecord); //保存记录
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_equipAlarmRecordRepository.Delete(i =>
|
|
|
|
|
|
|
|
i.ErrorCode == errorCode && i.EquipTypeCode == (int)EquipmentType.Fire);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|