using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace IStation.Server { /// /// 报警监测记录缓存辅助类 /// public class MonitorRecord4AlarmCacheHelper { //记录列表 private static readonly List _recordList = new List(); //数据不变记录列表 private static readonly List _unChangedRecordList = new List(); /// /// 设置 /// public static void Set(List list) { if (list == null || list.Count < 1) return; list.ForEach(x => { _recordList.RemoveAll(t=>t.CorpID==x.CorpID&&t.MonitorPointID==x.MonitorPointID&&t.SignalID==x.SignalID); _recordList.Add(x); var lastUnChangedRecord = _unChangedRecordList.Find(t => t.CorpID == x.CorpID && t.MonitorPointID == x.MonitorPointID && t.SignalID == x.SignalID); if (lastUnChangedRecord == null) { _unChangedRecordList.Add(x); } else { if (lastUnChangedRecord.DataValue != x.DataValue) { _unChangedRecordList.RemoveAll(t => t.CorpID == x.CorpID && t.MonitorPointID == x.MonitorPointID && t.SignalID == x.SignalID); _unChangedRecordList.Add(x); } } }); } /// /// 通过 MonitorPointID 获取 /// public static List GetByMonitorPointID(long CorpID, long MonitorPointID) { return _recordList.Where(x => x.CorpID == CorpID && x.MonitorPointID == MonitorPointID).ToList(); } /// /// 通过 MonitorPointID 获取第一条 /// public static Model.MonitorBasicRecord GetFirstByMonitorPointID(long CorpID, long MonitorPointID) { return _recordList.FirstOrDefault(x => x.CorpID == CorpID && x.MonitorPointID == MonitorPointID); } /// /// 通过 SignalID 获取 /// public static Model.MonitorBasicRecord GetBySignalID(long CorpID, long MonitorPointID, long SignalID) { return _recordList.Find(x=>x.CorpID==CorpID&&x.MonitorPointID==MonitorPointID&&x.SignalID==SignalID); } /// /// 通过 MonitorPointID 获取不变的 /// public static List GetUnChangedByMonitorPointID(long CorpID, long MonitorPointID) { return _unChangedRecordList.Where(x => x.CorpID == CorpID && x.MonitorPointID == MonitorPointID).ToList(); } /// /// 通过 MonitorPointID 获取不变的第一条 /// public static Model.MonitorBasicRecord GetFirstUnChangedByMonitorPointID(long CorpID, long MonitorPointID) { return _unChangedRecordList.FirstOrDefault(x => x.CorpID == CorpID && x.MonitorPointID == MonitorPointID); } /// /// 通过 SignalID 获取不变的 /// public static Model.MonitorBasicRecord GetUnChangedBySignalID(long CorpID, long MonitorPointID, long SignalID) { return _unChangedRecordList.Find(x => x.CorpID == CorpID && x.MonitorPointID == MonitorPointID && x.SignalID == SignalID); } } }