alarmAnalysis.vue
20.5 KB
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
<!--
* @Author: 'wangzhihui' '1733904062@qq.com'
* @Date: 2024-11-28 16:37:15
* @LastEditors: limin
* @LastEditTime: 2026-07-16 15:09:26
* @FilePath: \oEshield\src\pages\monitor\alarmAnalysis.vue
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>
<div class="main-container">
<div id="alarmMap" class="map-container"></div>
<div class="left-box" v-show="boxShow">
<!-- 饼图组件 -->
<ParCharts
class="pie"
ref="pieChartsRef"
id="pie-chart"
height="220px"
:list="pieList"
/>
<!-- 风险分析 -->
<div class="analy-box">
<div class="top-box">
<template v-if="alarmData.data.length">
<div
v-for="item in alarmData.data"
:key="item"
class="top-box-item"
>
<div class="top-box-item-left">{{ item.alarmName }}</div>
<div :class="['top-box-item-right', 'item' + item.alarmLevel]">
<!-- <div :class="['item', item.alarmLevel <= 5 ? 'item1' : 'item1-grey']"></div>
<div :class="['item', item.alarmLevel <= 4 ? 'item2' : 'item-grey']"></div>
<div :class="['item', item.alarmLevel <= 3 ? 'item3' : 'item-grey']"></div>
<div :class="['item', item.alarmLevel <= 2 ? 'item4' : 'item-grey']"></div>
<div :class="['item', item.alarmLevel <= 1 ? 'item5' : 'item5-grey']"></div> -->
</div>
</div>
</template>
<div class="top-box-none" v-else>
<div class="dask-bg">
<div class="top-box-item">
<div class="top-box-item-left">防拆报警</div>
<div class="top-box-item-right-none"></div>
</div>
<div class="top-box-item">
<div class="top-box-item-left">高危区域内长停</div>
<div class="top-box-item-right-none"></div>
</div>
<div class="top-box-item">
<div class="top-box-item-left">双设备分离</div>
<div class="top-box-item-right-none"></div>
</div>
<div class="top-box-item">
<div class="top-box-item-left">安装点长停</div>
<div class="top-box-item-right-none"></div>
</div>
</div>
<div class="dask">
<div>车辆无警情触发</div>
</div>
</div>
</div>
<div class="middle-box">
<div><span class="dot dot-1"></span>无风险</div>
<div><span class="dot dot-2"></span>低风险</div>
<div><span class="dot dot-3"></span>中风险</div>
<div><span class="dot dot-4"></span>高风险</div>
<div><span class="dot dot-5"></span>极高风险</div>
</div>
<div class="bottom-box">
<div class="bottom-box-item">
<div class="bottom-box-item-left">常驻地:</div>
<div class="bottom-box-item-right">
{{ alarmData.residence || "-" }}
</div>
</div>
<div class="bottom-box-item">
<div class="bottom-box-item-left">预测家庭地址:</div>
<div class="bottom-box-item-right">
{{ alarmData.homeAddress || "-" }}
</div>
</div>
<div class="bottom-box-item">
<div class="bottom-box-item-left">预测工作地址:</div>
<div class="bottom-box-item-right">
{{ alarmData.workAddress || "-" }}
</div>
</div>
</div>
</div>
</div>
<div class="right-box" v-show="boxShow">
<!-- 用车行为分析 -->
<div class="use-car-box">
<div class="title">
用车行为分析
<!-- <div
class="detail-btn"
v-if="pieList && pieList.length"
@click="goDetailPage()"
> -->
<div
class="detail-btn"
@click="goDetailPage()"
>
风险评估详情
</div>
</div>
<div class="x-name" v-if="xAxisDataList.length">
<span>{{ linetype == 1 ? "周" : "天" }}</span
><span v-if="lineChartsYear">-{{ lineChartsYear }}年</span>
</div>
<div class="line-charts" v-if="xAxisDataList.length">
<LineCharts
id="useCarCharts"
ref="useCarChartsRef"
height="250px"
:linetype="linetype"
:dataList="useCarData"
:xAxisData="xAxisDataList"
:lineChartsYear="lineChartsYear"
></LineCharts>
</div>
<div v-else class="empty-box">
<img
src="https://wx.glsx.com.cn/upload/biz/501829f0-6c34-443c-bf56-ae94072a6619.png"
alt=""
/>
<div>暂无里程数据</div>
</div>
</div>
<!-- 基本信息 -->
<div class="detail-box">
<div class="title">基本信息</div>
<div>
<div class="detail-msg">
<div class="detail-msg-left">承租人姓名:</div>
<div class="detail-msg-right">
{{ basicData.lesseeName || "-" }}
</div>
</div>
<div class="detail-msg">
<div class="detail-msg-left">店面名称:</div>
<div class="detail-msg-right">{{ basicData.shopName || "-" }}</div>
</div>
<div class="detail-msg">
<div class="detail-msg-left">客户姓名:</div>
<div class="detail-msg-right">{{ basicData.userName || "-" }}</div>
</div>
<div class="detail-msg">
<div class="detail-msg-left">业务工单号:</div>
<div class="detail-msg-right">
{{ basicData.workOrderNo || "-" }}
</div>
</div>
<div class="detail-msg">
<div class="detail-msg-left">车架号:</div>
<div class="detail-msg-right">{{ basicData.vin || "-" }}</div>
</div>
<div class="detail-msg">
<div class="detail-msg-left">创建时间:</div>
<div class="detail-msg-right">
{{ basicData.createTime || "-" }}
</div>
</div>
<div class="detail-msg">
<div class="detail-msg-left">设备状态:</div>
<template
v-if="
basicData.deviceInformationVOList &&
basicData.deviceInformationVOList.length
"
>
<div class="detail-msg-right">
<div
class="detail-msg-desc"
v-for="item in basicData.deviceInformationVOList"
>
<div class="sn">{{ item.sourceStr }}-{{ item.sn }}</div>
<div v-show="item.deviceStateStr">
{{ item.deviceStateStr }}
</div>
<div>定位-{{ item.address || " --" }}</div>
</div>
</div>
</template>
<template v-else>
<div class="detail-msg-desc">--</div>
</template>
</div>
</div>
</div>
</div>
<!-- 热力图 -->
<div class="hot-box">“历史停留”热力图</div>
</div>
</template>
<script>
import ParCharts from "./ParCharts.vue";
import mapService from "@/utils/mapBService.js";
import LineCharts from "./LineCharts.vue";
import { services } from "@/api";
import "utils/mapEvent.js";
import EventBus from "../../event-bus";
import {
GET_STAY_POINTLIST,
GET_BASIC_INFORMATION,
GET_RESIDENT_INFORMATION,
GET_ALARM_POINTLIST,
GET_USER_BEHAVIOR_INFORMATION,
GET_HISTORY_LOCATION,
} from "@/api/services/monitor";
const MONITOR_SERVICE = services.monitor;
export default {
name: "OEshieldAlarmAnalysis",
components: { ParCharts, LineCharts },
data() {
return {
resizeObserver: null,
AMap: null,
mapObj: null,
mapLoading: false,
isInitMap: false,
num: 4,
basicData: {},
alarmData: {
data: [],
residence: "",
homeAddress: "",
workAddress: "",
},
useCarData: [],
xAxisDataList: [],
pieList: [],
resultList: [],
linetype: 1,
boxShow: false,
lineChartsYear: "",
};
},
mounted() {
const _vehicleId = this.$route.query.vehicleId
this.vehicleId = _vehicleId
this.initBMap();
this.resetWidth();
},
methods: {
goDetailPage() {
this.$router.push({
name: "riskAssessDetail",
query: {
vehicleId: this.vehicleId,
vin: this.basicData.vin,
},
});
},
resetWidth() {
const homePage = document.querySelector(".desktop-left-sider");
// 创建 ResizeObserver 对象
this.resizeObserver = new ResizeObserver((entries) => {
console.log(111111);
// 当元素大小发生变化时执行的回调函数
for (let entry of entries) {
const width = entry.contentRect.width;
let myElement = document.querySelector(".main-container");
if (width == 0) {
myElement.style.width = "100%";
myElement.style.left = "0";
}
if (width == 200) {
myElement.style.width = "calc(100% - 200px)";
myElement.style.left = "200px";
}
}
});
// 开始观察目标元素的大小变化
homePage && this.resizeObserver.observe(homePage);
},
async initBMap() {
this.mapObj = await mapService.init("alarmMap");
window.AMap = this.mapObj;
AMap.invoke("LocalCity", (res) => {
AMap.invoke('panTo',res.center)
});
this.isInitMap = true;
this.boxShow = true;
this.getStayPointList(this.vehicleId);
this.getBasicInformation(this.vehicleId);
this.getResidentInformation(this.vehicleId);
this.getAlarmInformation(this.vehicleId);
this.getUserBehaviorInformation(this.vehicleId);
},
// 设备停留点查询
getStayPointList(vehicleId) {
EventBus.$emit("uiMap.historyLocation.destroy");
GET_STAY_POINTLIST({ vehicleId }).then((res) => {
if (res.code != 200) {
this.$message({
type: "error",
message: res.message,
});
return;
}
let _data = res.data || [];
if (!_data.length) {
this.$message({
type: "info",
message: "暂无历史停留数据",
});
return;
}
_data.forEach((item, idx) => {
item.idx = idx;
item.name = item.ownerName || "--";
item.sn = item.sn || "--";
item.vin = item.vin || "--";
item.begintime = item.beginTime;
item.endtime = item.endTime;
item.transferAddress = item.address || "--"; // 取后端返回address
});
this.resultList = _data;
EventBus.$emit("uiMap.historyLocation.draw", _data);
});
},
// 获取车辆基本信息
getBasicInformation(vehicleId) {
GET_BASIC_INFORMATION({ vehicleId }).then((res) => {
if (res.code != 200) {
this.$message({
type: "error",
message: res.message,
});
return;
}
this.basicData = res.data;
});
},
// 预测家庭地址和预测工作地址查询
getResidentInformation(vehicleId) {
GET_RESIDENT_INFORMATION({ vehicleId }).then((res) => {
if (res.code != 200) {
this.$message({
type: "error",
message: res.message,
});
return;
}
this.alarmData.residence = res.data.residence;
this.alarmData.homeAddress = res.data.homeAddress;
this.alarmData.workAddress = res.data.workAddress;
});
},
// 设备警情数据查询
getAlarmInformation(vehicleId) {
GET_ALARM_POINTLIST({ vehicleId }).then((res) => {
if (res.code != 200) {
this.$message({
type: "error",
message: res.message,
});
return;
}
this.alarmData.data =
res.data.length > 6 ? res.data.slice(0, 6) : res.data;
let _list = res.data;
if (_list.length === 0) {
this.$refs.pieChartsRef.draw();
return;
}
_list[0].value = (1 / _list[0].alarmLevel) * 100;
this.pieList.push(_list[0]);
this.$refs.pieChartsRef.draw();
});
},
// 用户行为数据查询
getUserBehaviorInformation(vehicleId) {
GET_USER_BEHAVIOR_INFORMATION({ vehicleId }).then((res) => {
if (res.code != 200) {
this.$message({
type: "error",
message: res.message,
});
return;
}
let _dataList =
res.data.statisticsType == 1
? res.data.userBehaviorWeekDTOList
: res.data.userBehaviorDayDTOList;
_dataList ? _dataList : [];
if (_dataList.length == 0) {
this.useCarData = [];
return;
}
this.linetype = res.data.statisticsType;
let _int = res.data.statisticsType == 1 ? "weekInt" : "dayInt";
let _type = res.data.statisticsType == 1 ? "weekNum" : "dayNum";
this.lineChartsYear = _dataList[_dataList.length - 1].yearInt || "";
_dataList.forEach((item) => {
res.data.statisticsType == 1
? this.xAxisDataList.push(item[_int])
: this.xAxisDataList.push(item.monthInt + "." + item[_int]);
this.useCarData.push(item[_type]);
});
setTimeout(() => {
this.$refs.useCarChartsRef.drawBarLine();
}, 1000);
});
},
},
// async created() {
// EventBus.$on("uiMap.historyLocation.transferSuccess", (data) => {
// this.resultList = [].concat(data);
// });
// },
beforeDestroy() {
this.resizeObserver.disconnect();
// this.checkLoadedTimeoutId && window.clearTimeout(this.checkLoadedTimeoutId);
},
};
</script>
<style lang="scss" scoped>
.analy-box,
.detail-box {
/* 修改垂直滚动条 */
&::-webkit-scrollbar {
width: 2px; /* 修改宽度 */
}
/* 修改滚动条轨道背景色 */
&::-webkit-scrollbar-track {
background-color: #fff;
}
/* 修改滚动条滑块颜色 */
&::-webkit-scrollbar-thumb {
background-color: #181c36e6;
}
/* 修改滚动条滑块悬停时的颜色 */
&::-webkit-scrollbar-thumb:hover {
background-color: #181c36e6;
}
}
.main-container {
position: fixed;
width: calc(100% - 200px);
height: calc(100% - 60px);
top: 60px;
left: 200px;
background: #fff;
padding: 0;
}
.map-container {
/* position: fixed;
width: calc(100% - 200px);
height: calc(100% - 60px);
top: 60px;
left: 200px;
background: #fff;
padding: 0; */
}
.left-box {
position: absolute;
top: 10px;
left: 26px;
z-index: 9999;
}
.pie {
width: 300px;
height: 270px;
background: #181c36;
box-shadow: 0 4px 6px 0 #00000014;
z-index: 9999;
}
.analy-box {
margin-top: 8px;
width: 300px;
max-height: 420px;
border-radius: 8px;
box-sizing: border-box;
overflow-y: auto;
overflow-x: hidden;
background: rgba(24, 28, 54, 0.9);
box-shadow: 0 4px 6px 0 #00000014;
box-sizing: border-box;
padding: 30px 16px 16px;
z-index: 9999;
.top-box {
position: relative;
.top-box-none {
position: relative;
width: 100%;
height: 130px;
.dask-bg {
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
justify-content: center;
}
.dask {
position: absolute;
z-index: 2;
left: 0;
top: 0;
right: 0;
bottom: 0;
width: 100%;
height: 100%;
border-radius: 8px;
background-color: rgba(82, 89, 141, 0.2);
backdrop-filter: blur(10px);
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
font-weight: 600;
font-size: 21px;
color: #ffffff;
}
}
&-item {
display: flex;
align-items: center;
margin-bottom: 16px;
.top-box-item-left {
font-weight: 400;
font-size: 12px;
color: #ffffff;
text-align: center;
width: 100px;
margin-right: 12px;
}
.top-box-item-right {
width: 140px;
height: 12px;
border-radius: 6px;
background: #46495e;
}
.item5 {
background: #4ed5d7;
}
.item4 {
background: #58d068;
}
.item3 {
background: #f7d310;
}
.item2 {
background: #f38906;
}
.item1 {
background: #f23204;
}
&-right-none {
width: 140px;
height: 12px;
background: #7a87d3;
border-radius: 6px;
}
}
&-item:last-child {
margin-bottom: 0;
}
.tips {
position: absolute;
top: 42px;
left: 158px;
font-weight: 600;
font-size: 14px;
color: #b5b5b5;
-webkit-text-stroke: 0.5px #181c36;
}
}
.middle-box {
display: flex;
justify-content: space-around;
width: 100%;
font-size: 10px;
color: #ffffffb3;
margin: 20px 0;
.dot {
width: 6px;
height: 6px;
border-radius: 50%;
display: inline-block;
margin-right: 4px;
vertical-align: middle;
}
.dot-1 {
background: #7481c3;
}
.dot-2 {
background: #58d068;
}
.dot-3 {
background: #f7d310;
}
.dot-4 {
background: #f38906;
}
.dot-5 {
background: #f23204;
}
}
.bottom-box {
&-item {
display: flex;
font-weight: 400;
font-size: 14px;
margin-top: 16px;
&-left {
min-width: 84px;
text-align: right;
font-family: PingFangSC-Regular;
font-weight: 400;
font-size: 12px;
color: #a3a4af;
}
&-right {
font-family: PingFangSC-Regular;
line-height: 17px;
font-weight: 400;
font-size: 12px;
color: #e5e5e8;
}
}
}
}
.right-box {
position: absolute;
top: 10px;
right: 26px;
z-index: 9999;
.title {
display: flex;
align-items: center;
justify-content: space-between;
.detail-btn {
cursor: pointer;
width: 116px;
text-align: center;
color: #fff;
height: 32px;
line-height: 32px;
background: #0077ff;
border-radius: 4px;
}
}
}
.detail-box {
margin-top: 8px;
width: 300px;
max-height: 420px;
overflow-y: auto;
overflow-x: hidden;
background: rgba(24, 28, 54, 0.9);
border-radius: 8px;
box-shadow: 0 4px 6px 0 #00000014;
z-index: 9999;
box-sizing: border-box;
padding: 16px;
.title {
font-weight: 500;
font-size: 14px;
color: #158bff;
margin-bottom: 10px;
}
.detail-msg {
display: flex;
justify-content: space-between;
font-weight: 400;
font-size: 14px;
margin-bottom: 8px;
&:last-child {
margin-bottom: 0;
}
&-left {
font-family: PingFangSC-Regular;
font-weight: 400;
font-size: 12px;
color: #a3a4af;
min-width: 72px;
text-align: right;
}
&-right {
flex: 1;
font-family: PingFangSC-Regular;
font-weight: 400;
font-size: 12px;
color: #e5e5e8;
}
.detail-msg-desc {
color: #e5e5e8;
.sn {
color: #2994ff;
}
& div {
margin-bottom: 1px;
line-height: 17px;
}
}
}
}
.use-car-box {
width: 300px;
height: 270px;
background: rgba(24, 28, 54, 0.9);
border-radius: 8px;
box-sizing: border-box;
padding: 16px;
box-shadow: 0 4px 6px 0 #00000014;
z-index: 9999;
position: relative;
.x-name {
color: #6e7079;
position: absolute;
right: 20px;
top: 50px;
}
.title {
font-weight: 500;
font-size: 14px;
color: #158bff;
}
.empty-box {
height: 250px;
font-weight: 400;
font-size: 14px;
color: #999999;
text-align: center;
margin-top: 40px;
img {
width: 86px;
height: 86px;
}
}
}
.hot-box {
position: absolute;
bottom: 0;
left: 50%;
transform: translateX(-50%);
width: 254px;
height: 48px;
background: #333336cc;
box-shadow: 0 4px 6px 0 #00000014;
border-radius: 24px 24px 0 0;
font-weight: 600;
font-size: 20px;
color: #ffffff;
text-align: center;
line-height: 48px;
z-index: 9999;
}
.line-charts {
padding-left: 10px;
}
</style>