ningshuxia
2022-12-01 e152cfebbab554d0f12b118cd3e434bc107f6ffd
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace IStation.Calculation
{
    /// <summary>
    /// 能效依赖多日辅助类
    /// </summary>
    public class EtaAccordMultiDayHelper
    {
 
        /// <summary>
        /// 依赖
        /// </summary>
        public static List<Model.EtaAccordMultiDayRecord> Accord
            (
                DateTime Day,
                IEnumerable<Model.EtaAccordConfigure> 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.EtaAccordMultiDayRecord>();
            foreach (var configure in configures)
            {
                //按流量统计
                if (configure.AccordType == Model.Eta.eAccordType.Q)
                {
                    //存在此区间范围内的数据
                    var run_normal_limit_list = run_normal_list.Where(t => t.Qa >= configure.LowerLimit && t.Qa <= configure.UpperLimit).ToList();
                    if (run_normal_limit_list != null && run_normal_limit_list.Count > 0)
                    {
                        var record = new Model.EtaAccordMultiDayRecord();
                        record.CorpID = configure.CorpID;
                        record.ConfigureID = configure.ID;
                        record.ObjectType = configure.BelongType;
                        record.ObjectID = configure.BelongID;
                        record.DataDay = Day.Date;
                        record.DataTime = dt_now;
                        record.AccordType = configure.AccordType;
                        record.LowerLimit = configure.LowerLimit;
                        record.UpperLimit = configure.UpperLimit;
 
                        record.Qmin = run_normal_limit_list.Min(t => t.Qa.Value);
                        record.Qmax = run_normal_limit_list.Max(t => t.Qa.Value);
                        record.Qavg = run_normal_limit_list.Average(t => t.Qa.Value);
 
                        record.Emin = run_normal_limit_list.Min(t => t.Ea.Value);
                        record.Emax = run_normal_limit_list.Max(t => t.Ea.Value);
                        record.Eavg = run_normal_limit_list.Average(t => t.Ea.Value);
 
                        record.Hmin = run_normal_limit_list.Min(t => t.Ha.Value);
                        record.Hmax = run_normal_limit_list.Max(t => t.Ha.Value);
                        record.Havg = run_normal_limit_list.Average(t => t.Ha.Value);
 
                        record.Pmin = run_normal_limit_list.Min(t => t.Pa.Value);
                        record.Pmax = run_normal_limit_list.Max(t => t.Pa.Value);
                        record.Pavg = run_normal_limit_list.Average(t => t.Pa.Value);
 
                        record.WPmin = run_normal_limit_list.Min(t => t.WPa.Value);
                        record.WPmax = run_normal_limit_list.Max(t => t.WPa.Value);
                        record.WPavg = run_normal_limit_list.Average(t => t.WPa.Value);
 
                        record.UWPmin = run_normal_limit_list.Min(t => t.UWPa.Value);
                        record.UWPmax = run_normal_limit_list.Max(t => t.UWPa.Value);
                        record.UWPavg = run_normal_limit_list.Average(t => t.UWPa.Value);
 
                        record.Qt = run_normal_limit_list.Sum(x => x.Qa.Value * x.Duration) / 3600f;
                        record.Qtt = run_normal_list.Sum(x => x.Qa.Value * x.Duration) / 3600f;
                        record.Dt = run_normal_limit_list.Sum(x => x.Pa.Value * x.Duration) / 3600f;
                        record.Dtt = run_normal_list.Sum(x => x.Pa.Value * x.Duration) / 3600f;
 
                        record.RunTime = run_normal_limit_list.Sum(t => t.Duration);
                        record.TotalRunTime = run_normal_list.Sum(t => t.Duration); 
 
                        record.PointCount = run_normal_limit_list.Count;
                        record.TotalPointCount = run_normal_list.Count();
 
                        record_list.Add(record);
                    }
                }
                else if (configure.AccordType == Model.Eta.eAccordType.E)
                {
                    //存在此区间范围内的数据
                    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)
                    {
                        var record = new Model.EtaAccordMultiDayRecord();
                        record.CorpID = configure.CorpID;
                        record.ConfigureID = configure.ID;
                        record.ObjectType = configure.BelongType;
                        record.ObjectID = configure.BelongID;
                        record.DataDay = Day.Date;
                        record.DataTime = dt_now;
                        record.AccordType = configure.AccordType;
                        record.LowerLimit = configure.LowerLimit;
                        record.UpperLimit = configure.UpperLimit;
 
                        record.Qmin = run_normal_limit_list.Min(t => t.Qa.Value);
                        record.Qmax = run_normal_limit_list.Max(t => t.Qa.Value);
                        record.Qavg = run_normal_limit_list.Average(t => t.Qa.Value);
 
                        record.Emin = run_normal_limit_list.Min(t => t.Ea.Value);
                        record.Emax = run_normal_limit_list.Max(t => t.Ea.Value);
                        record.Eavg = run_normal_limit_list.Average(t => t.Ea.Value);
 
                        record.Hmin = run_normal_limit_list.Min(t => t.Ha.Value);
                        record.Hmax = run_normal_limit_list.Max(t => t.Ha.Value);
                        record.Havg = run_normal_limit_list.Average(t => t.Ha.Value);
 
                        record.Pmin = run_normal_limit_list.Min(t => t.Pa.Value);
                        record.Pmax = run_normal_limit_list.Max(t => t.Pa.Value);
                        record.Pavg = run_normal_limit_list.Average(t => t.Pa.Value);
 
                        record.WPmin = run_normal_limit_list.Min(t => t.WPa.Value);
                        record.WPmax = run_normal_limit_list.Max(t => t.WPa.Value);
                        record.WPavg = run_normal_limit_list.Average(t => t.WPa.Value);
 
                        record.UWPmin = run_normal_limit_list.Min(t => t.UWPa.Value);
                        record.UWPmax = run_normal_limit_list.Max(t => t.UWPa.Value);
                        record.UWPavg = run_normal_limit_list.Average(t => t.UWPa.Value);
 
                        record.Qt = run_normal_limit_list.Sum(x => x.Qa.Value * x.Duration) / 3600f;
                        record.Qtt = run_normal_list.Sum(x => x.Qa.Value * x.Duration) / 3600f;
                        record.Dt = run_normal_limit_list.Sum(x => x.Pa.Value * x.Duration) / 3600f;
                        record.Dtt = run_normal_list.Sum(x => x.Pa.Value * x.Duration) / 3600f;
 
                        record.RunTime = run_normal_limit_list.Sum(t => t.Duration);
                        record.TotalRunTime = run_normal_list.Sum(t => t.Duration); 
 
                        record.PointCount = run_normal_limit_list.Count;
                        record.TotalPointCount = run_normal_list.Count();
 
                        record_list.Add(record);
                    }
                }
            }
            return record_list;
        }
 
    }
}