Shuxia Ning
2025-01-08 0a1bf56909464e938a68c29b26ab88ff51380fad
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
using Yw.Hydro;
 
namespace HStation.WinFrmUI
{
    /// <summary>
    /// 监测值辅助类
    /// </summary>
    public class SimulationMonitorValueHelper
    {
        /// <summary>
        /// 
        /// </summary>
        public SimulationMonitorValueHelper
            (
                SimulationVisualListHelper visualListHelper,
                SimulationMonitorHelper monitorHelper,
                SimulationCalcuResultHelper calcuResultHelper
            )
        {
            _visualListHelper = visualListHelper;
            _monitorHelper = monitorHelper;
            _calcuResultHelper = calcuResultHelper;
            _calcuResultHelper.InitialEvent += async () => await Update();
        }
 
        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>> GetAll()
        {
            if (_allList == null)
            {
                _allList = new List<HydroMonitorValueViewModel>();
                var allVisualDict = _visualListHelper.GetVisualDict();
                if (allVisualDict != null && allVisualDict.Count > 0)
                {
                    var allMonitorList = await _monitorHelper.GetAll();
                    if (allMonitorList != null && allMonitorList.Count > 0)
                    {
                        foreach (var monitor in allMonitorList)
                        {
                            if (allVisualDict.ContainsKey(monitor.Parter))
                            {
                                var visual = allVisualDict[monitor.Parter];
                                double? propValue = null;
                                var calcuVisualResult = _calcuResultHelper.GetVisual(monitor.Parter);
                                if (calcuVisualResult != null)
                                {
                                    propValue = calcuVisualResult.GetCalcuValue(monitor.PropName);
                                }
                                var vm = new HydroMonitorValueViewModel(monitor, visual, propValue);
                                _allList.Add(vm);
                            }
                        }
                    }
                }
            }
            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>
        /// 更新
        /// </summary>
        public async Task Update()
        {
            var all = await GetAll();
            foreach (var item in all)
            {
                if (!item.PropValue.HasValue)
                {
                    var calcuVisualResult = _calcuResultHelper.GetVisual(item.Vmo.Parter);
                    if (calcuVisualResult != null)
                    {
                        var propValue = calcuVisualResult.GetCalcuValue(item.Vmo.PropName);
                        if (propValue.HasValue)
                        {
                            item.PropValue = item.Vmo.GetPropValue(propValue.Value);
                        }
                    }
                }
            }
        }
 
        /// <summary>
        /// 更新
        /// </summary>
        public async Task Update(string code, eSourceType sourceType, List<HydroMonitorValueViewModel> valueList)
        {
            var all = await GetAll();
            all.RemoveAll(x => x.Vmo.Parter == code && x.Vmo.SourceType == sourceType);
            if (valueList != null && valueList.Count > 0)
            {
                all.AddRange(valueList);
            }
        }
 
        /// <summary>
        /// 重置
        /// </summary>
        public async Task Reset(List<HydroWorkingMonitorViewModel> allWorkingMonitorList)
        {
            var all = await GetAll();
            all.UpdateMonitorValue(allWorkingMonitorList);
        }
 
        /// <summary>
        /// 重置
        /// </summary>
        public async void Reset(string monitorInfo)
        {
            var allMonitorValueList = await GetAll();
            allMonitorValueList.UpdateMonitorValue(monitorInfo);
        }
 
 
    }
}