zhaoxing
2022-08-06 abcb0e14feb3591ed2648a08dac298cb856c0a86
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
<!DOCTYPE html>
<html>
 
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <meta name="viewport"
    content="width=device-width,initial-scale=1,user-scalable=0,minimum-scale=1.0,maximum-scale=1.0" />
 
  <meta name="apple-touch-fullscreen" content="yes" />
  <meta name="apple-mobile-web-app-capable" content="yes" />
  <meta name="apple-mobile-web-app-status-bar-style" content="black" />
  <meta name="format-detection" content="telephone=no" />
  <meta name="x5-fullscreen" content="true" />
  <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1" />
 
  <!--第三方lib-->
  <!-- <script type="text/javascript" src="../lib/include-lib.js" libpath="../lib/"
    include="jquery,jquery.range,bootstrap,bootstrap-checkbox,font-awesome,web-icons,layer,haoutil,nprogress,toastr,admui,turf,echarts-liquidfill,mars3d,mars3d-widget,mars3d-esri"></script> -->
  <script type="text/javascript" src="../lib/include-lib.js?time=20210329" libpath="../lib/"
    include="jquery,jquery.range,bootstrap,bootstrap-checkbox,font-awesome,web-icons,layer,haoutil,nprogress,toastr,admui,turf,echarts-liquidfill,mars3d,mars3d-widget,mars3d-esri"></script>
  <link href="./css/style.css" rel="stylesheet" />
  <link rel="stylesheet" href="./css/time_search.css">
  <link rel="stylesheet" href="./js/bootstrap/bootstrap-datepicker/bootstrap-datetimepicker.css">
  <link href="./css/hn.css" rel="stylesheet" />
  
  <style>
    .disable {
      pointer-events: none;
    }
 
    .time_line {
      color: aquamarine;
      border: 1px solid red;
      margin: 0;
      /* position: absolute;
      z-index: 0;
      top: 10px; */
      width: 100%;
 
    }
 
    .time_box {
      display: inline-block;
      /* position: absolute; */
      z-index: 10;
      width: 10px;
      height: 10px;
      margin-left: 10px;
      border-radius: 50%;
      background-color: aquamarine;
    }
 
    .message {
      visibility: hidden;
    }
 
    .time_box:hover+span {
      visibility: visible;
    }
 
    #timeline::-webkit-scrollbar {
      display: none;
    }
 
    #parentDiv {
      position: absolute;
      right: 10px;
      bottom: 100px;
      width: 300px;
      height: 500px;
    }
  </style>
</head>
 
<body class="dark">
  <!--加载前进行操作提示,优化用户体验-->
  <div id="mask" class="signmask" onclick="removeMask()"></div>
 
  <div id="mars3dContainer" class="mars3d-container"></div>
 
  <div class="infoview topWindows">
    <div class="topBox">
      <div class="topLeft"></div>
      <div class="topCenter">华能石洞口二厂三维实时重建</div>
      <div class="topRight">
        今天是 2022-8-3 星期三
      </div>
  </div>
  </div>
 
  <div class="infoview bottomWindows">
    <div>
      <input id="changqu_btn" type="button" class="btn btn-primary" value="厂区" />
      <input id="meipeng_btn" type="button" class="btn btn-primary" value="煤棚" />
      <input id="pengnei_btn" type="button" class="btn btn-primary" value="棚内" />
    </div>
  </div>
 
 
  <!-- <div id="parentDiv"></div> -->
 
  <!-- 操作按钮栏 -->
  <div class="infoview infoWindows handle">
    <button type="button" id="test2" class="btn btn-primary active" style="width: 100%;">煤棚整体</button>
    <button type="button" id="meipeng" class="btn btn-primary active" style="width: 100%;">煤棚整体</button>
    <button type="button" id="meipeng_qiang_ding" class="btn btn-primary" style="width: 100%;">墙面棚顶</button>
    <button type="button" id="meipeng_pati_madao" class="btn btn-primary" style="width: 100%;">爬梯马道</button>
    <button type="button" id="meipeng_tiejia" class="btn btn-primary" style="width: 100%;">钢结构架</button>
    <!-- <button type="button" id="meipeng_dimian" class="btn btn-primary" style="width: 100%;">煤棚地面</button> -->
 
    <button type="button" id="test_btn" class="btn btn-primary" style="width: 100%;">测试</button>
    <button type="button" id="point_btn" class="btn btn-primary" style="width: 100%;">煤堆</button>
  </div>
  <!-- 时间线 -->
  <!-- <div id="timeline">
  </div> -->
 
 
  <!-- 日历选择框 -->
 
  <div class="infoview infoWindows search" style="display: none">
    <div class="container">
      <form action="" class="form-horizontal">
        <fieldset>
          <div class="controls input-append date form_datetime" data-date="2019-09-16T05:25:07Z"
            data-date-format="dd MM yyyy - HH:ii p" data-link-field="dtp_input1">
            <input size="16" type="text" value="2019-10-01 10:07:00" readonly class="time1">
            <!-- <span class="add-on"><i class="icon-remove"></i></span> -->
            <span class="add-on"><i class="icon-th"></i></span>
          </div>
          <input type="hidden" id="dtp_input1" value="" />
          <div class="controls input-append date form_datetime" data-date="2019-09-16T05:25:07Z"
            data-date-format="dd MM yyyy - HH:ii p" data-link-field="dtp_input1">
            <input size="16" type="text" value="2019-10-01 12:00:00" readonly class="time2">
            <!-- <span class="add-on"><i class="icon-remove"></i></span> -->
            <span class="add-on"><i class="icon-th"></i></span>
          </div>
          <input type="hidden" id="dtp_input1" value="" />
        </fieldset>
      </form>
    </div>
    <button class="search_time_btn" style="background-color: #394582;">查询</button>
  </div>
 
 
 
 
  <!-- 煤堆面板,点击时间轴上的点显示对应煤堆信息 -->
  <div id="meidui_message"></div>
  <script src="./js/socket.io.js"></script>
  <script src="./js/bootstrap/bootstrap-datepicker/bootstrap-datetimepicker.js"></script>
  <script src="./js/bootstrap/bootstrap-datepicker/bootstrap-datetimepicker.zh-CN.js"></script>
  <script src="./js/common.js"></script>
  <script type="text/javascript">
    "use script"; //开发环境建议开启严格模式
 
 
    var map;
    var request;
    var graphicLayer
    var simu_layer
    var simu
    var heading_ = 0
    var work_ = true
    var dou_work
    var dou_data = {
      lon: 121.406729,
      lat: 31.467183,
      height: 14,
      heading: 70
    }
    var dou_params = []
    var model_list = []
    var point_model = []
    var showClockAnimate = false
 
    // var data_url = 'http://127.0.0.1:8001/admin/business/devicegroup/getdata?bid='
    var data_url = 'http://47.92.33.19:8001/admin/business/devicegroup/getdata?bid='
 
    const socket_ = io("http://127.0.0.1:8001?token=123");
    var time_btn = $("#time_line button")
    var model_no = 0
    var distance_half = 111319.5;
    var pointPrimitives = null;
    var time_mars = $('.mars-pannel')
 
 
    window.onload = function () {
 
      var drag = document.querySelectorAll('.search')
 
      for (var i = 0; i < drag.length; i++) {
        (function (j) {
          drag[j].onmousedown = function runs (e) {
 
 
            var e = e || window.event;
            var diffX = e.clientX - drag[j].offsetLeft;
            var diffY = e.clientY - drag[j].offsetTop;
 
 
            if (typeof drag.setCapture != 'undefined') {
              drag.setCapture();
            }
            // pauseEvent(e);
 
            // function pauseEvent (e) {
            //   if (e.stopPropagation) e.stopPropagation()
            //   if (e.preventDefault) e.preventDefault();
            //   e.cancelBubble = true;
            //   e.returnValue = false;
            //   return false;
            // }
 
            document.onmousemove = function (e) {
              var e = e || window.event;
              var left = e.clientX - diffX;
              var top = e.clientY - diffY;
 
              if (left < 0) {
                left = 0;
              } else if (left > window.innerWidth - drag[j].offsetWidth) {
                left = window.innerWidth - drag[j].offsetWidth;
              }
              if (top < 0) {
                top = 0;
              } else if (top > window.innerHeight - drag[j].offsetHeight) {
                top = window.innerHeight - drag[j].offsetHeight;
              }
 
              drag[j].style.left = left + 'px';
              drag[j].style.top = top + 'px';
              if (e.preventDefault) {
                e.preventDefault();
              }
            };
            document.onmouseup = function (e) { //当鼠标弹起来的时候不再移动
              this.onmousemove = null;
              this.onmouseup = null; //预防鼠标弹起来后还会循环(即预防鼠标放上去的时候还会移动)
 
              //修复低版本ie bug
              if (typeof drag[j].releaseCapture != 'undefined') {
                drag[j].releaseCapture();
              }
 
            };
          };
        })(i)
 
      }
 
    };
 
 
 
 
 
 
 
    // 页面初始执行的方法
    $(document).ready(function () {
      request = haoutil.system.getRequest();
      console.log(time_btn)
 
 
 
 
      $.ajax({
        type: 'get',
        dataType: 'json',
        async: false,//同步
        headers: {
          "Access-Control-Allow-Origin": "*"
          // "Accept": "application/json"
        },
        url: `${data_url}get_dou_params`,
        success: function (data) {
          console.log(data, "ajax_data")
          dou_params = data.data
        },
        error: function (request, textStatus) {
 
        }
      })
 
      // 设置日历面板的时间格式和语言
      $('.form_datetime').datetimepicker({
        language: 'zh-CN',  //设置为中文
        format: 'yyyy-mm-dd hh:ii:00',  //设置日期格式
        weekStart: 1,
        todayBtn: 1,
        autoclose: 1,
        todayHighlight: 1,
        startView: 2,
        forceParse: 0,
        showMeridian: 1
      });
 
    })
 
    // widget初始化
    function initWidget (map) {
      haoutil.loading.show();
 
      $.ajax({
        type: "get",
        dataType: "json",
        url: "config/widget.json",
        timeout: 0,
        success: function (widgetCfg) {
          haoutil.loading.hide();
 
          //url如果有传参时的处理
          if (haoutil.isutil.isNotNull(request.widget)) {
            if (request.onlyStart) {
              widgetCfg.openAtStart = [];
            }
            widgetCfg.openAtStart.push({
              uri: request.widget,
              name: request.name || "",
              windowOptions: {
                closeBtn: !request.onlyStart,
              },
              request: request,
            });
            map.flyHome({ duration: 0 });
          }
 
          //初始化widget管理器
          mars3d.widget.init(map, widgetCfg, "./"); //tip: 第3个参数支持定义widget目录的相对路径。
 
          if (window.lastWidgetItem) {
            activateWidget(lastWidgetItem);
            lastWidgetItem = null;
          }
        },
        error: function (XMLHttpRequest, textStatus, errorThrown) {
          haoutil.loading.hide();
          haoutil.alert("config/widget.json文件加载失败!");
        },
      });
      mars3d.widget.on(mars3d.widget.EventType.activated, function (event) {
        console.log("激活了widget", event);
      });
      mars3d.widget.on(mars3d.widget.EventType.disabled, function (event) {
        console.log("释放了widget", event);
      });
    }
 
 
 
    // 配置任务事件,激活对应的widget界面进行任务配置
    function showHistoryPathDetail (logic_id) {
      if (mars3d.widget.isActivate("widgets/rruRouterReplay/widget.js")) {
        var detailWiget = mars3d.widget.getClass("widgets/rruRouterReplay/widget.js");
        detailWiget.reloadData({
          "logic_id": logic_id
        });
      } else {
        mars3d.widget.activate({
          uri: "widgets/rruRouterReplay/widget.js",
          params: {
            "logic_id": logic_id
          }
        });
      }
    }
 
 
 
 
    // 测试socket.io
    socket_.on("comm", (data) => {
      console.log(data, "后端推送")
    })
    socket_.on("data_push", (data) => {
      console.log(data, "后端成功推送")
    })
    socket_.emit("test", { a: 10, b: 20, c: 30 })
    socket_.on("connect", (data) => {
      console.log(data, "用户已连接")
    })
    socket_.on("disconnect", (data) => {
      console.log(data, "用户已断开连接")
    })
    socket_.on("test2", (data) => {
      console.log("test2", data)
    })
 
 
 
 
 
    $("#test2").click(function () {
      socket_.on("comm", (data) => {
        console.log(data, "后端发送过来的")
      })
      socket_.emit("web_push", "123456789")
 
      const start = Date.now();
 
      socket.emit("ping", () => {
        const duration = Date.now() - start;
        console.log(duration);
      });
    })
 
 
    // 点击页面使时间轴详情页面隐藏
    $(document).on('click', function () {
      console.log("ddd")
 
      $("#meidui_message").css({ display: 'none' })//隐藏
    });
 
    $("#meidui_message").on('click', function (event) {
      event.stopPropagation();//阻止冒泡
    })
 
    // 初始化地球参数
    function initMap (options) {
      //合并属性参数,可覆盖config.json中的对应配置
      var mapOptions = mars3d.Util.merge(options, {
        scene: {
          center: {
            lat: 31.460107,
            lng: 121.398442,
            alt: 531.23,
            heading: 33,
            pitch: -23,
            roll: 359.8,
          },
          globe: {
            depthTestAgainstTerrain: false,
          },
        },
        control: {
          infoBox: false,
          timeline: true,
          clockAnimate: false,
          distanceLegend: { left: "100px", bottom: "27px" }
        },
        layers: [
          {
            id: 1,
            name: "华能厂区",
            type: "3dtiles",
            url: "../model/Huanengchangqu_0728/tileset.json",
            position: {
              lng: 121.403176,
              lat: 31.467125,
              alt: -10,
            },
            maximumScreenSpaceError: 1,
            maximumMemoryUsage: 1024,
            highlight: {
              type: mars3d.EventType.click, //默认为鼠标移入高亮,也可以指定click单击高亮
              color: "rgba(255,255,255,0)",
            },
            popup: "all",
            show: true,
            scale: 10,
          },
          {
            id: 2,
            name: "煤棚地面",
            type: "3dtiles",
            url: "../model/meipeng_new/meipeng_dimian/tileset.json",
            position: {
              lng: 121.40609,
              lat: 31.467183,
              alt: 10,
            },
            maximumScreenSpaceError: 1,
            maximumMemoryUsage: 1024,
            highlight: {
              type: mars3d.EventType.click, //默认为鼠标移入高亮,也可以指定click单击高亮
              color: "rgba(255,255,255,.1)",
            },
            popup: "all",
            show: true,
            rotation: { z: 32 },
            scale: 0.1,
          },
          {
            id: 3,
            name: "爬梯马道",
            type: "3dtiles",
            url: "../model/meipeng_new/meipeng_pati_madao/tileset.json",
            position: {
              lng: 121.40609,
              lat: 31.467183,
              alt: 10,
            },
            maximumScreenSpaceError: 1,
            maximumMemoryUsage: 1024,
            highlight: {
              type: mars3d.EventType.click, //默认为鼠标移入高亮,也可以指定click单击高亮
              color: "rgba(255,255,255,.1)",
            },
            popup: "all",
            show: true,
            rotation: { z: 32 },
            scale: 0.1,
          },
          {
            id: 4,
            name: "钢架构架",
            type: "3dtiles",
            url: "../model/meipeng_new/meipeng_tiejia/tileset.json",
            position: {
              lng: 121.40613,
              lat: 31.467183,
              alt: -48,
            },
            maximumScreenSpaceError: 1,
            maximumMemoryUsage: 1024,
            highlight: {
              type: mars3d.EventType.click, //默认为鼠标移入高亮,也可以指定click单击高亮
              color: "rgba(255,255,255,.1)",
            },
            popup: "all",
            show: true,
            rotation: { z: 32 },
            scale: 0.1,
          },
          {
            id: 5,
            name: "墙面顶棚",
            type: "3dtiles",
            url: "../model/meipeng_new/meipeng_qiang_ding/tileset.json",
            position: {
              lng: 121.40609,
              lat: 31.467183,
              alt: 10,
            },
            maximumScreenSpaceError: 1,
            maximumMemoryUsage: 1024,
            highlight: {
              type: mars3d.EventType.click, //默认为鼠标移入高亮,也可以指定click单击高亮
              color: "rgba(255,255,255,.1)",
            },
            popup: "all",
            show: true,
            rotation: { z: 32 },
            scale: 0.1,
          },
          // {
          //   id: 9,
          //   name: "test",
          //   type: "3dtiles",
          //   url: "../model/ytlhz/tileset.json",
          //   position: {
          //     lng: 121.453676,
          //     lat: 31.417225,
          //     alt: -118,
          //   },
          //   maximumScreenSpaceError: 1,
          //   maximumMemoryUsage: 1024,
          //   highlight: {
          //     type: mars3d.EventType.click, //默认为鼠标移入高亮,也可以指定click单击高亮
          //     color: "rgba(255,255,255,0)",
          //   },
          //   popup: "all",
          //   show: true,
          //   scale: 20,
          // }
        ],
      });
 
 
 
 
      var eventTarget = new mars3d.BaseClass()
      //创建三维地球场景
      map = new mars3d.Map("mars3dContainer", mapOptions);
      initWidget(map)
      var clockAnimate = new mars3d.control.ClockAnimate({
        format: "yyyy-MM-dd HH:mm:ss"
      })
      map.addControl(clockAnimate)
 
      // 添加采集设备模型
      simu_layer = new mars3d.layer.GraphicLayer({
        name: "四目设备",
        show: true
      })
      map.addLayer(simu_layer)
      //获取采集设备信息,根据信息添加模型
      $.ajax({
        type: 'get',
        dataType: 'json',
        async: false,//同步
        headers: {
          "Access-Control-Allow-Origin": "*"
          // "Accept": "application/json"
        },
        url: `${data_url}get_simu`,
        success: function (data) {
          console.log(data.data, "simu")
          for (let i = 0; i < data.data.length; i++) {
 
            simu = new mars3d.graphic.ModelEntity({
 
              position: [data.data[i].longitude, data.data[i].latitude, 50], // 楼栋位置
 
              style: {
                // url: "http://112.74.77.127:9100/hn/doulunji/dabi/doulunji_dabi.gltf",
                url: "../model/simu_0322/simu_0322.gltf",
                scale: 0.005,
                color: "#ff0000",
                fill: true
              },
              // 弹出框中打开任务下发表单
              popup: "<br/><p><a href='#' onclick='javascript:showHistoryPathDetail(" + data.data[i].logic_id + ")' >配置任务</a></p>",
              allowDrillPick: false,
            })
            simu_layer.addGraphic(simu)
          }
 
        },
        error: function (request, textStatus) {
 
        }
      })
 
 
 
      try {
        socket_.on("test_test", (data) => {
          console.log(data, "新的测试")
        })
 
      } catch (err) {
        console.log("没有接收到")
      }
 
 
 
 
 
 
      // Mars3D事件轴组件
      clockAnimate.on(mars3d.EventType.click, function (event) {
        if (event.targetType === "label") {
          console.log("单击了时间文本区域", event)
          console.log(eventTarget, "eventTarget")
 
          var startTime = Cesium.JulianDate.toDate(map.clock.startTime)
          var stopTime = Cesium.JulianDate.toDate(map.clock.stopTime)
          var currentTime = Cesium.JulianDate.toDate(map.clock.currentTime)
 
          eventTarget.fire("clickShowClockAnimate", { startTime, stopTime, currentTime })
        }
      })
 
 
      // 创建斗轮机图层
      graphicLayer = new mars3d.layer.GraphicLayer({
        name: "斗轮机",
        show: true
      })
      map.addLayer(graphicLayer)
      var dou_parent = new Cesium.Entity()
      // 加载斗轮机不同的部件
      var dou1 = new mars3d.graphic.ModelEntity({
        position: [121.406729, 31.467183, 14], // 楼栋位置
        style: {
          url: "http://112.74.77.127:9100/hn/doulunji/dizuo/dizuo.gltf",
          scale: 0.6,
          heading: 120
        }
      })
      graphicLayer.addGraphic(dou1)
 
      var dou2 = new mars3d.graphic.ModelEntity({
 
        position: [121.406729, 31.467183, 14], // 楼栋位置
 
        style: {
          url: "http://112.74.77.127:9100/hn/doulunji/dabi/doulunji_dabi.gltf",
          // url: "https://a.amap.com/jsapi_demos/static/gltf/Duck.gltf",
          scale: 0.6
        },
        popup: "<br/><p><a href='#' onclick='javascript:showHistoryPathDetail(" + "12345" + ")' >配置任务</a></p>",
        allowDrillPick: false,
      })
      graphicLayer.addGraphic(dou2)
 
      var dou3 = new mars3d.graphic.ModelEntity({
 
        position: [121.406729, 31.467183, 14], // 楼栋位置
        style: {
          url: "http://112.74.77.127:9100/hn/doulun_0322/doulun_0322.gltf",
          runAnimations: true,
          scale: 0.6
        },
        poup: '<p>我是斗轮</p>',
        allowDrillPick: false,
      })
      graphicLayer.addGraphic(dou3)
 
      var dou4 = new mars3d.graphic.ModelEntity({
 
        position: [121.406729, 31.467183, 14], // 楼栋位置
        style: {
          url: "http://112.74.77.127:9100/hn/doulunji/zhuzhou/zhuzhou.gltf",
          heading: 0,
          scale: 0.6
        },
        drawShow: false,
        poup: '<p>我是斗轮</p>',
        tooltip: '<p>我是斗轮</p>',
        allowDrillPick: false,
      })
      graphicLayer.addGraphic(dou4)
 
 
      console.log(this.dou3, "dou3")
 
 
 
 
      // 通过ID获取煤棚模型
      let other_wall_model = map.getLayer(0, "id");
      // let changqu_model = map.getLayer(1, "id");
      let dimian_model = map.getLayer(2, "id");
      let pati_madao_model = map.getLayer(3, "id");
      let tiejia_model = map.getLayer(4, "id");
      let qiang_ding_model = map.getLayer(5, "id");
 
 
 
 
      // 煤棚部分的显示与隐藏
      $("#meipeng").click(function () {
        //other_wall_model.show = true;
        pati_madao_model.show = true;
        dimian_model.show = true;
        tiejia_model.show = true;
        qiang_ding_model.show = true;
      });
 
      // 点击隐藏与显示厂区煤棚
      $("#meipeng_qiang_ding").click(function () {
        if (qiang_ding_model.show == false) {
          qiang_ding_model.show = true;
        } else {
          qiang_ding_model.show = false;
        }
      });
      $("#meipeng_pati_madao").click(function () {
        if (pati_madao_model.show == false) {
          pati_madao_model.show = true;
        } else {
          pati_madao_model.show = false;
        }
      });
      $("#meipeng_tiejia").click(function () {
        if (tiejia_model.show == false) {
          tiejia_model.show = true;
        } else {
          tiejia_model.show = false;
        }
      });
      // $("#meipeng_dimian").click(function () {
      //   console.log(dimian_model);
      //   if (dimian_model.show == false) {
      //     dimian_model.show = true;
      //   } else {
      //     dimian_model.show = false;
      //   }
      // });
 
      // 点击时间轴切换煤堆模型
      $(document).on('click', '.time_box', function (e) {
        e.stopPropagation();//阻止冒泡
        $("#meidui_message").empty()
        let time_ = e.target.nextSibling.nextSibling.textContent;
        let plan_box = ''
        $("#meidui_message").css({ display: 'block' });
        $.ajax({
          type: 'get',
          dataType: 'json',
          async: false,//同步
          headers: {
            "Access-Control-Allow-Origin": "*"
          },
          url: `${data_url}get_plan_by_time&index_=${time_}`,
          success: function (data) {
            console.log(data, "NO_data")
            if (data.data.length > 0) {
              plan_box = `
            <p class='p_text'><span class='span_text'>煤堆:</span>${data.data[0].plan_name}</p>
            <p class='p_text'><span class='span_text'>煤种:</span>${data.data[0].coal_marker}</p>
            <p class='p_text'><span class='span_text'>重量:</span>${data.data[0].coal_weight}吨</p>
            <p class='p_text'><span class='span_text'>体积:</span>${data.data[0].coal_volume}立方米</p>
            `
 
              $("#meidui_message").append(plan_box)
            } else {
              plan_box = '暂无数据'
              $("#meidui_message").append(plan_box)
            }
 
            let data_path = data.data[0].data_path
            if (pointPrimitives) {
              pointPrimitives.destroy(true)
            }
            $.ajax({
              url: data_path,
              dataType: 'text',
              success: function (data) {
                addPointCloud(data)
              }
            });
 
          },
          error: function (request, textStatus) {
          }
        })
 
      })
 
 
      // 请求数据库数据,对斗轮机模型进行操作
      $("#test_btn").click(function () {
        // openTimeBox()
        $("#test_btn").addClass("disable");
        console.log(dou_params)
        if (model_no < dou_params.length - 1) {
          model_no++
        } else {
          model_no = 0
        }
        let item = dou_params[model_no]
        dou_move(item.longitude, item.latitude, item.elevation, item.heading_angle)
 
        setTimeout(function () {
          $("#test_btn").removeClass("disable");
        }, 5000);
      })
 
 
      time_btn.click(function (e) {
        for (let i = 0; i < time_btn.length; i++) {
          console.log(time_btn[i].text)
        }
      })
      // 封装斗轮机工作移动方法
      function dou_move (lon, lat, h, heading_angle) {
        dou1.moveTo({
          position: [lon, lat, h]
        })
        dou2.moveTo({
          position: [lon, lat, h]
        })
        dou3.moveTo({
          position: [lon, lat, h]
        })
        dou4.moveTo({
          position: [lon, lat, h]
        })
        dou2.setStyle({
          heading: heading_angle
        })
        dou3.setStyle({
          heading: heading_angle
        })
        dou4.setStyle({
          heading: heading_angle
        })
      }
 
 
      // 斗轮机工作或暂停(对应斗轮机动画)
      $("#dou_work").click(function () {
        if (dou3.options.style.runAnimations == false) {
          dou3.setStyle({
            clampAnimations: false,
            runAnimations: true,
            direction: true,
            time: 5
          })
        } else {
          dou3.setStyle({
            clampAnimations: false,
            runAnimations: false,
            direction: true,
            time: 5
          })
        }
      })
 
 
 
 
 
 
 
 
      // 斗轮机旋转
      $("#dou_rote").click(function () {
        // 无动画效果的旋转
        dou_data.heading += 20
        dou2.setStyle({
          heading: dou_data.heading
        })
        dou3.setStyle({
          heading: dou_data.heading
        })
        dou4.setStyle({
          heading: dou_data.heading
        })
      })
 
      // 煤堆按钮  点击显示与隐藏时间轴和日历
      $("#point_btn").click(function () {
        $("#timeline").css({ display: 'none' })
        $(".search").toggle();
        // console.log(search)
      })
 
 
      // 给功能按钮添加样式
      $(function () {
        $(".handle > button").click(function () {
          $("button[class='active']").removeAttr("class");
          $(this).addClass("active");
        });
      });
 
 
 
      // group方法可以将一个数组按照指定长度进行分组
      function group (array, subGroupLength) {
        let index = 0;
        let newArray = [];
        while (index < array.length) {
          newArray.push(array.slice(index, index += subGroupLength));
        }
        return newArray;
      }
 
      // 封装加载点云方法
      function addPointCloud (data) {
        // 申明点渲染集合
        pointPrimitives = map.viewer.scene.primitives.add(new Cesium.PointPrimitiveCollection());
        datas = data.split(/\s|[\r\n]/)//将txt每行内容根据空格和换行进行切割
        data_list = datas.map(Number)//将切割后的xyz左边转换为数字格式
        list = group(data_list, 3)//将转换后的数据每3个分为一组
        // 循环数组,加载点云
        for (var i = 0; i < list.length; i++) {
          // 真实参数
          // var hn_lon = Number(list[i][0]) / distance_half + 121.398442;
          // var hn_lat = Number(list[i][1]) / distance_half + 31.460107;
          // var hn_h = 300 - Number(list[i][2]);
          // 缩小煤堆所用参数
          var hn_lon = Number(list[i][0]) / 151319.5 + 121.405902;
          var hn_lat = Number(list[i][1]) / 151319.5 + 31.467607;
          var hn_h = 200 - 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
          });
 
        }
      }
 
 
 
 
      // 选择时间显示所选时间段的时间轴
      $(".search_time_btn").click(function () {
        $("#timeline").css({ display: 'block' })
        $("#timeline").empty()
        let time1 = $(".time1").val()
        let time2 = $(".time2").val()
        $.ajax({
          type: 'get',
          dataType: 'json',
          async: false,//同步
          headers: {
            "Access-Control-Allow-Origin": "*"
            // "Accept": "application/json"
          },
          url: `${data_url}get_point_by_time&time1=${time1}&time2=${time2}`,
          success: function (data) {
            console.log(data, "point_data")
            point_model = data.data
            var time_box_html = ''
            for (let i = 1; i < point_model.length + 1; i++) {
              time_box_html += `<span class="time_box"></span>
              <span class="message">${point_model[i - 1].createTime}</span>`
            }
            $("#timeline").append(time_box_html)
 
          },
          error: function (request, textStatus) {
 
          }
        })
      })
 
 
      $("#changqu_btn").click(function () {
        qiang_ding_model.show = true;
        pati_madao_model.show = true;
        tiejia_model.show = true;
        map.setCameraView({
          lat: 31.460107,
          lng: 121.398442,
          alt: 531.23,
          heading: 33,
          pitch: -23,
        });
      })
 
      $("#meipeng_btn").click(function () {
        qiang_ding_model.show = true;
        pati_madao_model.show = true;
        tiejia_model.show = true;
        map.setCameraView({
          lat: 31.462920,
          lng: 121.405911,
          alt: 210,
          heading: 356,
          pitch: -20,
        });
      })
 
      $("#pengnei_btn").click(function () {
 
        pati_madao_model.show = false;
        tiejia_model.show = false;
        map.setCameraView({
          lat: 31.466055,
          lng: 121.406275,
          alt: 40,
          heading: 7,
          pitch: -14,
        });
      })
 
 
      //键盘漫游
      map.keyboardRoam.setOptions({
        moveStep: 0.1, //平移步长 (米)。
        dirStep: 50, //相机原地旋转步长,值越大步长越小。
        rotateStep: 0.3, //相机围绕目标点旋转速率,0.3-2.0
        minPitch: 0.1, //最小仰角  0-1
        maxPitch: 0.95, //最大仰角  0-1
      });
      map.keyboardRoam.enabled = true; //开启键盘漫游
    }
 
 
 
 
  </script>
</body>
 
</html>