namespace IStation.Application
|
{
|
/// <summary>
|
/// StationList
|
/// </summary>
|
[Route("SZJT/Station/List/Logic")]
|
[ApiDescriptionSettings("SZJT", Name = "泵站列表(Logic)", Order = 7000)]
|
public class StationList_LogicController : IDynamicApiController
|
{
|
|
/// <summary>
|
/// 获取监测KPI列表
|
/// </summary>
|
[Route("GetMonitorKpiList@V1.0")]
|
[HttpGet]
|
public List<StationListMonitorKpiInfoDto> 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 vmList = new List<StationListMonitorKpiInfoDto>();
|
foreach (var station in allStationList)
|
{
|
var vm = new StationListMonitorKpiInfoDto(station);
|
vmList.Add(vm);
|
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 StationListMonitorKpiLastRecordDto(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 StationListMonitorKpiLastStatusDto(equipment, runRecord));
|
}
|
}
|
}
|
return vmList;
|
}
|
|
|
|
|
|
|
|
|
}
|
}
|