using SqlSugar;
|
using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Text;
|
using System.Threading.Tasks;
|
|
namespace IStation.DAL
|
{
|
/// <summary>
|
/// 能效标准(单)时记录
|
/// </summary>
|
public class EtaStandardSingleHourRecord:CorpDAL<Entity.EtaStandardSingleHourRecord>
|
{
|
/// <summary>
|
///
|
/// </summary>
|
public override ConnectionConfig ConnectionConfig
|
{
|
get { return ConfigHelper.RecordConnectionConfig; }
|
}
|
|
/// <summary>
|
/// 通过对象获取
|
/// </summary>
|
public List<Entity.EtaStandardSingleHourRecord> GetByObject(long CorpID, string ObjectType, long ObjectID)
|
{
|
using (var db = new SqlSugarClient(ConnectionConfig))
|
{
|
return db.Queryable<Entity.EtaStandardSingleHourRecord>()
|
.Where(x => x.CorpID == CorpID && x.ObjectType == ObjectType && x.ObjectID == ObjectID)
|
.ToList();
|
}
|
}
|
|
|
/// <summary>
|
/// 通过对象获取某日的数据
|
/// </summary>
|
public List<Entity.EtaStandardSingleHourRecord> GetByObjectOfDay(long CorpID, string ObjectType, long ObjectID, DateTime Day)
|
{
|
using (var db = new SqlSugarClient(ConnectionConfig))
|
{
|
return db.Queryable<Entity.EtaStandardSingleHourRecord>()
|
.Where(x => x.CorpID == CorpID && x.ObjectType == ObjectType && x.ObjectID == ObjectID)
|
.Where(x => x.DataDay == Day.Date)
|
.ToList();
|
}
|
}
|
|
/// <summary>
|
/// 通过对象获取某时的数据
|
/// </summary>
|
public List<Entity.EtaStandardSingleHourRecord> GetByObjectOfHour(long CorpID, string ObjectType, long ObjectID, DateTime Day, int Hour)
|
{
|
using (var db = new SqlSugarClient(ConnectionConfig))
|
{
|
return db.Queryable<Entity.EtaStandardSingleHourRecord>()
|
.Where(x => x.CorpID == CorpID && x.ObjectType == ObjectType && x.ObjectID == ObjectID)
|
.Where(x => x.DataDay == Day.Date && x.DataHour == Hour)
|
.ToList();
|
}
|
}
|
|
/// <summary>
|
/// 通过对象获取日期区间内的数据
|
/// </summary>
|
public List<Entity.EtaStandardSingleHourRecord> GetByObjectOfDayRange(long CorpID, string ObjectType, long ObjectID, DateTime StartDay, DateTime EndDay)
|
{
|
if (StartDay.Date > EndDay.Date)
|
return default;
|
using (var db = new SqlSugarClient(ConnectionConfig))
|
{
|
return db.Queryable<Entity.EtaStandardSingleHourRecord>()
|
.Where(x => x.CorpID == CorpID && x.ObjectType == ObjectType && x.ObjectID == ObjectID)
|
.Where(x => x.DataDay >= StartDay.Date && x.DataDay <= EndDay.Date)
|
.ToList();
|
}
|
}
|
|
/// <summary>
|
/// 通过对象获取小时区间内的数据
|
/// </summary>
|
public List<Entity.EtaStandardSingleHourRecord> GetByObjectOfHourRange(long CorpID, string ObjectType, long ObjectID, DateTime StartDay, int StartHour, DateTime EndDay, int EndHour)
|
{
|
if (StartDay.Date > EndDay.Date)
|
return default;
|
using (var db = new SqlSugarClient(ConnectionConfig))
|
{
|
return db.Queryable<Entity.EtaStandardSingleHourRecord>()
|
.Where(x => x.CorpID == CorpID && x.ObjectType == ObjectType && x.ObjectID == ObjectID)
|
.Where(x => (x.DataDay > StartDay.Date && x.DataDay < EndDay.Date)
|
|| (x.DataDay == StartDay.Date && x.DataHour >= StartHour)
|
|| (x.DataDay == EndDay.Date && x.DataHour <= EndHour))
|
.ToList();
|
}
|
}
|
|
|
|
|
}
|
}
|