ningshuxia
2022-12-01 ad494f13d2ddf31f142cf7fb908b3a6e90395a1a
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace IStation.Calculation
{
    /// <summary>
    /// 能效汇总业务日辅助类
    /// </summary>
    public class EtaSumLogicDayHelper
    {
 
        /// <summary>
        /// 汇总
        /// </summary>
        public static Model.EtaSumLogicDayRecord Sum
            (
                long CorpID,
                string ObjectType,
                long ObjectID,
                DateTime Day,
                IEnumerable<Model.EtaLogicRealRecord> list
            )
        {
            if (list == null || list.Count() < 1)
                return default;
            var normal_list = list.Where(x => x.AnalyStatus == Model.Eta.eAnalyStatus.Normal).ToList();
 
            var model = new Model.EtaSumLogicDayRecord();
            model.CorpID = CorpID;
            model.ObjectType = ObjectType;
            model.ObjectID = ObjectID;
            model.DataDay = Day.Date;
            model.DataTime = DateTime.Now;
            model.Qt = list.Sum(x => (x.Qa ?? 0) * x.Duration) / 3600f;
            model.Dt = list.Sum(x => (x.Pa ?? 0) * x.Duration) / 3600f;
            model.PointCount = list.Count();
 
            if (normal_list.Count > 0)
            {
                if (normal_list.Exists(x => x.Qa.HasValue))
                {
                    model.Qmin = normal_list.Where(x => x.Qa.HasValue).Min(x => x.Qa.Value);
                    model.Qmax = normal_list.Where(x => x.Qa.HasValue).Max(x => x.Qa.Value);
                    model.Qavg = normal_list.Where(x => x.Qa.HasValue).Average(x => x.Qa.Value);
                }
 
                if (normal_list.Exists(x => x.Ha.HasValue))
                {
                    model.Hmin = normal_list.Where(x => x.Ha.HasValue).Min(x => x.Ha.Value);
                    model.Hmax = normal_list.Where(x => x.Ha.HasValue).Max(x => x.Ha.Value);
                    model.Havg = normal_list.Where(x => x.Ha.HasValue).Average(x => x.Ha.Value);
                }
 
                if (normal_list.Exists(x => x.Ea.HasValue))
                {
                    model.Emin = normal_list.Where(x => x.Ea.HasValue).Min(x => x.Ea.Value);
                    model.Emax = normal_list.Where(x => x.Ea.HasValue).Max(x => x.Ea.Value);
                    model.Eavg = normal_list.Where(x => x.Ea.HasValue).Average(x => x.Ea.Value);
                }
 
                if (normal_list.Exists(x => x.Pa.HasValue))
                {
                    model.Pmin = normal_list.Where(x => x.Pa.HasValue).Min(x => x.Pa.Value);
                    model.Pmax = normal_list.Where(x => x.Pa.HasValue).Max(x => x.Pa.Value);
                    model.Pavg = normal_list.Where(x => x.Pa.HasValue).Average(x => x.Pa.Value);
                }
 
                if (normal_list.Exists(x => x.WPa.HasValue))
                {
                    model.WPmin = normal_list.Where(x => x.WPa.HasValue).Min(x => x.WPa.Value);
                    model.WPmax = normal_list.Where(x => x.WPa.HasValue).Max(x => x.WPa.Value);
                    model.WPavg = normal_list.Where(x => x.WPa.HasValue).Average(x => x.WPa.Value);
                }
 
                if (normal_list.Exists(x => x.UWPa.HasValue))
                {
                    model.UWPmin = normal_list.Where(x => x.UWPa.HasValue).Min(x => x.UWPa.Value);
                    model.UWPmax = normal_list.Where(x => x.UWPa.HasValue).Max(x => x.UWPa.Value);
                    model.UWPavg = normal_list.Where(x => x.UWPa.HasValue).Average(x => x.UWPa.Value);
                }
 
            }
 
            return model;
 
 
        }
    }
}