lixiaojun
2022-11-23 b5c20e5143555a1bdd450a1e660216b90c93b6f1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
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 EtaStandardLogicHourRecord:CorpDAL<Entity.EtaStandardLogicHourRecord>
    {
        /// <summary>
        /// 
        /// </summary>
        public override ConnectionConfig ConnectionConfig
        {
            get { return ConfigHelper.RecordConnectionConfig; }
        }
 
        /// <summary>
        /// 通过对象获取
        /// </summary>
        public List<Entity.EtaStandardLogicHourRecord> GetByObject(long CorpID, string ObjectType, long ObjectID)
        {
            using (var db = new SqlSugarClient(ConnectionConfig))
            {
                return db.Queryable<Entity.EtaStandardLogicHourRecord>()
                            .Where(x => x.CorpID == CorpID && x.ObjectType == ObjectType && x.ObjectID == ObjectID)
                            .ToList();
            }
        }
 
 
        /// <summary>
        /// 通过对象获取某日的数据
        /// </summary>
        public List<Entity.EtaStandardLogicHourRecord> GetByObjectOfDay(long CorpID, string ObjectType, long ObjectID, DateTime Day)
        {
            using (var db = new SqlSugarClient(ConnectionConfig))
            {
                return db.Queryable<Entity.EtaStandardLogicHourRecord>()
                            .Where(x => x.CorpID == CorpID && x.ObjectType == ObjectType && x.ObjectID == ObjectID)
                            .Where(x => x.DataDay == Day.Date)
                            .ToList();
            }
        }
 
        /// <summary>
        /// 通过对象获取某时的数据
        /// </summary>
        public List<Entity.EtaStandardLogicHourRecord> GetByObjectOfHour(long CorpID, string ObjectType, long ObjectID, DateTime Day, int Hour)
        {
            using (var db = new SqlSugarClient(ConnectionConfig))
            {
                return db.Queryable<Entity.EtaStandardLogicHourRecord>()
                            .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.EtaStandardLogicHourRecord> 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.EtaStandardLogicHourRecord>()
                            .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.EtaStandardLogicHourRecord> 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.EtaStandardLogicHourRecord>()
                            .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();
            }
        }
 
 
 
 
    }
}