lixiaojun
2024-12-30 b4a83cab68992fbf1d88dcc43957f4aebea60343
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;
@@ -200,6 +210,10 @@
                    if (_hydroInfo == null)
                    {
                        hydroInfo = await GetHydroInfo(null);
                        if (hydroInfo == null)
                        {
                            return default;
                        }
                        if (_hydroInfo == null)
                        {
                            _hydroInfo = hydroInfo;
@@ -221,6 +235,10 @@
                if (!_allSchemeHydroInfoDict.ContainsKey(scheme))
                {
                    hydroInfo = await GetHydroInfo(scheme);
                    if (hydroInfo == null)
                    {
                        return default;
                    }
                    if (!_allSchemeHydroInfoDict.ContainsKey(scheme))
                    {
                        _allSchemeHydroInfoDict.Add(scheme, hydroInfo);
@@ -252,6 +270,21 @@
            {
                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;
            if (scheme == null)
@@ -268,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;
        }
@@ -491,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);
@@ -541,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);
@@ -762,15 +807,17 @@
            {
                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;
            }
            var db = await BLLFactory<Yw.BLL.HydroModelInfo>.Instance.GetByID(id);
            //var db = await HStation.BLL.XhsHydroInfo.GetByID(id);
            if (scheme == null)
            {
                _hydroInfo = db;
                // _hydroInfo = db;
                _hydroInfo = hydroInfo;
                return _hydroInfo;
            }
            if (_allSchemeHydroInfoDict == null || _allSchemeHydroInfoDict.Count < 1)
@@ -782,8 +829,9 @@
            {
                return default;
            }
            _allSchemeHydroInfoDict[schemeKey] = db;
            return db;
            //_allSchemeHydroInfoDict[schemeKey] = db;
            _allSchemeHydroInfoDict[schemeKey] = hydroInfo;
            return _allSchemeHydroInfoDict[schemeKey];
        }
        /// <summary>