From 6551843c49431dacf67ea26e1ea21bf887a5246c Mon Sep 17 00:00:00 2001
From: lixiaojun <1287241240@qq.com>
Date: 星期日, 22 十二月 2024 12:43:18 +0800
Subject: [PATCH] 测点整改

---
 WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/00-core/04-monitor/02-value/SimulationMonitorValueHelper.cs |  144 ++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 122 insertions(+), 22 deletions(-)

diff --git a/WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/00-core/04-monitor/02-value/SimulationMonitorValueHelper.cs b/WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/00-core/04-monitor/02-value/SimulationMonitorValueHelper.cs
index 5cd37ed..fd39ffb 100644
--- a/WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/00-core/04-monitor/02-value/SimulationMonitorValueHelper.cs
+++ b/WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/00-core/04-monitor/02-value/SimulationMonitorValueHelper.cs
@@ -1,4 +1,6 @@
-锘縰sing Yw.Vmo;
+锘縰sing DevExpress.Xpo.Helpers;
+using Yw.Hydro;
+using Yw.Vmo;
 
 namespace HStation.WinFrmUI
 {
@@ -10,28 +12,35 @@
         /// <summary>
         /// 
         /// </summary>
-        public SimulationMonitorValueHelper(SimulationVisualListHelper visualListHelper, SimulationMonitorHelper monitorHelper)
+        public SimulationMonitorValueHelper
+            (
+                SimulationVisualListHelper visualListHelper,
+                SimulationMonitorHelper monitorHelper,
+                SimulationCalcuResultHelper calcuResultHelper
+            )
         {
             _visualListHelper = visualListHelper;
             _monitorHelper = monitorHelper;
+            _calcuResultHelper = calcuResultHelper;
         }
 
-        private SimulationVisualListHelper _visualListHelper = null;//鍙鍒楄〃杈呭姪绫�
-        private SimulationMonitorHelper _monitorHelper = null;//鐩戞祴鐐硅緟鍔╃被     
-        private List<HydroMonitorValueViewModel> _allMonitorValueList = null;//鎵�鏈夌洃娴嬪�煎垪琛�
+        private readonly SimulationVisualListHelper _visualListHelper = null;//鍙鍒楄〃杈呭姪绫�
+        private readonly SimulationMonitorHelper _monitorHelper = null;//鐩戞祴鐐硅緟鍔╃被     
+        private readonly SimulationCalcuResultHelper _calcuResultHelper = null;//璁$畻缁撴灉杈呭姪绫�
+        private List<HydroMonitorValueViewModel> _allList = null;//鎵�鏈夌洃娴嬪�煎垪琛�
 
         /// <summary>
-        /// 鑾峰彇
+        /// 鑾峰彇鎵�鏈�
         /// </summary>
-        public async Task<List<HydroMonitorValueViewModel>> Get()
+        public async Task<List<HydroMonitorValueViewModel>> GetAll()
         {
-            if (_allMonitorValueList == null)
+            if (_allList == null)
             {
-                _allMonitorValueList = new List<HydroMonitorValueViewModel>();
+                _allList = new List<HydroMonitorValueViewModel>();
                 var allVisualDict = _visualListHelper.GetVisualDict();
                 if (allVisualDict != null && allVisualDict.Count > 0)
                 {
-                    var allMonitorList = await _monitorHelper.Get();
+                    var allMonitorList = await _monitorHelper.GetAll();
                     if (allMonitorList != null && allMonitorList.Count > 0)
                     {
                         foreach (var monitor in allMonitorList)
@@ -39,14 +48,38 @@
                             if (allVisualDict.ContainsKey(monitor.Relation))
                             {
                                 var visual = allVisualDict[monitor.Relation];
-                                var vm = new HydroMonitorValueViewModel(monitor, visual);
-                                _allMonitorValueList.Add(vm);
+                                double? propValue = null;
+                                var calcuVisualResult = _calcuResultHelper.GetVisual(monitor.Relation);
+                                if (calcuVisualResult != null)
+                                {
+                                    propValue = calcuVisualResult.GetCalcuValue(monitor.PropName);
+                                }
+                                var vm = new HydroMonitorValueViewModel(monitor, visual, propValue);
+                                _allList.Add(vm);
                             }
                         }
                     }
                 }
             }
-            return _allMonitorValueList;
+            return _allList;
+        }
+
+        /// <summary>
+        /// 鑾峰彇瀵规帴鍒楄〃
+        /// </summary>
+        public async Task<List<HydroMonitorValueViewModel>> GetDockingList()
+        {
+            var all = await GetAll();
+            return all.Where(x => x.Vmo.SourceType == eSourceType.Docking).ToList();
+        }
+
+        /// <summary>
+        /// 鑾峰彇鍒嗘瀽鍒楄〃
+        /// </summary>
+        public async Task<List<HydroMonitorValueViewModel>> GetAnalyseList()
+        {
+            var all = await GetAll();
+            return all.Where(x => x.Vmo.SourceType == eSourceType.Analyse).ToList();
         }
 
         /// <summary>
@@ -54,29 +87,96 @@
         /// </summary>
         public async void Update(string code, List<HydroMonitorVmo> monitorList)
         {
+            if (string.IsNullOrEmpty(code))
+            {
+                return;
+            }
             var visual = _visualListHelper.GetVisual(code);
             if (visual == null)
             {
                 return;
             }
 
-            var allMonitorValueList = await Get();
-            var monitorValueList = allMonitorValueList.Where(x => x.Vmo.Relation == code).ToList();
-            monitorValueList?.ForEach(x =>
+            var allValueList = await GetAll();
+            var valueList = allValueList.Where(x => x.Vmo.Relation == code).ToList();
+            valueList.ForEach(x =>
             {
                 var result = monitorList?.Exists(t => t.Relation == x.Vmo.Relation && t.PropName == x.Vmo.PropName);
                 if (!(result.HasValue && result.Value))
                 {
-                    allMonitorValueList.Remove(x);
+                    allValueList.Remove(x);
                 }
             });
             monitorList?.ForEach(x =>
             {
-                var result = monitorValueList?.Exists(t => t.Vmo.Relation == x.Relation && t.Vmo.PropName == x.PropName);
+                var result = valueList?.Exists(t => t.Vmo.Relation == x.Relation && t.Vmo.PropName == x.PropName);
                 if (!(result.HasValue && result.Value))
                 {
-                    var vm = new HydroMonitorValueViewModel(x, visual);
-                    allMonitorValueList.Add(vm);
+                    double? propValue = null;
+                    var calcuVisualResult = _calcuResultHelper.GetVisual(x.Relation);
+                    if (calcuVisualResult != null)
+                    {
+                        propValue = calcuVisualResult.GetCalcuValue(x.PropName);
+                    }
+                    var vm = new HydroMonitorValueViewModel(x, visual, propValue);
+                    allValueList.Add(vm);
+                }
+            });
+        }
+
+        /// <summary>
+        /// 鏇存柊
+        /// </summary>
+        public async Task Update(string code, eSourceType sourceType, List<HydroMonitorValueViewModel> valueList)
+        {
+            var all = await GetAll();
+            all.RemoveAll(x => x.Vmo.Relation == code && x.Vmo.SourceType == sourceType);
+            if (valueList != null && valueList.Count > 0)
+            {
+                all.AddRange(valueList);
+            }
+        }
+
+        /// <summary>
+        /// 鏇存柊
+        /// </summary>
+        public async void Update(string code, List<HydroMonitorVmo> monitorList, List<HydroMonitorDockingViewModel> monitorDockingList)
+        {
+            if (string.IsNullOrEmpty(code))
+            {
+                return;
+            }
+            var visual = _visualListHelper.GetVisual(code);
+            if (visual == null)
+            {
+                return;
+            }
+
+            var allValueList = await GetAll();
+            var valueList = allValueList.Where(x => x.Vmo.Relation == code).ToList();
+            valueList.ForEach(x =>
+            {
+                var result = monitorList?.Exists(t => t.Relation == x.Vmo.Relation && t.PropName == x.Vmo.PropName);
+                if (!(result.HasValue && result.Value))
+                {
+                    allValueList.Remove(x);
+                }
+            });
+            monitorList?.ForEach(x =>
+            {
+                var result = valueList?.Exists(t => t.Vmo.Relation == x.Relation && t.Vmo.PropName == x.PropName);
+                if (!(result.HasValue && result.Value))
+                {
+                    double? propValue = null;
+                    var monitorDocking = monitorDockingList?.Find(t => t.Vmo.Relation == x.Relation && t.Vmo.PropName == x.PropName);
+                    propValue = monitorDocking?.PropValue;
+                    if (!propValue.HasValue)
+                    {
+                        var calcuVisualResult = _calcuResultHelper.GetVisual(x.Relation);
+                        propValue = calcuVisualResult?.GetCalcuValue(x.PropName);
+                    }
+                    var vm = new HydroMonitorValueViewModel(x, visual, propValue);
+                    allValueList.Add(vm);
                 }
             });
         }
@@ -86,7 +186,7 @@
         /// </summary>
         public async void Reset(List<HydroWorkingMonitorViewModel> allWorkingMonitorList)
         {
-            var allMonitorValueList = await Get();
+            var allMonitorValueList = await GetAll();
             allMonitorValueList.UpdateMonitorValue(allWorkingMonitorList);
         }
 
@@ -95,7 +195,7 @@
         /// </summary>
         public async void Reset(string monitorInfo)
         {
-            var allMonitorValueList = await Get();
+            var allMonitorValueList = await GetAll();
             allMonitorValueList.UpdateMonitorValue(monitorInfo);
         }
 

--
Gitblit v1.9.3