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("插入失败!");
|
}
|
|
}
|
|
|
}
|
|
|
|
}
|
}
|