namespace IStation.Application
{
///
/// MeterList
///
[Route("SZJT/Meter/List/Mobile")]
[ApiDescriptionSettings("SZJT", Name = "仪表列表(手机)", Order = 1900)]
public class MeterList_MobileController : IDynamicApiController
{
///
/// 获取所有
///
[Route("GetAll@V1.0")]
[HttpGet]
public List 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();
#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();
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();
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;
}
}
}