123
ningshuxia
2023-04-13 eb32b4263f6901bb7ac1915b400e4fe28db20ef0
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace IStation.Calculation
{
    /// <summary>
    /// 能效标准多时辅助类
    /// </summary>
    public class EtaStandardMultiHourHelper 
    {
 
        /// <summary>
        /// 依赖
        /// </summary>
        public static List<Model.EtaStandardMultiHourRecord> Standard
            (
                long CorpID,
                string ObjectType,
                long ObjectID,
                DateTime Day,
                IEnumerable<Model.EtaStandardConfigure> configures,
                IEnumerable<Model.EtaMultiRealRecord> list
            )
        {
            if (configures == null || configures.Count() < 1)
                return default;
            if (list == null || list.Count() < 1)
                return default;
            var run_list = list.Where(x => x.RunningCount>0).ToList();
            if (run_list.Count < 1)
                return default;
            var run_normal_list = run_list.Where(x => x.AnalyStatus == Model.Eta.eAnalyStatus.Normal).ToList();
            if (run_normal_list.Count < 1)
                return default;
 
            var dt_now = DateTime.Now;
            var record_list = new List<Model.EtaStandardMultiHourRecord>();
            foreach (var configure in configures)
            {
                //存在此区间范围内的数据
                var run_normal_limit_list = run_normal_list.Where(t => t.Ea >= configure.LowerLimit && t.Ea <= configure.UpperLimit).ToList();
                if (run_normal_limit_list != null && run_normal_limit_list.Count > 0)
                {
                    for (int i = 0; i < 24; i++)
                    {
                        //此小时的此范围的所有运行点数据
                        var run_normal_limit_hour_list = run_normal_limit_list.Where(t => t.DataTime >= Day.Date.AddHours(i) && t.DataTime < Day.Date.AddHours(i + 1)).ToList();
                        if (run_normal_limit_hour_list.Count > 0)
                        {
                            //此小时的所有运行点数据
                            var run_normal_hour_list = run_normal_list.Where(t => t.DataTime >= Day.Date.AddHours(i) && t.DataTime < Day.Date.AddHours(i + 1)).ToList();
                            var record = new Model.EtaStandardMultiHourRecord();
                            record.CorpID = CorpID;
                            record.ConfigureID = configure.ID;
                            record.ObjectType = ObjectType;
                            record.ObjectID = ObjectID;
                            record.DataDay = Day.Date;
                            record.DataHour = i + 1;
                            record.DataTime = dt_now;
                            record.LowerLimit = configure.LowerLimit;
                            record.UpperLimit = configure.UpperLimit;
 
                            record.Qmin = run_normal_limit_hour_list.Min(t => t.Qa.Value);
                            record.Qmax = run_normal_limit_hour_list.Max(t => t.Qa.Value);
                            record.Qavg = run_normal_limit_hour_list.Average(t => t.Qa.Value);
 
                            record.Emin = run_normal_limit_hour_list.Min(t => t.Ea.Value);
                            record.Emax = run_normal_limit_hour_list.Max(t => t.Ea.Value);
                            record.Eavg = run_normal_limit_hour_list.Average(t => t.Ea.Value);
 
                            record.Hmin = run_normal_limit_hour_list.Min(t => t.Ha.Value);
                            record.Hmax = run_normal_limit_hour_list.Max(t => t.Ha.Value);
                            record.Havg = run_normal_limit_hour_list.Average(t => t.Ha.Value);
 
                            record.Pmin = run_normal_limit_hour_list.Min(t => t.Pa.Value);
                            record.Pmax = run_normal_limit_hour_list.Max(t => t.Pa.Value);
                            record.Pavg = run_normal_limit_hour_list.Average(t => t.Pa.Value);
 
                            record.WPmin = run_normal_limit_hour_list.Min(t => t.WPa.Value);
                            record.WPmax = run_normal_limit_hour_list.Max(t => t.WPa.Value);
                            record.WPavg = run_normal_limit_hour_list.Average(t => t.WPa.Value);
 
                            record.UWPmin = run_normal_limit_hour_list.Min(t => t.UWPa.Value);
                            record.UWPmax = run_normal_limit_hour_list.Max(t => t.UWPa.Value);
                            record.UWPavg = run_normal_limit_hour_list.Average(t => t.UWPa.Value);
 
                            record.Qt = run_normal_limit_hour_list.Sum(x => x.Qa.Value * x.Duration) / 3600f;
                            record.Qtt = run_normal_hour_list.Sum(x => x.Qa.Value * x.Duration) / 3600f;
                            record.Dt = run_normal_limit_hour_list.Sum(x => x.Pa.Value * x.Duration) / 3600f;
                            record.Dtt = run_normal_hour_list.Sum(x => x.Pa.Value * x.Duration) / 3600f;
 
                            record.RunTime = run_normal_limit_hour_list.Sum(t => t.Duration);
                            record.TotalRunTime = run_normal_hour_list.Sum(t => t.Duration);
 
                            record.PointCount = run_normal_limit_hour_list.Count;
                            record.TotalPointCount = run_normal_hour_list.Count;
 
                            record_list.Add(record);
                        }
                    }
                }
            }
            return record_list;
        }
 
    }
}