From 294b81166f21e12247e784d6bf404f5f34b2ee19 Mon Sep 17 00:00:00 2001
From: lixiaojun <1287241240@qq.com>
Date: 星期三, 19 二月 2025 12:51:14 +0800
Subject: [PATCH] Merge branch 'master' of http://47.103.154.90:83/r/HStation/XHS.V1.0

---
 WinFrmUI/Yw.WinFrmUI.Hydro.Core/06-visual/09-hydrant/HydroHydrantListCtrl.cs |  179 ++++++++++++++++++++++++++++++++++++++++-------------------
 1 files changed, 122 insertions(+), 57 deletions(-)

diff --git a/WinFrmUI/Yw.WinFrmUI.Hydro.Core/06-visual/09-hydrant/HydroHydrantListCtrl.cs b/WinFrmUI/Yw.WinFrmUI.Hydro.Core/06-visual/09-hydrant/HydroHydrantListCtrl.cs
index 0991f6c..8421fe5 100644
--- a/WinFrmUI/Yw.WinFrmUI.Hydro.Core/06-visual/09-hydrant/HydroHydrantListCtrl.cs
+++ b/WinFrmUI/Yw.WinFrmUI.Hydro.Core/06-visual/09-hydrant/HydroHydrantListCtrl.cs
@@ -1,5 +1,5 @@
-锘縰sing DevExpress.XtraEditors;
-using DevExpress.XtraRichEdit.Model;
+锘縰sing DevExpress.XtraGrid.Views.Grid;
+using DevExpress.XtraPrinting;
 using Yw.Model;
 
 namespace Yw.WinFrmUI
@@ -12,6 +12,9 @@
             this.gridView1.SetNormalView(30);
             this.gridView1.RegistCustomDrawRowIndicator(40);
             this.layoutControl1.SetupLayoutControl();
+            this.generalSearchAndSetCtrl1.SearchEvent += Search;
+            this.generalSearchAndSetCtrl1.ClearEvent += Reset;
+            this.generalSearchAndSetCtrl1.SetEvent += Set;
         }
 
         /// <summary>
@@ -32,18 +35,6 @@
         public event Action<List<HydroVisualViewModel>> HydroChangedViewEvent;
 
         /// <summary>
-        /// 鏄剧ず鏌ヨ闈㈡澘
-        /// </summary>
-        [Browsable(true)]
-        [Description("鏄剧ず鏌ヨ闈㈡澘")]
-        [DefaultValue(true)]
-        public bool ShowFindPanel
-        {
-            get { return this.gridView1.OptionsFind.AlwaysVisible; }
-            set { this.gridView1.OptionsFind.AlwaysVisible = value; }
-        }
-
-        /// <summary>
         /// 鏄惁鎷ユ湁姘村姏鍒楄〃
         /// </summary>
         public bool HasHydroList
@@ -51,40 +42,60 @@
             get { return _allList != null && _allList.Count > 0; }
         }
 
-        //鎵�鏈夊垪琛�
-        private List<HydroHydrantViewModel> _allList = null;
-        //鎵�鏈夌粦瀹氬垪琛�
-        private List<HydroHydrantViewModel> _allBindingList = null;
+
+        private List<HydroHydrantViewModel> _allList = null;//鎵�鏈夊垪琛�
+        private List<HydroHydrantViewModel> _allBindingList = null;//鎵�鏈夌粦瀹氬垪琛�
+        private HydroChangeHelper _changeHelper = null;//鏀瑰彉杈呭姪绫�
+        private HydroPropStatusHelper _propStatusHelper = null;//灞炴�х姸鎬佽緟鍔╃被
 
         /// <summary>
         /// 缁戝畾鏁版嵁
         /// </summary>
-        public void SetBindingData(Yw.Model.HydroModelInfo hydroInfo)
+        public void SetBindingData
+            (
+                Yw.Model.HydroModelInfo hydroInfo,
+                HydroChangeHelper changeHelper = null,
+                HydroPropStatusHelper propStatusHelper = null
+            )
         {
-            _allList = new List<HydroHydrantViewModel>();
-            if (hydroInfo != null && hydroInfo.Hydrants != null && hydroInfo.Hydrants.Count > 0)
-            {
-                foreach (var visual in hydroInfo.Hydrants)
-                {
-                    var vm = new HydroHydrantViewModel(visual, hydroInfo);
-                    _allList.Add(vm);
-                }
-            }
-            Search();
+            SetBindingData(hydroInfo, allCalcuResultVisualDict: null, changeHelper, propStatusHelper);
         }
 
         /// <summary>
         /// 缁戝畾鏁版嵁
         /// </summary>
-        public void SetBindingData(Yw.Model.HydroModelInfo hydroInfo, List<HydroCalcuResult> allCalcuResultList)
+        public void SetBindingData
+            (
+                Yw.Model.HydroModelInfo hydroInfo,
+                List<HydroCalcuVisualResult> allCalcuResultList,
+                HydroChangeHelper changeHelper = null,
+                HydroPropStatusHelper propStatusHelper = null
+            )
+        {
+            var allCalcuResultVisualDict = allCalcuResultList?.ToDictionary(x => x.Code);
+            SetBindingData(hydroInfo, allCalcuResultVisualDict, changeHelper, propStatusHelper);
+        }
+
+        /// <summary>
+        /// 缁戝畾鏁版嵁
+        /// </summary>
+        public void SetBindingData
+            (
+                HydroModelInfo hydroInfo,
+                Dictionary<string, HydroCalcuVisualResult> allCalcuResultVisualDict,
+                HydroChangeHelper changeHelper = null,
+                HydroPropStatusHelper propStatusHelper = null
+            )
         {
             _allList = new List<HydroHydrantViewModel>();
+            _changeHelper = changeHelper;
+            _propStatusHelper = propStatusHelper;
             if (hydroInfo != null && hydroInfo.Hydrants != null && hydroInfo.Hydrants.Count > 0)
             {
                 foreach (var visual in hydroInfo.Hydrants)
                 {
                     var vm = new HydroHydrantViewModel(visual, hydroInfo);
-                    var calcuResult = allCalcuResultList?.Find(x => x.Code == visual.Code);
+                    var calcuResult = allCalcuResultVisualDict?.GetValue(visual.Code);
                     if (calcuResult != null)
                     {
                         vm.UpdateCalcuProperty(calcuResult);
@@ -98,12 +109,19 @@
         /// <summary>
         /// 缁戝畾鏁版嵁
         /// </summary>
-        public void SetBindingData(List<HydroVisualViewModel> allVisualViewModelList)
+        public void SetBindingData
+            (
+                List<HydroVisualViewModel> allVisualViewModelList,
+                HydroChangeHelper changeHelper = null,
+                HydroPropStatusHelper propStatusHelper = null
+            )
         {
             _allList = new List<HydroHydrantViewModel>();
+            _changeHelper = changeHelper;
+            _propStatusHelper = propStatusHelper;
             allVisualViewModelList?.ForEach(x =>
             {
-                if (x.Catalog == HydroParterCatalogHelper.GetName(Yw.Hydro.ParterCatalog.Hydrant))
+                if (x.Vmo.Catalog == Yw.Hydro.ParterCatalog.Hydrant)
                 {
                     _allList.Add(x as HydroHydrantViewModel);
                 }
@@ -181,15 +199,24 @@
         /// <summary>
         /// 鏇存柊璁$畻灞炴��
         /// </summary>
-        public void UpdateCalcuProperty(List<HydroCalcuResult> allCalcuResultList)
+        public void UpdateCalcuProperty(List<HydroCalcuVisualResult> allCalcuResultList)
         {
-            if (allCalcuResultList != null && allCalcuResultList.Count > 0)
+            var allCalcuResultVisualDict = allCalcuResultList?.ToDictionary(x => x.Code);
+            UpdateCalcuProperty(allCalcuResultVisualDict);
+        }
+
+        /// <summary>
+        /// 鏇存柊璁$畻灞炴��
+        /// </summary>
+        public void UpdateCalcuProperty(Dictionary<string, HydroCalcuVisualResult> allCalcuResultVisualDict)
+        {
+            if (allCalcuResultVisualDict != null && allCalcuResultVisualDict.Count > 0)
             {
                 if (_allList != null && _allList.Count > 0)
                 {
                     foreach (var visual in _allList)
                     {
-                        var calcuResult = allCalcuResultList.Find(x => x.Code == visual.Code);
+                        var calcuResult = allCalcuResultVisualDict.GetValue(visual.Code);
                         if (calcuResult != null)
                         {
                             visual.UpdateCalcuProperty(calcuResult);
@@ -246,9 +273,13 @@
                 return;
             }
             var dlg = new SetHydroHydrantDlg();
-            dlg.SetBindingData(_allBindingList.Select(x => x.Vmo).ToList());
+            dlg.SetBindingData(_allBindingList.Select(x => x.Vmo).ToList(), _changeHelper, _propStatusHelper);
             dlg.ReloadDataEvent += (list) =>
             {
+                if (list == null || list.Count < 1)
+                {
+                    return;
+                }
                 _allBindingList.ForEach(x => x.UpdateProperty());
                 this.hydroHydrantViewModelBindingSource.ResetBindings(false);
                 var allVisualViewModelList = _allBindingList.Select(x => x as HydroVisualViewModel).ToList();
@@ -257,24 +288,6 @@
                 this.HydroChangedInfoEvent?.Invoke(allVisualInfoList);
             };
             dlg.ShowDialog();
-        }
-
-        //鏌ヨ
-        private void btnSearch_Click(object sender, EventArgs e)
-        {
-            Search();
-        }
-
-        //閲嶇疆
-        private void btnReset_Click(object sender, EventArgs e)
-        {
-            Reset();
-        }
-
-        //璁剧疆
-        private void btnSet_Click(object sender, EventArgs e)
-        {
-            Set();
         }
 
         private void gridView1_RowCellClick(object sender, DevExpress.XtraGrid.Views.Grid.RowCellClickEventArgs e)
@@ -288,9 +301,13 @@
             if (e.Column == this.colSet)
             {
                 var dlg = new SetHydroHydrantDlg();
-                dlg.SetBindingData(row.Vmo);
+                dlg.SetBindingData(row.Vmo, _changeHelper, _propStatusHelper);
                 dlg.ReloadDataEvent += (list) =>
                 {
+                    if (list == null || list.Count < 1)
+                    {
+                        return;
+                    }
                     row.UpdateProperty();
                     this.gridView1.RefreshRow(e.RowHandle);
                     this.HydroChangedViewEvent?.Invoke(new List<HydroVisualViewModel>() { row });
@@ -375,7 +392,7 @@
         /// <summary>
         /// 璁剧疆鎵归噺璁剧疆妯″紡
         /// </summary>
-        public void SetBulkSetView()
+        public void SetBulkView()
         {
             this.groupForHead.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always;
             this.colDbLocked.Visible = true;
@@ -394,7 +411,55 @@
             this.colSet.Visible = true;
         }
 
+        /// <summary>
+        /// 璁剧疆缁撴灉妯″紡
+        /// </summary>
+        public void SetResultView()
+        {
+            this.groupForHead.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never;
+            this.colDbLocked.Visible = true;
+            this.colName.Visible = true;
+            this.colCode.Visible = true;
+            this.colModelType.Visible = true;
+            this.colCoefficient.Visible = true;
+            this.colElev.Visible = true;
+            this.colMinorLoss.Visible = true;
+            this.colHasDb.Visible = true;
+            this.colFlags.Visible = true;
+            this.colDescription.Visible = true;
+            this.colCalcuPress.Visible = true;
+            this.colCalcuHead.Visible = true;
+            this.colCalcuDemand.Visible = true;
+            this.colSet.Visible = false;
+        }
 
+        /// <summary>
+        /// 
+        /// </summary>
+        public GridView GetGridView()
+        {
+            return this.gridView1;
+        }
+
+        /// <summary>
+        /// 
+        /// </summary>
+        public void ExportToXlsx()
+        {
+            var filePath = FileDialogHelper.SaveFile("瀵煎嚭Excel鏂囦欢", "Excel鏂囦欢|*.xlsx");
+            if (string.IsNullOrEmpty(filePath))
+            {
+                return;
+            }
+            var options = new XlsxExportOptions
+            {
+                ExportMode = XlsxExportMode.SingleFile, // 瀵煎嚭妯″紡
+                ShowGridLines = true, // 鏄剧ず缃戞牸绾�
+                TextExportMode = TextExportMode.Value, // 瀵煎嚭鏂囨湰妯″紡
+                SheetName = "娑堢伀鏍�" // 宸ヤ綔琛ㄥ悕绉�
+            };
+            this.gridView1.ExportToXlsx(filePath, options);
+        }
 
     }
 }

--
Gitblit v1.9.3