lixiaojun
2025-02-17 4bb44a9c6b32cf299f3103f66d720992ec4a89a2
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 = SimulationPrintLossStatisticsHelper.Create(baseHydroInfoRhs, working, calcuResult, _calcuPressModeIsHead, allEvaluationList);
                //损失曲线
                printWorking.LossCurve = SimulationPrintLossCurveHelper.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 = SimulationPrintLossStatisticsHelper.Create(hydroInfoRhs, working, calcuResult, _calcuPressModeIsHead, allEvaluationList);
                    //损失曲线
                    printWorking.LossCurve = SimulationPrintLossCurveHelper.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)
        {