lgq
2025-07-19 45c4742c0cf31b0217874944127491990bf1a097
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
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
var layer;// 定义全局变量
var isShow = false;
var default_top = 20;//默认上偏移
var default_left = 0;//默认左偏移
 
var listDevice;
var deviceMap=[];
 
//定时轮询时间5s
var INTERVAL = 5 * 1000;
var intervalData;
 
//定制,
var thId1 = "-999";
var thId2 = "-999";
var thData1;
var thData2;
 
var imgData = {};
 
var testList = [
    {
        "id":"2211",
        "name":"温湿度#1",
        "category":"3004",
        "type":"0",
        "leftV":"0.4040",
        "topV":"0.2515",
        "value":[{
            "passcode":"2",
            "name":"温度",
            "value":"1"
        },{
            "passcode":"3",
            "name":"温度",
            "value":"18"
        },{
            "passcode":"4",
            "name":"湿度",
            "value":"60"
        }]
    },{
        "id":"2221",
        "name":"温湿度#1",
        "category":"2002",
        "type":"0",
        "leftV":"0.4840",
        "topV":"0.2015",
        "value":[{
            "passcode":"3",
            "name":"温度",
            "value":"18"
        },{
            "passcode":"4",
            "name":"湿度",
            "value":"60"
        }]
    },{
        "id":"3331",
        "name":"精密空调#1",
        "category":"2002",
        "type":"0",
        "leftV":"0.6840",
        "topV":"0.5015",
        "value":[{
            "passcode":"1",
            "name":"温度",
            "value":"1"
        },{
            "passcode":"2",
            "name":"温度",
            "value":"1"
        },{
            "passcode":"3",
            "name":"湿度",
            "value":"60"
        }]
    }];
 
$(function () {
    layui.use(['layer'], function () {
        layer = layui.layer;
    });
 
    window.onload = function () {
 
        if(TEST_TAG){
            listDevice = testList;
            renderTips(listDevice);
        }else{
            //初始页面
            initImg();
 
            //初始化数据
            loadDevice();
 
            //开始模块的自我循环数据
            reLoadModelDataRecord();
        }
    }
 
});
 
function closepopBtn(){
    layer.closeAll();
}
 
// 循环执行页面数据的刷新
function reLoadModelDataRecord(){
    // 首先停止执行原有的循环
    if (intervalData) clearInterval(intervalData);
 
    intervalData = setInterval(function () {
        //监控信息渲染
        loadDevice();
    }, INTERVAL);
}
 
//获取2.5D图
function initImg() {
    $.ajaxSettings.async = false;
    $.get("./cgi-bin/img-data/query", function (data, status) {
        if ("success" == status) {
            // console.log("-------获取2.5D图接收的数据------");
            // console.log(data);
            imgData = data.data;
            renderImg();
        } else {
            window.parent.notify("系统获取2.5D图信息失败!");
        }
    }, "json");
}
 
//点击右侧操作按钮
function showEdit() {
    if (isShow) {
        $('.btn-edit').addClass('hide');
    } else {
        $('.btn-edit').removeClass('hide');
    }
    isShow = !isShow;
};
 
function renderImg() {
    var bodyH = $(document.body).height();
    var imgMin = $("#img-main");
    var top = imgMin.offset().top;
    var imgHei = bodyH - top - default_top;
    imgMin.height(imgHei);
    //console.log(imgData);
    //调整展示图片地址
    if(imgData){
        $("#img-three").attr('src', imgData);
    }
    $("#img-three").css("height", imgHei);
    // $("#img-three").css("width", "100%");
    $("#img-three").show();
};
 
//获取设备列表,渲染显示设备信息
function loadDevice() {
 
    $.ajaxSettings.async = false;
    $.get("./cgi-bin/detail/query-all", function (data, status) {
        if ("success" == status) {
            // console.log("-------获取设备列表接收的数据------");
            // console.log(data);
            listDevice = data;
 
            renderTips(listDevice)
        } else {
            window.parent.notify("系统获取系统配置信息失败!");
        }
    }, "json");
};
 
//开始渲染信息
function renderTips(listDevice) {
 
    //console.log(listDevice);
 
    var parent = $("#img-main");
    var parentWidth = parent.width();
    var parentHeight = parent.height();
 
    var left = 50, top = 50;
    var temp;
    var id;
    var tagValue;
    var category;
    var recordMap;
    var warnState = 0;
    var i;
    var name;
    var warnStr = " warn-div ";
    // console.log("=========所有设备信息=========");
    // console.log(listDevice);
    $.each(listDevice, function (index, device) {
 
        i = index;
        left = (parentWidth * device.leftV).toFixed(4);
        top = (parentHeight * device.topV).toFixed(4);
        category = device.category;//设备类型
        id = device.id;//设备ID
        name = device.name;
 
        if(category != CATEGORY.D3009.code){
            if(id && category){
                if(category != CATEGORY.D2090.code && category != CATEGORY.D2091.code){
                    recordMap = device.value;//设备监控属性集合
                    warnState = device.type;
                    tagValue = addCurData(category, recordMap, warnState,device);
                    warnState = tagValue.warnState;
                    if(warnState == 0){
                        warnStr = "";
                    }else{
                        warnStr = " warn-div ";
                    }
 
                    temp = "";
                    if(device.id == thId1 || device.id == thId2){
                        if(device.id == thId1){
                            thData1 = device;
                        }else{
                            thData2 = device;
                        }
                        temp += "<div id='" + device.id
                            + "' class='tip arrow_box "+warnStr+"'  style='left:" + left+ "px;top:" + top + "px;display: none;' "
                            + "name='" + device.name + "' category='" + category + "' index='" + index + "'>";
                        temp += "<div class = 'div-c'>";
                        temp += "</div>";
                        temp += "<div class = 'div-d' style='font-size: 14px;'><p style='margin-bottom: 5px;'><span>露点温度1</span><span style='margin-left: 10%;'>露点温度2</span></p>" +
                            "<p><span style='margin-left: 1%;background-color: rgba(21, 221, 86, 1);padding: 0% 5%;'>22.2℃</span>" +
                            "<span style='margin-left: 15%;background-color: rgba(21, 221, 86, 1);padding: 0% 5%;'>22.2℃</span></div>";
                        temp += "</div>";
 
                    }else{
                        if ("FULL" == tagValue.code) {
                            temp += "<div id='" + device.id
                                + "' class='tip arrow_box "+warnStr+"'  style='left:" + left+ "px;top:" + top + "px;' "
                                + "name='" + device.name + "' category='" + category + "' index='" + index + "'>";
                            temp += "<div class = 'div-c'>";
                            temp += addCurImg(category,warnState);
                            temp += "</div>";
                            temp += tagValue.htm;
 
                            // temp += "<div class = 'div-d' style='margin-top: -5px;'>";
                            // temp += "<span style='padding: 2px;background-color: #524c4c;color: white;'>";
                            // temp += name;
                            // temp += "</span>";
                            // temp += "</div>";
 
                            temp += "</div>";
                        } else {
                            temp += "<div id='" + device.id
                                + "' class='tip arrow_min "+warnStr+"'  style='left:" + left + "px;top:" + top + "px;' "
                                + "name='" + device.name + "' category='" + category + "' index='" + index + "'>";
                            temp += "<div class = 'div-c'>";
                            temp += addCurImg(category,warnState);
                            temp += "</div>";
                            temp += tagValue.htm;
 
                            // temp += "<div class = 'div-d' style='margin-top: -10px;'>";
                            // temp += "<span style='padding: 2px;background-color: #524c4c;color: white;'>";
                            // temp += name;
                            // temp += "</span>";
                            // temp += "</div>";
 
                            temp += "</div>";
                        }
 
                        // temp += "<div class = 'div-c'>";
                        // temp += addCurImg(category);
                        // temp += "</div>";
                        // temp += tagValue.htm;
                        // temp += "</div>";
                    }
                    // if(category == CATEGORY.D3001.code){
                    //     console.log("=========门禁设备=========设备信息:");
                    //     console.log(device);
                    // }
 
                    // if(device.id != "1001" && device.id != "1002"){
                    //     //删除原有元素,在进行追加
                    //     $("#"+device.id).remove();
                    //     parent.append(temp);
                    //
                    // }
                    //删除原有元素,在进行追加
                    $("#"+device.id).remove();
                    parent.append(temp);
                }
            }else{
                console.log("=========没有获取到该设备的设备id(类型)=========设备信息:");
                console.log(device);
            }
        }
 
 
 
    });
    // if(thData1 && thData2){
    //     addhtml(parent,i);
    // }
 
    //添加图标的事件
    $(".tip").click(function () {
        var id = $(this).attr("id");
        var name = $(this).attr("name");
 
        layer.msg("当前设备:" + name);
    });
 
    //添加图标的事件
    $(".tip").dblclick(function () {
        var deviceId = $(this).attr("id");
        var name = $(this).attr("name");
        var category = $(this).attr("category");
        var url = "";
        url = "./detail-ty.html?id="+deviceId+"&type="+category;
        if (category == CATEGORY.D2001.code) {
            url = "./detail-wsd.html?id="+deviceId+"&type=" + category;
        }
        if (category == CATEGORY.D3001.code) {
            url = "./detail-mj.html?id="+deviceId+"&type=" + category;
        }
        if (category == CATEGORY.D1004.code || category == CATEGORY.D1003.code) {
            url = "./detail-pd.html?id="+deviceId+"&type=" + category;
        }
        if (category == CATEGORY.D1001.code || category == CATEGORY.D1002.code) {
            url = "./detail-ups.html?id="+deviceId+"&type=" + category;
        }
        if (category == CATEGORY.D2002.code) {
            url = "./detail-jmkt.html?id="+deviceId+"&type=" + category;
        }
        if (category == CATEGORY.D1005.code) {
            url = "./detail-dcz.html?id="+deviceId+"&type=" + category;
        }
 
        //红外
        if (category == CATEGORY.D3003.code) {
            url = "./detail-hw.html?id=999&type=" + category;
            name = "红外";
        }
        //漏水
        if (category == CATEGORY.D2005.code) {
            url = "./detail-ls.html?id=999&type=" + category;
            name = "漏水";
        }
        //烟感
        if (category == CATEGORY.D3002.code) {
            url = "./detail-yg.html?id=999&type=" + category;
            name = "烟感";
        }
        if (category == CATEGORY.D3008.code) {
            url = "./detail-wg.html?id=999&type=" + category;
            name = "温感";
        }
        if (category == CATEGORY.D3004.code) {
            url = "./detail-video.html?id=999&type=" + category;
            name = "视频";
            // var html = '';
            // html += '<iframe class="J_iframe" name="iframe0" width="100%" height="100%" ';
            // html += 'src="./detail-video-pop.html?id='+deviceId+'&type='+category+'" ';
            // html += ' frameborder="0" data-id="detail-ty-2.html" seamless></iframe>';
            // $("#video .popCon").html(html);
            // $("#device-name").text(name);
            // layer.open({
            //     skin: 'mypop',
            //     type: 1,
            //     title: false,
            //     area: ['100%', '100%'],
            //     closeBtn: 0,
            //     shade: 0,
            //     scrollbar: false,
            //     content: $('#video')
            // });
            // return;
        }
        // console.log("===================跳转==================");
        // console.log("url="+url);
        // var url = "./warn-list.html?id=999&category=" + category;
        console.log("name="+name+",url="+url);
        window.parent.openTab(url, name + "", deviceId)
    });
 
    //添加图标的事件--鼠标悬停事件
    $(".tip").mouseenter(function () {
        var id = $(this).attr("id");
        var category = $(this).attr("category");
        if(category == "3004"){
            return ;
        }
        if(id != "th"){
            var name = $(this).attr("name");
            var index = $(this).attr("index");
 
            var device = listDevice[index];
 
            category = device.category;
            var record = device.value;
 
            var temp = addCurDataInfo(category,record);
 
            layer.open({
                type: 1
                ,title: '当前设备:' + name
                ,skin: 'skin-class'
                ,area: ['300px']
                ,shade: 0//不遮拦
                ,offset: ['0px','83%']//左上角显示
                ,moveType: 0 //拖拽模式,0或者1
                ,content: temp
            });
        }
 
        // console.log(listDevice[index]);
    });
 
 
 
    //添加图标的事件--鼠标离开事件
    $(".tip").mouseleave(function () {
        var id = $(this).attr("id");
        var name = $(this).attr("name");
        var index = $(this).attr("index");
        var category = $(this).attr("category");
        if (category != CATEGORY.D3004.code) {
            layer.closeAll();
        }
 
    });
};
 
function addhtml(parent,i){
    console.log("添加露点设备信息");
    i++;
    var parentWidth = parent.width();
    var parentHeight = parent.height();
 
    var left = (parentWidth * thData1.leftV).toFixed(4);
    var top = (parentHeight * thData1.topV).toFixed(4);
 
    var recordMap1 = thData1.value;//设备监控属性集合
    var recordMap2 = thData2.value;
 
    var value1 = "00.0",value2 = "00.0";
    $.each(recordMap1,function (index,item) {
        if (item.passcode == "3") {
            value1 = item.value;
        }
    });
    $.each(recordMap2,function (index,item) {
        if (item.passcode == "3") {
            value2 = item.value;
        }
    });
    value1 = parseFloat(value1).toFixed(1);
    value2 = parseFloat(value2).toFixed(1);
    var temp = "";
    temp += "<div id='th' class='tip arrow_box_1'  style='left:" + left+ "px;top:" + top + "px;'  index='" + i + "'>";
    temp += "<div class = 'div-c'>";
    temp += "</div>";
    temp += "<div class = 'div-d' style='font-size: 14px;'><p style='margin-left: 2%;margin-bottom: 5px;'><span>露点温度1</span><span style='margin-left: 10%;'>露点温度2</span></p>" +
        "<p style='margin-left: 2%;'><span style='margin-left: 1%;background-color: rgba(21, 221, 86, 1);padding: 0% 5%;'>" + value1 +"℃</span>" +
        "<span style='margin-left: 15%;background-color: rgba(21, 221, 86, 1);padding: 0% 5%;'>" + value2 +"℃</span></div>";
    temp += "</div>";
 
    //删除原有元素,在进行追加
    $("#th").remove();
    parent.append(temp);
}
 
 
//使各Tip支持拖拽
function editTips() {
 
    layer.confirm('进行设备拖拽时将会暂停设备数据的实时刷新,是否继续?', function (index) {
        layer.close(index);
        // 首先停止执行原有的循环
        // 循环体中包括设备位置和数据,进行拖拽要暂停数据的自动刷新
        if (intervalData) clearInterval(intervalData);
 
        //获取可以移动的范围,默认就是当前页面
        var maxY = $(document.body).height();
        var maxX = $(document.body).width();
 
        var tips = $(".tip");
        if (tips.length == 0) {
            return;
        }
        $.each(tips, function (index, item) {
            var dd = new Dragdrop({
                target: item,
                area: [0, maxX, 0, maxY],
                callback: function (obj) {
                    //console.log('left:' + (obj.moveX) + ' top:' + (obj.moveY));
                }
            });
            dd.dragAll();
        });
 
    });
};
 
//--保存位置信息,保存时候调整为相对于当前parent的位置保存
function saveTips() {
    var tips = $(".tip");
    if (tips.length == 0) {
        return;
    }
    var parent = $("#img-main");
    var parentWidth = parent.width();
    var parentHeight = parent.height();
    var parentLeft = parent.offset().left, parentTop = parent.offset().top;
 
    //封装数据进行保存
    var data = new Array();
    var id = null;
    var offset;
    var left = 0, top = 0;
    $.each(tips, function (index, item) {
        id = item.id;
        offset = $('#' + id).offset();
        var category =  $('#' + id).attr("category");
 
        left = (offset.left - parentLeft) / parentWidth;
        top = (offset.top - parentTop) / parentHeight;
 
        data[index] = {
            deviceId: id,
            leftV: left.toFixed(4),
            topV: top.toFixed(4)
        };
 
        // if(thData1 && thData2){
        //     if(id==thData1.id || id==thData2.id){
        //         offset = $('#th').offset();
        //
        //         left = (offset.left - parentLeft) / parentWidth;
        //         top = (offset.top - parentTop) / parentHeight;
        //     }
        // }
        //
        // if(id != "th"){
        //     data[index] = {
        //         deviceId: id,
        //         leftV: left.toFixed(4),
        //         topV: top.toFixed(4)
        //     };
        // }
    });
    // console.log(data);
 
    var param = data;
    console.log("-------保存设备位置信息,发送的数据------");
    console.log(param);
    //执行保存
    $.post("./cgi-bin/device-place/save", JSON.stringify(param), function (data, status) {
        if (data.code == "success") {
            layer.closeAll();
            layer.msg("数据保存成功!");
            window.parent.notify("数据保存成功!");
        } else {
            window.parent.notify("数据保存出错,请重新操作!"+data.msg+"!");
        }
        if (status == "success") {
            layer.closeAll();
            layer.msg("数据保存成功!");
            window.parent.notify("数据保存成功!");
        } else {
            window.parent.notify("数据保存出错,请重新操作!"+data.msg+"!");
        }
 
    }, "json");
    
};
 
function updateImg() {
    layer.confirm("是否更换2.5D图片?", function (index) {
        $("#image").click();
        layer.close(index);
    });
 
 
}
 
function toBase64() {
    var file = document.querySelector('input[type=file]').files[0];
    var fileSize = file.size;
    // console.log(fileSize);
    if(fileSize > 1024 * 1024 ){
        window.parent.notify("上传的图片大小不得大于1M!");
        return ;
    }
    var reader = new FileReader();
    reader.onloadend = function () {
        imgData = reader.result;
        uploadImg(imgData);
        // $("#img-three").attr("src", reader.result);
        // console.log(reader.result);
    }
    if (file) {
        reader.readAsDataURL(file);
    }
}
//上传图片Base64码
function uploadImg(imgData) {
    var param = {data:imgData};
    // console.log("-------保存2.5D图,发送的数据------");
    // console.log(param);
    //执行保存
    $.ajaxSettings.async = false;
    $.post("./cgi-bin/img-data/save", JSON.stringify(param), function (data, status) {
        if (data.code == "success") {
            layer.closeAll();
            window.parent.notify("图片保存成功!");
 
        } else {
            window.parent.notify("图片保存出错,请重新操作!"+data.msg+"!");
        }
    }, "json");
    renderImg();
}
 
/**
 * 不同的设备显示不同的信息,部分设备不显示设备信息
 *
 * 返回信息是一个MAP,包含两个信息,一个是CODE,一个是值
 */
function addCurData(category, record, warnState,device) {
    var recordMap = [];
    if(record){
        for(var i=0;i<record.length;i++){
            recordMap[record[i].passcode] = record[i];
        }
    }
    var result = {code: "FULL", htm: "",warnState:0};
    var temp = "";
    // //温湿度-只显示温度和湿度
    if (category == CATEGORY.D2001.code) {
        if(recordMap){
            if(recordMap[1] && recordMap[1].value == 1){
                temp += "<div class = 'div-d font-warn'>";
                // temp += "<p><span>"+device.name+"</span></p>";
                temp += "<p><span>通讯异常</span></p>";
                result.warnState = 1;
            }else{
                if(recordMap[2] && recordMap[2].value == 1){
                    temp += "<div class = 'div-d font-warn'>";
                    // temp += "<p><span>"+device.name+"</span></p>";
                    // temp += "<p><span>报警</span></p>";
                    result.warnState = 1;
                }else{
                    temp += "<div class = 'div-d'>";
                    // temp += "<p><span>"+device.name+"</span></p>";
                    // temp += "<p><span>正常</span></p>";
                }
                if (recordMap[3]) {
                    temp += "<p><span> 温  度:" + recordMap[3].value + "℃</span></p>";
                }
                if (recordMap[4]) {
                    temp += "<p><span> 湿  度:" + recordMap[4].value + "%</span></p>";
                }
            }
        }else{
            temp += "<div class = 'div-d font-warn'>";
            temp += "<p><span>"+device.name+"</span></p>";
            temp += "<p><span>通讯异常</span></p>";
            result.warnState = 1;
        }
        temp += "</div>";
        result.htm = temp;
        return result;
    }
    //精密空调
    if (category == CATEGORY.D2002.code) {
        if(recordMap){
            if(recordMap[1] && recordMap[1].value == 1){
                temp += "<div class = 'div-d font-warn'>";
                // temp += "<p><span>"+device.name+"</span></p>";
                temp += "<p><span>通讯异常</span></p>";
                result.warnState = 1;
            }else{
                if(recordMap[2] && recordMap[2].value == 1){
                    temp += "<div class = 'div-d font-warn'>";
                    // temp += "<p><span>"+device.name+"</span></p>";
                    // temp += "<p><span>报警</span></p>";
                    result.warnState = 1;
                }else{
                    temp += "<div class = 'div-d'>";
                    // temp += "<p><span>"+device.name+"</span></p>";
                    // temp += "<p><span>正常</span></p>";
                }
                if (recordMap[4]) {
                    temp += "<p><span>室内温度:" + recordMap[4].value + "℃</span></p>";
                }
                if (recordMap[5]) {
                    temp += "<p><span>室内湿度:" + recordMap[5].value + "%</span></p>";
                }
                if (recordMap[6]) {
                    temp += "<p><span>设定温度" + recordMap[6].value + "℃</span></p>";
                }
            }
        }else{
            temp += "<div class = 'div-d font-warn'>";
            temp += "<p><span>"+device.name+"</span></p>";
            temp += "<p><span>通讯异常</span></p>";
            result.warnState = 1;
        }
        temp += "</div>";
        result.htm = temp;
        return result;
    }
    // //普通空调
    // if (category == CATEGORY.D2003.code) {
    //     if(recordMap){
    //         if(recordMap[1] && recordMap[1].value == 1){
    //             temp += "<div class = 'div-d font-warn'>";
    //             // temp += "<p><span>"+device.name+"</span></p>";
    //             temp += "<p><span>通讯异常</span></p>";
    //         }else{
    //             if(recordMap[2] && recordMap[2].value == 1){
    //                 temp += "<div class = 'div-d font-warn'>";
    //                 // temp += "<p><span>"+device.name+"</span></p>";
    //                 // temp += "<p><span>报警</span></p>";
    //             }else{
    //                 temp += "<div class = 'div-d'>";
    //                 // temp += "<p><span>"+device.name+"</span></p>";
    //                 // temp += "<p><span>正常</span></p>";
    //             }
    //             if (recordMap[3]) {
    //                 temp += "<p><span>设定温度:" + recordMap[3].value + "℃</span></p>";
    //             }
    //             if (recordMap[4]) {
    //                 temp += "<p><span>设定湿度:" + recordMap[4].value + "%</span></p>";
    //             }
    //         }
    //     }else{
    //         temp += "<div class = 'div-d font-warn'>";
    //         temp += "<p><span>"+device.name+"</span></p>";
    //         temp += "<p><span>通讯异常</span></p>";
    //     }
    //     temp += "</div>";
    //     result.htm = temp;
    //     return result;
    // }
    // //电池
    // if (category == CATEGORY.D1005.code) {
    //     if(recordMap){
    //         if(recordMap[1] && recordMap[1].value == 1){
    //             temp += "<div class = 'div-d font-warn'>";
    //             // temp += "<p><span>"+device.name+"</span></p>";
    //             temp += "<p><span>通讯异常</span></p>";
    //         }else{
    //             if(recordMap[2] && recordMap[2].value == 1){
    //                 temp += "<div class = 'div-d font-warn'>";
    //                 // temp += "<p><span>"+device.name+"</span></p>";
    //                 // temp += "<p><span>报警</span></p>";
    //             }else{
    //                 temp += "<div class = 'div-d'>";
    //                 // temp += "<p><span>"+device.name+"</span></p>";
    //                 // temp += "<p><span>正常</span></p>";
    //             }
    //             if (recordMap[125]) {
    //                 temp += "<p><span>总 电 压:" + recordMap[125].value + "</span></p>";
    //             }
    //             if (recordMap[124]) {
    //                 temp += "<p><span>总 电 流:" + recordMap[124].value + "</span></p>";
    //             }
    //             // if (recordMap[3]) {
    //             //     temp += "<p><span>电池个数:" + recordMap[3].value + "</span></p>";
    //             // }
    //             // if (recordMap[126]) {
    //             //     temp += "<p><span>后备时间:" + recordMap[126].value + "</span></p>";
    //             // }
    //         }
    //     }else{
    //         temp += "<div class = 'div-d font-warn'>";
    //         temp += "<p><span>"+device.name+"</span></p>";
    //         temp += "<p><span>通讯异常</span></p>";
    //     }
    //     temp += "</div>";
    //     // temp += "</marquee>";
    //     result.htm = temp;
    //     return result;
    // }
    if(category == CATEGORY.D3001.code){
        temp += "<div class = 'div-d'>";
        // temp += "<p><span>"+device.name+"</span></p>";
        temp += "</div>";
        result.htm = temp;
        result.code = "EMPTY";
        return result;
    }
 
    if(category == CATEGORY.D3004.code){
        temp += "<div class = 'div-d'>";
        // temp += "<p><span>"+device.name+"</span></p>";
        temp += "</div>";
        result.htm = temp;
        result.code = "EMPTY";
        return result;
    }
 
    if(category == CATEGORY.D2005.code || category == CATEGORY.D3002.code
            || category == CATEGORY.D3003.code){
        if(recordMap){
            if(recordMap[1] && recordMap[1].value == 1){
                temp += "<div class = 'div-d font-warn'>";
                // temp += "<p><span>"+device.name+"</span></p>";
                temp += "<p><span>通讯异常</span></p>";
                result.warnState = 1;
            }else{
                if(recordMap[2] && recordMap[2].value == 1){
                    temp += "<div class = 'div-d font-warn'>";
                    // temp += "<p><span>"+device.name+"</span></p>";
                    temp += "<p><span>报警</span></p>";
                    result.warnState = 1;
                }else{
                    temp += "<div class = 'div-d '>";
                    // temp += "<p><span>"+device.name+"</span></p>";
                    temp += "<p><span>正常</span></p>";
                }
            }
        }else{
            temp += "<div class = 'div-d font-warn'>";
            // temp += "<p><span>"+device.name+"</span></p>";
            temp += "<p><span>通讯异常</span></p>";
            result.warnState = 1;
        }
        temp += "</div>";
        result.htm = temp;
        result.code = "EMPTY";
        return result;
    }
 
    //没有专门的显示,调整父DIV的大小
    if(recordMap){
        if(recordMap[1] && recordMap[1].value == 1){
            temp += "<div class = 'div-d font-warn'>";
            // temp += "<p><span>"+device.name+"</span></p>";
            // temp += "<p><span>通讯异常</span></p>";
            result.warnState = 1;
        }else{
            if(recordMap[2] && recordMap[2].value == 1){
                temp += "<div class = 'div-d font-warn'>";
                // temp += "<p><span>"+device.name+"</span></p>";
                // temp += "<p><span>报警</span></p>";
                result.warnState = 1;
            }else{
                temp += "<div class = 'div-d'>";
                // temp += "<p><span>"+device.name+"</span></p>";
                // temp += "<p><span>正常</span></p>";
            }
        }
    }else{
        temp += "<div class = 'div-d font-warn'>";
        // temp += "<p><span>"+device.name+"</span></p>";
        // temp += "<p><span>通讯异常</span></p>";
        result.warnState = 1;
    }
    temp += "</div>";
    result.htm = temp;
    result.code = "EMPTY";
    return result;
 
}
 
/**
 * 不同设备显示不同的图标
 * @param category
 * @returns {String}
 */
function addCurImg(category,warnState) {
    //温湿度
    if (category == CATEGORY.D2001.code) {
        return "<img src='images/icon-ht@64.png'/>";
    }
    //电表
    if (category == CATEGORY.D1003.code) {
        return "<img src='images/icon-db@100.png'/>";
    }
    //配电柜
    if (category == CATEGORY.D1004.code) {
        return "<img src='images/icon-ups@64.png'/>";
    }
    //UPS-三相
    if (category == CATEGORY.D1002.code) {
        if(warnState == 1){
            return "<img src='images/icon-ups@64.png'/>";
        }
        return "<img src='images/icon-ups@64.png'/>";
    }
    //UPS-单向
    if (category == CATEGORY.D1001.code) {
        if(warnState == 1){
            return "<img src='images/icon-ups@64.png'/>";
        }
        return "<img src='images/icon-ups@64.png'/>";
    }
    //门禁
    if (category == CATEGORY.D3001.code) {
        return "<img src='images/icon-mj@64.png'/>";
    }
    //精密空调
    if (category == CATEGORY.D2002.code) {
        return "<img src='images/img-kt.png'/>";
        // return "<img src='images/icon-ups@64.png'/>";
    }
    //普通空调
    if (category == CATEGORY.D2003.code) {
        return "<img src='images/img-kt2.png'/>";
        // return "<img src='images/icon-ups@64.png'/>";
    }
    //风机
    if (category == CATEGORY.D2004.code) {
        return "<img src='images/icon-fj.png'/>";
    }
    //红外
    if (category == CATEGORY.D3003.code) {
        return "<img src='images/icon-hw@100.png'/>";
    }
    //漏水
    if (category == CATEGORY.D2005.code) {
        return "<img src='images/icon-ls@100.png'/>";
    }
    //烟感
    if (category == CATEGORY.D3002.code) {
        return "<img src='images/icon-yg@100.png'/>";
    }
    //电池
    if (category == CATEGORY.D1005.code) {
        return "<img src='images/icon-dc@64.png'/>";
    }
    //视频
    if (category == CATEGORY.D3004.code) {
        return "<img src='images/icon-device-sp.png'/>";
    }
 
    return "<img src='images/icon-common@64.png'/>";
};
 
 
 
function addCurDataInfo(category,record){
    var recordMap = [];
    $.each(record,function (index,item) {
        recordMap[item.passcode] = item;
    });
 
    var temp = "";
    //UPS-单向
    if (category == CATEGORY.D1001.code) {
        temp += "<div class = 'div-temp'>";
        if (record) {
            $.each(record,function (index,item) {
                if (item.passcode == "1")temp += "<p><span>通讯状态:" + (item.value==0?"正常":"告警") + "</span></p>";
                if (item.passcode == "2")temp += "<p><span>告警状态:" + (item.value==0?"正常":"告警") + "</span></p>";
                if (item.passcode == "999")temp += "<p><span>告警内容:" + (item.value?item.value:"无告警") + "</span></p>";
                if (item.passcode == "3")temp += "<p><span>输入电压:" + item.value + "V</span></p>";
                if (item.passcode == "4")temp += "<p><span>输入电流:" + item.value + "A</span></p>";
                if (item.passcode == "5")temp += "<p><span>输出电压:" + item.value + "V</span></p>";
                if (item.passcode == "6")temp += "<p><span>输出电流:" + item.value + "A</span></p>";
                if (item.passcode == "13")temp += "<p><span>电池剩余:" + item.value + "%</span></p>";
            });
 
            temp += "<p><span></span></p>";
        }else{
            temp += "<p><span>暂无数据</span></p>";
        }
        temp += "</div>";
        return temp;
    }
    //UPS-三相
    if (category == CATEGORY.D1002.code) {
        temp += "<div class = 'div-temp'>";
        if (record) {
            $.each(record,function (index,item) {
                if (item.passcode == "1")temp += "<p><span>通讯状态:" + (item.value==0?"正常":"告警") + "</span></p>";
                if (item.passcode == "2")temp += "<p><span>告警状态:" + (item.value==0?"正常":"告警") + "</span></p>";
                if (item.passcode == "999")temp += "<p><span>告警内容:" + (item.value?item.value:"无告警") + "</span></p>";
                if (item.passcode == "3")temp += "<p><span>A相输入电压:" + item.value + "V</span></p>";
                if (item.passcode == "4")temp += "<p><span>B相输入电压:" + item.value + "V</span></p>";
                if (item.passcode == "5")temp += "<p><span>C相输入电压:" + item.value + "V</span></p>";
                if (item.passcode == "6")temp += "<p><span>A相输入电流:" + item.value + "A</span></p>";
                if (item.passcode == "7")temp += "<p><span>B相输入电流:" + item.value + "A</span></p>";
                if (item.passcode == "8")temp += "<p><span>C相输入电流:" + item.value + "A</span></p>";
                if (item.passcode == "9")temp += "<p><span>A相输出电压:" + item.value + "V</span></p>";
                if (item.passcode == "10")temp += "<p><span>B相输出电压:" + item.value + "V</span></p>";
                if (item.passcode == "11")temp += "<p><span>C相输出电压:" + item.value + "V</span></p>";
                if (item.passcode == "12")temp += "<p><span>A相输出电流:" + item.value + "A</span></p>";
                if (item.passcode == "13")temp += "<p><span>B相输出电流:" + item.value + "A</span></p>";
                if (item.passcode == "14")temp += "<p><span>C相输出电流:" + item.value  + "A</span></p>";
                if (item.passcode == "23")temp += "<p><span>电池剩余:" + (item.value?item.value : "#") + "%</span></p>";
            });
            temp += "<p><span></span></p>";
        }else{
            temp += "<p><span>暂无数据</span></p>";
        }
        temp += "</div>";
        return temp;
    }
    //电表
    if (category == CATEGORY.D1003.code) {
        temp += "<div class = 'div-temp'>";
        if (record) {
            $.each(record,function (index,item) {
                if (item.passcode == "1")temp += "<p><span>通讯状态:" + (item.value==0?"正常":"告警") + "</span></p>";
                if (item.passcode == "2")temp += "<p><span>告警状态:" + (item.value==0?"正常":"告警") + "</span></p>";
                if (item.passcode == "999")temp += "<p><span>告警内容:" + (item.value?item.value:"无告警") + "</span></p>";
                if (item.passcode == "3")temp += "<p><span> A相电压:" + item.value + "V</span></p>";
                if (item.passcode == "4")temp += "<p><span> B相电压:" + item.value + "V</span></p>";
                if (item.passcode == "5")temp += "<p><span> C相电压:" + item.value + "V</span></p>";
                if (item.passcode == "6")temp += "<p><span> A相电流:" + item.value + "A</span></p>";
                if (item.passcode == "7")temp += "<p><span> B相电流:" + item.value + "A</span></p>";
                if (item.passcode == "8")temp += "<p><span> C相电流:" + item.value + "A</span></p>";
                if (item.passcode == "16")temp += "<p><span> 频率:" + item.value + "Hz</span></p>";
            });
            temp += "<p><span></span></p>";
        }else{
            temp += "<p><span>暂无数据</span></p>";
        }
        temp += "</div>";
        return temp;
    }
    //电表
    if (category == CATEGORY.D1004.code) {
        temp += "<div class = 'div-temp'>";
        if (record) {
            $.each(record,function (index,item) {
                if (item.passcode == "1")temp += "<p><span>通讯状态:" + (item.value==0?"正常":"告警") + "</span></p>";
                if (item.passcode == "2")temp += "<p><span> 告警状态:" + (item.value==0?"正常":"告警") + "</span></p>";
                if (item.passcode == "999")temp += "<p><span>告警内容:" + (item.value?item.value:"无告警") + "</span></p>";
                if (item.passcode == "3")temp += "<p><span> 1#A相电压:" + item.value + "V</span></p>";
                if (item.passcode == "4")temp += "<p><span> 1#B相电压:" + item.value + "V</span></p>";
                if (item.passcode == "5")temp += "<p><span> 1#C相电压:" + item.value + "V</span></p>";
                if (item.passcode == "6")temp += "<p><span> 1#A相电流:" + item.value + "A</span></p>";
                if (item.passcode == "7")temp += "<p><span> 1#B相电流:" + item.value + "A</span></p>";
                if (item.passcode == "8")temp += "<p><span> 1#C相电流:" + item.value + "A</span></p>";
                if (item.passcode == "16")temp += "<p><span> 1#频率:" + item.value + "Hz</span></p>";
                if (item.passcode == "20")temp += "<p><span> 2#A相电压:" + item.value + "V</span></p>";
                if (item.passcode == "21")temp += "<p><span> 2#B相电压:" + item.value + "V</span></p>";
                if (item.passcode == "22")temp += "<p><span> 2#C相电压:" + item.value + "V</span></p>";
                if (item.passcode == "23")temp += "<p><span> 2#A相电流:" + item.value + "A</span></p>";
                if (item.passcode == "24")temp += "<p><span> 2#B相电流:" + item.value + "A</span></p>";
                if (item.passcode == "25")temp += "<p><span> 2#C相电流:" + item.value + "A</span></p>";
                if (item.passcode == "33")temp += "<p><span> 2#频率:" + item.value + "Hz</span></p>";
            });
            temp += "<p><span></span></p>";
        }else{
            temp += "<p><span>暂无数据</span></p>";
        }
        temp += "</div>";
        return temp;
    }
    //电池
    if (category == CATEGORY.D1005.code) {
        temp += "<div class = 'div-temp'>";
        if (record) {
            $.each(record,function (index,item) {
                if (item.passcode == "1")temp += "<p><span>通讯状态:" + (item.value==0?"正常":"告警") + "</span></p>";
                if (item.passcode == "2")temp += "<p><span>告警状态:" + (item.value==0?"正常":"告警") + "</span></p>";
                if (item.passcode == "999")temp += "<p><span>告警内容:" + (item.value?item.value:"无告警") + "</span></p>";
                if (item.passcode == "3")temp += "<p><span>电池个数:" + item.value + "</span></p>";
                if (item.passcode == "124")temp += "<p><span>总 电 流:" + item.value + "A</span></p>";
                if (item.passcode == "125")temp += "<p><span>总 电 压:" + item.value + "V</span></p>";
                if (item.passcode == "126")temp += "<p><span>后备时间:" + item.value + "小时</span></p>";
            });
        }else{
            temp += "<p><span>暂无数据</span></p>";
        }
        temp += "</div>";
        return temp;
    }
    //精密空调
    if (category == CATEGORY.D2002.code) {
        temp += "<div class = 'div-temp'>";
        if (record) {
            $.each(record,function (index,item) {
                if (item.passcode == "1")temp += "<p><span>通讯状态:" + (item.value==0?"正常":"告警") + "</span></p>";
                if (item.passcode == "2")temp += "<p><span>告警状态:" + (item.value==0?"正常":"告警") + "</span></p>";
                if (item.passcode == "999")temp += "<p><span>告警内容:" + (item.value?item.value:"无告警") + "</span></p>";
                if (item.passcode == "3")temp += "<p><span>运行状态:" + item.value + "</span></p>";
                if (item.passcode == "4")temp += "<p><span>室内温度:" + item.value + "℃</span></p>";
                if (item.passcode == "5")temp += "<p><span>室内湿度:" + item.value + "%</span></p>";
                if (item.passcode == "6")temp += "<p><span>设定温度:" + item.value + "℃</span></p>";
                if (item.passcode == "7")temp += "<p><span>设定湿度:" + item.value + "%</span></p>";
            });
        }
        temp += "</div>";
        return temp;
    }
    //普通空调
    if (category == CATEGORY.D2003.code) {
        temp += "<div class = 'div-temp'>";
        if (record) {
            $.each(record,function (index,item) {
                if (item.passcode == "1")temp += "<p><span>通讯状态:" + (item.value==0?"正常":"告警") + "</span></p>";
                if (item.passcode == "2")temp += "<p><span>告警状态:" + (item.value==0?"正常":"告警") + "</span></p>";
                if (item.passcode == "999")temp += "<p><span>告警内容:" + (item.value?item.value:"无告警") + "</span></p>";
                if (item.passcode == "3")temp += "<p><span>设定温度:" + item.value + "℃</span></p>";
                if (item.passcode == "4")temp += "<p><span>设定湿度:" + item.value + "%</span></p>";
            });
        }else{
            temp += "<p><span>暂无数据</span></p>";
        }
        temp += "</div>";
        return temp;
    }
    //漏水、红外、烟感
    if (category == CATEGORY.D2005.code || category == CATEGORY.D3002.code || category == CATEGORY.D3003.code ) {
        temp += "<div class = 'div-temp'>";
        if (record) {
            $.each(record,function (index,item) {
                if (item.passcode == "1")temp += "<p><span>通讯状态:" + (item.value==0?"正常":"告警") + "</span></p>";
                if (item.passcode == "2")temp += "<p><span>告警状态:" + (item.value==0?"正常":"告警") + "</span></p>";
            });
        }else{
            temp += "<p><span>暂无数据</span></p>";
        }
        temp += "</div>";
        return temp;
    }
 
    if (record) {
        temp += "<div class = 'div-temp'>";
        $.each(record, function (index, item) {
            if (item.passcode == "1"){
                temp += "<p><span>通讯状态:" + (item.value==0?"正常":"告警") + "</span></p>";
            }else if (item.passcode == "2"){
                temp += "<p><span>告警状态:" + (item.value==0?"正常":"告警") + "</span></p>";
            }else if(item.passcode == "999"){
                temp += "<p><span>告警内容:" + (item.value?item.value:"无告警") + "</span></p>";
            }else{
                temp += "<p><span>" + item.name + ":" + item.value + "</span></p>";
            }
        });
        temp += "</div>";
    }else{
        temp += "<div class = 'div-temp'>";
        temp += "<p><span>暂无数据</span></p>";
        temp += "</div>";
    }
 
    return temp;
 
 
 
}