duheng
2025-03-12 cec8d92bdca1da0b2eafe6eb3130f4bf6f03028b
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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
namespace Yw.WinFrmUI
{
    /// <summary>
    /// 颜色分级分类辅助类
    /// </summary>
    public class HydroGradingCatalogHelper
    {
        /// <summary>
        /// 字典
        /// </summary>
        public static Dictionary<string, string> Dict
        {
            get { return _dict; }
        }
 
        //字典
        private static readonly Dictionary<string, string> _dict = new Dictionary<string, string>()
        {
            { Yw.Hydro.ParterCatalog.Reservoir,"水库"},
            { Yw.Hydro.ParterCatalog.Tank,"水池"},
            { Yw.Hydro.ParterCatalog.Waterbox,"水箱"},
            { Yw.Hydro.ParterCatalog.Blunthead,"闷头"},
            { Yw.Hydro.ParterCatalog.Elbow,"弯头"},
            { Yw.Hydro.ParterCatalog.Threelink,"三通"},
            { Yw.Hydro.ParterCatalog.Fourlink,"四通"},
            { Yw.Hydro.ParterCatalog.Meter,"水表"},
            { Yw.Hydro.ParterCatalog.Flowmeter,"流量计"},
            { Yw.Hydro.ParterCatalog.Pressmeter,"压力表"},
            { Yw.Hydro.ParterCatalog.Nozzle,"喷嘴"},
            { Yw.Hydro.ParterCatalog.Hydrant,"消火栓"},
            { Yw.Hydro.ParterCatalog.Cooling,"冷却塔"},
            { Yw.Hydro.ParterCatalog.Pipe,"管道"},
            { Yw.Hydro.ParterCatalog.Translation,"过渡件"},
            { Yw.Hydro.ParterCatalog.Pump,"水泵"},
            { Yw.Hydro.ParterCatalog.Valve,"阀门"},
            { Yw.Hydro.ParterCatalog.Exchanger,"换热器"},
            { Yw.Hydro.ParterCatalog.Compressor,"压缩机"},
        };
 
        /// <summary>
        /// 获取名称
        /// </summary>
        public static string GetName(string code)
        {
            if (_dict.ContainsKey(code))
            {
                return _dict[code];
            }
            return string.Empty;
        }
 
        /// <summary>
        /// 获取编码
        /// </summary>
        public static string GetCode(string name)
        {
            if (_dict.ContainsValue(name))
            {
                return _dict.FirstOrDefault(x => x.Value == name).Key;
            }
            return string.Empty;
        }
 
        /// <summary>
        /// 获取字典
        /// </summary>
        public static Dictionary<string, string> GetDict(Yw.Model.HydroModelInfo hydro)
        {
            var dict = new Dictionary<string, string>();
            if (hydro == null)
            {
                return dict;
            }
            if (hydro.Reservoirs != null && hydro.Reservoirs.Count > 0)
            {
                dict.Add(Yw.Hydro.ParterCatalog.Reservoir, GetName(Yw.Hydro.ParterCatalog.Reservoir));
            }
            if (hydro.Tanks != null && hydro.Tanks.Count > 0)
            {
                dict.Add(Yw.Hydro.ParterCatalog.Tank, GetName(Yw.Hydro.ParterCatalog.Tank));
            }
            if (hydro.Waterboxs != null && hydro.Waterboxs.Count > 0)
            {
                dict.Add(Yw.Hydro.ParterCatalog.Waterbox, GetName(Yw.Hydro.ParterCatalog.Waterbox));
            }
            if (hydro.Bluntheads != null && hydro.Bluntheads.Count > 0)
            {
                dict.Add(Yw.Hydro.ParterCatalog.Blunthead, GetName(Yw.Hydro.ParterCatalog.Blunthead));
            }
            if (hydro.Elbows != null && hydro.Elbows.Count > 0)
            {
                dict.Add(Yw.Hydro.ParterCatalog.Elbow, GetName(Yw.Hydro.ParterCatalog.Elbow));
            }
            if (hydro.Threelinks != null && hydro.Threelinks.Count > 0)
            {
                dict.Add(Yw.Hydro.ParterCatalog.Threelink, GetName(Yw.Hydro.ParterCatalog.Threelink));
            }
            if (hydro.Fourlinks != null && hydro.Fourlinks.Count > 0)
            {
                dict.Add(Yw.Hydro.ParterCatalog.Fourlink, GetName(Yw.Hydro.ParterCatalog.Fourlink));
            }
            if (hydro.Meters != null && hydro.Meters.Count > 0)
            {
                dict.Add(Yw.Hydro.ParterCatalog.Meter, GetName(Yw.Hydro.ParterCatalog.Meter));
            }
            if (hydro.Flowmeters != null && hydro.Flowmeters.Count > 0)
            {
                dict.Add(Yw.Hydro.ParterCatalog.Flowmeter, GetName(Yw.Hydro.ParterCatalog.Flowmeter));
            }
            if (hydro.Pressmeters != null && hydro.Pressmeters.Count > 0)
            {
                dict.Add(Yw.Hydro.ParterCatalog.Pressmeter, GetName(Yw.Hydro.ParterCatalog.Pressmeter));
            }
            if (hydro.Nozzles != null && hydro.Nozzles.Count > 0)
            {
                dict.Add(Yw.Hydro.ParterCatalog.Nozzle, GetName(Yw.Hydro.ParterCatalog.Nozzle));
            }
            if (hydro.Hydrants != null && hydro.Hydrants.Count > 0)
            {
                dict.Add(Yw.Hydro.ParterCatalog.Hydrant, GetName(Yw.Hydro.ParterCatalog.Hydrant));
            }
            if (hydro.Coolings != null && hydro.Coolings.Count > 0)
            {
                dict.Add(Yw.Hydro.ParterCatalog.Cooling, GetName(Yw.Hydro.ParterCatalog.Cooling));
            }
            if (hydro.Pipes != null && hydro.Pipes.Count > 0)
            {
                dict.Add(Yw.Hydro.ParterCatalog.Pipe, GetName(Yw.Hydro.ParterCatalog.Pipe));
            }
            if (hydro.Translations != null && hydro.Translations.Count > 0)
            {
                dict.Add(Yw.Hydro.ParterCatalog.Translation, GetName(Yw.Hydro.ParterCatalog.Translation));
            }
            if (hydro.Pumps != null && hydro.Pumps.Count > 0)
            {
                dict.Add(Yw.Hydro.ParterCatalog.Pump, GetName(Yw.Hydro.ParterCatalog.Pump));
            }
            if (hydro.Valves != null && hydro.Valves.Count > 0)
            {
                dict.Add(Yw.Hydro.ParterCatalog.Valve, GetName(Yw.Hydro.ParterCatalog.Valve));
            }
            if (hydro.Exchangers != null && hydro.Exchangers.Count > 0)
            {
                dict.Add(Yw.Hydro.ParterCatalog.Exchanger, GetName(Yw.Hydro.ParterCatalog.Exchanger));
            }
            if (hydro.Compressors != null && hydro.Compressors.Count > 0)
            {
                dict.Add(Yw.Hydro.ParterCatalog.Compressor, GetName(Yw.Hydro.ParterCatalog.Compressor));
            }
            return dict;
        }
 
 
 
    }
}