From 0e6a1b0840fd64f8ab75f88aba3a1ca3ef4e884b Mon Sep 17 00:00:00 2001 From: tangxu <tangxu76880903> Date: 星期二, 11 六月 2024 11:05:04 +0800 Subject: [PATCH] 成行 AnaProject.db 数据库表中增加4列, StartOpenPumpIndexs , EndOpenPumpIndexs ,StartReservoirLevel,EndReservoirLevel 都是 TEXT --- Calc/IStation.Calc.Core/计算基类/ErQuCalcBaseHelper.cs | 126 ++++++++++++++++++++++++++---------------- 1 files changed, 78 insertions(+), 48 deletions(-) diff --git "a/Calc/IStation.Calc.Core/\350\256\241\347\256\227\345\237\272\347\261\273/ErQuCalcBaseHelper.cs" "b/Calc/IStation.Calc.Core/\350\256\241\347\256\227\345\237\272\347\261\273/ErQuCalcBaseHelper.cs" index 9e6592c..a17ef62 100644 --- "a/Calc/IStation.Calc.Core/\350\256\241\347\256\227\345\237\272\347\261\273/ErQuCalcBaseHelper.cs" +++ "b/Calc/IStation.Calc.Core/\350\256\241\347\256\227\345\237\272\347\261\273/ErQuCalcBaseHelper.cs" @@ -2,8 +2,7 @@ using IStation.Model; using System; using System.Collections.Generic; -using System.Linq; -using System.Runtime.CompilerServices; +using System.Linq; namespace IStation.Calc { @@ -15,63 +14,65 @@ /// <returns></returns> public static IStation.Calc.ErQuCalcBaseHelper Build(IStation.CalcModel.AnaRequest anaRequest) { - if (anaRequest.MaxLimitWaterBoxLevel != null) + if (anaRequest.MaxReservoirLevel != null) { - DateTime? limit_time = GetMaxLimitWaterBoxTime(anaRequest); + DateTime? limit_time = GetMaxReservoirLevelTime(anaRequest); - if(limit_time == null) + if (limit_time == null) { var calc = new IStation.Calc.ErQuCalcHelper_2_閫掑綊_瀹氭按浣峗浠绘剰鏃堕棿(); - calc.SetMaxReservoirHeight(anaRequest.MaxLimitWaterBoxLevel.Value); - + calc.SetMaxReservoirHeight(anaRequest.MaxReservoirLevel.Value); + return calc; } else { var calc = new IStation.Calc.ErQuCalcHelper_2_閫掑綊_瀹氭按浣峗鎸囧畾鏃堕棿(); - calc.SetMaxReservoirHeight(anaRequest.MaxLimitWaterBoxLevel.Value, limit_time.Value); - return calc; + calc.SetMaxReservoirHeight(anaRequest.MaxReservoirLevel.Value, limit_time.Value); + return calc; } } else { return new IStation.Calc.ErQuCalcHelper_2_閫掑綊_瀹氭按閲�(); } - + } - private static DateTime? GetMaxLimitWaterBoxTime(IStation.CalcModel.AnaRequest anaRequest) + private static DateTime? GetMaxReservoirLevelTime(IStation.CalcModel.AnaRequest anaRequest) { - - if (string.IsNullOrEmpty(anaRequest.MaxLimitWaterBoxTime)) + if (string.IsNullOrEmpty(anaRequest.MaxReservoirLevelTime)) { return null; } DateTime time; - if (DateTime.TryParse(anaRequest.MaxLimitWaterBoxTime, out time)) + if (DateTime.TryParse(anaRequest.MaxReservoirLevelTime, out time)) { return time; } - if (anaRequest.MaxLimitWaterBoxTime.Contains(":")) + if (anaRequest.MaxReservoirLevelTime.Contains(":")) { - var sss = anaRequest.MaxLimitWaterBoxTime.Split(':'); - int hour = 0; - int miut = 0; - if (int.TryParse(sss[0], out hour) && int.TryParse(sss[1],out miut)) + var sss = anaRequest.MaxReservoirLevelTime.Split(':'); + if (sss.Count() == 2) { - if (hour < anaRequest.StartTime.Hour) - return new DateTime(anaRequest.EndTime.Year, anaRequest.EndTime.Month, anaRequest.EndTime.Day, hour, miut, 0); - else - return new DateTime(anaRequest.StartTime.Year, anaRequest.StartTime.Month, anaRequest.StartTime.Day, hour, miut, 0); - } + int hour = 0; + int miut = 0; + if (int.TryParse(sss[0], out hour) && int.TryParse(sss[1], out miut)) + { + if (hour < anaRequest.StartTime.Hour) + return new DateTime(anaRequest.EndTime.Year, anaRequest.EndTime.Month, anaRequest.EndTime.Day, hour, miut, 0); + else + return new DateTime(anaRequest.StartTime.Year, anaRequest.StartTime.Month, anaRequest.StartTime.Day, hour, miut, 0); + } + } } else { int hour = 0; - if (int.TryParse(anaRequest.MaxLimitWaterBoxTime, out hour)) + if (int.TryParse(anaRequest.MaxReservoirLevelTime, out hour)) { if (hour < anaRequest.StartTime.Hour) return new DateTime(anaRequest.EndTime.Year, anaRequest.EndTime.Month, anaRequest.EndTime.Day, hour, 0, 0); @@ -79,10 +80,10 @@ return new DateTime(anaRequest.StartTime.Year, anaRequest.StartTime.Month, anaRequest.StartTime.Day, hour, 0, 0); } - + } - return null; + return null; } /// <summary> @@ -129,27 +130,41 @@ /// <param name="anaRequest"></param> public void SetAnaRequest(IStation.CalcModel.AnaRequest anaRequest) { - this._start_level姘村簱姘翠綅 = anaRequest.CurrentWaterBoxLevel; - this._startOpenCount = anaRequest.StartOpenCount; + this._start_level姘村簱姘翠綅 = anaRequest.StartReservoirLevel; this._clacOptType = anaRequest.CalcOptType; + if(anaRequest.IsKnownStartOpenPump) + { + if(anaRequest.StartOpenPumpIndexArray == null) + {//娌℃湁璧嬪�煎氨鏄〃绀轰笉鐭ラ亾, 濡傛灉閮戒笉寮�鏈�, 璧嬪�糩] + this._startOpenPumpCount = -1; + } + else + { + this._startOpenPumpArray = anaRequest.StartOpenPumpIndexArray; + this._startOpenPumpCount = anaRequest.StartOpenPumpIndexArray.Count; + } + } + else + { + this._startOpenPumpCount = -1; + } - - - if (anaRequest.TotalFlow鍙栨按鎬婚噺 != null) - this._stationTotalFlow = anaRequest.TotalFlow鍙栨按鎬婚噺.Value; + if (anaRequest.TotalFlowIn != null) + this._stationTotalFlow = anaRequest.TotalFlowIn.Value; this.Initial姘村簱鍙傛暟(anaRequest); this.SetRiverWaterLevels(anaRequest.WaterLevels闀挎睙); } + /// <summary> /// 璁$畻鏈�浼� /// </summary> /// <param name="TargetFlowTotal"></param> /// <param name="error_info"></param> /// <returns></returns> - public virtual List<AnaPrj> CalcOptPrjs(out string error_info) + public virtual AnaPrj CalcOptPrj(out string error_info) { error_info = null; @@ -188,7 +203,7 @@ - List<AnaPrj> listPrj; + // List<AnaPrj> listPrj; System.Diagnostics.Stopwatch sw2 = new System.Diagnostics.Stopwatch(); sw2.Start(); @@ -198,7 +213,7 @@ CalcTimeData(dd_minute); // 鐪熸寮�濮嬪垎鏋� - listPrj = CalcOptPrjsCore(); + var optPrj = CalcOptPrjsCore(); sw2.Stop(); @@ -215,21 +230,20 @@ // Thread.Sleep(20 * 1000); //} - if (listPrj == null || listPrj.Count == 0) + if (optPrj == null) { error_info = "鏈壘鍒板悎閫傜殑璋冨害鏂规"; return null; } - foreach (var prj in listPrj) - { - prj.StartTime = this._calStartTime; - prj.EndTime = this._calEndTime; - } + + optPrj.StartTime = this._calStartTime; + optPrj.EndTime = this._calEndTime; + OnShowDebugInfo.Invoke(string.Format("璁$畻鐢ㄦ椂: {0} 绉�", seconds)); - return listPrj; + return optPrj; } @@ -237,7 +251,7 @@ /// /// </summary> /// <returns></returns> - protected virtual List<AnaPrj> CalcOptPrjsCore() + protected virtual AnaPrj CalcOptPrjsCore() { return null; } @@ -305,14 +319,28 @@ /// 涓嶈鍒囨车鏃堕棿 /// </summary> protected List<IStation.CalcModel.TimeRange> _limitSwitchPumpTimes = null; - public List<IStation.CalcModel.TimeRange> LimitSwitchPumpTimes { get { return _limitSwitchPumpTimes; } set { _limitSwitchPumpTimes = value; } } + public List<IStation.CalcModel.TimeRange> LimitSwitchPumpTimes + { + get { return _limitSwitchPumpTimes; } + set + { + _limitSwitchPumpTimes = value; + } + } /// <summary> /// 涓嶈寮�娉垫椂闂� /// </summary> protected List<IStation.CalcModel.TimeRange> _limitOpenPumpTimes = null; - public List<IStation.CalcModel.TimeRange> LimitOpenPumpTimes { get { return _limitOpenPumpTimes; } set { _limitOpenPumpTimes = value; } } + public List<IStation.CalcModel.TimeRange> LimitOpenPumpTimes + { + get { return _limitOpenPumpTimes; } + set + { + _limitOpenPumpTimes = value; + } + } @@ -419,8 +447,8 @@ /// <summary> /// 鍒濆鍖栧紑鏈哄彴鏁� /// </summary> - protected int _startOpenCount = -1; - public int StartOpenCount { get => _startOpenCount; set => _startOpenCount = value; } + protected int _startOpenPumpCount = -1; + protected List<int> _startOpenPumpArray = null; /// <summary> /// @@ -473,5 +501,7 @@ return true; } + + } } -- Gitblit v1.9.3