Shuxia Ning
2024-11-06 adf8dc1c7cae1b12f486dcdb3d7daf4a5a59ec52
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
using IStation.Untity;
using System;
using System.Collections.Generic;
using System.Linq;
 
namespace IStation.WinFrmUI.Monitor
{
    public class EtaExportHelper
    {
 
        public static void Export(long monitor_data_sources_id)
        {
            var duration = 300;
            var station_list = new BLL.Station().GetAll();
            foreach (var station in station_list)
            {
                var station_id = station.ID;
                var station_index = station.SortCode;
                var packet_list = new BLL.StationSignalRecordPacket().Get(monitor_data_sources_id, station_id);
                if (packet_list == null && !packet_list.Any())
                {
                    return;
                }
 
                var flag_nr_dict = new Dictionary<int, double>();
                var pumps = new BLL.Equipment().GetPumpListByBelongTypeAndBelongID(IStation.ObjectType.Station, station_id);
                foreach (var pump in pumps)
                {
                    flag_nr_dict.Add(pump.SortCode, pump.RatedParas.Nr);
                }
 
                var eta_list = new List<Model.EtaMultiRealRecord>();
                foreach (var packet in packet_list)
                {
                    var year = packet.Year;
                    var month = packet.Month;
                    var station_record_list = packet.StationSignalRecords;
                    foreach (var station_record in station_record_list)
                    {
                        var total_flow = station_record.TotalFlow;
                        var total_pressure = station_record.TotalPressure;
                        var pump_total_flow = station_record.PumpSignalRecords.Sum(x => x.FlowRate);
                        var diff_flow = station_record.DiffFlow;
                        if (total_pressure < 0)
                            continue;
                        if (total_flow <= 0 && pump_total_flow <= 0)
                            continue;
                        if (pump_total_flow > 0 && Math.Abs(diff_flow) > 3000)
                            continue;
                        total_flow = Math.Round(total_flow, 1);
                        pump_total_flow = Math.Round(pump_total_flow, 1);
                        diff_flow = Math.Round(diff_flow, 1);
                        total_pressure = Math.Round(total_pressure, 2);
 
                        var pump_record_list = station_record.PumpSignalRecords;
                        pump_record_list = pump_record_list.OrderBy(x => x.Flag).ToList();
                        if (pump_record_list.Exists(x => x.Rpm < 0))
                            continue;
 
                        var run_flag_list = pump_record_list.Select(x => x.Flag).ToList();
                        var hz_list = new List<double>();
                        var time = station_record.Time;
                        var flow = pump_total_flow;
                        if (flow <=0)
                            flow = total_flow;
                        var head = pump_record_list.Average(x => x.Head);
                        var power = pump_record_list.Sum(x => x.InstantaneousPower);
                        var wp = Model.CurveCalcuHelper.CalculateWP(power, flow);
 
                        var eff = 0d;
                        var uwp = 0d;
 
                        foreach (var pump_record in pump_record_list)
                        {
                            var pump_flow = pump_record.FlowRate;
                            var pump_head = pump_record.Head;
                            var pump_power = pump_record.InstantaneousPower;
                            var pump_rpm = pump_record.Rpm;
                            var pump_eff = Model.CurveCalcuHelper.CalculateE(pump_flow, pump_head, pump_power);
                            var pump_uwp = Model.CurveCalcuHelper.CalculateUWP(pump_power, pump_flow, pump_head);
 
                            eff += pump_eff * pump_flow / flow;
                            uwp += pump_uwp * pump_flow / flow;
 
 
 
                            var flag = pump_record.Flag;
                            var nr = flag_nr_dict[flag];
                            var hz = pump_rpm / nr * 50;
                            if (flag == 15 || flag == 16)
                                hz = 50;
 
                            hz = Math.Round(hz, 1);
                            hz_list.Add(hz);
                        }
 
                        if (eff <= 0 && uwp <= 0)
                        {
                            eff = Model.CurveCalcuHelper.CalculateE(flow, head, power);
                            uwp = Model.CurveCalcuHelper.CalculateUWP(power, flow, head);
                        }
 
                        if (eff>85)
                            continue;
 
                        var eta = new IStation.Model.EtaMultiRealRecord();
                        eta.Station = station_index;
                        eta.DataTime = time;
                        eta.Duration = duration;
                        eta.Qa = Math.Round(flow, 1);
                        eta.Ha = Math.Round(head, 2);
                        eta.Pa = Math.Round(power, 1);
                        eta.Ea = Math.Round(eff, 1);
                        eta.WPa = Math.Round(wp, 3); ;
                        eta.UWPa = Math.Round(uwp, 3);
                        eta.RunningCount = pump_record_list.Count();
                        eta.RunningFlag = IntListHelper.ToString(run_flag_list);
                        eta.HZa = DoubleListHelper.ToString(hz_list);
 
                        eta_list.Add(eta);
                    }
                }
 
                var bol = new DAL.EtaMultiRealRecord().BulkInserts(eta_list);
                if (!bol)
                {
                    throw new System.Exception("插入失败!");
                }
 
            }
 
 
        }
 
 
 
    }
}