namespace IStation.Application { /// /// StationList /// [Route("SZJT/Station/List/Mobile")] [ApiDescriptionSettings("SZJT", Name = "泵站列表(手机)", Order = 2000)] public class StationList_MobileController : IDynamicApiController { /// /// 获取所有 /// [Route("GetAll@V1.0")] [HttpGet] public List 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(); 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(); 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; }, Yw.Service.ConfigHelper.CacheLevel1); return vm_list; } } }