Calc/IStation.Calc.Core/¼ÆËã»ùÀà/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,49 +14,49 @@
        /// <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)
        {
            if (string.IsNullOrEmpty(anaRequest.MaxLimitWaterBoxTime))
        private static DateTime? GetMaxReservoirLevelTime(IStation.CalcModel.AnaRequest anaRequest)
        {
            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(':');
                if(sss.Count() == 2)
                var sss = anaRequest.MaxReservoirLevelTime.Split(':');
                if (sss.Count() == 2)
                {
                    int hour = 0;
                    int miut = 0;
@@ -68,12 +67,12 @@
                        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);
@@ -81,10 +80,10 @@
                        return new DateTime(anaRequest.StartTime.Year, anaRequest.StartTime.Month, anaRequest.StartTime.Day, hour, 0, 0);
                }
            }
    return null;
            return null;
        }
        /// <summary>
@@ -131,10 +130,25 @@
        /// <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.TotalFlowIn != null)
                this._stationTotalFlow = anaRequest.TotalFlowIn.Value;
@@ -143,13 +157,14 @@
            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;
        }
    }
}