lixiaojun
2025-02-17 f4a5f0c3fc24136294eec0153ec0605529243388
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
namespace HStation.WinFrmUI
{
    /// <summary>
    /// 
    /// </summary>
    public class SimulationPrintLossStatisticsCategoryViewModel
    {
        /// <summary>
        /// 
        /// </summary>
        public SimulationPrintLossStatisticsCategoryViewModel() { }
 
        /// <summary>
        /// 
        /// </summary>
        public SimulationPrintLossStatisticsCategoryViewModel
            (
                Yw.Model.HydroModelInfo hydroInfo,
                HydroCalcuResult calcuResult,
                List<SimulationPrintLossStatisticsItemViewModel> allItemList
            )
        {
            if (hydroInfo == null)
            {
                return;
            }
            if (calcuResult == null || !calcuResult.Succeed)
            {
                return;
            }
            if (allItemList == null || allItemList.Count < 1)
            {
                return;
            }
 
            this.Items = new List<SimulationPrintLossStatisticsCategoryItemViewModel>();
            var groupList = allItemList.GroupBy(x => x.EnergyType).ToList();
            foreach (var group in groupList)
            {
                var item = new SimulationPrintLossStatisticsCategoryItemViewModel();
                switch (group.Key)
                {
                    case Yw.EPAnet.eEnergyType.Input:
                        {
                            item.EnergyType = Yw.WinFrmUI.eEnergyType.Input;
                            item.Name = "输入能量";
                        }
                        break;
                    case Yw.EPAnet.eEnergyType.Output:
                        {
                            item.EnergyType = Yw.WinFrmUI.eEnergyType.Output;
                            item.Name = "输出能量";
                        }
                        break;
                    case Yw.EPAnet.eEnergyType.Promote:
                        {
                            item.EnergyType = Yw.WinFrmUI.eEnergyType.Promote;
                            item.Name = "提升能量";
                        }
                        break;
                    case Yw.EPAnet.eEnergyType.MinorLoss:
                        {
                            item.EnergyType = Yw.WinFrmUI.eEnergyType.MinorLoss;
                            item.Name = "局部损失";
                        }
                        break;
                    case Yw.EPAnet.eEnergyType.FrictionalLoss:
                        {
                            item.EnergyType = Yw.WinFrmUI.eEnergyType.FrictionalLoss;
                            item.Name = "沿程损失";
                        }
                        break;
                    default: break;
                }
                item.Value = group.Sum(x => x.EnergyValue);
                this.Items.Add(item);
            }
 
            double pumpLoss = 0;
            if (hydroInfo.Pumps != null && hydroInfo.Pumps.Count > 0)
            {
                var allCalcuVisualDict = calcuResult.GetVisualDict();
                foreach (var pump in hydroInfo.Pumps)
                {
                    var calcuPumpResult = allCalcuVisualDict?.GetValue(pump.Code) as HydroCalcuPumpResult;
                    if (calcuPumpResult != null)
                    {
                        if (calcuPumpResult.CalcuP.HasValue && calcuPumpResult.CalcuE.HasValue)
                        {
                            pumpLoss += calcuPumpResult.CalcuP.Value * 1000 * (1 - calcuPumpResult.CalcuE.Value / 100);
                        }
                    }
                }
            }
 
            var promoteItem = this.Items.Find(x => x.EnergyType == Yw.WinFrmUI.eEnergyType.Promote);
            if (promoteItem != null)
            {
                promoteItem.Value += pumpLoss;
            }
 
            var minorLossItem = this.Items.Find(x => x.EnergyType == Yw.WinFrmUI.eEnergyType.MinorLoss);
            if (minorLossItem != null)
            {
                minorLossItem.Value += pumpLoss;
            }
 
        }
 
        /// <summary>
        /// 子级集合
        /// </summary>
        public List<SimulationPrintLossStatisticsCategoryItemViewModel> Items { get; set; }
 
 
    }
}