| | |
| | | [HttpGet] |
| | | public List<StationPanelMonitorKpiInfoDto> GetMonitorKpiList(int Count = 4) |
| | | { |
| | | var allStationList = new Service.LogicSite().GetAll(); |
| | | #region 服务准备 |
| | | |
| | | var service_logic_site = new Lazy<Service.LogicSite>(() => new 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; |
| | | } |
| | | var serviceMonitor = new Yw.Service.MonitorPoint(); |
| | | var serviceMonitorRecord = new Yw.Service.MonitorRealRecord(); |
| | | var serviceEquipment = new Yw.Service.Equipment(); |
| | | var serviceRunRecord = new Yw.Service.RunRealRecord(); |
| | | |
| | | #endregion |
| | | |
| | | var vmList = new List<StationPanelMonitorKpiInfoDto>(); |
| | | foreach (var station in allStationList) |
| | | { |
| | | var vm = new StationPanelMonitorKpiInfoDto(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) |
| | | |
| | | 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) |
| | | { |
| | | allMonitorList = allMonitorList.Where(x => x.Flags.Contains(Flags.KPI)).OrderByDescending(X => X.Importance).ToList(); |
| | | if (allMonitorList.Count > 0) |
| | | monitorList = monitorList.Where(x => x.Flags.Contains(Flags.KPI)).OrderByDescending(X => X.Importance).ToList(); |
| | | if (monitorList.Count > 0) |
| | | { |
| | | allMonitorList = allMonitorList.Take(Count).ToList(); |
| | | foreach (var monitor in allMonitorList) |
| | | monitorList = monitorList.Take(Count).ToList(); |
| | | foreach (var monitor in monitorList) |
| | | { |
| | | var monitorRecord = serviceMonitorRecord.GetLastRecord(monitor.SignalList.First().ID); |
| | | var monitorRecord = service_monitor_record.Value.GetLastRecord(monitor.SignalList.First().ID); |
| | | vm.LastRecordList.Add(new StationPanelMonitorKpiLastRecordDto(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) |
| | | var equipmentGroupList = service_equipment_group.Value.GetByBelongTypeAndBelongID(IStation.DataType.LogicSite, station.ID); |
| | | if (equipmentGroupList != null && equipmentGroupList.Count > 0) |
| | | { |
| | | foreach (var equipment in allEquipmentList) |
| | | var equipmentGroup = equipmentGroupList.Find(x => x.Flags.Contains(IStation.Flags.机组)); |
| | | if (equipmentGroup != null) |
| | | { |
| | | var runRecord = serviceRunRecord.GetLastRecord(Yw.Assets.DataType.Equipment, equipment.ID); |
| | | vm.LastStatusList.Add(new StationPanelMonitorKpiLastStatusDto(equipment, runRecord)); |
| | | 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)); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |