Shuxia Ning
2024-11-27 175472475dadbd80e9c23e043ab6cdce36082d6a
WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/06-simulation/XhsProjectSimulationCorePage.cs
@@ -1,31 +1,15 @@
global using Yw.EPAnet;
using DevExpress.CodeParser;
using DevExpress.Diagram.Core.Native;
using DevExpress.Diagram.Core.Native;
using DevExpress.Mvvm.Native;
using DevExpress.Office.Utils;
using DevExpress.PivotGrid.QueryMode.TuplesTree;
using DevExpress.Utils.Extensions;
using DevExpress.Xpo.Helpers;
using DevExpress.XtraBars.Ribbon;
using DevExpress.XtraPrinting.Native;
using DevExpress.XtraRichEdit.Layout;
using DevExpress.XtraSpreadsheet.Commands;
using DevExpress.Utils.MVVM;
using DevExpress.XtraMap;
using HStation.WinFrmUI.PhartRelation;
using Microsoft.Web.WebView2.Core;
using NetTaste;
using Mapster;
using NPOI.SS.Formula.Functions;
using System.Collections.Generic;
using System.Diagnostics;
using System.Windows.Media;
using System.Windows.Media.Media3D;
using Yw.DAL.Basic;
using Yw.Hydro;
using Yw.Model;
using Yw.Pump;
using Yw.Vmo;
using Yw.WinFrmUI.Bimface;
using Yw.WinFrmUI.Hydro;
using static DevExpress.Map.OpenGL.OpenGLCheckingHelper;
using Yw.WinFrmUI.Q3d;
namespace HStation.WinFrmUI
{
@@ -40,39 +24,32 @@
            RegistBulkSetEvents();
        }
        /// <summary>
        /// 新增工况事件
        /// </summary>
        public event Action<HydroWorkingVmo> AppendWorkingEvent;
        private HStation.Vmo.XhsProjectVmo _project = null;//项目
        private HStation.Vmo.XhsProjectSiteVmo _projectSite = null;//项目站
        private Yw.Model.HydroModelInfo _hydroInfo = null;//水力信息
        private Dictionary<HydroWorkingVmo, bool> _allWorkingCheckedListDict = null;//所有工况选择列表字典
        /// <summary>
        /// 绑定数据
        /// </summary>
        public async Task SetBindingData
        public void SetBindingData
            (
                HStation.Vmo.XhsProjectVmo project,
                HStation.Vmo.XhsProjectSiteVmo projectSite,
                Yw.Model.HydroModelInfo hydroInfo
                XhsProjectVmo project,
                XhsProjectSiteVmo projectSite,
                Yw.Model.HydroModelInfo hydroInfo,
                Dictionary<HydroWorkingVmo, bool> allWorkingCheckedListDict
            )
        {
            if (project == null)
            {
                return;
            }
            _project = project;
            _projectSite = projectSite;
            _hydroInfo = hydroInfo;
            if (_projectSite == null)
            {
                _projectSite = await BLLFactory<HStation.BLL.XhsProjectSite>.Instance.GetDefaultByProjectID(_project.ID);
            }
            if (_hydroInfo == null)
            {
                var hydroRelation = await BLLFactory<Yw.BLL.HydroModelRelation>.Instance
                    .GetDefaultByObjectTypeAndObjectIDOfPurpose(HStation.Xhs.DataType.XhsProjectSite, _projectSite.ID, HStation.Xhs.Purpose.Simulation);
                _hydroInfo = await BLLFactory<Yw.BLL.HydroModelInfo>.Instance.GetByID(hydroRelation.ModelID);
            }
            _allWorkingCheckedListDict = allWorkingCheckedListDict;
            //this.PageTitle.Caption = $"{_project.Name}\r\n水力模拟";
        }
        /// <summary>
@@ -81,21 +58,10 @@
        public override void InitialDataSource()
        {
            base.InitialDataSource();
            if (_project == null)
            {
                return;
            }
            this.PageTitle.Caption = $"{_project.Name}\r\n水力模拟";
            ShowBimfaceCtrl();
            ShowQ3dCtrl();
            ShowPropertyCtrl();
        }
        private void InitialUI()
        {
            InitialWorkingList();
        }
        #region BIM控件
@@ -105,6 +71,10 @@
        //获取 bimface 控件
        private async Task<XhsProjectSimulationBimfaceCtrl> GetBimfaceCtrl()
        {
            if (_hydroInfo == null)
            {
                return default;
            }
            if (_bimfaceCtrl == null)
            {
                _bimfaceCtrl = new XhsProjectSimulationBimfaceCtrl();
@@ -116,16 +86,12 @@
                    {
                        return;
                    }
                    InitialUI();
                };
                _bimfaceCtrl.HydroMouseLeftClickEvent += (obj) =>
                _bimfaceCtrl.HydroMouseLeftClickEvent += (code) =>
                {//鼠标左键点击事件
                    if (_hydroInfo == null)
                    {
                        return;
                    }
                    //_selectedVisual = obj;
                    //ShowSelectedProperty();
                    var visualListHelper = GetVisualListHelper();
                    var visual = visualListHelper.GetVisual(code);
                    SelectVisual(visual, eVisualSource.Bimface);
                };
            }
            return _bimfaceCtrl;
@@ -139,11 +105,6 @@
            this.tabPageBimface.Controls.Add(bimfaceCtrl);
        }
        private void SelectBimfaceParter()
        {
        }
        #endregion
        #region Q3d控件
@@ -154,20 +115,20 @@
        //获取 Q3d 控件
        private XhsProjectSimulationQ3dCtrl GetQ3dCtrl()
        {
            if (_hydroInfo == null)
            {
                return default;
            }
            if (_q3dCtrl == null)
            {
                _q3dCtrl = new XhsProjectSimulationQ3dCtrl();
                _q3dCtrl.Dock = DockStyle.Fill;
                _q3dCtrl.InitialData(() => _hydroInfo);
                _q3dCtrl.SelectedPartersChangedEvent += (obj) =>
                _q3dCtrl.SelectedPartersChangedEvent += (codes) =>
                {
                    if (_hydroInfo == null)
                    {
                        return;
                    }
                    var allParterList = _hydroInfo.GetAllVisuals();
                    _visual = allParterList?.Find(x => x.Code == obj?.FirstOrDefault());
                    //ShowSelectedProperty();
                    var visualListHelper = GetVisualListHelper();
                    var visuals = visualListHelper.GetVisualList(codes);
                    SelectVisual(visuals?.LastOrDefault(), eVisualSource.Q3d);
                };
            }
            return _q3dCtrl;
@@ -179,6 +140,259 @@
            var q3dCtrl = GetQ3dCtrl();
            this.tabPageQ3d.Controls.Clear();
            this.tabPageQ3d.Controls.Add(q3dCtrl);
        }
        #endregion
        #region 属性控件
        //属性控件
        private XhsProjectSimulationPropertyCtrl _propertyCtrl = null;
        //获取属性控件
        private XhsProjectSimulationPropertyCtrl GetPropertyCtrl()
        {
            if (_hydroInfo == null)
            {
                return default;
            }
            if (_propertyCtrl == null)
            {
                _propertyCtrl = new XhsProjectSimulationPropertyCtrl();
                _propertyCtrl.Dock = DockStyle.Fill;
                _propertyCtrl.HydroViewEvent += (visual) =>
                {
                    SelectVisual(visual, eVisualSource.Property);
                };
                _propertyCtrl.BlinkLinkNodeEvent += async (link, linkNodeCode) =>
                { //强调连接节点
                    if (link == null)
                    {
                        return;
                    }
                    var visualListHelper = GetVisualListHelper();
                    var linkNode = visualListHelper.GetVisual(linkNodeCode);
                    if (linkNode == null)
                    {
                        return;
                    }
                    var blinkCodes = new List<string>();
                    if (linkNode.GetType() == typeof(HydroJunctionInfo))
                    {
                        var allLinkList = visualListHelper.GetLinkList();
                        if (allLinkList == null || allLinkList.Count < 1)
                        {
                            return;
                        }
                        var linkList = allLinkList.Where(x => (x.StartCode == linkNodeCode || x.EndCode == linkNodeCode) && x.Code != linkNodeCode).ToList();
                        if (linkList == null || linkList.Count < 1)
                        {
                            return;
                        }
                        blinkCodes.AddRange(linkList.Select(x => x.Code));
                    }
                    else
                    {
                        blinkCodes.Add(linkNodeCode);
                    }
                    await _bimfaceCtrl?.ClearBlinkComponents();
                    await _bimfaceCtrl?.SetBlinkComponents(blinkCodes);
                    await Task.Delay(5000);
                    await _bimfaceCtrl?.ClearBlinkComponents();
                };
                _propertyCtrl.PropertyValueChangedEvent += async (visual) =>
                {
                    if (visual == null)
                    {
                        return;
                    }
                    UpdateVisualListCtrl();
                    var gradingHelper = await GetGradingHelper();
                    gradingHelper.Set();
                };
                _propertyCtrl.MarkPropertyValueChangedEvent += async (visual) =>
                {
                    //标注属性发生改变
                    //判断当前是否有标注展示,若有则更新标注,最好是更新单个标注
                    var markHelper = await GetMarkHelper();
                    markHelper.Set(visual);
                };
                _propertyCtrl.GradingPropertyValueChangedEvent += async (visual) =>
                {
                    //分级属性发生改变
                    //判断当前是否有分级展示,若有则更新分级,最好是更新单个分级
                    var gradingHelper = await GetGradingHelper();
                    gradingHelper.Set(visual);
                };
                _propertyCtrl.FlowEffectPropertyValueChangedEvent += async (visual) =>
                {
                    //流向属性发生改变
                    //判断流向是否加载,如果加载则更新流向,最好是更新单个流向
                    var flowEffectHelper = await GetFlowEffectHelper();
                    flowEffectHelper.Set(visual);
                };
            }
            return _propertyCtrl;
        }
        //属性控件是否可见
        private bool IsPropertyCtrlVisible
        {
            get
            {
                if (this.docPnlRight.Visibility == DevExpress.XtraBars.Docking.DockVisibility.Visible)
                {
                    if (this.controlContainerRight.Controls.Count > 0)
                    {
                        if (this.controlContainerRight.Controls[0] is XhsProjectSimulationPropertyCtrl)
                        {
                            return true;
                        }
                    }
                }
                return false;
            }
        }
        //显示属性控件
        private void ShowPropertyCtrl()
        {
            if (IsPropertyCtrlVisible)
            {
                return;
            }
            var propertyCtrl = GetPropertyCtrl();
            this.controlContainerRight.Controls.Clear();
            this.controlContainerRight.Controls.Add(propertyCtrl);
            this.docPnlRight.Visibility = DevExpress.XtraBars.Docking.DockVisibility.Visible;
            this.docPnlRight.Text = "属性";
            this.docPnlRight.Width = 300;
        }
        //设置属性控件
        private void SetPropertyCtrl(HydroVisualInfo visual)
        {
            ShowPropertyCtrl();
            var visualVmListHelper = GetVisualVmListHelper();
            var vm = visualVmListHelper.GetVisual(visual);
            _propertyCtrl.SelectedObject = vm;
        }
        //更新属性控件
        private void UpdatePropertyCtrl()
        {
            _propertyCtrl?.UpdateRows();
        }
        //清理属性控件
        private void ClearPropertyCtrl()
        {
            if (_propertyCtrl != null)
            {
                _propertyCtrl.SelectedObject = null;
            }
        }
        #endregion
        #region 选择构件
        //可见来源
        protected enum eVisualSource
        {
            None,
            Bimface,
            Q3d,
            Property,
            List,
            Search,
            Monitor,
            Check,
            Calcu,
            Warning,
        }
        //选择构件
        private Yw.Model.HydroVisualInfo _visual = null;
        //选择构件
        private void SelectVisual(HydroVisualInfo visual, eVisualSource source)
        {
            _visual = visual;
            switch (source)
            {
                case eVisualSource.None:
                    {
                        _bimfaceCtrl?.ZoomAndSelectComponent(visual?.Code);
                        this.barBtnSetMonitor.Enabled = visual != null;
                        SetPropertyCtrl(visual);
                    }
                    break;
                case eVisualSource.Bimface:
                    {
                        this.barBtnSetMonitor.Enabled = visual != null;
                        SetPropertyCtrl(visual);
                    }
                    break;
                case eVisualSource.Q3d:
                    {
                        _bimfaceCtrl?.ZoomAndSelectComponent(visual?.Code);
                        this.barBtnSetMonitor.Enabled = visual != null;
                        SetPropertyCtrl(visual);
                    }
                    break;
                case eVisualSource.Property:
                    {
                        _bimfaceCtrl?.ZoomAndSelectComponent(visual?.Code);
                        this.barBtnSetMonitor.Enabled = visual != null;
                    }
                    break;
                case eVisualSource.List:
                    {
                        _bimfaceCtrl?.ZoomAndSelectComponent(visual?.Code);
                        this.barBtnSetMonitor.Enabled = visual != null;
                        SetPropertyCtrl(visual);
                    }
                    break;
                case eVisualSource.Search:
                    {
                        _bimfaceCtrl?.ZoomAndSelectComponent(visual?.Code);
                        this.barBtnSetMonitor.Enabled = visual != null;
                        SetPropertyCtrl(visual);
                    }
                    break;
                case eVisualSource.Monitor:
                    {
                        _bimfaceCtrl?.ZoomAndSelectComponent(visual?.Code);
                        this.barBtnSetMonitor.Enabled = visual != null;
                        SetPropertyCtrl(visual);
                    }
                    break;
                case eVisualSource.Check:
                    {
                        _bimfaceCtrl?.ZoomAndSelectComponent(visual?.Code);
                        this.barBtnSetMonitor.Enabled = visual != null;
                        SetPropertyCtrl(visual);
                    }
                    break;
                case eVisualSource.Calcu:
                    {
                        _bimfaceCtrl?.ZoomAndSelectComponent(visual?.Code);
                        this.barBtnSetMonitor.Enabled = visual != null;
                        SetPropertyCtrl(visual);
                    }
                    break;
                case eVisualSource.Warning:
                    {
                        _bimfaceCtrl?.ZoomAndSelectComponent(visual?.Code);
                        this.barBtnSetMonitor.Enabled = visual != null;
                        SetPropertyCtrl(visual);
                    }
                    break;
                default: break;
            }
        }
        #endregion
@@ -209,7 +423,7 @@
        private SimulationVisualVmListHelper _visualVmListHelper = null;
        //获取可见视图列表辅助类
        private async Task<SimulationVisualVmListHelper> GetVisualVmListHelper()
        private SimulationVisualVmListHelper GetVisualVmListHelper()
        {
            if (_hydroInfo == null)
            {
@@ -218,10 +432,8 @@
            if (_visualVmListHelper == null)
            {
                var visualListHelper = GetVisualListHelper();
                _visualVmListHelper = new SimulationVisualVmListHelper(visualListHelper);
                var workingTupleHelper = GetWorkingTupleHelper();
                var calcuResult = await workingTupleHelper.GetCalcuResult(_working);
                _visualVmListHelper.InitialData(_hydroInfo, calcuResult);
                var calcuResultHelper = GetCalcuResultHelper();
                _visualVmListHelper = new SimulationVisualVmListHelper(visualListHelper, calcuResultHelper);
            }
            return _visualVmListHelper;
        }
@@ -242,11 +454,11 @@
                _visualListCtrl.Dock = DockStyle.Fill;
                _visualListCtrl.HydroClickInfoEvent += (visual) =>
                {
                    SelectVisual(visual, eVisualSource.List);
                };
                _visualListCtrl.HydroChangedInfoEvent += (visualList) =>
                {
                    SelectVisual(_visual, eVisualSource.List);
                };
            }
            return _visualListCtrl;
@@ -272,7 +484,7 @@
        }
        //显示构件明细控件
        private async void ShowVisualListCtrl()
        private void ShowVisualListCtrl()
        {
            if (_hydroInfo == null)
            {
@@ -287,10 +499,10 @@
                this.docPnlBottom.Text = "构件明细";
                this.docPnlBottom.Height = 350;
            }
            var visualVmListHelper = await GetVisualVmListHelper();
            var visualVmListHelper = GetVisualVmListHelper();
            var allVisualVmList = visualVmListHelper.GetVisualList();
            visualListCtrl.SetBindingData(allVisualVmList);
            var calcuResult = await GetCalcuResult();
            var calcuResult = GetCalcuResult();
            if (calcuResult != null && calcuResult.Succeed)
            {
                visualListCtrl.SetCalcuView();
@@ -367,238 +579,6 @@
        }
        #endregion
        #endregion
        #region 选择构件
        //可见来源
        protected enum eVisualSource
        {
            None,
            Bimface,
            Q3d,
            Check,
            Property,
            Calcu,
            Monitor,
            Warning,
            Search,
        }
        //选择构件
        private Yw.Model.HydroVisualInfo _visual = null;
        //选择构件
        private void SelectVisual(HydroVisualInfo visual, eVisualSource source)
        {
            if (visual == null)
            {
                switch (source)
                {
                    case eVisualSource.None:
                        {
                            _bimfaceCtrl?.ZoomAndSelectComponent(null);
                            this.barBtnSetMonitor.Enabled = false;
                            ClearPropertyCtrl();
                        }
                        break;
                    case eVisualSource.Bimface:
                        {
                            this.barBtnSetMonitor.Enabled = false;
                            ClearPropertyCtrl();
                        }
                        break;
                    case eVisualSource.Check:
                        {
                            _bimfaceCtrl?.ZoomAndSelectComponent(null);
                            this.barBtnSetMonitor.Enabled = false;
                            ClearPropertyCtrl();
                        }
                        break;
                    case eVisualSource.Property:
                        {
                            _bimfaceCtrl?.ZoomAndSelectComponent(null);
                            this.barBtnSetMonitor.Enabled = false;
                        }
                        break;
                    case eVisualSource.Calcu:
                        {
                            _bimfaceCtrl?.ZoomAndSelectComponent(null);
                            this.barBtnSetMonitor.Enabled = false;
                            ClearPropertyCtrl();
                        }
                        break;
                    default: break;
                }
                _visual = null;
                return;
            }
            if (_visual == null)
            {
                _visual = visual;
                return;
            }
            if (_visual.Code == visual.Code)
            {
                UpdatePropertyCtrl();
                return;
            }
            _visual = visual;
            _bimfaceCtrl?.ZoomAndSelectComponent(visual.Code);
            this.barBtnSetMonitor.Enabled = true;
            SetPropertyCtrl(visual);
        }
        #endregion
        #region 属性控件
        //属性控件
        private XhsProjectSimulationPropertyCtrl _propertyCtrl = null;
        //获取属性控件
        private XhsProjectSimulationPropertyCtrl GetPropertyCtrl()
        {
            if (_hydroInfo == null)
            {
                return default;
            }
            if (_propertyCtrl == null)
            {
                _propertyCtrl = new XhsProjectSimulationPropertyCtrl();
                _propertyCtrl.Dock = DockStyle.Fill;
                _propertyCtrl.HydroViewEvent += (visual) =>
                {
                    if (visual == null)
                    {
                        return;
                    }
                    _bimfaceCtrl?.ZoomToComponent(visual.Code);
                };
                _propertyCtrl.BlinkLinkNodeEvent += async (link, linkNodeCode) =>
                { //强调连接节点
                    if (link == null)
                    {
                        return;
                    }
                    var visualListHelper = GetVisualListHelper();
                    var linkNode = visualListHelper.GetVisual(linkNodeCode);
                    if (linkNode == null)
                    {
                        return;
                    }
                    var blinkCodes = new List<string>();
                    if (linkNode.GetType() == typeof(HydroJunctionInfo))
                    {
                        var allLinkList = visualListHelper.GetLinkList();
                        if (allLinkList == null || allLinkList.Count < 1)
                        {
                            return;
                        }
                        var linkList = allLinkList.Where(x => (x.StartCode == linkNodeCode || x.EndCode == linkNodeCode) && x.Code != linkNodeCode).ToList();
                        if (linkList == null || linkList.Count < 1)
                        {
                            return;
                        }
                        blinkCodes.AddRange(linkList.Select(x => x.Code));
                    }
                    else
                    {
                        blinkCodes.Add(linkNodeCode);
                    }
                    await _bimfaceCtrl?.ClearBlinkComponents();
                    await _bimfaceCtrl?.SetBlinkComponents(blinkCodes);
                    await Task.Delay(5000);
                    await _bimfaceCtrl?.ClearBlinkComponents();
                };
                _propertyCtrl.PropertyValueChangedEvent += (visual) =>
                {
                    if (visual == null)
                    {
                        return;
                    }
                    UpdateVisualListCtrl();
                    //ApplyGradingResultList(visual);
                };
                _propertyCtrl.MarkPropertyValueChangedEvent += (visual) =>
                {
                    //标注属性发生改变
                    //判断当前是否有标注展示,若有则更新标注,最好是更新单个标注
                };
                _propertyCtrl.GradingPropertyValueChangedEvent += (parter) =>
                {
                    //分级属性发生改变
                    //判断当前是否有分级展示,若有则更新分级,最好是更新单个分级
                };
                _propertyCtrl.FlowEffectPropertyValueChangedEvent += (visual) =>
                {
                    //流向属性发生改变
                    //判断流向是否加载,如果加载则更新流向,最好是更新单个流向
                };
            }
            return _propertyCtrl;
        }
        //属性控件是否可见
        private bool IsPropertyCtrlVisible
        {
            get
            {
                if (this.docPnlRight.Visibility == DevExpress.XtraBars.Docking.DockVisibility.Visible)
                {
                    if (this.controlContainerRight.Controls.Count > 0)
                    {
                        if (this.controlContainerRight.Controls[0] is XhsProjectSimulationPropertyCtrl)
                        {
                            return true;
                        }
                    }
                }
                return false;
            }
        }
        //显示属性控件
        private void ShowPropertyCtrl()
        {
            if (IsPropertyCtrlVisible)
            {
                return;
            }
            var propertyCtrl = GetPropertyCtrl();
            this.controlContainerRight.Controls.Clear();
            this.controlContainerRight.Controls.Add(propertyCtrl);
            this.docPnlRight.Visibility = DevExpress.XtraBars.Docking.DockVisibility.Visible;
            this.docPnlRight.Text = "属性";
            this.docPnlRight.Width = 300;
        }
        //设置属性控件
        private void SetPropertyCtrl(HydroVisualInfo visual)
        {
            ShowPropertyCtrl();
            //  var vm = GetVisualViewModel(visual);
            //  _propertyCtrl.SelectedObject = vm;
        }
        //更新属性控件
        private void UpdatePropertyCtrl()
        {
            _propertyCtrl?.UpdateRows();
        }
        //清理属性控件
        private void ClearPropertyCtrl()
        {
            if (_propertyCtrl != null)
            {
                _propertyCtrl.SelectedObject = null;
            }
        }
        #endregion
@@ -1175,11 +1155,11 @@
        private HydroVisualSearchListCtrl _searchCtrl = null;
        //获取查询组件
        private async Task<HydroVisualSearchListCtrl> GetSearchCtrl()
        private HydroVisualSearchListCtrl GetSearchCtrl()
        {
            if (_searchCtrl == null)
            {
                var visualVmListHelper = await GetVisualVmListHelper();
                var visualVmListHelper = GetVisualVmListHelper();
                var allVisualVmList = visualVmListHelper.GetVisualList();
                _searchCtrl = new HydroVisualSearchListCtrl();
                _searchCtrl.Dock = DockStyle.Fill;
@@ -1217,13 +1197,13 @@
        }
        //显示查询控件
        private async void ShowSearchCtrl(string content)
        private void ShowSearchCtrl(string content)
        {
            if (IsSearchCtrlVisible)
            {
                return;
            }
            var searchCtrl = await GetSearchCtrl();
            var searchCtrl = GetSearchCtrl();
            searchCtrl.SetBindingData(content);
            this.controlContainerBottom.Controls.Clear();
            this.controlContainerBottom.Controls.Add(searchCtrl);
@@ -1271,8 +1251,9 @@
            if (_markHelper == null)
            {
                var visualListHelper = GetVisualListHelper();
                var calcuResultHelper = GetCalcuResultHelper();
                var bimfaceCtrl = await GetBimfaceCtrl();
                _markHelper = new SimulationMarkHelper(visualListHelper, bimfaceCtrl);
                _markHelper = new SimulationMarkHelper(visualListHelper, calcuResultHelper, bimfaceCtrl);
            }
            return _markHelper;
        }
@@ -1322,7 +1303,7 @@
            if (_gradingHelper == null)
            {
                var visualListHelper = GetVisualListHelper();
                var calcuResultHelper = await GetCalcuResultHelper();
                var calcuResultHelper = GetCalcuResultHelper();
                var bimfaceCtrl = await GetBimfaceCtrl();
                _gradingHelper = new SimulationGradingHelper(visualListHelper, calcuResultHelper, bimfaceCtrl);
            }
@@ -1445,7 +1426,7 @@
                var visualListHelper = GetVisualListHelper();
                var bimfaceCtrl = await GetBimfaceCtrl();
                _flowEffectHelper = new SimulationFlowEffectHelper(visualListHelper, bimfaceCtrl);
                var calcuResult = await GetCalcuResult();
                var calcuResult = GetCalcuResult();
                _flowEffectHelper.InitialData(calcuResult);
            }
            return _flowEffectHelper;
@@ -1477,7 +1458,8 @@
            }
            if (_monitorHelper == null)
            {
                _monitorHelper = new SimulationMonitorHelper(_hydroInfo.ID);
                var visualListHelper = GetVisualListHelper();
                _monitorHelper = new SimulationMonitorHelper(visualListHelper);
            }
            return _monitorHelper;
        }
@@ -1699,9 +1681,9 @@
        }
        //显示检查控件
        private async void ShowCheckCtrl()
        private void ShowCheckCtrl()
        {
            var checkResult = await GetCheckResult();
            var checkResult = GetCheckResult();
            ShowCheckCtrl(checkResult);
        }
@@ -1726,12 +1708,14 @@
        private SimulationCalcuResultHelper _calcuResultHelper = null;
        //获取计算结果辅助类
        private async Task<SimulationCalcuResultHelper> GetCalcuResultHelper()
        private SimulationCalcuResultHelper GetCalcuResultHelper()
        {
            if (_calcuResultHelper == null)
            {
                _calcuResultHelper = new SimulationCalcuResultHelper();
                _calcuResultHelper.CalcuResult = await GetCalcuResult();
                var workingHelper = GetWorkingHelper();
                _calcuResultHelper = new SimulationCalcuResultHelper(workingHelper);
                var calcuResult = GetCalcuResult();
                _calcuResultHelper.InitialData();
            }
            return _calcuResultHelper;
        }
@@ -1885,7 +1869,7 @@
            if (_calcuResultLabelHelper == null)
            {
                var visualListHelper = GetVisualListHelper();
                var calcuResultHelper = await GetCalcuResultHelper();
                var calcuResultHelper = GetCalcuResultHelper();
                var bimfaceCtrl = await GetBimfaceCtrl();
                _calcuResultLabelHelper = new SimulationCalcuResultLabelHelper(visualListHelper, calcuResultHelper, bimfaceCtrl);
            }
@@ -1907,7 +1891,7 @@
        #region 管网修复
        //修复管网
        private async void Repair()
        private void Repair()
        {
            if (_hydroInfo == null)
            {
@@ -1954,7 +1938,7 @@
                    count++;
                }
            }
            var visualVmListHelper = await GetVisualVmListHelper();
            var visualVmListHelper = GetVisualVmListHelper();
            visualVmListHelper.UpdateProperty();
            UpdateVisualListCtrl();
            UpdatePropertyCtrl();
@@ -1984,6 +1968,7 @@
                return;
            }
            var netWork = Yw.Hydro.ParseHelper.ToNetwork(_hydroInfo);
            var json = JsonHelper.Object2Json(netWork);
            var result = netWork.ToInpString();
            File.WriteAllText(fileName, result);
            TipFormHelper.ShowSucceed("导出成功");
@@ -2072,31 +2057,17 @@
        #endregion
        #region 工况计算
        #region 水力计算
        //工况元组辅助类
        private SimulationWorkingTupleHelper _workingTupleHelper = null;
        //获取工况元组辅助类
        private SimulationWorkingTupleHelper GetWorkingTupleHelper()
        {
            if (_workingTupleHelper == null)
            {
                var visualListHelper = GetVisualListHelper();
                _workingTupleHelper = new SimulationWorkingTupleHelper(visualListHelper);
            }
            return _workingTupleHelper;
        }
        //设置工况窗体
        private async void CalcuWorking()
        //计算
        private async void Calcu()
        {
            if (_hydroInfo == null)
            {
                return;
            }
            var workingTupleHelper = GetWorkingTupleHelper();
            var allWorkingList = await workingTupleHelper.GetWorkingList();
            var workingCheckedListHelper = GetWorkingCheckedListHelper();
            var allWorkingList = workingCheckedListHelper.GetWorkingList();
            var monitorValueHelper = GetMonitorValueHelper();
            var allMonitorValueList = await monitorValueHelper.Get();
            var dlg = new SetHydroWorkingDlg();
@@ -2105,226 +2076,181 @@
            {
                SelectVisual(visual, eVisualSource.Calcu);
            };
            dlg.HydroCalcuEvent += async (working) =>
            dlg.HydroCalcuEvent += async (vm) =>
            {
                var vmo = new HydroWorkingVmo();
                vmo.ModelID = _hydroInfo.ID;
                vmo.Name = working.Name;
                vmo.WorkingInfo = JsonHelper.Object2Json(working.WorkingInfo);
                vmo.MonitorInfo = JsonHelper.Object2Json(working.MonitorInfo);
                vmo.SortCode = allWorkingList.Count < 1 ? 1 : allWorkingList.Max(x => x.SortCode) + 1;
                vmo.Description = working.Description;
                vmo.ID = await BLLFactory<Yw.BLL.HydroWorking>.Instance.Insert(vmo);
                if (vmo.ID < 1)
                {
                    TipFormHelper.ShowError("创建工况失败,计算取消!");
                    return;
                }
                allWorkingList.Add(vmo);
                _hydroInfo.UpdateWorkingInfo(vm.WorkingInfo);
                allMonitorValueList.UpdateMonitorValue(vm.MonitorInfo);
                _hydroInfo.UpdateWorkingInfo(working.WorkingInfo);
                var hydroInfo = _hydroInfo.Adapt<Yw.Model.HydroModelInfo>();
                var working = new HydroWorkingVmo();
                working.ModelID = _hydroInfo.ID;
                working.Name = working.Name;
                working.WorkingInfo = JsonHelper.Object2Json(working.WorkingInfo);
                working.MonitorInfo = JsonHelper.Object2Json(working.MonitorInfo);
                working.SortCode = working.SortCode;
                working.Description = working.Description;
                var workingHelper = GetWorkingHelper();
                //校验
                var checkResult = _hydroInfo.Check();
                if (!checkResult.Succeed)
                {
                    workingTupleHelper.AppendTuple(vmo, checkResult, null);
                    AppendWorking(vmo);
                    ShowCheckCtrl(checkResult);
                    TipFormHelper.ShowWarn("校验失败,请检查后重试");
                    workingHelper.InitialData(hydroInfo, working, checkResult, null);
                    TipFormHelper.ShowError("校验失败,请检查后重试");
                    return;
                }
                WaitFormHelper.ShowWaitForm(this, "正在计算分析中,请稍候...");
                //await Task.Delay(5000);
                //await Task.Delay(3000);
                var calcuResult = _hydroInfo.Calcu(Yw.EPAnet.CalcuMode.MinorLoss);
                WaitFormHelper.HideWaitForm();
                workingHelper.InitialData(hydroInfo, working, checkResult, calcuResult);
                if (calcuResult.Succeed)
                {
                    workingTupleHelper.AppendTuple(vmo, checkResult, calcuResult);
                    AppendWorking(vmo);
                    var visualVmListHelper = await GetVisualVmListHelper();
                    visualVmListHelper.UpdateProperty();
                    visualVmListHelper.UpdateCalcuProperty(calcuResult);
                    UpdateVisualListCtrl();
                    UpdatePropertyCtrl();
                    var calcuResultHelper = await GetCalcuResultHelper();
                    calcuResultHelper.CalcuResult = calcuResult;
                    var calcuResultLabelHelper = await GetCalcuResultLabelHelper();
                    calcuResultLabelHelper.Set();
                    if (calcuResult.WainingList != null && calcuResult.WainingList.Count > 0)
                    {
                        ShowCalcuWarningCtrl(calcuResult);
                    }
                    this.barBtnAddWorking.Enabled = true;
                    TipFormHelper.ShowSucceed("计算成功!");
                    var codes = _hydroInfo.Pumps.Select(x => x.Code).ToList();
                    await _bimfaceCtrl?.ZoomAndSelectComponents(codes);
                }
                else
                {
                    ShowCalcuFailedCtrl(calcuResult);
                    TipFormHelper.ShowError("计算失败!");
                }
                var gradingHelper = await GetGradingHelper();
                gradingHelper.InitialData();
                gradingHelper.Set();
                UpdateVisualListCtrl();
                UpdatePropertyCtrl();
                #region 计算结果
                var calcuResultHelper = GetCalcuResultHelper();
                calcuResultHelper.InitialData();
                #endregion
                #region 视图列表
                var visualVmListHelper = GetVisualVmListHelper();
                visualVmListHelper.UpdateCalcuProperty(calcuResult);
                #endregion
                #region 计算标签
                var calcuResultLabelHelper = await GetCalcuResultLabelHelper();
                calcuResultLabelHelper.Set();
                #endregion
            };
            dlg.ShowDialog();
        }
        //工况计算
        private void barBtnWorkingCalcu_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        //水力计算
        private void barBtnCalcu_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            CalcuWorking();
            var network = _hydroInfo.ToW3dNetworkViewModel();
            var json = JsonHelper.Object2Json(network);
            Calcu();
        }
        #endregion
        #region 当前工况
        //工况辅助类
        private SimulationWorkingHelper _workingHelper = null;
        //获取工况辅助类
        private SimulationWorkingHelper GetWorkingHelper()
        {
            if (_workingHelper == null)
            {
                _workingHelper = new SimulationWorkingHelper();
            }
            return _workingHelper;
        }
        //获取工况
        private HydroWorkingVmo GetWorking()
        {
            var workingHelper = GetWorkingHelper();
            return workingHelper.Working;
        }
        //获取检查结果
        private HydroCheckResult GetCheckResult()
        {
            var workingHelper = GetWorkingHelper();
            return workingHelper.CheckResult;
        }
        //获取计算结果
        private HydroCalcuResult GetCalcuResult()
        {
            var workingHelper = GetWorkingHelper();
            return workingHelper.CalcuResult;
        }
        //新增工况
        private void AddWorking()
        {
            var workingHelper = GetWorkingHelper();
            if (workingHelper.Working == null)
            {
                TipFormHelper.ShowWarn("尚未计算,请计算后重试!");
                return;
            }
            var dlg = new AddHydroWorkingDlg();
            dlg.SetBindingData(workingHelper.Working);
            dlg.ReloadDataEvent += (rhs) =>
            {
                this.barBtnAddWorking.Enabled = false;
                workingHelper.ResetWorking(rhs);
                this.AppendWorkingEvent?.Invoke(rhs);
            };
            dlg.ShowDialog();
        }
        //增加工况
        private void barBtnAddWorking_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            AddWorking();
        }
        #endregion
        #region 选择工况
        //工况选择列表辅助类
        private SimulationWorkingCheckedListHelper _workingCheckedListHelper = null;
        //获取工况元组辅助类
        private SimulationWorkingCheckedListHelper GetWorkingCheckedListHelper()
        {
            if (_workingCheckedListHelper == null)
            {
                var visualListHelper = GetVisualListHelper();
                _workingCheckedListHelper = new SimulationWorkingCheckedListHelper(visualListHelper);
                _workingCheckedListHelper.InitialData(_allWorkingCheckedListDict);
            }
            return _workingCheckedListHelper;
        }
        //更新工况选择列表
        public void UpdateWorkingCheckedList(HydroWorkingVmo working, bool hasChecked)
        {
            var helper = GetWorkingCheckedListHelper();
            helper.Update(working, hasChecked);
        }
        #endregion
        #region 工况分析
        #region 当前工况
        //当前工况
        private Yw.Vmo.HydroWorkingVmo _working = null;
        //获取检查结果
        private async Task<HydroCheckResult> GetCheckResult()
        {
            var workingTupleHelper = GetWorkingTupleHelper();
            return await workingTupleHelper.GetCheckResult(_working);
        }
        //获取计算结果
        private async Task<HydroCalcuResult> GetCalcuResult()
        {
            var workingTupleHelper = GetWorkingTupleHelper();
            return await workingTupleHelper.GetCalcuResult(_working);
        }
        //初始化工况列表
        private async void InitialWorkingList()
        {
            var workingTupleList = GetWorkingTupleHelper();
            var allWorkingList = await workingTupleList.GetWorkingList();
            this.repositoryItemImageComboBox1.Items.BeginUpdate();
            this.repositoryItemImageComboBox1.Items.Clear();
            if (allWorkingList != null && allWorkingList.Count > 0)
            {
                allWorkingList.ForEach(x => this.repositoryItemImageComboBox1.Items.Add(x.Name, x, -1));
                this.barEditCurrentWorking.EditValue = allWorkingList.Last();
            }
            this.repositoryItemImageComboBox1.Items.EndUpdate();
        }
        //增加当前工况
        private void AppendWorking(HydroWorkingVmo working)
        {
            this.repositoryItemImageComboBox1.Items.BeginUpdate();
            this.repositoryItemImageComboBox1.Items.Add(working.Name, working, -1);
            this.repositoryItemImageComboBox1.Items.EndUpdate();
            this.barEditCurrentWorking.EditValue = working;
        }
        //设置当前工况
        private async void SetCurrentWorking(HydroWorkingVmo working)
        {
            _working = working;
            this.barEditCurrentWorking.EditValue = working;
            var workingTupleHelper = GetWorkingTupleHelper();
        }
        //当前工况发生改变
        private void barEditCurrentWorking_EditValueChanged(object sender, EventArgs e)
        {
            var working = this.barEditCurrentWorking.EditValue as HydroWorkingVmo;
            SetCurrentWorking(working);
        }
        #endregion
        #region 工况控件
        //工况控件
        private HydroWorkingTreeCtrl _workingCtrl = null;
        //获取工况控件
        private async Task<HydroWorkingTreeCtrl> GetWorkingCtrl()
        {
            if (_workingCtrl == null)
            {
                _workingCtrl = new HydroWorkingTreeCtrl();
                _workingCtrl.Dock = DockStyle.Fill;
                _workingCtrl.FocusedChangedEvent += (vmo) =>
                {
                };
                _workingCtrl.HydroClickEvent += (working) =>
                {
                    SetCurrentWorking(working);
                };
            }
            return _workingCtrl;
        }
        //工况控件是否可见
        private bool IsWorkingCtrlVisible
        {
            get
            {
                if (this.docPnlRight.Visibility == DevExpress.XtraBars.Docking.DockVisibility.Visible)
                {
                    if (this.controlContainerRight.Controls.Count > 0)
                    {
                        if (this.controlContainerRight.Controls[0] is HydroWorkingTreeCtrl)
                        {
                            return true;
                        }
                    }
                }
                return false;
            }
        }
        //显示工况控件
        private async void ShowWorkingCtrl()
        {
            var workingCtrl = await GetWorkingCtrl();
            if (!IsWorkingCtrlVisible)
            {
                this.controlContainerRight.Controls.Clear();
                this.controlContainerRight.Controls.Add(workingCtrl);
                this.docPnlRight.Visibility = DevExpress.XtraBars.Docking.DockVisibility.Visible;
                this.docPnlRight.Text = "工况";
                this.docPnlRight.Width = 300;
            }
            var workingTupleHelper = GetWorkingTupleHelper();
            var allWorkingList = await workingTupleHelper.GetWorkingList();
            workingCtrl.SetBindingData(allWorkingList);
        }
        //更新工况控件
        private async void UpdateWorkingCtrl()
        {
            if (!IsWorkingCtrlVisible)
            {
                return;
            }
            var workingTupleHelper = GetWorkingTupleHelper();
            var allWorkingList = await workingTupleHelper.GetWorkingList();
            var workingCtrl = await GetWorkingCtrl();
            workingCtrl.SetBindingData(allWorkingList);
        }
        //工况列表点击
        private void barBtnWorkingList_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            ShowWorkingCtrl();
        }
        #endregion
        #region 工况评估
@@ -2335,13 +2261,13 @@
            {
                return;
            }
            if (_working == null)
            var working = GetWorking();
            if (working == null)
            {
                TipFormHelper.ShowWarn("尚未计算,请计算后重试!");
                return;
            }
            var workingTupleHelper = GetWorkingTupleHelper();
            var checkResult = await workingTupleHelper.GetCheckResult(_working);
            var checkResult = GetCheckResult();
            if (checkResult == null)
            {
                return;
@@ -2352,11 +2278,7 @@
                TipFormHelper.ShowWarn("检查失败,停止评估!");
                return;
            }
            var calcuResult = await workingTupleHelper.GetCalcuResult(_working);
            if (calcuResult == null)
            {
                return;
            }
            var calcuResult = GetCalcuResult();
            if (!calcuResult.Succeed)
            {
                ShowCalcuFailedCtrl(calcuResult);
@@ -2372,7 +2294,7 @@
            var allVisualDict = visualListHelper.GetVisualDict();
            var monitorHelper = GetMonitorHelper();
            var allMonitorList = await monitorHelper.Get();
            var allWorkingMonitorList = JsonHelper.Json2Object<List<HydroWorkingMonitorViewModel>>(_working.MonitorInfo);
            var allWorkingMonitorList = JsonHelper.Json2Object<List<HydroWorkingMonitorViewModel>>(working.MonitorInfo);
            var allCalcuResultDict = calcuResult.GetVisualDict();
            var dlg = new HydroWorkingEvaluationDlg();
            dlg.SetBindingData(allVisualDict, allMonitorList, allWorkingMonitorList, allCalcuResultDict);
@@ -2390,7 +2312,7 @@
        #region 工况并联
        //并联分析
        private async void barBtnAnaly_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        private void barBtnAnaly_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (_hydroInfo == null)
            {
@@ -2401,7 +2323,7 @@
                return;
            }
            var calcuResultHelper = await GetCalcuResultHelper();
            var calcuResultHelper = GetCalcuResultHelper();
            var vmList = new List<XhsSinglePumpViewModel>();
            foreach (var pump in _hydroInfo.Pumps)
            {
@@ -2436,7 +2358,7 @@
                vm.CurveQE = qePtList;
                vm.CurveQP = qpPtList;
                var calcuResultVisualDict = calcuResultHelper.GetVisualResultDict();
                var calcuResultVisualDict = calcuResultHelper.GetVisualDict();
                if (calcuResultVisualDict != null && calcuResultVisualDict.Count > 0)
                {
                    //var calcuResult = allCalcuResultList.Find(x => x.Code == pump.Code) as HydroCalcuLinkResult;
@@ -2486,7 +2408,10 @@
        private void barBtnWorkingPower_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            XtraMessageBox.Show("正在开发中,敬请期待!");
            var workingHelper = GetWorkingHelper();
            var dlg = new SimulationSingleWorkingEnergyDlg();
            dlg.SetBindingData(workingHelper.HydroInfo, workingHelper.CalcuResult);
            dlg.ShowDialog();
        }
        #endregion
@@ -2495,7 +2420,26 @@
        private void barBtnWorkingLossCurve_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            XtraMessageBox.Show("正在开发中,敬请期待!");
            if (_visual == null)
            {
                XtraMessageBox.Show("请选择节点后重试!");
                return;
            }
            if (!(_visual is Yw.Model.HydroNodeInfo))
            {
                XtraMessageBox.Show("请选择节点后重试!");
                return;
            }
            var network = _hydroInfo.ToNetwork();
            var calcuResult = network.Calcu(Yw.EPAnet.CalcuMode.Simple);
            var allNodeList = network.GetAllNodes();
            var node = allNodeList.Find(x => x.Id == _visual.Code);
            var allPathList = network.AnalyzeDownstreamPath(node, calcuResult);
            var allEpaLossList = network.GetChartNodeByPathLinks(allPathList, calcuResult);
            var allLossList = allEpaLossList?.Select(x => new HydroNodeLossViewModel(x)).ToList();
            var dlg = new HydroSingleLossCurveDlg();
            dlg.SetBindingData(allLossList);
            dlg.ShowDialog();
        }
        #endregion
@@ -2504,7 +2448,18 @@
        private void barBtnWorkingLossScale_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            XtraMessageBox.Show("正在开发中,敬请期待!");
            var workingHelper = GetWorkingHelper();
            if (workingHelper.Working == null)
            {
                TipFormHelper.ShowWarn("请计算后重试!");
                return;
            }
            var network = workingHelper.HydroInfo.ToNetwork();
            var calcuResult = network.Calcu(Yw.EPAnet.CalcuMode.MinorLoss);
            var allEnergyPointList = network.AnalyzeEnergy(calcuResult);
            var dlg = new HydroSingleLossScaleDlg();
            dlg.SetBindingData(workingHelper.HydroInfo, allEnergyPointList);
            dlg.ShowDialog();
        }
        #endregion
@@ -2515,7 +2470,7 @@
            XtraMessageBox.Show("正在开发中,敬请期待!");
        }
        #endregion
        #endregion
        #endregion
@@ -2523,5 +2478,6 @@
    }
}