lixiaojun
2025-01-03 d672ca82c49f01dae2c5c955202b5857ef680a71
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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
namespace Yw.WinFrmUI
{
    /// <summary>
    /// 
    /// </summary>
    public static class HydroModelInfoCheckExtensions
    {
 
        /// <summary>
        /// 校验
        /// </summary>
        public static HydroCheckResult Check(this Yw.Model.HydroModelInfo hydroInfo)
        {
            var result = new HydroCheckResult();
            if (hydroInfo == null)
            {
                result.Succeed = false;
                return result;
            }
 
            //验证水源
            var checkItemLackSource = new HydroCheckItem()
            {
                Mode = HydroCheckMode.Global,
                Type = HydroCheckType.LackSource,
                Code = string.Empty,
                Failed = false,
                Reason = "至少包含一座水库或水池(水箱)"
            };
            result.Items.Add(checkItemLackSource);
            var allSourceList = hydroInfo.GetAllSources();
            if (allSourceList == null || allSourceList.Count < 1)
            {
                checkItemLackSource.Failed = true;
            }
 
            //验证连接节点
            var checkItemLackJunction = new HydroCheckItem()
            {
                Mode = HydroCheckMode.Global,
                Type = HydroCheckType.LackJunction,
                Code = string.Empty,
                Failed = false,
                Reason = "至少包含一个连接节点"
            };
            result.Items.Add(checkItemLackJunction);
            var allJunctionList = hydroInfo.GetAllJunctions();
            if (allJunctionList == null || allJunctionList.Count < 1)
            {
                checkItemLackJunction.Failed = true;
            }
 
            //验证水泵
            var checkItemLackPump = new HydroCheckItem()
            {
                Mode = HydroCheckMode.Global,
                Type = HydroCheckType.LackPump,
                Code = string.Empty,
                Failed = false,
                Reason = "至少包含一台水泵"
            };
            result.Items.Add(checkItemLackPump);
            var allPumpList = hydroInfo.Pumps;
            if (allPumpList == null || allPumpList.Count < 1)
            {
                checkItemLackPump.Failed = true;
            }
 
            //验证孤立节点
            var allNodeList = hydroInfo.GetAllNodes();
            var allLinkList = hydroInfo.GetAllLinks();
            foreach (var node in allNodeList)
            {
                var checkItemAloneNode = new HydroCheckItem()
                {
                    Mode = HydroCheckMode.Item,
                    Type = HydroCheckType.AloneNode,
                    Code = node.Code,
                    Failed = false,
                    Reason = "判断是否有管段连接"
                };
                result.Items.Add(checkItemAloneNode);
                if (!allLinkList.Exists(x => x.StartCode == node.Code || x.EndCode == node.Code))
                {
                    checkItemAloneNode.Failed = true;
                }
            }
 
            //验证管段异常连接
            foreach (var link in allLinkList)
            {
                var checkItemAbnormalLink = new HydroCheckItem()
                {
                    Mode = HydroCheckMode.Item,
                    Type = HydroCheckType.AbnormalLink,
                    Code = link.Code,
                    Failed = false,
                    Reason = "管段异常连接"
                };
                result.Items.Add(checkItemAbnormalLink);
                var startNode = allNodeList.Find(x => x.Code == link.StartCode);
                var endNode = allNodeList.Find(x => x.Code == link.EndCode);
 
                //孤立管段
                if (startNode == null && startNode == null)
                {
                    checkItemAbnormalLink.Failed = true;
                    checkItemAbnormalLink.Reason = "孤立管段";
                }
                else
                {
                    if (startNode == null)
                    {
                        checkItemAbnormalLink.Failed = true;
                        checkItemAbnormalLink.Reason = "缺少上游节点";
                    }
                    else if (endNode == null)
                    {
                        checkItemAbnormalLink.Failed = true;
                        checkItemAbnormalLink.Reason = "缺少下游节点";
                    }
                    else
                    {
                        if (startNode == endNode)
                        {
                            checkItemAbnormalLink.Failed = true;
                            checkItemAbnormalLink.Reason = "上下游节点相同";
                        }
                    }
                }
            }
 
            //验证水库
            //验证水池
            var allTankList = hydroInfo.GetAllTanks();
            if (allTankList != null && allTankList.Count > 0)
            {
                foreach (var tank in allTankList)
                {
                    //初始水位
                    var checkItemInitLevel = new HydroCheckItem()
                    {
                        Mode = HydroCheckMode.Item,
                        Type = HydroCheckType.AbnormalProp,
                        Code = tank.Code,
                        Failed = false,
                        Reason = "判断初始水位"
                    };
                    result.Items.Add(checkItemInitLevel);
                    if (tank.InitLevel <= 0)
                    {
                        checkItemInitLevel.Failed = true;
                        checkItemInitLevel.Reason = "初始水位设置错误";
                    }
                }
            }
            //验证水箱
            //验证水泵
            foreach (var pump in allPumpList)
            {
                //额定功率
                var checkItemRatedP = new HydroCheckItem()
                {
                    Mode = HydroCheckMode.Item,
                    Type = HydroCheckType.AbnormalProp,
                    Code = pump.Code,
                    Failed = false,
                    Reason = "判断水泵额定功率"
                };
                result.Items.Add(checkItemRatedP);
                if (pump.RatedP < 10)
                {
                    checkItemRatedP.Failed = true;
                    checkItemRatedP.Reason = "水泵额定功率设定错误";
                }
 
                //流量扬程曲线
                var checkItemCurveQH = new HydroCheckItem()
                {
                    Mode = HydroCheckMode.Item,
                    Type = HydroCheckType.AbnormalProp,
                    Code = pump.Code,
                    Failed = false,
                    Reason = "判断是否设置流量扬程曲线"
                };
                result.Items.Add(checkItemCurveQH);
                if (string.IsNullOrEmpty(pump.CurveQH))
                {
                    checkItemCurveQH.Failed = true;
                    checkItemCurveQH.Reason = "未设置流量扬程曲线";
                }
                else
                {
                    var curve = hydroInfo.Curves?.Find(x => x.Code == pump.CurveQH);
                    if (curve == null)
                    {
                        checkItemCurveQH.Failed = true;
                        checkItemCurveQH.Reason = "流量扬程曲线设置错误";
                    }
                }
            }
 
            //验证管道
            var allPipeList = hydroInfo.Pipes;
            if (allPipeList == null)
            {
                allPipeList = new List<Model.HydroPipeInfo>();
            }
            foreach (var pipe in allPipeList)
            {
                //长度
                var checkItemLength = new HydroCheckItem()
                {
                    Mode = HydroCheckMode.Item,
                    Type = HydroCheckType.AbnormalProp,
                    Code = pipe.Code,
                    Failed = false,
                    Reason = "判断管道长度"
                };
                result.Items.Add(checkItemLength);
                if (pipe.Length <= 0)
                {
                    checkItemLength.Failed = true;
                    checkItemLength.Reason = "管道长度属性设置错误";
                }
 
                //直径
                var checkItemDiameter = new HydroCheckItem()
                {
                    Mode = HydroCheckMode.Item,
                    Type = HydroCheckType.AbnormalProp,
                    Code = pipe.Code,
                    Failed = false,
                    Reason = "判断管道直径"
                };
                result.Items.Add(checkItemDiameter);
                if (pipe.Diameter <= 10 || pipe.Diameter > 10000)
                {
                    checkItemDiameter.Failed = true;
                    checkItemDiameter.Reason = "管道直径区间(10,10000]";
                }
 
                //粗糙系数
                var checkItemRoughness = new HydroCheckItem()
                {
                    Mode = HydroCheckMode.Item,
                    Type = HydroCheckType.AbnormalProp,
                    Code = pipe.Code,
                    Failed = false,
                    Reason = "判断管道粗糙系数"
                };
                result.Items.Add(checkItemRoughness);
                if (pipe.Roughness <= 5 || pipe.Roughness > 10000)
                {
                    checkItemRoughness.Failed = true;
                    checkItemRoughness.Reason = "管道粗糙系数(5,10000]";
                }
            }
 
            #region 验证阻件
 
            //当成GPV阀门处理的
            var allResistanceList = hydroInfo.GetAllResistances();
            if (allResistanceList != null && allResistanceList.Count > 0)
            {
                foreach (var resistance in allResistanceList)
                {
                    //直径
                    var checkItemDiameter = new HydroCheckItem()
                    {
                        Mode = HydroCheckMode.Item,
                        Type = HydroCheckType.AbnormalProp,
                        Code = resistance.Code,
                        Failed = false,
                        Reason = "判断管道直径"
                    };
                    result.Items.Add(checkItemDiameter);
                    if (resistance.Diameter <= 10 || resistance.Diameter > 10000)
                    {
                        checkItemDiameter.Failed = true;
                        checkItemDiameter.Reason = "水力组件直径区间(10,10000]";
                    }
                    var checkItemCurveQL = new HydroCheckItem()
                    {
                        Mode = HydroCheckMode.Item,
                        Type = HydroCheckType.AbnormalProp,
                        Code = resistance.Code,
                        Failed = false,
                        Reason = "判断水头损失曲线"
                    };
                    result.Items.Add(checkItemCurveQL);
                    if (resistance.LinkStatus == Yw.Hydro.ResistanceStatus.None)
                    {
                        if (string.IsNullOrEmpty(resistance.CurveQL))
                        {
                            checkItemCurveQL.Failed = true;
                            checkItemCurveQL.Reason = "缺少水头损失曲线";
                        }
                        else
                        {
                            if (hydroInfo.Curves == null || !hydroInfo.Curves.Exists(t => t.Code == resistance.CurveQL))
                            {
                                checkItemCurveQL.Failed = true;
                                checkItemCurveQL.Reason = "缺少水头损失曲线";
                            }
                        }
                    }
 
                }
 
 
            }
 
 
 
            #endregion
 
            if (result.Items.Exists(x => x.Failed))
            {
                result.Succeed = false;
            }
 
            return result;
        }
 
 
 
 
    }
}