From 7ae4a1016ac49599caa7dacb2c3256e9744175c4 Mon Sep 17 00:00:00 2001
From: Shuxia Ning <NingShuxia0927@outlook.com>
Date: 星期五, 08 十一月 2024 13:07:36 +0800
Subject: [PATCH] 11

---
 WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/06-simulation/XhsProjectSimulationCorePage.cs | 2146 +++++++++++++++++++++++++++++++++++++++++++++++++++++------
 1 files changed, 1,916 insertions(+), 230 deletions(-)

diff --git a/WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/06-simulation/XhsProjectSimulationCorePage.cs b/WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/06-simulation/XhsProjectSimulationCorePage.cs
index 6f4ef9d..e897094 100644
--- a/WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/06-simulation/XhsProjectSimulationCorePage.cs
+++ b/WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/06-simulation/XhsProjectSimulationCorePage.cs
@@ -1,7 +1,13 @@
 锘縢lobal using Yw.EPAnet;
 using DevExpress.Mvvm.Native;
+using DevExpress.Xpo.Helpers;
 using DevExpress.XtraRichEdit.Layout;
+using DevExpress.XtraSpreadsheet.Commands;
 using HStation.WinFrmUI.PhartRelation;
+using System.Diagnostics;
+using System.Windows.Media.Media3D;
+using Yw.Pump;
+using Yw.Vmo;
 using Yw.WinFrmUI.Bimface;
 using Yw.WinFrmUI.Hydro;
 
@@ -22,9 +28,9 @@
         private HStation.Vmo.XhsProjectSiteVmo _projectSite = null;//椤圭洰绔�
         private Yw.Model.HydroModelInfo _hydroInfo = null;//姘村姏淇℃伅
 
-        private Yw.Model.HydroParterInfo _parter = null;
-        private Yw.WinFrmUI.HydroCheckResult _checkResult = null;
-        private Yw.EPAnet.CalcuResult _calcuResult = null;
+
+        private Yw.WinFrmUI.HydroCheckResult _checkResult = null;//妫�鏌ョ粨鏋�
+        private Yw.EPAnet.CalcuResult _calcuResult = null;//璁$畻缁撴灉
 
         /// <summary>
         /// 缁戝畾鏁版嵁
@@ -58,7 +64,7 @@
         /// <summary>
         /// 鍒濆鍖栨暟鎹�
         /// </summary>
-        public override async void InitialDataSource()
+        public override void InitialDataSource()
         {
             base.InitialDataSource();
             if (_project == null)
@@ -71,6 +77,7 @@
             ShowPropertyCtrl();
 
         }
+
 
         #region Bimface
 
@@ -98,7 +105,7 @@
                     {
                         return;
                     }
-                    _parter = obj;
+                    _selectedParter = obj;
                     ShowProperty();
                 };
             }
@@ -111,6 +118,11 @@
             var bimfaceCtrl = await GetBimfaceCtrl();
             this.tabPageBimface.Controls.Clear();
             this.tabPageBimface.Controls.Add(bimfaceCtrl);
+        }
+
+        private void SelectBimfaceParter()
+        {
+
         }
 
         #endregion
@@ -135,7 +147,7 @@
                         return;
                     }
                     var allParterList = _hydroInfo.GetAllParters();
-                    _parter = allParterList?.Find(x => x.Code == obj?.FirstOrDefault());
+                    _selectedParter = allParterList?.Find(x => x.Code == obj?.FirstOrDefault());
                     ShowProperty();
                 };
             }
@@ -152,7 +164,7 @@
 
         #endregion
 
-        #region 灞炴�ч潰鏉�
+        #region 鏋勪欢灞炴��
 
         //灞炴�ф帶浠�
         private XhsProjectSimulationPropertyCtrl _propertyCtrl = null;
@@ -164,7 +176,7 @@
             {
                 _propertyCtrl = new XhsProjectSimulationPropertyCtrl();
                 _propertyCtrl.Dock = DockStyle.Fill;
-                _propertyCtrl.InitialData(() => _hydroInfo, () => GetAllCalcuResultList());
+                _propertyCtrl.InitialData(() => _hydroInfo, () => GetCalcuResultList());
                 _propertyCtrl.BlinkLinkParterEvent += async (code, linkCode) =>
                 { //寮鸿皟杩炴帴缁勪欢
                     if (string.IsNullOrEmpty(code))
@@ -213,6 +225,23 @@
                     await Task.Delay(5000);
                     await _bimfaceCtrl?.ClearBlinkComponents();
                 };
+                _propertyCtrl.PropertyValueChangedEvent += (parter) =>
+                {
+                    if (parter == null)
+                    {
+                        return;
+                    }
+                    UpdateParterListProperty(parter);
+                    AutoApplyGrading();
+                };
+                _propertyCtrl.ViewParterEvent += (parter) =>
+                {
+                    if (parter == null)
+                    {
+                        return;
+                    }
+                    _bimfaceCtrl?.ZoomToComponent(parter.Code);
+                };
             }
             return _propertyCtrl;
         }
@@ -228,12 +257,6 @@
             this.docPnlRight.Width = 300;
         }
 
-        //灞炴�ч潰鏉挎寜閽�
-        private void barBtnProperty_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
-        {
-            ShowPropertyCtrl();
-        }
-
         //鏄剧ず灞炴��
         private void ShowProperty()
         {
@@ -245,50 +268,122 @@
             {
                 ShowPropertyCtrl();
             }
-
-            if (_parter == null)
+            if (_selectedParter == null)
             {
-                _propertyCtrl?.SelectParter(null);
+                _propertyCtrl?.CancelSelectParter();
                 return;
             }
+            _propertyCtrl?.SelectParter(_selectedParter.Code);
 
-            _propertyCtrl?.SelectParter(_parter.Code);
-            if (_calcuResult != null)
+            var allCalcuResultList = GetCalcuResultList();
+            if (allCalcuResultList != null && allCalcuResultList.Count > 0)
             {
-                if (_calcuResult.Succeed)
+                var calcuResult = allCalcuResultList.Find(x => x.Code == _selectedParter.Code);
+                if (calcuResult != null)
                 {
-                    var allCalcuParterList = _calcuResult.GetParterList();
-                    var calcuParter = allCalcuParterList.Find(x => x.Id == _parter.Code);
-                    if (calcuParter != null)
-                    {
-                        IHydroCalcuResult calcuProperty = null;
-                        if (calcuParter is Yw.EPAnet.CalcuNode calcuNode)
-                        {
-                            var calcuNodeProperty = new Yw.WinFrmUI.HydroCalcuNodeResult();
-                            calcuNodeProperty.Code = _parter.Code;
-                            calcuNodeProperty.CalcuPress = calcuNode.Press;
-                            calcuNodeProperty.CalcuDemand = calcuNode.Demand;
-                            calcuNodeProperty.CalcuHead = calcuNode.Head;
-                            calcuProperty = calcuNodeProperty;
-                        }
-                        else if (calcuParter is Yw.EPAnet.CalcuLink calcuLink)
-                        {
-                            var calcuLinkProperty = new Yw.WinFrmUI.HydroCalcuLinkResult();
-                            calcuLinkProperty.Code = _parter.Code;
-                            calcuLinkProperty.CalcuHeadLoss = calcuLink.Headloss;
-                            calcuLinkProperty.CalcuFlow = calcuLink.Flow;
-                            calcuLinkProperty.CalcuVelocity = calcuLink.Velocity;
-                            calcuProperty = calcuLinkProperty;
-                        }
-
-                        if (calcuProperty != null)
-                        {
-                            _propertyCtrl?.UpdateCalcuProperty(calcuProperty);
-                        }
-                    }
+                    _propertyCtrl?.UpdateCalcuProperty(calcuResult);
                 }
             }
+        }
 
+
+
+        #endregion
+
+        #region 閫夋嫨鏋勪欢
+
+        //閫夋嫨鏋勪欢
+        private Yw.Model.HydroParterInfo _selectedParter = null;
+
+        //鏇存柊閫夋嫨缁勪欢灞炴��
+        private void UpdateSelectedParterProperty()
+        {
+            if (_selectedParter == null)
+            {
+                return;
+            }
+            _propertyCtrl?.UpdateProperty(); 
+        }
+
+        //鏇存柊閫夋嫨缁勪欢璁$畻灞炴��
+        private void UpdateSelectedParterCalcuProperty()
+        {
+            if (_selectedParter == null)
+            {
+                return;
+            }
+            var allCalcuResultList = GetCalcuResultList();
+            if (allCalcuResultList == null || allCalcuResultList.Count < 1)
+            {
+                return;
+            }
+            var calcuResult = allCalcuResultList.Find(x => x.Code == _selectedParter.Code);
+            if (calcuResult == null)
+            {
+                return;
+            }
+            _propertyCtrl?.UpdateCalcuProperty(calcuResult);
+        }
+
+        //鏇存柊鏋勪欢鍒楄〃灞炴��
+        private void UpdateParterListProperty()
+        {
+            if (this.docPnlBottom.Visibility != DevExpress.XtraBars.Docking.DockVisibility.Visible)
+            {
+                return;
+            }
+            var parterListCtrl = this.controlContainerBottom.Controls[0] as Yw.WinFrmUI.HydroParterListCtrl;
+            if (parterListCtrl == null)
+            {
+                return;
+            }
+            parterListCtrl.UpdateProperty();
+        }
+
+        //鏇存柊鏋勪欢鍒楄〃灞炴��
+        private void UpdateParterListProperty(Yw.Model.HydroParterInfo parter)
+        {
+            if (this.docPnlBottom.Visibility != DevExpress.XtraBars.Docking.DockVisibility.Visible)
+            {
+                return;
+            }
+            var parterListCtrl = this.controlContainerBottom.Controls[0] as Yw.WinFrmUI.HydroParterListCtrl;
+            if (parterListCtrl == null)
+            {
+                return;
+            }
+            parterListCtrl.UpdateProperty(parter);
+        }
+
+        //鏇存柊鏋勪欢鍒楄〃灞炴��
+        private void UpdateParterListProperty(List<Yw.Model.HydroParterInfo> parterList)
+        {
+            if (this.docPnlBottom.Visibility != DevExpress.XtraBars.Docking.DockVisibility.Visible)
+            {
+                return;
+            }
+            var parterListCtrl = this.controlContainerBottom.Controls[0] as Yw.WinFrmUI.HydroParterListCtrl;
+            if (parterListCtrl == null)
+            {
+                return;
+            }
+            parterListCtrl.UpdateProperty(parterList);
+        }
+
+        //鏇存柊鏋勪欢鍒楄〃璁$畻灞炴��
+        private void UpdateParterListCalcuProperty()
+        {
+            if (this.docPnlBottom.Visibility != DevExpress.XtraBars.Docking.DockVisibility.Visible)
+            {
+                return;
+            }
+            var parterListCtrl = this.controlContainerBottom.Controls[0] as Yw.WinFrmUI.HydroParterListCtrl;
+            if (parterListCtrl == null)
+            {
+                return;
+            }
+            var allCalcuResultList = GetCalcuResultList();
+            parterListCtrl.UpdateCalcuProperty(allCalcuResultList);
         }
 
         #endregion
@@ -309,11 +404,11 @@
                         return;
                     }
                     var allParterList = _hydroInfo.GetAllParters();
-                    _parter = allParterList?.Find(x => x.Code == code);
+                    _selectedParter = allParterList?.Find(x => x.Code == code);
                     var elementIds = new List<string>();
-                    if (_parter != null)
+                    if (_selectedParter != null)
                     {
-                        elementIds.Add(_parter.Code);
+                        elementIds.Add(_selectedParter.Code);
                     }
                     await _bimfaceCtrl?.ZoomAndSelectComponents(elementIds);
                     ShowProperty();
@@ -342,7 +437,7 @@
             }
             this.controlContainerBottom.Controls.Clear();
             var matchingListCtrl = GetMatchingListCtrl();
-            var input = AssetsMatchingParasHelper.Create(_hydroInfo, GetAllCalcuResultList());
+            var input = AssetsMatchingParasHelper.Create(_hydroInfo, GetCalcuResultList());
             matchingListCtrl.SetBindingData(input);
             this.controlContainerBottom.Controls.Add(matchingListCtrl);
             this.docPnlBottom.Visibility = DevExpress.XtraBars.Docking.DockVisibility.Visible;
@@ -372,7 +467,7 @@
                         return;
                     }
                     var allParterList = _hydroInfo.GetAllParters();
-                    _parter = allParterList?.Find(x => x.Code == parter.Code);
+                    _selectedParter = allParterList?.Find(x => x.Code == parter.Code);
                     var elementIds = new List<string>() { parter.Code };
                     await _bimfaceCtrl?.ZoomAndSelectComponents(elementIds);
                     ShowProperty();
@@ -381,7 +476,7 @@
                 {
                     var codes = parters?.Select(x => x.Code).Distinct().ToList();
                     await _bimfaceCtrl?.ZoomAndSelectComponents(codes);
-                    _parter = null;
+                    _selectedParter = null;
                     ShowProperty();
                 };
             }
@@ -465,15 +560,15 @@
                     var elementIds = new List<string>();
                     if (string.IsNullOrEmpty(code))
                     {
-                        _parter = null;
+                        _selectedParter = null;
                     }
                     else
                     {
                         var allParterList = _hydroInfo.GetAllParters();
-                        _parter = allParterList?.Find(x => x.Code == code);
-                        if (_parter != null)
+                        _selectedParter = allParterList?.Find(x => x.Code == code);
+                        if (_selectedParter != null)
                         {
-                            elementIds.Add(_parter.Code);
+                            elementIds.Add(_selectedParter.Code);
                         }
                     }
                     await _bimfaceCtrl?.ZoomAndSelectComponents(elementIds);
@@ -483,7 +578,7 @@
             return _checkCtrl;
         }
 
-        //鏄剧ず鏍¢獙鎺т欢
+        //鏄剧ず妫�鏌ユ帶浠�
         private void ShowCheckCtrl()
         {
             if (_checkResult == null)
@@ -495,12 +590,12 @@
             this.controlContainerBottom.Controls.Clear();
             this.controlContainerBottom.Controls.Add(checkCtrl);
             this.docPnlBottom.Visibility = DevExpress.XtraBars.Docking.DockVisibility.Visible;
-            this.docPnlBottom.Text = "鏍¢獙缁撴灉";
+            this.docPnlBottom.Text = "妫�鏌ョ粨鏋�";
             this.docPnlBottom.Height = 350;
 
         }
 
-        //姘村姏楠岃瘉
+        //姘村姏妫�鏌�
         private void barBtnHydroCheck_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
         {
             if (_hydroInfo == null)
@@ -522,7 +617,17 @@
             {
                 return;
             }
+            Stopwatch sw = new Stopwatch();
+            sw.Start();
+
+
             var id = await BLLFactory<Yw.BLL.HydroModelInfo>.Instance.Save(_hydroInfo);
+
+            //鑰楁椂宸ㄥぇ鐨勪唬鐮�  
+
+            sw.Stop();
+            TimeSpan ts2 = sw.Elapsed;
+            Console.WriteLine("Stopwatch鎬诲叡鑺辫垂{0}ms.", ts2.TotalMilliseconds);
             if (id < 1)
             {
                 TipFormHelper.ShowError("淇濆瓨澶辫触锛�");
@@ -548,14 +653,14 @@
                 _parterListCtrl.Dock = DockStyle.Fill;
                 _parterListCtrl.HydroClickEvent += async (parter) =>
                 {
-                    if (_hydroInfo == null)
-                    {
-                        return;
-                    }
-                    var allParterList = _hydroInfo.GetAllParters();
-                    _parter = allParterList?.Find(x => x.Code == parter.Code);
-                    await _bimfaceCtrl?.ZoomAndSelectComponents(new List<string>() { _parter.Code });
+                    _selectedParter = parter;
+                    await _bimfaceCtrl?.ZoomAndSelectComponent(_selectedParter.Code);
                     ShowProperty();
+                };
+                _parterListCtrl.HydroChangedEvent += (parterList) =>
+                {
+                    UpdateSelectedParterProperty();
+                    AutoApplyGrading();
                 };
             }
             return _parterListCtrl;
@@ -568,8 +673,17 @@
             {
                 return;
             }
+            var allCalcuResultList = GetCalcuResultList();
             var parterListCtrl = GetParterListCtrl();
-            parterListCtrl.SetBindingData(_hydroInfo, GetAllCalcuResultList());
+            parterListCtrl.SetBindingData(_hydroInfo, allCalcuResultList);
+            if (allCalcuResultList == null || allCalcuResultList.Count < 1)
+            {
+                parterListCtrl.SetNormalView();
+            }
+            else
+            {
+                parterListCtrl.SetCalcuView();
+            }
             this.controlContainerBottom.Controls.Clear();
             this.controlContainerBottom.Controls.Add(parterListCtrl);
             this.docPnlBottom.Visibility = DevExpress.XtraBars.Docking.DockVisibility.Visible;
@@ -615,14 +729,14 @@
             //姘村簱
             this.barBtnSetReservoirList.ItemClick += delegate
             {
-                var dlg = new HydroReservoirBulkSetListDlg();
-                dlg.ShowDialog();
+                //var dlg = new HydroReservoirBulkSetListDlg();
+                //dlg.ShowDialog();
             };
             //姘存睜
             this.barBtnSetTankList.ItemClick += delegate
             {
-                var dlg = new HydroTankBulkSetListDlg();
-                dlg.ShowDialog();
+                //var dlg = new HydroTankBulkSetListDlg();
+                //dlg.ShowDialog();
             };
             //姘寸
             this.barBtnSetWaterboxList.ItemClick += delegate
@@ -631,38 +745,167 @@
                 {
                     return;
                 }
-                var dlg = new HydroWaterboxBulkSetListDlg();
+                var dlg = new SetHydroWaterboxListDlg();
                 dlg.SetBindingData(_hydroInfo);
+                dlg.HydroClickEvent += async (obj) =>
+                {
+                    if (obj == null)
+                    {
+                        return;
+                    }
+                    _selectedParter = obj;
+                    await _bimfaceCtrl?.ZoomAndSelectComponent(obj.Code);
+                    ShowProperty();
+                };
+                dlg.HydroChangedEvent += (obj) =>
+                {
+
+                };
                 dlg.ShowDialog();
             };
             //杩炴帴鑺傜偣
             this.barBtnSetJunctionList.ItemClick += delegate
             {
-                var dlg = new HydroJunctionBulkSetListDlg();
-                dlg.ShowDialog();
+                //var dlg = new HydroJunctionBulkSetListDlg();
+                //dlg.ShowDialog();
             };
             //闂峰ご
             this.barBtnSetBluntheadList.ItemClick += delegate
             {
-                var dlg = new HydroBluntheadBulkSetListDlg();
+                if (_hydroInfo == null)
+                {
+                    return;
+                }
+                var dlg = new SetHydroBluntheadListDlg();
+                dlg.SetBindingData(_hydroInfo);
+                dlg.HydroClickEvent += async (obj) =>
+                {
+                    if (obj == null)
+                    {
+                        return;
+                    }
+                    _selectedParter = obj;
+                    await _bimfaceCtrl?.ZoomAndSelectComponent(obj.Code);
+                    ShowProperty();
+                };
+                dlg.HydroChangedEvent += (obj) =>
+                {
+
+                };
                 dlg.ShowDialog();
             };
             //寮ご
             this.barBtnSetElbowsList.ItemClick += delegate
             {
-                var dlg = new HydroElbowBulkSetListDlg();
+                if (_hydroInfo == null)
+                {
+                    return;
+                }
+                var dlg = new SetHydroElbowListDlg();
+                dlg.SetBindingData(_hydroInfo);
+                dlg.HydroClickEvent += async (obj) =>
+                {
+                    if (obj == null)
+                    {
+                        return;
+                    }
+                    _selectedParter = obj;
+                    await _bimfaceCtrl?.ZoomAndSelectComponent(obj.Code);
+                    ShowProperty();
+                };
+                dlg.HydroChangedEvent += (obj) =>
+                {
+
+                };
                 dlg.ShowDialog();
             };
             //涓夐��
             this.barBtnSetThreelinkList.ItemClick += delegate
             {
-                var dlg = new HydroThreelinkBulkSetListDlg();
+                if (_hydroInfo == null)
+                {
+                    return;
+                }
+                var dlg = new SetHydroThreelinkListDlg();
+                dlg.SetBindingData(_hydroInfo);
                 dlg.ShowDialog();
             };
             //鍥涢��
             this.barBtnSetFourlinkList.ItemClick += delegate
             {
-
+                if (_hydroInfo == null)
+                {
+                    return;
+                }
+                var dlg = new SetHydroFourlinkListDlg();
+                dlg.SetBindingData(_hydroInfo);
+                dlg.ShowDialog();
+            };
+            //姘磋〃
+            this.barBtnSetMeterList.ItemClick += delegate
+            {
+                if (_hydroInfo == null)
+                {
+                    return;
+                }
+                var dlg = new SetHydroMeterListDlg();
+                dlg.SetBindingData(_hydroInfo);
+                dlg.ShowDialog();
+            };
+            //娴侀噺璁�
+            this.barBtnSetFlowmeterList.ItemClick += delegate
+            {
+                if (_hydroInfo == null)
+                {
+                    return;
+                }
+                var dlg = new SetHydroFlowmeterListDlg();
+                dlg.SetBindingData(_hydroInfo);
+                dlg.ShowDialog();
+            };
+            //鍘嬪姏琛�
+            this.barBtnSetPressmeterList.ItemClick += delegate
+            {
+                if (_hydroInfo == null)
+                {
+                    return;
+                }
+                var dlg = new SetHydroPressmeterListDlg();
+                dlg.SetBindingData(_hydroInfo);
+                dlg.ShowDialog();
+            };
+            //绠¢亾
+            this.barBtnSetPipeList.ItemClick += delegate
+            {
+                if (_hydroInfo == null)
+                {
+                    return;
+                }
+                var dlg = new SetHydroPipeListDlg();
+                dlg.SetBindingData(_hydroInfo);
+                dlg.ShowDialog();
+            };
+            //姘存车
+            this.barBtnSetPumpList.ItemClick += delegate
+            {
+                if (_hydroInfo == null)
+                {
+                    return;
+                }
+                var dlg = new SetHydroPumpListDlg();
+                dlg.SetBindingData(_hydroInfo);
+                dlg.ShowDialog();
+            };
+            //闃�闂�
+            this.barBtnSetValveList.ItemClick += delegate
+            {
+                if (_hydroInfo == null)
+                {
+                    return;
+                }
+                var dlg = new SetHydroValveListDlg();
+                dlg.SetBindingData(_hydroInfo);
+                dlg.ShowDialog();
             };
         }
 
@@ -888,7 +1131,7 @@
             {
                 return;
             }
-            var allCalcuResultList = GetAllCalcuResultList();
+            var allCalcuResultList = GetCalcuResultList();
             var vmList = new List<XhsSinglePumpViewModel>();
             foreach (var pump in _hydroInfo.Pumps)
             {
@@ -947,7 +1190,7 @@
 
             }
 
-            var dlg = new PumpParallelChartDlg();
+            var dlg = new PumpParallelAnalyDlg();
             dlg.SetBindingData(vmList);
             dlg.ReloadDataEvent += (list) =>
             {
@@ -969,6 +1212,72 @@
         #endregion
 
         #region 姘村姏璁$畻
+
+
+        #region 鍓嶆彁鏉′欢
+
+        //鏄剧ず璁$畻鍓嶆彁鏉′欢绐椾綋
+        private void ShowCalcuPrefixDlg()
+        {
+            if (_hydroInfo == null)
+            {
+                return;
+            }
+            var dlg = new HStation.WinFrmUI.SetHydroCalcuPrefixDlg1();
+            dlg.SetBindingData(_hydroInfo);
+            dlg.HydroViewEvent += async (parter) =>
+            {
+                _selectedParter = parter;
+                if (_selectedParter != null)
+                {
+                    await _bimfaceCtrl?.ZoomAndSelectComponents(new List<string>() { _selectedParter.Code });
+                }
+                ShowProperty();
+            };
+            dlg.HydroCalcuEvent += async () =>
+            {
+                if (_hydroInfo == null)
+                {
+                    return;
+                }
+
+                //鏍¢獙
+                _checkResult = _hydroInfo.Check();
+                if (!_checkResult.Succeed)
+                {
+                    ShowCheckCtrl();
+                    TipFormHelper.ShowWarn("鏍¢獙澶辫触锛岃妫�鏌ュ悗閲嶈瘯");
+                    return;
+                }
+
+                WaitFormHelper.ShowWaitForm(this, "姝e湪璁$畻鍒嗘瀽涓紝璇风◢鍊�...");
+
+ 
+                //await Task.Delay(5000);
+
+                var netWork = Yw.Hydro.ParseHelper.ToNetwork(_hydroInfo);
+                _calcuResult = netWork.Calcu();
+
+                WaitFormHelper.HideWaitForm();
+                if (_calcuResult.Succeed)
+                {
+                    GetCalcuResultList(false);
+                    await _bimfaceCtrl?.SetLogicCalcuCustomLabels(_calcuResult);
+                    TipFormHelper.ShowSucceed("璁$畻鎴愬姛锛�");
+                }
+                else
+                {
+                    ShowCalcuFailedCtrl();
+                    TipFormHelper.ShowError("璁$畻澶辫触锛�");
+                }
+
+            };
+            dlg.ShowDialog();
+        }
+
+        #endregion
+
+        #region 璁$畻澶辫触
 
         //璁$畻澶辫触鎺т欢
         private HydroCalcuFailedCtrl _calcuFailedCtrl = null;
@@ -1008,8 +1317,16 @@
             this.docPnlBottom.Height = 350;
         }
 
+        #endregion
+
+        #region 璁$畻缁撴灉
+
+        //鎵�鏈夎绠楃粨鏋滃垪琛�
+        private List<HydroCalcuResult> _allCalcuResultList = null;
+
         //鑾峰彇璁$畻缁撴灉
-        private List<IHydroCalcuResult> GetAllCalcuResultList()
+        //true 浣跨敤缂撳瓨锛宖alse 涓嶄娇鐢ㄧ紦瀛�
+        private List<HydroCalcuResult> GetCalcuResultList(bool isCache = true)
         {
             if (_hydroInfo == null)
             {
@@ -1023,110 +1340,156 @@
             {
                 return default;
             }
-            var list = new List<IHydroCalcuResult>();
+            if (isCache)
+            {
+                return _allCalcuResultList;
+            }
+
+            _allCalcuResultList = new List<HydroCalcuResult>();
+
+            //鑺傜偣
             var allNodeList = _hydroInfo.GetAllNodes();
             if (allNodeList != null && allNodeList.Count > 0)
             {
-                var allCalcuNodeList = _calcuResult.NodeList;
-                if (allCalcuNodeList != null && allCalcuNodeList.Count > 0)
+                foreach (var node in allNodeList)
                 {
-                    foreach (var node in allNodeList)
+                    var calcuNode = _calcuResult.NodeList?.Find(x => x.Id == node.Code);
+                    if (calcuNode != null)
                     {
-                        var calcuNode = allCalcuNodeList.Find(x => x.Id == node.Code);
-                        if (calcuNode != null)
+                        var calcuResult = new HydroCalcuNodeResult()
                         {
-                            var calcuResult = new HydroCalcuNodeResult()
-                            {
-                                Code = node.Code,
-                                CalcuPress = calcuNode.Press,
-                                CalcuHead = calcuNode.Head,
-                                CalcuDemand = calcuNode.Demand
-                            };
-                            list.Add(calcuResult);
-                        }
+                            Code = node.Code,
+                            CalcuPress = calcuNode.Press,
+                            CalcuHead = calcuNode.Head,
+                            CalcuDemand = calcuNode.Demand
+                        };
+                        _allCalcuResultList.Add(calcuResult);
                     }
                 }
             }
 
-            var allListList = _hydroInfo.GetAllLinks();
-            if (allListList != null && allListList.Count > 0)
+            //绠℃
+            var allLinkList = _hydroInfo.GetAllLinks();
+            if (allLinkList != null && allLinkList.Count > 0)
             {
-                var allCalcuLinkList = _calcuResult.LinkList;
-                if (allCalcuLinkList != null && allCalcuLinkList.Count > 0)
+                foreach (var link in allLinkList)
                 {
-                    foreach (var link in allListList)
+                    var calcuLink = _calcuResult.LinkList?.Find(x => x.Id == link.Code);
+                    if (calcuLink != null)
                     {
-                        var calcuLink = allCalcuLinkList.Find(x => x.Id == link.Code);
-                        if (calcuLink != null)
+                        var calcuResult = new HydroCalcuLinkResult()
                         {
-                            var calcuResult = new HydroCalcuLinkResult()
-                            {
-                                Code = link.Code,
-                                CalcuFlow = calcuLink.Flow,
-                                CalcuVelocity = calcuLink.Velocity,
-                                CalcuHeadLoss = calcuLink.Headloss
-                            };
-                            list.Add(calcuResult);
-                        }
+                            Code = link.Code,
+                            CalcuFlow = calcuLink.Flow,
+                            CalcuVelocity = calcuLink.Velocity,
+                            CalcuHeadLoss = calcuLink.Headloss
+                        };
+                        _allCalcuResultList.Add(calcuResult);
                     }
                 }
             }
 
-            return list;
+            //娴侀噺璁�
+            var allFlowmeterList = _hydroInfo.Flowmeters;
+            if (allFlowmeterList != null && allFlowmeterList.Count > 0)
+            {
+                foreach (var flowmeter in allFlowmeterList)
+                {
+                    var calcuFlowmeterResult = _allCalcuResultList.Find(x => x.Code == flowmeter.Code) as HydroCalcuNodeResult;
+                    if (calcuFlowmeterResult != null)
+                    {
+                        var calcuFlowmeterNewResult = new HydroCalcuFlowmeterResult(calcuFlowmeterResult);
+                        var calcuFlowmeterLinkResultList = new List<HydroCalcuLinkResult>();
+                        var flowmeterLinkList = allLinkList?.Where(x => x.StartCode == flowmeter.Code || x.EndCode == flowmeter.Code).ToList();
+                        if (flowmeterLinkList != null && flowmeterLinkList.Count > 0)
+                        {
+                            foreach (var flowmeterLink in flowmeterLinkList)
+                            {
+                                var calcuFlowmeterLinkResult = _allCalcuResultList.Find(x => x.Code == flowmeterLink.Code) as HydroCalcuLinkResult;
+                                if (calcuFlowmeterLinkResult != null)
+                                {
+                                    calcuFlowmeterLinkResultList.Add(calcuFlowmeterLinkResult);
+                                }
+                            }
+                        }
+                        if (calcuFlowmeterLinkResultList.Exists(x => x.CalcuFlow.HasValue))
+                        {
+                            calcuFlowmeterNewResult.CalcuQ = calcuFlowmeterLinkResultList.Where(x => x.CalcuFlow.HasValue).Average(x => x.CalcuFlow.Value);
+                        }
+                        _allCalcuResultList.Remove(calcuFlowmeterResult);
+                        _allCalcuResultList.Add(calcuFlowmeterNewResult);
+                    }
+                }
+            }
+
+            //鍘嬪姏琛�
+            var allPressmeterList = _hydroInfo.Pressmeters;
+            if (allPressmeterList != null && allPressmeterList.Count > 0)
+            {
+                foreach (var pressmeter in allPressmeterList)
+                {
+                    var calcuPressmeterResult = _allCalcuResultList.Find(x => x.Code == pressmeter.Code) as HydroCalcuNodeResult;
+                    if (calcuPressmeterResult != null)
+                    {
+                        var calcuPressmeterNewResult = new HydroCalcuPressmeterResult(calcuPressmeterResult);
+                        calcuPressmeterNewResult.CalcuPr = calcuPressmeterResult.CalcuPress;
+                        _allCalcuResultList.Remove(calcuPressmeterResult);
+                        _allCalcuResultList.Add(calcuPressmeterNewResult);
+                    }
+                }
+            }
+
+            //姘存车
+            var allPumpList = _hydroInfo.Pumps;
+            if (allPumpList != null && allPumpList.Count > 0)
+            {
+                foreach (var pump in allPumpList)
+                {
+                    var calcuPumpResult = _allCalcuResultList.Find(x => x.Code == pump.Code) as HydroCalcuLinkResult;
+                    if (calcuPumpResult != null)
+                    {
+                        var calcuPumpNewResult = new HydroCalcuPumpResult(calcuPumpResult);
+                        calcuPumpNewResult.CalcuQ = calcuPumpResult.CalcuFlow;
+                        if (calcuPumpNewResult.CalcuQ.HasValue)
+                        {
+                            var calcuNodeStartResult = _allCalcuResultList.Find(x => x.Code == pump.StartCode) as HydroCalcuNodeResult;
+                            var calcuNodeEndResult = _allCalcuResultList.Find(x => x.Code == pump.EndCode) as HydroCalcuNodeResult;
+                            if (calcuNodeStartResult != null && calcuNodeEndResult != null)
+                            {
+                                if (calcuNodeStartResult.CalcuPress.HasValue && calcuNodeEndResult.CalcuPress.HasValue)
+                                {
+                                    calcuPumpNewResult.CalcuH = Math.Abs(calcuNodeStartResult.CalcuPress.Value - calcuNodeEndResult.CalcuPress.Value);
+                                }
+                                if (pump.LinkStatus == Yw.Hydro.PumpStatus.Open && pump.RatedN.HasValue)
+                                {
+                                    var curveqp = _hydroInfo.Curves?.Find(x => x.Code == pump.CurveQP);
+                                    if (curveqp != null)
+                                    {
+                                        if (curveqp.CurveData != null && curveqp.CurveData.Count > 3)
+                                        {
+                                            var point2dList = curveqp.CurveData.Select(x => new Yw.Geometry.Point2d(x.X, x.Y)).ToList();
+                                            var point2dSimularList = point2dList.GetQPPointListByN(pump.RatedN.Value, pump.RatedN.Value * pump.SpeedRatio);
+                                            var pumpCurveQp = new Yw.Pump.CurveQP(eFeatType.Cubic, point2dSimularList);
+                                            calcuPumpNewResult.CalcuP = pumpCurveQp.FeatCurve.GetPointY(calcuPumpNewResult.CalcuQ.Value);
+                                        }
+                                    }
+                                }
+                                if (calcuPumpNewResult.CalcuH.HasValue && calcuPumpNewResult.CalcuP.HasValue)
+                                {
+                                    calcuPumpNewResult.CalcuE = Yw.Pump.CalculationHelper.CalcuE(calcuPumpNewResult.CalcuQ.Value, calcuPumpNewResult.CalcuH.Value, calcuPumpNewResult.CalcuP.Value);
+                                }
+                            }
+                        }
+                        _allCalcuResultList.Remove(calcuPumpResult);
+                        _allCalcuResultList.Add(calcuPumpNewResult);
+                    }
+                }
+            }
+
+            return _allCalcuResultList;
         }
 
-        //鏄剧ず璁$畻鍓嶆彁绐椾綋
-        private async void ShowCalcuPrefixDlg()
-        {
-            if (_hydroInfo == null)
-            {
-                return;
-            }
-            var dlg = new SetHydroCalcuPrefixDlg();
-            dlg.SetBindingData(_hydroInfo);
-            dlg.HydroViewEvent += async (parter) =>
-            {
-                _parter = parter;
-                if (_parter != null)
-                {
-                    await _bimfaceCtrl?.ZoomAndSelectComponents(new List<string>() { _parter.Code });
-                }
-                ShowProperty();
-            };
-            dlg.HydroCalcuEvent += async () =>
-            {
-                if (_hydroInfo == null)
-                {
-                    return;
-                }
-
-                //鏍¢獙
-                _checkResult = _hydroInfo.Check();
-                if (!_checkResult.Succeed)
-                {
-                    ShowCheckCtrl();
-                    TipFormHelper.ShowWarn("鏍¢獙澶辫触锛岃妫�鏌ュ悗閲嶈瘯");
-                    return;
-                }
-
-                var netWork = Yw.Hydro.ParseHelper.ToNetwork(_hydroInfo);
-                _calcuResult = netWork.Calcu();
-                if (_calcuResult.Succeed)
-                {
-                    await _bimfaceCtrl?.SetLogicCalcuCustomLabels(_calcuResult);
-                    TipFormHelper.ShowSucceed("璁$畻鎴愬姛锛�");
-                }
-                else
-                {
-                    ShowCalcuFailedCtrl();
-                    TipFormHelper.ShowError("璁$畻澶辫触锛�");
-                }
-            };
-            if (dlg.ShowDialog() == DialogResult.Cancel)
-            {
-                await _bimfaceCtrl?.ClearLogicCalcuCustomLabels();
-            }
-        }
+        #endregion
 
         //姘村姏璁$畻
         private void barBtnHydroCalcu_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
@@ -1160,12 +1523,12 @@
                     {
                         var first = list.First();
                         var allParterList = _hydroInfo.GetAllParters();
-                        _parter = allParterList?.Find(x => x.Code == first.Code);
+                        _selectedParter = allParterList?.Find(x => x.Code == first.Code);
                         list.ForEach(x => elementIds.Add(x.Code));
                     }
                     else
                     {
-                        _parter = null;
+                        _selectedParter = null;
                     }
                     await _bimfaceCtrl?.ZoomAndSelectComponents(elementIds);
                     ShowProperty();
@@ -1199,22 +1562,18 @@
 
         #region 妯″瀷鏍囨敞
 
-        //鎵�鏈夋爣娉ㄥ垪琛�
-        private List<HydroMarkSetViewModel> _allMarkList = null;
+        //鎵�鏈夋爣娉ㄨ缃垪琛�
+        private List<HydroMarkSetViewModel> _allMarkSetList = null;
 
-        //鏄剧ず鏍囨敞绐椾綋
-        private async void ShowMarkDlg()
+        //鑾峰彇鏍囨敞璁剧疆鍒楄〃
+        private List<HydroMarkSetViewModel> GetMarkSetList()
         {
-            if (_hydroInfo == null)
+            if (_allMarkSetList == null)
             {
-                return;
-            }
-            if (_allMarkList == null)
-            {
-                _allMarkList = new List<HydroMarkSetViewModel>();
+                _allMarkSetList = new List<HydroMarkSetViewModel>();
                 if (_hydroInfo.Waterboxs != null && _hydroInfo.Waterboxs.Count > 0)
                 {
-                    _allMarkList.Add(new HydroMarkSetViewModel()
+                    _allMarkSetList.Add(new HydroMarkSetViewModel()
                     {
                         Code = Yw.Hydro.ParterCatalog.Waterbox,
                         Name = Yw.WinFrmUI.HydroParterCatalogHelper.GetCatalogName(Yw.Hydro.ParterCatalog.Waterbox),
@@ -1223,7 +1582,7 @@
                 }
                 if (_hydroInfo.Pumps != null && _hydroInfo.Pumps.Count > 0)
                 {
-                    _allMarkList.Add(new HydroMarkSetViewModel()
+                    _allMarkSetList.Add(new HydroMarkSetViewModel()
                     {
                         Code = Yw.Hydro.ParterCatalog.Pump,
                         Name = Yw.WinFrmUI.HydroParterCatalogHelper.GetCatalogName(Yw.Hydro.ParterCatalog.Pump),
@@ -1232,7 +1591,7 @@
                 }
                 if (_hydroInfo.Valves != null && _hydroInfo.Valves.Count > 0)
                 {
-                    _allMarkList.Add(new HydroMarkSetViewModel()
+                    _allMarkSetList.Add(new HydroMarkSetViewModel()
                     {
                         Code = Yw.Hydro.ParterCatalog.Valve,
                         Name = Yw.WinFrmUI.HydroParterCatalogHelper.GetCatalogName(Yw.Hydro.ParterCatalog.Valve),
@@ -1241,7 +1600,7 @@
                 }
                 if (_hydroInfo.Pipes != null && _hydroInfo.Pipes.Count > 0)
                 {
-                    _allMarkList.Add(new HydroMarkSetViewModel()
+                    _allMarkSetList.Add(new HydroMarkSetViewModel()
                     {
                         Code = Yw.Hydro.ParterCatalog.Pipe,
                         Name = Yw.WinFrmUI.HydroParterCatalogHelper.GetCatalogName(Yw.Hydro.ParterCatalog.Pipe),
@@ -1250,7 +1609,7 @@
                 }
                 if (_hydroInfo.Nozzles != null && _hydroInfo.Nozzles.Count > 0)
                 {
-                    _allMarkList.Add(new HydroMarkSetViewModel()
+                    _allMarkSetList.Add(new HydroMarkSetViewModel()
                     {
                         Code = Yw.Hydro.ParterCatalog.Nozzle,
                         Name = Yw.WinFrmUI.HydroParterCatalogHelper.GetCatalogName(Yw.Hydro.ParterCatalog.Nozzle),
@@ -1258,54 +1617,561 @@
                     });
                 }
             }
-            var dlg = new SetHydroMarkDlg();
-            dlg.InitialData(() => _hydroInfo);
-            dlg.SetBindingData(_allMarkList);
-            dlg.ReloadDataEvent += async (allResultList) =>
+            return _allMarkSetList;
+        }
+
+        //鎵�鏈夋爣娉ㄧ粨鏋滃垪琛�
+        private List<HydroMarkResultViewModel> _allMarkResultList = null;
+
+        //鑾峰彇鏍囨敞缁撴灉鍒楄〃
+        private List<HydroMarkResultViewModel> GetMarkResultList()
+        {
+            if (_hydroInfo == null)
             {
-                var leadLabels = allResultList?.Select(x => new LogicMarkLeadLabel(x.Code, x.Text)).ToList();
-                await _bimfaceCtrl?.SetLogicMarkLeadLabels(leadLabels);
-            };
-            if (dlg.ShowDialog() != DialogResult.OK)
-            {
-                await _bimfaceCtrl?.ClearLogicMarkLeadLabels();
+                return default;
             }
+            _allMarkResultList = new List<HydroMarkResultViewModel>();
+            var allMarkSetList = GetMarkSetList();
+            foreach (var markSet in allMarkSetList)
+            {
+                switch (markSet.Code)
+                {
+                    case Yw.Hydro.ParterCatalog.Waterbox:
+                        {
+                            if (_hydroInfo.Waterboxs != null && _hydroInfo.Waterboxs.Count > 0)
+                            {
+                                switch ((eWaterboxMarkType)markSet.MarkType)
+                                {
+                                    case eWaterboxMarkType.None:
+                                        {
+
+                                        }
+                                        break;
+                                    case eWaterboxMarkType.PoolElev:
+                                        {
+                                            _hydroInfo.Waterboxs.ForEach(t =>
+                                            {
+                                                _allMarkResultList.Add(new HydroMarkResultViewModel()
+                                                {
+                                                    Code = t.Code,
+                                                    Text = $"姹犲簳鏍囬珮:{Math.Round(t.PoolElev, 4)}m"
+                                                });
+                                            });
+                                        }
+                                        break;
+                                    case eWaterboxMarkType.InitLevel:
+                                        {
+                                            _hydroInfo.Waterboxs.ForEach(t =>
+                                            {
+                                                _allMarkResultList.Add(new HydroMarkResultViewModel()
+                                                {
+                                                    Code = t.Code,
+                                                    Text = $"鍒濆姘翠綅:{Math.Round(t.InitLevel, 4)}m"
+                                                });
+                                            });
+                                        }
+                                        break;
+                                    case eWaterboxMarkType.MinLevel:
+                                        {
+                                            _hydroInfo.Waterboxs.ForEach(t =>
+                                            {
+                                                _allMarkResultList.Add(new HydroMarkResultViewModel()
+                                                {
+                                                    Code = t.Code,
+                                                    Text = $"鏈�灏忔按浣�:{Math.Round(t.MinLevel, 4)}m"
+                                                });
+                                            });
+                                        }
+                                        break;
+                                    case eWaterboxMarkType.MaxLevel:
+                                        {
+                                            _hydroInfo.Waterboxs.ForEach(t =>
+                                            {
+                                                _allMarkResultList.Add(new HydroMarkResultViewModel()
+                                                {
+                                                    Code = t.Code,
+                                                    Text = $"鏈�楂樻按浣�:{Math.Round(t.MaxLevel, 4)}m"
+                                                });
+                                            });
+                                        }
+                                        break;
+                                    case eWaterboxMarkType.DN:
+                                        {
+                                            _hydroInfo.Waterboxs.ForEach(t =>
+                                            {
+                                                _allMarkResultList.Add(new HydroMarkResultViewModel()
+                                                {
+                                                    Code = t.Code,
+                                                    Text = $"鐩村緞:{Math.Round(t.DN, 4)}m"
+                                                });
+                                            });
+                                        }
+                                        break;
+                                    case eWaterboxMarkType.MinVol:
+                                        {
+                                            _hydroInfo.Waterboxs.ForEach(t =>
+                                            {
+                                                _allMarkResultList.Add(new HydroMarkResultViewModel()
+                                                {
+                                                    Code = t.Code,
+                                                    Text = $"鏈�灏忓绉�:{Math.Round(t.MinVol, 1)}m"
+                                                });
+                                            });
+                                        }
+                                        break;
+                                    default: break;
+                                }
+                            }
+                        }
+                        break;
+                    case Yw.Hydro.ParterCatalog.Pump:
+                        {
+                            if (_hydroInfo.Pumps != null && _hydroInfo.Pumps.Count > 0)
+                            {
+                                switch ((ePumpMarkType)markSet.MarkType)
+                                {
+                                    case ePumpMarkType.None:
+                                        {
+
+                                        }
+                                        break;
+                                    case ePumpMarkType.PumpStatus:
+                                        {
+                                            _hydroInfo.Pumps.ForEach(t =>
+                                            {
+                                                _allMarkResultList.Add(new HydroMarkResultViewModel()
+                                                {
+                                                    Code = t.Code,
+                                                    Text = $"寮�鏈虹姸鎬�:{Yw.WinFrmUI.HydroLinkStatusHelper.GetStatusName(t.LinkStatus)}"
+                                                });
+                                            });
+                                        }
+                                        break;
+                                    case ePumpMarkType.RatedP:
+                                        {
+                                            _hydroInfo.Pumps.ForEach(t =>
+                                            {
+                                                _allMarkResultList.Add(new HydroMarkResultViewModel()
+                                                {
+                                                    Code = t.Code,
+                                                    Text = $"棰濆畾鍔熺巼:{t.RatedP}kW"
+                                                });
+                                            });
+                                        }
+                                        break;
+                                    case ePumpMarkType.RatedQ:
+                                        {
+                                            _hydroInfo.Pumps.ForEach(t =>
+                                            {
+                                                _allMarkResultList.Add(new HydroMarkResultViewModel()
+                                                {
+                                                    Code = t.Code,
+                                                    Text = $"棰濆畾娴侀噺:{t.RatedQ}m鲁/h"
+                                                });
+                                            });
+                                        }
+                                        break;
+                                    case ePumpMarkType.RatedH:
+                                        {
+                                            _hydroInfo.Pumps.ForEach(t =>
+                                            {
+                                                _allMarkResultList.Add(new HydroMarkResultViewModel()
+                                                {
+                                                    Code = t.Code,
+                                                    Text = $"棰濆畾鎵▼:{t.RatedH}m"
+                                                });
+                                            });
+                                        }
+                                        break;
+                                    case ePumpMarkType.RatedN:
+                                        {
+                                            _hydroInfo.Pumps.ForEach(t =>
+                                            {
+                                                _allMarkResultList.Add(new HydroMarkResultViewModel()
+                                                {
+                                                    Code = t.Code,
+                                                    Text = $"棰濆畾杞��:{t.RatedN}r/min"
+                                                });
+                                            });
+                                        }
+                                        break;
+                                    case ePumpMarkType.RatedHz:
+                                        {
+                                            _hydroInfo.Pumps.ForEach(t =>
+                                            {
+                                                _allMarkResultList.Add(new HydroMarkResultViewModel()
+                                                {
+                                                    Code = t.Code,
+                                                    Text = $"棰濆畾棰戠巼:{t.RatedHz}"
+                                                });
+                                            });
+                                        }
+                                        break;
+                                    case ePumpMarkType.CurrentN:
+                                        {
+                                            _hydroInfo.Pumps.ForEach(t =>
+                                            {
+                                                if (t.RatedN.HasValue)
+                                                {
+                                                    _allMarkResultList.Add(new HydroMarkResultViewModel()
+                                                    {
+                                                        Code = t.Code,
+                                                        Text = $"璁惧畾杞��:{Math.Round(t.RatedN.Value * t.SpeedRatio, 1)}r/min"
+                                                    });
+                                                }
+                                            });
+                                        }
+                                        break;
+                                    case ePumpMarkType.CurrentHz:
+                                        {
+                                            _hydroInfo.Pumps.ForEach(t =>
+                                            {
+                                                _allMarkResultList.Add(new HydroMarkResultViewModel()
+                                                {
+                                                    Code = t.Code,
+                                                    Text = $"璁惧畾棰戠巼:{Math.Round(t.RatedHz * t.SpeedRatio, 1)}hz"
+                                                });
+                                            });
+                                        }
+                                        break;
+                                    default: break;
+                                }
+                            }
+                        }
+                        break;
+                    case Yw.Hydro.ParterCatalog.Valve:
+                        {
+                            if (_hydroInfo.Valves != null && _hydroInfo.Valves.Count > 0)
+                            {
+                                switch ((eValveMarkType)markSet.MarkType)
+                                {
+                                    case eValveMarkType.None:
+                                        {
+
+                                        }
+                                        break;
+                                    case eValveMarkType.ValveStatus:
+                                        {
+                                            _hydroInfo.Valves.ForEach(t =>
+                                            {
+                                                _allMarkResultList.Add(new HydroMarkResultViewModel()
+                                                {
+                                                    Code = t.Code,
+                                                    Text = $"闃�闂ㄧ姸鎬�:{HydroLinkStatusHelper.GetStatusName(t.LinkStatus)}"
+                                                });
+                                            });
+                                        }
+                                        break;
+                                    case eValveMarkType.ValveType:
+                                        {
+                                            _hydroInfo.Valves.ForEach(t =>
+                                            {
+                                                _allMarkResultList.Add(new HydroMarkResultViewModel()
+                                                {
+                                                    Code = t.Code,
+                                                    Text = $"闃�闂ㄧ被鍨�:{HydroValveTypeHelper.GetTypeName(t.ValveType)}"
+                                                });
+                                            });
+                                        }
+                                        break;
+                                    case eValveMarkType.Diameter:
+                                        {
+                                            _hydroInfo.Valves.ForEach(t =>
+                                            {
+                                                _allMarkResultList.Add(new HydroMarkResultViewModel()
+                                                {
+                                                    Code = t.Code,
+                                                    Text = $"鐩村緞:{t.Diameter}mm"
+                                                });
+                                            });
+                                        }
+                                        break;
+                                    case eValveMarkType.MinorLoss:
+                                        {
+                                            _hydroInfo.Valves.ForEach(t =>
+                                            {
+                                                _allMarkResultList.Add(new HydroMarkResultViewModel()
+                                                {
+                                                    Code = t.Code,
+                                                    Text = $"灞�闃荤郴鏁�:{t.MinorLoss}"
+                                                });
+                                            });
+                                        }
+                                        break;
+                                    default: break;
+                                }
+                            }
+                        }
+                        break;
+                    case Yw.Hydro.ParterCatalog.Pipe:
+                        {
+                            if (_hydroInfo.Pipes != null && _hydroInfo.Pipes.Count > 0)
+                            {
+                                switch ((ePipeMarkType)markSet.MarkType)
+                                {
+                                    case ePipeMarkType.None:
+                                        {
+
+                                        }
+                                        break;
+                                    case ePipeMarkType.PipeStatus:
+                                        {
+                                            _hydroInfo.Pipes.ForEach(t =>
+                                            {
+                                                _allMarkResultList.Add(new HydroMarkResultViewModel()
+                                                {
+                                                    Code = t.Code,
+                                                    Text = $"鐘舵��:{Yw.WinFrmUI.HydroLinkStatusHelper.GetStatusName(t.LinkStatus)}"
+                                                });
+                                            });
+                                        }
+                                        break;
+                                    case ePipeMarkType.Diameter:
+                                        {
+                                            _hydroInfo.Pipes.ForEach(t =>
+                                            {
+                                                _allMarkResultList.Add(new HydroMarkResultViewModel()
+                                                {
+                                                    Code = t.Code,
+                                                    Text = $"鐩村緞:{t.Diameter}mm"
+                                                });
+                                            });
+                                        }
+                                        break;
+                                    case ePipeMarkType.Length:
+                                        {
+                                            _hydroInfo.Pipes.ForEach(t =>
+                                            {
+                                                _allMarkResultList.Add(new HydroMarkResultViewModel()
+                                                {
+                                                    Code = t.Code,
+                                                    Text = $"闀垮害:{t.Length}m"
+                                                });
+                                            });
+                                        }
+                                        break;
+                                    case ePipeMarkType.Roughness:
+                                        {
+                                            _hydroInfo.Pipes.ForEach(t =>
+                                            {
+                                                _allMarkResultList.Add(new HydroMarkResultViewModel()
+                                                {
+                                                    Code = t.Code,
+                                                    Text = $"绮楃硻绯绘暟:{t.Roughness}"
+                                                });
+                                            });
+                                        }
+                                        break;
+                                    case ePipeMarkType.MinorLoss:
+                                        {
+                                            _hydroInfo.Pipes.ForEach(t =>
+                                            {
+                                                _allMarkResultList.Add(new HydroMarkResultViewModel()
+                                                {
+                                                    Code = t.Code,
+                                                    Text = $"灞�闃荤郴鏁�:{t.MinorLoss}"
+                                                });
+                                            });
+                                        }
+                                        break;
+                                    default: break;
+                                }
+                            }
+                        }
+                        break;
+                    case Yw.Hydro.ParterCatalog.Nozzle:
+                        {
+                            if (_hydroInfo.Nozzles != null && _hydroInfo.Nozzles.Count > 0)
+                            {
+                                switch ((eNozzleMarkType)markSet.MarkType)
+                                {
+                                    case eNozzleMarkType.None:
+                                        {
+
+                                        }
+                                        break;
+                                    case eNozzleMarkType.Elev:
+                                        {
+                                            _hydroInfo.Nozzles.ForEach(t =>
+                                            {
+                                                _allMarkResultList.Add(new HydroMarkResultViewModel()
+                                                {
+                                                    Code = t.Code,
+                                                    Text = $"鏍囬珮:{Math.Round(t.Elev, 4)}m"
+                                                });
+                                            });
+                                        }
+                                        break;
+                                    case eNozzleMarkType.Demand:
+                                        {
+                                            _hydroInfo.Nozzles.ForEach(t =>
+                                            {
+                                                _allMarkResultList.Add(new HydroMarkResultViewModel()
+                                                {
+                                                    Code = t.Code,
+                                                    Text = $"闇�姘撮噺:{t.Demand}m鲁/h"
+                                                });
+                                            });
+                                        }
+                                        break;
+                                    case eNozzleMarkType.Coefficient:
+                                        {
+                                            _hydroInfo.Nozzles.ForEach(t =>
+                                            {
+                                                _allMarkResultList.Add(new HydroMarkResultViewModel()
+                                                {
+                                                    Code = t.Code,
+                                                    Text = $"鍠峰皠绯绘暟:{t.Coefficient}"
+                                                });
+                                            });
+                                        }
+                                        break;
+                                    default: break;
+                                }
+                            }
+                        }
+                        break;
+                    default: break;
+                }
+            }
+            return _allMarkResultList;
+        }
+
+        //搴旂敤鏍囨敞缁撴灉鍒楄〃
+        private async Task ApplyMarkResultList()
+        {
+            var allMarkResultList = GetMarkResultList();
+            var leadLabels = allMarkResultList?.Select(x => new LogicMarkLeadLabel(x.Code, x.Text, 100000)).ToList();
+            await _bimfaceCtrl?.SetLogicMarkLeadLabels(leadLabels);
+            TipFormHelper.ShowSucceed("鏍囨敞淇℃伅宸茶缃�");
+        }
+
+        //娓呴櫎鏍囨敞缁撴灉鍒楄〃
+        private async Task ClearMarkResultList()
+        {
+            if (_allMarkResultList == null || _allMarkResultList.Count < 1)
+            {
+                TipFormHelper.ShowWarn("灏氭湭璁剧疆鏍囨敞淇℃伅");
+                return;
+            }
+            _allMarkResultList = null;
+            await _bimfaceCtrl?.ClearLogicMarkLeadLabels();
+            TipFormHelper.ShowSucceed("鏍囨敞淇℃伅宸叉竻闄�");
+        }
+
+        //鏄剧ず鏍囨敞璁剧疆绐椾綋
+        private void ShowMarkSetDlg()
+        {
+            if (_hydroInfo == null)
+            {
+                return;
+            }
+            var allMarkSetList = GetMarkSetList();
+            var dlg = new SetHydroMarkDlg();
+            dlg.SetBindingData(allMarkSetList);
+            dlg.ReloadDataEvent += async (list) =>
+            {
+                _allMarkSetList = list;
+                await ApplyMarkResultList();
+            };
+            dlg.ShowDialog();
         }
 
         //璁剧疆鏍囨敞
         private void barBtnSetMark_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
         {
-            ShowMarkDlg();
+            ShowMarkSetDlg();
+        }
+
+        //娓呴櫎鏍囨敞
+        private async void barBtnClearMark_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
+        {
+            await ClearMarkResultList();
         }
 
         #endregion
 
         #region 棰滆壊鍒嗙骇
 
-        //棰滆壊鍒嗙骇搴旂敤鍒楄〃
-        private List<HydroGradingApplyViewModel> _allGradingApplyList = null;
-        //棰滆壊鍒嗙骇缂栫爜鍒楄〃
-        private List<string> _allGradingCodeList = null;
+        #region 棰滆壊閰嶇疆
 
-        //璁剧疆棰滆壊鍒嗙骇
-        private void SetGrading()
+        //鎵�鏈夊垎绾у垪琛�
+        private List<HydroGradingVmo> _allGradingList = null;
+
+        //鑾峰彇鍒嗙骇鍒楄〃
+        private async Task<List<HydroGradingVmo>> GetGradingList()
+        {
+            if (_hydroInfo == null)
+            {
+                return default;
+            }
+            if (_allGradingList == null)
+            {
+                _allGradingList = await BLLFactory<Yw.BLL.HydroGrading>.Instance.GetByModelID(_hydroInfo.ID);
+                if (_allGradingList == null || _allGradingList.Count < 1)
+                {
+                    var config = Yw.Settings.HydroParasHelper.Hydro.Grading;
+                    if (config != null && config.Items != null && config.Items.Count > 0)
+                    {
+                        _allGradingList = new List<HydroGradingVmo>();
+                        config.Items.ForEach(x =>
+                        {
+                            var vmo = new HydroGradingVmo()
+                            {
+                                ModelID = _hydroInfo.ID,
+                                Catalog = x.Catalog,
+                                PropName = x.PropName,
+                                SetValue = x.SetValue,
+                                MinValue = x.MinValue,
+                                MaxValue = x.MaxValue,
+                                Color = x.Color,
+                                SortCode = config.Items.IndexOf(x)
+                            };
+                            _allGradingList.Add(vmo);
+                        });
+                    }
+                }
+            }
+            return _allGradingList;
+        }
+
+        //鏄剧ず閰嶇疆棰滆壊鍒嗙骇绐椾綋
+        private async void ShowSetGradingDlg()
         {
             if (_hydroInfo == null)
             {
                 return;
             }
-            var dlg = new SetHydroGradingModelDlg();
-            dlg.SetBindingData(_hydroInfo.ID);
+            var allGradingList = await GetGradingList();
+            var dlg = new SetHydroGradingTreeDlg();
+            dlg.SetBindingData(_hydroInfo, allGradingList);
+            dlg.ReloadDataEvent += (list) =>
+            {
+                _allGradingList = list;
+            };
+            dlg.ApplyDataEvent += (catalog, propName) =>
+            {
+                ApplyGrading(catalog, propName);
+            };
             dlg.ShowDialog();
         }
 
-        //搴旂敤棰滆壊鍒嗙骇
-        private async void ApplyGrading()
+        //閰嶇疆棰滆壊鍒嗙骇
+        private void barBtnGradingSet_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
         {
-            if (_hydroInfo == null)
-            {
-                return;
-            }
+            ShowSetGradingDlg();
+        }
+
+        #endregion
+
+        #region 搴旂敤鍒嗙骇
+
+        //棰滆壊鍒嗙骇搴旂敤鍒楄〃
+        private List<HydroGradingApplyViewModel> _allGradingApplyList = null;
+
+        //鑾峰彇棰滆壊鍒嗙骇搴旂敤鍒楄〃
+        private List<HydroGradingApplyViewModel> GetGradingApplyList()
+        {
             if (_allGradingApplyList == null)
             {
                 _allGradingApplyList = new List<HydroGradingApplyViewModel>();
@@ -1316,7 +2182,7 @@
                     {
                         Code = Yw.Hydro.ParterCatalog.Pump,
                         Name = Yw.WinFrmUI.HydroParterCatalogHelper.GetCatalogName(Yw.Hydro.ParterCatalog.Pump),
-                        PropName = string.Empty
+                        PropName = Yw.Hydro.ParterProp.LinkStatus
                     });
                 }
                 if (_hydroInfo.Valves != null && _hydroInfo.Valves.Count > 0)
@@ -1325,7 +2191,7 @@
                     {
                         Code = Yw.Hydro.ParterCatalog.Valve,
                         Name = Yw.WinFrmUI.HydroParterCatalogHelper.GetCatalogName(Yw.Hydro.ParterCatalog.Valve),
-                        PropName = string.Empty
+                        PropName = Yw.Hydro.ParterProp.LinkStatus
                     });
                 }
                 if (_hydroInfo.Pipes != null && _hydroInfo.Pipes.Count > 0)
@@ -1334,38 +2200,823 @@
                     {
                         Code = Yw.Hydro.ParterCatalog.Pipe,
                         Name = Yw.WinFrmUI.HydroParterCatalogHelper.GetCatalogName(Yw.Hydro.ParterCatalog.Pipe),
-                        PropName = string.Empty
+                        PropName = Yw.Hydro.ParterProp.CalcuFlow
                     });
                 }
             }
-            var dlg = new ApplyHydroGradingDlg();
-            dlg.SetBindingData(() => _hydroInfo, _allGradingApplyList, GetAllCalcuResultList());
-            dlg.ReloadDataEvent += (obj) =>
+            return _allGradingApplyList;
+        }
+
+        //鑾峰彇棰滆壊鍒嗙骇搴旂敤缁撴灉鍒楄〃
+        private async Task<List<HydroGradingApplyResultViewModel>> GetGradingApplyResultList()
+        {
+            if (_hydroInfo == null)
             {
-                _allGradingCodeList = obj?.Select(x => x.Code).Distinct().ToList();
-                var objGroupList = obj?.GroupBy(x => x.Color).ToList();
-                objGroupList.ForEach(async x =>
+                return default;
+            }
+
+            //鎵�鏈夊垎绾у垪琛�
+            var allGradingList = await GetGradingList();
+            if (allGradingList == null || allGradingList.Count < 1)
+            {
+                return default;
+            }
+
+            //鎵�鏈夊垎绾у簲鐢ㄥ垪琛�
+            var allGradingApplyList = GetGradingApplyList();
+            if (allGradingApplyList == null || allGradingApplyList.Count < 1)
+            {
+                return default;
+            }
+
+            //鎵�鏈夎绠楃粨鏋滃垪琛�
+            var allCalcuResultList = GetCalcuResultList();
+
+            //鎵�鏈夊簲鐢ㄧ粨鏋滃垪琛�
+            var allGradingApplyResultList = new List<HydroGradingApplyResultViewModel>();
+            allGradingApplyList.ForEach(x =>
+            {
+                var allCatalogGradingList = allGradingList.Where(t => t.Catalog == x.Code).ToList();
+                if (allCatalogGradingList != null || allCatalogGradingList.Count > 0)
                 {
-                    await _bimfaceCtrl?.OverrideComponentsColor(x.Select(t => t.Code).Distinct().ToList(), x.Key, 1);
-                });
-            };
-            if (dlg.ShowDialog() != DialogResult.OK)
+                    switch (x.Code)
+                    {
+                        case Yw.Hydro.ParterCatalog.Pump:
+                            {
+                                if (_hydroInfo.Pumps != null && _hydroInfo.Pumps.Count > 0)
+                                {
+                                    foreach (var pump in _hydroInfo.Pumps)
+                                    {
+                                        switch (x.PropName)
+                                        {
+                                            case Yw.Hydro.ParterProp.LinkStatus:
+                                                {
+                                                    var gradingList = allCatalogGradingList.Where(x => x.PropName == Yw.Hydro.ParterProp.LinkStatus).OrderBy(t => t.SortCode).ToList();
+                                                    if (gradingList != null && gradingList.Count > 0)
+                                                    {
+                                                        var grading = gradingList.Meet(pump.LinkStatus);
+                                                        if (grading != null)
+                                                        {
+                                                            var result = new HydroGradingApplyResultViewModel()
+                                                            {
+                                                                Code = pump.Code,
+                                                                Color = grading.Color
+                                                            };
+                                                            allGradingApplyResultList.Add(result);
+                                                        }
+                                                    }
+                                                }
+                                                break;
+                                            case Yw.Hydro.ParterProp.CalcuFlow:
+                                                {
+                                                    var gradingList = allCatalogGradingList.Where(x => x.PropName == Yw.Hydro.ParterProp.CalcuFlow).OrderBy(t => t.SortCode).ToList();
+                                                    if (gradingList != null && gradingList.Count > 0)
+                                                    {
+                                                        var calcuResult = allCalcuResultList?.Find(t => t.Code == pump.Code);
+                                                        if (calcuResult is HydroCalcuLinkResult calcuLinkResult)
+                                                        {
+                                                            if (calcuLinkResult.CalcuFlow.HasValue)
+                                                            {
+                                                                var grading = gradingList.Meet(Math.Abs(calcuLinkResult.CalcuFlow.Value));
+                                                                if (grading != null)
+                                                                {
+                                                                    var result = new HydroGradingApplyResultViewModel()
+                                                                    {
+                                                                        Code = pump.Code,
+                                                                        Color = grading.Color
+                                                                    };
+                                                                    allGradingApplyResultList.Add(result);
+                                                                }
+                                                            }
+                                                        }
+                                                    }
+                                                }
+                                                break;
+                                            case Yw.Hydro.ParterProp.CalcuVelocity:
+                                                {
+                                                    var gradingList = allCatalogGradingList.Where(x => x.PropName == Yw.Hydro.ParterProp.CalcuVelocity).OrderBy(t => t.SortCode).ToList();
+                                                    if (gradingList != null && gradingList.Count > 0)
+                                                    {
+                                                        var calcuResult = allCalcuResultList?.Find(t => t.Code == pump.Code);
+                                                        if (calcuResult is HydroCalcuLinkResult calcuLinkResult)
+                                                        {
+                                                            if (calcuLinkResult.CalcuVelocity.HasValue)
+                                                            {
+                                                                var grading = gradingList.Meet(Math.Abs(calcuLinkResult.CalcuVelocity.Value));
+                                                                if (grading != null)
+                                                                {
+                                                                    var result = new HydroGradingApplyResultViewModel()
+                                                                    {
+                                                                        Code = pump.Code,
+                                                                        Color = grading.Color
+                                                                    };
+                                                                    allGradingApplyResultList.Add(result);
+                                                                }
+                                                            }
+                                                        }
+                                                    }
+                                                }
+                                                break;
+                                            case Yw.Hydro.ParterProp.CalcuHeadLoss:
+                                                {
+                                                    var gradingList = allCatalogGradingList.Where(x => x.PropName == Yw.Hydro.ParterProp.CalcuHeadLoss).OrderBy(t => t.SortCode).ToList();
+                                                    if (gradingList != null && gradingList.Count > 0)
+                                                    {
+                                                        var calcuResult = allCalcuResultList?.Find(t => t.Code == pump.Code);
+                                                        if (calcuResult is HydroCalcuLinkResult calcuLinkResult)
+                                                        {
+                                                            if (calcuLinkResult.CalcuHeadLoss.HasValue)
+                                                            {
+                                                                var grading = gradingList.Meet(Math.Abs(calcuLinkResult.CalcuHeadLoss.Value));
+                                                                if (grading != null)
+                                                                {
+                                                                    var result = new HydroGradingApplyResultViewModel()
+                                                                    {
+                                                                        Code = pump.Code,
+                                                                        Color = grading.Color
+                                                                    };
+                                                                    allGradingApplyResultList.Add(result);
+                                                                }
+                                                            }
+                                                        }
+                                                    }
+                                                }
+                                                break;
+                                            default: break;
+                                        }
+                                    }
+                                }
+                            }
+                            break;
+                        case Yw.Hydro.ParterCatalog.Valve:
+                            {
+                                if (_hydroInfo.Valves != null && _hydroInfo.Valves.Count > 0)
+                                {
+                                    foreach (var valve in _hydroInfo.Valves)
+                                    {
+                                        switch (x.PropName)
+                                        {
+                                            case Yw.Hydro.ParterProp.LinkStatus:
+                                                {
+                                                    var gradingList = allCatalogGradingList.Where(x => x.PropName == Yw.Hydro.ParterProp.LinkStatus).OrderBy(t => t.SortCode).ToList();
+                                                    if (gradingList != null && gradingList.Count > 0)
+                                                    {
+                                                        var grading = gradingList.Meet(valve.LinkStatus);
+                                                        if (grading != null)
+                                                        {
+                                                            var result = new HydroGradingApplyResultViewModel()
+                                                            {
+                                                                Code = valve.Code,
+                                                                Color = grading.Color
+                                                            };
+                                                            allGradingApplyResultList.Add(result);
+                                                        }
+                                                    }
+                                                }
+                                                break;
+                                            case Yw.Hydro.ParterProp.CalcuFlow:
+                                                {
+                                                    var gradingList = allCatalogGradingList.Where(x => x.PropName == Yw.Hydro.ParterProp.CalcuFlow).OrderBy(t => t.SortCode).ToList();
+                                                    if (gradingList != null && gradingList.Count > 0)
+                                                    {
+                                                        var calcuResult = allCalcuResultList?.Find(t => t.Code == valve.Code);
+                                                        if (calcuResult is HydroCalcuLinkResult calcuLinkResult)
+                                                        {
+                                                            if (calcuLinkResult.CalcuFlow.HasValue)
+                                                            {
+                                                                var grading = gradingList.Meet(Math.Abs(calcuLinkResult.CalcuFlow.Value));
+                                                                if (grading != null)
+                                                                {
+                                                                    var result = new HydroGradingApplyResultViewModel()
+                                                                    {
+                                                                        Code = valve.Code,
+                                                                        Color = grading.Color
+                                                                    };
+                                                                    allGradingApplyResultList.Add(result);
+                                                                }
+                                                            }
+                                                        }
+                                                    }
+                                                }
+                                                break;
+                                            case Yw.Hydro.ParterProp.CalcuVelocity:
+                                                {
+                                                    var gradingList = allCatalogGradingList.Where(x => x.PropName == Yw.Hydro.ParterProp.CalcuVelocity).OrderBy(t => t.SortCode).ToList();
+                                                    if (gradingList != null && gradingList.Count > 0)
+                                                    {
+                                                        var calcuResult = allCalcuResultList?.Find(t => t.Code == valve.Code);
+                                                        if (calcuResult is HydroCalcuLinkResult calcuLinkResult)
+                                                        {
+                                                            if (calcuLinkResult.CalcuVelocity.HasValue)
+                                                            {
+                                                                var grading = gradingList.Meet(Math.Abs(calcuLinkResult.CalcuVelocity.Value));
+                                                                if (grading != null)
+                                                                {
+                                                                    var result = new HydroGradingApplyResultViewModel()
+                                                                    {
+                                                                        Code = valve.Code,
+                                                                        Color = grading.Color
+                                                                    };
+                                                                    allGradingApplyResultList.Add(result);
+                                                                }
+                                                            }
+                                                        }
+                                                    }
+                                                }
+                                                break;
+                                            case Yw.Hydro.ParterProp.CalcuHeadLoss:
+                                                {
+                                                    var gradingList = allCatalogGradingList.Where(x => x.PropName == Yw.Hydro.ParterProp.CalcuHeadLoss).OrderBy(t => t.SortCode).ToList();
+                                                    if (gradingList != null && gradingList.Count > 0)
+                                                    {
+                                                        var calcuResult = allCalcuResultList?.Find(t => t.Code == valve.Code);
+                                                        if (calcuResult is HydroCalcuLinkResult calcuLinkResult)
+                                                        {
+                                                            if (calcuLinkResult.CalcuHeadLoss.HasValue)
+                                                            {
+                                                                var grading = gradingList.Meet(Math.Abs(calcuLinkResult.CalcuHeadLoss.Value));
+                                                                if (grading != null)
+                                                                {
+                                                                    var result = new HydroGradingApplyResultViewModel()
+                                                                    {
+                                                                        Code = valve.Code,
+                                                                        Color = grading.Color
+                                                                    };
+                                                                    allGradingApplyResultList.Add(result);
+                                                                }
+                                                            }
+                                                        }
+                                                    }
+                                                }
+                                                break;
+                                            default: break;
+                                        }
+                                    }
+                                }
+                            }
+                            break;
+                        case Yw.Hydro.ParterCatalog.Pipe:
+                            {
+                                if (_hydroInfo.Pipes != null && _hydroInfo.Pipes.Count > 0)
+                                {
+                                    foreach (var pipe in _hydroInfo.Pipes)
+                                    {
+                                        switch (x.PropName)
+                                        {
+                                            case Yw.Hydro.ParterProp.CalcuFlow:
+                                                {
+                                                    var gradingList = allCatalogGradingList.Where(x => x.PropName == Yw.Hydro.ParterProp.CalcuFlow).OrderBy(t => t.SortCode).ToList();
+                                                    if (gradingList != null && gradingList.Count > 0)
+                                                    {
+                                                        var calcuResult = allCalcuResultList?.Find(t => t.Code == pipe.Code);
+                                                        if (calcuResult is HydroCalcuLinkResult calcuLinkResult)
+                                                        {
+                                                            if (calcuLinkResult.CalcuFlow.HasValue)
+                                                            {
+                                                                var grading = gradingList.Meet(Math.Abs(calcuLinkResult.CalcuFlow.Value));
+                                                                if (grading != null)
+                                                                {
+                                                                    var result = new HydroGradingApplyResultViewModel()
+                                                                    {
+                                                                        Code = pipe.Code,
+                                                                        Color = grading.Color
+                                                                    };
+                                                                    allGradingApplyResultList.Add(result);
+                                                                }
+                                                            }
+                                                        }
+                                                    }
+                                                }
+                                                break;
+                                            case Yw.Hydro.ParterProp.CalcuVelocity:
+                                                {
+                                                    var gradingList = allCatalogGradingList.Where(x => x.PropName == Yw.Hydro.ParterProp.CalcuVelocity).OrderBy(t => t.SortCode).ToList();
+                                                    if (gradingList != null && gradingList.Count > 0)
+                                                    {
+                                                        var calcuResult = allCalcuResultList?.Find(t => t.Code == pipe.Code);
+                                                        if (calcuResult is HydroCalcuLinkResult calcuLinkResult)
+                                                        {
+                                                            if (calcuLinkResult.CalcuVelocity.HasValue)
+                                                            {
+                                                                var grading = gradingList.Meet(Math.Abs(calcuLinkResult.CalcuVelocity.Value));
+                                                                if (grading != null)
+                                                                {
+                                                                    var result = new HydroGradingApplyResultViewModel()
+                                                                    {
+                                                                        Code = pipe.Code,
+                                                                        Color = grading.Color
+                                                                    };
+                                                                    allGradingApplyResultList.Add(result);
+                                                                }
+                                                            }
+                                                        }
+                                                    }
+                                                }
+                                                break;
+                                            case Yw.Hydro.ParterProp.CalcuHeadLoss:
+                                                {
+                                                    var gradingList = allCatalogGradingList.Where(x => x.PropName == Yw.Hydro.ParterProp.CalcuHeadLoss).OrderBy(t => t.SortCode).ToList();
+                                                    if (gradingList != null && gradingList.Count > 0)
+                                                    {
+                                                        var calcuResult = allCalcuResultList?.Find(t => t.Code == pipe.Code);
+                                                        if (calcuResult is HydroCalcuLinkResult calcuLinkResult)
+                                                        {
+                                                            if (calcuLinkResult.CalcuHeadLoss.HasValue)
+                                                            {
+                                                                var grading = gradingList.Meet(Math.Abs(calcuLinkResult.CalcuHeadLoss.Value));
+                                                                if (grading != null)
+                                                                {
+                                                                    var result = new HydroGradingApplyResultViewModel()
+                                                                    {
+                                                                        Code = pipe.Code,
+                                                                        Color = grading.Color
+                                                                    };
+                                                                    allGradingApplyResultList.Add(result);
+                                                                }
+                                                            }
+                                                        }
+                                                    }
+                                                }
+                                                break;
+                                            default: break;
+                                        }
+                                    }
+                                }
+                            }
+                            break;
+                        default: break;
+                    }
+                }
+            });
+
+            return allGradingApplyResultList;
+        }
+
+        //鑾峰彇棰滆壊鍒嗙骇搴旂敤缁撴灉鍒楄〃
+        private async Task<List<HydroGradingApplyResultViewModel>> GetGradingApplyResultList(string catalog, string propName)
+        {
+            if (_hydroInfo == null)
             {
-                await _bimfaceCtrl?.RestoreComponentsColor(_allGradingCodeList);
+                return default;
+            }
+
+            //鎵�鏈夊垎绾у垪琛�
+            var allGradingList = await GetGradingList();
+            if (allGradingList == null || allGradingList.Count < 1)
+            {
+                return default;
+            }
+            var currentGradingList = allGradingList.Where(x => x.Catalog == catalog).ToList();
+            if (currentGradingList.Count < 1)
+            {
+                return default;
+            }
+
+            //鎵�鏈夊垎绾у簲鐢ㄥ垪琛�
+            var allGradingApplyList = GetGradingApplyList();
+            if (allGradingApplyList == null || allGradingApplyList.Count < 1)
+            {
+                return default;
+            }
+
+            //褰撳墠鍒嗙骇搴旂敤
+            var gradingApply = allGradingApplyList.Find(x => x.Code == catalog);
+            if (gradingApply == null)
+            {
+                return default;
+            }
+            gradingApply.PropName = propName;
+
+            //鎵�鏈夎绠楃粨鏋�
+            var allCalcuResultList = GetCalcuResultList();
+
+            //搴旂敤缁撴灉鍒楄〃
+            var gradingApplyResultList = new List<HydroGradingApplyResultViewModel>();
+
+            switch (catalog)
+            {
+                case Yw.Hydro.ParterCatalog.Pump:
+                    {
+                        if (_hydroInfo.Pumps != null && _hydroInfo.Pumps.Count > 0)
+                        {
+                            foreach (var pump in _hydroInfo.Pumps)
+                            {
+                                switch (propName)
+                                {
+                                    case Yw.Hydro.ParterProp.LinkStatus:
+                                        {
+                                            var gradingList = currentGradingList.Where(x => x.PropName == Yw.Hydro.ParterProp.LinkStatus).OrderBy(t => t.SortCode).ToList();
+                                            if (gradingList != null && gradingList.Count > 0)
+                                            {
+                                                var grading = gradingList.Meet(pump.LinkStatus);
+                                                if (grading != null)
+                                                {
+                                                    var result = new HydroGradingApplyResultViewModel()
+                                                    {
+                                                        Code = pump.Code,
+                                                        Color = grading.Color
+                                                    };
+                                                    gradingApplyResultList.Add(result);
+                                                }
+                                            }
+                                        }
+                                        break;
+                                    case Yw.Hydro.ParterProp.CalcuFlow:
+                                        {
+                                            var gradingList = currentGradingList.Where(x => x.PropName == Yw.Hydro.ParterProp.CalcuFlow).OrderBy(t => t.SortCode).ToList();
+                                            if (gradingList != null && gradingList.Count > 0)
+                                            {
+                                                var calcuResult = allCalcuResultList?.Find(t => t.Code == pump.Code);
+                                                if (calcuResult is HydroCalcuLinkResult calcuLinkResult)
+                                                {
+                                                    if (calcuLinkResult.CalcuFlow.HasValue)
+                                                    {
+                                                        var grading = gradingList.Meet(Math.Abs(calcuLinkResult.CalcuFlow.Value));
+                                                        if (grading != null)
+                                                        {
+                                                            var result = new HydroGradingApplyResultViewModel()
+                                                            {
+                                                                Code = pump.Code,
+                                                                Color = grading.Color
+                                                            };
+                                                            gradingApplyResultList.Add(result);
+                                                        }
+                                                    }
+                                                }
+                                            }
+                                        }
+                                        break;
+                                    case Yw.Hydro.ParterProp.CalcuVelocity:
+                                        {
+                                            var gradingList = currentGradingList.Where(x => x.PropName == Yw.Hydro.ParterProp.CalcuVelocity).OrderBy(t => t.SortCode).ToList();
+                                            if (gradingList != null && gradingList.Count > 0)
+                                            {
+                                                var calcuResult = allCalcuResultList?.Find(t => t.Code == pump.Code);
+                                                if (calcuResult is HydroCalcuLinkResult calcuLinkResult)
+                                                {
+                                                    if (calcuLinkResult.CalcuVelocity.HasValue)
+                                                    {
+                                                        var grading = gradingList.Meet(Math.Abs(calcuLinkResult.CalcuVelocity.Value));
+                                                        if (grading != null)
+                                                        {
+                                                            var result = new HydroGradingApplyResultViewModel()
+                                                            {
+                                                                Code = pump.Code,
+                                                                Color = grading.Color
+                                                            };
+                                                            gradingApplyResultList.Add(result);
+                                                        }
+                                                    }
+                                                }
+                                            }
+                                        }
+                                        break;
+                                    case Yw.Hydro.ParterProp.CalcuHeadLoss:
+                                        {
+                                            var gradingList = currentGradingList.Where(x => x.PropName == Yw.Hydro.ParterProp.CalcuHeadLoss).OrderBy(t => t.SortCode).ToList();
+                                            if (gradingList != null && gradingList.Count > 0)
+                                            {
+                                                var calcuResult = allCalcuResultList?.Find(t => t.Code == pump.Code);
+                                                if (calcuResult is HydroCalcuLinkResult calcuLinkResult)
+                                                {
+                                                    if (calcuLinkResult.CalcuHeadLoss.HasValue)
+                                                    {
+                                                        var grading = gradingList.Meet(Math.Abs(calcuLinkResult.CalcuHeadLoss.Value));
+                                                        if (grading != null)
+                                                        {
+                                                            var result = new HydroGradingApplyResultViewModel()
+                                                            {
+                                                                Code = pump.Code,
+                                                                Color = grading.Color
+                                                            };
+                                                            gradingApplyResultList.Add(result);
+                                                        }
+                                                    }
+                                                }
+                                            }
+                                        }
+                                        break;
+                                    default: break;
+                                }
+                            }
+                        }
+                    }
+                    break;
+                case Yw.Hydro.ParterCatalog.Valve:
+                    {
+                        if (_hydroInfo.Valves != null && _hydroInfo.Valves.Count > 0)
+                        {
+                            foreach (var valve in _hydroInfo.Valves)
+                            {
+                                switch (propName)
+                                {
+                                    case Yw.Hydro.ParterProp.LinkStatus:
+                                        {
+                                            var gradingList = currentGradingList.Where(x => x.PropName == Yw.Hydro.ParterProp.LinkStatus).OrderBy(t => t.SortCode).ToList();
+                                            if (gradingList != null && gradingList.Count > 0)
+                                            {
+                                                var grading = gradingList.Meet(valve.LinkStatus);
+                                                if (grading != null)
+                                                {
+                                                    var result = new HydroGradingApplyResultViewModel()
+                                                    {
+                                                        Code = valve.Code,
+                                                        Color = grading.Color
+                                                    };
+                                                    gradingApplyResultList.Add(result);
+                                                }
+                                            }
+                                        }
+                                        break;
+                                    case Yw.Hydro.ParterProp.CalcuFlow:
+                                        {
+                                            var gradingList = currentGradingList.Where(x => x.PropName == Yw.Hydro.ParterProp.CalcuFlow).OrderBy(t => t.SortCode).ToList();
+                                            if (gradingList != null && gradingList.Count > 0)
+                                            {
+                                                var calcuResult = allCalcuResultList?.Find(t => t.Code == valve.Code);
+                                                if (calcuResult is HydroCalcuLinkResult calcuLinkResult)
+                                                {
+                                                    if (calcuLinkResult.CalcuFlow.HasValue)
+                                                    {
+                                                        var grading = gradingList.Meet(Math.Abs(calcuLinkResult.CalcuFlow.Value));
+                                                        if (grading != null)
+                                                        {
+                                                            var result = new HydroGradingApplyResultViewModel()
+                                                            {
+                                                                Code = valve.Code,
+                                                                Color = grading.Color
+                                                            };
+                                                            gradingApplyResultList.Add(result);
+                                                        }
+                                                    }
+                                                }
+                                            }
+                                        }
+                                        break;
+                                    case Yw.Hydro.ParterProp.CalcuVelocity:
+                                        {
+                                            var gradingList = currentGradingList.Where(x => x.PropName == Yw.Hydro.ParterProp.CalcuVelocity).OrderBy(t => t.SortCode).ToList();
+                                            if (gradingList != null && gradingList.Count > 0)
+                                            {
+                                                var calcuResult = allCalcuResultList?.Find(t => t.Code == valve.Code);
+                                                if (calcuResult is HydroCalcuLinkResult calcuLinkResult)
+                                                {
+                                                    if (calcuLinkResult.CalcuVelocity.HasValue)
+                                                    {
+                                                        var grading = gradingList.Meet(Math.Abs(calcuLinkResult.CalcuVelocity.Value));
+                                                        if (grading != null)
+                                                        {
+                                                            var result = new HydroGradingApplyResultViewModel()
+                                                            {
+                                                                Code = valve.Code,
+                                                                Color = grading.Color
+                                                            };
+                                                            gradingApplyResultList.Add(result);
+                                                        }
+                                                    }
+                                                }
+                                            }
+                                        }
+                                        break;
+                                    case Yw.Hydro.ParterProp.CalcuHeadLoss:
+                                        {
+                                            var gradingList = currentGradingList.Where(x => x.PropName == Yw.Hydro.ParterProp.CalcuHeadLoss).OrderBy(t => t.SortCode).ToList();
+                                            if (gradingList != null && gradingList.Count > 0)
+                                            {
+                                                var calcuResult = allCalcuResultList?.Find(t => t.Code == valve.Code);
+                                                if (calcuResult is HydroCalcuLinkResult calcuLinkResult)
+                                                {
+                                                    if (calcuLinkResult.CalcuHeadLoss.HasValue)
+                                                    {
+                                                        var grading = gradingList.Meet(Math.Abs(calcuLinkResult.CalcuHeadLoss.Value));
+                                                        if (grading != null)
+                                                        {
+                                                            var result = new HydroGradingApplyResultViewModel()
+                                                            {
+                                                                Code = valve.Code,
+                                                                Color = grading.Color
+                                                            };
+                                                            gradingApplyResultList.Add(result);
+                                                        }
+                                                    }
+                                                }
+                                            }
+                                        }
+                                        break;
+                                    default: break;
+                                }
+                            }
+                        }
+                    }
+                    break;
+                case Yw.Hydro.ParterCatalog.Pipe:
+                    {
+                        if (_hydroInfo.Pipes != null && _hydroInfo.Pipes.Count > 0)
+                        {
+                            foreach (var pipe in _hydroInfo.Pipes)
+                            {
+                                switch (propName)
+                                {
+                                    case Yw.Hydro.ParterProp.CalcuFlow:
+                                        {
+                                            var gradingList = currentGradingList.Where(x => x.PropName == Yw.Hydro.ParterProp.CalcuFlow).OrderBy(t => t.SortCode).ToList();
+                                            if (gradingList != null && gradingList.Count > 0)
+                                            {
+                                                var calcuResult = allCalcuResultList?.Find(t => t.Code == pipe.Code);
+                                                if (calcuResult is HydroCalcuLinkResult calcuLinkResult)
+                                                {
+                                                    if (calcuLinkResult.CalcuFlow.HasValue)
+                                                    {
+                                                        var grading = gradingList.Meet(Math.Abs(calcuLinkResult.CalcuFlow.Value));
+                                                        if (grading != null)
+                                                        {
+                                                            var result = new HydroGradingApplyResultViewModel()
+                                                            {
+                                                                Code = pipe.Code,
+                                                                Color = grading.Color
+                                                            };
+                                                            gradingApplyResultList.Add(result);
+                                                        }
+                                                    }
+                                                }
+                                            }
+                                        }
+                                        break;
+                                    case Yw.Hydro.ParterProp.CalcuVelocity:
+                                        {
+                                            var gradingList = currentGradingList.Where(x => x.PropName == Yw.Hydro.ParterProp.CalcuVelocity).OrderBy(t => t.SortCode).ToList();
+                                            if (gradingList != null && gradingList.Count > 0)
+                                            {
+                                                var calcuResult = allCalcuResultList?.Find(t => t.Code == pipe.Code);
+                                                if (calcuResult is HydroCalcuLinkResult calcuLinkResult)
+                                                {
+                                                    if (calcuLinkResult.CalcuVelocity.HasValue)
+                                                    {
+                                                        var grading = gradingList.Meet(Math.Abs(calcuLinkResult.CalcuVelocity.Value));
+                                                        if (grading != null)
+                                                        {
+                                                            var result = new HydroGradingApplyResultViewModel()
+                                                            {
+                                                                Code = pipe.Code,
+                                                                Color = grading.Color
+                                                            };
+                                                            gradingApplyResultList.Add(result);
+                                                        }
+                                                    }
+                                                }
+                                            }
+                                        }
+                                        break;
+                                    case Yw.Hydro.ParterProp.CalcuHeadLoss:
+                                        {
+                                            var gradingList = currentGradingList.Where(x => x.PropName == Yw.Hydro.ParterProp.CalcuHeadLoss).OrderBy(t => t.SortCode).ToList();
+                                            if (gradingList != null && gradingList.Count > 0)
+                                            {
+                                                var calcuResult = allCalcuResultList?.Find(t => t.Code == pipe.Code);
+                                                if (calcuResult is HydroCalcuLinkResult calcuLinkResult)
+                                                {
+                                                    if (calcuLinkResult.CalcuHeadLoss.HasValue)
+                                                    {
+                                                        var grading = gradingList.Meet(Math.Abs(calcuLinkResult.CalcuHeadLoss.Value));
+                                                        if (grading != null)
+                                                        {
+                                                            var result = new HydroGradingApplyResultViewModel()
+                                                            {
+                                                                Code = pipe.Code,
+                                                                Color = grading.Color
+                                                            };
+                                                            gradingApplyResultList.Add(result);
+                                                        }
+                                                    }
+                                                }
+                                            }
+                                        }
+                                        break;
+                                    default: break;
+                                }
+                            }
+                        }
+                    }
+                    break;
+                default: break;
+            }
+
+            return gradingApplyResultList;
+        }
+
+        //棰滆壊鍒嗙骇鏄惁搴旂敤浜�
+        private bool _isGradingApply = false;
+        //棰滆壊鍒嗙骇搴旂敤缂栫爜鍒楄〃
+        private List<string> _allGradingApplyCodeList = null;
+
+        //搴旂敤棰滆壊鍒嗙骇
+        private async void ApplyGrading()
+        {
+            if (_hydroInfo == null)
+            {
+                return;
+            }
+            _isGradingApply = true;
+            var allGradingApplyResultList = await GetGradingApplyResultList();
+            if (allGradingApplyResultList == null || allGradingApplyResultList.Count < 1)
+            {
+                CancelApplyGrading();
+                return;
+            }
+            var objGroupList = allGradingApplyResultList.GroupBy(x => x.Color).ToList();
+            objGroupList.ForEach(async x =>
+            {
+                await _bimfaceCtrl?.OverrideComponentsColor(x.Select(t => t.Code).Distinct().ToList(), x.Key, 1);
+            });
+            _allGradingApplyCodeList = allGradingApplyResultList.Select(x => x.Code).Distinct().ToList();
+        }
+
+        //搴旂敤棰滆壊鍒嗙骇
+        private async void ApplyGrading(string catalog, string propName)
+        {
+            if (_hydroInfo == null)
+            {
+                return;
+            }
+            _isGradingApply = true;
+            var allGradingApplyResultList = await GetGradingApplyResultList(catalog, propName);
+            if (allGradingApplyResultList == null || allGradingApplyResultList.Count < 1)
+            {
+                return;
+            }
+            var objGroupList = allGradingApplyResultList.GroupBy(x => x.Color).ToList();
+            objGroupList.ForEach(async x =>
+            {
+                await _bimfaceCtrl?.OverrideComponentsColor(x.Select(t => t.Code).Distinct().ToList(), x.Key, 1);
+            });
+            var codeList = allGradingApplyResultList.Select(x => x.Code);
+            if (_allGradingApplyCodeList == null)
+            {
+                _allGradingApplyCodeList = new List<string>();
+            }
+            _allGradingApplyCodeList.AddRange(codeList);
+            _allGradingApplyCodeList = _allGradingApplyCodeList.Distinct().ToList();
+        }
+
+        //鑷姩搴旂敤棰滆壊鍒嗙骇
+        private void AutoApplyGrading()
+        {
+            if (!_isGradingApply)
+            {
+                return;
+            }
+            ApplyGrading();
+        }
+
+        //鍙栨秷搴旂敤棰滆壊鍒嗙骇
+        private async void CancelApplyGrading()
+        {
+            if (_hydroInfo == null)
+            {
+                return;
+            }
+            _isGradingApply = false;
+            if (_allGradingApplyCodeList != null && _allGradingApplyCodeList.Count > 0)
+            {
+                await _bimfaceCtrl?.RestoreComponentsColor(_allGradingApplyCodeList);
             }
         }
 
-        //璁剧疆
-        private void barBtnGradingSet_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
+        //鏄剧ず搴旂敤棰滆壊鍒嗙骇绐椾綋
+        private void ShowApplyGradingDlg()
         {
-            SetGrading();
+            if (_hydroInfo == null)
+            {
+                return;
+            }
+            var allGradingApplyList = GetGradingApplyList();
+            if (allGradingApplyList == null || allGradingApplyList.Count < 1)
+            {
+                return;
+            }
+            var dlg = new ApplyHydroGradingDlg();
+            dlg.SetBindingData(allGradingApplyList);
+            dlg.ReloadDataEvent += (obj) =>
+            {
+                _allGradingApplyList = obj;
+                ApplyGrading();
+            };
+            dlg.ShowDialog();
         }
 
-        //搴旂敤
+        //搴旂敤棰滆壊鍒嗙骇
         private void barBtnGradingApply_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
         {
-            ApplyGrading();
+            ShowApplyGradingDlg();
         }
+
+        //鍙栨秷搴旂敤鍒嗙骇
+        private void batBtnCancelGradingApply_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
+        {
+            CancelApplyGrading();
+        }
+
+        #endregion
 
         #endregion
 
@@ -1386,8 +3037,13 @@
                 }
                 var hydroRelation = await BLLFactory<Yw.BLL.HydroModelRelation>.Instance
                     .GetDefaultByObjectTypeAndObjectIDOfPurpose(HStation.Xhs.DataType.XhsProjectSite, _projectSite.ID, HStation.Xhs.Purpose.Simulation);
+                Stopwatch sw = new Stopwatch();
+                sw.Start();
                 _hydroInfo = await BLLFactory<Yw.BLL.HydroModelInfo>.Instance.GetByID(hydroRelation.ModelID);
-                _parter = null;
+                sw.Stop();
+                TimeSpan ts2 = sw.Elapsed;
+                Console.WriteLine("Stopwatch鎬诲叡鑺辫垂{0}ms.", ts2.TotalMilliseconds);
+                _selectedParter = null;
                 await _bimfaceCtrl?.ZoomAndSelectComponents(null);
                 ShowProperty();
                 TipFormHelper.ShowSucceed("鏁版嵁宸插埛鏂�");
@@ -1395,5 +3051,35 @@
         }
 
         #endregion
+
+        #region 姘存祦鍔ㄧ敾
+
+        //鍔犺浇娴佸悜
+        private async void barBtnLoadFlowDirection_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
+        {
+            var pipes = _hydroInfo.Pipes;
+            var list = pipes.Select(x =>
+            {
+                return new Yw.WinFrmUI.Bimface.LogicFlowEffect()
+                {
+                    Id = x.Code,
+                    Rotation = 90,
+                    Speed = 0.1d
+                };
+            }).ToList();
+            await _bimfaceCtrl?.LoadFlowEffect(list);
+        }
+
+        //鍗歌浇娴佸悜
+        private async void barBtnUnloadFlowDirection_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
+        {
+            await _bimfaceCtrl?.UnloadFlowEffect();
+        }
+
+        #endregion
+
+
+
+
     }
 }
\ No newline at end of file

--
Gitblit v1.9.3