From b50a06a3185619c4cbbc521ab026f1bfa4d13aae Mon Sep 17 00:00:00 2001
From: ningshuxia <ningshuxia0927@outlook.com>
Date: 星期二, 30 四月 2024 11:13:08 +0800
Subject: [PATCH] 调度

---
 Schedule/IStation.Client/Form1.cs                        |   87 ++++++++++
 Schedule/IStation.Algorithm/Schedule/SchedulingHelper.cs |  120 +++++++++++++-
 Schedule/IStation.Client/Form1.Designer.cs               |  153 +++++++++++++++---
 Schedule/IStation.Algorithm/Helper/IntListHelper.cs      |   46 +++++
 Schedule/IStation.Algorithm/DAL/ScheduleConclusion.cs    |   68 ++++++--
 5 files changed, 407 insertions(+), 67 deletions(-)

diff --git a/Schedule/IStation.Algorithm/DAL/ScheduleConclusion.cs b/Schedule/IStation.Algorithm/DAL/ScheduleConclusion.cs
index c101ab8..fb0e762 100644
--- a/Schedule/IStation.Algorithm/DAL/ScheduleConclusion.cs
+++ b/Schedule/IStation.Algorithm/DAL/ScheduleConclusion.cs
@@ -17,6 +17,8 @@
             return $"{_tableNamePrefix}{runFlag}";
         }
 
+        #region Table
+
         /// <summary>
         /// 鑾峰彇鍏ㄩ儴琛ㄥ悕
         /// </summary>
@@ -50,11 +52,10 @@
             using (SqlSugarClient db = Connection)
             {
                 var sql = $"select count(*)  from sqlite_master where type = 'table' and name = '{GetTableName(runFlag)}';";
-                var bol = db.Ado.ExecuteCommand(sql) > 0;
+                var bol = db.Ado.GetInt(sql) > 0;
                 return bol;
             }
         }
-
 
         /// <summary>
         /// 鏁版嵁搴撳垱寤鸿〃
@@ -65,13 +66,41 @@
             {
                 var tableName = GetTableName(runFlag);
                 var sql_exist = $"select count(*)  from sqlite_master where type = 'table' and name = '{tableName}';";
-                if (db.Ado.ExecuteCommand(sql_exist) > 0)
+                if (db.Ado.GetInt(sql_exist) > 0)
                     return true;
                 var sql_create_table = $"CREATE TABLE  {tableName}  (\r\n   ID BIGINT  NOT NULL\r\n PRIMARY KEY,\r\n    ScheduleCombineID BIGINT,\r\n   RunFlag    VARCHAR (255),\r\n   Pump1   REAL,\r\n   Pump2   REAL,\r\n   Pump3   REAL,\r\n   Head   REAL,\r\n    Flow    REAL,\r\n   Power  REAL,\r\n    WP  REAL,\r\n   UWP    REAL\r\n);";
                 var bol = db.Ado.ExecuteCommand(sql_create_table) > 0;
                 return bol;
             }
         }
+
+        /// <summary>
+        //  鍒犻櫎鎵�鏈夎〃
+        /// </summary>
+        public bool DeleteAllTable()
+        {
+            var tables = GetAllTableName();
+            if (tables == null || !tables.Any())
+                return false;
+
+            using (SqlSugarClient db = Connection)
+            {
+                db.BeginTran();
+
+                foreach (var table in tables)
+                {
+                    var sql = $"drop table {table};";
+                    db.Ado.ExecuteCommand(sql);
+                }
+                db.CommitTran();
+            }
+            return true;
+        }
+
+
+        #endregion
+
+        #region BulkInserts
 
         /// <summary>
         /// 澶ф壒閲忔彃鍏�
@@ -131,7 +160,6 @@
             }
         }
 
-
         /// <summary>
         /// 澶ф壒閲忔彃鍏�
         /// </summary>
@@ -152,8 +180,6 @@
                 return db.Fastest<Entity.ScheduleConclusion>().AS(tableName).BulkCopy(list) > 0;
             }
         }
-
-
 
         /// <summary>
         /// 澶ф壒閲忔彃鍏�
@@ -193,28 +219,32 @@
             return true;
         }
 
+        #endregion
+
+
 
         /// <summary>
-        /// 鑾峰彇鍏ㄩ儴琛ㄥ悕
+        /// 澶ф壒閲忔彃鍏�
         /// </summary>
-        public bool DeleteAllTable()
+        public List<Entity.ScheduleConclusion> GetList(string runFlag, double targetFlow, double targetHead, int takeCount)
         {
-            var tables = GetAllTableName();
-            if (tables == null || !tables.Any())
-                return false;
-
+            var tableName = GetTableName(runFlag);
             using (SqlSugarClient db = Connection)
             {
-                db.BeginTran();
-
-                foreach (var table in tables)
+                var sql = $"select count(*)  from sqlite_master where type = 'table' and name = '{tableName}';";
+                if (db.Ado.GetInt(sql) < 1)
                 {
-                    var sql = $"drop table {table};";
-                    db.Ado.ExecuteCommand(sql);
+                    return default;
                 }
-                db.CommitTran();
+                var list = db.Queryable<Entity.ScheduleConclusion>().AS(tableName)
+                      .Where(x => x.Head >= targetHead && x.Head <= targetHead * 1.01 && x.Flow > targetFlow)
+                      .OrderBy(x => x.Power)
+                      .Take(takeCount)
+                      .ToList();
+                return list;
             }
-            return true;
+
+
         }
 
     }
diff --git a/Schedule/IStation.Algorithm/Helper/IntListHelper.cs b/Schedule/IStation.Algorithm/Helper/IntListHelper.cs
new file mode 100644
index 0000000..773b110
--- /dev/null
+++ b/Schedule/IStation.Algorithm/Helper/IntListHelper.cs
@@ -0,0 +1,46 @@
+锘縩amespace IStation
+{
+    /// <summary>
+    /// 鏁存暟鍒楄〃杈呭姪绫�
+    /// </summary>
+    public class IntListHelper
+    {
+        //鍒嗗壊瀛楃
+        private const string _split = ",";
+
+        /// <summary>
+        /// 杞寲涓哄瓧绗︿覆
+        /// </summary>
+        public static string ToString(IEnumerable<int> list)
+        {
+            if (list == null || list.Count() < 1)
+                return string.Empty;
+            return string.Join(_split, list);
+        }
+
+        /// <summary>
+        /// 杞寲涓哄垪琛�
+        /// </summary>
+        /// <param name="str"></param>
+        /// <returns></returns>
+        public static List<int> ToList(string str)
+        {
+            if (string.IsNullOrEmpty(str))
+                return new List<int>();
+            try
+            {
+                var list = str.Split(new string[] { _split }, StringSplitOptions.RemoveEmptyEntries);
+                if (list.Count() < 1)
+                    return new List<int>();
+                return list.Select(x => Convert.ToInt32(x)).ToList();
+            }
+            catch
+            {
+                return new List<int>();
+            }
+
+        }
+
+
+    }
+}
diff --git a/Schedule/IStation.Algorithm/Schedule/SchedulingHelper.cs b/Schedule/IStation.Algorithm/Schedule/SchedulingHelper.cs
index d94b38f..9f08205 100644
--- a/Schedule/IStation.Algorithm/Schedule/SchedulingHelper.cs
+++ b/Schedule/IStation.Algorithm/Schedule/SchedulingHelper.cs
@@ -1,4 +1,6 @@
-锘縩amespace IStation.Algorithm
+锘縰sing System;
+
+namespace IStation.Algorithm
 {
 
     #region ViewModel
@@ -61,11 +63,13 @@
         string GetRunFlag(Dictionary<int, bool> dic)
         {
             var tableName = string.Empty;
-            var count = dic.Count; 
-            for (int i = 0; i < count; i++)
+            var index = 0;
+            var count = dic.Count;
+            foreach (var item in dic)
             {
-                tableName += GetRunFlag(dic);
-                if ((i + 1) != count)
+                tableName += GetRunFlag(item.Key, item.Value);
+                index++;
+                if (index != count)
                 {
                     tableName += _falgSpaceMark;
                 }
@@ -78,12 +82,49 @@
             return (isBp ? _falgFrePumpTag : _falgFixPumpTag) + id;
         }
 
+        string GetRunFlag(List<string> flags)
+        {
+            var tableName = string.Empty;
+            var count = flags.Count;
+            var index = 0;
+            foreach (var flag in flags)
+            {
+                tableName += flag;
+                index++;
+                if (index != count)
+                {
+                    tableName += _falgSpaceMark;
+                }
+            }
+            return tableName;
+        }
+
+
 
         #endregion
 
         DAL.ScheduleCombine _dal = new DAL.ScheduleCombine();
         DAL.ScheduleConclusion _dalScheduleConclusion = new DAL.ScheduleConclusion();
         DAL.ScheduleAnaLog _dalAnaLog = new DAL.ScheduleAnaLog();
+
+
+        public class CurrentViewModel : Entity.ScheduleConclusion
+        {
+            public CurrentViewModel(Entity.ScheduleConclusion rhs) : base(rhs)
+            {
+                this.Flags = new List<int>();
+                var flags = rhs.RunFlag.Split('_');
+                foreach (var item in flags)
+                {
+                    if (int.TryParse(item.Substring(1), out int flag))
+                    {
+                        this.Flags.Add(flag);
+                    }
+
+                }
+            }
+            public List<int> Flags { get; set; }
+        }
 
 
         public void Ana(List<Pump> pumps, double tagetFlow, double tagetHead, List<int> openPumpCombine)
@@ -93,27 +134,76 @@
             if (openPumpCombine != null && openPumpCombine.Any())
             {
                 var allCombineList = PermutationAndCombination<int>.GetCombination(pumpIds.ToArray(), 2);
-                var combineList = new List<int[]>();
+                var combineList = new List<List<int>>();
                 foreach (var combine in allCombineList)
                 {
-                    foreach (var pump in combine)
-                    {
-                        if (openPumpCombine.Contains(pump))
-                        {
-                            combineList.Add(combine);
-                            break;
-                        }
-                    }
+                    var pump1 = combine[0];
+                    var pump2 = combine[1];
+                    if (!openPumpCombine.Contains(pump1))
+                        continue;
+                    if (!openPumpCombine.Contains(pump2))
+                        continue;
+                    combineList.Add(combine.ToList());
                 }
                 if (combineList.Count < 1)
                     return;
+
+                var avgFlow = tagetFlow / 2;
+
+                var optimalConclusionList = new List<CurrentViewModel>();
                 foreach (var combine in combineList)
                 {
-                  //  var runFlag = getal
+                    var dic = new Dictionary<int, bool>();
+                    foreach (var pump in combine)
+                    {
+                        if (dic_pump.ContainsKey(pump))
+                        {
+                            dic.Add(pump, dic_pump[pump]);
+                        }
+                    }
+                    var runFalg = GetRunFlag(dic);
+                    var list = _dalScheduleConclusion.GetList(runFalg, avgFlow, tagetHead, 1);
+                    if (list != null && list.Any())
+                    {
+                        var vmList = list.Select(x => new CurrentViewModel(x)).ToList();
+                        optimalConclusionList.AddRange(vmList);
+                    }
                 }
+                if (optimalConclusionList == null || !optimalConclusionList.Any())
+                {
+                    return;
+                }
+
+                var optimalConclusionCombineList = PermutationAndCombination<CurrentViewModel>.GetCombination(optimalConclusionList.ToArray(), 2);
+                var combines = new List<Combine>();
+                foreach (var arr in optimalConclusionCombineList)
+                {
+                    var falgs = arr.SelectMany(x => x.Flags).ToList();
+                    if (falgs.GroupBy(x => x).Where(x => x.Count() > 1).Count() > 0)
+                    {
+                        continue;
+                    }
+                    var combine = new Combine();
+                    combine.Power = arr.Sum(x => x.Power);
+                    combine.Head = arr.Average(x => x.Head);
+                    combine.Flow = arr.Sum(x => x.Flow);
+                    combine.RunFlagList = falgs;
+                    combines.Add(combine);
+                }
+
+                var a = combines;
             }
         }
 
+        private class Combine
+        {
+            public double Flow { get; set; }
+            public double Head { get; set; }
+            public double Power { get; set; }
+            public List<int> RunFlagList { get; set; }
+        }
+
+
 
         /// <summary>
         /// 鎻掑叆鍒嗘瀽鏃ュ織
diff --git a/Schedule/IStation.Client/Form1.Designer.cs b/Schedule/IStation.Client/Form1.Designer.cs
index 2c458bb..589fd7a 100644
--- a/Schedule/IStation.Client/Form1.Designer.cs
+++ b/Schedule/IStation.Client/Form1.Designer.cs
@@ -28,60 +28,161 @@
         /// </summary>
         private void InitializeComponent()
         {
-            btnAnaCombine = new Button();
+            btnAnaCh1Combine = new Button();
             richTextBox1 = new RichTextBox();
-            btnAnaConclusion = new Button();
+            btnAnaChConclusion = new Button();
+            tableLayoutPanel1 = new TableLayoutPanel();
+            btnAnaCh2Combine = new Button();
+            tableLayoutPanel2 = new TableLayoutPanel();
+            txtFlow = new TextBox();
+            txtHead = new TextBox();
+            btnAna = new Button();
+            txtOpenCombineList = new RichTextBox();
+            tableLayoutPanel1.SuspendLayout();
+            tableLayoutPanel2.SuspendLayout();
             SuspendLayout();
             // 
-            // btnAnaCombine
+            // btnAnaCh1Combine
             // 
-            btnAnaCombine.Dock = DockStyle.Top;
-            btnAnaCombine.Location = new Point(0, 0);
-            btnAnaCombine.Name = "btnAnaCombine";
-            btnAnaCombine.Size = new Size(1036, 46);
-            btnAnaCombine.TabIndex = 0;
-            btnAnaCombine.Text = "鍒嗘瀽娉电粍鍚�";
-            btnAnaCombine.UseVisualStyleBackColor = true;
-            btnAnaCombine.Click += btnAnaCombine_Click;
+            btnAnaCh1Combine.Dock = DockStyle.Fill;
+            btnAnaCh1Combine.Location = new Point(3, 3);
+            btnAnaCh1Combine.Name = "btnAnaCh1Combine";
+            btnAnaCh1Combine.Size = new Size(512, 104);
+            btnAnaCh1Combine.TabIndex = 0;
+            btnAnaCh1Combine.Text = "鍒嗘瀽1杈撴按娉电粍鍚�";
+            btnAnaCh1Combine.UseVisualStyleBackColor = true;
+            btnAnaCh1Combine.Click += btnAnaCh1Combine_Click;
             // 
             // richTextBox1
             // 
             richTextBox1.Dock = DockStyle.Bottom;
-            richTextBox1.Location = new Point(0, 410);
+            richTextBox1.Location = new Point(0, 221);
             richTextBox1.Name = "richTextBox1";
-            richTextBox1.Size = new Size(1036, 227);
+            richTextBox1.Size = new Size(1036, 416);
             richTextBox1.TabIndex = 1;
             richTextBox1.Text = "";
             // 
-            // btnAnaConclusion
+            // btnAnaChConclusion
             // 
-            btnAnaConclusion.Dock = DockStyle.Fill;
-            btnAnaConclusion.Location = new Point(0, 46);
-            btnAnaConclusion.Name = "btnAnaConclusion";
-            btnAnaConclusion.Size = new Size(1036, 364);
-            btnAnaConclusion.TabIndex = 2;
-            btnAnaConclusion.Text = "鍒嗘瀽娉电粍鍚堢粨璁�";
-            btnAnaConclusion.UseVisualStyleBackColor = true;
-            btnAnaConclusion.Click += btnAnaConclusion_Click;
+            btnAnaChConclusion.Location = new Point(3, 113);
+            btnAnaChConclusion.Name = "btnAnaChConclusion";
+            btnAnaChConclusion.Size = new Size(512, 104);
+            btnAnaChConclusion.TabIndex = 2;
+            btnAnaChConclusion.Text = "鍒嗘瀽鍏ㄩ儴娉电粍鍚堢粨璁�";
+            btnAnaChConclusion.UseVisualStyleBackColor = true;
+            btnAnaChConclusion.Click += btnAnaChConclusion_Click;
+            // 
+            // tableLayoutPanel1
+            // 
+            tableLayoutPanel1.ColumnCount = 2;
+            tableLayoutPanel1.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50F));
+            tableLayoutPanel1.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50F));
+            tableLayoutPanel1.Controls.Add(btnAnaCh1Combine, 0, 0);
+            tableLayoutPanel1.Controls.Add(btnAnaChConclusion, 0, 1);
+            tableLayoutPanel1.Controls.Add(btnAnaCh2Combine, 1, 0);
+            tableLayoutPanel1.Controls.Add(tableLayoutPanel2, 1, 1);
+            tableLayoutPanel1.Dock = DockStyle.Fill;
+            tableLayoutPanel1.Location = new Point(0, 0);
+            tableLayoutPanel1.Name = "tableLayoutPanel1";
+            tableLayoutPanel1.RowCount = 2;
+            tableLayoutPanel1.RowStyles.Add(new RowStyle(SizeType.Percent, 50F));
+            tableLayoutPanel1.RowStyles.Add(new RowStyle(SizeType.Percent, 50F));
+            tableLayoutPanel1.Size = new Size(1036, 221);
+            tableLayoutPanel1.TabIndex = 3;
+            // 
+            // btnAnaCh2Combine
+            // 
+            btnAnaCh2Combine.Location = new Point(521, 3);
+            btnAnaCh2Combine.Name = "btnAnaCh2Combine";
+            btnAnaCh2Combine.Size = new Size(512, 104);
+            btnAnaCh2Combine.TabIndex = 3;
+            btnAnaCh2Combine.Text = "鍒嗘瀽2杈撴按娉电粍鍚�";
+            btnAnaCh2Combine.UseVisualStyleBackColor = true;
+            btnAnaCh2Combine.Click += btnAnaCh2Combine_Click;
+            // 
+            // tableLayoutPanel2
+            // 
+            tableLayoutPanel2.ColumnCount = 2;
+            tableLayoutPanel2.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50F));
+            tableLayoutPanel2.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50F));
+            tableLayoutPanel2.Controls.Add(txtFlow, 0, 0);
+            tableLayoutPanel2.Controls.Add(txtHead, 1, 0);
+            tableLayoutPanel2.Controls.Add(btnAna, 1, 1);
+            tableLayoutPanel2.Controls.Add(txtOpenCombineList, 0, 1);
+            tableLayoutPanel2.Dock = DockStyle.Fill;
+            tableLayoutPanel2.Location = new Point(521, 113);
+            tableLayoutPanel2.Name = "tableLayoutPanel2";
+            tableLayoutPanel2.RowCount = 2;
+            tableLayoutPanel2.RowStyles.Add(new RowStyle(SizeType.Percent, 34.2857132F));
+            tableLayoutPanel2.RowStyles.Add(new RowStyle(SizeType.Percent, 65.71429F));
+            tableLayoutPanel2.Size = new Size(512, 105);
+            tableLayoutPanel2.TabIndex = 4;
+            // 
+            // txtFlow
+            // 
+            txtFlow.Dock = DockStyle.Fill;
+            txtFlow.Location = new Point(3, 3);
+            txtFlow.Name = "txtFlow";
+            txtFlow.Size = new Size(250, 30);
+            txtFlow.TabIndex = 0;
+            txtFlow.Text = "16406";
+            // 
+            // txtHead
+            // 
+            txtHead.Dock = DockStyle.Fill;
+            txtHead.Location = new Point(259, 3);
+            txtHead.Name = "txtHead";
+            txtHead.Size = new Size(250, 30);
+            txtHead.TabIndex = 1;
+            txtHead.Text = "15.92";
+            // 
+            // btnAna
+            // 
+            btnAna.Dock = DockStyle.Fill;
+            btnAna.Location = new Point(259, 39);
+            btnAna.Name = "btnAna";
+            btnAna.Size = new Size(250, 63);
+            btnAna.TabIndex = 3;
+            btnAna.Text = "鍒嗘瀽";
+            btnAna.UseVisualStyleBackColor = true;
+            btnAna.Click += btnAna_Click;
+            // 
+            // txtOpenCombineList
+            // 
+            txtOpenCombineList.Dock = DockStyle.Fill;
+            txtOpenCombineList.Location = new Point(3, 39);
+            txtOpenCombineList.Name = "txtOpenCombineList";
+            txtOpenCombineList.Size = new Size(250, 63);
+            txtOpenCombineList.TabIndex = 4;
+            txtOpenCombineList.Text = "11,12,13,17";
             // 
             // Form1
             // 
             AutoScaleDimensions = new SizeF(11F, 24F);
             AutoScaleMode = AutoScaleMode.Font;
             ClientSize = new Size(1036, 637);
-            Controls.Add(btnAnaConclusion);
+            Controls.Add(tableLayoutPanel1);
             Controls.Add(richTextBox1);
-            Controls.Add(btnAnaCombine);
             Name = "Form1";
             StartPosition = FormStartPosition.CenterScreen;
             Text = "Form1";
+            tableLayoutPanel1.ResumeLayout(false);
+            tableLayoutPanel2.ResumeLayout(false);
+            tableLayoutPanel2.PerformLayout();
             ResumeLayout(false);
         }
 
         #endregion
 
-        private Button btnAnaCombine;
+        private Button btnAnaCh1Combine;
         private RichTextBox richTextBox1;
-        private Button btnAnaConclusion;
+        private Button btnAnaChConclusion;
+        private TableLayoutPanel tableLayoutPanel1;
+        private Button btnAnaCh2Combine;
+        private TableLayoutPanel tableLayoutPanel2;
+        private TextBox txtFlow;
+        private TextBox txtHead;
+        private Button btnAna;
+        private RichTextBox txtOpenCombineList;
     }
 }
\ No newline at end of file
diff --git a/Schedule/IStation.Client/Form1.cs b/Schedule/IStation.Client/Form1.cs
index 4351674..dbe4601 100644
--- a/Schedule/IStation.Client/Form1.cs
+++ b/Schedule/IStation.Client/Form1.cs
@@ -12,15 +12,16 @@
             };
         }
 
+        string _floder = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Data");
+
         private void btnAnaCombine_Click(object sender, EventArgs e)
         {
-            this.richTextBox1.Text += "正在分析泵组合";
-            var folder = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Data");
-            var ch1 = folder + "\\" + "陈行一输.json";
+            this.richTextBox1.Text += "\r\n正在分析泵组合";
+            var ch1 = _floder + "\\" + "陈行一输.json";
             var ch1_json = File.ReadAllText(ch1);
             var ch1Pumps = JsonHelper.Json2Object<List<Model.Pump>>(ch1_json);
 
-            var ch2 = folder + "\\" + "陈行二输.json";
+            var ch2 = _floder + "\\" + "陈行二输.json";
             var ch2_json = File.ReadAllText(ch2);
             var ch2Pumps = JsonHelper.Json2Object<List<Model.Pump>>(ch2_json);
 
@@ -35,18 +36,90 @@
             });
         }
 
-        private void btnAnaConclusion_Click(object sender, EventArgs e)
+
+
+
+        private void btnAnaCh1Combine_Click(object sender, EventArgs e)
         {
-            this.richTextBox1.Text += "正在分析泵组合结论";
+            var ch1 = _floder + "\\" + "陈行一输.json";
+            var ch1_json = File.ReadAllText(ch1);
+            var ch1Pumps = JsonHelper.Json2Object<List<Model.Pump>>(ch1_json);
+            this.richTextBox1.Text += "\r\n正在分析1输水泵组合";
+            Task.Run(() =>
+            {
+                var helper = new Algorithm.SchedulingAnaHelper();
+                helper.AnaCombine(ch1Pumps);
+                this.Invoke(() =>
+                {
+                    this.richTextBox1.Text += "\r\n分析1输水泵组合完毕";
+                });
+            });
+        }
+
+
+        private void btnAnaCh2Combine_Click(object sender, EventArgs e)
+        {
+            var ch2 = _floder + "\\" + "陈行二输.json";
+            var ch2_json = File.ReadAllText(ch2);
+            var ch2Pumps = JsonHelper.Json2Object<List<Model.Pump>>(ch2_json);
+
+            this.richTextBox1.Text += "\r\n正在分析2输水泵组合";
+            Task.Run(() =>
+            {
+                var helper = new Algorithm.SchedulingAnaHelper();
+                helper.AnaCombine(ch2Pumps);
+                this.Invoke(() =>
+                {
+                    this.richTextBox1.Text += "\r\n分析2输水泵组合完毕";
+                });
+            });
+        }
+
+
+        private void btnAnaChConclusion_Click(object sender, EventArgs e)
+        {
+            this.richTextBox1.Text += "\r\n正在分析全部泵组合结论";
             Task.Run(() =>
             {
                 var helper = new Algorithm.SchedulingAnaHelper();
                 helper.AnaConclusion();
                 this.Invoke(() =>
                 {
-                    this.richTextBox1.Text += "\r\n泵组合分析完毕";
+                    this.richTextBox1.Text += "\r\n全部泵组合分析完毕";
                 });
             });
         }
+
+        private void btnAna_Click(object sender, EventArgs e)
+        {
+            if (!double.TryParse(this.txtFlow.Text, out double targetFlow))
+            {
+                MessageBox.Show("请输入流量!");
+                return;
+            }
+            if (!double.TryParse(this.txtHead.Text, out double targetHead))
+            {
+                MessageBox.Show("请输入压力!");
+                return;
+            }
+            var combine = this.txtOpenCombineList.Text.Trim();
+            if (string.IsNullOrEmpty(combine))
+            {
+                MessageBox.Show("请输入泵组合!");
+                return;
+            }
+            var combineList = IntListHelper.ToList(combine);
+            if (combineList == null || combineList.Count < 1)
+            {
+                MessageBox.Show("请输入有效泵组合!\r\n','号间隔!");
+                return;
+            }
+            var ch1 = _floder + "\\" + "陈行一输.json";
+            var ch1_json = File.ReadAllText(ch1);
+            var ch1Pumps = JsonHelper.Json2Object<List<Model.Pump>>(ch1_json);
+
+            var helper = new Algorithm.SchedulingHelper();
+            helper.Ana(ch1Pumps, targetFlow, targetHead, combineList);
+        }
     }
 }
\ No newline at end of file

--
Gitblit v1.9.3