tangxu
2022-11-02 05f522e321a742f03bf1e3e26edaeb5147da42f4
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
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using IStation.Model.Api;
using IStation.ViewModel;
using AutoMapper;
using System.Text;
 
namespace IStation.WebApi.Controllers
{
    /// <summary>
    /// 大屏单站点(Bimface 本地加载(松花江用))
    /// </summary>
    [RoutePrefix("Demo/StationBimShj")]
    public class Demo_StationBimShjController : ApiController
    {
 
        private class RecordBase1
        {
            public string RecordTime { get; set; }
            public double RecordValue { get; set; }
        }
 
        private class RecordBase1ExSignalID : RecordBase1
        {
            public long SignalID { get; set; }
        }
 
        /// <summary>
        /// 获取泵站主页信息
        /// </summary>
        /// <param name="StationID">泵站ID</param>
        /// <returns></returns>
        [Route("GetInitalInfo")]
        [HttpGet]
        public Result  GetInitalInfo (long StationID)
        {
            StationID = 14;
            string CacheKey = "LargeScreen.Demo.StationBimShj" + StationID;//缓存,就不能加载用户自定义的图层等信息,以后需要用异步加载
            object objModel = System.Runtime.Caching.MemoryCache.Default.Get(CacheKey);
            if (objModel != null)
            {
                Dictionary<string, object> dict2 = (Dictionary<string, object>)objModel;
                return new Result_Object(dict2);
            }
 
 
            var stationBase = IStation.Service.StationBase.GetByStationID(StationID);
            if (stationBase == null)
            {
                return new Result(IStation.Model.Api.Code.Error, "未找到对应泵站");
            }
 
            Dictionary<string, object> dict = new Dictionary<string, object>();
 
 
            //搜索BIM
            //IStation.Service.BimFileMapperView bllBim = new IStation.Service.BimFileMapperView();
            //var bimFileList = IStation.Service.BimFileMapperView.GetDetailByStationID(StationID);
            //IStation.Model.BimFileMapperViewDetail defaultBimFile = null;
            //if (bimFileList != null && bimFileList.Count > 0)
            //{
            //    defaultBimFile = bimFileList.FirstOrDefault();
            //}
            //else
            {
                return new Result(IStation.Model.Api.Code.Alert, "未定义BIM模型") ;
            }
            //BIM映射ID
            dict["BimFileMapperID"] = defaultBimFile.ID;
 
            //摄像头
            dict["Cameras"] = IStation.Service.CameraBase.GetAll();
 
 
            //BIM
            dict["BimfaceFileID"] = defaultBimFile.BimfaceID;
            //与GetInitalInfo4Remote区别就是这里没有获取
            //var token = IStation.BIM.BimFaceHelper.GetFileToken(defaultBimFile.BimfaceID.ToString());
            //if (token != null)
            //{
            //    dict["BimfaceViewToken"] = token.Token;
            //}
            List<IStation.Model.BimComponentMapper> listComponentMapping = null;//产品映射
 
            #region BIM设置
            //
            IStation.Model.BimFileMapperSettings mapSettings = defaultBimFile.Settings;
            IStation.Model.BimFileSettings fileSettings = defaultBimFile.FileSettings;
            if (mapSettings != null)
                listComponentMapping = mapSettings.ComponentMappers;
 
 
            //var bimEmployeeSet = IStation.Service.BimEmployeeSet.GetByEmployeeAndMapperID(EmployeeID, defaultBimFile.ID);
            //IStation.Model.BimEmployeeSettings employeeSettings = bimEmployeeSet == null ? null : bimEmployeeSet.Settings;
 
 
            List<IStation.ViewModel.CommonBimLayer> bimLayers = new List<IStation.ViewModel.CommonBimLayer>();
            //List<IStation.ViewModel.BimCamera> bimCameras = new List<ViewModel.BimCamera>();
            List<IStation.ViewModel.BimWalkThrough> bimBimWalkThrough = new List<IStation.ViewModel.BimWalkThrough>();
 
            if (fileSettings != null)
            {
                #region 图层
                var allCustomComponentsLayers = fileSettings.CustomComponentsLayers;
                if (allCustomComponentsLayers != null && allCustomComponentsLayers.Count > 0)
                {
                    foreach (var layer in allCustomComponentsLayers)
                    {
                        IStation.ViewModel.CommonBimLayer bimLayer = new IStation.ViewModel.CommonBimLayer();
                        if (layer.ComponentIds == null || layer.ComponentIds.Count() == 0)
                            continue;
 
                        bimLayer.Name = layer.Name;
                        bimLayer.ID = layer.ID;
                        bimLayer.ComponentIds = layer.ComponentIds;
                        bimLayer.Type = 0;//表示 系统添加 
                        bimLayer.IsDisp = true;
                        bimLayers.Add(bimLayer);
                    }
                }
                #endregion
 
                #region 视图
                //var viewBimCameras = fileSettings.CustomCameraStatus_3Ds;
                //if (viewBimCameras != null && viewBimCameras.Count > 0)
                //{
                //    foreach (var m in viewBimCameras)
                //        bimCameras.Add(new ViewModel.BimCamera(m));
                //}
                #endregion
 
                #region  路径漫游
                var customWalkThroughs = fileSettings.CustomWalkThroughs;
                if (customWalkThroughs != null && customWalkThroughs.Count > 0)
                {
                    foreach (var m in customWalkThroughs)
                        bimBimWalkThrough.Add(new IStation.ViewModel.BimWalkThrough(m));
                }
                #endregion
            }
            #region  暂时不要自定义的视图
            //if (employeeSettings != null)
            //{
            //    //
            //    //var allEmployeeComponentsLayers = employeeSettings.CustomComponentsLayers;
            //    //if (allEmployeeComponentsLayers != null)
            //    //{
            //    //    foreach (var layer in allEmployeeComponentsLayers)
            //    //    {
            //    //        IStation.ViewModel.BimLayer bimLayer = new ViewModel.BimLayer();
            //    //        if (layer.ComponentIds == null || layer.ComponentIds.Count() == 0)
            //    //            continue;
 
            //    //        bimLayer.Name = layer.Name;
            //    //        bimLayer.ID = layer.ID;
            //    //        bimLayer.ComponentIds = layer.ComponentIds;
            //    //        bimLayer.Type = 1;//表示 员工添加 
            //    //        bimLayers.Add(bimLayer);
            //    //    }
            //    //}
            //}
            #endregion
 
            //
            dict["LayerSettingGeneral"] = bimLayers;
 
            if (fileSettings != null)
                dict["FileSettingCamera"] = fileSettings.CustomCameraStatus_3Ds;
            dict["FileSettingWalkThrough"] = bimBimWalkThrough;
 
            //建筑物外墙
            var layer_components_建筑物 = new List<string>() {"1345184", "1345372", "1345386", "1345400", "1345416", "1345430", "1345444", "1345458", "1345472", "1345490",
                "1345549", "1345547", "1345545", "1345543", "1345541", "1345539", "1345537", "1345535", "1515102", "1516086", "1391996",
                "1391995", "1391994", "1391993", "1391992", "1391991", "1391989", "1391649", "1391896", "1391903", "1391910", "1391917", "1391924", "1391931" };
            IStation.ViewModel.SpecBimLayer bimLayer建筑物外墙 = new IStation.ViewModel.SpecBimLayer();
            bimLayer建筑物外墙.IsDisp = true;
            bimLayer建筑物外墙.ComponentIds = layer_components_建筑物;
 
            dict["LayerSetting4Build"] = bimLayer建筑物外墙;
 
 
            //if (fileSettings != null && fileSettings.CustomComponentsDivs string.IsNullOrEmpty(defaultBimFile.ViewSettingData))
            //{
            //    IStation.Entity.BimFileMapping.ViewSettings bimViewSettings = null;
            //    bimViewSettings = IStation.Entity.BimFileMapping.ViewSettings.ToObject(defaultBimFile.ViewSettingData);
            //    dict["BimViewSettings"] = bimViewSettings;
            //}
            #endregion
 
 
 
            #region 监控面板
            //
            var allProducts = IStation.Service.ProductBase.GetByStationID(StationID);
            if (allProducts != null && mapSettings != null)
            {
                List<IStation.ViewModel.BimTipPanel> allMinitorPanel = new List<IStation.ViewModel.BimTipPanel>();
 
                List<IStation.Model.BimMonitorPanelLayer> listMonitorPanelLayer = mapSettings.MonitorPanelLayers;
                if (listMonitorPanelLayer != null)
                {
                    //List<long> signalIDs = new List<long>();
                    foreach (var signalLoc in listMonitorPanelLayer)
                    {
                        foreach (var monitorPanel in signalLoc.MonitorPanels)
                        {
                            if (monitorPanel.LocationType == IStation.Model.BimMonitorPanel.eLocationType.机泵)
                            {
                                #region 机泵
                                IStation.ViewModel.BimTipPanel panel_minitor_view = new IStation.ViewModel.BimTipPanel();
                                panel_minitor_view.ProductID = monitorPanel.LocationObjectID;
                                panel_minitor_view.Name = monitorPanel.Name;
                                //(from x in allProducts where x.ID == monitorPanel.LocationObjectID select x.Name).FirstOrDefault();
                                panel_minitor_view.Posi = new IStation.ViewModel.BimPosi() { x = monitorPanel.WorldPostion.x, y = monitorPanel.WorldPostion.y, z = monitorPanel.WorldPostion.z };
                                panel_minitor_view.IsDispSignal = monitorPanel.ValuesVisible;
 
                                if (monitorPanel.ValuesVisible)
                                {
                                    panel_minitor_view.RunStatus = 1;
                                    panel_minitor_view.SignalList = new List<IStation.ViewModel.RecordBase>();
                                    foreach (var measure_point_id in monitorPanel.MeasurePointIds)
                                    {
                                        var signal = IStation.Service.SignalInfoHelper.GetDefaultByPointID(measure_point_id);
                                        if (signal == null)
                                            continue;
 
                                        panel_minitor_view.SignalList.Add(new IStation.ViewModel.RecordBase(signal));
                                    }
                                }
 
 
                                allMinitorPanel.Add(panel_minitor_view);
                                #endregion
                            }
                            else if (monitorPanel.LocationType == IStation.Model.BimMonitorPanel.eLocationType.总管)
                            {
                                #region 总管
                                IStation.ViewModel.BimTipPanel panel_minitor_view = new IStation.ViewModel.BimTipPanel();
                                panel_minitor_view.ProductID = monitorPanel.LocationObjectID;
                                panel_minitor_view.Name = monitorPanel.Name;
                                //(from x in allProducts where x.ID == monitorPanel.LocationObjectID select x.Name).FirstOrDefault();
                                panel_minitor_view.Posi = new IStation.ViewModel.BimPosi() { x = monitorPanel.WorldPostion.x, y = monitorPanel.WorldPostion.y, z = monitorPanel.WorldPostion.z };
                                panel_minitor_view.IsDispSignal = monitorPanel.ValuesVisible;
 
                                if (monitorPanel.ValuesVisible)
                                {
                                    panel_minitor_view.RunStatus = 1;
                                    panel_minitor_view.SignalList = new List<IStation.ViewModel.RecordBase>();
                                    foreach (var measure_point_id in monitorPanel.MeasurePointIds)
                                    {
                                        var signal = IStation.Service.SignalInfoHelper.GetDefaultByPointID(measure_point_id);
                                        if (signal == null)
                                            continue;
 
                                        panel_minitor_view.SignalList.Add(new IStation.ViewModel.RecordBase(signal));
                                    }
                                }
 
 
                                allMinitorPanel.Add(panel_minitor_view);
                                #endregion
                            }
                        }
 
                    }
 
                    //为了页面加载数据,初始化时不读取数据
                    //var records = IStation.SignalRecordHelper.GetLastRecordBySignalID(signalIDs, 120);
                    //if(records != null)
                    //{
                    //    foreach(var panel in allMinitorPanel)
                    //    {
                    //        foreach(var s in panel.SignalList)
                    //        {
                    //            var r = (from x in records where x.SignalID == s.ID orderby x.RecordTime select x).LastOrDefault();
                    //            if(r != null)
                    //            {
                    //                s.RecordValue = r.RecordValue.ToString();
                    //                s.ReocrdTime = r.RecordTime;
                    //                panel.RunStatus = 1;
                    //            }
                    //        }
                    //    }
                    //}
                }
 
                dict["MinitorPanel"] = allMinitorPanel;
            }
            #endregion
 
 
 
 
 
 
 
            #region 模型树
            int pump_number = 0;
            if (allProducts != null)
            {
                List<IStation.ViewModel.BimMenuTreeNodeGrp> productTreeList = new List<IStation.ViewModel.BimMenuTreeNodeGrp>();
 
                IStation.ViewModel.BimMenuTreeNodeGrp grp泵站 = new BimMenuTreeNodeGrp();
                grp泵站.NodeID = string.Format("S{0}", IStation.ObjectType.Station_泵站);
                grp泵站.Name = "泵站";
                grp泵站.ObjectType = IStation.ObjectType.Station_泵站;
                grp泵站.Nodes = new List<BimMenuTreeNode>();
 
                IStation.ViewModel.BimMenuTreeNode tree_node_station = new IStation.ViewModel.BimMenuTreeNode();
                tree_node_station.NodeID = string.Format("S{0}child", StationID);
                tree_node_station.Name = stationBase.Name;
                tree_node_station.ObjectID = StationID;
                tree_node_station.ObjectType = IStation.ObjectType.Station_泵站;
 
                var all_station_signals = IStation.Service.SignalInfoHelper.GetOnlyByStationID(StationID);
                if (all_station_signals != null && all_station_signals.Count > 0)
                {
                    List<IStation.ViewModel.RecordBase> vm_SignalList = new List<IStation.ViewModel.RecordBase>();
                    foreach (var s in all_station_signals)
                    {
                        IStation.ViewModel.RecordBase v = new IStation.ViewModel.RecordBase(s);
                        vm_SignalList.Add(v);
                    }
 
                    tree_node_station.SignalList = vm_SignalList;
                }
                grp泵站.Nodes.Add(tree_node_station);
                productTreeList.Add(grp泵站);
 
 
 
 
                //
                IStation.ViewModel.BimMenuTreeNodeGrp grp机组 = new BimMenuTreeNodeGrp();
                grp机组.NodeID = string.Format("M{0}", IStation.ObjectType.Machine_机泵);
                grp机组.Name = "机泵";
                grp机组.ObjectType = IStation.ObjectType.Machine_机泵;
                grp机组.Nodes = new List<BimMenuTreeNode>();
 
                var pumpRunInfos = new Service.PumpRunInfoLog().GetByPumpSystemID((from x in allProducts select x.ID));
                if (pumpRunInfos == null)
                    pumpRunInfos = new List<Model.PumpRunInfoLog>();
                foreach (var product in allProducts)
                {
                    //if (product.SubType == IStation.ObjectType.Equipment_泵)
                    //{
                    //    continue;
                    //}
                    //else if (product.SubType == IStation.ObjectType.Equipment_电机)
                    //{
                    //    continue;
                    //}
                    //else if (product.SubType == IStation.ObjectType.Machine_机泵组)
                    //{
                    //    continue;
                    //}
                    if (product.SubType != IStation.ObjectType.Machine_机泵)
                    {//暂时只有机泵
                        continue;
                    }
                    pump_number++;
                    IStation.ViewModel.BimMenuTreeNode tree_node_product = new IStation.ViewModel.BimMenuTreeNode();
                    tree_node_product.NodeID = string.Format("P{0}", product.ID);
                    tree_node_product.Name = product.Name;
                    tree_node_product.ObjectID = product.ID;
                    tree_node_product.ObjectType = product.SubType;
 
                    if (listComponentMapping != null)
                    {
                        tree_node_product.BimID = (from x in listComponentMapping where x.BelongType == IStation.ObjectType.Product_资产 && x.BelongID == product.ID select x.ComponentID).FirstOrDefault();
                    }
 
                    var pumpRunInfo = (from x in pumpRunInfos where x.ObjectID == product.ID select x).FirstOrDefault();
                    if (pumpRunInfo != null)
                    {
                        tree_node_product.RunStatus = (int)pumpRunInfo.RunStatus;
                    }
 
 
                    List<long> productids = new List<long>();
                    productids.Add(product.ID);
                    var childProducts = IStation.Service.ProductBase.GetAllChildByProductID(product.ID);
                    if (childProducts != null && childProducts.Count() > 0)
                    {
                        productids.AddRange(from x in childProducts select x.ID);
                    }
 
                    var all_product_signals = IStation.Service.SignalInfoHelper.GetOnlyByProductID(productids);
                    if (all_product_signals != null && all_product_signals.Count > 0)
                    {
                        List<IStation.ViewModel.RecordBase> vm_SignalList = new List<IStation.ViewModel.RecordBase>();
                        foreach (var s in all_product_signals)
                        {
                            IStation.ViewModel.RecordBase v = new IStation.ViewModel.RecordBase(s);
                            vm_SignalList.Add(v);
                        }
 
                        tree_node_product.SignalList = vm_SignalList;
                    }
 
 
 
                    grp机组.Nodes.Add(tree_node_product);
                }
 
                productTreeList.Add(grp机组);
                dict["ProductTree"] = productTreeList;
            }
            #endregion
 
 
            //基本信息
            double longitude = 0, latitude = 0;
            var pointInfo = Model.Map.PointInfo.ToModel(stationBase.MapPosition);
            if (pointInfo != null)
            {
                longitude = pointInfo.Longitude;
                latitude = pointInfo.Latitude;
            }
 
            dict["BaseInfo"] = new { ID = StationID, Name = stationBase.Name, Address = stationBase.Address, Longitude = longitude, Latitude = latitude, PumpNumber = pump_number };
 
 
 
            System.Runtime.Caching.MemoryCache.Default.Set(CacheKey, dict, DateTimeOffset.Now.AddMinutes(2.3));
 
            return new Result_Model<Dictionary<string, object>>(dict) ;
        }
        /// <summary>
        /// 获取产品属性信息
        /// </summary>
        /// <param name="ProductID">产品ID</param>
        /// <param name="IsIncludeBaseInfo">是否包含基础信息</param>
        /// <returns></returns>
        [Route("GetProductPropList")]
        [HttpGet]
        public Result GetProductPropList(long ProductID, bool IsIncludeBaseInfo)
        {
            var equipment = IStation.Service.ProductBase.GetByProductID(ProductID);
            if (equipment == null)
            {
                return new Result(IStation.Model.Api.Code.Error, "未检索到设备");
            }
 
            string manufacturerName = "";
            if (equipment.ManufacturerID > 0)
            {
                manufacturerName = IStation.Service.Manufacture.GetManufactureNameByID(equipment.ManufacturerID);
            }
            Dictionary<string, object> dict = new Dictionary<string, object>();
 
            var ThumbRealImage = "";
            if (!string.IsNullOrEmpty(equipment.RealImage))
            {
                string[] temp = equipment.RealImage.Split('.');
                string ext = "." + temp[temp.Length - 1].ToLower();
                ThumbRealImage = equipment.RealImage.Replace(ext, "_th" + ext);
            }
 
 
            List<IStation.ViewModel.ProductProp> listProp = new List<IStation.ViewModel.ProductProp>();
            if (IsIncludeBaseInfo)
            {
                listProp.Add(new IStation.ViewModel.ProductProp() { ID = 0, GroupName = "基本信息", PropName = "ID", PropValue = equipment.ID.ToString() });
                listProp.Add(new IStation.ViewModel.ProductProp() { ID = 0, GroupName = "基本信息", PropName = "名称", PropValue = equipment.Name });
                listProp.Add(new IStation.ViewModel.ProductProp() { ID = 0, GroupName = "基本信息", PropName = "编号", PropValue = equipment.NO });
                listProp.Add(new IStation.ViewModel.ProductProp() { ID = 0, GroupName = "基本信息", PropName = "型号", PropValue = equipment.Code });
                listProp.Add(new IStation.ViewModel.ProductProp() { ID = 0, GroupName = "基本信息", PropName = "规格", PropValue = equipment.Specification });
                listProp.Add(new IStation.ViewModel.ProductProp() { ID = 0, GroupName = "基本信息", PropName = "材质", PropValue = equipment.Material });
                listProp.Add(new IStation.ViewModel.ProductProp() { ID = 0, GroupName = "基本信息", PropName = "厂商名称", PropValue = manufacturerName });
                listProp.Add(new IStation.ViewModel.ProductProp() { ID = 0, GroupName = "基本信息", PropName = "出厂编号", PropValue = equipment.ManufacturerNO });
                listProp.Add(new IStation.ViewModel.ProductProp() { ID = 0, GroupName = "基本信息", PropName = "出厂日期", PropValue = equipment.ManufacturerDay });
                listProp.Add(new IStation.ViewModel.ProductProp() { ID = 0, GroupName = "基本信息", PropName = "合同编号", PropValue = equipment.ContractNO });
                listProp.Add(new IStation.ViewModel.ProductProp() { ID = -1, GroupName = "基本信息", PropName = "ThumbRealImage", PropValue = ThumbRealImage });
                listProp.Add(new IStation.ViewModel.ProductProp() { ID = -1, GroupName = "基本信息", PropName = "RealImage", PropValue = equipment.RealImage });
            }
 
 
            //机泵下的电机和泵额定参数
            IStation.Model.RatedParas.Pump ratedParas泵 = null;
            IStation.Model.RatedParas.Motor ratedParas电机 = null;
            if (equipment.SubType == IStation.ObjectType.Machine_机泵)
            {
                var childs = IStation.Service.ProductBase.GetAllChildByProductID(equipment.ID);
                if (childs != null && childs.Count > 1)
                {
                    var pump = childs.Find(x => x.SubType == IStation.ObjectType.Equipment_泵);
                    if (pump != null && !string.IsNullOrEmpty(pump.RatedParas))
                        ratedParas泵 = Model.RatedParas.Pump.ToModel(pump.RatedParas);
                    var motor = childs.Find(x => x.SubType == IStation.ObjectType.Equipment_电机);
                    if (motor != null && !string.IsNullOrEmpty(motor.RatedParas))
                        ratedParas电机 = Model.RatedParas.Motor.ToModel(motor.RatedParas);
                }
            }
            if (equipment.SubType == IStation.ObjectType.Equipment_泵 && !string.IsNullOrEmpty(equipment.RatedParas))
            {
                ratedParas泵 = Model.RatedParas.Pump.ToModel(equipment.RatedParas);
            }
            if (equipment.SubType == IStation.ObjectType.Equipment_电机 && !string.IsNullOrEmpty(equipment.RatedParas))
            {
                ratedParas电机 = Model.RatedParas.Motor.ToModel(equipment.RatedParas);
            }
            if (ratedParas泵 != null)
            {
                if (ratedParas泵.Q > 0)
                    listProp.Add(new IStation.ViewModel.ProductProp() { ID = 0, GroupName = "额定参数", PropName = "额定流量", PropValue = ratedParas泵.Q.ToString() });
                if (ratedParas泵.H > 0)
                    listProp.Add(new IStation.ViewModel.ProductProp() { ID = 0, GroupName = "额定参数", PropName = "额定扬程", PropValue = ratedParas泵.H.ToString() });
                if (ratedParas泵.NPSHr > 0)
                    listProp.Add(new IStation.ViewModel.ProductProp() { ID = 0, GroupName = "额定参数", PropName = "额定汽蚀", PropValue = ratedParas泵.NPSHr.ToString() });
            }
            if (ratedParas电机 != null)
            {
                if (ratedParas电机.P > 0)
                    listProp.Add(new IStation.ViewModel.ProductProp() { ID = 0, GroupName = "额定参数", PropName = "电机功率", PropValue = ratedParas电机.P.ToString() });
                if (ratedParas电机.N > 0)
                    listProp.Add(new IStation.ViewModel.ProductProp() { ID = 0, GroupName = "额定参数", PropName = "电机转速", PropValue = ratedParas电机.N.ToString() });
                if (ratedParas电机.I > 0)
                    listProp.Add(new IStation.ViewModel.ProductProp() { ID = 0, GroupName = "额定参数", PropName = "额定电流", PropValue = ratedParas电机.I.ToString() });
            }
 
            //附加属性
            var otherProViews = IStation.Service.ProductTypePropView.GetByProductTypeID(equipment.ProductTypeID);
            if (otherProViews != null && otherProViews.Count > 0)
            {
                var dic = new Eventech.Model.LongAndStringDict1(equipment.PropsParas);
                foreach (var prop in otherProViews)
                {
                    listProp.Add(new IStation.ViewModel.ProductProp
                    {
                        ID = prop.ID,
                        PropName = prop.PropName,
                        GroupName = prop.GroupName,
                        PropValue = dic.ContainsKey(prop.ID) ? dic[prop.ID] : prop.DefaultValue
                    });
                }
            }
 
            return new Result_Model<List<IStation.ViewModel.ProductProp>>(listProp);
        }
 
        /// <summary>
        /// 获取产品属性信息
        /// </summary>
        /// <param name="ProductID">产品ID</param>
        /// <param name="InIncludeChild">是否包含基础信息</param>
        /// <returns></returns>
        [Route("GetSignalListByProductID")]
        [HttpGet]
        public Result GetSignalListByProductID(long ProductID,bool InIncludeChild)
        {
            List<long> productids = new List<long>();
            productids.Add(ProductID);
 
            List<IStation.Model.MeasurePointSignalView > signals = null;
            if (InIncludeChild)
            {
                var childProducts = IStation.Service.ProductBase.GetAllChildByProductID(ProductID);
                if (childProducts != null && childProducts.Count() > 0)
                {
                    productids.AddRange(from x in childProducts select x.ID);
                }
 
                signals = IStation.Service.SignalInfoHelper.GetOnlyByProductID(productids);
            }
            else
            {
                signals = IStation.Service.SignalInfoHelper.GetOnlyByProductID(productids);
            }
            //
 
            if (signals == null || signals.Count() == 0)
            {
                return new Result(IStation.Model.Api.Code.Error, "未配置监控");
            }
 
            List<IStation.ViewModel.RecordBase> vm_SignalList = new List<IStation.ViewModel.RecordBase>();
 
            foreach (var s in signals)
            {
                IStation.ViewModel.RecordBase v = new IStation.ViewModel.RecordBase(s);
 
                vm_SignalList.Add(v);
            }
 
            return new Result_Model<List<IStation.ViewModel.RecordBase>>(vm_SignalList);
 
        }
 
        #region 多个SignalID的最近记录
        /// <summary>
        /// 多个SignalID的最近记录
        /// </summary>
        /// <param name="SignalID">信号ID</param>
        /// <param name="Second">最近多少秒</param>
        /// <returns></returns>
        [Route("GetMultiSignalLastRecord")]
        [HttpGet]
        public Result GetMultiSignalLastRecord( string SignalID, int Second)
        {
            string[] SignalIDs1 = SignalID.Split(',');
            if (SignalIDs1 == null || SignalIDs1.Count() == 0)
            {
                return new Result(IStation.Model.Api.Code.Error, "没有输入 SignalID 参数");
            }
            List<long> SignalIDs2 = new List<long>();
            foreach (var id in SignalIDs1)
            {
                if (!string.IsNullOrEmpty(id))
                    SignalIDs2.Add(Convert.ToInt64(id));
            }
            var signal_array = IStation.Service.SignalInfoHelper.GetBySignalID(SignalIDs2);
 
            if (Second < 1)
                Second = 600;
            //if (!string.IsNullOrEmpty(request["Second"]))
            //{
            //    Second = Convert.ToInt32(request["Second"]);
            //}
 
            var vm_list = new List<RecordBase1ExSignalID>();
            var records = new Service.Signal().GetLastGeneralRecord(signal_array.Select(x=>x.MeasurePointID));
 
            // IStation.LogHelper.Info("StoreObjectID:" + String.Join(",", (from x in signal_array select x.StoreObjectID)));
            if (records == null || records.Count() == 0)
            {
                return new Result_Model<List<RecordBase1ExSignalID>>(vm_list);
            }
 
            foreach (var r in records)
            {
                var signal = (from x in signal_array where x.MeasurePointID == r.ObjectId select x).FirstOrDefault();
                if (signal == null)
                    continue;
 
                RecordBase1ExSignalID vm = new RecordBase1ExSignalID();
                vm.SignalID = signal.SignalID;
                vm.RecordTime = r.DataTime.ToString("yyyy-MM-dd HH:mm:ss");  
                vm.RecordValue = GetDispValue(signal, r.DataValue);
                if (Second > 0)
                {
                    if ((DateTime.Now - r.DataTime).TotalSeconds < Second)
                    {
                        vm_list.Add(vm);
                    }
                }
                else
                {
                    vm_list.Add(vm);
                }
            }
 
            return new Result_Model<List<RecordBase1ExSignalID>>(vm_list);
        }
        private static double GetDispValue(IStation.Model.GeneralMonitorPointView signal, double minitorDataValue)
        {
            //// Math.Round(record.DataValue, signal.DecimalPlaces);
            return Math.Round(minitorDataValue, 4);
        }
        #endregion
 
    }
}