lixiaojun
2025-02-18 1f7091dac2a5dddf4a0a40acb0940d3787cf35f5
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
using Yw.EPAnet;
using Yw.Hydro;
 
namespace Yw.WinFrmUI
{
    /// <summary>
    /// 损失统计辅助类
    /// </summary>
    public class HydroLossStatisticsHelper
    {
        /// <summary>
        /// 创建
        /// </summary>
        public static HydroLossStatisticsViewModel Create
            (
                Yw.Model.HydroModelInfo hydroInfo,
                HydroWorkingVmo working,
                HydroCalcuResult calcuResult = null,
                bool isHead = false,
                List<Yw.Vmo.HydroEvaluationVmo> allEvaluationList = null
            )
        {
            if (hydroInfo == null)
            {
                return default;
            }
            if (working == null)
            {
                return default;
            }
 
            var vm = new HydroLossStatisticsViewModel();
 
            //计算结果
            if (calcuResult == null)
            {
                hydroInfo.UpdateWorkingInfo(working.WorkingInfo);
                calcuResult = hydroInfo.Calcu(Yw.EPAnet.CalcuMode.MinorLoss, isHead, allEvaluationList);
                if (!calcuResult.Succeed)
                {
                    return vm;
                }
            }
 
            //能量计算
            var network = hydroInfo.ToNetwork();
            var allEnergyList = network.AnalyzeEnergy(calcuResult.EPAnetCalcuResult);
            if (allEnergyList == null || allEnergyList.Count < 1)
            {
                return vm;
            }
 
            //子级集合
            vm.Items = allEnergyList.Select(x => new HydroLossStatisticsItemViewModel(x)).ToList();
            //能量输入
            vm.Input = HydroLossStatisticsInputHelper.Create(hydroInfo, calcuResult, vm.Items);
            //分类损失
            vm.Catalog = HydroLossStatisticsCatalogHelper.Create(hydroInfo, calcuResult, vm.Items);
            //种类统计
            vm.Category = HydroLossStatisticsCategoryHelper.Create(hydroInfo, calcuResult, vm.Items);
 
            return vm;
        }
 
 
    }
}