duheng
2024-11-27 5d8b95b69c1bf800f2a2ebee62c6f7181c0bd7c8
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace Yw.WinFrmUI
{
    /// <summary>
    /// 
    /// </summary>
    public static class HydroCatalogLossScaleHelper
    {
        /// <summary>
        /// 获取分类损失比例列表
        /// </summary>
        public static List<HydroCatalogLossScaleViewModel> GetAllCatalogLossScaleList(this Yw.Model.HydroModelInfo hydroInfo, List<Yw.EPAnet.EnergyPoint> allEnergyList)
        {
            if (hydroInfo == null)
            {
                return default;
            }
            var allScaleList = new List<HydroCatalogLossScaleViewModel>();
            if (allEnergyList != null && allEnergyList.Count > 0)
            {
                if (hydroInfo.Pipes != null && hydroInfo.Pipes.Count > 0)
                {
                    var allVisualIds = hydroInfo.Pipes.Select(x => x.Code).Distinct().ToList();
                    var allVisualEnergyList = allEnergyList.Where(x => allVisualIds.Contains(x.Id)).ToList();
                    var visualLossScale = new HydroCatalogLossScaleViewModel();
                    visualLossScale.Catalog = Yw.Hydro.ParterCatalog.Pipe;
                    visualLossScale.CatalogName = HydroParterCatalogHelper.GetName(Yw.Hydro.ParterCatalog.Pipe);
                    visualLossScale.Loss = allVisualEnergyList.Count > 0 ? allVisualEnergyList.Sum(x => x.EnergyPower) : 0;
                    allScaleList.Add(visualLossScale);
                }
                if (hydroInfo.Translations != null && hydroInfo.Translations.Count > 0)
                {
                    var allVisualIds = hydroInfo.Translations.Select(x => x.Code).Distinct().ToList();
                    var allVisualEnergyList = allEnergyList.Where(x => allVisualIds.Contains(x.Id)).ToList();
                    var visualLossScale = new HydroCatalogLossScaleViewModel();
                    visualLossScale.Catalog = Yw.Hydro.ParterCatalog.Translation;
                    visualLossScale.CatalogName = HydroParterCatalogHelper.GetName(Yw.Hydro.ParterCatalog.Translation);
                    visualLossScale.Loss = allVisualEnergyList.Count > 0 ? allVisualEnergyList.Sum(x => x.EnergyPower) : 0;
                    allScaleList.Add(visualLossScale);
                }
                if (hydroInfo.Valves != null && hydroInfo.Valves.Count > 0)
                {
                    var allVisualIds = hydroInfo.Valves.Select(x => x.Code).Distinct().ToList();
                    var allVisualEnergyList = allEnergyList.Where(x => allVisualIds.Contains(x.Id)).ToList();
                    var visualLossScale = new HydroCatalogLossScaleViewModel();
                    visualLossScale.Catalog = Yw.Hydro.ParterCatalog.Valve;
                    visualLossScale.CatalogName = HydroParterCatalogHelper.GetName(Yw.Hydro.ParterCatalog.Valve);
                    visualLossScale.Loss = allVisualEnergyList.Count > 0 ? allVisualEnergyList.Sum(x => x.EnergyPower) : 0;
                    allScaleList.Add(visualLossScale);
                }
                if (hydroInfo.Elbows != null && hydroInfo.Elbows.Count > 0)
                {
                    var allVisualIds = hydroInfo.Elbows.Select(x => x.Code).Distinct().ToList();
                    var allVisualEnergyList = allEnergyList.Where(x => allVisualIds.Contains(x.Id)).ToList();
                    var visualLossScale = new HydroCatalogLossScaleViewModel();
                    visualLossScale.Catalog = Yw.Hydro.ParterCatalog.Elbow;
                    visualLossScale.CatalogName = HydroParterCatalogHelper.GetName(Yw.Hydro.ParterCatalog.Elbow);
                    visualLossScale.Loss = allVisualEnergyList.Count > 0 ? allVisualEnergyList.Sum(x => x.EnergyPower) : 0;
                    allScaleList.Add(visualLossScale);
                }
                if (hydroInfo.Threelinks != null && hydroInfo.Threelinks.Count > 0)
                {
                    var allVisualIds = hydroInfo.Threelinks.Select(x => x.Code).Distinct().ToList();
                    var allVisualEnergyList = allEnergyList.Where(x => allVisualIds.Contains(x.Id)).ToList();
                    var visualLossScale = new HydroCatalogLossScaleViewModel();
                    visualLossScale.Catalog = Yw.Hydro.ParterCatalog.Threelink;
                    visualLossScale.CatalogName = HydroParterCatalogHelper.GetName(Yw.Hydro.ParterCatalog.Threelink);
                    visualLossScale.Loss = allVisualEnergyList.Count > 0 ? allVisualEnergyList.Sum(x => x.EnergyPower) : 0;
                    allScaleList.Add(visualLossScale);
                }
            }
            return allScaleList;
        }
 
 
    }
}