lixiaojun
2024-12-24 f7253b1a5b2a945d88e6ab230910a78c2cbbc7ad
WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/05-function/SimulationFunctionCtrl.cs
@@ -1,6 +1,9 @@
using DevExpress.Utils.Extensions;
using DevExpress.CodeParser;
using DevExpress.DataAccess.Native;
using DevExpress.Utils.Extensions;
using DevExpress.Utils.Svg;
using DevExpress.XtraCharts;
using System.Collections.Concurrent;
using Yw.DAL.Basic;
using Yw.Vmo;
@@ -65,6 +68,7 @@
        private Dictionary<HydroWorkingVmo, bool> _allWorkingCheckedListDict = null;//所有工况选择列表字典
        private Dictionary<XhsSchemeVmo, Yw.Model.HydroModelInfo> _allSchemeHydroInfoDict = null;//所有方案水力信息列表
        private Dictionary<XhsSchemeVmo, Dictionary<HydroWorkingVmo, bool>> _allSchemeWorkingCheckedListDict = null;//所有方案工况选择列表字典
        private ConcurrentDictionary<string, bool> _gettingHydroInfoDict = new ConcurrentDictionary<string, bool>();//获取水力信息字典
        /// <summary>
        /// 绑定数据
@@ -157,6 +161,7 @@
            this.CreateProjectSiteSchemeEvent?.Invoke(_project, _projectSite, hydroInfo, this.svgImg32[3]);
        }
        //右键弹出
        private void accordionControl1_MouseClick(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Right)
@@ -165,11 +170,13 @@
            }
        }
        //全部折叠
        private void barBtnCollpseAll_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            this.accordionControl1.CollapseAll();
        }
        //全部展开
        private void barBtnExpandAll_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            this.accordionControl1.ExpandAll();
@@ -186,7 +193,10 @@
            Yw.Model.HydroModelInfo hydroInfo = null;
            if (!useCache)
            {
                hydroInfo = await GetHydroInfo(scheme);
                if (hydroInfo == null)
                {
                    hydroInfo = await GetHydroInfo(scheme);
                }
                if (hydroInfo == null)
                {
                    return default;
@@ -199,7 +209,15 @@
                {
                    if (_hydroInfo == null)
                    {
                        _hydroInfo = await GetHydroInfo(null);
                        hydroInfo = await GetHydroInfo(null);
                        if (hydroInfo == null)
                        {
                            return default;
                        }
                        if (_hydroInfo == null)
                        {
                            _hydroInfo = hydroInfo;
                        }
                    }
                    return _hydroInfo;
                }
@@ -217,9 +235,16 @@
                if (!_allSchemeHydroInfoDict.ContainsKey(scheme))
                {
                    hydroInfo = await GetHydroInfo(scheme);
                    _allSchemeHydroInfoDict.Add(scheme, hydroInfo);
                    return hydroInfo;
                    if (hydroInfo == null)
                    {
                        return default;
                    }
                    if (!_allSchemeHydroInfoDict.ContainsKey(scheme))
                    {
                        _allSchemeHydroInfoDict.Add(scheme, hydroInfo);
                    }
                }
                return _allSchemeHydroInfoDict[scheme];
            }
            if (_allSchemeHydroInfoDict.ContainsKey(scheme))
@@ -231,7 +256,7 @@
                _allSchemeHydroInfoDict.Add(scheme, hydroInfo);
            }
            return hydroInfo;
            return _allSchemeHydroInfoDict[scheme];
        }
        //获取水力信息
@@ -244,6 +269,21 @@
            if (_projectSite == null)
            {
                return default;
            }
            string key = $"{_project.ID}-{_projectSite.ID}-{scheme?.ID}";
            if (_gettingHydroInfoDict.TryGetValue(key, out bool getting))
            {
                if (getting)
                {
                    return default;
                }
            }
            WaitFormHelper.ShowWaitForm(this.FindForm(), "正在加载模型数据,请稍后...");
            //var overlay = this.ShowOverlay();
            if (!_gettingHydroInfoDict.TryAdd(key, true))
            {
                _gettingHydroInfoDict[key] = true;
            }
            HydroModelRelationVmo relation = null;
@@ -261,7 +301,11 @@
            {
                return default;
            }
            var hydroInfo = await BLLFactory<Yw.BLL.HydroModelInfo>.Instance.GetByID(relation.ModelID);
            //var hydroInfo = await BLLFactory<Yw.BLL.HydroModelInfo>.Instance.GetByID(relation.ModelID);
            var hydroInfo = await HStation.BLL.XhsHydroInfo.GetByID(relation.ModelID);
            _gettingHydroInfoDict[key] = false;
            //overlay.Close();
            WaitFormHelper.HideWaitForm();
            return hydroInfo;
        }
@@ -484,6 +528,10 @@
                elementWorking.Click += async (sender, e) =>
                {
                    var hydroInfo = await GetHydroInfo(null, true);
                    if (hydroInfo == null)
                    {
                        return;
                    }
                    this.ShowProjectSiteWorkingEvent?.Invoke(_project, _projectSite, null, hydroInfo, working, this.svgImg32[4]);
                };
                this.elementProjectSiteSimulation.Elements.Add(elementWorking);
@@ -534,6 +582,10 @@
                elementWorking.Click += async (sender, e) =>
                {
                    var hydroInfo = await GetHydroInfo(scheme, true);
                    if (hydroInfo == null)
                    {
                        return;
                    }
                    this.ShowProjectSiteWorkingEvent?.Invoke(_project, _projectSite, scheme, hydroInfo, working, this.svgImg32[4]);
                };
                elementScheme.Elements.Add(elementWorking);
@@ -755,7 +807,8 @@
            {
                return default;
            }
            var id = await BLLFactory<Yw.BLL.HydroModelInfo>.Instance.Save(hydroInfo);
            //var id = await BLLFactory<Yw.BLL.HydroModelInfo>.Instance.Save(hydroInfo);
            var id = await HStation.BLL.XhsHydroInfo.Save(hydroInfo);
            if (id < 1)
            {
                return default;