lixiaojun
2025-02-19 288e87195c7b604e87fe4b98aa759c5fff6e2346
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;
@@ -982,8 +986,11 @@
            WaitFormHelper.ShowWaitForm("正在保存,请稍后...");
            var bol = await BLLFactory<Yw.BLL.HydroModelInfo>.Instance
                .Update(_hydroInfo, addParterList, updateParterList, removeParters);
            if (!bol)
            {
                WaitFormHelper.HideWaitForm();
@@ -1830,7 +1837,7 @@
            gradingHelper.Set();
        }
        #endregion 颜色分级
        #endregion
        #region 人工刷新
@@ -1857,7 +1864,7 @@
            }
        }
        #endregion 人工刷新
        #endregion
        #region 监测点
@@ -1896,7 +1903,7 @@
            return await helper.GetAnalyseList();
        }
        #endregion 监测点
        #endregion
        #region 监测值
@@ -2513,6 +2520,59 @@
        #endregion
        #region 评价规则
        //评价规则辅助类
        private SimulationEvaluationHelper _evaluationHelper = null;
        //获取评价规则辅助类
        private SimulationEvaluationHelper GetEvaluationHelper()
        {
            if (_evaluationHelper == null)
            {
                _evaluationHelper = new SimulationEvaluationHelper(_hydroInfo.ID);
            }
            return _evaluationHelper;
        }
        //获取评价规则列表
        private async Task<List<Yw.Vmo.HydroEvaluationVmo>> GetEvaluationList()
        {
            var helper = GetEvaluationHelper();
            return await helper.GetEvaluationList();
        }
        //设置评价规则列表
        private void SetEvaluationList(List<Yw.Vmo.HydroEvaluationVmo> allEvaluationList)
        {
            var helper = GetEvaluationHelper();
            helper.SetEvaluationList(allEvaluationList);
        }
        //显示评价窗体
        private void ShowEvaluationDlg()
        {
            if (_hydroInfo == null)
            {
                return;
            }
            var dlg = new SetHydroEvaluationModelDlg();
            dlg.SetBindingData(_hydroInfo.ID);
            dlg.ReloadDataEvent += (rhs) =>
            {
                SetEvaluationList(rhs);
            };
            dlg.ShowDialog();
        }
        //评价规则
        private void barBtnEvaluation_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            ShowEvaluationDlg();
        }
        #endregion
        #region 水力计算
        //计算
@@ -2629,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();
@@ -2939,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)
        {
@@ -3018,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)
@@ -3030,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();
        }
        //综合分析
@@ -3089,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
            {
@@ -3129,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;
                        }
@@ -3139,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)
@@ -3183,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
@@ -3277,5 +3505,6 @@
    }
}