using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Text;
|
using System.Threading.Tasks;
|
|
namespace IStation.Service
|
{
|
/// <summary>
|
/// 能效(业务)实时记录
|
/// </summary>
|
public partial class EtaLogicRealRecord
|
{
|
|
#region Query
|
|
/// <summary>
|
/// 通过 CorpID 获取某日的数据
|
/// </summary>
|
public List<Model.EtaLogicRealRecord> 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();
|
}
|
|
/// <summary>
|
/// 通过对象获取某日的数据
|
/// </summary>
|
public List<Model.EtaLogicRealRecord> 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();
|
}
|
|
/// <summary>
|
/// 通过对象获取日期区间内的数据
|
/// </summary>
|
public List<Model.EtaLogicRealRecord> 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;
|
}
|
|
/// <summary>
|
/// 通过对象获取时间区间内的数据
|
/// </summary>
|
public List<Model.EtaLogicRealRecord> 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
|
|
/// <summary>
|
/// 插入一条
|
/// </summary>
|
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;
|
}
|
|
/// <summary>
|
/// 批量插入
|
/// </summary>
|
public bool InsertsLastRecord(IEnumerable<Model.EtaLogicRealRecordPure> 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
|
|
/// <summary>
|
/// 获取最后一条记录
|
/// </summary>
|
public Model.EtaLogicRealRecordPure GetLastRecord(long CorpID, string ObjectType, long ObjectID)
|
{
|
var redisCache = new RedisCache.EtaRealRecord();
|
return redisCache.GetLastLogicRecord(CorpID, ObjectType, ObjectID);
|
}
|
|
/// <summary>
|
/// 获取最后一条记录
|
/// </summary>
|
public List<Model.EtaLogicRealRecordPure> GetLastRecord(long CorpID, string ObjectType, IEnumerable<long> ObjectIds)
|
{
|
if (ObjectIds == null || ObjectIds.Count() < 1)
|
return default;
|
var redisCache = new RedisCache.EtaRealRecord();
|
return redisCache.GetLastLogicRecord(CorpID, ObjectType, ObjectIds);
|
}
|
|
/// <summary>
|
/// 获取最后一条记录
|
/// </summary>
|
public List<Model.EtaLogicRealRecordPure> GetLastRecord(long CorpID, IEnumerable<KeyValuePair<string, long>> list)
|
{
|
if (list == null || list.Count() < 1)
|
return default;
|
var redisCache = new RedisCache.EtaRealRecord();
|
return redisCache.GetLastLogicRecord(CorpID, list);
|
}
|
|
/// <summary>
|
/// 获取最后一条正常记录
|
/// </summary>
|
public Model.EtaLogicRealRecordPure GetLastNormalRecord(long CorpID, string ObjectType, long ObjectID)
|
{
|
var redisCache = new RedisCache.EtaRealRecord();
|
return redisCache.GetLastNormalLogicRecord(CorpID, ObjectType, ObjectID);
|
}
|
|
/// <summary>
|
/// 获取最后一条正常记录
|
/// </summary>
|
public List<Model.EtaLogicRealRecordPure> GetLastNormalRecord(long CorpID, string ObjectType, IEnumerable<long> ObjectIds)
|
{
|
if (ObjectIds == null || ObjectIds.Count() < 1)
|
return default;
|
var redisCache = new RedisCache.EtaRealRecord();
|
return redisCache.GetLastNormalLogicRecord(CorpID, ObjectType, ObjectIds);
|
}
|
|
/// <summary>
|
/// 获取最后一条正常记录
|
/// </summary>
|
public List<Model.EtaLogicRealRecordPure> GetLastNormalRecord(long CorpID, IEnumerable<KeyValuePair<string, long>> list)
|
{
|
if (list == null || list.Count() < 1)
|
return default;
|
var redisCache = new RedisCache.EtaRealRecord();
|
return redisCache.GetLastNormalLogicRecord(CorpID, list);
|
}
|
|
/// <summary>
|
/// 获取最后一条不正常记录
|
/// </summary>
|
public Model.EtaLogicRealRecordPure GetLastAbnormalRecord(long CorpID, string ObjectType, long ObjectID)
|
{
|
var redisCache = new RedisCache.EtaRealRecord();
|
return redisCache.GetLastAbnormalLogicRecord(CorpID, ObjectType, ObjectID);
|
}
|
|
/// <summary>
|
/// 获取最后一条正常记录
|
/// </summary>
|
public List<Model.EtaLogicRealRecordPure> GetLastAbnormalRecord(long CorpID, string ObjectType, IEnumerable<long> ObjectIds)
|
{
|
if (ObjectIds == null || ObjectIds.Count() < 1)
|
return default;
|
var redisCache = new RedisCache.EtaRealRecord();
|
return redisCache.GetLastAbnormalLogicRecord(CorpID, ObjectType, ObjectIds);
|
}
|
|
/// <summary>
|
/// 获取最后一条不正常记录
|
/// </summary>
|
public List<Model.EtaLogicRealRecordPure> GetLastAbnormalRecord(long CorpID, IEnumerable<KeyValuePair<string, long>> list)
|
{
|
if (list == null || list.Count() < 1)
|
return default;
|
var redisCache = new RedisCache.EtaRealRecord();
|
return redisCache.GetLastAbnormalLogicRecord(CorpID, list);
|
}
|
|
#endregion
|
}
|
}
|