|
|
@ -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.Charger.Handler;
|
|
|
|
using Service.Charger.Handler;
|
|
|
|
using Service.WaterCool.Client;
|
|
|
|
using Service.WaterCool.Client;
|
|
|
|
using Service.WaterCool.Msg.WaterCool;
|
|
|
|
using Service.WaterCool.Msg.WaterCool;
|
|
|
@ -13,7 +16,11 @@ public class WaterCoolStatusHandler : SimpleChannelInboundHandler<WaterCoolStatu
|
|
|
|
{
|
|
|
|
{
|
|
|
|
private static readonly ILog Log = LogManager.GetLogger(typeof(WaterCoolStatusHandler));
|
|
|
|
private static readonly ILog Log = LogManager.GetLogger(typeof(WaterCoolStatusHandler));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public EquipAlarmRecordRepository EquipAlarmRecordRepository { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public EquipAlarmDefineRepository EquipAlarmDefineRepository { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public EquipAlarmProcessRecordRepository EquipAlarmProcessRecordRepository { get; set; }
|
|
|
|
protected override void ChannelRead0(IChannelHandlerContext ctx, WaterCoolStatus msg)
|
|
|
|
protected override void ChannelRead0(IChannelHandlerContext ctx, WaterCoolStatus msg)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Log.Info($"receive OtherMsg={msg}");
|
|
|
|
Log.Info($"receive OtherMsg={msg}");
|
|
|
@ -22,6 +29,111 @@ public class WaterCoolStatusHandler : SimpleChannelInboundHandler<WaterCoolStatu
|
|
|
|
{
|
|
|
|
{
|
|
|
|
WaterCoolClientMgr.Dictionary[sn].WaterCoolStatus = msg;
|
|
|
|
WaterCoolClientMgr.Dictionary[sn].WaterCoolStatus = msg;
|
|
|
|
WaterCoolClientMgr.Dictionary[sn].IsConnect = true;
|
|
|
|
WaterCoolClientMgr.Dictionary[sn].IsConnect = true;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (msg != null && msg.TmsTroubleCode >= 1)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
SaveAlarmInfo(new List<string> { msg.TmsTroubleCode.ToString() }, sn);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void SaveAlarmInfo(List<string> lstAlarm, string sn)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
string waterCool = "waterCool";
|
|
|
|
|
|
|
|
int typeCode = (int)EquipmentType.WaterCool;
|
|
|
|
|
|
|
|
if (lstAlarm.Count > 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
#region 有报警比较两边差异,新出现的报警就添加,消失的报警就处理并记录
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var lstEquipAlarmRecord =
|
|
|
|
|
|
|
|
EquipAlarmRecordRepository.QueryListByClause(e => e.EquipTypeCode == typeCode).ToList();
|
|
|
|
|
|
|
|
var sqllstAlarm = lstEquipAlarmRecord.Select(obj => obj.ErrorCode).ToList();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 找出实时报警中存在但数据库中不存在的元素
|
|
|
|
|
|
|
|
List<string> uniqueToList1 = lstAlarm.Except(sqllstAlarm).ToList();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 找出数据库中存在但实时报警中不存在的元素
|
|
|
|
|
|
|
|
List<string> uniqueToList2 = sqllstAlarm.Except(lstAlarm).ToList();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (uniqueToList1.Count > 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
//这里要添加新的报警数据
|
|
|
|
|
|
|
|
foreach (var errorCode in uniqueToList1)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
EquipAlarmDefine? alarmDefine =
|
|
|
|
|
|
|
|
EquipAlarmDefineRepository.SelectByEquipCodeAndErrorCode(typeCode, waterCool,
|
|
|
|
|
|
|
|
errorCode);
|
|
|
|
|
|
|
|
if (alarmDefine != null)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
EquipAlarmRecord record = new EquipAlarmRecord()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
EquipTypeCode = alarmDefine.EquipTypeCode,
|
|
|
|
|
|
|
|
EquipCode = sn,
|
|
|
|
|
|
|
|
ErrorCode = alarmDefine.ErrorCode,
|
|
|
|
|
|
|
|
ErrorLevel = alarmDefine.ErrorLevel,
|
|
|
|
|
|
|
|
ErrorMsg = alarmDefine.ErrorMsg,
|
|
|
|
|
|
|
|
ProcessMethod = alarmDefine.ProcessMethod,
|
|
|
|
|
|
|
|
StartTime = DateTime.Now
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
EquipAlarmRecordRepository.Insert(record);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (uniqueToList2.Count > 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
//这些是要清除实时报警,并且处理记录的。
|
|
|
|
|
|
|
|
// 使用LINQ找出ErrorCode在uniqueToList2中的EquipAlarmRecord对象
|
|
|
|
|
|
|
|
List<EquipAlarmRecord> filteredObjectList = lstEquipAlarmRecord
|
|
|
|
|
|
|
|
.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);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
#region 没报警把已处理记录更新并删除实时报警
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var lstEquipAlarmRecord =
|
|
|
|
|
|
|
|
EquipAlarmRecordRepository.QueryListByClause(e => e.EquipTypeCode ==typeCode ).ToList();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (lstEquipAlarmRecord.Count > 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
foreach (var VARIABLE in lstEquipAlarmRecord)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
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(e => e.EquipTypeCode == typeCode);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|