lixiaojun
2024-12-22 6551843c49431dacf67ea26e1ea21bf887a5246c
WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/00-core/04-monitor/01-monitor/SimulationMonitorHelper.cs
@@ -1,4 +1,5 @@
using Yw.Vmo;
using Yw.Hydro;
using Yw.Vmo;
namespace HStation.WinFrmUI
{
@@ -15,13 +16,13 @@
            _visualListHelper = visualListHelper;
        }
        private SimulationVisualListHelper _visualListHelper = null;//可见构件列表辅助类
        private readonly SimulationVisualListHelper _visualListHelper = null;//可见构件列表辅助类
        private List<HydroMonitorVmo> _allMonitorList = null;//所有监测点列表
        /// <summary>
        /// 获取
        /// </summary>
        public async Task<List<HydroMonitorVmo>> Get()
        public async Task<List<HydroMonitorVmo>> GetAll()
        {
            if (_allMonitorList == null)
            {
@@ -35,20 +36,80 @@
        }
        /// <summary>
        /// 获取对接列表
        /// </summary>
        public async Task<List<HydroMonitorVmo>> GetDockingList()
        {
            var all = await GetAll();
            return all?.Where(x => x.SourceType == Yw.Hydro.eSourceType.Docking).ToList();
        }
        /// <summary>
        /// 获取分析列表
        /// </summary>
        public async Task<List<HydroMonitorVmo>> GetAnalyseList()
        {
            var all = await GetAll();
            return all?.Where(x => x.SourceType == Yw.Hydro.eSourceType.Analyse).ToList();
        }
        /// <summary>
        /// 更新
        /// </summary>
        public async Task<List<HydroMonitorVmo>> Update(string code)
        {
            var allMonitorList = await Get();
            allMonitorList.RemoveAll(x => x.Relation == code);
            var all = await GetAll();
            all.RemoveAll(x => x.Relation == code);
            var monitorList = await BLLFactory<Yw.BLL.HydroMonitor>.Instance.GetByRelation(_visualListHelper.HydroInfo.ID, code);
            if (monitorList != null && monitorList.Count > 0)
            {
                allMonitorList.AddRange(monitorList);
                all.AddRange(monitorList);
            }
            return monitorList;
        }
        /// <summary>
        /// 更新对接
        /// </summary>
        public async Task<List<HydroMonitorVmo>> UpdateDocking(string code)
        {
            var all = await GetAll();
            all.RemoveAll(x => x.Relation == code && x.SourceType == Yw.Hydro.eSourceType.Docking);
            var monitorList = await BLLFactory<Yw.BLL.HydroMonitor>.Instance.GetBySourceType(_visualListHelper.HydroInfo.ID, code, Yw.Hydro.eSourceType.Docking);
            if (monitorList != null && monitorList.Count > 0)
            {
                all.AddRange(monitorList);
            }
            return monitorList;
        }
        /// <summary>
        /// 更新
        /// </summary>
        public async Task Update(string code, eSourceType sourceType, List<HydroMonitorVmo> monitorList)
        {
            var all = await GetAll();
            all.RemoveAll(x => x.Relation == code && x.SourceType == sourceType);
            if (monitorList != null && monitorList.Count > 0)
            {
                all.AddRange(monitorList);
            }
        }
        /// <summary>
        /// 更新分析
        /// </summary>
        public async Task<List<HydroMonitorVmo>> UpdateAnalyse(string code)
        {
            var all = await GetAll();
            all.RemoveAll(x => x.Relation == code && x.SourceType == Yw.Hydro.eSourceType.Analyse);
            var monitorList = await BLLFactory<Yw.BLL.HydroMonitor>.Instance.GetBySourceType(_visualListHelper.HydroInfo.ID, code, Yw.Hydro.eSourceType.Analyse);
            if (monitorList != null && monitorList.Count > 0)
            {
                all.AddRange(monitorList);
            }
            return monitorList;
        }