lixiaojun
2024-12-13 3d0d8f7aa9f58ca8759f15001caf4e1e78bb99d1
WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/06-simulation/XhsProjectSimulationCorePage.cs
@@ -4,6 +4,7 @@
using DevExpress.XtraMap;
using HStation.WinFrmUI.PhartRelation;
using Mapster;
using NPOI.OpenXmlFormats.Dml;
using NPOI.SS.Formula.Functions;
using System.Diagnostics;
using Yw.EPAnet;
@@ -30,6 +31,26 @@
        /// </summary>
        public event Action<HydroWorkingVmo> AppendWorkingEvent;
        /// <summary>
        /// 保存模型事件
        /// </summary>
        public event Func<Yw.Model.HydroModelInfo, Task<Yw.Model.HydroModelInfo>> SaveModelEvent;
        /// <summary>
        /// 刷新模型事件
        /// </summary>
        public event Func<Task<Yw.Model.HydroModelInfo>> RefreshModelEvent;
        /// <summary>
        /// 更新方案事件
        /// </summary>
        public event Action<XhsSchemeVmo> UpdateSchemeEvent;
        /// <summary>
        /// 移除方案事件
        /// </summary>
        public event Action<XhsSchemeVmo> RemoveSchemeEvent;
        private HStation.Vmo.XhsProjectVmo _project = null;//项目
        private HStation.Vmo.XhsProjectSiteVmo _projectSite = null;//项目站
        private HStation.Vmo.XhsSchemeVmo _scheme = null;//方案
@@ -54,6 +75,16 @@
            _hydroInfo = hydroInfo;
            _allWorkingCheckedListDict = allWorkingCheckedListDict;
            ResetMonitorValue();
            if (_scheme == null)
            {
                this.ribPageGroupForScheme.Visible = false;
                this.PageTitle.Caption = $"水力模拟";
            }
            else
            {
                this.ribPageGroupForScheme.Visible = true;
                this.PageTitle.Caption = $"模拟方案\r\n{_scheme.Name}";
            }
        }
        /// <summary>
@@ -95,7 +126,7 @@
                {//鼠标左键点击事件
                    var visualListHelper = GetVisualListHelper();
                    var visual = visualListHelper.GetVisual(code);
                    SelectVisual(visual, eVisualSource.Bimface);
                    SelectVisual(visual, eSimulationVisualSource.Bimface);
                };
            }
            return _bimfaceCtrl;
@@ -109,7 +140,7 @@
            this.tabPageBimface.Controls.Add(bimfaceCtrl);
        }
        #endregion
        #endregion BIM控件
        #region Q3d控件
@@ -132,7 +163,7 @@
                {
                    var visualListHelper = GetVisualListHelper();
                    var visuals = visualListHelper.GetVisualList(codes);
                    SelectVisual(visuals?.LastOrDefault(), eVisualSource.Q3d);
                    SelectVisual(visuals?.LastOrDefault(), eSimulationVisualSource.Q3d);
                };
            }
            return _q3dCtrl;
@@ -146,7 +177,7 @@
            this.tabPageQ3d.Controls.Add(q3dCtrl);
        }
        #endregion
        #endregion Q3d控件
        #region 属性控件
@@ -167,7 +198,7 @@
                _propertyCtrl.AllowEdit = true;
                _propertyCtrl.HydroViewEvent += (visual) =>
                {
                    SelectVisual(visual, eVisualSource.Property);
                    SelectVisual(visual, eSimulationVisualSource.Property);
                };
                _propertyCtrl.BlinkLinkNodeEvent += async (link, linkNodeCode) =>
                { //强调连接节点
@@ -237,7 +268,6 @@
                    var flowEffectHelper = await GetFlowEffectHelper();
                    flowEffectHelper.Set(visual);
                };
            }
            return _propertyCtrl;
        }
@@ -292,122 +322,117 @@
            _propertyCtrl?.UpdateRows();
        }
        #endregion
        #endregion 属性控件
        #region 选择构件
        //可见来源
        protected enum eVisualSource
        {
            None,
            Bimface,
            Q3d,
            Property,
            List,
            Set,
            Search,
            Monitor,
            Check,
            Calcu,
            Warning,
        }
        //选择构件
        private Yw.Model.HydroVisualInfo _visual = null;
        //选择构件
        private void SelectVisual(HydroVisualInfo visual, eVisualSource source)
        private void SelectVisual(HydroVisualInfo visual, eSimulationVisualSource source)
        {
            _visual = visual;
            switch (source)
            {
                case eVisualSource.None:
                case eSimulationVisualSource.None:
                    {
                        _bimfaceCtrl?.ZoomAndSelectComponent(visual?.Code);
                        this.barBtnSetMonitor.Enabled = visual != null;
                        SetPropertyCtrl(visual);
                    }
                    break;
                case eVisualSource.Bimface:
                case eSimulationVisualSource.Bimface:
                    {
                        this.barBtnSetMonitor.Enabled = visual != null;
                        SetPropertyCtrl(visual);
                    }
                    break;
                case eVisualSource.Q3d:
                case eSimulationVisualSource.Q3d:
                    {
                        _bimfaceCtrl?.ZoomAndSelectComponent(visual?.Code);
                        this.barBtnSetMonitor.Enabled = visual != null;
                        SetPropertyCtrl(visual);
                    }
                    break;
                case eVisualSource.Property:
                case eSimulationVisualSource.Property:
                    {
                        _bimfaceCtrl?.ZoomAndSelectComponent(visual?.Code);
                        this.barBtnSetMonitor.Enabled = visual != null;
                    }
                    break;
                case eVisualSource.List:
                case eSimulationVisualSource.List:
                    {
                        _bimfaceCtrl?.ZoomAndSelectComponent(visual?.Code);
                        this.barBtnSetMonitor.Enabled = visual != null;
                        SetPropertyCtrl(visual);
                    }
                    break;
                case eVisualSource.Set:
                case eSimulationVisualSource.Set:
                    {
                        _bimfaceCtrl?.ZoomAndSelectComponent(visual?.Code);
                        this.barBtnSetMonitor.Enabled = visual != null;
                        SetPropertyCtrl(visual);
                    }
                    break;
                case eVisualSource.Search:
                case eSimulationVisualSource.Search:
                    {
                        _bimfaceCtrl?.ZoomAndSelectComponent(visual?.Code);
                        this.barBtnSetMonitor.Enabled = visual != null;
                        SetPropertyCtrl(visual);
                    }
                    break;
                case eVisualSource.Monitor:
                case eSimulationVisualSource.Monitor:
                    {
                        _bimfaceCtrl?.ZoomAndSelectComponent(visual?.Code);
                        this.barBtnSetMonitor.Enabled = visual != null;
                        SetPropertyCtrl(visual);
                    }
                    break;
                case eVisualSource.Check:
                case eSimulationVisualSource.Check:
                    {
                        _bimfaceCtrl?.ZoomAndSelectComponent(visual?.Code);
                        this.barBtnSetMonitor.Enabled = visual != null;
                        SetPropertyCtrl(visual);
                    }
                    break;
                case eVisualSource.Calcu:
                case eSimulationVisualSource.Calcu:
                    {
                        _bimfaceCtrl?.ZoomAndSelectComponent(visual?.Code);
                        this.barBtnSetMonitor.Enabled = visual != null;
                        SetPropertyCtrl(visual);
                    }
                    break;
                case eVisualSource.Warning:
                case eSimulationVisualSource.Warning:
                    {
                        _bimfaceCtrl?.ZoomAndSelectComponent(visual?.Code);
                        this.barBtnSetMonitor.Enabled = visual != null;
                        SetPropertyCtrl(visual);
                    }
                    break;
                default: break;
            }
        }
        //选择构件
        private void SelectVisual(string code, eVisualSource source)
        private void SelectVisual(string code, eSimulationVisualSource source)
        {
            var visual = GetVisual(code);
            SelectVisual(visual, source);
        }
        #endregion
        #endregion 选择构件
        #region 构件明细
@@ -425,6 +450,13 @@
                _visualListHelper.InitialData(_hydroInfo);
            }
            return _visualListHelper;
        }
        //重置可见列表
        private void ResetVisualList()
        {
            var helper = GetVisualListHelper();
            helper.InitialData(_hydroInfo);
        }
        //获取可见构件
@@ -449,7 +481,7 @@
            return helper.GetSourceList();
        }
        #endregion
        #endregion 可见列表
        #region 视图列表
@@ -479,7 +511,14 @@
            return helper.GetVisualList();
        }
        #endregion
        //获取可见视图
        private HydroVisualViewModel GetVisualViewModel(string code)
        {
            var helper = GetVisualVmListHelper();
            return helper.GetVisual(code);
        }
        #endregion 视图列表
        #region 明细控件
@@ -495,11 +534,11 @@
                _visualListCtrl.Dock = DockStyle.Fill;
                _visualListCtrl.HydroClickInfoEvent += (visual) =>
                {
                    SelectVisual(visual, eVisualSource.List);
                    SelectVisual(visual, eSimulationVisualSource.List);
                };
                _visualListCtrl.HydroChangedInfoEvent += (visualList) =>
                {
                    SelectVisual(_visual, eVisualSource.List);
                    SelectVisual(_visual, eSimulationVisualSource.List);
                };
            }
            return _visualListCtrl;
@@ -579,7 +618,7 @@
            ShowVisualListCtrl();
        }
        #endregion
        #endregion 明细控件
        #region 构件显示
@@ -628,9 +667,9 @@
            SetVisualVisible();
        }
        #endregion
        #endregion 构件显示
        #endregion
        #endregion 构件明细
        #region 一键显隐
@@ -654,7 +693,9 @@
            SetDecoratorVisible(this.barCkDecorator.Checked);
        }
        #endregion
        #endregion 一键显隐
        #region 保存信息
@@ -665,27 +706,29 @@
            {
                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)
            if (this.SaveModelEvent == null)
            {
                return;
            }
            var hydroInfo = await this.SaveModelEvent.Invoke(_hydroInfo);
            if (hydroInfo == null)
            {
                TipFormHelper.ShowError("保存失败!");
                return;
            }
            _hydroInfo = await BLLFactory<Yw.BLL.HydroModelInfo>.Instance.GetByID(id);
            _hydroInfo = hydroInfo;
            TipFormHelper.ShowSucceed("保存成功!");
            //Stopwatch sw = new Stopwatch();
            //sw.Start();
            //耗时巨大的代码
            //sw.Stop();
            //TimeSpan ts2 = sw.Elapsed;
            //Console.WriteLine("Stopwatch总共花费{0}ms.", ts2.TotalMilliseconds);
        }
        #endregion
        #endregion 保存信息
        #region 批量配置
@@ -700,11 +743,11 @@
                dlg.SetBindingData(allVisualViewModelList);
                dlg.HydroClickInfoEvent += (visual) =>
                {
                    SelectVisual(visual, eVisualSource.Set);
                    SelectVisual(visual, eSimulationVisualSource.Set);
                };
                dlg.HydroChangedInfoEvent += visuals =>
                {
                    SelectVisual(visuals?.FirstOrDefault(), eVisualSource.Set);
                    SelectVisual(visuals?.FirstOrDefault(), eSimulationVisualSource.Set);
                    UpdateVisualListCtrl();
                };
                dlg.ShowDialog();
@@ -717,11 +760,11 @@
                dlg.SetBindingData(allVisualViewModelList);
                dlg.HydroClickInfoEvent += (visual) =>
                {
                    SelectVisual(visual, eVisualSource.Set);
                    SelectVisual(visual, eSimulationVisualSource.Set);
                };
                dlg.HydroChangedInfoEvent += visuals =>
                {
                    SelectVisual(visuals?.FirstOrDefault(), eVisualSource.Set);
                    SelectVisual(visuals?.FirstOrDefault(), eSimulationVisualSource.Set);
                    UpdateVisualListCtrl();
                };
                dlg.ShowDialog();
@@ -734,11 +777,11 @@
                dlg.SetBindingData(allVisualViewModelList);
                dlg.HydroClickInfoEvent += (visual) =>
                {
                    SelectVisual(visual, eVisualSource.Set);
                    SelectVisual(visual, eSimulationVisualSource.Set);
                };
                dlg.HydroChangedInfoEvent += visuals =>
                {
                    SelectVisual(visuals?.FirstOrDefault(), eVisualSource.Set);
                    SelectVisual(visuals?.FirstOrDefault(), eSimulationVisualSource.Set);
                    UpdateVisualListCtrl();
                };
                dlg.ShowDialog();
@@ -751,11 +794,11 @@
                dlg.SetBindingData(allVisualViewModelList);
                dlg.HydroClickInfoEvent += (visual) =>
                {
                    SelectVisual(visual, eVisualSource.Set);
                    SelectVisual(visual, eSimulationVisualSource.Set);
                };
                dlg.HydroChangedInfoEvent += visuals =>
                {
                    SelectVisual(visuals?.FirstOrDefault(), eVisualSource.Set);
                    SelectVisual(visuals?.FirstOrDefault(), eSimulationVisualSource.Set);
                    UpdateVisualListCtrl();
                };
                dlg.ShowDialog();
@@ -768,11 +811,11 @@
                dlg.SetBindingData(allVisualViewModelList);
                dlg.HydroClickInfoEvent += (visual) =>
                {
                    SelectVisual(visual, eVisualSource.Set);
                    SelectVisual(visual, eSimulationVisualSource.Set);
                };
                dlg.HydroChangedInfoEvent += visuals =>
                {
                    SelectVisual(visuals?.FirstOrDefault(), eVisualSource.Set);
                    SelectVisual(visuals?.FirstOrDefault(), eSimulationVisualSource.Set);
                    UpdateVisualListCtrl();
                };
                dlg.ShowDialog();
@@ -785,11 +828,11 @@
                dlg.SetBindingData(allVisualVmList);
                dlg.HydroClickInfoEvent += (visual) =>
                {
                    SelectVisual(visual, eVisualSource.Set);
                    SelectVisual(visual, eSimulationVisualSource.Set);
                };
                dlg.HydroChangedInfoEvent += visuals =>
                {
                    SelectVisual(visuals?.FirstOrDefault(), eVisualSource.Set);
                    SelectVisual(visuals?.FirstOrDefault(), eSimulationVisualSource.Set);
                    UpdateVisualListCtrl();
                };
                dlg.ShowDialog();
@@ -802,11 +845,11 @@
                dlg.SetBindingData(allVisualViewModelList);
                dlg.HydroClickInfoEvent += (visual) =>
                {
                    SelectVisual(visual, eVisualSource.Set);
                    SelectVisual(visual, eSimulationVisualSource.Set);
                };
                dlg.HydroChangedInfoEvent += visuals =>
                {
                    SelectVisual(visuals?.FirstOrDefault(), eVisualSource.Set);
                    SelectVisual(visuals?.FirstOrDefault(), eSimulationVisualSource.Set);
                    UpdateVisualListCtrl();
                };
                dlg.ShowDialog();
@@ -819,11 +862,11 @@
                dlg.SetBindingData(allVisualViewModelList);
                dlg.HydroClickInfoEvent += (visual) =>
                {
                    SelectVisual(visual, eVisualSource.Set);
                    SelectVisual(visual, eSimulationVisualSource.Set);
                };
                dlg.HydroChangedInfoEvent += visuals =>
                {
                    SelectVisual(visuals?.FirstOrDefault(), eVisualSource.Set);
                    SelectVisual(visuals?.FirstOrDefault(), eSimulationVisualSource.Set);
                    UpdateVisualListCtrl();
                };
                dlg.ShowDialog();
@@ -836,11 +879,11 @@
                dlg.SetBindingData(allVisualViewModelList);
                dlg.HydroClickInfoEvent += (visual) =>
                {
                    SelectVisual(visual, eVisualSource.Set);
                    SelectVisual(visual, eSimulationVisualSource.Set);
                };
                dlg.HydroChangedInfoEvent += visuals =>
                {
                    SelectVisual(visuals?.FirstOrDefault(), eVisualSource.Set);
                    SelectVisual(visuals?.FirstOrDefault(), eSimulationVisualSource.Set);
                    UpdateVisualListCtrl();
                };
                dlg.ShowDialog();
@@ -853,11 +896,11 @@
                dlg.SetBindingData(allVisualViewModelList);
                dlg.HydroClickInfoEvent += (visual) =>
                {
                    SelectVisual(visual, eVisualSource.Set);
                    SelectVisual(visual, eSimulationVisualSource.Set);
                };
                dlg.HydroChangedInfoEvent += visuals =>
                {
                    SelectVisual(visuals?.FirstOrDefault(), eVisualSource.Set);
                    SelectVisual(visuals?.FirstOrDefault(), eSimulationVisualSource.Set);
                    UpdateVisualListCtrl();
                };
                dlg.ShowDialog();
@@ -870,11 +913,11 @@
                dlg.SetBindingData(allVisualViewModelList);
                dlg.HydroClickInfoEvent += (visual) =>
                {
                    SelectVisual(visual, eVisualSource.Set);
                    SelectVisual(visual, eSimulationVisualSource.Set);
                };
                dlg.HydroChangedInfoEvent += visuals =>
                {
                    SelectVisual(visuals?.FirstOrDefault(), eVisualSource.Set);
                    SelectVisual(visuals?.FirstOrDefault(), eSimulationVisualSource.Set);
                    UpdateVisualListCtrl();
                };
                dlg.ShowDialog();
@@ -887,11 +930,11 @@
                dlg.SetBindingData(allVisualViewModelList);
                dlg.HydroClickInfoEvent += (visual) =>
                {
                    SelectVisual(visual, eVisualSource.Set);
                    SelectVisual(visual, eSimulationVisualSource.Set);
                };
                dlg.HydroChangedInfoEvent += visuals =>
                {
                    SelectVisual(visuals?.FirstOrDefault(), eVisualSource.Set);
                    SelectVisual(visuals?.FirstOrDefault(), eSimulationVisualSource.Set);
                    UpdateVisualListCtrl();
                };
                dlg.ShowDialog();
@@ -904,11 +947,11 @@
                dlg.SetBindingData(allVisualViewModelList);
                dlg.HydroClickInfoEvent += (visual) =>
                {
                    SelectVisual(visual, eVisualSource.Set);
                    SelectVisual(visual, eSimulationVisualSource.Set);
                };
                dlg.HydroChangedInfoEvent += visuals =>
                {
                    SelectVisual(visuals?.FirstOrDefault(), eVisualSource.Set);
                    SelectVisual(visuals?.FirstOrDefault(), eSimulationVisualSource.Set);
                    UpdateVisualListCtrl();
                };
                dlg.ShowDialog();
@@ -921,11 +964,11 @@
                dlg.SetBindingData(allVisualViewModelList);
                dlg.HydroClickInfoEvent += (visual) =>
                {
                    SelectVisual(visual, eVisualSource.Set);
                    SelectVisual(visual, eSimulationVisualSource.Set);
                };
                dlg.HydroChangedInfoEvent += visuals =>
                {
                    SelectVisual(visuals?.FirstOrDefault(), eVisualSource.Set);
                    SelectVisual(visuals?.FirstOrDefault(), eSimulationVisualSource.Set);
                    UpdateVisualListCtrl();
                };
                dlg.ShowDialog();
@@ -938,11 +981,11 @@
                dlg.SetBindingData(allVisualViewModelList);
                dlg.HydroClickInfoEvent += (visual) =>
                {
                    SelectVisual(visual, eVisualSource.Set);
                    SelectVisual(visual, eSimulationVisualSource.Set);
                };
                dlg.HydroChangedInfoEvent += visuals =>
                {
                    SelectVisual(visuals?.FirstOrDefault(), eVisualSource.Set);
                    SelectVisual(visuals?.FirstOrDefault(), eSimulationVisualSource.Set);
                    UpdateVisualListCtrl();
                };
                dlg.ShowDialog();
@@ -955,11 +998,11 @@
                dlg.SetBindingData(allVisualViewModelList);
                dlg.HydroClickInfoEvent += (visual) =>
                {
                    SelectVisual(visual, eVisualSource.Set);
                    SelectVisual(visual, eSimulationVisualSource.Set);
                };
                dlg.HydroChangedInfoEvent += visuals =>
                {
                    SelectVisual(visuals?.FirstOrDefault(), eVisualSource.Set);
                    SelectVisual(visuals?.FirstOrDefault(), eSimulationVisualSource.Set);
                    UpdateVisualListCtrl();
                };
                dlg.ShowDialog();
@@ -972,17 +1015,16 @@
                dlg.SetBindingData(allVisualViewModelList);
                dlg.HydroClickInfoEvent += (visual) =>
                {
                    SelectVisual(visual, eVisualSource.Set);
                    SelectVisual(visual, eSimulationVisualSource.Set);
                };
                dlg.HydroChangedInfoEvent += visuals =>
                {
                    SelectVisual(visuals?.FirstOrDefault(), eVisualSource.Set);
                    SelectVisual(visuals?.FirstOrDefault(), eSimulationVisualSource.Set);
                    UpdateVisualListCtrl();
                };
                dlg.ShowDialog();
            };
        }
        //显示RadialMenu
        private void barBtnSetList_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
@@ -1187,11 +1229,9 @@
            {
                this.barBtnSetCompressorList.Visibility = DevExpress.XtraBars.BarItemVisibility.Always;
            }
        }
        #endregion
        #endregion 批量配置
        #region 构件查询
@@ -1210,12 +1250,12 @@
                _searchCtrl.InitialData(allVisualVmList);
                _searchCtrl.HydroClickInfoEvent += (visual) =>
                {
                    SelectVisual(visual, eVisualSource.Check);
                    SelectVisual(visual, eSimulationVisualSource.Check);
                };
                _searchCtrl.HydroSearchInfoEvent += (list) =>
                {
                    var visual = list?.FirstOrDefault();
                    SelectVisual(visual, eVisualSource.Search);
                    SelectVisual(visual, eSimulationVisualSource.Search);
                };
            }
            return _searchCtrl;
@@ -1282,7 +1322,7 @@
            ShowSearchDlg();
        }
        #endregion
        #endregion 构件查询
        #region 模型标注
@@ -1334,7 +1374,7 @@
            markHelper.Set();
        }
        #endregion
        #endregion 模型标注
        #region 颜色分级
@@ -1416,42 +1456,34 @@
            gradingHelper.Set();
        }
        #endregion
        #endregion 颜色分级
        #region 人工刷新
        //刷新
        private async void barBtnRefresh_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (this.RefreshModelEvent == null)
            {
                return;
            }
            if (XtraMessageBox.Show("刷新后将丢失当前水力信息更改,是否继续刷新?", "询问", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                if (_project == null)
                var hydroInfo = await this.RefreshModelEvent.Invoke();
                if (hydroInfo == null)
                {
                    TipFormHelper.ShowError("刷新失败!");
                    return;
                }
                if (_projectSite == null)
                {
                    return;
                }
                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);
                sw.Stop();
                TimeSpan ts2 = sw.Elapsed;
                Console.WriteLine("Stopwatch总共花费{0}ms.", ts2.TotalMilliseconds);
                _visual = null;
                await _bimfaceCtrl?.ZoomAndSelectComponents(null);
                //ShowSelectedProperty();
                TipFormHelper.ShowSucceed("数据已刷新");
                _hydroInfo = hydroInfo;
                SelectVisual(visual: null, eSimulationVisualSource.None);
                var visualListHelper = GetVisualListHelper();
                visualListHelper.InitialData(_hydroInfo);
                ResetVisualList();
                TipFormHelper.ShowSucceed("刷新成功!");
            }
        }
        #endregion
        #endregion 人工刷新
        #region 水流动画
@@ -1484,7 +1516,7 @@
            flowEffectHelper.Set();
        }
        #endregion
        #endregion 水流动画
        #region 监测列表
@@ -1506,6 +1538,13 @@
                _monitorHelper = new SimulationMonitorHelper(visualListHelper);
            }
            return _monitorHelper;
        }
        //获取监测点列表
        private async Task<List<HydroMonitorVmo>> GetMonitorList()
        {
            var helper = GetMonitorHelper();
            return await helper.Get();
        }
        //设置监测点列表
@@ -1544,7 +1583,7 @@
            SetMonitorList(_visual);
        }
        #endregion
        #endregion 监测点
        #region 监测值
@@ -1567,16 +1606,15 @@
        private void ResetMonitorValue()
        {
            var allWorkingList = GetWorkingList();
            var working = allWorkingList?.Last(x => !string.IsNullOrEmpty(x.MonitorInfo));
            var working = allWorkingList?.LastOrDefault(x => !string.IsNullOrEmpty(x.MonitorInfo));
            if (working != null)
            {
                var helper = GetMonitorValueHelper();
                helper.Reset(working.MonitorInfo);
            }
        }
        #endregion
        #endregion 监测值
        #region 监测值控件
@@ -1594,7 +1632,7 @@
                {
                    var visualListHelper = GetVisualListHelper();
                    var visual = visualListHelper.GetVisual(code);
                    SelectVisual(visual, eVisualSource.Monitor);
                    SelectVisual(visual, eSimulationVisualSource.Monitor);
                };
            }
            return _monitorValueListCtrl;
@@ -1642,7 +1680,7 @@
            ShowMonitorValueListCtrl();
        }
        #endregion
        #endregion 监测值控件
        #region 监测点标记
@@ -1669,9 +1707,9 @@
            monitorMarkerHelper.Set();
        }
        #endregion
        #endregion 监测点标记
        #endregion
        #endregion 监测列表
        #region 模型检查
@@ -1693,7 +1731,7 @@
                {
                    var visualListHelper = GetVisualListHelper();
                    var visual = visualListHelper.GetVisual(code);
                    SelectVisual(visual, eVisualSource.Check);
                    SelectVisual(visual, eSimulationVisualSource.Check);
                };
            }
            return _checkCtrl;
@@ -1755,7 +1793,7 @@
            ShowCheckCtrl(checkResult);
        }
        #endregion
        #endregion 模型检查
        #region 模型计算
@@ -1775,7 +1813,7 @@
            return _calcuResultHelper;
        }
        #endregion
        #endregion 计算结果
        #region 计算失败
@@ -1839,7 +1877,7 @@
            calcuFailedCtrl.SetBindingData(calcuResult.FailedList);
        }
        #endregion
        #endregion 计算失败
        #region 计算警告
@@ -1857,7 +1895,7 @@
                {
                    var visualListHelper = GetVisualListHelper();
                    var visual = visualListHelper.GetVisual(code);
                    SelectVisual(visual, eVisualSource.Warning);
                    SelectVisual(visual, eSimulationVisualSource.Warning);
                };
            }
            return _calcuWarningCtrl;
@@ -1911,7 +1949,7 @@
            calcuWaringCtrl.SetBindingData(calcuResult.WainingList, allVisualDict);
        }
        #endregion
        #endregion 计算警告
        #region 计算标签
@@ -1938,9 +1976,9 @@
            calcuResultLabelHelper.Set();
        }
        #endregion
        #endregion 计算标签
        #endregion
        #endregion 模型计算
        #region 管网修复
@@ -2005,7 +2043,7 @@
            Repair();
        }
        #endregion
        #endregion 管网修复
        #region 导出INP
@@ -2027,7 +2065,7 @@
            TipFormHelper.ShowSucceed("导出成功");
        }
        #endregion
        #endregion 导出INP
        #region 水泵列表
@@ -2050,7 +2088,7 @@
                pumps.ForEach(x => x.UpdateWorkingInfo(list));
                var visualVmListHelper = GetVisualVmListHelper();
                visualVmListHelper.UpdateProperty(pumps.Select(x => x as Yw.Model.HydroVisualInfo).ToList());
                SelectVisual(_visual, eVisualSource.None);
                SelectVisual(_visual, eSimulationVisualSource.None);
                var gradingHelper = await GetGradingHelper();
                gradingHelper.Set();
            };
@@ -2091,7 +2129,7 @@
                });
                var visualVmListHelper = GetVisualVmListHelper();
                visualVmListHelper.UpdateProperty(pumps.Select(x => x as Yw.Model.HydroVisualInfo).ToList());
                SelectVisual(_visual, eVisualSource.None);
                SelectVisual(_visual, eSimulationVisualSource.None);
                var gradingHelper = await GetGradingHelper();
                gradingHelper.Set();
            };
@@ -2102,11 +2140,10 @@
        //并联模拟
        private void barBtnPumpParallel_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            PumpParallel();
        }
        #endregion
        #endregion 水泵列表
        #region 水力计算
@@ -2125,7 +2162,7 @@
            dlg.SetBindingData(_hydroInfo, allWorkingList, allMonitorValueList);
            dlg.HydroViewEvent += (visual) =>
            {
                SelectVisual(visual, eVisualSource.Calcu);
                SelectVisual(visual, eSimulationVisualSource.Calcu);
            };
            dlg.HydroCalcuEvent += async (vm) =>
            {
@@ -2138,7 +2175,11 @@
                working.ModelID = vm.ModelID;
                working.Name = vm.Name;
                working.WorkingInfo = JsonHelper.Object2Json(vm.WorkingInfo);
                working.MonitorInfo = JsonHelper.Object2Json(vm.MonitorInfo);
                var useWorkingMonitorInfo = vm.MonitorInfo?.Where(x => x.PropValue.HasValue).ToList();
                if (useWorkingMonitorInfo != null && useWorkingMonitorInfo.Count > 0)
                {
                    working.MonitorInfo = JsonHelper.Object2Json(useWorkingMonitorInfo);
                }
                working.SortCode = vm.SortCode;
                working.Description = vm.Description;
@@ -2165,6 +2206,7 @@
                        ShowCalcuWarningCtrl(calcuResult);
                    }
                    this.barBtnAddWorking.Enabled = true;
                    this.barBtnExportWord.Enabled = true;
                    TipFormHelper.ShowSucceed("计算成功!");
                }
                else
@@ -2178,38 +2220,35 @@
                var visualVmListHelper = GetVisualVmListHelper();
                visualVmListHelper.UpdateCalcuProperty(calcuResult);
                #endregion
                #endregion 视图列表
                #region 当前构件
                SelectVisual(_visual, eVisualSource.Calcu);
                SelectVisual(_visual, eSimulationVisualSource.Calcu);
                #endregion
                #endregion 当前构件
                #region 构件明细
                UpdateVisualListCtrl();
                #endregion
                #endregion 构件明细
                #region 颜色分级
                var gradingHelper = await GetGradingHelper();
                gradingHelper.Set();
                #endregion
                #endregion 颜色分级
                #region 计算标签
                var calcuResultLabelHelper = await GetCalcuResultLabelHelper();
                calcuResultLabelHelper.Set();
                #endregion
                #endregion 计算标签
            };
            dlg.ShowDialog();
        }
        //水力计算
@@ -2218,7 +2257,49 @@
            Calcu();
        }
        #endregion
        #endregion 水力计算
        #region 导出报告
        private async void barBtnExportWord_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (_visual == null)
            {
                SelectInputSource();
                if (_visual == null)
                {
                    TipFormHelper.ShowWarn("请选择构件后重试!");
                    return;
                }
            }
            HydroVisualInfo visual = _visual;
            if (_visual is HydroLinkInfo linkInfo)
            {
                var visualListHelper = GetVisualListHelper();
                visual = visualListHelper.GetVisual(linkInfo.StartCode);
            }
            var allMonitorList = await GetMonitorList();
            var working = GetWorking();
            var calcuResult = GetCalcuResult();
            var dlg = new SimulationWorkingReportDlg();
            dlg.ReloadDataEvent += (vm) =>
            {
                var fileName = FileDialogHelper.SaveWordDoc("导出Word报告");
                if (string.IsNullOrEmpty(fileName))
                {
                    return;
                }
                var reportHelper = new SimulationWorkingReportHelper();
                reportHelper.Create(fileName, vm);
                TipFormHelper.ShowInfo("导出成功!");
            };
            dlg.SetBindingData(_project, _hydroInfo, allMonitorList, working, calcuResult, visual);
            dlg.ShowDialog();
        }
        #endregion 导出报告
        #region 当前工况
@@ -2283,7 +2364,7 @@
            AddWorking();
        }
        #endregion
        #endregion 当前工况
        #region 选择工况
@@ -2330,10 +2411,30 @@
            helper.Remove(working);
        }
        #endregion
        #endregion 选择工况
        #region 工况分析
        //选择进口水源
        private void SelectInputSource()
        {
            var sources = GetSourceList();
            if (sources != null)
            {
                if (sources.Count == 1)
                {
                    SelectVisual(sources[0], eSimulationVisualSource.None);
                }
                else
                {
                    var source = sources.FirstOrDefault(x => x.Flags.Contains(HStation.Xhs.Flags.进口));
                    if (source != null)
                    {
                        SelectVisual(source, eSimulationVisualSource.None);
                    }
                }
            }
        }
        //精度评估
        private async void barBtnWorkingEvaluation_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
@@ -2389,8 +2490,9 @@
        }
        //能效分析
        private void barBtnWorkingPower_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        private async void barBtnWorkingPower_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            var allMonitorList = await GetMonitorList();
            var workingCheckedListHelper = GetWorkingCheckedListHelper();
            var allCheckedWorkingList = workingCheckedListHelper.GetCheckedWorkingList();
            if (allCheckedWorkingList == null || allCheckedWorkingList.Count < 1)
@@ -2402,14 +2504,13 @@
                    return;
                }
                var dlg = new SimulationSingleWorkingEnergyDlg();
                dlg.SetBindingData(workingHelper.Working, workingHelper.HydroInfo, workingHelper.CalcuResult);
                dlg.SetBindingData(workingHelper.Working, workingHelper.HydroInfo, allMonitorList, workingHelper.CalcuResult);
                dlg.ShowDialog();
            }
            else
            {
                var dlg = new SimulationMultiWorkingEnergyDlg();
                dlg.SetBindingData(_hydroInfo, allCheckedWorkingList);
                dlg.SetBindingData(_hydroInfo, allMonitorList, allCheckedWorkingList);
                dlg.ShowDialog();
            }
        }
@@ -2419,22 +2520,7 @@
        {
            if (_visual == null)
            {
                var sources = GetSourceList();
                if (sources != null)
                {
                    if (sources.Count == 1)
                    {
                        SelectVisual(sources[0], eVisualSource.None);
                    }
                    else
                    {
                        var source = sources.FirstOrDefault(x => x.Flags.Contains(HStation.Xhs.Flags.进口));
                        if (source != null)
                        {
                            SelectVisual(source, eVisualSource.None);
                        }
                    }
                }
                SelectInputSource();
                if (_visual == null)
                {
                    TipFormHelper.ShowWarn("请选择构件后重试!");
@@ -2461,7 +2547,7 @@
                var dlg = new HydroSingleWorkingLossCurveDlg();
                dlg.HydroClickEvent += (code) =>
                {
                    SelectVisual(code, eVisualSource.None);
                    SelectVisual(code, eSimulationVisualSource.None);
                };
                dlg.SetBindingData(workingHelper.HydroInfo, workingHelper.CalcuResult, visual);
                dlg.ShowDialog();
@@ -2471,7 +2557,7 @@
                var dlg = new HydroMultiWorkingLossCurveDlg();
                dlg.HydroClickEvent += (code) =>
                {
                    SelectVisual(code, eVisualSource.None);
                    SelectVisual(code, eSimulationVisualSource.None);
                };
                dlg.SetBindingData(_hydroInfo, allCheckedWorkingList, visual);
                dlg.ShowDialog();
@@ -2508,26 +2594,14 @@
        {
            if (_visual == null)
            {
                var sources = GetSourceList();
                if (sources != null)
                {
                    if (sources.Count == 1)
                    {
                        SelectVisual(sources[0], eVisualSource.None);
                    }
                    else
                    {
                        var source = sources.FirstOrDefault(x => x.Flags.Contains(HStation.Xhs.Flags.进口));
                        if (source != null)
                        {
                            SelectVisual(source, eVisualSource.None);
                        }
                    }
                }
                if (_visual == null)
                {
                    TipFormHelper.ShowWarn("请选择构件后重试!");
                    return;
                    SelectInputSource();
                    if (_visual == null)
                    {
                        TipFormHelper.ShowWarn("请选择构件后重试!");
                        return;
                    }
                }
            }
            HydroVisualInfo visual = _visual;
@@ -2562,13 +2636,81 @@
            }
        }
        #endregion
        #endregion 工况分析
        #region 方案管理
        //更新方案
        private void UpdateScheme()
        {
            if (_scheme == null)
            {
                return;
            }
            if (_hydroInfo == null)
            {
                return;
            }
            var dlg = new EditXhsSchemeDlg();
            dlg.SetBindingData(_scheme, _hydroInfo);
            dlg.ReloadDataEvent += (rhs) =>
            {
                _scheme = rhs;
                this.PageTitle.Caption = $"模拟方案\r\n{_scheme.Name}";
                UpdatePageTitle(this.PageGuid, this.PageTitle);
                this.UpdateSchemeEvent?.Invoke(_scheme);
            };
            dlg.ShowDialog();
        }
        //编辑方案
        private void barBtnEditScheme_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            UpdateScheme();
        }
        //删除方案
        private async void DeleteScheme()
        {
            var bol = XtraMessageBox.Show("请问是否删除当前方案?", "询问", MessageBoxButtons.YesNo) == DialogResult.Yes;
            if (!bol)
            {
                return;
            }
            if (_scheme == null)
            {
                return;
            }
            var relation = await BLLFactory<Yw.BLL.HydroModelRelation>.Instance
                .GetDefaultByObjectTypeAndObjectIDOfPurpose(HStation.Xhs.DataType.XhsScheme, _scheme.ID, HStation.Xhs.Purpose.Simulation);
            if (relation == null)
            {
                TipFormHelper.ShowError("水力模拟方案删除失败,请重试!");
                return;
            }
            if (!await BLLFactory<Yw.BLL.HydroModelRelation>.Instance.DeleteAllByID(relation.ID))
            {
                TipFormHelper.ShowError("水力模拟方案删除失败,请重试!");
                return;
            }
            if (!await BLLFactory<HStation.BLL.XhsScheme>.Instance.DeleteByID(_scheme.ID))
            {
                TipFormHelper.ShowError("水力模拟方案删除失败,请重试!");
                return;
            }
            this.RemoveSchemeEvent?.Invoke(_scheme);
            TipFormHelper.ShowSucceed("水力模拟方案删除成功!");
            ClosePage(this.PageGuid);
        }
        //删除方案
        private void barBtnDeleteScheme_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            DeleteScheme();
        }
        #endregion 方案管理
    }
}