From ed113213fc94c3d9886ea08dfddd09d08d9ba7d5 Mon Sep 17 00:00:00 2001
From: ningshuxia <ningshuxia0927@outlook.com>
Date: 星期三, 16 四月 2025 19:19:34 +0800
Subject: [PATCH] 调度代码修正

---
 01-api/Service/IStation.Service/07-helper/02-schedule/ScheduleHelper.cs |  171 ++++++++++++--------------------------------------------
 1 files changed, 38 insertions(+), 133 deletions(-)

diff --git a/01-api/Service/IStation.Service/07-helper/02-schedule/ScheduleHelper.cs b/01-api/Service/IStation.Service/07-helper/02-schedule/ScheduleHelper.cs
index 715c65d..1578b1a 100644
--- a/01-api/Service/IStation.Service/07-helper/02-schedule/ScheduleHelper.cs
+++ b/01-api/Service/IStation.Service/07-helper/02-schedule/ScheduleHelper.cs
@@ -1,6 +1,4 @@
-锘縰sing IStation.Application;
-
-namespace IStation.Service
+锘縩amespace IStation.Service
 {
     /// <summary>
     /// 璋冨害鍒嗘瀽杈呭姪绫�
@@ -18,7 +16,7 @@
                 this.Flag = flag;
             }
             public int Flag { get; set; }
-        } 
+        }
         #endregion
 
         #region Private Variable
@@ -32,12 +30,10 @@
         private double _sel_opt_flow_excess = 1;//鍙�夋柟妗堢殑娴侀噺浣欓噺
         private readonly double _sel_opt_pump_pressure_excess = 0;//鍙�夋柟妗堢殑鍗曟车鎵▼榛樿鎶崌浣欓噺
 
-        private readonly double _sel_opt_flow_deviation_ratio = 0.05;//鍙�夋柟妗堢殑娴侀噺鍋忓樊姣�
+        private double _sel_opt_flow_deviation_ratio = 0.05;//鍙�夋柟妗堢殑娴侀噺鍋忓樊姣�
         private readonly double _sel_opt_reasonable_flow_deviation_ratio = 0.005;//鍚堢悊鐨勬柟妗堢殑娴侀噺鍋忓樊姣�
 
-        private readonly Service.AnalysisParameter _service_analysis_parameter = new();
-        private readonly Service.AnalysisDeviation _service_analysis_deviation = new();
-        private readonly Service.AnalysisFactor _service_analysis_factor = new();
+        private readonly Service.AnalysisParameter _service_analysis_parameter = new(); 
 
         private int _min_open_count;//鏈�灏忓紑娉垫暟閲�
         private int _max_open_count;//鏈�澶у紑娉垫暟閲�
@@ -62,7 +58,6 @@
         /// </summary>
         public void Initial(List<int> current_open_flag_list, Model.ScheduleConfig schedule_config, List<Model.AnalysisDeviation> analysis_deviation_list)
         {
-
             _current_open_flag_list = current_open_flag_list;
             _min_open_count = 1;
             _max_open_count = 0;
@@ -96,7 +91,7 @@
 
 
         #region OptAnaCombine
-         
+
         /// <summary>
         /// 鑾峰彇鏈�浼樼粍鍚�
         /// </summary>
@@ -225,11 +220,17 @@
             {
                 flag_cumulative_runtime_loss_ratio_dict = GetFlagCumulativeRuntimeLossRatioDict(flag_cumulative_runtime_dict);
             }
-            #endregion 
+            #endregion
 
             #region 瀛樺湪-浼樺厛寮�娉靛垪琛�
 
+            var priority_open_flag_list_remark = string.Empty;
             var exist_priority_open_flag_list = priority_open_flag_list != null && priority_open_flag_list.Count > 0;
+            if (exist_priority_open_flag_list)
+            {
+                priority_open_flag_list = priority_open_flag_list.OrderBy(x => x).ToList();
+                priority_open_flag_list_remark = IntListHelper.ToString(priority_open_flag_list);
+            }
 
             #endregion
 
@@ -420,13 +421,18 @@
                     //浼樺厛寮�娉靛垪琛�
                     if (exist_priority_open_flag_list)
                     {
-                        foreach (var flag in priority_open_flag_list)
-                        {
-                            if (combine.Contains(flag))
-                            {
-                                combine_merit_ratio *= 1.05;
-                            }
-                        }
+                        //foreach (var flag in priority_open_flag_list)
+                        //{
+                        //    if (combine.Contains(flag))
+                        //    {
+                        //        combine_merit_ratio *= 1.05;
+                        //    } 
+                        //}
+
+                        //鐩墠閫昏緫 浼樺厛寮�娉�==蹇呭紑鏂规
+                        var combine_remark = IntListHelper.ToString(combine.OrderBy(x => x));
+                        if (!combine_remark.Contains(priority_open_flag_list_remark))
+                            continue;
                     }
 
                     #endregion
@@ -501,7 +507,7 @@
                 return default;
 
             //鍏堜慨姝g粍鍚堟洸绾垮拰妯″瀷鐨勫亸宸壃绋�
-            var combine_deviation_factor_dict = GetCombineDeviationFactorDict(target_flow, combine); 
+            var combine_deviation_factor_dict = GetCombineDeviationFactorDict(target_flow, combine);
             var conclusion_ex_list_list = new List<List<AnalysisConclusionViewModel>>();
             var conclusion_ex_list_dict = new Dictionary<int, List<AnalysisConclusionViewModel>>();
             double max_supply_flow = 0;
@@ -514,7 +520,8 @@
 
                 //缁勫悎鍋忓樊绯绘暟
                 var combine_deviation_factor = combine_deviation_factor_dict[flag];
-                var current_pressure_diff = target_pressure - inlet_water_level + combine_deviation_factor + _sel_opt_pump_pressure_excess;
+                var current_pressure_diff = target_pressure - inlet_water_level - combine_deviation_factor + _sel_opt_pump_pressure_excess;
+ 
                 current_pressure_diff = Math.Round(current_pressure_diff, 1);
 
                 //棰戠巼闄愬埗
@@ -542,7 +549,8 @@
                         }
                         else
                         {
-                            conclusion_list = new List<Model.AnalysisParameter>() { min_pressure_diff_conclusion };
+                            var list = _service_analysis_parameter.GetList(run_flag);
+                            conclusion_list = _service_analysis_parameter.GetList(run_flag, current_pressure_diff);  
                         }
                     }
                 }
@@ -557,18 +565,17 @@
             }
 
             if (conclusion_ex_list_list.Count != combine.Count())
-                return default; 
+                return default;
 
             if (max_supply_flow < target_flow * _sel_opt_flow_excess)
             {
                 if (GlobalHelper.IsStation1(combine))
                 {
-                    _sel_opt_flow_excess= 0.995;
+                    _sel_opt_flow_excess = 0.97;
                 }
                 var flow_excess = target_flow * _sel_opt_flow_excess;
                 if (max_supply_flow < flow_excess)
                     return default;
-
             }
 
             var opt_ana_combine = GetOptAnaCombine(conclusion_ex_list_dict, pump_nr_dict, pump_bp_dict, target_flow);
@@ -689,7 +696,7 @@
                         ana_combine.TotalPower += opt_cl_ex.Power;
 
                         var ana_fre_pump = new AnaFrePump();
-                        ana_fre_pump.Flag = flag; 
+                        ana_fre_pump.Flag = flag;
                         ana_fre_pump.Flow = opt_cl_ex.Flow;
                         ana_fre_pump.Head = opt_cl_ex.Head;
                         ana_fre_pump.PressureDiff = opt_cl_ex.PressureDiff;
@@ -709,7 +716,7 @@
             }
             if (!ana_combine_list.Any())
                 return default;
-            var opt_ana_combine = ana_combine_list.OrderBy(x => x.TotalPower).First();
+            var opt_ana_combine = ana_combine_list.OrderBy(x=>x.TotalFlow).OrderBy(x => x.TotalPower).First();
             return opt_ana_combine;
         }
 
@@ -934,7 +941,7 @@
                 Yw.LogHelper.Error($"[{Yw.Untity.IntListHelper.ToString(flags)}]缁勫悎涓嶅瓨鍦ㄥ亸宸郴鏁�!");
                 return deviation_factor_dict;
             }
-             
+
             var a = flow;
             var flow_dev = flow;
             Model.AnalysisDeviation analysis_deviation = null;
@@ -944,8 +951,8 @@
                 analysis_deviation = analysis_deviation_list.Where(x => x.MinFlow <= flow_dev && flow_dev <= x.MaxFlow).FirstOrDefault();
                 if (analysis_deviation != null)
                     break;
-            } 
-           
+            }
+
             if (analysis_deviation == null)
             {
                 Yw.LogHelper.Error($"[{Yw.Untity.IntListHelper.ToString(flags)}]缁勫悎涓嶅瓨鍦ㄥ亸宸郴鏁�!");
@@ -968,7 +975,7 @@
         #endregion
 
         #region Expand
-  
+
         /// <summary>
         /// 鑾峰彇鍙橀娉靛垪琛� 鏍规嵁宸ュ喌璁$畻
         /// </summary>
@@ -1039,7 +1046,7 @@
 
 
                 var fre_pump = new AnaFrePump();
-                fre_pump.Flag = flag; 
+                fre_pump.Flag = flag;
                 fre_pump.Flow = flow;
                 fre_pump.Head = head;
                 fre_pump.Power = curveQP.GetFitPointY(flow);
@@ -1054,109 +1061,7 @@
 
             return ana_fre_pump_list;
         }
-
-        /// <summary>
-        /// 鑾峰彇鍙橀娉靛垪琛� 鏍规嵁宸ュ喌璁$畻
-        /// </summary>
-        /// <param name="pumps"></param>
-        /// <param name="flag_rpm_dic"></param>
-        /// <param name="flag_inlet_water_level_dict"></param>
-        /// <param name="flag_flow_dic"></param>
-        /// <param name="flag_head_dic"></param>
-        /// <param name="flag_curve_head_dic"></param>
-        /// <param name="total_flow"></param>
-        /// <param name="ues_deviation_factor"></param>
-        /// <returns></returns>
-        public List<AnaFrePump> GetAnaFrePumpListByWorking(
-            List<Model.Pump> pumps,
-            Dictionary<int, double> flag_rpm_dic,
-            Dictionary<int, double> flag_inlet_water_level_dict,
-            Dictionary<int, double> flag_flow_dic,
-            Dictionary<int, double> flag_head_dic,
-            double total_flow,
-            out Dictionary<int, double> flag_curve_head_dic,
-            bool ues_deviation_factor = false
-            )
-        {
-            flag_curve_head_dic = new Dictionary<int, double>();
-            if (pumps == null || !pumps.Any())
-            {
-                return default;
-            }
-
-            if (flag_rpm_dic == null || !flag_rpm_dic.Any())
-            {
-                return default;
-            }
-
-            var run_flag_list = flag_rpm_dic.Where(x => x.Value > 1).Select(x => x.Key).OrderBy(x => x).ToList();
-            var ana_fre_pump_list = new List<AnaFrePump>();
-            foreach (var flag in run_flag_list)
-            {
-                var pump = pumps.Find(x => x.Flag == flag);
-                if (pump == null)
-                    continue;
-                var rpm = flag_rpm_dic[flag];
-                if (rpm < 1)
-                    continue;
-
-                var hz = Math.Round(rpm / pump.Nr * 50, 1);
-
-
-                var CurveQH50 = pump.CurveQH;
-                var CurveQP50 = pump.CurveQP;
          
-
-                var curveQH = Curve.PumpCalculateHelper.CalculateSimilarQH(CurveQH50, pump.Nr, rpm);
-                var curveQP = Curve.PumpCalculateHelper.CalculateSimilarQP(CurveQP50, pump.Nr, rpm);
-
-                double flow = 0, head = 0;
-                if (flag_head_dic != null && flag_head_dic.ContainsKey(pump.Flag))
-                {
-                    head = flag_head_dic[pump.Flag];
-                }
-
-                if (flag_inlet_water_level_dict != null && flag_inlet_water_level_dict.ContainsKey(pump.Flag))
-                {
-                    head -= flag_inlet_water_level_dict[pump.Flag];
-                }
-
-                if (ues_deviation_factor)
-                {
-                    //var combine_deviation_factor_dict = GetCombineDeviationFactorDict(total_flow, run_flag_list);//淇缁勫悎鏇茬嚎鍜屾ā鍨嬬殑鍋忓樊鎵▼ 
-                    //if (combine_deviation_factor_dict != null && combine_deviation_factor_dict.ContainsKey(flag))
-                    //{
-                    //    var combine_deviation_factor = combine_deviation_factor_dict[flag];  //缁勫悎鍋忓樊绯绘暟
-                    //    head -= combine_deviation_factor;
-                    //}
-                }
-
-                flow = curveQH.GetInterPointLastX(head) ?? 0;
-                if (flow < 0)
-                    continue;
-
-                var working_flow = flag_flow_dic[flag];
-                flag_curve_head_dic[flag] = curveQH.GetFitPointY(working_flow);
-
-                var fre_pump = new AnaFrePump();
-                fre_pump.Flag = flag; 
-                fre_pump.Flow = flow;
-                fre_pump.Head = head;
-                fre_pump.Power = curveQP.GetFitPointY(flow);
-                fre_pump.PressureDiff = head - Curve.PumpCalculateHelper.CalculateOtherPress(flow, pump.Ic, pump.Oc, null, null);
-                fre_pump.Eff = Curve.PumpCalculateHelper.CalculateE(fre_pump.Flow, fre_pump.Head, fre_pump.Power);
-                fre_pump.Frequency = rpm / pump.Nr * 50;
-                fre_pump.Speed = rpm;
-
-                ana_fre_pump_list.Add(fre_pump); 
-            }
-
-
-            return ana_fre_pump_list;
-        }
-
-
-
         #endregion  
 
     }

--
Gitblit v1.9.3