namespace IStation.Application
{
///
/// StationPanel
///
[Route("SZJT/Station/Panel/Logic")]
[ApiDescriptionSettings("SZJT", Name = "泵站面板(Logic)", Order = 8000)]
public class StationPanel_LogicController : IDynamicApiController
{
///
/// 获取监测KPI列表
///
[Route("GetMonitorKpiList@V1.0")]
[HttpGet]
public List GetMonitorKpiList(int Count = 4)
{
#region 服务准备
var service_logic_site = new Lazy(() => new Service.LogicSite());
var service_equipment_group = new Lazy(() => new Yw.Service.EquipmentGroup());
var service_equipment = new Lazy(() => new Yw.Service.Equipment());
var service_monitor_group = new Lazy(() => new Yw.Service.MonitorPointGroup());
var service_monitor = new Lazy(() => new Yw.Service.MonitorPoint());
var service_signal = new Lazy(() => new Yw.Service.Signal());
var service_monitor_record = new Lazy(() => new Yw.Service.MonitorRealRecord());
var service_run_record = new Lazy(() => new Yw.Service.RunRealRecord());
#endregion
#region 获取所有泵站
var allStationList = service_logic_site.Value.GetAll();
if (allStationList == null || allStationList.Count < 1)
{
return default;
}
#endregion
var vmList = new List();
foreach (var station in allStationList)
{
var vm = new StationPanelMonitorKpiInfoDto(station);
vmList.Add(vm);
var monitorList = service_monitor.Value.GetExSignalWithSignalTypeByBelongTypeAndBelongID(IStation.DataType.LogicSite, station.ID, Yw.Monitor.eCronType.Real);
monitorList = monitorList?.Where(x => x.UseStatus == Yw.Model.eUseStatus.Enable).ToList();
if (monitorList != null && monitorList.Count > 0)
{
monitorList = monitorList.Where(x => x.Flags.Contains(Flags.KPI)).OrderByDescending(X => X.Importance).ToList();
if (monitorList.Count > 0)
{
monitorList = monitorList.Take(Count).ToList();
foreach (var monitor in monitorList)
{
var monitorRecord = service_monitor_record.Value.GetLastRecord(monitor.SignalList.First().ID);
vm.LastRecordList.Add(new StationPanelMonitorKpiLastRecordDto(monitor, monitorRecord));
}
}
}
var equipmentGroupList = service_equipment_group.Value.GetByBelongTypeAndBelongID(IStation.DataType.LogicSite, station.ID);
if (equipmentGroupList != null && equipmentGroupList.Count > 0)
{
var equipmentGroup = equipmentGroupList.Find(x => x.Flags.Contains(IStation.Flags.机组));
if (equipmentGroup != null)
{
var equipmentList = service_equipment.Value.GetByGroupID(equipmentGroup.ID);
equipmentList = equipmentList?.Where(x => x.ParentIds.Count < 1).ToList();
if (equipmentList != null && equipmentList.Count > 0)
{
foreach (var equipment in equipmentList)
{
var runRecord = service_run_record.Value.GetLastRecord(Yw.Assets.DataType.Equipment, equipment.ID);
vm.LastStatusList.Add(new StationPanelMonitorKpiLastStatusDto(equipment, runRecord));
}
}
}
}
}
return vmList;
}
}
}