|
|
@ -23,21 +23,23 @@ namespace Service.Charger.Handler;
|
|
|
|
public class SummaryFailuresReqHandler : SimpleChannelInboundHandler<SummaryFailuresReq>, IBaseHandler
|
|
|
|
public class SummaryFailuresReqHandler : SimpleChannelInboundHandler<SummaryFailuresReq>, IBaseHandler
|
|
|
|
{
|
|
|
|
{
|
|
|
|
private EquipAlarmDefineRepository EquipAlarmDefineRepository { get; set; }
|
|
|
|
private EquipAlarmDefineRepository EquipAlarmDefineRepository { get; set; }
|
|
|
|
private EquipAlarmRecordRepository equipAlarmRecordRepository { get; set; }
|
|
|
|
private EquipAlarmRecordRepository EquipAlarmRecordRepository { get; set; }
|
|
|
|
|
|
|
|
private EquipAlarmProcessRecordRepository EquipAlarmProcessRecordRepository { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
///
|
|
|
|
///
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
|
private static readonly ILog Log = LogManager.GetLogger(typeof(SummaryFailuresReqHandler));
|
|
|
|
private static readonly ILog Log = LogManager.GetLogger(typeof(SummaryFailuresReqHandler));
|
|
|
|
|
|
|
|
|
|
|
|
List<EquipAlarmDefine> lstEquipAlarmDefine=new List<EquipAlarmDefine>();
|
|
|
|
List<EquipAlarmDefine> lstEquipAlarmDefine = new List<EquipAlarmDefine>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Alarm(string number)
|
|
|
|
void Alarm(string number)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
EquipAlarmDefine alarm = lstEquipAlarmDefine.Where(i => i.ErrorCode == number).First();
|
|
|
|
EquipAlarmDefine alarm = lstEquipAlarmDefine.Where(i => i.ErrorCode == number).First();
|
|
|
|
if (alarm!=null)
|
|
|
|
if (alarm != null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
equipAlarmRecordRepository.Insert(new EquipAlarmRecord()
|
|
|
|
EquipAlarmRecordRepository.Insert(new EquipAlarmRecord()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
EquipTypeCode = alarm.EquipTypeCode,
|
|
|
|
EquipTypeCode = alarm.EquipTypeCode,
|
|
|
|
EquipCode = alarm.EquipCode,
|
|
|
|
EquipCode = alarm.EquipCode,
|
|
|
@ -48,8 +50,6 @@ public class SummaryFailuresReqHandler : SimpleChannelInboundHandler<SummaryFail
|
|
|
|
StartTime = DateTime.Now,
|
|
|
|
StartTime = DateTime.Now,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
@ -64,7 +64,7 @@ public class SummaryFailuresReqHandler : SimpleChannelInboundHandler<SummaryFail
|
|
|
|
Log.Error($"receive data err msg={JsonConvert.SerializeObject(msg)}");
|
|
|
|
Log.Error($"receive data err msg={JsonConvert.SerializeObject(msg)}");
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}*/
|
|
|
|
}*/
|
|
|
|
lstEquipAlarmDefine = EquipAlarmDefineRepository.QueryListByClause(i => i.EquipCode == "plc");
|
|
|
|
lstEquipAlarmDefine = EquipAlarmDefineRepository.QueryListByClause(i => i.EquipCode == "plc");
|
|
|
|
List<string> lstAlarm = new List<string>();
|
|
|
|
List<string> lstAlarm = new List<string>();
|
|
|
|
|
|
|
|
|
|
|
|
if (msg.ScreenEmergencyStop)
|
|
|
|
if (msg.ScreenEmergencyStop)
|
|
|
@ -213,18 +213,66 @@ public class SummaryFailuresReqHandler : SimpleChannelInboundHandler<SummaryFail
|
|
|
|
Alarm("72");
|
|
|
|
Alarm("72");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//查询当前PLC的实时报警信息
|
|
|
|
|
|
|
|
var lstNowEquipAlarmRecord = EquipAlarmRecordRepository.QueryListByClause(i => i.EquipCode == "plc");
|
|
|
|
|
|
|
|
var sqllstAlarm = lstNowEquipAlarmRecord.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.QueryByClause(i => i.ErrorCode == errorCode);
|
|
|
|
|
|
|
|
if (alarmDefine != null)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
EquipAlarmRecord record = new EquipAlarmRecord()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
EquipTypeCode = alarmDefine.EquipTypeCode,
|
|
|
|
|
|
|
|
EquipCode = "plc",
|
|
|
|
|
|
|
|
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<EquipAlarmRecord> 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);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ClientMgr.PlcClient.Auto = msg.T3 == 1;
|
|
|
|
ClientMgr.PlcClient.Auto = msg.T3 == 1;
|
|
|
|
ClientMgr.PlcClient.Remote = msg.T3 == 1;
|
|
|
|
ClientMgr.PlcClient.Remote = msg.T3 == 1;
|
|
|
|
ClientMgr.PlcClient.Init = msg.T6 == 1;
|
|
|
|
ClientMgr.PlcClient.Init = msg.T6 == 1;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|