lixiaojun
2023-12-26 3c05a19c6896c197953df955c729d26c8dc94536
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
namespace IStation.Application
{
    /// <summary>
    /// StationList
    /// </summary>
    [Route("SZJT/Station/List/Mobile")]
    [ApiDescriptionSettings("SZJT", Name = "泵站列表(手机)", Order = 2000)]
    public class StationList_MobileController : IDynamicApiController
    {
 
        /// <summary>
        /// 获取所有
        /// </summary>
        [Route("GetAll@V1.0")]
        [HttpGet]
        public List<StationListGroupMobileDto> GetAll()
        {
            var keyContent = $"SZJT_Station_List_Mobile_GetAll";
            var cacheKey = MemoryCacheKeyHelper.GetKey(MemoryCacheKey.WebApiLevel, MemoryCacheKey.Module, keyContent);
 
            var vm_list = MemoryCacheHelper.GetSet(cacheKey, () =>
            {
                #region 获取默认策略
 
                var allPolicyList = new Service.LogicPolicy().GetAll();
                Service.LogicPolicy.PublishCache(cacheKey);
                var policy = allPolicyList?.Find(x => x.Flags.Contains(IStation.Flags.默认));
                if (policy == null)
                {
                    policy = allPolicyList?.FirstOrDefault();
                }
                if (policy == null)
                {
                    return default;
                }
 
                #endregion
 
                #region 获取清单列表
 
                var allLogicTreeList = new Service.LogicTree().GetExByPolicyID(policy.ID);
                Service.LogicTree.PublishCache(cacheKey);
                if (allLogicTreeList == null || allLogicTreeList.Count < 1)
                {
                    return default;
                }
 
                #endregion
 
                var vmList = new List<StationListGroupMobileDto>();
                var service_map = new Yw.Service.MapInfo();
 
                foreach (var logicTree in allLogicTreeList)
                {
                    if (logicTree.LogicType == IStation.DataType.LogicArea)
                    {
                        var group = new StationListGroupMobileDto();
                        group.ID = logicTree.LogicID;
                        group.Name = logicTree.Name;
                        group.SortCode = logicTree.SortCode;
                        group.Description = logicTree.Description;
                        group.StationList = new List<StationListItemMobileDto>();
                        vmList.Add(group);
                        continue;
                    }
                    if (logicTree.LogicType == IStation.DataType.LogicSite)
                    {
                        var station = new StationListItemMobileDto();
                        station.ID = logicTree.LogicID;
                        station.Name = logicTree.Name;
                        station.SortCode = logicTree.SortCode;
                        station.Description = logicTree.Description;
                        var mapInfo = service_map.Get(logicTree.LogicType, logicTree.LogicID, Yw.Map.Kind.Gaodei, Yw.Map.Purpose.Location);
                        if (mapInfo != null)
                        {
                            var marker = Yw.Model.Map.Marker.ToModel(mapInfo.Position);
                            if (marker != null)
                            {
                                station.Address = marker.Address;
                            }
                        }
                        var parentLogicTree = allLogicTreeList.Find(x => logicTree.ParentIds.LastOrDefault() == x.ID);
                        if (parentLogicTree != null)
                        {
                            if (parentLogicTree.LogicType == IStation.DataType.LogicArea)
                            {
                                var group = vmList.Find(x => x.ID == parentLogicTree.LogicID);
                                if (group != null)
                                {
                                    group.StationList.Add(station);
                                }
                            }
                        }
                    }
                }
 
 
                return vmList;
            }, CacheHelper.CacheLevel1);
            return vm_list;
 
        }
 
 
 
 
 
 
 
 
 
    }
}