namespace IStation.Application
|
{
|
/// <summary>
|
/// StationMap
|
/// </summary>
|
[Route("SZJT/Station/Map")]
|
[ApiDescriptionSettings("SZJT", Name = "泵站地图(Logic)", Order = 6000)]
|
public class StationMap_LogicController : IDynamicApiController
|
{
|
|
/// <summary>
|
/// 获取监测KPI列表
|
/// </summary>
|
[Route("GetMonitorKpiList@V1.0")]
|
[HttpGet]
|
public List<StationMapMonitorKpiInfoDto> GetMonitorKpiList(int Count = 4)
|
{
|
var allStationList = new Service.LogicSite().GetAll();
|
if (allStationList == null || allStationList.Count < 1)
|
{
|
return default;
|
}
|
var serviceMonitor = new Yw.Service.MonitorPoint();
|
var serviceMonitorRecord = new Yw.Service.MonitorRealRecord();
|
var serviceEquipment = new Yw.Service.Equipment();
|
var serviceRunRecord = new Yw.Service.RunRealRecord();
|
var serviceMap = new Yw.Service.MapInfo();
|
var vmList = new List<StationMapMonitorKpiInfoDto>();
|
foreach (var station in allStationList)
|
{
|
var vm = new StationMapMonitorKpiInfoDto(station);
|
vmList.Add(vm);
|
var map = serviceMap.Get(IStation.DataType.LogicSite, station.ID, Yw.Map.Kind.Gaodei, Yw.Map.Purpose.Location);
|
if (map != null)
|
{
|
var position = Yw.Model.Map.Marker.ToModel(map.Position);
|
vm.Position = position;
|
}
|
var allMonitorList = serviceMonitor.GetExSignalWithSignalTypeByBelongTypeAndBelongID(IStation.DataType.LogicSite, station.ID);
|
allMonitorList = allMonitorList?.Where(x => x.CronType == Yw.Monitor.eCronType.Real).ToList();
|
if (allMonitorList != null && allMonitorList.Count > 0)
|
{
|
allMonitorList = allMonitorList.Where(x => x.Flags.Contains(Flags.KPI)).OrderByDescending(X => X.Importance).ToList();
|
if (allMonitorList.Count > 0)
|
{
|
allMonitorList = allMonitorList.Take(Count).ToList();
|
foreach (var monitor in allMonitorList)
|
{
|
var monitorRecord = serviceMonitorRecord.GetLastRecord(monitor.SignalList.First().ID);
|
vm.LastRecordList.Add(new StationMapMonitorKpiLastRecordDto(monitor, monitorRecord));
|
}
|
}
|
}
|
|
var allEquipmentList = serviceEquipment.GetByBelongTypeAndBelongID(IStation.DataType.LogicSite, station.ID);
|
allEquipmentList = allEquipmentList?.Where(x => x.ParentIds.Count < 1).ToList();
|
if (allEquipmentList != null && allEquipmentList.Count > 0)
|
{
|
foreach (var equipment in allEquipmentList)
|
{
|
var runRecord = serviceRunRecord.GetLastRecord(Yw.Assets.DataType.Equipment, equipment.ID);
|
vm.LastStatusList.Add(new StationMapMonitorKpiLastStatusDto(equipment, runRecord));
|
}
|
}
|
}
|
return vmList;
|
}
|
|
|
|
|
|
|
|
|
}
|
}
|