ningshuxia
2022-11-14 e4680615a852b2eb115b32c8bcbc3b788c3f9ef4
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace IStation.Calculation
{
    /// <summary>
    /// 能效标准业务日辅助类
    /// </summary>
    public class EtaStandardLogicDayHelper
    {
 
        /// <summary>
        /// 标准
        /// </summary>
        public static List<Model.EtaStandardLogicDayRecord> Standard
            (
                long CorpID,
                string ObjectType,
                long ObjectID,
                DateTime Day,
                IEnumerable<Model.EtaStandardConfigure> configures,
                IEnumerable<Model.EtaLogicRealRecord> list
            )
        {
            if (configures == null || configures.Count() < 1)
                return default;
            if (list == null || list.Count() < 1)
                return default;
            var normal_list = list.Where(x => x.AnalyStatus == Model.Eta.eAnalyStatus.Normal).ToList();
            if (normal_list.Count < 1)
                return default;
 
            var dt_now = DateTime.Now;
            var record_list = new List<Model.EtaStandardLogicDayRecord>();
            foreach (var configure in configures)
            {
                //存在此区间范围内的数据
                var normal_limit_list = normal_list.Where(t => t.Ea >= configure.LowerLimit && t.Ea <= configure.UpperLimit).ToList();
                if (normal_limit_list != null && normal_limit_list.Count > 0)
                {
                    var record = new Model.EtaStandardLogicDayRecord();
                    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 = normal_limit_list.Where(x => x.Qa.HasValue).Min(t => t.Qa.Value);
                    record.Qmax = normal_limit_list.Where(x => x.Qa.HasValue).Max(t => t.Qa.Value);
                    record.Qavg = normal_limit_list.Where(x => x.Qa.HasValue).Average(t => t.Qa.Value);
 
                    record.Emin = normal_limit_list.Where(x => x.Ea.HasValue).Min(t => t.Ea.Value);
                    record.Emax = normal_limit_list.Where(x => x.Ea.HasValue).Max(t => t.Ea.Value);
                    record.Eavg = normal_limit_list.Where(x => x.Ea.HasValue).Average(t => t.Ea.Value);
 
                    record.Hmin = normal_limit_list.Where(x => x.Ha.HasValue).Min(t => t.Ha.Value);
                    record.Hmax = normal_limit_list.Where(x => x.Ha.HasValue).Max(t => t.Ha.Value);
                    record.Havg = normal_limit_list.Where(x => x.Ha.HasValue).Average(t => t.Ha.Value);
 
                    record.Pmin = normal_limit_list.Where(x=>x.Pa.HasValue).Min(t => t.Pa.Value);
                    record.Pmax = normal_limit_list.Where(x => x.Pa.HasValue).Max(t => t.Pa.Value);
                    record.Pavg = normal_limit_list.Where(x => x.Pa.HasValue).Average(t => t.Pa.Value);
 
                    record.WPmin = normal_limit_list.Where(x => x.WPa.HasValue).Min(t => t.WPa.Value);
                    record.WPmax = normal_limit_list.Where(x => x.WPa.HasValue).Max(t => t.WPa.Value);
                    record.WPavg = normal_limit_list.Where(x => x.WPa.HasValue).Average(t => t.WPa.Value);
 
                    record.UWPmin = normal_limit_list.Where(x => x.UWPa.HasValue).Min(t => t.UWPa.Value);
                    record.UWPmax = normal_limit_list.Where(x => x.UWPa.HasValue).Max(t => t.UWPa.Value);
                    record.UWPavg = normal_limit_list.Where(x => x.UWPa.HasValue).Average(t => t.UWPa.Value);
 
                    record.Qt = normal_limit_list.Where(x => x.Qa.HasValue).Sum(x => x.Qa.Value * x.Duration) / 3600f;
                    record.Qtt = normal_list.Where(x => x.Qa.HasValue).Sum(x => x.Qa.Value * x.Duration) / 3600f;
                    record.Dt = normal_limit_list.Where(x => x.Pa.HasValue).Sum(x => x.Pa.Value * x.Duration) / 3600f;
                    record.Dtt = normal_list.Where(x => x.Pa.HasValue).Sum(x => x.Pa.Value * x.Duration) / 3600f;
 
                    record.PointCount = normal_limit_list.Count;
                    record.TotalPointCount = normal_list.Count();
 
                    record_list.Add(record);
                }
            }
            return record_list;
        }
 
    }
}