namespace IStation.Application { /// /// StationList /// [Route("SZJT/Station/List/Logic")] [ApiDescriptionSettings("SZJT", Name = "泵站列表(Logic)", Order = 7000)] public class StationList_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 StationListMonitorKpiInfoDto(station); vmList.Add(vm); var allMonitorList = service_monitor.Value.GetExSignalWithSignalTypeByBelongTypeAndBelongID(IStation.DataType.LogicSite, station.ID, Yw.Monitor.eCronType.Real); allMonitorList = allMonitorList?.Where(x => x.UseStatus == Yw.Model.eUseStatus.Enable).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 = service_monitor_record.Value.GetLastRecord(monitor.SignalList.First().ID); vm.LastRecordList.Add(new StationListMonitorKpiLastRecordDto(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 StationListMonitorKpiLastStatusDto(equipment, runRecord)); } } } } } return vmList; } } }