lixiaojun
2024-05-15 e45eab5980c08520aee01a72224ccdfd12600543
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
using Microsoft.VisualBasic;
 
namespace IStation.Application
{
    /// <summary>
    /// BigScreen
    /// </summary>
    [Route("SZJT/Big/Screen/Logic")]
    [ApiDescriptionSettings("SZJT", Name = "大屏(Logic)", Order = 1000)]
    public class BigScreen_LogicController : IDynamicApiController
    {
 
        #region 所有
 
        /// <summary>
        /// 获取所有泵站kpi信息(待完善)
        /// </summary>
        [Route("GetAllStationKpiInfo@V1.0")]
        [HttpGet]
        public BigScreenAllStationKpiDto GetAllStationKpiInfo()
        {
            var vm = new BigScreenAllStationKpiDto();
            vm.Lws = new BigScreenAllStationKpiItemDto()
            {
                Name = "当日累计供水量",
                Value = "1120",
                UnitName = "m³"
            };
            vm.Lps = new BigScreenAllStationKpiItemDto()
            {
                Name = "当日累计用电量",
                Value = "2300",
                UnitName = "kW‧h"
            };
            vm.Sws = new BigScreenAllStationKpiItemDto()
            {
                Name = "当前瞬时总流量",
                Value = "2300.2",
                UnitName = "m³/h"
            };
            vm.Sps = new BigScreenAllStationKpiItemDto()
            {
                Name = "当前瞬时总功率",
                Value = "2600.2",
                UnitName = "kW"
            };
            vm.Tsc = new BigScreenAllStationKpiItemDto()
            {
                Name = "泵站总数量",
                Value = "13",
                UnitName = "座"
            };
            vm.Rsc = new BigScreenAllStationKpiItemDto()
            {
                Name = "运行泵站数量",
                Value = "10",
                UnitName = "座"
            };
            vm.Tpc = new BigScreenAllStationKpiItemDto()
            {
                Name = "机组总数",
                Value = "50",
                UnitName = "台"
            };
            vm.Rpc = new BigScreenAllStationKpiItemDto()
            {
                Name = "运行机组数量",
                Value = "40",
                UnitName = "台"
            };
            return vm;
        }
 
        /// <summary>
        /// 获取所有泵站项列表
        /// </summary>
        [Route("GetAllStationItemList@V1.0")]
        [HttpGet]
        public List<BigScreenAllStationListItemDto> GetAllStationItemList()
        {
            var allStationList = new Service.LogicSite().GetAll();
            if (allStationList == null || allStationList.Count < 1)
            {
                return default;
            }
 
            var service_monitor = new Lazy<Yw.Service.MonitorPoint>(() => new Yw.Service.MonitorPoint());
            var service_monitor_record = new Lazy<Yw.Service.MonitorRealRecord>(() => new Yw.Service.MonitorRealRecord());
 
            var vmList = new List<BigScreenAllStationListItemDto>();
            foreach (var station in allStationList)
            {
                var vm = new BigScreenAllStationListItemDto();
                vm.ID = station.ID;
                vm.Name = station.Name;
                vmList.Add(vm);
                var allMonitorList = service_monitor.Value.GetExSignalWithSignalTypeByBelongTypeAndBelongID(IStation.DataType.LogicSite, station.ID, Yw.Monitor.eCronType.Real);
                if (allMonitorList != null && allMonitorList.Count > 0)
                {
                    var monitorQ = allMonitorList.Find(x => x.SignalList.Exists(t => t.SignalType.Code == Yw.Monitor.SignalType.瞬时流量));
                    if (monitorQ != null)
                    {
                        var signalQ = monitorQ.SignalList.Find(x => x.SignalType.Code == Yw.Monitor.SignalType.瞬时流量);
                        vm.Qk = new BigScreenAllStationListKpiItemDto()
                        {
                            Name = "瞬时流量",
                            Value = null,
                            UnitName = signalQ.GetDisplayUnitName()
                        };
                        var recordQ = service_monitor_record.Value.GetLastRecord(signalQ.ID);
                        if (recordQ != null)
                        {
                            vm.Qk.Value = signalQ.GetDisplayValue(recordQ.DataValue);
                        }
                    }
 
                    var monitorPr = allMonitorList.Find(x => x.Flags.Contains(Yw.Monitor.Flags.出口) && x.SignalList.Exists(t => t.SignalType.Code == Yw.Monitor.SignalType.压力));
                    if (monitorPr != null)
                    {
                        var signalPr = monitorPr.SignalList.Find(x => x.SignalType.Code == Yw.Monitor.SignalType.压力);
                        vm.Prk = new BigScreenAllStationListKpiItemDto()
                        {
                            Name = "出口压力",
                            Value = null,
                            UnitName = signalPr.GetDisplayUnitName()
                        };
                        var recordPr = service_monitor_record.Value.GetLastRecord(signalPr.ID);
                        if (recordPr != null)
                        {
                            vm.Prk.Value = signalPr.GetDisplayValue(recordPr.DataValue);
                        }
                    }
                }
            }
 
            return vmList;
        }
 
        /// <summary>
        /// 获取所有泵站工单Kpi信息
        /// </summary>
        [Route("GetAllStationRepairKpiInfo@V1.0")]
        [HttpGet]
        public BigScreenAllStationRepairKpiDto GetAllStationRepairKpiInfo()
        {
            var vm = new BigScreenAllStationRepairKpiDto();
            vm.Cd = 10;
            vm.Cm = 235;
            vm.Cy = 1230;
            vm.Pending = 5;
            vm.Accepted = 5;
            vm.Progress = 35;
            vm.Checked = 680;
            return vm;
        }
 
        /// <summary>
        /// 获取所有泵站工单日统计(最近一月)
        /// </summary>
        [Route("GetAllStationRepairDayStatisticsInfo@V1.0")]
        [HttpGet]
        public List<BigScreenAllStationRepairDayCountDto> GetAllStationRepairDayStatisticsInfo()
        {
            var dtEnd = DateTime.Now.Date;
            var dtStart = dtEnd.AddMonths(-1);
            var vmList = new List<BigScreenAllStationRepairDayCountDto>();
            for (DateTime dt = dtStart; dt <= dtEnd; dt = dt.AddDays(1))
            {
                var vm = new BigScreenAllStationRepairDayCountDto();
                vm.Day = dt;
                vm.Count = Yw.Untity.RandomHelper.Random(10, 100);
                vmList.Add(vm);
            }
            return vmList;
        }
 
        /// <summary>
        /// 获取所有泵站工单月统计(最近一年)
        /// </summary>
        [Route("GetAllStationRepairMonthStatisticsInfo@V1.0")]
        [HttpGet]
        public List<BigScreenAllStationRepairMonthCountDto> GetAllStationRepairMonthStatisticsInfo()
        {
            var dtNow = DateTime.Now;
            var dtEnd = new DateTime(dtNow.Year, dtNow.Month, 1);
            var dtStart = dtEnd.AddMonths(-11);
            var vmList = new List<BigScreenAllStationRepairMonthCountDto>();
            for (DateTime dt = dtStart; dt <= dtEnd; dt = dt.AddMonths(1))
            {
                var vm = new BigScreenAllStationRepairMonthCountDto();
                vm.Year = dt.Year;
                vm.Month = dt.Month;
                vm.Count = Yw.Untity.RandomHelper.Random(100, 1000);
                vmList.Add(vm);
            }
            return vmList;
        }
 
        /// <summary>
        /// 获取所有泵站报警信息
        /// </summary>
        [Route("GetAllStationAlarmInfo@V1.0")]
        [HttpGet]
        public List<BigScreenAllStationAlarmItemDto> GetAllStationAlarmInfo()
        {
            var vmList = new List<BigScreenAllStationAlarmItemDto>();
            vmList.Add(new BigScreenAllStationAlarmItemDto()
            {
                ID = 1,
                Name = "金庭中腰泵站",
                Content = "1#机组出口压力过低,请关注状态变化"
            });
            vmList.Add(new BigScreenAllStationAlarmItemDto()
            {
                ID = 2,
                Name = "凯泉一体化加压泵站",
                Content = "2#瞬时流量数据异常,请检修"
            });
            vmList.Add(new BigScreenAllStationAlarmItemDto()
            {
                ID = 3,
                Name = "凯泉一体化加压泵站",
                Content = "2#瞬时流量数据异常,请检修"
            });
            vmList.Add(new BigScreenAllStationAlarmItemDto()
            {
                ID = 4,
                Name = "凯泉一体化加压泵站",
                Content = "2#瞬时流量数据异常,请检修"
            });
            vmList.Add(new BigScreenAllStationAlarmItemDto()
            {
                ID = 5,
                Name = "凯泉一体化加压泵站",
                Content = "2#瞬时流量数据异常,请检修"
            });
            vmList.Add(new BigScreenAllStationAlarmItemDto()
            {
                ID = 6,
                Name = "凯泉一体化加压泵站",
                Content = "2#瞬时流量数据异常,请检修"
            });
            return vmList;
        }
 
        #endregion
 
 
        #region 单站
 
        /// <summary>
        /// 获取单泵站kpi信息
        /// </summary>
        [Route("GetSingleStationKpiInfo@V1.0")]
        [HttpGet]
        public BigScreenSingleStationKpiDto GetSingleStationKpiInfo([FromQuery][Required] StationIDInput input)
        {
            var vm = new BigScreenSingleStationKpiDto();
 
            var service_monitor = new Lazy<Yw.Service.MonitorPoint>(() => new Yw.Service.MonitorPoint());
            var service_monitor_record = new Lazy<Yw.Service.MonitorRealRecord>(() => new Yw.Service.MonitorRealRecord());
            var service_equipment = new Lazy<Yw.Service.Equipment>(() => new Yw.Service.Equipment());
            var service_run_record = new Lazy<Yw.Service.RunRealRecord>(() => new Yw.Service.RunRealRecord());
 
            var allMonitorList = service_monitor.Value.GetExSignalWithSignalTypeByBelongTypeAndBelongID(IStation.DataType.LogicSite, input.StationID, Yw.Monitor.eCronType.Real);
            if (allMonitorList != null && allMonitorList.Count > 0)
            {
                var monitorQ = allMonitorList.Find(x => x.SignalList.Exists(t => t.SignalType.Code == Yw.Monitor.SignalType.瞬时流量));
                if (monitorQ != null)
                {
                    var signalQ = monitorQ.SignalList.Find(x => x.SignalType.Code == Yw.Monitor.SignalType.瞬时流量);
                    vm.Q = new BigScreenSingleStationKpiItemDto()
                    {
                        Name = "瞬时流量",
                        Value = null,
                        UnitName = signalQ.GetDisplayUnitName()
                    };
                    var recordQ = service_monitor_record.Value.GetLastRecord(signalQ.ID);
                    if (recordQ != null)
                    {
                        vm.Q.Value = signalQ.GetDisplayValue(recordQ.DataValue);
                    }
                }
 
                var monitorPr = allMonitorList.Find(x => x.Flags.Contains(Yw.Monitor.Flags.出口) && x.SignalList.Exists(t => t.SignalType.Code == Yw.Monitor.SignalType.压力));
                if (monitorPr != null)
                {
                    var signalPr = monitorPr.SignalList.Find(x => x.SignalType.Code == Yw.Monitor.SignalType.压力);
                    vm.Pr = new BigScreenSingleStationKpiItemDto()
                    {
                        Name = "出口压力",
                        Value = null,
                        UnitName = signalPr.GetDisplayUnitName()
                    };
                    var recordPr = service_monitor_record.Value.GetLastRecord(signalPr.ID);
                    if (recordPr != null)
                    {
                        vm.Pr.Value = signalPr.GetDisplayValue(recordPr.DataValue);
                    }
                }
 
                var monitorZD = allMonitorList.Find(x => x.SignalList.Exists(t => t.SignalType.Code == Yw.Monitor.SignalType.浊度));
                if (monitorZD != null)
                {
                    var signalZD = monitorZD.SignalList.Find(x => x.SignalType.Code == Yw.Monitor.SignalType.浊度);
                    vm.ZD = new BigScreenSingleStationKpiItemDto()
                    {
                        Name = "浊度",
                        Value = null,
                        UnitName = signalZD.GetDisplayUnitName()
                    };
                    var recordZD = service_monitor_record.Value.GetLastRecord(signalZD.ID);
                    if (recordZD != null)
                    {
                        vm.ZD.Value = signalZD.GetDisplayValue(recordZD.DataValue);
                    }
                }
 
                var monitorYL = allMonitorList.Find(x => x.SignalList.Exists(t => t.SignalType.Code == Yw.Monitor.SignalType.余氯));
                if (monitorYL != null)
                {
                    var signalYL = monitorYL.SignalList.Find(x => x.SignalType.Code == Yw.Monitor.SignalType.余氯);
                    vm.YL = new BigScreenSingleStationKpiItemDto()
                    {
                        Name = "余氯",
                        Value = null,
                        UnitName = signalYL.GetDisplayUnitName()
                    };
                    var recordYL = service_monitor_record.Value.GetLastRecord(signalYL.ID);
                    if (recordYL != null)
                    {
                        vm.YL.Value = signalYL.GetDisplayValue(recordYL.DataValue);
                    }
                }
 
            }
 
            var allEquipmentList = service_equipment.Value.GetByBelongTypeAndBelongID(IStation.DataType.LogicSite, input.StationID);
            allEquipmentList = allEquipmentList?.Where(x => x.Flags.Contains(IStation.Flags.机组)).ToList();
            if (allEquipmentList != null && allEquipmentList.Count > 0)
            {
                vm.RunList = new List<BigScreenSingleStationKpiRunItemDto>();
                foreach (var equipment in allEquipmentList)
                {
                    var vm_run = new BigScreenSingleStationKpiRunItemDto()
                    {
                        Name = equipment.Name,
                        RunStatus = 0
                    };
                    var run_record = service_run_record.Value.GetLastRecord(Yw.Assets.DataType.Equipment, equipment.ID);
                    if (run_record != null)
                    {
                        vm_run.RunStatus = run_record.RSa;
                    }
                    vm.RunList.Add(vm_run);
                }
            }
 
            return vm;
        }
 
        /// <summary>
        /// 获取单泵站指标信息
        /// </summary>
        [Route("GetSingleStationQuotaInfo@V1.0")]
        [HttpGet]
        public BigScreenSingleStationQuotaKpiDto GetSingleStationQuotaInfo([FromQuery][Required] StationIDInput input)
        {
            var vm = new BigScreenSingleStationQuotaKpiDto();
            vm.Ws = new List<BigScreenSingleStationQuotaItemDto>();
            vm.Ps = new List<BigScreenSingleStationQuotaItemDto>();
 
            var dtEnd = DateTime.Now.Date;
            var dtStart = dtEnd.AddMonths(-1);
            List<Yw.Model.MonitorDayRecord> allWsRecordList = null;//所有供水量
            List<Yw.Model.MonitorDayRecord> allPsRecordList = null;//所有用电量
            Yw.Model.Signal_SignalType signalWs = null;//用水量信号
            Yw.Model.Signal_SignalType signalPs = null;//用电量信号
            var service_day_record = new Lazy<Yw.Service.MonitorDayRecord>(() => new Yw.Service.MonitorDayRecord());
            var allMonitorList = new Yw.Service.MonitorPoint().GetExSignalWithSignalTypeByBelongTypeAndBelongID(IStation.DataType.LogicSite, input.StationID, Yw.Monitor.eCronType.EachDay);
            if (allMonitorList != null && allMonitorList.Count > 0)
            {
                var monitorWs = allMonitorList.Find(x => x.SignalList.Exists(t => t.SignalType.Code == Yw.Monitor.SignalType.累积流量));
                if (monitorWs != null)
                {
                    signalWs = monitorWs.SignalList.Find(x => x.SignalType.Code == Yw.Monitor.SignalType.累积流量);
                    allWsRecordList = service_day_record.Value.GetBySignalIDOfDayRange(signalWs.ID, dtStart, dtEnd);
                }
                var monitorPs = allMonitorList.Find(x => x.SignalList.Exists(t => t.SignalType.Code == Yw.Monitor.SignalType.有功电度));
                if (monitorPs != null)
                {
                    signalPs = monitorPs.SignalList.Find(x => x.SignalType.Code == Yw.Monitor.SignalType.有功电度);
                    allPsRecordList = service_day_record.Value.GetBySignalIDOfDayRange(signalPs.ID, dtStart, dtEnd);
                }
            }
 
            for (DateTime dt = dtStart; dt <= dtEnd; dt = dt.AddDays(1))
            {
                var ws = allWsRecordList?.Find(x => x.DataDay.Date == dt.Date);
                vm.Ws.Add(new BigScreenSingleStationQuotaItemDto()
                {
                    Day = dt,
                    Value = ws == null ? "0" : signalWs.GetDisplayValue(ws.DataValue),
                    UnitName = signalWs?.GetDisplayUnitNames()
                });
                var ps = allPsRecordList.Find(x => x.DataDay.Date == dt.Date);
                vm.Ps.Add(new BigScreenSingleStationQuotaItemDto()
                {
                    Day = dt,
                    Value = ps == null ? "0" : signalPs.GetDisplayValue(ps.DataValue),
                    UnitName = signalPs?.GetDisplayUnitNames()
                });
            }
            return vm;
        }
 
        /// <summary>
        /// 获取单泵站机组项列表
        /// </summary>
        [Route("GetSingleStationEnginePumpItemList@V1.0")]
        [HttpGet]
        public List<BigScreenSingleStationEnginePumpListItemDto> GetSingleStationEnginePumpItemList([FromQuery][Required] StationIDInput input)
        {
            var service_equipment = new Yw.Service.Equipment();
            var allEnginePumpList = service_equipment.GetByBelongTypeAndBelongID(IStation.DataType.LogicSite, input.StationID);
            allEnginePumpList = allEnginePumpList?.Where(x => x.Flags.Contains(IStation.Flags.机组)).ToList();
            if (allEnginePumpList == null || allEnginePumpList.Count < 1)
            {
                return default;
            }
 
            var service_monitor_mapping = new Lazy<Yw.Service.EquipmentMonitorMapping>(() => new Yw.Service.EquipmentMonitorMapping());
            var service_monitor = new Lazy<Yw.Service.MonitorPoint>(() => new Yw.Service.MonitorPoint());
            var service_monitor_record = new Lazy<Yw.Service.MonitorRealRecord>(() => new Yw.Service.MonitorRealRecord());
 
            var vmList = new List<BigScreenSingleStationEnginePumpListItemDto>();
            foreach (var enginePump in allEnginePumpList)
            {
                var vm = new BigScreenSingleStationEnginePumpListItemDto();
                vm.ID = enginePump.ID;
                vm.Name = enginePump.Name;
                vmList.Add(vm);
 
                var allChildEquipmentList = service_equipment.GetChildAndSelfByID(enginePump.ID);
                if (allChildEquipmentList != null && allChildEquipmentList.Count > 0)
                {
                    var allChildEquipmentIds = allChildEquipmentList.Select(x => x.ID).Distinct().ToList();
                    var allMappingList = service_monitor_mapping.Value.GetByEquipmentIds(allChildEquipmentIds);
                    if (allMappingList != null && allMappingList.Count > 0)
                    {
                        var allMonitorIds = allMappingList.Select(x => x.MonitorPointID).Distinct().ToList();
                        var allMonitorList = service_monitor.Value.GetExSignalWithSignalTypeByIds(allMonitorIds);
                        if (allMonitorList != null && allMonitorList.Count > 0)
                        {
                            var monitorRs = allMonitorList.Find(x => x.SignalList.Exists(t => t.SignalType.Code == Yw.Monitor.SignalType.运行状态));
                            if (monitorRs != null)
                            {
                                var signalRs = monitorRs.SignalList.Find(x => x.SignalType.Code == Yw.Monitor.SignalType.运行状态);
                                vm.Rs = new BigScreenSingleStationEnginePumpListKpiItemDto()
                                {
                                    Name = "状态",
                                    Value = null,
                                    UnitName = null
                                };
                                var recordRs = service_monitor_record.Value.GetLastRecord(signalRs.ID);
                                if (recordRs != null)
                                {
                                    vm.Rs.Value = recordRs.DataValue;
                                }
                            }
 
                            var monitorHz = allMonitorList.Find(x => x.SignalList.Exists(t => t.SignalType.Code == Yw.Monitor.SignalType.频率));
                            if (monitorHz != null)
                            {
                                var signalHz = monitorHz.SignalList.Find(x => x.SignalType.Code == Yw.Monitor.SignalType.频率);
                                vm.Hz = new BigScreenSingleStationEnginePumpListKpiItemDto()
                                {
                                    Name = "频率",
                                    Value = null,
                                    UnitName = signalHz.GetDisplayUnitName()
                                };
                                var recordHz = service_monitor_record.Value.GetLastRecord(signalHz.ID);
                                if (recordHz != null)
                                {
                                    vm.Hz.Value = signalHz.GetDisplayValue(recordHz.DataValue);
                                }
                            }
 
                            var monitorP = allMonitorList.Find(x => x.SignalList.Exists(t => t.SignalType.Code == Yw.Monitor.SignalType.有功功率));
                            if (monitorP != null)
                            {
                                var signalP = monitorP.SignalList.Find(x => x.SignalType.Code == Yw.Monitor.SignalType.有功功率);
                                vm.P = new BigScreenSingleStationEnginePumpListKpiItemDto()
                                {
                                    Name = "功率",
                                    Value = null,
                                    UnitName = signalP.GetDisplayUnitName()
                                };
                                var recordP = service_monitor_record.Value.GetLastRecord(signalP.ID);
                                if (recordP != null)
                                {
                                    vm.P.Value = signalP.GetDisplayValue(recordP.DataValue);
                                }
                            }
 
                        }
                    }
                }
            }
 
            return vmList;
        }
 
        /// <summary>
        /// 获取单泵站工单Kpi信息(待完善)
        /// </summary>
        [Route("GetSingleStationRepairKpiInfo@V1.0")]
        [HttpGet]
        public BigScreenSingleStationRepairKpiDto GetSingleStationRepairKpiInfo([FromQuery][Required] StationIDInput input)
        {
            var vm = new BigScreenSingleStationRepairKpiDto();
            vm.Cd = 10;
            vm.Cm = 235;
            vm.Cy = 1230;
            vm.Pending = 5;
            vm.Accepted = 5;
            vm.Progress = 35;
            vm.Checked = 680;
            return vm;
        }
 
        /// <summary>
        /// 获取单泵站工单统计信息
        /// </summary>
        [Route("GetSingleStationRepairStatisticsInfo@V1.0")]
        [HttpGet]
        public BigScreenSingleStationRepairStatisticsInfoDto GetSingleStationRepairStatisticsInfo([FromQuery][Required] StationIDInput input)
        {
            var vm = new BigScreenSingleStationRepairStatisticsInfoDto();
            vm.LastMonth = new List<BigScreenSingleStationRepairDayCountDto>();
 
            var dtEnd = DateTime.Now.Date;
            var dtStart = dtEnd.AddMonths(-1);
            for (DateTime dt = dtStart; dt <= dtEnd; dt = dt.AddDays(1))
            {
                var vm_day = new BigScreenSingleStationRepairDayCountDto();
                vm_day.Day = dt;
                vm_day.Count = Yw.Untity.RandomHelper.Random(10, 100);
                vm.LastMonth.Add(vm_day);
            }
 
            vm.LastYear = new List<BigScreenSingleStationRepairMonthCountDto>();
            var dtNow = DateTime.Now;
            dtEnd = new DateTime(dtNow.Year, dtNow.Month, 1);
            dtStart = dtEnd.AddMonths(-11);
            for (DateTime dt = dtStart; dt <= dtEnd; dt = dt.AddMonths(1))
            {
                var vm_month = new BigScreenSingleStationRepairMonthCountDto();
                vm_month.Year = dt.Year;
                vm_month.Month = dt.Month;
                vm_month.Count = Yw.Untity.RandomHelper.Random(100, 1000);
                vm.LastYear.Add(vm_month);
            }
            return vm;
        }
 
        /// <summary>
        /// 获取单泵站机组工单统计信息
        /// </summary>
        [Route("GetSingleStationRepairEnginePumpStatisticsInfo@V1.0")]
        [HttpGet]
        public BigScreenSingleStationRepairEnginePumpStatisticsInfoDto GetSingleStationRepairEnginePumpStatisticsInfo([FromQuery][Required] StationIDInput input)
        {
            var vm = new BigScreenSingleStationRepairEnginePumpStatisticsInfoDto();
            vm.Cd = new List<BigScreenSingleStationRepairEnginePumpCountDto>()
            {
                new BigScreenSingleStationRepairEnginePumpCountDto(){ Name="1#机组",Count=1},
                new BigScreenSingleStationRepairEnginePumpCountDto(){ Name="2#机组",Count=3},
                new BigScreenSingleStationRepairEnginePumpCountDto(){ Name="3#机组",Count=0},
                new BigScreenSingleStationRepairEnginePumpCountDto(){ Name="4#机组",Count=1}
            };
            vm.Cm = new List<BigScreenSingleStationRepairEnginePumpCountDto>()
            {
                new BigScreenSingleStationRepairEnginePumpCountDto(){ Name="1#机组",Count=10},
                new BigScreenSingleStationRepairEnginePumpCountDto(){ Name="2#机组",Count=32},
                new BigScreenSingleStationRepairEnginePumpCountDto(){ Name="3#机组",Count=4},
                new BigScreenSingleStationRepairEnginePumpCountDto(){ Name="4#机组",Count=18}
            };
            vm.Cm = new List<BigScreenSingleStationRepairEnginePumpCountDto>()
            {
                new BigScreenSingleStationRepairEnginePumpCountDto(){ Name="1#机组",Count=123},
                new BigScreenSingleStationRepairEnginePumpCountDto(){ Name="2#机组",Count=45},
                new BigScreenSingleStationRepairEnginePumpCountDto(){ Name="3#机组",Count=8},
                new BigScreenSingleStationRepairEnginePumpCountDto(){ Name="4#机组",Count=23}
            };
            return vm;
        }
 
        /// <summary>
        /// 获取单泵站报警信息
        /// </summary>
        [Route("GetSingleStationAlarmInfo@V1.0")]
        [HttpGet]
        public List<BigScreenSingleStationAlarmItemDto> GetSingleStationAlarmInfo([FromQuery][Required] StationIDInput input)
        {
            var vmList = new List<BigScreenSingleStationAlarmItemDto>();
            var allEquipmentList = new Yw.Service.Equipment().GetByBelongTypeAndBelongID(IStation.DataType.LogicSite, input.StationID);
            if (allEquipmentList == null || allEquipmentList.Count < 1)
            {
                return vmList;
            }
            var allEnginePumpList = allEquipmentList.Where(x => x.Flags.Contains(IStation.Flags.机组)).ToList();
            if (allEnginePumpList.Count < 1)
            {
                return vmList;
            }
            var service_monitor_maping = new Yw.Service.EquipmentMonitorMapping();
            var service_monitor = new Lazy<Yw.Service.MonitorPoint>(() => new Yw.Service.MonitorPoint());
            var servie_alarm_record = new Lazy<Yw.Service.MonitorValueAlarmRecord>(() => new Yw.Service.MonitorValueAlarmRecord());
            foreach (var enginePump in allEnginePumpList)
            {
                var allMonitorMappingList = service_monitor_maping.GetByEquipmentIDContainsChildren(enginePump.ID);
                if (allMonitorMappingList != null && allMonitorMappingList.Count > 0)
                {
                    var allMonitorIds = allMonitorMappingList.Select(x => x.MonitorPointID).Distinct().ToList();
                    var allMonitorList = service_monitor.Value.GetExSignalWithSignalTypeByIds(allMonitorIds);
                    var allSignalList = allMonitorList.SelectMany(x => x.SignalList).ToList();
                    var allSignalIds = allSignalList.Select(x => x.ID).Distinct().ToList();
                    var allAlarmList = servie_alarm_record.Value.GetLastListBySignalIds(allSignalIds, 3);
                    if (allAlarmList != null && allAlarmList.Count > 0)
                    {
                        foreach (var alarm in allAlarmList)
                        {
                            var vm = new BigScreenSingleStationAlarmItemDto()
                            {
                                ID = alarm.ID,
                                Name = enginePump.Name,
                                Content = alarm.AlarmName
                            };
                            vmList.Add(vm);
                        }
                    }
                }
            }
 
            return vmList;
        }
 
        #endregion
 
    }
}