lixiaojun
2024-12-30 c22cc4c60e9ff156fc25b39a5c024cc758df354b
WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/00-core/04-monitor/03-marker/SimulationMonitorMarkerHelper.cs
@@ -1,5 +1,4 @@
using Yw.Vmo;
using Yw.WinFrmUI.Bimface;
using Yw.WinFrmUI.Bimface;
namespace HStation.WinFrmUI
{
@@ -11,15 +10,18 @@
        /// <summary>
        /// 
        /// </summary>
        public SimulationMonitorMarkerHelper(SimulationMonitorHelper monitorHelper, ISimulationMonitorMarkerView view)
        public SimulationMonitorMarkerHelper
            (
                SimulationMonitorHelper monitorHelper,
                ISimulationMonitorMarkerView view
            )
        {
            _monitorHelper = monitorHelper;
            _views = new List<ISimulationMonitorMarkerView>() { view };
        }
        private SimulationMonitorHelper _monitorHelper = null;//监测点辅助类
        private List<ISimulationMonitorMarkerView> _views = null;//视图列表
        private List<LogicMonitorMarker> _allMarkerList = null;//所有标记列表
        private readonly SimulationMonitorHelper _monitorHelper = null;//监测点辅助类
        private readonly List<ISimulationMonitorMarkerView> _views = null;//视图列表
        /// <summary>
        /// 是否可见
@@ -32,49 +34,19 @@
        private bool _visible = false;
        /// <summary>
        /// 获取
        /// 获取所有
        /// </summary>
        public async Task<List<LogicMonitorMarker>> Get()
        public async Task<List<LogicMonitorMarker>> GetAll()
        {
            var allMonitorList = await _monitorHelper.Get();
            _allMarkerList = allMonitorList?.Select(x => new LogicMonitorMarker()
            var allMonitorList = await _monitorHelper.GetAll();
            var allGroupList = allMonitorList?.GroupBy(x => new { x.Parter, x.SourceType }).ToList();
            var allMarkerList = allGroupList?.Select(x => new LogicMonitorMarker()
            {
                Id = x.Relation,
                PropName = x.PropName,
                Description = x.Description
                Code = x.Key.Parter,
                SourceType = (int)x.Key.SourceType,
                Description = x.Key.SourceType == Yw.Hydro.eSourceType.Docking ? $"传感器测点({x.Count()})" : $"分析测点({x.Count()})"
            }).ToList();
            return _allMarkerList;
        }
        /// <summary>
        /// 更新
        /// </summary>
        public async void Update(string code, List<HydroMonitorVmo> monitorList)
        {
            var allMarkerList = await Get();
            var markerList = allMarkerList.Where(x => x.Id == code).ToList();
            markerList?.ForEach(x =>
            {
                var result = monitorList?.Exists(t => t.Relation == x.Id && t.PropName == x.PropName);
                if (!(result.HasValue && result.Value))
                {
                    allMarkerList.Remove(x);
                }
            });
            monitorList?.ForEach(x =>
            {
                var result = markerList?.Exists(t => t.Id == x.Relation && t.PropName == x.PropName);
                if (!(result.HasValue && result.Value))
                {
                    var vm = new LogicMonitorMarker()
                    {
                        Id = x.Relation,
                        PropName = x.PropName,
                        Description = x.Description
                    };
                    allMarkerList.Add(vm);
                }
            });
            return allMarkerList;
        }
        /// <summary>
@@ -84,7 +56,7 @@
        {
            if (this.Visible)
            {
                var allMarkerList = await Get();
                var allMarkerList = await GetAll();
                _views.ForEach(x => x.SetLogicMonitors(allMarkerList));
            }
            else