|
@@ -438,6 +438,8 @@
|
|
|
/** ----------------------------------weosocket结束------------------------------------- */
|
|
|
|
|
|
import {
|
|
|
+ getMenuEventType,
|
|
|
+ getEventPush,
|
|
|
getBaseInfo,
|
|
|
getTodayEvents,
|
|
|
getDeptEventCount,
|
|
@@ -496,6 +498,7 @@
|
|
|
this.getEventByReportorOrder(this.getCurrentDataStr())
|
|
|
this.getExposureStage(this.getCurrentDataStr())
|
|
|
this.getSupermap(this.getCurrentDataStr())
|
|
|
+ this.getMenuEventType()
|
|
|
/** ----------------------------------weosocket开始------------------------------------- */
|
|
|
// this.initWebSocket()
|
|
|
/** ----------------------------------weosocket结束------------------------------------- */
|
|
@@ -503,13 +506,13 @@
|
|
|
if (this.calendarDay == this.getCurrentDataStr()) {
|
|
|
this.getTodayEvents(this.getCurrentDataStr(), true);
|
|
|
this.getDeptEventCount(this.getCurrentDataStr(), true);
|
|
|
- this.getEventList(this.getCurrentDataStr(), this.pageSize, this.pageNum, '', true);
|
|
|
+ // this.getEventList(this.getCurrentDataStr(), this.pageSize, this.pageNum, '', true);
|
|
|
this.getEventByEventType(this.getCurrentDataStr(), true);
|
|
|
this.getEventByReportorOrder(this.getCurrentDataStr(), true);
|
|
|
this.getExposureStage(this.getCurrentDataStr(), true);
|
|
|
- this.getSupermap(this.getCurrentDataStr(), true);
|
|
|
+ // this.getSupermap(this.getCurrentDataStr(), true);
|
|
|
}
|
|
|
- }, 10000)
|
|
|
+ }, 30000)
|
|
|
|
|
|
this.bottomMenuList() //获取底部公共组件消息和任务
|
|
|
},
|
|
@@ -571,6 +574,11 @@
|
|
|
weosocket: false,
|
|
|
websock: '',
|
|
|
setIntervalWesocketPush: null,
|
|
|
+ websockSid: {
|
|
|
+ userId: '',
|
|
|
+ eventTypeDl: '',
|
|
|
+ eventType: '',
|
|
|
+ },
|
|
|
/** ----------------------------------weosocket结束------------------------------------- */
|
|
|
/** ----------------------------------摄像头预览开始------------------------------------- */
|
|
|
activePanel: 'key1',
|
|
@@ -592,6 +600,16 @@
|
|
|
},
|
|
|
/** ----------------------------------weosocket结束------------------------------------- */
|
|
|
methods: {
|
|
|
+ getMenuEventType() {
|
|
|
+ let that = this
|
|
|
+ getMenuEventType().then(res => {
|
|
|
+ that.websockSid.userId = Cookies.get('userId')
|
|
|
+ that.websockSid.eventTypeDl = res.data.eventTypeDl
|
|
|
+ that.websockSid.eventType = res.data.eventType
|
|
|
+ that.initWebSocket(that.websockSid.userId, that.websockSid.eventTypeDl, that.websockSid.eventType)
|
|
|
+ console.log(that.websockSid)
|
|
|
+ })
|
|
|
+ },
|
|
|
setEventTypeId(data) {
|
|
|
// let data = {eventTypeIdDl: [], eventTypeId: []}
|
|
|
// let data = {eventTypeIdDl: that.eventTypeIdDl, eventTypeId: that.eventTypeId}
|
|
@@ -1045,7 +1063,7 @@
|
|
|
},
|
|
|
getWebSocketEvent(data) {
|
|
|
let that = this
|
|
|
- const event = JSON.parse(data);
|
|
|
+ const event = data
|
|
|
//右侧获取事件列表
|
|
|
that.markersList = []
|
|
|
let markersMap = {
|
|
@@ -1128,9 +1146,8 @@
|
|
|
})
|
|
|
},
|
|
|
/** ----------------------------------weosocket开始------------------------------------- */
|
|
|
- initWebSocket() { //初始化weosocket
|
|
|
- // const wsuri = 'ws://127.0.0.1:10003/webSocket/' + Cookies.get('username')
|
|
|
- const wsuri = 'ws://127.0.0.1:10003/webSocket/admin'
|
|
|
+ initWebSocket(userId, eventTypeDl, eventType) { //初始化weosocket
|
|
|
+ const wsuri = 'ws://127.0.0.1:10003/eventPush/' + userId + '/' + eventTypeDl + '/' + eventType
|
|
|
this.websock = new WebSocket(wsuri)
|
|
|
console.log('建立websocket连接')
|
|
|
this.websock.onopen = this.websocketonopen
|
|
@@ -1143,14 +1160,15 @@
|
|
|
this.sendPing()
|
|
|
},
|
|
|
websocketonerror() { //连接建立失败重连
|
|
|
- this.initWebSocket()
|
|
|
+ this.initWebSocket(this.websockSid.userId, this.websockSid.eventTypeDl, this.websockSid.eventType,)
|
|
|
},
|
|
|
websocketonmessage(e) { //数据接收
|
|
|
console.log('接收数据', e.data)
|
|
|
// let data = "{\"fromId\":\"forest\",\"fromUserId\":\""+Cookies.get('username')+"\",\"toUserId\":\""+Cookies.get('username')+"\"}";
|
|
|
let data = "{\"fromId\":\"forest\",\"fromUserId\":\"admin\",\"toUserId\":\"admin\"}";
|
|
|
if (this.calendarDay == this.getCurrentDataStr() && data != e.data) {
|
|
|
- this.getWebSocketEvent(e.data);
|
|
|
+ // 处理收到的消息
|
|
|
+ this.handleWebSoceketEvent(e.data)
|
|
|
|
|
|
// this.getEventListNew();
|
|
|
// this.getTodayEvents(this.getCurrentDataStr());
|
|
@@ -1163,6 +1181,29 @@
|
|
|
// thes.$refs.up.pause();//停止播放音乐
|
|
|
}
|
|
|
},
|
|
|
+ // 处理WebSocket事件
|
|
|
+ handleWebSoceketEvent(val) {
|
|
|
+ let that = this
|
|
|
+ let data = JSON.parse(val)
|
|
|
+ /**
|
|
|
+ * that.markersList.filter( item => data.eventCode == item.parameter).length == 0 如果地图中不存在当前事件则添加
|
|
|
+ * eventPush: 事件列表消息
|
|
|
+ * */
|
|
|
+ if (data.tag == "eventPush" && that.markersList.filter( item => data.eventCode == item.parameter).length == 0) {
|
|
|
+ getEventPush({eventCode: data.eventCode}).then((res) => {
|
|
|
+ if (res.data != undefined) {
|
|
|
+ //插入到第一条
|
|
|
+ this.eventList.unshift(res.data)
|
|
|
+ // 插入后删除最后一条 保证列表中为10条数据
|
|
|
+ if (this.eventList.length > 9)
|
|
|
+ this.eventList.splice(10, 1)
|
|
|
+ // 将收到的数据在地图上添加
|
|
|
+ this.getWebSocketEvent(res.data)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ console.log(that.eventList[0])
|
|
|
+ },
|
|
|
websocketsend(Data) { //数据发送
|
|
|
this.websock.send(Data)
|
|
|
},
|
|
@@ -1185,7 +1226,7 @@
|
|
|
if (this.weosocket) {
|
|
|
this.websock.send(JSON.stringify(ping))
|
|
|
} else {
|
|
|
- this.initWebSocket()
|
|
|
+ // this.initWebSocket()
|
|
|
}
|
|
|
}, time)
|
|
|
},
|