master
2022-03-21 1292f810644e422357734d1616761eb920903f45
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
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
var layer_xingzhengqu_100;
var layer_sifasuo_101;
var layer_shequjiaozheng_102;
var layer_anzhibangjiao_103;
var layer_renmintiaojie_104;
var layer_pudong_gltf_200;
var layer_shanghai_tiles_201;
var layer_shanghai_roads_202;
var layer_sifaju_effect_203;
var layer_shanghai_mask_300;
var pci_data = [];
var MR_data = [];
var MR_msisdn1;
var MR_msisdn2;
var MR_msisdn3;
var msisdn_list;
var msisdn_id_list = [];
var msisdn_name = [];
var point_list = [];
var open_merge_list = [];
var new_msisdn_list = [];
var data_yn = '';
var repoint_list = [];
var repoint_id_list = [];
var repoint_name = [];
var floor_linght = []
var floor_position_light = []
var floor_position_light2 = []
var model_list = [];
var light_graphic_list = [];
var color_boxs = $("#color_boxs")
var distance_half = 111319.5;
var new_msisdn_position = []
var msisdn_msg = []
var floor_position_points = []
var floor_position_floor = []
var graphicLayer17
var points17 = []
var initGraphic
var polinlayer1
// import data from '../data/sites.js'
var get_JSON = {
    ruijin_url:"http://localhost:4500/dataservice/Bdata?bid="
}
// 页面初始化,创建楼层按键
$(document).ready(function(){
    var btn_box_html = ''
    for(let i=1;i<23;i++){
        btn_box_html += `<button style="margin-right:4px;" class="${i}">F${i}</button>`
    }
    $("#building_btn").append(btn_box_html)
    // $.ajax({
    //     type: 'get',
    //     dataType: 'json',
    //     async: true,//同步
    //     url: `http://localhost:4500/dataservice/Bdata?bid=get_msisdn_msg`,
    //     success:function(data){
    //       console.log(data.data.data,"msisdn")
    //       msisdn_msg = data.data.data
    //       for(let i=0;i<msisdn_msg.length;i++){
    //           floor_position_floor[i] = []
    //       }
    //     },
    //     error: function (request, textStatus) {
        
    //     }
    // })
    $.getJSON('data/msisdn_list.json',(result)=>{
        
        console.log("e")
        let data = result.RECORDS
        console.log(data)
        msisdn_list = data
        for(let i=0;i<msisdn_list.length;i++){
            floor_linght[i] = []
        }
        console.log(floor_linght)
    })
 
    $.getJSON('data/msisdn_position.json',(result)=>{
        console.log(result.data,"data")
        MR_data = result.data;
        if(MR_data.length>=0){
            data_yn = '<p>定位运行</p>'
        }else{
            data_yn = '<p>暂无数据</p>'
        }
        $("#data_yn").append(data_yn)
        for(let i=0;i<msisdn_list.length;i++){
            msisdn_name[i] = `graphic_msisdn${i}`
            msisdn_id_list[i] = MR_data.filter(item=>{
                return item.msisdn == msisdn_list[i].msisdn
            })
        }
        })
    $.getJSON('data/repoint.json',(result)=>{
        console.log("eeee")
        repoint_list = result.data;
        for(let i=0;i<repoint_list.length;i++){
            if(Number(repoint_list[i].lat)<31.211869869520108){
                repoint_list[i].lat = 31.211869869520108
            }
        }
        for(let i=0;i<msisdn_list.length;i++){
            repoint_name[i] = `graphic_msisdn${i}`
            repoint_id_list[i] = repoint_list.filter(item=>{
                return item.msisdn == msisdn_list[i].msisdn
            })
        }
        for(let i=0;i<floor_linght.length;i++){
            for(let j=0;j<22;j++){
                floor_linght[i][j] = msisdn_id_list[i].filter(item=>{
                    return finalHeight2(item.height) == j
                })
            }
        }
        console.log(floor_linght)
        })
 
        // $.ajax({
        //     type:'get',
        //     dataType:'json',
        //     async:true,
        //     url:'http://localhost:4500/dataservice/Bdata?bid=get_ruijin_outside&floor_=7',
        //     success:function(data){
        //         console.log("e")
        //         let datas = data.data.data
        //         console.log(datas)
        //         for(let i=0;i<datas.length;i++){
        //             let item = datas[i]
        //             points17[i] = [item.lon,item.lat] 
        //         }
                
        //         const graphic_17 = new mars3d.graphic.WallEntity({
        //           positions:points17,
        //           style: {
        //             closure: true,
        //             diffHeight: 2,
        //           }
        //         })
        //         graphicLayer17.addGraphic(graphic_17)
                
                
        //     }
        // })
    
})
// 
 
    var current=null
        function getEvent()
        {
          if(document.all)
          {
          return window.event;//如果是ie
          }
          func=getEvent.caller;
          while(func!=null)
          {
            var arg0=func.arguments[0];
            if(arg0)
            {
              if((arg0.constructor==Event || arg0.constructor ==MouseEvent)||(typeof(arg0)=="object" && arg0.preventDefault && arg0.stopPropagation))
              {
              return arg0;
              }
            }
            func=func.caller;
          }
          return null;
        }
        
        function doOver() {
          var evt=getEvent();
          var element=evt.srcElement || evt.target;
          var DisColor=document.getElementById("DisColor");
          var HexColor=document.getElementById("HexColor");
          if ((element.tagName=="TD") && (current!=element)) {
            if (current!=null){
              current.style.backgroundColor = current._background
            }
            element._background = element.style.backgroundColor
            DisColor.style.backgroundColor = rgbToHex(element.style.backgroundColor)
            HexColor.value = rgbToHex(element.style.backgroundColor)
            element.style.backgroundColor = "white"
            current = element
          }
        }
        function rgbToHex(aa)
        {
          if(aa.indexOf("rgb") != -1)
          {
            aa=aa.replace("rgb(","")
            aa=aa.replace(")","")
            aa=aa.split(",")
            r=parseInt(aa[0]);
            g=parseInt(aa[1]);
            b=parseInt(aa[2]);
            r = r.toString(16);
            if (r.length == 1) { r = '0' + r; }
            g = g.toString(16);
            if (g.length == 1) { g = '0' + g; }
            b = b.toString(16);
            if (b.length == 1) { b = '0' + b; }
            return ("#" + r + g + b).toUpperCase();
          }
          else
          {
            return aa;
          }
        }
 
// 通过获取到的数据进行创建设备定位点和路线
function addMsisdnPoint(){
    
    console.log(msisdn_id_list)
    for(let i=0;i<msisdn_id_list.length;i++){
        
        msisdn_position(msisdn_id_list[i],msisdn_name[i],`msisdn_graphic${i}`,msisdn_list[i].name_,"img/end.png")
        // msisdn_position(repoint_id_list[i],repoint_name[i],`repoint_graphic${i}`,msisdn_list[i].name_,"img/start.png")
    }
    // for(let i=0;i<)
    if(floor_linght.length>0){
        for(let i=0;i<floor_linght.length;i++){
        for(let j=0;j<22;j++){
            msisdn_light(floor_linght[i][j],`msisdn_graphic${i}`,`#00${i}${i}${i}${i}`,"img/textures/arrow2.png",0,floor_position_light)
            msisdn_light2(floor_linght[i][j],`msisdn_graphic${i}`,`#00${i}${i}${i}${i}`,"img/textures/arrow2.png",15*(j-1),floor_position_light2)
        }
    }
    }
    
    console.log(floor_position_light[0].points[0])
}
 
// 将获得的数据高度转换成适应大楼模型的高度
function finalHeight(h){
    // let h1 = Number(h)/2.8
    // let h2 = Math.floor(h1)-1
    // let h3 = h2*3
    // return h3
    let h1 = Number(h)
    let h2 = 0
    let h3 = 0
    let h4 = 0
    let h5 = 0
    if(h1<=4.5){
        h5 = 1
    }else{
        h2 = h1-4.5-1
        h3 = h2/2.8
        h4 = Math.floor(h3)+2
        h5 = h4*3*0.87333
    }
    
    return h5
}
function finalHeight2(h){
    let h1 = Number(h)/2.8
    let h2 = Math.floor(h1)-1
    return h2
    
}
function light_graphic(code){
    var light_graphic = name_ =  new mars3d.layer.GraphicLayer({
        id:code,
        pid:104,
        name:code,
        show:true
    })
    light_graphic_list.push(light_graphic)
    map.addLayer(light_graphic)
}
// 封装设备定位曲线的创建方法
function msisdn_light(data,map_name_,color,image_url,hh=0,arr_){
    var polinlayer =  new mars3d.layer.GraphicLayer({
        pid:104,
        // name:code,
        show:false
    })
    map.addLayer(polinlayer)
    let len = data.length
    for (let i = 0; i < len-1; i++) {
    let item = data[i];
    // 分别计算出两个点的高 
    let h1 = finalHeight(data[i]["height"])+hh
    let h2 = finalHeight(data[i+1]["height"])+hh
    // 设置开始和技术点,两点确定一条直线
      let startPoint = Cesium.Cartesian3.fromDegrees(data[i]["lon"], data[i]["lat"], h1)
      let endPoint = Cesium.Cartesian3.fromDegrees(data[i+1]["lon"], data[i+1]["lat"], h2)
      map_name_ = new mars3d.graphic.PolylineEntity({
        positions: [startPoint,endPoint],
        style: {
          width: 5,
          // 动画线材质
          material: mars3d.MaterialUtil.createMaterialProperty(mars3d.MaterialType.LineFlow, {
            color: color,
            image: image_url,
            speed: 5,
            repeat: new Cesium.Cartesian2(15, 1)
          })
        },
        hsaEdit:true,
        hasHeightEdit:true
      })
      polinlayer.addGraphic(map_name_)
      arr_.push(map_name_)
      }
}
function msisdn_light2(data,map_name_,color,image_url,hh=0,arr_){
    polinlayer1 =  new mars3d.layer.GraphicLayer({
        pid:104,
        // name:code,
        show:false
    })
    map.addLayer(polinlayer1)
    let len = data.length
    for (let i = 0; i < len-1; i++) {
    let item = data[i];
    // 分别计算出两个点的高 
    let h1 = finalHeight(data[i]["height"])+hh
    let h2 = finalHeight(data[i+1]["height"])+hh
    // 设置开始和技术点,两点确定一条直线
      let startPoint = Cesium.Cartesian3.fromDegrees(data[i]["lon"], data[i]["lat"], h1)
      let endPoint = Cesium.Cartesian3.fromDegrees(data[i+1]["lon"], data[i+1]["lat"], h2)
      map_name_ = new mars3d.graphic.PolylineEntity({
        positions: [startPoint,endPoint],
        style: {
          width: 5,
          // 动画线材质
          material: mars3d.MaterialUtil.createMaterialProperty(mars3d.MaterialType.LineFlow, {
            color: color,
            image: image_url,
            speed: 5,
            repeat: new Cesium.Cartesian2(15, 1)
          })
        },
        hsaEdit:true,
        hasHeightEdit:true
      })
      arr_.push(map_name_)
      }
}
function showHistoryPathDetail(itemname,itemid,itemfloor) {
 
  if (mars3d.widget.isActivate("widgets/rruRouterReplay/widget.js")) {
    var detailWiget = mars3d.widget.getClass("widgets/rruRouterReplay/widget.js");
    detailWiget.reloadData({
        "id":itemid,
        "name":itemname,
        "floor":itemfloor
    });
  } else {
    mars3d.widget.activate({
      uri: "widgets/rruRouterReplay/widget.js",
      params: {
        "id":itemid,
        "name":itemname,
        "floor":itemfloor
    }
    });
  }
}
// 封装设备定位点的方法
function msisdn_position(data,name_,map_name_,code,image_url){
    name_ =  new mars3d.layer.GraphicLayer({
        pid:155,
        name:code,
        show:true
    })
    map.addLayer(name_)
    for(let i=0;i<data.length;i++){
        let item = data[i]
        let height = finalHeight(item.height)
        map_name_ = new mars3d.graphic.BillboardEntity({
        position: [Number(item.lon), Number(item.lat),height+1 ], // 楼栋位置
        style: {
            image: image_url,
            scale:0.5,
            opacity:1,
            scaleByDistance_far:500,
            distanceDisplayCondition_far:500,
            scaleByDistance_farValue:0.5,
            scaleByDistance:true,
            visibleDepth:true,
            hasPixelOffset:false,
            distanceDisplayCondition:true,
            label:{
                text:item.index_,
                color:"#ffff00",
                font_size: 15,
                pixelOffsetY: -20,
                distanceDisplayCondition: true,
                distanceDisplayCondition_far: 1500,
                distanceDisplayCondition_near: 0
            }
        },
        
        popup:"编号:" +
      item["msisdn"] +
      "<br />时间:" +
      item["id"] +
      "<br />名称:" +
      item["name_"] +
      "<br/><p><a href='#' onclick='javascript:showHistoryPathDetail(" + item["msisdn"] + ",\"" + item["name_"] + "\",\"" + item["height"] + "\")' >轨迹查询</a></p>"
    })
    name_.addGraphic(map_name_)
    point_list.push(map_name_)
    }
}
 
function addpoint17(){
    graphicLayer17 = new mars3d.layer.GraphicLayer()
    map.addLayer(graphicLayer17)
    
      
}
 
function mr_rode(){
    console.log(model_list)
    console.log(new_msisdn_position,msisdn_msg)
 
}
 
 
function floor_height(h){
    let x = (h+15)/18
    return x
}
 
// 瑞金大楼的创建和对其进行的操作
function openFloor(){
    var num = 0;
    var openfl = false;
    var height_list = [];
    initGraphic =  new mars3d.layer.GraphicLayer({
        pid:155,
        name:"路径",
        show:true
    })
    map.addLayer(initGraphic)
    // 切换楼层颜色
    
    // 调色板,用于调整大楼外部颜色
 
    // 展开楼层
    $(".open2").click(function(e){
        mr_rode()
        console.log(floor_position_light,"展开前")
        let point_arr = new_msisdn_list.length>0?new_msisdn_list:point_list
        for(let i=0;i<point_arr.length;i++){
            let floor = point_arr[i].options.position[2]/(3*0.87333)
            console.log(floor,"floor")
            if(floor>1){
                point_arr[i].addDynamicPosition([point_arr[i].options.position[0],point_arr[i].options.position[1],point_arr[i].options.position[2]+15*(floor-1)])
            }
            
        }
        for(let i = 1;i<model_list.length;i++){
            if(i<7){
                model_list[i].moveTo({
                    position:[model_list[i].options.position[0],model_list[i].options.position[1],model_list[i].options.position[2]+15*i]
                })
            }else{
                model_list[i].moveTo({
                    position:[model_list[i].options.position[0],model_list[i].options.position[1],model_list[i].options.position[2]+15*(i-1)]
                })
            }
        }
        for(let i=0;i<floor_position_light.length;i++){
            floor_position_light[i].remove()
        }
        for(let i=0;i<floor_position_light2.length;i++){
             polinlayer1.addGraphic(floor_position_light2[i])
        }
        
        console.log(floor_position_light,"展开后")
    })
    // 合并楼层
    $(".merge").click(function(){
        for(let i=0;i<floor_position_light2.length;i++){
            floor_position_light2[i].remove()
        }
        for(let i=0;i<point_list.length;i++){
            point_list[i].addDynamicPosition([point_list[i].options.position[0],point_list[i].options.position[1],point_list[i].options.position[2]])
        }
        for(let i = 1;i<model_list.length;i++){
            model_list[i].moveTo({
                position:[model_list[i].options.position[0],model_list[i].options.position[1],model_list[i].options.position[2]]
            })
        }
        for(let i=0;i<floor_position_light.length;i++){
            floor_position_light[i].addTo(initGraphic)
        }
    })
    // 显示全部
    $(".hide_").click(function(){
        for(let i=0;i<model_list.length;i++){
            model_list[i].show = true
        }
        for(let i=0;i<point_list.length;i++){
            new_msisdn_list = []
                point_list[i].setStyle({
                    opacity:1,
                    label:{
                        opacity:1
                    }
                })
            
            new_msisdn_list.push(point_list[i])
        }
    })
    // 切换按钮,显示与隐藏调色盘
    $(".change").click(function(){
        $("#color_boxs").toggle();
    })
    // 选取按钮,点击按钮显示相应楼层
    var button_button = $("button")
    button_button.click(function(e){
        new_msisdn_list = []
        // console.log(new_msisdn_list,"opacity")
        // 六楼以下楼层对应相应的按钮,六层时把五楼楼顶和六楼同时隐藏,六楼以上按钮对应到楼层加一
        $(this).addClass('red')
        $(this).siblings('button').removeClass('red')
        let floor_ = e.target.className
        // let floor_end = Number(floor_)
        let floor_end = Number(floor_.slice(0,-3))
        if(floor_end){
            for(let i=0;i<point_list.length;i++){
                new_msisdn_list= []
                let floor = Number(point_list[i].options.position[2])/(3*0.87333)
                let floor_1 = Math.floor(floor)
                console.log(floor_end,floor)
                if(floor_end < floor_1){
                    point_list[i].setStyle({
                        opacity:0,
                        label:{
                            opacity:0
                        }
                    })
                }else{
                    point_list[i].setStyle({
                        opacity:1,
                        label:{
                            opacity:1
                        }
                    })
                }
                new_msisdn_list.push(point_list[i])
            }
            for(let i=0;i<floor_position_light.length;i++){
                let floor = Number(floor_position_light[i].points[0]._alt)/3
                // console.log(floor,"floor")
                if(floor_end < floor){
                    floor_position_light[i].setStyle({
                        width:0
                    })
                }else{
                    floor_position_light[i].setStyle({
                        width:5
                    })
                }
            }
            for(let i=0;i<floor_position_light2.length;i++){
                    let floor_2 = floor_height(Number(floor_position_light2[i].points[0]._alt))
                    let floor = floor_2
                    if(floor_end < floor_2){
                        floor_position_light2[i].setStyle({
                            width:0
                        })
                    }else{
                        floor_position_light2[i].setStyle({
                            width:5
                        })
                    }
                
            }
            if(floor_end<7){
                
                for(let i=1;i<floor_end+1;i++){
                    model_list[i].show = true
                }
                for(let j=floor_end;j<model_list.length;j++){
                    model_list[j].show = false
                }
                
            }else if(floor_end == 7){
                for(let i=1;i<8;i++){
                    model_list[i].show = true
                }
                for(let j=8;j<model_list.length;j++){
                    model_list[j].show = false
                }
            }else{
                for(let i=1;i<floor_end+1;i++){
                    model_list[i+1].show = true
                }
                for(let j=floor_end;j<model_list.length+1;j++){
                    model_list[j+1].show = false
                }
            }
        }
        
        
    console.log("完成")
        
    })
    
    
    
    var model_lon = 121.462075;
    var model_lat = 31.21219;
    var heading_ =  165
    // 添加医院大楼模型
    const graphicLayer = new mars3d.layer.GraphicLayer({
        id: 203,
        pid: 98,
        name: "上海瑞金医院",
        show: true,
        flyTo:false
    })
    map.addLayer(graphicLayer)
    floorGraphic1 = new mars3d.graphic.ModelEntity({
        position: [model_lon, model_lat, 0], // 楼栋位置
        style: {
            scale:0.87333,
        distanceDisplayCondition_far:100,
        url: "./gltf/Ruijin2/F1.gltf",
        heading: heading_,
        color:"#ffff00",
        fill:true
        },
        popup:`<p>一楼</p>`,
        rotation:{x:0,y:0,z:180}
    })
    floorGraphic2 = new mars3d.graphic.ModelEntity({
        
        position: [model_lon,model_lat, 0], // 楼栋位置
        style: {
            scale:0.87333,
            distanceDisplayCondition_far:100,
        url: "./gltf/Ruijin2/F2.gltf",
        heading: heading_,
        color:"#ffff00",
        fill:true
        },
        popup:`<p>二楼</p>`,
        rotation:{x:0,y:0,z:180}
    })
    floorGraphic3 = new mars3d.graphic.ModelEntity({
        
        position: [model_lon,model_lat, 0], // 楼栋位置
        style: {
            scale:0.87333,
            distanceDisplayCondition_far:100,
        url: "./gltf/Ruijin2/F3-5.gltf",
        heading: heading_,
        color:"#ffff00",
        fill:true
        },
        popup:`<p>三楼</p>`,
        rotation:{x:0,y:0,z:180}
    })
    floorGraphic4 = new mars3d.graphic.ModelEntity({
        
        position: [model_lon,model_lat, 2.8], // 楼栋位置
        style: {
            scale:0.87333,
            distanceDisplayCondition_far:100,
        url: "./gltf/Ruijin2/F3-5.gltf",
        heading: heading_,
        color:"#ffff00",
        fill:true
        },
        popup:`<p>四楼</p>`,
        rotation:{x:0,y:0,z:180}
    })
    floorGraphic5 = new mars3d.graphic.ModelEntity({
        
        position: [model_lon,model_lat, 5.6], // 楼栋位置
        style: {
            scale:0.87333,
            distanceDisplayCondition_far:100,
        url: "./gltf/Ruijin2/F3-5.gltf",
        heading: heading_,
        color:"#ffff00",
        fill:true
        },
        popup:`<p>五楼</p>`,
        rotation:{x:0,y:0,z:180}
    })
    floorGraphic6 = new mars3d.graphic.ModelEntity({
        
        position: [model_lon,model_lat, 8.4], // 楼栋位置
        style: {
            scale:0.87333,
            distanceDisplayCondition_far:100,
        url: "./gltf/Ruijin2/F3-5.gltf",
        heading: heading_,
        color:"#ffff00",
        fill:true
        },
        
        rotation:{x:0,y:0,z:180}
    })
    floorGraphic7 = new mars3d.graphic.ModelEntity({
        
        position: [model_lon,model_lat, 2.4], // 楼栋位置
        style: {
            scale:0.87333,
        url: "./gltf/Ruijin2/F5-roof.gltf",
        heading: heading_,
        color:"#ffff00",
        fill:true
        },
        popup:`<p>六楼</p>`,
        rotation:{x:0,y:0,z:180}
    })
    floorGraphic8 = new mars3d.graphic.ModelEntity({
        
        position: [model_lon,model_lat, -0.8], // 楼栋位置
        style: {
            scale:0.87333,
        url: "./gltf/Ruijin2/F7-16.gltf",
        heading: heading_,
        color:"#ffff00",
        fill:true
        },
        popup:`<p>七楼</p>`,
        rotation:{x:0,y:0,z:180}
    })
    floorGraphic9 = new mars3d.graphic.ModelEntity({
        
        position: [model_lon,model_lat, 2.1], // 楼栋位置
        style: {
            scale:0.87333,
        url: "./gltf/Ruijin2/F7-16.gltf",
        heading: heading_,
        color:"#ffff00",
        fill:true
        },
        popup:`<p>八楼</p>`,
        rotation:{x:0,y:0,z:180}
    })
    floorGraphic10 = new mars3d.graphic.ModelEntity({
        
        position: [model_lon,model_lat, 5], // 楼栋位置
        style: {
            scale:0.87333,
        url: "./gltf/Ruijin2/F7-16.gltf",
        heading: heading_,
        color:"#ffff00",
        fill:true
        },
        rotation:{x:0,y:0,z:180}
    })
    floorGraphic11 = new mars3d.graphic.ModelEntity({
        
        position: [model_lon,model_lat, 7.9], // 楼栋位置
        style: {
            scale:0.87333,
        url: "./gltf/Ruijin2/F7-16.gltf",
        heading: heading_,
        color:"#ffff00",
        fill:true
        },
        rotation:{x:0,y:0,z:180}
    })
    floorGraphic12 = new mars3d.graphic.ModelEntity({
        
        position: [model_lon,model_lat, 10.7], // 楼栋位置
        style: {
            scale:0.87333,
        url: "./gltf/Ruijin2/F7-16.gltf",
        heading: heading_,
        color:"#ffff00",
        fill:true
        },
        rotation:{x:0,y:0,z:180}
    })
    floorGraphic13 = new mars3d.graphic.ModelEntity({
        
        position: [model_lon,model_lat, 13.5], // 楼栋位置
        style: {
            scale:0.87333,
        url: "./gltf/Ruijin2/F7-16.gltf",
        heading: heading_,
        color:"#ffff00",
        fill:true
        },
        rotation:{x:0,y:0,z:180}
    })
    floorGraphic14 = new mars3d.graphic.ModelEntity({
        
        position: [model_lon,model_lat, 16.3], // 楼栋位置
        style: {
            scale:0.87333,
        url: "./gltf/Ruijin2/F7-16.gltf",
        heading: heading_,
        color:"#ffff00",
        fill:true
        },
        rotation:{x:0,y:0,z:180}
    })
    floorGraphic15 = new mars3d.graphic.ModelEntity({
        
        position: [model_lon,model_lat, 19.1], // 楼栋位置
        style: {
            scale:0.87333,
        url: "./gltf/Ruijin2/F7-16.gltf",
        heading: heading_,
        color:"#ffff00",
        fill:true
        },
        rotation:{x:0,y:0,z:180}
    })
    floorGraphic16 = new mars3d.graphic.ModelEntity({
        
        position: [model_lon,model_lat, 21.9], // 楼栋位置
        style: {
            scale:0.87333,
        fill:true,
        // opacity:0.7,
        // color:"#ffffff",
        url: "./gltf/Ruijin2/F7-16.gltf",
        heading: heading_,
        color:"#ffff00",
        fill:true
        },
        rotation:{x:0,y:0,z:180}
    })
    floorGraphic17 = new mars3d.graphic.ModelEntity({
        
        position: [model_lon,model_lat, 24.7], // 楼栋位置
        style: {
            scale:0.87333,
        url: "./gltf/Ruijin2/F7-16.gltf",
        heading: heading_,
        color:"#ffff00",
        fill:true
        },
        rotation:{x:0,y:0,z:180}
    })
    floorGraphic18 = new mars3d.graphic.ModelEntity({
        
        position: [model_lon,model_lat, -1.4], // 楼栋位置
        style: {
            scale:0.87333,
        url: "./gltf/Ruijin2/L17_220303.gltf",
        heading: heading_,
        color:"#ffff00",
        fill:true
        },
        rotation:{x:0,y:0,z:180}
    })
    floorGraphic19 = new mars3d.graphic.ModelEntity({
        
        position: [model_lon,model_lat, 1.4], // 楼栋位置
        style: {
            scale:0.87333,
        url: "./gltf/Ruijin2/L17_220303.gltf",
        heading: heading_,
        color:"#ffff00",
        fill:true
        },
        rotation:{x:0,y:0,z:180}
    })
    floorGraphic20 = new mars3d.graphic.ModelEntity({
        
        position: [model_lon,model_lat, 4.2], // 楼栋位置
        style: {
            scale:0.87333,
        url: "./gltf/Ruijin2/L17_220303.gltf",
        heading: heading_,
        color:"#ffff00",
        fill:true
        },
        rotation:{x:0,y:0,z:180}
    })
    floorGraphic21 = new mars3d.graphic.ModelEntity({
        
        position: [model_lon,model_lat, 7], // 楼栋位置
        style: {
            scale:0.87333,
        url: "./gltf/Ruijin2/L17_220303.gltf",
        heading: heading_,
        color:"#ffff00",
        fill:true
        },
        rotation:{x:0,y:0,z:180}
    })
    floorGraphic22 = new mars3d.graphic.ModelEntity({
        
        position: [model_lon,model_lat, 9.8], // 楼栋位置
        style: {
            scale:0.87333,
        url: "./gltf/Ruijin2/L17_220303.gltf",
        heading: heading_,
        color:"#ffff00",
        fill:true
        },
        rotation:{x:0,y:0,z:180}
    })
    floorGraphic23 = new mars3d.graphic.ModelEntity({
        
        position: [model_lon,model_lat, 12.6], // 楼栋位置
        style: {
            scale:0.87333,
        url: "./gltf/Ruijin2/L17_220303.gltf",
        heading: heading_,
        color:"#ffff00",
        fill:true
        },
        rotation:{x:0,y:0,z:180}
    })
    floorGraphic24 = new mars3d.graphic.ModelEntity({
        
        position: [model_lon,model_lat, -1.8], // 楼栋位置
        style: {
            scale:0.87333,
            maximumScale:2,
        url: "./gltf/Ruijin2/F22-roof.gltf",
        heading: heading_,
        color:"#ffff00",
        fill:true
        },
    })
    model_list.push(
        floorGraphic1,
        floorGraphic2,
        floorGraphic3,
        floorGraphic4,
        floorGraphic5,
        floorGraphic6,
        floorGraphic7,
        floorGraphic8,
        floorGraphic9,
        floorGraphic10,
        floorGraphic11,
        floorGraphic12,
        floorGraphic13,
        floorGraphic14,
        floorGraphic15,
        floorGraphic16,
        floorGraphic17,
        floorGraphic18,
        floorGraphic19,
        floorGraphic20,
        floorGraphic21,
        floorGraphic22,
        floorGraphic23,
        floorGraphic24,
        )
    
    for(let i = 0;i<model_list.length;i++){
        graphicLayer.addGraphic(model_list[i])
    }
    if(model_list.length>0){
    var ColorHex=new Array('00','33','66','99','CC','FF')
    var SpColorHex=new Array('FF0000','00FF00','0000FF','FFFF00','00FFFF','FF00FF')
    
 
      var colorTable=''
      for (i=0;i<2;i++)  //循环2部分
      {
        for (j=0;j<6;j++) //循环6行
        {
          colorTable=colorTable+'<tr height=12>'
          for (k=0;k<3;k++)
          {
            for (l=0;l<6;l++)
            {
              colorTable=colorTable+'<td onclick="test_box()" class="color_box" width=11 style="background-color:#'+ColorHex[k+i*3]+ColorHex[l]+ColorHex[j]+'">'
            }
          }
        }
      }
      colorTable='<table id="color_fbox" border="1" cellspacing="0" cellpadding="0" style="border-collapse: collapse" bordercolor="000000" style="cursor:hand;">'
          +colorTable+'</table>';
      colorpanel.innerHTML=colorTable
      }
    
}
 
function test_box(){
    console.log("我在外边")
    doclick()
}
function doclick(){
        console.log("我在里面")
          var evt=getEvent();
          var element=evt.srcElement || evt.target;
          console.log(element.style.backgroundColor)
          if (element.tagName=="TD"){
              console.log(element)
            var bg=rgbToHex(element.style.backgroundColor);
                for(let i=0;i<model_list.length;i++){
                        model_list[i].setStyle({
                            color:bg,
                            fill:true,
                            shadows:Cesium.ShadowMode.ENABLED,
                            colorBlendMode:Cesium.ColorBlendMode.HIGHLIGHT,
                            colorBlendAmountEnabled : true ,
                            colorBlendAmount:0.8
                        })
                }
            return bg;
          }
        }
// 图层&目录设备定位
function addMockpoint(){
    var tucengdian = new mars3d.layer.DivLayer({
        id: 155,
        pid: 99,
        name: "设备定位",
        show:false,
        popup: "all",
        flyTo: false
    }); //新建图层
    map.addLayer(tucengdian);
}
function open_msg(e){//轨迹回放方法
    console.log(e)
}
 
// group方法可以将一个数组按照指定长度进行分组
function group(array, subGroupLength) {
      let index = 0 ;
      let newArray = [];
       while (index < array.length) {
          newArray.push(array.slice(index, index += subGroupLength));
      }
      return newArray;
  }
  
  
  // 试加载TXT点云文件
// function addPrimitivesPointFromJSONTest() {
//   var pointPrimitives = null;// 申明点渲染集合
//   pointPrimitives = map.viewer.scene.primitives.add(new Cesium.PointPrimitiveCollection());
//     // 读取TXT文件并将TXT内容转换为数组
//     $.ajax({
//         url: './data/hn4.txt',
//         dataType: 'text',
//         success: function(data) {
//             // console.log(data)
//             datas = data.split(/\s|[\r\n]/)//将txt每行内容根据空格和换行进行切割
//             data_list = datas.map(Number)//将切割后的xyz左边转换为数字格式
//             list = group(data_list,3)//将转换后的数据每六个分为一组
//             // 循环数组,加载点云
//             for (var i = 0; i <list.length; i++) {
//                 var hn_lon = Number(list[i][0])/distance_half+121.461085;
//                 var hn_lat = Number(list[i][1])/distance_half+31.210190;
//                 var hn_h = 300-Number(list[i][2]);
//                 var color_b = Math.floor(hn_h)
//                 if(hn_h<=50){
//                     color = Cesium.Color.fromCssColorString(`rgba(0, ${color_b}, ${color_b}, 1)`)
//                 }else if(hn_h<=80){
//                     color = Cesium.Color.fromCssColorString(`rgba(${color_b}, 0, ${color_b}, 1)`)
//                 }else{
//                     color = Cesium.Color.fromCssColorString(`rgba(${color_b}, ${color_b}, 0, 1)`)
//                 }
//                   var position = Cesium.Cartesian3.fromDegrees(hn_lon,hn_lat,hn_h);
//                   pointPrimitives.add({
//                     pixelSize: 1,
//                     color: color,
//             //         outlineColor: Cesium.Color.BLUE,
//                     outlineWidth: 0,
//                     position: position
//                   });
//                 }
//         }
//     });
// }
 
 
// 添加PCI模型
function addPciModel(){
    var PCI_position_layer = new mars3d.layer.GraphicLayer({
        pid:99,
        name:'new_PCI',
        show:false
    })
    map.addLayer(PCI_position_layer)
    $.ajax({
        type:'get',
        dataType:'json',
        async:true,
        url:get_JSON.ruijin_url+'get_rru_info',
        success:function(data){
            var datas_2 = []
            let datas = data.data.data
            for(let i=0;i<datas.length;i++){
                datas_2.push(datas[i])
            }
            let rru_end = unique(datas)
            console.log(rru_end,"rru_end")
            for(let i=0;i<rru_end.length;i++){
                let  item = datas[i]
                let coneGlow = new mars3d.graphic.CircleEntity({
                  position: Cesium.Cartesian3.fromDegrees(Number(item.Longitude),Number(item.Latitude),0),
                  style: {
                    color:'rgba(255, 254, 253, 1.0)',
                    radius: 4,
                    diffHeight:Number(item.AntHight)
                  },
                  popup:`<p>名称:${item.SitenameCN}</p>
                  <p>地址:${item.SiteAddress}</p>
                  <p>编号:${item.eNodeBID}</p>
                  <p>经度:${item.Longitude}</p>
                  <p>纬度:${item.Latitude}</p>
                  <p>高度:${item.AntHight}</p>`,
                  show:true
                })
                PCI_position_layer.addGraphic(coneGlow)
            }
            for(let i=0;i<datas_2.length;i++){
                let item = datas_2[i]
                for(let j=0;j<rru_end.length;j++){
                    if(item.SitenameCN == rru_end[j].SitenameCN||item.SiteAddress === rru_end[j].SiteAddress){
                        item.Longitude = rru_end[j].Longitude
                        item.Latitude = rru_end[j].Latitude
                        item.AntHight = rru_end[j].AntHight
                        let num = Number(item.DirectionalAngle)
                        let plane_pci
                        let h = Number(item.AntHight)
                        if(item.frequencyRange == '1.8G'){
                            plane_pci = addPCIPlane(item,h-7,num,"#ff0000")
                        }else if(item.frequencyRange == '2.1G'){
                            plane_pci = addPCIPlane(item,h+7,num,"#00ff00")
                        }else{
                            plane_pci = addPCIPlane(item,h,num,"#0000ff")
                        }
                        PCI_position_layer.addGraphic(plane_pci)
                    }
                }
            }
            
        },
        error: function (request, textStatus) {
        
        }
    })
}
 
 
// 封装方法,将rru_info获取到的宏站数据去重
function unique(arr) {
    for ( var i = 0, len = arr.length; i < len; i++ ) {
         for ( var j = i + 1, len = arr.length; j < len; j++ ) {
             if (arr[i].SitenameCN === arr[j].SitenameCN||arr[i].SiteAddress === arr[j].SiteAddress) {
                arr.splice(j, 1 );
                j --;         //每刪除一個數j的值就減1 
                len--;       // j值減小時len也要相應減1(減少循環次數,節省性能)    
                // console.log(j,len)
 
            }
        }
    }
    return arr;
}
 
function addPCIPlane(item,h,heading,color){
    const primitive = new mars3d.graphic.PlaneEntity({
        
        position: [Number(item.Longitude),Number(item.Latitude),h],
        style: {
            plane: new Cesium.Plane(Cesium.Cartesian3.UNIT_X,10.0),
        // plane_normal: ,
        heading:heading,
        dimensions_x: 3.0,
        dimensions_y: 6.0,
        color: color,
        opacity: 0.4,
        
        // 高亮时的样式(默认为鼠标移入,也可以指定type:'click'单击高亮),构造后也可以openHighlight、closeHighlight方法来手动调用
        highlight: {
            opacity: 0.9
        },
        
        },
        popup:`<p>PCI:${item.PCI}</p>
        <p>Sitename:${item.SitenameCN}</p>
        <p>信号:${item.frequencyRange}</p>
        <p>???:${item.EARFCN}</p>
        `,
        description:"文字"
    })
    // PCI_position_layer.addGraphic(primitive)
    return primitive
}
 
 
function addLightMr(){
    ue_trace_layer = new mars3d.layer.GraphicLayer({
        // type:'group',
        id: 104,
        pid: 99,
        name: "设备轨迹",
        show: true,
        popup: "all",
        flyTo: false
    });
    map.addLayer(ue_trace_layer);
 
}
function testLight(){
    var testgraphic = new mars3d.layer.GraphicLayer({
        id: 104,
        pid: 99,
        name: "测试轨迹",
        show: true,
        flyTo: false
    });
    map.addLayer(ue_trace_layer);
}
// function showHistoryPathDetail(itemCode) {
 
//   if (mars3d.widget.isActivate("widgetsTS/taxiRouteReplay/widget.js")) {
//     var detailWiget = mars3d.widget.getClass("widgetsTS/taxiRouteReplay/widget.js");
//     detailWiget.reloadData(itemCode);
//   } else {
//     mars3d.widget.activate({
//       uri: "widgetsTS/taxiRouteReplay/widget.js",
//       params: itemCode,
//     });
//   }
// }
function addCustomLayers() {
    addMsisdnPoint();
    addLightMr();//设备轨迹
    addPciModel();//PCI位置
    openFloor();//瑞金大楼
    addMockpoint();//设备定位点
    addpoint17();
}