lixiaojun
2025-01-06 f373ad1f566c9c8679547f4205d86eb6e0836d59
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Yw.Model;
 
namespace Yw.WinFrmUI
{
    /// <summary>
    /// 水力更改辅助类
    /// </summary>
    public class HydroChangeHelper
    {
        /// <summary>
        /// 
        /// </summary>
        public HydroChangeHelper(Yw.Model.HydroModelInfo hydroInfo)
        {
            _hydroInfo = hydroInfo;
        }
 
        private readonly Yw.Model.HydroModelInfo _hydroInfo = null;//水力信息
        private List<HydroParterInfo> _addParterList = new();//增加构件列表
        private List<HydroParterInfo> _updateParterList = new();//更新构件列表
        private List<HydroParterInfo> _removeParterList = new(); //移除构件列表
 
        /// <summary>
        /// 附加
        /// </summary>
        public void Append(HydroParterInfo parter, eChangeType changeType)
        {
            if (parter == null)
            {
                return;
            }
            var allParterList = _hydroInfo.GetAllParters();
            switch (changeType)
            {
                case eChangeType.Add:
                    {
                        if (!_addParterList.Exists(x => x.Code == parter.Code))
                        {
                            if (allParterList.Exists(x => x.Code == parter.Code))
                            {
                                _addParterList.Add(parter);
                            }
                        }
                    }
                    break;
                case eChangeType.Update:
                    {
                        if (!_updateParterList.Exists(x => x.Code == parter.Code))
                        {
                            if (allParterList.Exists(x => x.Code == parter.Code))
                            {
                                if (!_addParterList.Exists(x => x.Code == parter.Code))
                                {
                                    _updateParterList.Add(parter);
                                }
                            }
                        }
                    }
                    break;
                case eChangeType.Remove:
                    {
                        if (!_removeParterList.Exists(x => x.Code == parter.Code))
                        {
                            if (!allParterList.Exists(x => x.Code == parter.Code))
                            {
                                _removeParterList.Add(parter);
                            }
                        }
                    }
                    break;
                default: break;
            }
        }
 
        /// <summary>
        /// 获取新增构件列表
        /// </summary>
        public List<HydroParterInfo> GetAddParterList()
        {
            return _addParterList.ToList();
        }
 
        /// <summary>
        /// 获取更新构件列表
        /// </summary>
        public List<HydroParterInfo> GetUpdateParterList()
        {
            return _updateParterList.ToList();
        }
 
        /// <summary>
        /// 获取移除构件列表
        /// </summary>
        public List<string> GetRemoveParters()
        {
            return _removeParterList.Select(x => x.Code).Distinct().ToList();
        }
 
 
    }
}