wangrong
2025-09-23 40634ebaf5863a599bba8ca2c0575ca079fb8e15
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
<!DOCTYPE html>
<html lang="en">
<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="author" content="通感一体"/>
    <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"/>
    <!-- 标题及搜索关键字 -->
    <meta name="keywords" content="通感一体"/>
    <meta name="description" content="通感一体"/>
    <title>通感一体化</title>
</head>
<style>
    #redcap {
        position: absolute;
        top: 50px;
        left: 100px;
        z-index: 10;
    }
    #alarmInfo {
        display: none;
        position: absolute;
        left: 10px;
        bottom: 10px;
        width: 28%;
        transition: right 0.6s ease;
    }
    #alarmInfo .table {
        margin: 0;
        color: #212529;
        border-radius: 5px;
        background-color: white;
    }
    #alarmInfo .table tbody tr:hover {
        cursor: pointer;
        background-color: rgba(0, 0, 0, .05);
    }
    @media (min-width: 3000px) {
        #myIframe {
            width: 50% !important;
            top: 10px !important;
        }
        #boat_data {
            width: 46.5% !important;
        }
    }
</style>
<script
        type="text/javascript"
        src="./lib/include-lib.js"
        libpath="./lib/"
        include="jquery,layer,toastr,font-awesome,bootstrap,layer,haoutil,mars3d"
></script>
<script src="./js/offlinemap/map_load.js"></script>
<script src="./js/jizhan_boat.js"></script>
<script src="./js/station_video_map.js"></script>
<body>
<div id="container"></div>
<button id="redcap">Redcap站</button>
<!-- <button id="button1"></button>  
<button id="button2"></button>  -->
<div id="alarmInfo" class="left_box">
    <table class="table uav-alarm">
        <colgroup>
            <col style="width: 35%;">
            <col style="width: 45%;">
            <col>
        </colgroup>
        <thead>
        <tr>
            <th>告警时间</th>
            <th>无人机名</th>
            <th>告警描述</th>
        </tr>
        </thead>
        <tbody>
        </tbody>
    </table>
    <table class="table ship-alarm" style="margin-top: 10px;">
        <colgroup>
            <col style="width: 35%;">
            <col style="width: 45%;">
            <col>
        </colgroup>
        <thead>
            <tr>
                <th>告警时间</th>
                <th>船名</th>
                <th>告警描述</th>
            </tr>
        </thead>
        <tbody>
        </tbody>
    </table>
</div>
<div class="right_box" id="contentBox">
    <div class="change2" onclick="toggleContent()"></div>
    <iframe id="myIframe" src="./index2.html"></iframe>
    <div class="boat_data" id="boat_data">
        <div class="boat_left">
            <div style="height: 30px; background-color: #23374a; color: white; padding-left: 10px; display: flex; align-items: center;">
                <span style="flex: 1;">基站监控</span>
                <button onclick="refreshVideo()" style="margin-right: 10px;">🔄 刷新</button>
            </div>
            <iframe id="video" src="" frameborder="0"
                    style="width: 100%; height: calc(100% - 30px); display: none;"></iframe>
        </div>
        <div class="wurenji_data">
            <p style="height: 10%;margin: 0;background-color: rgb(35, 55, 74);color: aliceblue;padding-left: 20px;"
               onclick="openWindow('http:\/\/47.100.95.164:38083/planefp-optimize/#/',600,500)">放大</p>
            <iframe src="http://47.100.95.164:38083/planefp-optimize/#/" frameborder="0"
                    style="width: 100%;height: 90%;"></iframe>
        </div>
    </div>
</div>
 
</body>
<!-- <script src="./js/mqtt.js"></script>
<script src="./js/mqttws.js"></script> -->
 
<script>
    // 航道名
    const CHANNEL_CY = {
        id: 1,
        name: '宸苑航道'
    }
    const CHANNEL_DF = {
        id: 0,
        name: '杜丰航道'
    }
 
    var wd_width = 1900
    let width_ = window.screen.width
    var isHidden = false
    var toggleBtn = document.getElementById('redcap');
    var boat_options = {
        size: BMAP_POINT_SIZE_SMALL,
        shape: BMAP_POINT_SHAPE_CIRCLE,
        color: '#ff0000'
    }
    var wrj_options = {
        size: BMAP_POINT_SIZE_SMALL,
        shape: BMAP_POINT_SHAPE_CIRCLE,
        color: '#fd9319'
    }
    var boat_points = []
    var wrj_points = []
    let css_ = document.createElement('link')
    if (width_ > wd_width) {
        console.log("s")
        css_.href = './css/lage.css'
    } else {
        console.log("l")
        css_.href = './css/small.css'
 
    }
    css_.type = "text/css";
    css_.rel = "stylesheet";
    console.log(css_)
    document.head.appendChild(css_);
 
    let height_ = window.screen.height
    console.log(width_, height_, "宽高")
    var isBoxOpen = false;
    $(document).ready(function () {
        var originalIconSize = new BMap.Size(200, 200);
        // 目标图标尺寸
        var targetIconSize = new BMap.Size(20, 20);
 
        function addLabel_(maker, text, color, x, y) {
            let label = new BMap.Label(text, { offset: new BMap.Size(x, y) });
            // 设置Label的样式
            label.setStyle({
                color: color, // 文本颜色
                fontSize: "12px", // 字体大小
                border: "1px solid #ccc", // 边框
                backgroundColor: "#f5f5f5", // 背景颜色
                padding: "3px", // 内边距
                borderRadius: "3px", // 边框圆角
                boxShadow: "0 1px 5px rgba(0,0,0,0.65)", // 阴影效果
                textAlign: "center", // 文本对齐方式
                // width: "80px" // 标签宽度
            });
            maker.setLabel(label);
        }
 
        // 计算缩放比例
        var scale = targetIconSize.width / originalIconSize.width;
        var baidu_map = new BMap.Map('container'); // 创建Map实例
        baidu_map.centerAndZoom(new BMap.Point(122.118792, 31.1236), 11); // 初始化地图,设置中心点坐标和地图级别
 
        function onTilesLoaded() {
            baidu_map.setCenter(new BMap.Point(122.118792, 31.0736));
            baidu_map.removeEventListener('tilesloaded', onTilesLoaded);
        }
 
        baidu_map.addEventListener('tilesloaded', onTilesLoaded);
        baidu_map.enableScrollWheelZoom(true); // 开启鼠标滚轮缩放
        var myIcon = new BMap.Icon("./img2/shexiangtou2_left.png", new BMap.Size(50, 50));
        // 创建Marker标注,使用小车图标
        var pt = new BMap.Point(121.488792, 31.070236);
        var marker = new BMap.Marker(pt, {
            icon: myIcon
        });
        var myIcon = new BMap.Icon("./img2/wurenji2.png", new BMap.Size(50, 50));
        // 创建Marker标注,使用小车图标
        var pt2 = new BMap.Point(121.3565434886248, 30.84122335627239);
        var marker2 = new BMap.Marker(pt2, {
            icon: myIcon
        });
        // 为按钮1添加点击事件监听器
        var myIcon3 = new BMap.Icon("./img2/shexiangtou2_left.png", new BMap.Size(50, 50));
        // 创建Marker标注,使用小车图标
        var pt3 = new BMap.Point(121.516777, 31.227673);
        var marker3 = new BMap.Marker(pt3, {
            icon: myIcon3
        });
        var pt4 = new BMap.Point(121.381574,31.362422); //121.381474,31.36244
        var marker4 = new BMap.Marker(pt4, {
            icon: myIcon3
        });
        var pt5 = new BMap.Point(121.483551,31.186844); //121.483551,31.186844
        var marker5 = new BMap.Marker(pt5, {
            icon: myIcon3
        });        
        var pt6 = new BMap.Point(121.460129,31.167454); //121.460129,31.167454
        var marker6 = new BMap.Marker(pt6, {
            icon: myIcon3
        });
 
        const markerConfigs = [
            {
                name: '杜丰通感',
                icon: './img2/shexiangtou2_left.png',
                point: new BMap.Point(121.488792, 31.070236),
                labelOffset: [-25, -25],
                color: 'blue',
                messageData: {
                lat: 31.061703,
                lng: 121.47786,
                alt: 310.7,
                heading: 313.7,
                pitch: -18.6,
                name: 'df'
                },
                channel: CHANNEL_DF,
                site: STATION_DF,
                show: 'boat' // 可选值:'boat' | 'uav'
            },
            {
                name: '无人机基地通感',
                icon: './img2/wurenji2.png',
                point: new BMap.Point(121.3565434886248, 30.84122335627239),
                labelOffset: [-30, -25],
                color: 'blue',
                messageData: {
                lat: 30.825031,
                lng: 121.35679,
                alt: 643.2,
                heading: 337.4,
                pitch: -23,
                name: 'dy'
                },
                show: 'uav'
            },
            {
                name: '宬苑通感',
                icon: './img2/shexiangtou2_left.png',
                point: new BMap.Point(121.516777, 31.227673),
                labelOffset: [-25, -25],
                color: 'blue',
                messageData: {
                lat: 31.199828,
                lng: 121.511941,
                alt: 445.6,
                heading: 341.8,
                pitch: -9.9,
                name: 'df'
                },
                channel: CHANNEL_CY,
                site: STATION_CY,
                show: 'boat'
            },
            {
                name: '卫星公司',
                icon: './img2/shexiangtou2_left.png',
                point: new BMap.Point(121.381574, 31.362422),
                labelOffset: [-25, -25],
                color: 'blue',
                messageData: {
                    lat: 31.348842,
                    lng: 121.385574,
                    alt: 643.2,
                    heading: 337.4,
                    pitch: -23,
                    name: 'wxgs'
                },
                show: 'none'
            },
            {
                name: '世博展览馆',
                icon: './img2/shexiangtou2_left.png',
                point: new BMap.Point(121.483551, 31.186844),
                labelOffset: [-25, -25],
                color: 'blue',
                messageData: {
                    lat: 31.196144,
                    lng: 121.480311,
                    alt: 500.6,
                    heading: 170.8,
                    pitch: -22.9,
                    name: 'longhua'
                },
                show: 'none'
            },
            {
                name: '龙华',
                icon: './img2/shexiangtou2_left.png',
                point: new BMap.Point(121.460129, 31.167454),
                labelOffset: [-25, -25],
                color: 'blue',
                messageData: {
                    lat: 31.151454,
                    lng: 121.469129,
                    alt: 445.6,
                    heading: 341.8,
                    pitch: -19.9,
                    name: 'longhua'
                },
                show: 'none'
            }
        ];
 
        let markerObjects = [];
 
        function createMarker(config, index) {
        const icon = new BMap.Icon(config.icon, new BMap.Size(50, 50));
        const marker = new BMap.Marker(config.point, { icon });
        const label = new BMap.Label(config.name, {
            offset: new BMap.Size(...config.labelOffset)
        });
 
        label.setStyle({
            color: config.color,
            fontSize: "12px",
            border: "1px solid #ccc",
            backgroundColor: "#f5f5f5",
            padding: "3px",
            borderRadius: "3px",
            boxShadow: "0 1px 5px rgba(0,0,0,0.65)",
            textAlign: "center"
        });
 
        marker.setLabel(label);
        baidu_map.addOverlay(marker);
 
        marker.addEventListener('click', () => {
            markerObjects.forEach(obj => obj.marker.getLabel().setStyle({ color: 'blue' }));
            label.setStyle({ color: 'red' });
            if (config.messageData) {
                iframe.contentWindow.postMessage(config.messageData, '*');
            }
            document.querySelector('.right_box').style.display = 'block';
            if (config.show === 'boat') {
                document.querySelector('.boat_left').style.display = 'block';
                document.querySelector('.wurenji_data').style.display = 'none';
                showVideoBySite(config.site);
                showAlarmInfo(config.channel);
            } else if (config.show === 'uav') {
                document.querySelector('.boat_left').style.display = 'none';
                document.querySelector('.wurenji_data').style.display = 'block';
            } else {
                document.querySelector('.boat_left').style.display = 'none';
                document.querySelector('.wurenji_data').style.display = 'none';
            }
            if (width_ > wd_width) {
                document.querySelector('.right_box').style.width = '70%';
                document.querySelector('#boat_data').style.width = config.show === 'uav' ? '49%' : '65%';
                document.querySelector('#myIframe').style.width = config.show === 'uav' ? '49%' : '33.33%';
            }
        });
 
        markerObjects.push({ marker, label });
        }
 
        markerConfigs.forEach(createMarker);
 
 
        // 将标注添加到地图
        // 切换按钮
        $(".category_box").click(function () {
            $(".category_box").removeClass("active")
            $(this).addClass("active")
        })
        // 摄像头折叠
        $(".change2").click(function () {
            label_.setStyle({
                color: "blue"
            })
            label_2.setStyle({
                color: "blue"
            })
            // label_3.setStyle({
            //           color:"blue"
            //         })
            // var $titleHead = $(this).closest(".right_box")
            // $titleHead.toggleClass("collapsed")
        })
    })
    // 获取按钮和iframe元素  
    var button1 = document.getElementById('button1');
    var button2 = document.getElementById('button2');
    var iframe = document.getElementById('myIframe');
 
    $(document).on('click', '#alarmInfo tbody tr', function () {
        let alarmId = $(this).data('alarm');
        let channelId = $(this).data('channel');
        let type = $(this).data('type');
        window.open(`http://10.5.226.53:8088/web/template/ywjai/guarantee-dify-channel.html?channel=${channelId}&type=${type}&alarmId=${alarmId}`);
    });
 
    function toggleContent() {
        document.querySelector('.right_box').style.display = 'none';
    }
 
    function openWindow(url, w, h) {
        let left = window.screen.width - w - 20
        let top = window.screen.height - h - 20
        var newWindow = window.open(url, 'cxw', `width=${ w }px,height=${ h }px,left=${ left }px,top=${ top }px`);
 
        // 你可以省略left和top特性,这样浏览器会决定新窗口的位置
        // var newWindow = window.open('https://example.com', '_blank', 'width=800,height=600');
    }
 
    function showVideoBySite(siteName) {
        console.log('基站:')
        console.log(siteName)
        const videoFrame = document.getElementById("video");
        const newSrc = "a.html?site=" + encodeURIComponent(siteName);
        console.log(newSrc)
 
        if (!videoFrame.src.includes(encodeURIComponent(siteName))) {
            videoFrame.src = newSrc;  // 只有不一样时才切换,避免刷新中断
        }
        videoFrame.style.display = "block";
    }
 
    function showAlarmInfo(channel) {
        $.ajax({
            type: 'get',
            data: {
                stationId: channel.id
            },
            url: '/tggz/tg/alarm/alarmInfoList',
            success:function(res){
                let shipHtml = [];
                let uavHtml = [];
                let { code, data, msg } = res;
                if (code !== 0) {
                    console.error(msg);
                    return false;
                }
 
                if (data?.length) {
                    for (let i in data) {
                        let { id, startTime, shipname, description, objectType } = data[i];
                        let html = `<tr data-alarm="${id}" data-channel="${channel.id}" data-type="${objectType === 0 ? 'ship' : 'uav'}">
                                        <td>${startTime ? startTime.replace('T', ' ') : ''}</td>
                                        <td>${shipname || ''}</td>
                                        <td>${description || ''}</td>
                                    </tr>`;
                        if (objectType === 0) {
                            shipHtml.push(html);
                        } else {
                            uavHtml.push(html);
                        }
                    }
                } else {
                    shipHtml.push('...');
                    uavHtml.push('...');
                }
 
                $('#alarmInfo .ship-alarm tbody').html(shipHtml.join(''));
                $('#alarmInfo .uav-alarm tbody').html(uavHtml.join(''));
                $('#alarmInfo').show();
            }
        });
    }
 
    function refreshVideo() {
        const videoFrame = document.getElementById("video");
        const url = new URL(videoFrame.src);
        const site = url.searchParams.get("site");
 
        if (site) {
          const newSrc = "a.html?site=" + encodeURIComponent(site);
          videoFrame.src = newSrc;
          console.log("视频刷新:", newSrc);
        }
    }
</script>
</html>