ningshuxia
2022-10-28 3ccb7c60e1ed8b6748ed7fb8b64b1dbe50d62abf
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
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 EtaLogicRealRecord:CorpDAL<Entity.EtaLogicRealRecord>
    {
        /// <summary>
        /// 
        /// </summary>
        public override ConnectionConfig ConnectionConfig
        {
            get { return ConfigHelper.RecordConnectionConfig; }
        }
 
        /// <summary>
        /// 通过 CorpID 获取某日的数据
        /// </summary>
        public List<Entity.EtaLogicRealRecord> GetByCorpIDOfDay(long CorpID, DateTime Day)
        {
            using (var db = new SqlSugarClient(ConnectionConfig))
            {
                return db.Queryable<Entity.EtaLogicRealRecord>()
                    .Where(x => x.CorpID == CorpID && x.DataTime >= Day.Date && x.DataTime < Day.Date.AddDays(1))
                    .ToList();
            }
        }
 
        /// <summary>
        /// 通过 Object 获取某日的数据
        /// </summary>
        public List<Entity.EtaLogicRealRecord> GetByObjectOfDay(long CorpID, string ObjectType, long ObjectID, DateTime Day)
        {
            using (var db = new SqlSugarClient(ConnectionConfig)) 
            {
                return db.Queryable<Entity.EtaLogicRealRecord>()
                    .Where(x=>x.CorpID==CorpID&&x.ObjectType==ObjectType&&x.ObjectID==ObjectID&&x.DataTime>=Day.Date&&x.DataTime<Day.Date.AddDays(1))
                    .ToList();
            }
        }
 
        /// <summary>
        /// 获取 Object 获取日期区间内的数据
        /// </summary>
        public List<Entity.EtaLogicRealRecord> 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.EtaLogicRealRecord>()
                    .Where(x => x.CorpID == CorpID && x.ObjectType == ObjectType && x.ObjectID == ObjectID && x.DataTime >= StartDay.Date && x.DataTime < EndDay.Date.AddDays(1))
                    .ToList();
            }
        }
 
        /// <summary>
        /// 获取 Object 时间区间内的数据
        /// </summary>
        public List<Entity.EtaLogicRealRecord> GetByObjectOfTimeRange(long CorpID, string ObjectType, long ObjectID, DateTime StartTime, DateTime EndTime)
        {
            if (StartTime > EndTime)
            {
                return default;
            }
 
            using (var db = new SqlSugarClient(ConnectionConfig))
            {
                return db.Queryable<Entity.EtaLogicRealRecord>()
                    .Where(x => x.CorpID == CorpID && x.ObjectType == ObjectType && x.ObjectID == ObjectID && x.DataTime >= StartTime && x.DataTime < EndTime)
                    .ToList();
            }
        }
 
 
 
 
 
 
 
 
 
    }
}