DeviceList1078.vue
44.2 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
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
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
<template>
<div v-loading="loading" id="devicePosition" style="width:100vw; height: 91vh">
<el-container v-loading="loading" style="height: 91vh;" element-loading-text="拼命加载中">
<el-aside width="300px" style="background-color: #ffffff">
<device1078-tree :tree-data="sourceValue" @node-click="nodeClick"></device1078-tree>
</el-aside>
<el-container>
<el-header height="5vh" style="text-align: left;font-size: 17px;line-height:5vh;width:90%">
<el-tag size="small" style="margin-left: 15px;" v-if="simNodeData">
<span v-if="channelData">{{`设备:${simNodeData.code} - 通道:${channelData.name}`}}</span>
<span v-else>{{`设备:${simNodeData.code}`}}</span>
</el-tag>
<el-tag size="small" style="margin-left: 15px;" v-if="playerIdx >= 0">下一个播放窗口 : {{ playerIdx + 1 }}</el-tag>
<i class="el-icon-s-platform btn" :class="{active:spilt==1}" @click="spiltClickFun(1)"/>
<i class="el-icon-menu btn" :class="{active:spilt==4}" @click="spiltClickFun(4)"/>
<i class="el-icon-s-grid btn" :class="{active:spilt==9}" @click="spiltClickFun(9)"/>
<i class="el-icon-full-screen btn" :class="{active:spilt==16}" @click="spiltClickFun(16)"/>
<el-button size="mini" style="margin-left: 15px;" @click="oneClickPlayback()">一键播放</el-button>
<el-button size="mini" style="margin-left: 15px;" @click="closeSelectItem()">关闭选中</el-button>
<el-button size="mini" style="margin-left: 15px;" @click="closeSelectCarItem()">一键关闭</el-button>
<el-button size="mini" style="margin-left: 15px;" @click="inspectionsDialog" v-if="patrolValue" type="danger">
视屏巡查中
</el-button>
<el-button size="mini" style="margin-left: 15px;" @click="inspectionsDialog" v-else>视屏巡查</el-button>
</el-header>
<el-main style="padding: 0;">
<!-- 视频播放器 -->
<playerListComponent
ref="playListComponent"
@playerClick="handleClick"
:video-url="videoUrl"
v-model="spilt" style="width: 100%; height: 100%;"
></playerListComponent>
</el-main>
</el-container>
</el-container>
<div id="carRMenu" class="rMenu">
<ul>
<li id="m_add" @click="oneClickPlayback();">一键播放视频</li>
<li id="m_del" @click="closeSelectCarItem();">一键关闭选中车辆流</li>
</ul>
</div>
<div id="channelCarRMenu" class="rMenu">
<ul>
<li id="m_add" @click="oneClickPlayback();">一键播放视频</li>
<li id="m_del" @click="closeSelectCarItem();">一键关闭选中车辆流</li>
</ul>
</div>
<el-dialog title="视屏巡查设置" width="600" append-to-body
:close-on-click-modal="false"
:visible.sync="showVideoDialog" v-loading="loading">
<el-card class="box-card">
<tree-transfer
:disabled="patrolValue"
style="text-align: left; display: inline-block;"
:to_data="targetValue"
:defaultExpandedKeys="expandedKeys"
node_key="id"
:filter="true"
:title="['源列表', '巡查列表']"
:from_data="sourceValue"
:defaultProps="treeProps"
:filter-node="filterNode"
class="inspections-tree"
height="500px">
</tree-transfer>
</el-card>
<el-card class="box-card">
<div slot="header" class="clearfix">
<span style="font-size: math">巡查时间间隔</span>
</div>
<el-time-select
v-model="timerTime"
:picker-options="{
start: '00:30',
step: '00:30',
end: '5:00'
}"
placeholder="选择巡查时间"
:disabled="patrolValue">
</el-time-select>
</el-card>
<el-card class="box-card">
<div slot="header" class="clearfix">
<span style="font-size: math">巡查宫格数量</span>
</div>
<el-select v-model="patrolCell" placeholder="placeholder" :disabled="patrolValue">
<el-option
v-for="item in patrolCellList"
:key="item"
:label="item"
:value="item">
</el-option>
</el-select>
</el-card>
<div slot="footer" class="dialog-footer">
<el-button type="danger" v-if="patrolValue" @click="closeInspections">关闭</el-button>
<el-button type="primary" v-else @click="openInspections">开启</el-button>
<el-button @click="showVideoDialog = false">取 消</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import tree from "vue-giant-tree";
import uiHeader from "../layout/UiHeader.vue";
import playerListComponent from './common/PlayerListComponent.vue';
import player from './common/JessVideoPlayer.vue';
import DeviceTree from './common/DeviceTree.vue'
import treeTransfer from "el-tree-transfer";
import {parseTime} from "../../utils/ruoyi";
import Device1078Tree from "./JT1078Components/deviceList/Device1078Tree.vue";
import userService from "./service/UserService";
export default {
name: "live",
components: {
playerListComponent,
Device1078Tree,
uiHeader, player, DeviceTree, tree, treeTransfer
},
data() {
return {
//车辆列表过滤
filterText: '',
//穿梭框巡查数据-----------↓
//穿梭框默认展开
expandedKeys: [],
// 批次获取器
batchFetcher: null,
//源列表数据
sourceValue: [],
//原始sim列表 (sim对象)
simList: [],
//目标列表数据
targetValue: [],
//巡查播放原始列表
lastTargetValue: [],
//巡查过滤列表 (sim)
lastTargetValueFilter: [],
//现在正在播放的列表
nowPlayArray: [],
//prop参数
treeProps: {
children: 'children',
label: 'name',
disabled: 'disabled',
},
//巡查按钮
patrolValue: false,
//巡查宫格数量
patrolCell: 9,
//巡查宫格下拉框数据
patrolCellList: [1, 4, 9, 12],
//巡查时间
timerTime: '00:30',
//巡查定时器
fetchInterval: null,
//上线车辆
onlineCar: new Map(),
//车辆数据定时器
carInfoTimeout: null,
//车载key集合
onlineCarKeys: [],
//树节点对象
simNodeData: null,
videoUrl: [],
videoUrlHistory: "",
spilt: 1,//分屏
windowClickData: null,
playerIdx: 0,//激活播放器
updateLooper: 0, //数据刷新轮训标志
count: 15,
historyLoadingFlag: true,
total: 0,
startTime: '',
endTime: '',
//channel
loading: false,
device: null,
nodes: [],
carPlayTimer: null,
carTreeNode: null,
ztreeObj: null,
ztreeNode: null,
fullscreenLoading: true,
fullscreenLoadingStyle: '',
showVideoDialog: false,
historyPlayListHtml: '',
hisotoryPlayFlag: false,
downloadURL: null,
rightMenuId: null,
channelData: null,
port: -1,
httpPort: -1,
stream: "",
sim: "",
channel: "",
setting: {
callback: {
beforeExpand: this.beforeExpand
},
check: {
enable: false,
},
edit: {
enable: false,
}
},
defaultProps: {
children: 'children',
label: 'title',
name: 'title',
isLeaf: 'spread',
nameIsHTML: true,
view: {
nameIsHTML: true
}
},
};
},
mounted() {
let that = this;
that.initTreeData();
},
created() {
this.checkPlayByParam();
this.getCarInfoBuffer()
},
beforeDestroy() {
if (!this.isEmpty(this.timer)) {
clearInterval(this.timer);
}
if (!this.isEmpty(this.updateLooper)){
clearTimeout(this.updateLooper);
}
if (!this.isEmpty(this.carPlayTimer)) {
clearTimeout(this.carPlayTimer);
}
},
computed: {
liveStyle() {
let style = {width: '99%', height: '99%'}
switch (this.spilt) {
case 4:
style = {width: '49%', height: '49%'}
break
case 9:
style = {width: '32%', height: '32%'}
break
case 12:
style = {width: '24.5%', height: '32%'}
break
}
this.$nextTick(() => {
for (let i = 0; i < this.spilt; i++) {
const player = this.$refs.player
player && player[i] && player[i].updatePlayerDomSize()
}
})
return style
}
},
watch: {
spilt(newValue) {
console.log("切换画幅;" + newValue)
let that = this
for (let i = 1; i <= newValue; i++) {
if (!that.$refs['player' + i]) {
continue
}
this.$nextTick(() => {
if (that.$refs['player' + i] instanceof Array) {
that.$refs['player' + i][0].resize()
} else {
that.$refs['player' + i].resize()
}
})
}
window.localStorage.setItem('split', newValue)
},
'$route.fullPath': 'checkPlayByParam'
},
destroyed() {
},
methods: {
/**
* 视频窗口点击传值
* @param data 该窗口的数据
* @param index 该窗口的下标
* @param len 窗口总数
*/
handleClick(data, index, len) {
console.log(index)
this.playerIdx = index
this.windowClickData = data
},
/**
* 统计树节点下一级有多少在线数量
*/
statisticsOnline(data) {
for (let i in data) {
console.log(data[i].abnormalStatus === undefined && data[i].children && data[i].children.length > 0)
if (data[i].abnormalStatus === undefined && data[i].children && data[i].children.length > 0) {
data[i].onlineData = data[i].children.filter(item => item.abnormalStatus === 1);
}
}
},
/**
* 树点击事件
*/
nodeClick(data, node) {
if (data.children && data.children.length > 0 && data.abnormalStatus) {
this.simNodeData = data
this.channelData = null
} else if (data.parent.abnormalStatus === 10){
this.$message.error("设备未接入SIM卡")
} else if (data.parent.abnormalStatus === 20){
this.$message.error("设备不在线")
} else if (data.children === undefined) {
let playerIdx = this.playerIdx;
this.simNodeData = node.parent.data
this.channelData = data
this.openPlay(data, playerIdx++);
if (playerIdx > (this.spilt - 1)){
this.playerIdx = 0
} else {
this.playerIdx = playerIdx
}
} else {
console.log(data)
this.$message.error("设备状态异常")
}
},
/**
* 模糊查询树
*/
filterNode(value, data) {
console.log(data)
if (!value) return true;
return this.findSearKey(data, value)
},
/**
* 递归搜索父级是否包含关键字
*/
findSearKey(node, key) {
if (node.name.indexOf(key) !== -1) {
return true;
} else {
if (node.parent === undefined || node.parent === null) {
return false;
} else {
return this.findSearKey(node.parent, key);
}
}
},
/**
* 处理返回的tree数据
*/
processingTreeData(data, pid, parent) {
for (let i in data) {
data[i].pid = pid
data[i].parent = parent;
if (data[i].children || (Array.isArray(data[i].children) && data[i].abnormalStatus === undefined)) {
this.processingTreeData(data[i].children, data[i].id, data[i]);
} else {
data[i].name = data[i].code
if (data[i].abnormalStatus !== 1) {
data[i].disabled = true;
let targetValue = this.targetValue;
if (targetValue.length > 0) {
this.disableItemsByName(targetValue, data[i].name);
}
}
this.addChannels(data[i])
}
}
},
/**
* 原始sim列表数据 (用来验证视屏巡查车辆是否在线)
* @param data 查询后台树列表
*/
processingSimList(data) {
if (data && data.length > 0) {
for (let i in data) {
if (data[i].children === undefined && data[i].abnormalStatus) {
this.simList.push(data[i]);
} else if (data[i].children && data[i].children.length > 0) {
this.processingSimList(data[i].children);
}
}
}
},
/**
* 处理巡查列表数据
*/
disableItemsByName(arr, targetName) {
arr.forEach(item => {
// 检查当前项是否是对象并且包含 name 属性且值为 targetName
if (item && typeof item === 'object' && item.name === targetName) {
item.disabled = true;
}
// 如果当前项有 children 属性且是数组,则递归调用自身
if (item && Array.isArray(item.children)) {
this.disableItemsByName(item.children, targetName);
}
});
},
/**
* 查询车辆信息
*/
getCarInfoBuffer() {
this.loading = true;
this.getCarInfo()
},
getCarInfo() {
console.log()
this.$axios({
method: 'get',
url: `/api/jt1078/query/car/tree/${userService.getUser().role.authority == 0?'all':userService.getUser().role.authority}`,
}).then(res => {
if (res && res.data && res.data.data) {
if (res.data.data.code == 1) {
//处理数据
this.simList = []
this.processingSimList(res.data.data.result)
this.processingTreeData(res.data.data.result, 0);
this.statisticsOnline(res.data.data.result)
console.log(res.data.data.result)
this.sourceValue = res.data.data.result;
this.loading = false
//定时更新数据
let this_ = this
this.carInfoTimeout = setTimeout(function () {
this_.getCarInfo()
}, 45000);
} else if (res.data.data.message) {
this.$message.error(res.data.data.message);
}
} else {
this.$message.error("请求错误,请刷新再试");
}
this.loading = false
}).catch(error => {
this.$message.error(error.message);
})
},
/**
* 打开巡查设置悬浮框
*/
inspectionsDialog() {
this.showVideoDialog = true
},
/**
* 添加通道
*/
addChannels(data) {
console.log(data)
if (data.sim2){
let nvr_labels = ['中门','','车前','驾驶舱','前门','前车厢','后车厢','360'];
//'ADAS','DSM','前门客流','中门客流','360前','360后','360左','360右'
let rm_labels = [];
let children = [];
for (let i in nvr_labels) {
if (nvr_labels[i] === ''){
continue
}
children.push({
id: `${data.id}_${data.sim}_${Number(i) + Number(1)}`,
pid: data.id,
name: nvr_labels[i],
disabled: data.disabled,
parent: data
})
}
for (let i in rm_labels) {
if (rm_labels[i] === ''){
continue
}
children.push({
id: `${data.id}_${data.sim2}_${Number(i) + Number(1)}`,
pid: data.id,
name: rm_labels[i],
disabled: data.disabled,
parent: data
})
}
data.children = children;
}else {
let labels = ['ADAS', 'DSM', '路况', '司机', '整车前', '中门', '倒车', '前门客流', '后面客流'];
let children = [];
for (let i in labels) {
children.push({
id: `${data.id}_${data.sim}_${Number(i) + Number(1)}`,
pid: data.id,
name: labels[i],
disabled: data.disabled,
parent: data
})
}
data.children = children;
}
},
/**
* 巡查时间转换器
*/
timerTimeConvertor() {
switch (this.timerTime) {
case "00:30":
return 30000
case "01:00":
return 30000 * 2
case "01:30":
return 30000 * 3
case "02:00":
return 30000 * 4
case "02:30":
return 30000 * 5
case "03:00":
return 30000 * 6
case "03:30":
return 30000 * 7
case "04:00":
return 30000 * 8
case "04:30":
return 30000 * 9
case "05:00":
return 30000 * 10
default:
return null
}
},
/**
* 巡查开启按钮
*/
openInspections() {
let time = this.timerTimeConvertor();
this.spilt = this.patrolCell;
if (time == null) {
this.$message.error("时间选择错误 ==> [ " + this.timerTime + " ]")
console.log("时间选择结果为 ===> [ " + time + " ]")
}
let targetValue = this.targetValue;
if (targetValue === undefined || targetValue === null || targetValue.length === 0) {
this.$message.error("未选择巡查对象")
return
}
this.startFetching(time)
this.showVideoDialog = false
},
/**
* 巡查树数组只获取最后一级的一维数组
* @param array 原数组
*/
getLastElementsOfInnerArrays(array) {
const result = [];
//递归取值
function traverse(arr) {
for (let item of arr) {
let children = item.children;
if (children !== undefined && Array.isArray(children)) {
traverse(children);
} else if (children === undefined) {
result.push(item)
} else {
console.log("数据格式有误 ==> { " + item + " }")
}
}
}
//开启递归取值
traverse(array);
return result;
},
/**
* 巡查关闭按钮
*/
closeInspections() {
this.stopPatrol()
this.patrolValue = false
clearInterval(this.fetchInterval);
let nowPlayArray = this.nowPlayArray;
for (let index in nowPlayArray) {
this.setPlayUrl(null, index)
}
},
/**
* 后台关闭视频巡查
*/
stopPatrol() {
this.$axios({
method: 'get',
url: `/api/jt1078/query/stopPatrol/request/io`,
}).then((res) => {
if (res.data.code === 0) {
this.$message.success("视频巡查已关闭")
} else {
this.$message.error("视频巡查已关闭失败, 请联系管理员");
}
});
},
/**
* 后台开启视频巡查
*/
startPatrol(data) {
this.$axios({
method: 'post',
url: `/api/jt1078/query/startPatrol/request/io`,
data: data,
headers: {
'Content-Type': 'application/json', // 设置请求头
}
}).then((res) => {
if (res.data.code === 0) {
console.log("视频巡查已开启 ===》 " + res.data.msg)
this.$message.success("视频巡查已开启");
} else {
console.log("视频巡查开启失败 ===》 " + res.data.msg)
this.$message.error("视频巡查开启失败, 请联系管理员");
}
});
},
/**
* 巡查对话框取消按钮
*/
cancel() {
this.loading = true;
this.targetValue = [];
this.timerTime = '00:30'
},
/**
* 开启推流视频播放
*/
openPlay(data, idxTmp, fun) {
console.log("开启视频播放入参数据 ===》 [ " + data + " ]")
let id = data.id;
if (id === undefined || id === null) {
console.log("id 内容为 :" + id)
return;
}
console.log("id 内容为 :" + id)
let arr = id.split('_');
if (arr === undefined || arr === null || arr.length !== 3) {
console.log("split 内容为 :" + arr)
return;
}
this.$axios({
method: 'get',
url: '/api/jt1078/query/send/request/io/' + arr[1] + '/' + arr[2]
}).then(res => {
if (res.data.code === 0 && res.data.data) {
let videoUrl;
this.downloadURL = res.data.data.flv;
if (location.protocol === "https:") {
videoUrl = res.data.data.wss_flv;
} else {
videoUrl = res.data.data.ws_flv;
}
data.playUrl = videoUrl;
this.setPlayUrl(videoUrl, idxTmp);
} else {
if (!this.isEmpty(res.data.data) && !this.isEmpty(res.data.data.msg)) {
this.$message.error(res.data.data.msg);
} else {
this.$message.error(res.data.msg);
}
}
if (fun) {
fun();
}
})
},
/**
* 批量开启推流视频播放
* @param data 视频推流参数集合 Array
*/
// openBatchPlay(data) {
// if (data === undefined || !Array.isArray(data)) {
// return;
// }
// console.log("批量开启推流视频播放 ----》"+data)
// let index = 0;
// this.cycleBatchPlay(data, index)
// },
cycleBatchPlay(data, index) {
if (data === undefined || data[index] === undefined) {
return;
}
let this_i = this
this.openPlay(data[index], Number(index), function () {
index++
this_i.cycleBatchPlay(data, index)
});
},
/**
* 发送请求验证车辆是否在线
* @param item
* @returns {boolean|*}
*/
checkStatus(item) {
if (this.lastTargetValueFilter.includes(item)) {
return true
}
if (this.simList) {
let find = this.simList.find(simData => simData.sim === item && simData.abnormalStatus !== 1);
//没找到则为离线 反之在线
console.log("find ===> " + find)
let f = (find === undefined)
if (f) {
this.lastTargetValueFilter.push(item)
}
return !f
}
return true; // 直接返回预定义的在线状态
},
/**
* 批量验证车辆在线情况
* @param items
* @returns {*}
*/
validateItemsOnline(items) {
// 检查所有提供的 items 是否在线,并返回过滤后的在线 items
const onlineItems = items.filter(item => this.checkStatus(item.id.split('_')[1]));
if (onlineItems.length !== items.length) {
console.warn("有车辆下线");
}
this.nowPlayArray = items;
return onlineItems;
},
/**
* 循环从数组中取出一定数量的值
* @param array 原数组
* @param batchSize 取出的数量
* @returns {function(): *[]} 取出的结果
*/
// createBatchFetcher(array, batchSize) {
// let currentIndex = 0;
// array = array.slice(); // 创建数组副本以避免修改原始数组
// return function fetchNextBatch() {
// const result = [];
// for (let i = 0; i < batchSize; i++) {
// if (currentIndex >= array.length) {
// currentIndex = 0; // 当达到数组末尾时重置索引
// }
// result.push(array[currentIndex]);
// currentIndex++;
// }
// return result;
// };
// },
createBatchFetcher(array, batchSize) {
let currentIndex = 0;
const originalArray = array.slice(); // 创建原始数组副本
return function fetchNextBatch() {
const result = [];
for (let i = 0; i < batchSize && currentIndex < originalArray.length; i++) {
result.push(originalArray[currentIndex]);
currentIndex++;
}
return result;
};
},
/**
* 开启视频巡查
* @param items 选择巡查的对象
* @param time
*/
startFetching(time) {
this.lastTargetValue = this.getLastElementsOfInnerArrays(this.targetValue);
console.log("targetValue ===> " + this.targetValue);
console.log("lastTargetValue ===> " + this.lastTargetValue);
if (!this.patrolValue && this.lastTargetValue.length > 0) {
// 在初始化 batchFetcher 之前验证 items 是否全部在线
this.lastTargetValue = this.validateItemsOnline(this.lastTargetValue);
if (this.lastTargetValue.length === 0) {
console.warn("【车辆全部下线】请重新选择");
return;
}
this.startPatrol(this.lastTargetValue)
this.batchFetcher = this.createBatchFetcher(this.lastTargetValue, this.spilt);
// 立即执行一次 fetchNextBatch 并等待其完成
let data = this.fetchNextBatch();
console.log(parseTime(new Date(), '{y}-{m}-{d} {h}:{i}:{s}') + " 视频巡查数组 ===》 " + data);
this.beachSendIORequest(this.convertBeachList(data));
// 设置定时器以定期获取批次
this.fetchInterval = setInterval(() => {
let data = this.fetchNextBatch();
console.log(parseTime(new Date(), '{y}-{m}-{d} {h}:{i}:{s}') + " 视频巡查数组 ===》 " + data);
this.beachSendIORequest(this.convertBeachList(data));
}, time);
this.patrolValue = true;
}
},
/**
* 数组转换 (方便批量发送请求)
*/
convertBeachList(data) {
if (data && data.length > 0) {
return data.map(item => item.id.split('_').slice(1).join('-'))
}
},
/**
* 更新巡查播放列表
*/
fetchNextBatch() {
// 在每次获取批次前验证在线状态
const updatedItems = this.validateItemsOnline(this.lastTargetValue);
if (updatedItems.length === 0) {
this.$message.error("车辆已全部下线,已关闭 【视屏巡查】")
this.stopFetching();
return
}
if (updatedItems.length !== this.lastTargetValue.length) {
// 更新 items 和 batchFetcher
this.lastTargetValue = updatedItems;
this.batchFetcher = this.createBatchFetcher(updatedItems, this.spilt);
}
const batch = this.batchFetcher();
this.nowPlayArray = batch;
return batch
},
/**
* 关闭视频巡查
*/
stopFetching() {
if (this.isFetching) {
clearInterval(this.fetchInterval);
this.fetchInterval = null;
this.isFetching = false;
}
},
destroy(idx) {
this.clear(idx.substring(idx.length - 1))
},
treeChannelClick(device, data, isCatalog) {
if (data.channelId && !isCatalog) {
if (device.online === 0) {
this.$message.error('设备离线!不允许点播');
this.closeLoading();
return false;
} else {
this.isSendDevicePush(data, this.patrolValue);
}
}
},
contextMenuEvent: function (device, event, data, isCatalog) {
},
isSendDevicePush(itemData, patrolValue) {
if (patrolValue) {
this.videoPatrolStart(itemData);
} else {
this.sendDevicePush(itemData);
}
},
//通知设备上传媒体流
sendDevicePush(itemData, fun) {
this.save(itemData)
let deviceId = itemData.deviceId;
let channelId = itemData.channelId;
if (this.isEmpty(deviceId)) {
this.$message.error("没有获取到sim卡,请检查设备是否接入");
this.closeLoading();
if (fun) {
fun();
}
return;
}
console.log("通知设备推流1:" + deviceId + " : " + channelId);
let idxTmp = this.playerIdx
this.$axios({
method: 'get',
url: '/api/jt1078/query/send/request/io/' + deviceId + '/' + channelId
}).then(res => {
console.log(res)
if (res.data.code === 0 && res.data.data) {
let videoUrl;
this.port = res.data.data.port;
this.httpPort = res.data.data.httpPort;
this.stream = res.data.data.stream;
console.log(res.data.data);
if (!this.isEmpty(res.data.data)) {
this.downloadURL = res.data.data.flv;
if (location.protocol === "https:") {
videoUrl = res.data.data.wss_flv;
} else {
videoUrl = res.data.data.ws_flv;
}
console.log(videoUrl);
itemData.playUrl = videoUrl;
this.setPlayUrl(videoUrl, idxTmp);
}
} else {
this.$message.error(res.data.msg);
}
if (fun) {
fun();
}
}).catch(function (e) {
if (fun) {
fun();
}
}).finally(() => {
this.closeLoading();
});
},
/**
* 播放器赋值
* @param url 播放内容路径
* @param idx 播放的id
*/
setPlayUrl(url, idx) {
this.$refs.playListComponent.setPlayUrl(url, idx)
},
checkPlayByParam() {
let {deviceId, channelId} = this.$route.query
if (deviceId && channelId) {
this.sendDevicePush({deviceId, channelId})
}
},
shot(e) {
console.log(e)
// send({code:'image',data:e})
var base64ToBlob = function (code) {
let parts = code.split(';base64,');
let contentType = parts[0].split(':')[1];
let raw = window.atob(parts[1]);
let rawLength = raw.length;
let uInt8Array = new Uint8Array(rawLength);
for (let i = 0; i < rawLength; ++i) {
uInt8Array[i] = raw.charCodeAt(i);
}
return new Blob([uInt8Array], {
type: contentType
});
};
let aLink = document.createElement('a');
let blob = base64ToBlob(e); //new Blob([content]);
let evt = document.createEvent("HTMLEvents");
evt.initEvent("click", true, true); //initEvent 不加后两个参数在FF下会报错 事件类型,是否冒泡,是否阻止浏览器的默认行为
aLink.download = '截图';
aLink.href = URL.createObjectURL(blob);
aLink.click();
},
save(item) {
let dataStr = window.localStorage.getItem('playData') || '[]'
let data = JSON.parse(dataStr);
data[this.playerIdx] = item
window.localStorage.setItem('playData', JSON.stringify(data))
},
clear(idx) {
let dataStr = window.localStorage.getItem('playData') || '[]'
let data = JSON.parse(dataStr);
data[idx - 1] = null;
console.log(data);
window.localStorage.setItem('playData', JSON.stringify(data))
},
initTreeData() {
this.showLoading();
this.$axios({
method: 'get',
url: `/api/jt1078/query/company/tree`,
}).then((res) => {
if (res && res.data && res.data.data) {
if (res.data.data.code == 1) {
let data = res.data.data.result;
this.initDate(this.nodes, data);
} else if (res.data.data.message) {
this.$message.error(res.data.data.message);
}
} else {
this.$message.error("请求错误,请刷新再试");
}
this.closeLoading();
});
},
initDate(nodes, datas) {
if (nodes && datas) {
let len = datas.length;
for (let i = 0; i < len; i++) {
if (null == datas[i].id || undefined == datas[i].id || "" == datas[i].id) {
continue;
}
let node = this.combationNodeValue(datas[i].name, datas[i].id, datas[i].type, true, datas[i].sim, datas[i].abnormalStatus)
nodes.push(node);
if (datas[i].children) {
node.children = [];
this.initDate(node.children, datas[i].children);
}
}
}
},
combationNodeValue(name, id, type, isParent, sim, abnormalStatus) {
if (this.isEmpty(sim)) {
sim = "";
}
if (abnormalStatus >= 10 && abnormalStatus < 20) {
name = "<view style='color:red'>" + name + "</view>";
} else if (abnormalStatus >= 20 && abnormalStatus < 30) {
name = "<view style='color:#ccc'>" + name + "</view>";
}
return {
name: name,
id: id,
abnormalStatus: abnormalStatus,
sim: sim,
type: type,
isParent: isParent,
}
},
onClick(evt, treeId, treeNode) {
this.combationChildNode(treeNode);
},
beforeExpand(treeId, treeNode) {
return true;
},
combationChildNode(treeNo) {
this.ztreeNode = treeNo;
if (treeNo.seachChild && (treeNo.seachChild == 'true')) {
return;
}
this.showLoading();
if (treeNo.type == 401 || treeNo.type == '401') {
let device = new Object();
if (this.isEmpty(treeNo.online)) {
treeNo.online = 1;
}
device.online = treeNo.online;
if (this.spilt == 1) {
this.videoUrl = []
}
this.closeLoading();
let pageObj = this;
if (!this.isEmpty(this.sim) && !this.channel && this.sim != treeNo.sim && this.channel != treeNo.id) {
let data = new Object();
data.channelId = treeNo.id;
data.sim = treeNo.sim;
data.deviceId = treeNo.sim;
this.sim = treeNo.sim;
this.channel = treeNo.id;
console.log("stop");
this.sendIORequestStop(data.sim, data.channelId, function () {
let flag = pageObj.treeChannelClick(device, data, false);
if (false == flag) {
treeNo.online = 0;
}
});
} else {
let data = new Object();
data.channelId = treeNo.id;
data.sim = treeNo.sim;
data.deviceId = treeNo.sim;
this.sim = treeNo.sim;
this.channel = treeNo.id;
let flag = pageObj.treeChannelClick(device, data, false);
if (false == flag) {
treeNo.online = 0;
}
}
} else if (treeNo.type == 301 || treeNo.type == '301') {
this.addChannel(treeNo);
this.carTreeNode = treeNo;
this.channel = null;
} else if (treeNo.type == 2 || treeNo.type == '2') {
this.requestChildNode(treeNo);
this.sim = null;
this.channel = null;
this.carTreeNode = null;
} else {
this.carTreeNode = null;
this.sim = null;
this.channel = null;
this.closeLoading();
}
},
/**
* 添加通道
*/
addChannel(treeNo) {
let labels = ['ADAS', 'DSM', '路况', '司机', '整车前', '中门', '倒车', '前门客流', '后面客流'];
let children = [];
let len = labels.length;
let i = 0;
let pageObj = this;
for (; i < len; i++) {
console.log(treeNo.abnormalStatus + "==========================>" + i);
let node = this.combationNodeValue(labels[i], i + 1, 401, false, treeNo.sim, treeNo.abnormalStatus);
node.sim = treeNo.sim;
node.zbh = treeNo.name;
node.id = i + 1;
children.push(node);
}
this.ztreeObj.addNodes(treeNo, 0, children, true);
treeNo.seachChild = 'true';
pageObj.sim = treeNo.sim;
this.closeLoading();
},
requestChildNode(treeNo) {
if (treeNo.spread === 'false' || !treeNo.spread) {
let id = treeNo.id;
this.$axios({
method: 'get',
url: `/api/jt1078/query/car/tree/` + id,
}).then((res) => {
if (res && res.data && res.data.data) {
if (res.data.data.code == 1) {
let children = [];
this.initDate(children, res.data.data.result);
this.ztreeObj.addNodes(treeNo, -1, children, true);
treeNo.seachChild = 'true';
let _this = this;
this.carPlayTimer = setTimeout(function () {
_this.requestChildNode1();
}, 15000);
} else if (res.data.data.message) {
this.$message.error(res.data.data.message);
}
} else {
this.$message.error("请求错误,请刷新再试");
}
this.closeLoading();
})
}
},
requestChildNode1() {
this.$axios({
method: 'get',
url: `/api/jt1078/query/car/tree/` + 100,
}).then((res) => {
if (res && res.data && res.data.data) {
if (res.data.data.code == 1) {
this.refreshRequestRefresh(res.data.data.result);
} else if (res.data.data.message) {
this.$message.error(res.data.data.message);
}
} else {
this.$message.error("请求错误,请刷新再试");
}
})
},
refreshRequestRefresh(nodes) {
if (nodes) {
let length = nodes.length;
for (let i = 0; i < length; i++) {
let findNode = this.ztreeObj.getNodeByParam("id", nodes[i].id + "", null);
if (findNode) {
findNode.name = nodes[i].name;
if (findNode.type == 301 || findNode.type == '301') {
findNode.name = nodes[i].name;
} else {
findNode.name = nodes[i].name;
}
this.ztreeObj.updateNode(findNode);
if (nodes[i].children) {
this.refreshRequestRefresh(nodes[i].children);
}
}
}
}
},
showLoading() {
this.loading = true;
this.fullscreenLoading = true;
// this.fullscreenLoadingStyle ='display:block';
},
closeLoading() {
this.loading = false;
//this.fullscreenLoadingStyle ='display:none';
this.fullscreenLoading = false;
console.log("已经关闭");
},
sendIORequestStop(sim, channel, fun) {
if (this.isEmpty(sim) || this.isEmpty(channel)) {
console.log("sim:" + sim + ";channel:" + channel);
if (fun) {
fun();
}
return;
}
this.videoUrl = [''];
this.$axios({
method: 'get',
url: `/api/jt1078/query/send/stop/io/` + sim + "/" + channel + "/" + this.stream + "/" + this.port + "/" + this.httpPort,
}).then((res) => {
console.log(res);
if (fun) {
fun();
}
});
},
isEmpty(val) {
return null == val || undefined == val || "" == val;
},
close() {
let pageObj = this;
this.showLoading();
this.historyPlayListHtml = null;
this.startTime = null;
this.endTime = null;
if (this.hisotoryPlayFlag) {
this.sendIORequestStop(this.sim, this.channel, function () {
pageObj.showVideoDialog = false;
pageObj.videoUrl = [''];
pageObj.closeLoading();
console.log("关闭弹窗");
});
} else {
pageObj.showVideoDialog = false;
pageObj.closeLoading();
}
},
/**
* 视频一键播放
*/
oneClickPlayback() {
if (this.isEmpty(this.simNodeData)) {
this.$message.error('请选择车辆');
return;
}
if (this.isEmpty(this.simNodeData.abnormalStatus)) {
this.$message.error('请检查车辆状态');
return;
}
if (this.simNodeData.abnormalStatus != 1) {
this.$message.error('车辆设备离线,请检查设备');
return;
}
if (this.isEmpty(this.simNodeData.sim)) {
this.$message.error('无法获取SIM卡信息,请检查设备');
return;
}
let children = this.simNodeData.children;
if (children && children.length > 0){
this.spilt = 9;
let data = []
let count = 1;
for (let i in children) {
let split = children[i].id.split("_");
if (split.length === 3){
data.push(`${split[1]}-${split[2]}`)
if (count++ === this.spilt){
break
}
}
}
if (data.length === 0){
this.$message.error("该设备无通道播放")
return;
}
this.beachSendIORequest(data);
}else {
this.$message.error("该设备无通道播放")
}
},
/**
* 批量发送推流请求
* @param data
*/
beachSendIORequest(data) {
console.log(data)
this.$axios({
method: 'post',
url: '/api/jt1078/query/beachSend/request/io',
data: data,
headers: {
'Content-Type': 'application/json', // 设置请求头
}
}).then(
res => {
let dataList = res.data.data;
console.log(dataList);
if (res.data.code == 0 && dataList != null && dataList.length >= 0) {
for (let i in dataList) {
this.$refs.playListComponent.setPlayUrl(dataList[i].ws_flv, i)
}
} else {
this.$message.error(res.data.msg);
}
}
)
},
// playOneAllChannel(channel) {
// if (channel == 9) {
// return;
// }
// let item = new Object();
// item.deviceId = this.sim;
// item.channelId = 1 + channel;
// this.playerIdx = channel;
//
// this.sendDevicePush(item);
// },
spiltClickFun(val) {
this.spilt = val;
if (val - 1 < this.playerIdx) {
this.playerIdx = val - 1;
}
},
closeSelectItem() {
console.log("============================>" + this.playerIdx);
this.setPlayUrl(null, this.playerIdx)
},
closeSelectCarItem() {
for (let index = 0; index < 9; index++) {
this.setPlayUrl(null, index)
}
},
showRMenu(event) {
if (this.isEmpty(this.rightMenuId)) {
return;
}
let carMenu = document.getElementById(this.rightMenuId);
carMenu.setAttribute("style", "display:block");
let x = event.clientX;
let y = event.clientY;
carMenu.setAttribute("style", "display:block;top:" + y + "px;left:" + x + "px");
document.addEventListener("click", this.hideMenu);
console.log(this.rightMenuId);
},
hideMenu() {
if (this.isEmpty(this.rightMenuId)) {
return;
}
let carMenu = document.getElementById(this.rightMenuId);
carMenu.setAttribute("style", "display:none");
this.rightMenuId = null;
}
}
};
</script>
<style scoped>
.inspections-tree >>> .el-tree {
padding-bottom: 22px;
}
.device-list-tree >>> .el-tree {
padding-bottom: 13px;
}
.device-list-tree >>> .el-tree-node__content {
padding-bottom: 13px;
height: 20px;
}
.el-main {
background-color: rgba(0, 0, 0, 0.84);
color: #333;
text-align: center;
line-height: 160px;
padding: 0;
margin-left: 1px;
}
.device-tree-main-box {
text-align: left;
}
.btn {
margin: 0 10px;
}
.btn:hover {
color: #409EFF;
}
.btn.active {
color: #409EFF;
}
.redborder {
border: 2px solid red !important;
}
.play-box {
background-color: #000000;
border: 2px solid #505050;
display: flex;
align-items: center;
justify-content: center;
}
.historyListLi {
width: 97%;
white-space: nowrap;
text-overflow: ellipsis;
cursor: pointer;
padding: 3px;
margin-bottom: 6px;
border: 1px solid #000000;
}
.historyListDiv {
height: 80vh;
width: 100%;
overflow-y: auto;
overflow-x: hidden;
}
/* 菜单的样式 */
.rMenu {
position: absolute;
top: 0;
display: none;
margin: 0;
padding: 0;
text-align: left;
border: 1px solid #BFBFBF;
border-radius: 3px;
background-color: #EEE;
box-shadow: 0 0 10px #AAA;
}
.rMenu li {
width: 170px;
list-style: none outside none;
cursor: default;
color: #666;
margin-left: -20px;
}
.rMenu li:hover {
color: #EEE;
background-color: #666;
}
li#menu-item-delete, li#menu-item-rename {
margin-top: 1px;
}
.videoList {
display: flex;
flex-wrap: wrap;
align-content: flex-start;
}
.video-item {
position: relative;
width: 15rem;
height: 10rem;
margin-right: 1rem;
background-color: #000000;
}
.video-item-img {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
margin: auto;
width: 100%;
height: 100%;
}
.video-item-img:after {
content: "";
display: inline-block;
position: absolute;
z-index: 2;
top: 0;
bottom: 0;
left: 0;
right: 0;
margin: auto;
width: 3rem;
height: 3rem;
background-image: url("../assets/loading.png");
background-size: cover;
background-color: #000000;
}
.video-item-title {
position: absolute;
bottom: 0;
color: #000000;
background-color: #ffffff;
line-height: 1.5rem;
padding: 0.3rem;
width: 14.4rem;
}
.baidumap {
width: 100%;
height: 100%;
border: none;
position: absolute;
left: 0;
top: 0;
right: 0;
bottom: 0;
margin: auto;
}
/* 去除百度地图版权那行字 和 百度logo */
.baidumap > .BMap_cpyCtrl {
display: none !important;
}
.baidumap > .anchorBL {
display: none !important;
}
.scroll-container {
max-height: 85vh; /* 设置最大高度为85%的视口高度 */
overflow-y: auto; /* 内容超出时显示垂直滚动条 */
overflow-x: hidden; /* 隐藏水平滚动条 */
}
.transfer-footer {
margin-left: 20px;
padding: 6px 5px;
}
</style>