using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace IStation.Service { /// /// 能效(业务)实时记录 /// public partial class EtaLogicRealRecord { #region Query /// /// 通过 CorpID 获取某日的数据 /// public List GetByCorpIDOfDay(long CorpID, DateTime Day) { var dal = new DAL.EtaLogicRealRecord(); var entity_list = dal.GetByCorpIDOfDay(CorpID, Day); var model_list = Entity2Models(entity_list); return model_list?.OrderBy(x => x.DataTime).ToList(); } /// /// 通过对象获取某日的数据 /// public List GetByObjectOfDay(long CorpID, string ObjectType, long ObjectID, DateTime Day) { var dal=new DAL.EtaLogicRealRecord(); var entity_list = dal.GetByObjectOfDay(CorpID, ObjectType, ObjectID, Day); var model_list = Entity2Models(entity_list); return model_list?.OrderBy(x => x.DataTime).ToList(); } /// /// 通过对象获取日期区间内的数据 /// public List GetByObjectOfDayRange(long CorpID, string ObjectType, long ObjectID, DateTime StartDay, DateTime EndDay) { if (StartDay.Date > EndDay.Date) return default; var dal=new DAL.EtaLogicRealRecord(); var entity_list = dal.GetByObjectOfDayRange(CorpID, ObjectType, ObjectID, StartDay.Date, EndDay.Date); var model_list = Entity2Models(entity_list); return model_list; } /// /// 通过对象获取时间区间内的数据 /// public List GetByObjectOfTimeRange(long CorpID, string ObjectType, long ObjectID, DateTime StartTime, DateTime EndTime) { if (StartTime > EndTime) return default; var dal=new DAL.EtaLogicRealRecord(); var entity_list = dal.GetByObjectOfTimeRange(CorpID, ObjectType, ObjectID, StartTime, EndTime); var model_list = Entity2Models(entity_list); return model_list; } #endregion #region Insert /// /// 插入一条 /// public long InsertLastRecord(Model.EtaLogicRealRecordPure model) { if (model == null) return default; var dal=new DAL.EtaLogicRealRecord(); var entity = Model2Entity(model); var id = dal.Insert(entity); if (id > 0) { var redisCache = new RedisCache.EtaRealRecord(); redisCache.SetLastLogicRecord(model); } return id; } /// /// 批量插入 /// public bool InsertsLastRecord(IEnumerable list) { if (list == null || list.Count() < 1) return default; var dal=new DAL.EtaLogicRealRecord(); var entity_list = Model2Entities(list.ToList()); var bol = dal.Inserts(entity_list); if (bol) { var redisCache = new RedisCache.EtaRealRecord(); redisCache.SetLastLogicRecord(list); } return bol; } #endregion #region Last /// /// 获取最后一条记录 /// public Model.EtaLogicRealRecordPure GetLastRecord(long CorpID, string ObjectType, long ObjectID) { var redisCache = new RedisCache.EtaRealRecord(); return redisCache.GetLastLogicRecord(CorpID, ObjectType, ObjectID); } /// /// 获取最后一条记录 /// public List GetLastRecord(long CorpID, string ObjectType, IEnumerable ObjectIds) { if (ObjectIds == null || ObjectIds.Count() < 1) return default; var redisCache = new RedisCache.EtaRealRecord(); return redisCache.GetLastLogicRecord(CorpID, ObjectType, ObjectIds); } /// /// 获取最后一条记录 /// public List GetLastRecord(long CorpID, IEnumerable> list) { if (list == null || list.Count() < 1) return default; var redisCache = new RedisCache.EtaRealRecord(); return redisCache.GetLastLogicRecord(CorpID, list); } /// /// 获取最后一条正常记录 /// public Model.EtaLogicRealRecordPure GetLastNormalRecord(long CorpID, string ObjectType, long ObjectID) { var redisCache = new RedisCache.EtaRealRecord(); return redisCache.GetLastNormalLogicRecord(CorpID, ObjectType, ObjectID); } /// /// 获取最后一条正常记录 /// public List GetLastNormalRecord(long CorpID, string ObjectType, IEnumerable ObjectIds) { if (ObjectIds == null || ObjectIds.Count() < 1) return default; var redisCache = new RedisCache.EtaRealRecord(); return redisCache.GetLastNormalLogicRecord(CorpID, ObjectType, ObjectIds); } /// /// 获取最后一条正常记录 /// public List GetLastNormalRecord(long CorpID, IEnumerable> list) { if (list == null || list.Count() < 1) return default; var redisCache = new RedisCache.EtaRealRecord(); return redisCache.GetLastNormalLogicRecord(CorpID, list); } /// /// 获取最后一条不正常记录 /// public Model.EtaLogicRealRecordPure GetLastAbnormalRecord(long CorpID, string ObjectType, long ObjectID) { var redisCache = new RedisCache.EtaRealRecord(); return redisCache.GetLastAbnormalLogicRecord(CorpID, ObjectType, ObjectID); } /// /// 获取最后一条正常记录 /// public List GetLastAbnormalRecord(long CorpID, string ObjectType, IEnumerable ObjectIds) { if (ObjectIds == null || ObjectIds.Count() < 1) return default; var redisCache = new RedisCache.EtaRealRecord(); return redisCache.GetLastAbnormalLogicRecord(CorpID, ObjectType, ObjectIds); } /// /// 获取最后一条不正常记录 /// public List GetLastAbnormalRecord(long CorpID, IEnumerable> list) { if (list == null || list.Count() < 1) return default; var redisCache = new RedisCache.EtaRealRecord(); return redisCache.GetLastAbnormalLogicRecord(CorpID, list); } #endregion } }