lixiaojun
2024-04-04 0a48aec6a38d34db6e9194920aac7d2d19cadcb3
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
namespace IStation.Application
{
    /// <summary>
    /// MeterList 
    /// </summary>
    [Route("SZJT/Meter/List/Mobile")]
    [ApiDescriptionSettings("SZJT", Name = "仪表列表(手机)", Order = 1900)]
    public class MeterList_MobileController : IDynamicApiController
    {
 
        /// <summary>
        /// 获取所有
        /// </summary>
        [Route("GetAll@V1.0")]
        [HttpGet]
        public List<MeterListGroupMobileDto> GetAll()
        {
            var keyContent = $"SZJT_Meter_List_Mobile_GetAll";
            var cacheKey = MemoryCacheKeyHelper.GetKey(MemoryCacheKey.WebApiLevel, MemoryCacheKey.Module, keyContent);
 
            var vm_list = MemoryCacheHelper.GetSet(cacheKey, () =>
            {
                #region 数据准备
 
                var allEquipmentList = new Yw.Service.Equipment().GetByBelongTypeAndBelongID(IStation.DataType.LogicDma, 1);
                Yw.Service.Equipment.PublishCache(cacheKey);
                if (allEquipmentList == null || allEquipmentList.Count < 1)
                {
                    return default;
                }
                var service_catalog = new Yw.Service.SysCatalog();
                var service_map = new Yw.Service.MapInfo();
                var vmList = new List<MeterListGroupMobileDto>();
 
                #endregion
 
                #region 流量计
 
                var vm_group_flow = new MeterListGroupMobileDto()
                {
                    ID = 1,
                    Name = "流量计",
                    SortCode = 1,
                    Description = string.Empty
                };
                vmList.Add(vm_group_flow);
                var allFlowCatalogList = service_catalog.GetChildAndSelfByCode(IStation.Catalog.FlowMeter);
                if (allFlowCatalogList != null && allFlowCatalogList.Count > 0)
                {
                    var allFlowCatalogIds = allFlowCatalogList.Select(x => x.ID).Distinct().ToList();
                    var allFlowList = allEquipmentList.Where(x => allFlowCatalogIds.Contains(x.CatalogID)).ToList();
                    if (allFlowList != null && allFlowList.Count > 0)
                    {
                        vm_group_flow.MeterList = new List<MeterListItemMobileDto>();
                        foreach (var flow in allFlowList)
                        {
                            var vm_meter_flow = new MeterListItemMobileDto(flow);
                            vm_group_flow.MeterList.Add(vm_meter_flow);
                            var mapInfo = service_map.Get(Yw.Assets.DataType.Equipment, flow.ID, Yw.Map.Kind.Gaodei, Yw.Map.Purpose.Location);
                            if (mapInfo != null)
                            {
                                var marker = Yw.Model.Map.Marker.ToModel(mapInfo.Position);
                                if (marker != null)
                                {
                                    vm_meter_flow.Address = marker.Address;
                                }
                            }
                        }
                    }
                }
 
                #endregion
 
                #region 压力计
 
                var vm_group_press = new MeterListGroupMobileDto()
                {
                    ID = 2,
                    Name = "压力计",
                    SortCode = 2,
                    Description = string.Empty
                };
                vmList.Add(vm_group_press);
                var allPressMeterList = service_catalog.GetChildAndSelfByCode(IStation.Catalog.PressMeter);
                if (allPressMeterList != null && allPressMeterList.Count > 0)
                {
                    var allPressCatalogIds = allPressMeterList.Select(x => x.ID).Distinct().ToList();
                    var allPressList = allEquipmentList.Where(x => allPressCatalogIds.Contains(x.CatalogID)).ToList();
                    if (allPressList != null && allPressList.Count > 0)
                    {
                        vm_group_press.MeterList = new List<MeterListItemMobileDto>();
                        foreach (var press in allPressList)
                        {
                            var vm_meter_press = new MeterListItemMobileDto(press);
                            vm_group_press.MeterList.Add(vm_meter_press);
                            var mapInfo = service_map.Get(Yw.Assets.DataType.Equipment, press.ID, Yw.Map.Kind.Gaodei, Yw.Map.Purpose.Location);
                            if (mapInfo != null)
                            {
                                var marker = Yw.Model.Map.Marker.ToModel(mapInfo.Position);
                                if (marker != null)
                                {
                                    vm_meter_press.Address = marker.Address;
                                }
                            }
                        }
                    }
                }
 
                #endregion
 
                #region 功率表
 
                //var vm_group_power = new MeterListGroupMobileDto()
                //{
                //    ID = 3,
                //    Name = "功率表",
                //    SortCode = 3,
                //    Description = string.Empty
                //};
                //vmList.Add(vm_group_power);
 
                #endregion
 
                #region 水质仪
 
                //var vm_group_water = new MeterListGroupMobileDto()
                //{
                //    ID = 4,
                //    Name = "水质仪",
                //    SortCode = 4,
                //    Description = string.Empty
                //};
                //vmList.Add(vm_group_water);
 
                #endregion
 
                return vmList;
            }, Yw.Service.ConfigHelper.CacheLevel1);
            return vm_list;
 
        }
 
 
 
 
 
 
 
 
 
    }
}