修改bug
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
* @Author: zwq
|
||||
* @Date: 2021-07-19 15:18:30
|
||||
* @LastEditors: zhp
|
||||
* @LastEditTime: 2024-03-26 10:06:54
|
||||
* @LastEditTime: 2024-03-26 15:43:27
|
||||
* @Description:
|
||||
-->
|
||||
<template>
|
||||
@@ -76,6 +76,9 @@ import baseTable1 from './components/baseTable'
|
||||
import screenfull from 'screenfull'
|
||||
import doubleYChart from './components/doubleYChart '
|
||||
import LinearBarChart from './components/linearBarChart'
|
||||
import WebSocketHeartbeat from './ws.js';
|
||||
|
||||
// 创建WebSocketHeartbeat实例
|
||||
const qualityYearList = [
|
||||
{
|
||||
name: '翻转机', code: 'EQ20240110112358000235', status: '运行', error: '否'
|
||||
@@ -215,6 +218,8 @@ export default {
|
||||
rowNum: 10
|
||||
},
|
||||
// cxDataList,
|
||||
SJGws: undefined,
|
||||
wsHeartbeat:undefined,
|
||||
productLineList:[],
|
||||
qualityYearList,
|
||||
clientWidth: 0,
|
||||
@@ -387,144 +392,221 @@ export default {
|
||||
this.times = year + "-" + month + "-" + day + " " + hours + ":" + minutes + ":" + seconds;
|
||||
},
|
||||
initWebSocket() {
|
||||
if (typeof (WebSocket) === 'undefined') {
|
||||
alert('您的浏览器不支持WebSocket')
|
||||
} else {
|
||||
let date = new Date().valueOf()
|
||||
const wsUrl = process.env.VUE_APP_Socket_API + `/websocket/message?userId=EN${date}`
|
||||
// const wsUrl = 'ws://192.168.1.104:48082/websocket/message?userId=SJG'
|
||||
// const wsUrl = 'ws://10.70.2.2:8080/websocket/message?userId=EN111'
|
||||
// 实例化 WebSocket
|
||||
this.websocket = new WebSocket(wsUrl)
|
||||
// 监听 WebSocket 连接
|
||||
this.websocket.onopen = this.websocketOnOpen
|
||||
// 监听 WebSocket 错误信息
|
||||
this.websocket.onerror = this.websocketOnError
|
||||
// 监听 WebSocket 消息
|
||||
this.websocket.onmessage = this.websocketOnMessage
|
||||
// 监听 webSocket 断开信息
|
||||
this.websocket.onclose = this.websocketClose
|
||||
}
|
||||
let date = new Date().valueOf()
|
||||
const wsUrl = process.env.VUE_APP_Socket_API + `/websocket/message?userId=EN${date}`
|
||||
this.wsHeartbeat = new WebSocketHeartbeat(wsUrl);
|
||||
|
||||
// 处理收到的消息
|
||||
this.wsHeartbeat.ws.onmessage = (event) => {
|
||||
console.log('收到消息:', event.data)
|
||||
this.wsData = event?.data ? JSON.parse(event?.data) : {}
|
||||
// console.log('22222', this.wsData.data)
|
||||
if (this.wsData.type === 'EnergyMonitoring') {
|
||||
let EnergyNameList = []
|
||||
this.wsData.data.forEach((ele) => {
|
||||
EnergyNameList.push(ele.lineName)
|
||||
})
|
||||
this.EnergyMonitoringNameList = EnergyNameList
|
||||
let EnergyDataList = []
|
||||
this.wsData.data.forEach((ele) => {
|
||||
EnergyDataList.push(ele.useQuantity
|
||||
)
|
||||
})
|
||||
this.EnergyMonitoringList = EnergyDataList
|
||||
console.log(EnergyDataList)
|
||||
this.$refs.EnergyMonitoringChart.initChart(this.EnergyMonitoringNameList, this.EnergyMonitoringList)
|
||||
}
|
||||
};
|
||||
// if (typeof (WebSocket) === 'undefined') {
|
||||
// alert('您的浏览器不支持WebSocket')
|
||||
// } else {
|
||||
// const wsUrl = process.env.VUE_APP_Socket_API + `/websocket/message?userId=EN${date}`
|
||||
// // const wsUrl = 'ws://192.168.1.104:48082/websocket/message?userId=SJG'
|
||||
// // const wsUrl = 'ws://10.70.2.2:8080/websocket/message?userId=EN111'
|
||||
// // 实例化 WebSocket
|
||||
// this.websocket = new WebSocket(wsUrl)
|
||||
// // 监听 WebSocket 连接
|
||||
// this.websocket.onopen = this.websocketOnOpen
|
||||
// // 监听 WebSocket 错误信息
|
||||
// this.websocket.onerror = this.websocketOnError
|
||||
// // 监听 WebSocket 消息
|
||||
// this.websocket.onmessage = this.websocketOnMessage
|
||||
// // 监听 webSocket 断开信息
|
||||
// this.websocket.onclose = this.websocketClose
|
||||
// }
|
||||
},
|
||||
SJGInitWebSocket() {
|
||||
if (typeof (WebSocket) === 'undefined') {
|
||||
alert('您的浏览器不支持WebSocket')
|
||||
} else {
|
||||
let date = new Date().valueOf()
|
||||
// console.log(date);
|
||||
console.log(process.env);
|
||||
const SJGWsUrl = process.env.VUE_APP_Socket_API + `/websocket/message?userId=SJG${date}`
|
||||
this.SJGWebsocket = new WebSocket(SJGWsUrl)
|
||||
// 监听 WebSocket 连接
|
||||
this.SJGWebsocket.onopen = this.SJGWebsocketOnOpen
|
||||
// 监听 WebSocket 错误信息
|
||||
this.SJGWebsocket.onerror = this.SJGWebsocketOnError
|
||||
// 监听 WebSocket 消息
|
||||
this.SJGWebsocket.onmessage = this.SJGWebsocketOnMessage
|
||||
// 监听 webSocket 断开信息
|
||||
this.SJGWebsocket.onclose = this.SJGWebsocketClose
|
||||
}
|
||||
},
|
||||
SJGWebsocketOnOpen() {
|
||||
console.log('socket连接成功')
|
||||
// console.log(this.SJGWebsocket.onmessage);
|
||||
this.SJGWebsocket.onmessage()
|
||||
},
|
||||
// 连接建立失败重连
|
||||
SJGWebsocketOnError(e) {
|
||||
// console.log('11111', e)
|
||||
this.SJGInitWebSocket()
|
||||
},
|
||||
// 数据接收
|
||||
SJGWebsocketOnMessage(e) {
|
||||
// console.log(1111, e)
|
||||
this.SJGWsData = e?.data ? JSON.parse(e?.data) : {}
|
||||
// console.log(this.wsData.detData);
|
||||
// console.log('22222', this.wsData.data)
|
||||
if (this.SJGWsData.type === 'order') {
|
||||
this.orderList = this.SJGWsData.detData.map((ele, index) => {
|
||||
if (ele.progressRate != 1) {
|
||||
return {
|
||||
id: ele.id,
|
||||
name: ele.name,
|
||||
progressRate: ele.progressRate.toFixed(3)
|
||||
let date = new Date().valueOf()
|
||||
const SJGWsUrl = process.env.VUE_APP_Socket_API + `/websocket/message?userId=SJG${date}`
|
||||
this.SJGws = new WebSocketHeartbeat(SJGWsUrl);
|
||||
|
||||
// 处理收到的消息
|
||||
this.SJGws.ws.onmessage = (event) => {
|
||||
console.log('收到消息:', event.data)
|
||||
this.SJGWsData = event?.data ? JSON.parse(event?.data) : {}
|
||||
// console.log(this.wsData.detData);
|
||||
// console.log('22222', this.wsData.data)
|
||||
if (this.SJGWsData.type === 'order') {
|
||||
this.orderList = this.SJGWsData.detData.map((ele, index) => {
|
||||
if (ele.progressRate != 1) {
|
||||
return {
|
||||
id: ele.id,
|
||||
name: ele.name,
|
||||
progressRate: ele.progressRate.toFixed(3)
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
console.log(this.orderList)
|
||||
} else if (this.SJGWsData.type === 'equipment') {
|
||||
let eqArr = this.SJGWsData.detData.map((item, index) => [
|
||||
`<span style="color:rgba(255,255,255,0.5)" >${index + 1 || ''}
|
||||
});
|
||||
console.log(this.orderList)
|
||||
} else if (this.SJGWsData.type === 'equipment') {
|
||||
let eqArr = this.SJGWsData.detData.map((item, index) => [
|
||||
`<span style="color:rgba(255,255,255,0.5)" >${index + 1 || ''}
|
||||
</span>`,
|
||||
`<span style="color:rgba(255,255,255,0.5)" >${item.name || ''}
|
||||
`<span style="color:rgba(255,255,255,0.5)" >${item.name || ''}
|
||||
</span>`,
|
||||
`<span style="color:rgba(255,255,255,0.5)">${item.code || ''}</span>`,
|
||||
`<span style="color:rgba(255,255,255,0.5)">${item.status || ''}</span>`,
|
||||
`<span style="color:rgba(255,255,255,0.5)">${item.error || ''}</span>`,
|
||||
])
|
||||
this.eqConfig.data = eqArr
|
||||
this.$refs['eqScrollBoard'].updateRows(eqArr)
|
||||
// console.log(SJGWsData.orderList)
|
||||
} else if (this.SJGWsData.type === 'productline') {
|
||||
console.log('aaaaaaaaaaaaaaaaaaa', this.SJGWsData);
|
||||
let nameList = []
|
||||
let passRateList = []
|
||||
let outputNumList = []
|
||||
`<span style="color:rgba(255,255,255,0.5)">${item.code || ''}</span>`,
|
||||
`<span style="color:rgba(255,255,255,0.5)">${item.status || ''}</span>`,
|
||||
`<span style="color:rgba(255,255,255,0.5)">${item.error || ''}</span>`,
|
||||
])
|
||||
this.eqConfig.data = eqArr
|
||||
this.$refs['eqScrollBoard'].updateRows(eqArr)
|
||||
// console.log(SJGWsData.orderList)
|
||||
} else if (this.SJGWsData.type === 'productline') {
|
||||
console.log('aaaaaaaaaaaaaaaaaaa', this.SJGWsData);
|
||||
let nameList = []
|
||||
let passRateList = []
|
||||
let outputNumList = []
|
||||
this.SJGWsData.detData.forEach((ele) => {
|
||||
// if (item.id == ele.productionLineId) {
|
||||
// if (item.name.substr(0, 1) == "D") {
|
||||
// console.log(ele)
|
||||
nameList.push(ele.lineName)
|
||||
outputNumList.push(ele.outputNum)
|
||||
passRateList.push(ele.passRate)
|
||||
// }
|
||||
// if (item.name.substr(0, 1) == "D") {
|
||||
// console.log(ele)
|
||||
nameList.push(ele.lineName)
|
||||
outputNumList.push(ele.outputNum)
|
||||
passRateList.push(ele.passRate)
|
||||
// }
|
||||
// }
|
||||
})
|
||||
this.$refs.productLineChart.initChart(nameList, passRateList, outputNumList)
|
||||
} else if (this.SJGInitWebSocket === 'inspection') {
|
||||
}
|
||||
this.$refs.productLineChart.initChart(nameList, passRateList, outputNumList)
|
||||
} else if (this.SJGInitWebSocket === 'inspection') {
|
||||
}
|
||||
};
|
||||
// if (typeof (WebSocket) === 'undefined') {
|
||||
// alert('您的浏览器不支持WebSocket')
|
||||
// } else {
|
||||
// let date = new Date().valueOf()
|
||||
// // console.log(date);
|
||||
// console.log(process.env);
|
||||
// const SJGWsUrl = process.env.VUE_APP_Socket_API + `/websocket/message?userId=SJG${date}`
|
||||
// this.SJGWebsocket = new WebSocket(SJGWsUrl)
|
||||
// // 监听 WebSocket 连接
|
||||
// this.SJGWebsocket.onopen = this.SJGWebsocketOnOpen
|
||||
// // 监听 WebSocket 错误信息
|
||||
// this.SJGWebsocket.onerror = this.SJGWebsocketOnError
|
||||
// // 监听 WebSocket 消息
|
||||
// this.SJGWebsocket.onmessage = this.SJGWebsocketOnMessage
|
||||
// // 监听 webSocket 断开信息
|
||||
// this.SJGWebsocket.onclose = this.SJGWebsocketClose
|
||||
// }
|
||||
},
|
||||
// SJGWebsocketOnOpen() {
|
||||
// console.log('socket连接成功')
|
||||
// // console.log(this.SJGWebsocket.onmessage);
|
||||
// this.SJGWebsocket.onmessage()
|
||||
// },
|
||||
// // 连接建立失败重连
|
||||
// SJGWebsocketOnError(e) {
|
||||
// // console.log('11111', e)
|
||||
// this.SJGInitWebSocket()
|
||||
// },
|
||||
// 数据接收
|
||||
// SJGWebsocketOnMessage(e) {
|
||||
// console.log(1111, e)
|
||||
// this.SJGWsData = e?.data ? JSON.parse(e?.data) : {}
|
||||
// // console.log(this.wsData.detData);
|
||||
// // console.log('22222', this.wsData.data)
|
||||
// if (this.SJGWsData.type === 'order') {
|
||||
// this.orderList = this.SJGWsData.detData.map((ele, index) => {
|
||||
// if (ele.progressRate != 1) {
|
||||
// return {
|
||||
// id: ele.id,
|
||||
// name: ele.name,
|
||||
// progressRate: ele.progressRate.toFixed(3)
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
// console.log(this.orderList)
|
||||
// } else if (this.SJGWsData.type === 'equipment') {
|
||||
// let eqArr = this.SJGWsData.detData.map((item, index) => [
|
||||
// `<span style="color:rgba(255,255,255,0.5)" >${index + 1 || ''}
|
||||
// </span>`,
|
||||
// `<span style="color:rgba(255,255,255,0.5)" >${item.name || ''}
|
||||
// </span>`,
|
||||
// `<span style="color:rgba(255,255,255,0.5)">${item.code || ''}</span>`,
|
||||
// `<span style="color:rgba(255,255,255,0.5)">${item.status || ''}</span>`,
|
||||
// `<span style="color:rgba(255,255,255,0.5)">${item.error || ''}</span>`,
|
||||
// ])
|
||||
// this.eqConfig.data = eqArr
|
||||
// this.$refs['eqScrollBoard'].updateRows(eqArr)
|
||||
// // console.log(SJGWsData.orderList)
|
||||
// } else if (this.SJGWsData.type === 'productline') {
|
||||
// console.log('aaaaaaaaaaaaaaaaaaa', this.SJGWsData);
|
||||
// let nameList = []
|
||||
// let passRateList = []
|
||||
// let outputNumList = []
|
||||
// this.SJGWsData.detData.forEach((ele) => {
|
||||
// // if (item.id == ele.productionLineId) {
|
||||
// // if (item.name.substr(0, 1) == "D") {
|
||||
// // console.log(ele)
|
||||
// nameList.push(ele.lineName)
|
||||
// outputNumList.push(ele.outputNum)
|
||||
// passRateList.push(ele.passRate)
|
||||
// // }
|
||||
// // }
|
||||
// })
|
||||
// this.$refs.productLineChart.initChart(nameList, passRateList, outputNumList)
|
||||
// } else if (this.SJGInitWebSocket === 'inspection') {
|
||||
// }
|
||||
// },
|
||||
SJGWebsocketClose(e) {
|
||||
console.log('WebSocket 断开连接', e)
|
||||
this.SJGws.ws.onclose = (event) => { console.log(event); }
|
||||
},
|
||||
// // 连接建立之后执行send方法发送数据
|
||||
websocketOnOpen() {
|
||||
console.log('socket连接成功')
|
||||
this.websocket.onmessage()
|
||||
},
|
||||
// websocketOnOpen() {
|
||||
// console.log('socket连接成功')
|
||||
// this.websocket.onmessage()
|
||||
// },
|
||||
// 连接建立失败重连
|
||||
websocketOnError(e) {
|
||||
console.log('11111', e)
|
||||
this.initWebSocket()
|
||||
},
|
||||
// websocketOnError(e) {
|
||||
// console.log('11111', e)
|
||||
// this.initWebSocket()
|
||||
// },
|
||||
// 数据接收
|
||||
websocketOnMessage(e) {
|
||||
// console.log(1111, e)
|
||||
this.wsData = e?.data ? JSON.parse(e?.data) : {}
|
||||
// console.log('22222', this.wsData.data)
|
||||
if (this.wsData.type === 'EnergyMonitoring') {
|
||||
let EnergyNameList = []
|
||||
this.wsData.data.forEach((ele) => {
|
||||
EnergyNameList.push(ele.lineName)
|
||||
})
|
||||
this.EnergyMonitoringNameList = EnergyNameList
|
||||
let EnergyDataList = []
|
||||
this.wsData.data.forEach((ele) => {
|
||||
EnergyDataList.push(ele.useQuantity
|
||||
)
|
||||
})
|
||||
this.EnergyMonitoringList = EnergyDataList
|
||||
console.log(EnergyDataList)
|
||||
this.$refs.EnergyMonitoringChart.initChart(this.EnergyMonitoringNameList, this.EnergyMonitoringList)
|
||||
}
|
||||
},
|
||||
// websocketOnMessage(e) {
|
||||
// // console.log(1111, e)
|
||||
// this.wsData = e?.data ? JSON.parse(e?.data) : {}
|
||||
// // console.log('22222', this.wsData.data)
|
||||
// if (this.wsData.type === 'EnergyMonitoring') {
|
||||
// let EnergyNameList = []
|
||||
// this.wsData.data.forEach((ele) => {
|
||||
// EnergyNameList.push(ele.lineName)
|
||||
// })
|
||||
// this.EnergyMonitoringNameList = EnergyNameList
|
||||
// let EnergyDataList = []
|
||||
// this.wsData.data.forEach((ele) => {
|
||||
// EnergyDataList.push(ele.useQuantity
|
||||
// )
|
||||
// })
|
||||
// this.EnergyMonitoringList = EnergyDataList
|
||||
// console.log(EnergyDataList)
|
||||
// this.$refs.EnergyMonitoringChart.initChart(this.EnergyMonitoringNameList, this.EnergyMonitoringList)
|
||||
// }
|
||||
// },
|
||||
// 数据发送
|
||||
websocketSend() {
|
||||
this.websocket.send('11111')
|
||||
},
|
||||
// 关闭
|
||||
// websocketSend() {
|
||||
// this.websocket.send('11111')
|
||||
// },
|
||||
// // 关闭
|
||||
websocketClose(e) {
|
||||
// console.log('WebSocket 断开连接', e)
|
||||
this.wsHeartbeat.ws.onclose = (event) => { console.log(event); }
|
||||
},
|
||||
windowWidth(value) {
|
||||
this.clientWidth = value
|
||||
|
||||
Reference in New Issue
Block a user