using System; using System.Collections.Generic; using System.Reflection.Emit; using System.Linq; namespace IStation.CalcModel { public class AnaPrj { public AnaPrj() { } public AnaPrj(AnaPrj prj) { this.ID = prj.ID; this.Name = prj.Name; this.IsFixed = prj.IsFixed; this.SumMoney = prj.SumMoney; this.SumFlow = prj.SumFlow; this.SumPower = prj.SumPower; this.Note = prj.Note; this.StartTime = prj.StartTime; this.EndTime = prj.EndTime; this.CalcSpaceMinute = prj.CalcSpaceMinute; if (prj.BlockTimes != null) { this.BlockTimes = new List(); foreach (var item in prj.BlockTimes) { this.BlockTimes.Add(new AnaPrjBlockTime(item)); } } } public List GetAllPointTimeList() { List list = new List(); if (this.BlockTimes != null) { foreach (var bt in this.BlockTimes) { if (bt.PointTimes != null) { list.AddRange(bt.PointTimes); } } } return list; } public double GetWaterLevelHByTime(DateTime time) { List list = new List(); if (this.BlockTimes != null) { foreach (var bt in this.BlockTimes) { if (bt.PointTimes == null) continue; foreach (var tp in bt.PointTimes) { if (tp.Time >= time) return tp.WaterLevelH; } } } return -1; } public DateTime StartTime { get; set; } public DateTime EndTime { get; set; } public string ID { get; set; } public string Name { get; set; } //流水号 public string WaterLevelInfo { get; set; } public double SumFlow { get; set; }//吨(计算值) public double SumPower { get; set; } public double SumMoney { get; set; } public double SumFlow4Disp { get { return Math.Round(SumFlow / 10000, 2); } } public double SumPower4Disp { get { return Math.Round(SumPower, 0); } } public double MaxWaterLevelH { get; set; }//最大水库水位 public DateTime MaxWaterLevelTime { get; set; }//最大水库水位时间 public int CalcSpaceMinute { get; set; } //千吨水能耗 public double QDSLN { get { if (SumFlow == 0) return 0; return Math.Round(SumPower * 1000 / SumFlow, 1); } } public List EndTimeOpenPumpStatus { get; set; } //最后一刻的开泵状态:用于第二天调度计算 public List PumpSwitchs { get; set; }//泵操作信息 public List BlockTimes { get; set; } /// /// 正好 /// /// /// public AnaPrjPointTime FindPointTime(DateTime time) { if (BlockTimes == null || BlockTimes.Count == 0) return null; if(time > this.BlockTimes.Last().PointTimes.Last().Time.AddMinutes(-5)) { return this.BlockTimes.Last().PointTimes.Last(); } foreach (var bt in BlockTimes) { if (bt.PointTimes == null) continue; var fff = bt.PointTimes.Find(x => x.Time == time); if(fff != null) return fff; } return null; } /// /// 靠近 /// /// /// public AnaPrjPointTime NearPointTime(DateTime time) { if(BlockTimes == null) return null; AnaPrjPointTime near_pt = null; double min_dis = 30;//最少30分 foreach (var bt in BlockTimes) { if (bt.PointTimes == null) continue; foreach(var pt in bt.PointTimes) { var m = Math.Abs((time - pt.Time).TotalMinutes); if (m < min_dis) { min_dis = m; near_pt = pt; } } } return near_pt; } // public bool IsFixed { get; set; } = false; public string Note { get;set; } public int Type { get; set; }//0 表示分析得出 1 表示手动添加 //排序与比较 public class Comparer : IComparer { private eCalcOptType sortType; public Comparer(eCalcOptType type) { sortType = type; } #region IComparer 成员 int IComparer.Compare(AnaPrj obj1, AnaPrj obj2) { if (sortType == eCalcOptType.功率) { if (Math.Abs(obj1.SumPower - obj2.SumPower) < 0.1) { return 0; } else if (obj1.SumPower > obj2.SumPower) { return 1; } else { return -1; } } else { if (Math.Abs(obj1.SumMoney- obj2.SumMoney) < 0.1) { return 0; } else if (obj1.SumMoney > obj2.SumMoney) { return 1; } else { return -1; } } } #endregion } } public class AnaPrjBlockTime { public AnaPrjBlockTime() { } public AnaPrjBlockTime(AnaPrjBlockTime item) { this.StartTime = item.StartTime; this.EndTime = item.EndTime; this.OpenPumpIndexs = item.OpenPumpIndexs; this.OpenPumpCount = item.OpenPumpCount; this.SumFlow = item.SumFlow; this.SumMoney = item.SumMoney; this.SumPower = item.SumPower; } public int ID { get;set; } public DateTime StartTime { get; set; }//时间 public DateTime EndTime { get; set; }//结束时间 public int StartTimeIndex { get; set; }//开始时角标 public int EndTimeIndex { get; set; }//结束时角标 public int OpenPumpCount { get; set; }//开泵数量 public double ReservoirEndHeight { get; set; }//开始时的水位 public double ReservoirStartHeight { get; set; }//结束时的水位 public List OpenPumpIndexs { get; set; }// 开泵情况 public int StartSwitchGroupID { get; set; }//开始时对应的SwitchID public int EndSwitchGroupID { get; set; }//结束时对应的SwitchID public double SumFlow { get; set; }//已经考虑时间段 (累计值) public double SumPower { get; set; }//已经考虑时间段 (累计值 度) public double SumMoney { get; set; }//已经考虑时间段 (累计值) public double SumFlow4Disp { get { return Math.Round(SumFlow / 10000, 2); } } public double SumPower4Disp { get { return Math.Round(SumPower, 0); } } public List PointTimes { get; set; } //千吨水能耗 public double QDSLN { get { if(SumFlow == 0) return 0; return Math.Round(SumPower * 1000 / SumFlow, 1); } } public static AnaPrjBlockTime Find( List items, DateTime start) { if (items == null || items.Count == 0) return null; if(items.Count == 1) { return items[0]; } foreach(var item in items) { if(item.StartTime >= start ) { return item; } } return null; } } public class AnaPrjPointTime { public AnaPrjPointTime() { } public AnaPrjPointTime(AnaPrjPointTime rhs) { this.Time = rhs.Time; this.ReservoirDropFlowTotal = rhs.ReservoirDropFlowTotal; this.RealHead = rhs.RealHead; this.RealFlow = rhs.RealFlow; this.SumMoney = rhs.SumMoney; this.RealPower = rhs.RealPower; this.SumPower = rhs.SumPower; this.SumFlow = rhs.SumFlow; this.WaterLevelQ = rhs.WaterLevelQ; this.WaterLevelH = rhs.WaterLevelH; this.OpenPumpCount = rhs.OpenPumpCount; this.WaterLevelC = rhs.WaterLevelC; } public AnaPrjPointTime( IStation.CalcModel.TimePoint t, IStation.CalcModel.StationTimeData td, int openPumpCount) { this.Time = t.Time; this.ReservoirDropFlowTotal = t.ReservoirDropFlowTotal; this.OpenPumpCount = openPumpCount; this.RealHead = td.Head; this.RealFlow = td.Flow; this.RealPower = td.Power; this.SumMoney = td.SumMoney; this.SumPower = td.SumPower; this.SumFlow = td.SumFlow; this.WaterLevelC = t.WaterLevelC; this.WaterLevelQ = Math.Round(td.WaterLevelQ, 2); this.WaterLevelH = Math.Round(td.WaterLevelH, 4); //this.PumpDatas = td.PumpDatas; } public AnaPrjPointTime(IStation.CalcModel.TimePoint t ) { this.Time = t.Time; this.ReservoirDropFlowTotal = t.ReservoirDropFlowTotal; this.WaterLevelC = t.WaterLevelC ; this.WaterLevelQ = t.WaterLevelC ; } // public DateTime Time { get; set; } public int OpenPumpCount { get; set; } public double RealHead { get; set; } public double RealFlow { get; set; }//瞬时值, 不考虑时间段 public double RealPower { get; set; }//瞬时值, 不考虑时间段 public double SumFlow { get; set; }//流量 , 考虑时间段 public double SumPower { get; set; }//用电量 , 考虑时间段 public double SumMoney { get; set; }//费电 , 考虑时间段 public double WaterLevelQ { get; set; }//前池水位 public double WaterLevelH { get; set; }//水库水位 public double WaterLevelC { get; set; }//长江水位 public double ReservoirDropFlowTotal { get; set; }//水库总供水量 //public List PumpDatas { get; set; } } public class AnaPrjSwitchInfo { public AnaPrjSwitchInfo() { } // public int Index { get; set;}//顺序ID public int GroupID { get; set; }//分组ID public int PumpIndex { get; set; }//泵角标 public DateTime Time { get; set; }//时间 public int SwitchType { get; set; }//1 开机 0 关机 } }