ningshuxia
9 天以前 b24092beff11a75a3fec392dcedd475b407ebdc3
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
namespace IStation.Service
{
    /// <summary>
    /// 能效(多)实时记录
    /// </summary>
    public partial class EtaMultiRealRecord
    {
         
        /// <summary>
        ///  通过 Station 获取流量、扬程、日期区间内运行的汇总内容数据
        /// </summary>
        public List<Model.EtaMultiRunSummaryContent> GetRunSummaryContentByStationOfQHDayRange(int Station, double Qmin, double Qmax, double Hmin, double Hmax, DateTime StartDay, DateTime EndDay)
        {
            //判断流量
            if (Qmin > Qmax)
            {
                return default;
            }
            //判断扬程
            if (Hmin > Hmax)
            {
                return default;
            }
            //判断日期
            if (StartDay.Date > EndDay.Date)
            {
                return default;
            }
            var dal = DALCreateHelper.CreateDAL<DAL.IEtaMultiRealRecord>();
            var entity_list = dal.GetRunSummaryContentByStationOfQHDayRange(Station, Qmin, Qmax, Hmin, Hmax, StartDay.Date, EndDay.Date);
            var model_list = Entity2Models(entity_list);
            return model_list;
        } 
 
        /// <summary>
        /// 获取流量扬程区间的运行时间和平均效率
        /// </summary>
        public List<Model.EtaQHETRect> GetRunQHETRectByObjectOfDayRange(int Station, double Qspace, double Hspace, DateTime StartDay, DateTime EndDay)
        {
            if (StartDay.Date > EndDay.Date)
            {
                return default;
            }
            if (Qspace <= 0 || Hspace <= 0)
            {
                return default;
            }
 
            var dal = DALCreateHelper.CreateDAL<DAL.IEtaMultiRealRecord>();
            var entity_list = dal.GetRunQHETByStationOfDayRange(Station, StartDay, EndDay);
            if (entity_list == null || entity_list.Count < 1)
            {
                return default;
            }
 
            //流量最小值
            var min_double_q = entity_list.Min(x => x.Q);
            int q_min = 0;
            if (min_double_q > 10000)
                q_min = (int)(Math.Floor((min_double_q / 10000)) * 10000);
            else if (min_double_q > 1000)
                q_min = (int)(Math.Floor((min_double_q / 1000)) * 1000);
            else if (min_double_q > 100)
                q_min = (int)(Math.Floor((min_double_q / 100)) * 100);
            else
                q_min = (int)(Math.Floor((min_double_q / Qspace)) * Qspace);
 
 
 
            //流量最大值
            int q_max = (int)Math.Ceiling(entity_list.Max(x => x.Q));
 
 
            //扬程最大值
            int h_max = (int)Math.Ceiling(entity_list.Max(x => x.H));
            //扬程最小值
            int h_min = (int)Math.Floor(entity_list.Min(x => x.H));
 
            //流量小数位数
            var q_digit = 1;
            //扬程小数位数
            var h_digit = 2;
 
            var list = new List<Model.EtaQHETRect>();
 
            double q_temp = q_min;
            while (q_temp < q_max)
            {
                double q_temp_over = Math.Round(q_temp + Qspace, q_digit);
                if (q_temp_over > q_max)
                    q_temp_over = q_max;
 
                double h_temp = h_min;
                while (h_temp < h_max)
                {
                    double h_temp_over = Math.Round(h_temp + Hspace, h_digit);
                    if (h_temp_over > h_max)
                        h_temp_over = h_max;
 
                    var items = entity_list.Where(t => t.H >= h_temp && t.H <= h_temp_over && t.Q >= q_temp && t.Q <= q_temp_over).ToList();
 
                    var model = new Model.EtaQHETRect();
                    model.Hmax = h_temp_over;
                    model.Hmin = h_temp;
                    model.Qmax = q_temp_over;
                    model.Qmin = q_temp;
                    if (items.Count > 0)
                    {
                        model.Tsum = items.Sum(t => t.T);
                        model.Eavg = Math.Round(items.Average(t => t.E), 2);
                    }
                    list.Add(model);
 
                    h_temp = h_temp_over;
                }
 
                q_temp = q_temp_over;
            }
 
            return list;
        }
 
        /// <summary>
        /// 获取流量扬程区间的运行时间和平均效率
        /// </summary>
        public Model.EtaQHETRectList GetRunQHETRectListByObjectOfDayRange(int Station, double Qspace, double Hspace, DateTime StartDay, DateTime EndDay)
        {
            if (EndDay.Date < StartDay.Date)
            {
                return default;
            }
            if (Qspace <= 0 || Hspace <= 0)
            {
                return default;
            }
 
            var dal = DALCreateHelper.CreateDAL<DAL.IEtaMultiRealRecord>();
            var entity_list = dal.GetRunQHETByStationOfDayRange(Station, StartDay, EndDay);
            if (entity_list == null || entity_list.Count < 1)
            {
                return default;
            }
 
            var list = new Model.EtaQHETRectList();
 
            //流量最大值
            int q_max = (int)Math.Ceiling(entity_list.Max(x => x.Q));
            //流量最小值
            int q_min = (int)Math.Floor(entity_list.Min(x => x.Q));
 
            //扬程最大值
            int h_max = (int)Math.Ceiling(entity_list.Max(x => x.H));
            //扬程最小值
            int h_min = (int)Math.Floor(entity_list.Min(x => x.H));
 
            //流量小数位数
            var q_digit = 1;
            //扬程小数位数
            var h_digit = 2;
 
            list.Qmax = q_max;
            list.Qmin = q_min;
            list.Hmax = h_max;
            list.Hmin = h_min;
            list.Qspace = Qspace;
            list.Hspace = Hspace;
 
            double q_temp = q_min;
            while (q_temp < q_max)
            {
                double q_temp_over = Math.Round(q_temp + Qspace, q_digit);
                if (q_temp_over > q_max)
                    q_temp_over = q_max;
 
                double h_temp = h_min;
                while (h_temp < h_max)
                {
                    double h_temp_over = Math.Round(h_temp + Hspace, h_digit);
                    if (h_temp_over > h_max)
                        h_temp_over = h_max;
 
                    var items = entity_list.Where(t => t.H >= h_temp && t.H <= h_temp_over && t.Q >= q_temp && t.Q <= q_temp_over).ToList();
                    if (items.Count > 0)
                    {
                        var model = new Model.EtaQHETRect();
                        model.Hmax = h_temp_over;
                        model.Hmin = h_temp;
                        model.Qmax = q_temp_over;
                        model.Qmin = q_temp;
                        model.Tsum = items.Sum(t => t.T);
                        model.Eavg = Math.Round(items.Average(t => t.E), 2);
                        list.RectList.Add(model);
                    }
 
                    h_temp = h_temp_over;
                }
 
                q_temp = q_temp_over;
            }
 
            return list;
        }
 
     
 
 
    }
}