ws心跳检查

This commit is contained in:
2024-03-26 17:16:52 +08:00
parent f844834453
commit 1c0dba7dbb
8 changed files with 335 additions and 331 deletions

View File

@@ -6,28 +6,33 @@ import store from "@/store";
const timestr = new Date().getTime()
const dcsConn = new WsConnect(
// websocket地址
process.env.VUE_APP_Socket_Dcs_API + '/xc-screen/websocket/dcsmsg'+timestr,
process.env.VUE_APP_Socket_Dcs_API + '/xc-screen/websocket/dcsmsg' + timestr,
// 传递给后台的数据
'',
(data) => {
// console.log('dcs成功的回调函数, 接收到的data数据: ', data)
let msgData = JSON.parse(data)
let msgData = {}
try {
msgData = JSON.parse(data)
} catch (error) {
console.log("websocket: [unable to msgData] : ", data);
}
if (msgData == null) return;
switch (msgData?.type) {
case "FanFrequencyInfo": {
store.dispatch({type: "websocket/setFanFrequencyInfo", payload:msgData.data.FanFrequencyInfo})
store.dispatch({ type: "websocket/setFanFrequencyInfo", payload: msgData.data.FanFrequencyInfo })
break;
}
case "KilnInfo": {
store.dispatch({type: "websocket/setKilnInfo", payload: msgData.data})
store.dispatch({ type: "websocket/setKilnInfo", payload: msgData.data })
break;
}
case "GasInfo": {
store.dispatch({type: "websocket/setGasInfo", payload: msgData.data})
store.dispatch({ type: "websocket/setGasInfo", payload: msgData.data })
break;
}
case "SumGasInfo": {
store.dispatch({type: "websocket/setSumGasInfo", payload: msgData.data})
store.dispatch({ type: "websocket/setSumGasInfo", payload: msgData.data })
break;
}
default:
@@ -39,16 +44,20 @@ const dcsConn = new WsConnect(
)
// ISRA
const mesIsra = new WsConnect(
process.env.VUE_APP_Socket_API + '/websocket/message?userId=KILN'+timestr,
process.env.VUE_APP_Socket_API + '/websocket/message?userId=KILN' + timestr,
'',
(data) => {
// console.log('mes ISRA成功的回调函数, 接收到的data数据: ', data)
let msgData = JSON.parse(data)
// console.log(msgData)
let msgData = {}
try {
msgData = JSON.parse(data)
} catch (error) {
console.log("websocket: [unable to msgData] : ", data);
}
if (msgData == null) return;
switch (msgData?.type) {
case "israKiln": {
store.dispatch({type: "websocket/setIsraKiln", payload:msgData.detData.dayStatistic})
store.dispatch({ type: "websocket/setIsraKiln", payload: msgData.detData.dayStatistic })
break;
}
default:
@@ -61,15 +70,20 @@ const mesIsra = new WsConnect(
// 原料 MA
const mesMA = new WsConnect(
process.env.VUE_APP_Socket_API + '/websocket/message?userId=MA'+timestr,
process.env.VUE_APP_Socket_API + '/websocket/message?userId=MA' + timestr,
'',
(data) => {
// console.log('mes 原料成功的回调函数, 接收到的data数据: ', data)
let msgData = JSON.parse(data)
let msgData = {}
try {
msgData = JSON.parse(data)
} catch (error) {
console.log("websocket: [unable to msgData] : ", data);
}
if (msgData == null) return;
switch (msgData?.type) {
case "material": {
store.dispatch({type: "websocket/setMaterial", payload:msgData.data})
store.dispatch({ type: "websocket/setMaterial", payload: msgData.data })
break;
}
default:
@@ -82,25 +96,30 @@ const mesMA = new WsConnect(
// 能耗 EN
const mesEN = new WsConnect(
// websocket地址
process.env.VUE_APP_Socket_API + '/websocket/message?userId=ENERGY'+timestr,
process.env.VUE_APP_Socket_API + '/websocket/message?userId=ENERGY' + timestr,
// 传递给后台的数据
'',
// 成功拿到后台返回的数据的回调函数
(data) => {
// console.log('mes 能耗成功的回调函数, 接收到的data数据: ', data)
let msgData = JSON.parse(data)
let msgData = {}
try {
msgData = JSON.parse(data)
} catch (error) {
console.log("websocket: [unable to msgData] : ", data);
}
if (msgData == null) return;
switch (msgData?.type) {
case "EnergyInfo": {
store.dispatch({type: "websocket/setEnergyInfo", payload:msgData.data})
store.dispatch({ type: "websocket/setEnergyInfo", payload: msgData.data })
break;
}
case "EnergyTrend": {
store.dispatch({type: "websocket/setEnergyTrend", payload:msgData.data})
store.dispatch({ type: "websocket/setEnergyTrend", payload: msgData.data })
break;
}
case "EnergyMonitoring": {
store.dispatch({type: "websocket/setEnergyMonitoring", payload:msgData.data})
store.dispatch({ type: "websocket/setEnergyMonitoring", payload: msgData.data })
break;
}
default:
@@ -114,23 +133,30 @@ const mesEN = new WsConnect(
// 烟气 GAS
const mesGAS = new WsConnect(
// websocket地址
process.env.VUE_APP_Socket_API + '/websocket/message?userId=GAS'+timestr,
process.env.VUE_APP_Socket_API + '/websocket/message?userId=GAS' + timestr,
// 传递给后台的数据
'',
// 成功拿到后台返回的数据的回调函数
(data) => {
// console.log('mes 烟气成功的回调函数, 接收到的data数据: ', data)
let msgData = JSON.parse(data)
let msgData = {}
try {
msgData = JSON.parse(data)
} catch (error) {
console.log("websocket: [unable to msgData] : ", data);
}
if (msgData == null) return;
switch (msgData?.type) {
case "exhaustGas": {
store.dispatch({type: "websocket/setExhaustGasInfo", payload:msgData.realtime})
store.dispatch({type: "websocket/setExhaustGasChart", payload:{
dayTrend: msgData.dayTrend,
weekTrend: msgData.weekTrend,
monthTrend: msgData.monthTrend,
yearTrend: msgData.yearTrend,
}})
store.dispatch({ type: "websocket/setExhaustGasInfo", payload: msgData.realtime })
store.dispatch({
type: "websocket/setExhaustGasChart", payload: {
dayTrend: msgData.dayTrend,
weekTrend: msgData.weekTrend,
monthTrend: msgData.monthTrend,
yearTrend: msgData.yearTrend,
}
})
break;
}
default:
@@ -145,23 +171,30 @@ const mesGAS = new WsConnect(
// 缺陷分类/统计 IS
const mesIS = new WsConnect(
// websocket地址
process.env.VUE_APP_Socket_API + '/websocket/message?userId=IS'+timestr,
process.env.VUE_APP_Socket_API + '/websocket/message?userId=IS' + timestr,
// 传递给后台的数据
'',
// 成功拿到后台返回的数据的回调函数
(data) => {
// console.log('mes 缺陷成功的回调函数, 接收到的data数据: ', data)
let msgData = JSON.parse(data)
let msgData = {}
try {
msgData = JSON.parse(data)
} catch (error) {
console.log("websocket: [unable to msgData] : ", data);
}
if (msgData == null) return;
switch (msgData?.type) {
case "isra": {
store.dispatch({type: "websocket/setDefectChart", payload:{
checkType: msgData.detData.checkType,
dayStatistic: msgData.detData.dayStatistic,
weekStatistic: msgData.detData.weekStatistic,
monthStatistic: msgData.detData.monthStatistic,
yearStatistic: msgData.detData.yearStatistic,
}})
store.dispatch({
type: "websocket/setDefectChart", payload: {
checkType: msgData.detData.checkType,
dayStatistic: msgData.detData.dayStatistic,
weekStatistic: msgData.detData.weekStatistic,
monthStatistic: msgData.detData.monthStatistic,
yearStatistic: msgData.detData.yearStatistic,
}
})
break;
}
default:
@@ -176,29 +209,34 @@ const mesIS = new WsConnect(
// 深加工生产运行驾驶舱(除能源) SJG
const mesSJG = new WsConnect(
// websocket地址
process.env.VUE_APP_Socket_API + '/websocket/message?userId=SJG'+timestr,
process.env.VUE_APP_Socket_API + '/websocket/message?userId=SJG' + timestr,
// 传递给后台的数据
'',
// 成功拿到后台返回的数据的回调函数
(data) => {
// console.log('mes 产线产量及良品率成功的回调函数, 接收到的data数据: ', data)
let msgData = JSON.parse(data)
let msgData = {}
try {
msgData = JSON.parse(data)
} catch (error) {
console.log("websocket: [unable to msgData] : ", data);
}
if (msgData == null) return;
switch (msgData?.type) {
case "productline": {
store.dispatch({type: "websocket/setProductline", payload:msgData.detData})
store.dispatch({ type: "websocket/setProductline", payload: msgData.detData })
break;
}
case "equipment": {
store.dispatch({type: "websocket/setSJGEq", payload:msgData.detData})
store.dispatch({ type: "websocket/setSJGEq", payload: msgData.detData })
break;
}
case "order": {
store.dispatch({type: "websocket/setWorkOrder", payload:msgData.detData})
store.dispatch({ type: "websocket/setWorkOrder", payload: msgData.detData })
break;
}
case "defectSum": {
store.dispatch({type: "websocket/setDefectSum", payload:msgData.detData})
store.dispatch({ type: "websocket/setDefectSum", payload: msgData.detData })
break;
}
default:
@@ -213,18 +251,23 @@ const mesSJG = new WsConnect(
// 订单完成情况 OV
const mesOV = new WsConnect(
// websocket地址
process.env.VUE_APP_Socket_API + '/websocket/message?userId=OV'+timestr,
process.env.VUE_APP_Socket_API + '/websocket/message?userId=OV' + timestr,
// 'ws://192.168.0.33:48082/websocket/message?userId=OV'+timestr,
// 传递给后台的数据
'',
// 成功拿到后台返回的数据的回调函数
(data) => {
// console.log('mes 产线产量及良品率成功的回调函数, 接收到的data数据: ', data)
let msgData = JSON.parse(data)
let msgData = {}
try {
msgData = JSON.parse(data)
} catch (error) {
console.log("websocket: [unable to msgData] : ", data);
}
if (msgData == null) return;
switch (msgData?.type) {
case "order": {
store.dispatch({type: "websocket/setOrder", payload:msgData.detData})
store.dispatch({ type: "websocket/setOrder", payload: msgData.detData })
break;
}
default:
@@ -239,35 +282,39 @@ const mesOV = new WsConnect(
// 本日生产良品率 CUTTING
const mesCUTTING = new WsConnect(
// websocket地址
process.env.VUE_APP_Socket_API + '/websocket/message?userId=CUTTING'+timestr,
process.env.VUE_APP_Socket_API + '/websocket/message?userId=CUTTING' + timestr,
// 传递给后台的数据
'',
// 成功拿到后台返回的数据的回调函数
(data) => {
// console.log('mes 产线产量及良品率成功的回调函数, 接收到的data数据: ', data)
let msgData = JSON.parse(data)
let msgData = {}
try {
msgData = JSON.parse(data)
} catch (error) {
console.log("websocket: [unable to msgData] : ", data);
}
if (msgData == null) return;
console.log(msgData)
switch (msgData?.type) {
case "cutting": {
if (msgData?.name === 'table') {
store.dispatch({type: "websocket/setYieldRateTable", payload:msgData.data})
store.dispatch({ type: "websocket/setYieldRateTable", payload: msgData.data })
return
}
if (msgData?.dateType === 'day') {
store.dispatch({type: "websocket/setCutChartDay", payload:msgData.detData})
store.dispatch({ type: "websocket/setCutChartDay", payload: msgData.detData })
return
}
if (msgData?.dateType === 'weekly') {
store.dispatch({type: "websocket/setCutChartWeek", payload:msgData.detData})
store.dispatch({ type: "websocket/setCutChartWeek", payload: msgData.detData })
return
}
if (msgData?.dateType === 'month') {
store.dispatch({type: "websocket/setCutChartMonth", payload:msgData.detData})
store.dispatch({ type: "websocket/setCutChartMonth", payload: msgData.detData })
return
}
if (msgData?.dateType === 'year') {
store.dispatch({type: "websocket/setCutChartYear", payload:msgData.detData})
store.dispatch({ type: "websocket/setCutChartYear", payload: msgData.detData })
return
}
break;