From 288e87195c7b604e87fe4b98aa759c5fff6e2346 Mon Sep 17 00:00:00 2001
From: lixiaojun <1287241240@qq.com>
Date: 星期三, 19 二月 2025 00:10:12 +0800
Subject: [PATCH] 能效分析

---
 WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/06-simulation/XhsProjectSimulationCorePage.cs |  298 +++++++++++++++++++++++++++++++++++++++++++++++------------
 1 files changed, 235 insertions(+), 63 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 3512cd2..1f14d3d 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
@@ -25,6 +25,10 @@
         #region 妯″瀷浜嬩欢
 
         /// <summary>
+        /// 鑾峰彇妯″瀷浜嬩欢
+        /// </summary>
+        public event Func<XhsSchemeVmo, Task<Yw.Model.HydroModelInfo>> GetModelEvent;
+        /// <summary>
         /// 鍒锋柊妯″瀷浜嬩欢
         /// </summary>
         public event Func<Task<Yw.Model.HydroModelInfo>> RefreshModelEvent;
@@ -1860,7 +1864,7 @@
             }
         }
 
-        #endregion 浜哄伐鍒锋柊
+        #endregion
 
         #region 鐩戞祴鐐�
 
@@ -1899,7 +1903,7 @@
             return await helper.GetAnalyseList();
         }
 
-        #endregion 鐩戞祴鐐�
+        #endregion
 
         #region 鐩戞祴鍊�
 
@@ -2685,8 +2689,154 @@
 
         #region 瀵煎嚭鎶ュ憡
 
+        //鍒涘缓鎵撳嵃淇℃伅
+        private async Task<SimulationPrintViewModel> CreatePrintInfo()
+        {
+            if (_project == null)
+            {
+                return default;
+            }
+            if (_hydroInfo == null)
+            {
+                return default;
+            }
+
+            #region 宸ュ喌鍒楄〃
+
+            var allWorkingList = GetCheckedWorkingList();
+            if (allWorkingList == null || allWorkingList.Count < 1)
+            {
+                var working = GetWorking();
+                if (working == null)
+                {
+                    TipFormHelper.ShowWarn("璇疯绠楁垨閫夋嫨宸ュ喌鍚庨噸璇曪紒");
+                    return default;
+                }
+                allWorkingList = new List<HydroWorkingVmo>() { working };
+            }
+
+            #endregion
+
+            #region 閫夋嫨鑺傜偣
+
+            var selectedNode = GetSelectNode();
+            if (selectedNode == null)
+            {
+                return default;
+            }
+
+            #endregion
+
+            var vm = new SimulationPrintViewModel();
+
+            #region 椤圭洰
+
+            vm.Project = new SimulationPrintProjectViewModel(_project);
+            if (_hydroInfo == null)
+            {
+                return vm;
+            }
+
+            #endregion
+
+            #region 姘存车鍒楄〃
+
+            vm.PumpList = _hydroInfo.Pumps?.Select(x =>
+                {
+                    var pump = new SimulationPrintPumpViewModel(x);
+                    return pump;
+                }).ToList();
+
+            #endregion
+
+            #region 闄勫姞淇℃伅
+
+            var allMonitorList = await GetMonitorList();
+            var allEvaluationList = await GetEvaluationList();
+
+            #endregion
+
+            #region 鍩虹妯″瀷
+
+            var baseHydroInfo = _hydroInfo;
+            if (_scheme != null)
+            {
+                baseHydroInfo = await GetModelEvent?.Invoke(null);
+            }
+            var baseHydroInfoRhs = baseHydroInfo.Adapt<Yw.Model.HydroModelInfo>();
+
+            #endregion
+
+            #region 閬嶅巻宸ュ喌
+
+            vm.WorkingList = new List<SimulationPrintWorkingViewModel>();
+            foreach (var working in allWorkingList)
+            {
+                baseHydroInfoRhs.UpdateWorkingInfo(working.WorkingInfo);
+                var calcuResult = baseHydroInfoRhs.Calcu(Yw.EPAnet.CalcuMode.MinorLoss, _calcuPressModeIsHead, allEvaluationList);
+
+                var printWorking = new SimulationPrintWorkingViewModel(working);
+                vm.WorkingList.Add(printWorking);
+
+                //绮惧害璇勪及
+                printWorking.Accuracy = SimulationPrintAccuracyHelper.Create(baseHydroInfoRhs, allMonitorList, working, calcuResult, _calcuPressModeIsHead, allEvaluationList);
+                //姘存车鍒嗘瀽
+                printWorking.PumpAnaly = SimulationPrintPumpAnalyHelper.Create(baseHydroInfoRhs, working, calcuResult, _calcuPressModeIsHead, allEvaluationList);
+                //鐩戞祴鍒嗘瀽
+                printWorking.MonitorAnaly = SimulationPrintMonitorAnalyHelper.Create(baseHydroInfoRhs, allMonitorList, working, calcuResult, _calcuPressModeIsHead, allEvaluationList);
+                //鑳借�楀垎鏋�
+                printWorking.EnergyAnaly = SimulationPrintEnergyAnalyHelper.Create(baseHydroInfoRhs, working, calcuResult, _calcuPressModeIsHead, allEvaluationList);
+                //鎹熷け缁熻
+                printWorking.LossStatistics = HydroLossStatisticsHelper.Create(baseHydroInfoRhs, working, calcuResult, _calcuPressModeIsHead, allEvaluationList);
+                //鎹熷け鏇茬嚎
+                printWorking.LossCurve = HydroLossCurveHelper.Create(baseHydroInfoRhs, working, selectedNode, calcuResult, _calcuPressModeIsHead, allEvaluationList);
+            }
+
+            #endregion
+
+            #region 鏂规澶勭悊
+
+            if (_scheme != null)
+            {
+                var hydroInfo = _hydroInfo;
+                var hydroInfoRhs = hydroInfo.Adapt<Yw.Model.HydroModelInfo>();
+                vm.Scheme = new SimulationPrintSchemeViewModel(_scheme);
+                foreach (var working in allWorkingList)
+                {
+                    hydroInfoRhs.UpdateWorkingInfo(working.WorkingInfo);
+                    var calcuResult = hydroInfoRhs.Calcu(Yw.EPAnet.CalcuMode.MinorLoss, _calcuPressModeIsHead, allEvaluationList);
+
+                    var printWorking = new SimulationPrintWorkingViewModel(working);
+                    vm.Scheme.WorkingList.Add(printWorking);
+
+                    //绮惧害璇勪及
+                    printWorking.Accuracy = SimulationPrintAccuracyHelper.Create(hydroInfoRhs, allMonitorList, working, calcuResult, _calcuPressModeIsHead, allEvaluationList);
+                    //姘存车鍒嗘瀽
+                    printWorking.PumpAnaly = SimulationPrintPumpAnalyHelper.Create(hydroInfoRhs, working, calcuResult, _calcuPressModeIsHead, allEvaluationList);
+                    //鐩戞祴鍒嗘瀽
+                    printWorking.MonitorAnaly = SimulationPrintMonitorAnalyHelper.Create(hydroInfoRhs, allMonitorList, working, calcuResult, _calcuPressModeIsHead, allEvaluationList);
+                    //鑳借�楀垎鏋�
+                    printWorking.EnergyAnaly = SimulationPrintEnergyAnalyHelper.Create(hydroInfoRhs, working, calcuResult, _calcuPressModeIsHead, allEvaluationList);
+                    //鎹熷け缁熻
+                    printWorking.LossStatistics = HydroLossStatisticsHelper.Create(hydroInfoRhs, working, calcuResult, _calcuPressModeIsHead, allEvaluationList);
+                    //鎹熷け鏇茬嚎
+                    printWorking.LossCurve = HydroLossCurveHelper.Create(hydroInfoRhs, working, selectedNode, calcuResult, _calcuPressModeIsHead, allEvaluationList);
+                }
+            }
+
+            #endregion 
+
+
+            return vm;
+        }
+
+        //瀵煎嚭word
         private async void barBtnExportWord_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
         {
+            var printInfo = await CreatePrintInfo();
+            var printDlg = new SimulationCommonReportDlg();
+            printDlg.SetBindingData(printInfo);
+            printDlg.ShowDialog();
             if (_visual == null)
             {
                 SelectInputSource();
@@ -2995,6 +3145,27 @@
             }
         }
 
+        //鑾峰彇閫夋嫨鑺傜偣
+        private HydroNodeInfo GetSelectNode()
+        {
+            if (_visual == null)
+            {
+                SelectInputSource();
+                if (_visual == null)
+                {
+                    TipFormHelper.ShowWarn("璇烽�夋嫨鏋勪欢鍚庨噸璇曪紒");
+                    return null;
+                }
+            }
+            HydroVisualInfo visual = _visual;
+            if (_visual is HydroLinkInfo linkInfo)
+            {
+                var visualListHelper = GetVisualListHelper();
+                visual = visualListHelper.GetVisual(linkInfo.StartCode);
+            }
+            return visual as HydroNodeInfo;
+        }
+
         //绮惧害璇勪及
         private async void barBtnWorkingEvaluation_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
         {
@@ -3074,11 +3245,18 @@
         }
 
         //鎹熷け缁熻
-        private void barBtnWorkingLossStatistics_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
+        private async void barBtnWorkingLossStatistics_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
         {
-            var workingCheckedListHelper = GetWorkingCheckedListHelper();
-            var allCheckedWorkingList = workingCheckedListHelper.GetCheckedWorkingList();
-            if (allCheckedWorkingList == null || allCheckedWorkingList.Count < 1)
+            if (_hydroInfo == null)
+            {
+                return;
+            }
+            var hydroInfo = _hydroInfo.Adapt<Yw.Model.HydroModelInfo>();
+            var isHead = _calcuPressModeIsHead;
+            var allEvaluationList = await GetEvaluationList();
+
+            var workingList = GetCheckedWorkingList();
+            if (workingList == null || workingList.Count < 1)
             {
                 var workingHelper = GetWorkingHelper();
                 if (!workingHelper.Initialized)
@@ -3086,16 +3264,15 @@
                     TipFormHelper.ShowWarn("璇疯绠楀悗閲嶈瘯锛�");
                     return;
                 }
-                var dlg = new HydroSingleWorkingLossStatisticsDlg();
-                dlg.SetBindingData(workingHelper.HydroInfo);
+                var dlg = new HydroLossStatisticsDlg();
+                dlg.SetBindingData(hydroInfo, workingHelper.Working, workingHelper.CalcuResult, isHead, allEvaluationList);
                 dlg.ShowDialog();
+                return;
             }
-            else
-            {
-                var dlg = new HydroMultiWorkingLossStatisticsDlg();
-                dlg.SetBindingData(_hydroInfo, allCheckedWorkingList);
-                dlg.ShowDialog();
-            }
+
+            var workingDlg = new HydroLossStatisticsWorkingDlg();
+            workingDlg.SetBindingData(hydroInfo, workingList, isHead, allEvaluationList);
+            workingDlg.ShowDialog();
         }
 
         //缁煎悎鍒嗘瀽
@@ -3145,39 +3322,39 @@
             }
         }
 
-        #endregion 宸ュ喌鍒嗘瀽
+        #endregion
 
         #region 鎹熷け鏇茬嚎
 
-        //鍗曞伐鍐垫崯澶辨洸绾挎帶浠�
-        private HydroSingleWorkingLossCurveInteropCtrl _singleWorkingLossCurveCtrl = null;
+        //鎹熷け鏇茬嚎浜や簰鎺т欢
+        private HydroLossCurveInteropCtrl _lossCurveInteropCtrl = null;
 
-        //鑾峰彇鍗曞伐鍐垫崯澶辨洸绾挎帶浠�
-        private HydroSingleWorkingLossCurveInteropCtrl GetSingleWorkingLossCurveCtrl()
+        //鑾峰彇鎹熷け鏇茬嚎浜や簰鎺т欢
+        private HydroLossCurveInteropCtrl GetLossCurveInteropCtrl()
         {
-            if (_singleWorkingLossCurveCtrl == null)
+            if (_lossCurveInteropCtrl == null)
             {
-                _singleWorkingLossCurveCtrl = new HydroSingleWorkingLossCurveInteropCtrl();
-                _singleWorkingLossCurveCtrl.Dock = DockStyle.Fill;
-                _singleWorkingLossCurveCtrl.HydroClickEvent += (code) =>
+                _lossCurveInteropCtrl = new HydroLossCurveInteropCtrl();
+                _lossCurveInteropCtrl.Dock = DockStyle.Fill;
+                _lossCurveInteropCtrl.HydroClickEvent += (code) =>
                 {
                     var visual = GetVisual(code);
                     SelectVisual(visual, eSimulationVisualSource.None);
                 };
-                _singleWorkingLossCurveCtrl.HydroSpecialDisplayEvent += (list) =>
+                _lossCurveInteropCtrl.HydroSpecialDisplayEvent += (list) =>
                 {
                     _bimfaceCtrl?.SetLogicOutlineGlowEffect(list);
                 };
-                _singleWorkingLossCurveCtrl.HydroCancelSpecialDisplayEvent += () =>
+                _lossCurveInteropCtrl.HydroCancelSpecialDisplayEvent += () =>
                 {
                     _bimfaceCtrl?.RemoveLogicOutlineGlowEffect();
                 };
             }
-            return _singleWorkingLossCurveCtrl;
+            return _lossCurveInteropCtrl;
         }
 
-        //鍗曞伐鍐垫崯澶辨洸绾挎帶浠舵槸鍚﹀彲瑙�
-        private bool IsSingleWorkingLossCurveCtrlVisible
+        //鎹熷け鏇茬嚎鎺т欢鏄惁鍙
+        private bool IsLossCurveInteropCtrlVisible
         {
             get
             {
@@ -3185,7 +3362,7 @@
                 {
                     if (this.controlContainerBottom.Controls.Count > 0)
                     {
-                        if (this.controlContainerBottom.Controls[0] is HydroSingleWorkingLossCurveInteropCtrl)
+                        if (this.controlContainerBottom.Controls[0] is HydroLossCurveInteropCtrl)
                         {
                             return true;
                         }
@@ -3195,43 +3372,43 @@
             }
         }
 
-        //鏄剧ず鍗曞伐鍐垫崯澶辨洸绾挎帶浠�
-        private void ShowSingleWorkingLossCurveCtrl(Yw.Model.HydroModelInfo hydroInfo, HydroCalcuResult calcuResult, HydroVisualInfo visual)
+        //鏄剧ず鎹熷け鏇茬嚎鎺т欢
+        private void ShowLossCurveInteropCtrl
+            (
+                Yw.Model.HydroModelInfo hydroInfo,
+                HydroWorkingVmo working,
+                HydroNodeInfo node,
+                HydroCalcuResult calcuResult = null,
+                bool isHead = false,
+                List<HydroEvaluationVmo> allEvaluationList = null
+            )
         {
-            var singleWorkingLossCurveCtrl = GetSingleWorkingLossCurveCtrl();
-            if (!IsSingleWorkingLossCurveCtrlVisible)
+            var ctrl = GetLossCurveInteropCtrl();
+            if (!IsLossCurveInteropCtrlVisible)
             {
                 this.controlContainerBottom.Controls.Clear();
-                this.controlContainerBottom.Controls.Add(singleWorkingLossCurveCtrl);
+                this.controlContainerBottom.Controls.Add(ctrl);
                 this.docPnlBottom.Visibility = DevExpress.XtraBars.Docking.DockVisibility.Visible;
                 this.docPnlBottom.Text = "鎹熷け鏇茬嚎";
                 this.docPnlBottom.Height = 350;
             }
-            singleWorkingLossCurveCtrl.SetBindingData(hydroInfo, calcuResult, visual);
+            ctrl.SetBindingData(hydroInfo, working, node, calcuResult, isHead, allEvaluationList);
         }
 
         //鎹熷け鏇茬嚎
-        private void barBtnWorkingLossCurve_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
+        private async void barBtnLossCurve_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
         {
-            if (_visual == null)
+            var node = GetSelectNode();
+            if (node == null)
             {
-                SelectInputSource();
-                if (_visual == null)
-                {
-                    TipFormHelper.ShowWarn("璇烽�夋嫨鏋勪欢鍚庨噸璇曪紒");
-                    return;
-                }
-            }
-            HydroVisualInfo visual = _visual;
-            if (_visual is HydroLinkInfo linkInfo)
-            {
-                var visualListHelper = GetVisualListHelper();
-                visual = visualListHelper.GetVisual(linkInfo.StartCode);
+                return;
             }
 
-            var workingCheckedListHelper = GetWorkingCheckedListHelper();
-            var allCheckedWorkingList = workingCheckedListHelper.GetCheckedWorkingList();
-            if (allCheckedWorkingList == null || allCheckedWorkingList.Count < 1)
+            var isHead = _calcuPressModeIsHead;
+            var allEvaluationList = await GetEvaluationList();
+
+            var workingList = GetCheckedWorkingList();
+            if (workingList == null || workingList.Count < 1)
             {
                 var workingHelper = GetWorkingHelper();
                 if (!workingHelper.Initialized)
@@ -3239,18 +3416,13 @@
                     TipFormHelper.ShowWarn("璇疯绠楀悗閲嶈瘯锛�");
                     return;
                 }
-                ShowSingleWorkingLossCurveCtrl(workingHelper.HydroInfo, workingHelper.CalcuResult, visual);
+                ShowLossCurveInteropCtrl(workingHelper.HydroInfo, workingHelper.Working, node, workingHelper.CalcuResult, isHead, allEvaluationList);
+                return;
             }
-            else
-            {
-                var dlg = new HydroMultiWorkingLossCurveDlg();
-                dlg.HydroClickEvent += (code) =>
-                {
-                    SelectVisual(code, eSimulationVisualSource.None);
-                };
-                dlg.SetBindingData(_hydroInfo, allCheckedWorkingList, visual);
-                dlg.ShowDialog();
-            }
+
+            var dlg = new HydroLossCurveMultiWorkingDlg();
+            dlg.SetBindingData(_hydroInfo, workingList, node, _calcuPressModeIsHead, allEvaluationList);
+            dlg.ShowDialog();
         }
 
         #endregion

--
Gitblit v1.9.3