lixiaojun
2023-12-14 b802ff5e1f903b526326c85d5658565a8dba95ec
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
namespace IStation.Application
{
    /// <summary>
    /// StationMap
    /// </summary>
    [Route("SZJT/Station/Map/Logic")]
    [ApiDescriptionSettings("SZJT", Name = "泵站地图(Logic)", Order = 6000)]
    public class StationMap_LogicController : IDynamicApiController
    {
 
        /// <summary>
        /// 获取监测KPI列表
        /// </summary>
        [Route("GetMonitorKpiList@V1.0")]
        [HttpGet]
        public List<StationMapMonitorKpiInfoDto> 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 serviceMap = new Yw.Service.MapInfo();
            var vmList = new List<StationMapMonitorKpiInfoDto>();
            foreach (var station in allStationList)
            {
                var vm = new StationMapMonitorKpiInfoDto(station);
                vmList.Add(vm);
                var map = serviceMap.Get(IStation.DataType.LogicSite, station.ID, Yw.Map.Kind.Gaodei, Yw.Map.Purpose.Location);
                if (map != null)
                {
                    var position = Yw.Model.Map.Marker.ToModel(map.Position);
                    vm.Position = position;
                }
                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 StationMapMonitorKpiLastRecordDto(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 StationMapMonitorKpiLastStatusDto(equipment, runRecord));
                    }
                }
            }
            return vmList;
        }
 
 
 
 
 
 
 
 
    }
}