tangxu
2024-12-19 9acdf3c826311bd67180821ce19c625d0e384ca8
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
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
 
using System;
using System.Collections.Generic;
using System.Reflection.Emit;
using System.Linq;
 
namespace IStation.CalcModel
{
    public class AnaPrj
    {
        public AnaPrj() { }
        public AnaPrj(AnaPrj prj) {
            this.ID = prj.ID;   
            this.Name = prj.Name; 
            this.IsFixed = prj.IsFixed;
            this.SumMoney = prj.SumMoney;
            this.SumFlow = prj.SumFlow;
            this.SumPower = prj.SumPower;
            this.Note = prj.Note;
            this.StartTime = prj.StartTime;
            this.EndTime = prj.EndTime;
            this.CalcSpaceMinute = prj.CalcSpaceMinute;
            if (prj.BlockTimes != null)
            {
                this.BlockTimes = new List<AnaPrjBlockTime>();
                foreach (var item in prj.BlockTimes)
                {
                    this.BlockTimes.Add(new AnaPrjBlockTime(item));
                }
            }
        }
        public List<AnaPrjPointTime> GetAllPointTimeList()
        {
            List<AnaPrjPointTime> list = new List<AnaPrjPointTime>();
            if (this.BlockTimes != null)
            {
                foreach (var bt in this.BlockTimes)
                {
                    if (bt.PointTimes != null)
                    {
                        list.AddRange(bt.PointTimes);
                    }
                }
            }
 
            return list;
        }
 
        public double GetWaterLevelHByTime(DateTime time)
        {
            List<AnaPrjPointTime> list = new List<AnaPrjPointTime>();
            if (this.BlockTimes != null)
            {
                foreach (var bt in this.BlockTimes)
                {
                    if (bt.PointTimes == null)
                        continue;
                    foreach (var tp in bt.PointTimes)
                    {
                        if (tp.Time >= time)
                            return tp.WaterLevelH;
                    }
                }
            }
 
            return -1;
        }
        public DateTime StartTime { get; set; }
        public DateTime EndTime { get; set; }
 
        public string ID { get; set; }
        public string Name { get; set; } //流水号
        public string WaterLevelInfo { get; set; }
        public double SumFlow { get; set; }//吨(计算值)
 
        public double SumPower { get; set; }
        public double SumMoney { get; set; }
 
        public double SumFlow4Disp { get { return Math.Round(SumFlow / 10000, 2); } }
        public double SumPower4Disp { get { return Math.Round(SumPower, 0); } }
 
        public double MaxWaterLevelH { get; set; }//最大水库水位
        public DateTime MaxWaterLevelTime { get; set; }//最大水库水位时间
 
        public int CalcSpaceMinute { get; set; }
 
        //千吨水能耗
        public double QDSLN
        {
            get
            {
                if (SumFlow == 0)
                    return 0;
                return Math.Round(SumPower * 1000 / SumFlow, 1);
            }
        }
 
        public List<int> EndTimeOpenPumpStatus { get; set; } //最后一刻的开泵状态:用于第二天调度计算
        public List<AnaPrjSwitchInfo> PumpSwitchs { get; set; }//泵操作信息
        public List<AnaPrjBlockTime> BlockTimes { get; set; }
        
        /// <summary>
        /// 正好
        /// </summary>
        /// <param name="time"></param>
        /// <returns></returns>
        public AnaPrjPointTime FindPointTime(DateTime time)
        {
            if (BlockTimes == null || BlockTimes.Count  == 0)
                return null;
            if(time > this.BlockTimes.Last().PointTimes.Last().Time.AddMinutes(-5))
            {
                return this.BlockTimes.Last().PointTimes.Last();
            }
            foreach (var bt in BlockTimes)
            {
                if (bt.PointTimes == null)
                    continue;
                var fff = bt.PointTimes.Find(x => x.Time == time);
                if(fff != null)
                    return fff; 
            }
            return null;
        }
 
        /// <summary>
        /// 靠近
        /// </summary>
        /// <param name="time"></param>
        /// <returns></returns>
        public AnaPrjPointTime NearPointTime(DateTime time)
        {
            if(BlockTimes == null)
                return null;
            AnaPrjPointTime near_pt = null;
            double min_dis = 30;//最少30分
            foreach (var bt in BlockTimes)
            {
                if (bt.PointTimes == null)
                    continue;
                foreach(var pt in bt.PointTimes)
                {
                    var m = Math.Abs((time - pt.Time).TotalMinutes);
                    if (m < min_dis)
                    {
                        min_dis = m;
                        near_pt = pt;
                    }
                }
 
            }
            return near_pt;
        }
 
        //
        public bool IsFixed { get; set; } = false;
 
        public string Note { get;set; }
        public int Type { get; set; }//0 表示分析得出 1 表示手动添加
        //排序与比较
        public class Comparer : IComparer<AnaPrj>
        {
            private eCalcOptType sortType;
            public Comparer(eCalcOptType type)
            {
                sortType = type;
            }
 
            #region IComparer<FeatPoint> 成员
            int IComparer<AnaPrj>.Compare(AnaPrj obj1, AnaPrj obj2)
            {
                if (sortType ==  eCalcOptType.功率)
                {
                    if (Math.Abs(obj1.SumPower - obj2.SumPower) < 0.1)
                    {
                        return 0;
                    }
                    else if (obj1.SumPower > obj2.SumPower)
                    {
                        return 1;
                    }
                    else
                    {
                        return -1;
                    }
                }
                else
                {
                    if (Math.Abs(obj1.SumMoney- obj2.SumMoney) < 0.1)
                    {
                        return 0;
                    }
                    else if (obj1.SumMoney > obj2.SumMoney)
                    {
                        return 1;
                    }
                    else
                    {
                        return -1;
                    }
                }
            }
 
            #endregion
        }
    }
 
    public class AnaPrjBlockTime
    {
        public AnaPrjBlockTime() {   }
        public AnaPrjBlockTime(AnaPrjBlockTime item) { 
            this.StartTime = item.StartTime;
            this.EndTime = item.EndTime; 
            this.OpenPumpIndexs = item.OpenPumpIndexs;
            this.OpenPumpCount = item.OpenPumpCount;
            this.SumFlow = item.SumFlow;
            this.SumMoney = item.SumMoney;
            this.SumPower = item.SumPower; 
        }
  
        public int ID { get;set; }
        public DateTime StartTime { get; set; }//时间
        public DateTime EndTime { get; set; }//结束时间
        public int StartTimeIndex { get; set; }//开始时角标
        public int EndTimeIndex { get; set; }//结束时角标
        public int OpenPumpCount { get; set; }//开泵数量
        public double ReservoirEndHeight { get; set; }//开始时的水位
        public double ReservoirStartHeight { get; set; }//结束时的水位
        public List<int> OpenPumpIndexs { get; set; }// 开泵情况
 
        public int StartSwitchGroupID { get; set; }//开始时对应的SwitchID
        public int EndSwitchGroupID { get; set; }//结束时对应的SwitchID
 
        public double SumFlow { get; set; }//已经考虑时间段  (累计值)
        public double SumPower { get; set; }//已经考虑时间段 (累计值 度)
        public double SumMoney { get; set; }//已经考虑时间段 (累计值) 
 
        public double SumFlow4Disp { get { return Math.Round(SumFlow / 10000, 2); } }
        public double SumPower4Disp { get { return Math.Round(SumPower, 0); } }
 
        public List<AnaPrjPointTime> PointTimes { get; set; }
 
        //千吨水能耗
        public double QDSLN
        {
            get
            {
                if(SumFlow == 0)
                    return 0;
                return Math.Round(SumPower * 1000 / SumFlow, 1);
            }
        }
 
        public static AnaPrjBlockTime Find(
            List<AnaPrjBlockTime> items,
            DateTime start)
        {
            if (items == null || items.Count == 0)
                return null;
            if(items.Count == 1)
            {
                return items[0];
            }
            foreach(var item in items) 
            { 
                if(item.StartTime >= start ) 
                {
                    return item; 
                }
            }
 
            return null;
        }
    }
 
    public class AnaPrjPointTime
    {
        public AnaPrjPointTime() { }
        public AnaPrjPointTime(AnaPrjPointTime rhs) 
        {
            this.Time = rhs.Time;
            this.ReservoirDropFlowTotal = rhs.ReservoirDropFlowTotal;
            this.RealHead = rhs.RealHead;
            this.RealFlow = rhs.RealFlow;
            this.SumMoney = rhs.SumMoney;
            this.RealPower = rhs.RealPower;
            this.SumPower = rhs.SumPower;
            this.SumFlow = rhs.SumFlow;
            this.WaterLevelQ = rhs.WaterLevelQ;
            this.WaterLevelH = rhs.WaterLevelH;
            this.OpenPumpCount = rhs.OpenPumpCount;
            this.WaterLevelC = rhs.WaterLevelC; 
        }
        public AnaPrjPointTime(
            IStation.CalcModel.TimePoint t,
            IStation.CalcModel.StationTimeData td,
            int openPumpCount) {
            this.Time = t.Time;
            this.ReservoirDropFlowTotal = t.ReservoirDropFlowTotal;
            this.OpenPumpCount = openPumpCount;
 
 
            this.RealHead = td.Head;
            this.RealFlow = td.Flow;
            this.RealPower = td.Power;
 
            this.SumMoney = td.SumMoney;  
            this.SumPower = td.SumPower;
            this.SumFlow = td.SumFlow;
 
            this.WaterLevelC = t.WaterLevelC;
            this.WaterLevelQ = Math.Round(td.WaterLevelQ, 2);
            this.WaterLevelH = Math.Round(td.WaterLevelH, 4);
           
 
 
            //this.PumpDatas = td.PumpDatas;
        }
        public AnaPrjPointTime(IStation.CalcModel.TimePoint t )
        {
            this.Time = t.Time;
            this.ReservoirDropFlowTotal = t.ReservoirDropFlowTotal;
            this.WaterLevelC =  t.WaterLevelC ;
            this.WaterLevelQ =  t.WaterLevelC ;
        }
        //
        public DateTime Time { get; set; }
        public int OpenPumpCount { get; set; }
 
        public double RealHead { get; set; }
        public double RealFlow { get; set; }//瞬时值, 不考虑时间段
        public double RealPower { get; set; }//瞬时值, 不考虑时间段
 
        public double SumFlow { get; set; }//流量 , 考虑时间段
        public double SumPower { get; set; }//用电量 , 考虑时间段
        public double SumMoney { get; set; }//费电 , 考虑时间段
 
 
 
        public double WaterLevelQ { get; set; }//前池水位 
        public double WaterLevelH { get; set; }//水库水位
        public double WaterLevelC { get; set; }//长江水位
 
        public double ReservoirDropFlowTotal { get; set; }//水库总供水量
 
 
        //public List<IStation.CalcModel.PumpTimeData> PumpDatas { get; set; } 
    }
 
    public class AnaPrjSwitchInfo
    {
        public AnaPrjSwitchInfo() { }
        //
        public int Index { get; set;}//顺序ID
        public int GroupID { get; set; }//分组ID
        public int PumpIndex { get; set; }//泵角标
        public DateTime Time { get; set; }//时间
        public int SwitchType { get; set; }//1 开机 0 关机 
    }
}