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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace IStation.Calculation
{
    /// <summary>
    /// 能效标准单日辅助类
    /// </summary>
    public class EtaStandardSingleDayHelper
    {
 
        /// <summary>
        /// 依赖
        /// </summary>
        public static List<Model.EtaStandardSingleDayRecord> Standard
            (
                long CorpID,
                string ObjectType,
                long ObjectID,
                DateTime Day,
                IEnumerable<Model.EtaStandardConfigure> configures,
                IEnumerable<Model.EtaSingleRealRecord> list
            )
        {
            if (configures == null || configures.Count() < 1)
                return default;
            if (list == null || list.Count() < 1)
                return default;
            var run_list = list.Where(x => x.RSa == RunStatus.Run).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.EtaStandardSingleDayRecord>();
            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)
                {
                    var record = new Model.EtaStandardSingleDayRecord();
                    record.CorpID = CorpID;
                    record.ConfigureID = configure.ID;
                    record.ObjectType = ObjectType;
                    record.ObjectID = ObjectID;
                    record.DataDay = Day.Date;
                    record.DataTime = dt_now;
                    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;
        }
 
    }
}