namespace IStation.Application
|
{
|
/// <summary>
|
/// StationPanel
|
/// </summary>
|
[Route("SZJT/Station/Panel/Logic")]
|
[ApiDescriptionSettings("SZJT", Name = "泵站面板(Logic)", Order = 8000)]
|
public class StationPanel_LogicController : IDynamicApiController
|
{
|
|
/// <summary>
|
/// 获取监测KPI列表
|
/// </summary>
|
[Route("GetMonitorKpiList@V1.0")]
|
[HttpGet]
|
public List<StationPanelMonitorKpiInfoDto> GetMonitorKpiList(int Count = 4)
|
{
|
#region 服务准备
|
|
var service_logic_site = new Lazy<Yw.Service.LogicSite>(() => new Yw.Service.LogicSite());
|
var service_equipment_group = new Lazy<Yw.Service.EquipmentGroup>(() => new Yw.Service.EquipmentGroup());
|
var service_equipment = new Lazy<Yw.Service.Equipment>(() => new Yw.Service.Equipment());
|
var service_monitor_group = new Lazy<Yw.Service.MonitorPointGroup>(() => new Yw.Service.MonitorPointGroup());
|
var service_monitor = new Lazy<Yw.Service.MonitorPoint>(() => new Yw.Service.MonitorPoint());
|
var service_signal = new Lazy<Yw.Service.Signal>(() => new Yw.Service.Signal());
|
var service_monitor_record = new Lazy<Yw.Service.MonitorRealRecord>(() => new Yw.Service.MonitorRealRecord());
|
var service_run_record = new Lazy<Yw.Service.RunRealRecord>(() => 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<StationPanelMonitorKpiInfoDto>();
|
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;
|
}
|
|
|
|
|
|
|
|
|
}
|
}
|