From d647dc0448ded5d750d325a8deaaf7ed3547b433 Mon Sep 17 00:00:00 2001 From: lb Date: Wed, 20 Dec 2023 17:01:40 +0800 Subject: [PATCH 1/6] update --- src/views/specialEquipment/maintain/Record.vue | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/views/specialEquipment/maintain/Record.vue b/src/views/specialEquipment/maintain/Record.vue index bf33d9a0..be4d1309 100644 --- a/src/views/specialEquipment/maintain/Record.vue +++ b/src/views/specialEquipment/maintain/Record.vue @@ -195,18 +195,21 @@ export default { { id: 3, name: '特种设备' }, ], filterable: true, + defaultSelect: null }, { type: 'select', label: '设备', placeholder: '请选择设备', param: 'equipmentId', + defaultSelect: null }, { type: 'select', label: '计划名称', placeholder: '请选择计划名称', param: 'maintainPlanId', + defaultSelect: null }, // 开始结束时间 { @@ -220,6 +223,7 @@ export default { endPlaceholder: '结束日期', defaultTime: ['00:00:00', '23:59:59'], param: 'startTime', + defaultSelect: null // width: 350, }, { @@ -229,6 +233,7 @@ export default { { name: '是', id: 1 }, { name: '否', id: 2 }, ], + defaultSelect: null, param: 'relatePlan', }, { @@ -434,12 +439,16 @@ export default { created() { this.initSearchBar(); if (this.$route.query) { + this.queryParams.specialType = + this.$route.query?.specialType ?? undefined; this.queryParams.equipmentId = this.$route.query?.equipmentId ?? undefined; this.queryParams.maintainPlanId = this.$route.query?.maintainPlanId ?? undefined; this.queryParams.relatePlan = this.$route.query?.relatePlan ?? undefined; this.queryParams.startTime = this.$route.query?.createTime ?? undefined; + this.searchBarFormConfig[0].defaultSelect = + this.$route.query.specialType ?? undefined; this.searchBarFormConfig[1].defaultSelect = this.$route.query.equipmentId ?? undefined; this.searchBarFormConfig[2].defaultSelect = From 5974e7026e7dc872a0b26be0ec60940ed7499ff9 Mon Sep 17 00:00:00 2001 From: lb Date: Thu, 21 Dec 2023 10:26:56 +0800 Subject: [PATCH 2/6] update kiln databorad --- src/views/databoard/kiln/index.vue | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/src/views/databoard/kiln/index.vue b/src/views/databoard/kiln/index.vue index 6d005504..12eef32c 100644 --- a/src/views/databoard/kiln/index.vue +++ b/src/views/databoard/kiln/index.vue @@ -6,18 +6,7 @@ --> diff --git a/src/views/databoard/kiln/FanSequence.vue b/src/views/databoard/kiln/FanSequence.vue index ca8b8648..c23c6316 100644 --- a/src/views/databoard/kiln/FanSequence.vue +++ b/src/views/databoard/kiln/FanSequence.vue @@ -7,13 +7,13 @@ + \ No newline at end of file diff --git a/src/views/databoard/wholePlant/LeftTwo.vue b/src/views/databoard/wholePlant/LeftTwo.vue index 0a21c83e..f3f1a075 100644 --- a/src/views/databoard/wholePlant/LeftTwo.vue +++ b/src/views/databoard/wholePlant/LeftTwo.vue @@ -4,7 +4,7 @@ style=" display: grid; gap: 16px; - grid-template-rows: 462px 462px; + grid-template-rows: 308px 616px; "> diff --git a/src/views/databoard/wholePlant/MiddleTwo.vue b/src/views/databoard/wholePlant/MiddleTwo.vue index 9a65aeba..3c974b92 100644 --- a/src/views/databoard/wholePlant/MiddleTwo.vue +++ b/src/views/databoard/wholePlant/MiddleTwo.vue @@ -4,19 +4,19 @@ style=" display: grid; gap: 16px; - grid-template-rows: 462px 462px; + grid-template-rows: 605px 320px; "> - - + + \ No newline at end of file + + \ No newline at end of file diff --git a/src/views/databoard/wholePlant/RightTwo.vue b/src/views/databoard/wholePlant/RightTwo.vue index 0cc9ec58..0d444ac2 100644 --- a/src/views/databoard/wholePlant/RightTwo.vue +++ b/src/views/databoard/wholePlant/RightTwo.vue @@ -6,17 +6,17 @@ gap: 16px; grid-template-rows: 462px 462px; "> - + \ No newline at end of file + + \ No newline at end of file diff --git a/src/views/databoard/wholePlant/index.vue b/src/views/databoard/wholePlant/index.vue index d1941e73..dd9cdf37 100644 --- a/src/views/databoard/wholePlant/index.vue +++ b/src/views/databoard/wholePlant/index.vue @@ -8,8 +8,8 @@ position: absolute; transform-origin: 16px 8px; font-size: 16px; - top: -8px; - left: -16px; + top: 0px; + left: 0px; width: 1920px; height: 1080px; display: flex; @@ -42,7 +42,6 @@ import MiddleTwo from './MiddleTwo'; import RightTwo from './RightTwo'; import screenfull from 'screenfull' import { debounce } from '@/utils/debounce' -import { getDcsMsg, getMesMsg } from './../utils/wsInterface' export default { name: 'wholePlantBoard', @@ -77,9 +76,6 @@ export default { window.addEventListener('resize', () => { this.boxReset() }) - // closeWebsocket() - // getDcsMsg() - // getMesMsg() console.log('mounted...........') }, destroyed() { diff --git a/src/websocket/websocket.js b/src/websocket/websocket.js new file mode 100644 index 00000000..49467b81 --- /dev/null +++ b/src/websocket/websocket.js @@ -0,0 +1,176 @@ +/** + * 发起websocket请求函数 + * @param {string} url ws连接地址 + * @param {Object} agentData 传给后台的参数 + * @param {function} successCallback 接收到ws数据,对数据进行处理的回调函数 + * @param {function} errCallback ws连接错误的回调函数 + */ +export function WsConnect(url, agentData, successCallback, errCallback) { + this.wsUrl = url; + this.wsObj = null; + // 是否执行重连 true/不执行 ; false/执行 + this.lockReconnect = false; + // 重连定时器 + this.wsCreateHandler = null; + // 连接成功,执行回调函数 + this.messageCallback = successCallback; + // 连接失败,执行回调函数 + this.errorCallback = errCallback; + // 发送给后台的数据 + this.sendDatas = agentData; + // 创建ws函数 + this.createWebSoket = () => { + if (typeof WebSocket === "undefined") { + writeToScreen("您的浏览器不支持WebSocket,无法获取数据"); + return false; + } + try { + this.wsObj = new WebSocket(url); + initWsEventHandle(); + } catch (e) { + writeToScreen("连接异常,开始重连"); + reconnect(); + } + }; + // 手动关闭websocket (这里手动关闭会执行onclose事件) + this.closeWebsocket = () => { + if (this.wsObj) { + writeToScreen("手动关闭websocket"); + this.wsObj.close(); // 关闭websocket + // this.wsObj.onclose() // 关闭websocket(如果上面的关闭不生效就加上这一条) + // 关闭重连 + this.lockReconnect = true; + this.wsCreateHandler && clearTimeout(this.wsCreateHandler); + // 关闭心跳检查 + heartCheck.stop(); + } + }; + const initWsEventHandle = () => { + try { + // 连接成功 + this.wsObj.onopen = (event) => { + onWsOpen(event); + heartCheck.start(); + }; + + // 监听服务器端返回的信息 + this.wsObj.onmessage = (event) => { + onWsMessage(event); + heartCheck.start(); + }; + + this.wsObj.onclose = (event) => { + writeToScreen("onclose执行关闭事件"); + onWsClose(event); + }; + + this.wsObj.onerror = (event) => { + writeToScreen("onerror执行error事件,开始重连"); + onWsError(event); + reconnect(); + }; + } catch (err) { + writeToScreen("绑定事件没有成功,开始重连"); + reconnect(); + } + }; + + const onWsOpen = (event) => { + writeToScreen("CONNECT"); + // // 客户端与服务器端通信 + // wsObj.send('我发送消息给服务端'); + // 添加状态判断,当为OPEN时,发送消息 + if (this.wsObj.readyState === this.wsObj.OPEN) { + // wsObj.OPEN = 1 + // 发给后端的数据需要字符串化 + this.wsObj.send(JSON.stringify(this.sendDatas)); + } + if (this.wsObj.readyState === this.wsObj.CLOSED) { + // wsObj.CLOSED = 3 + writeToScreen("wsObj.readyState=3, ws连接异常,开始重连"); + reconnect(); + this.errorCallback(event); + } + }; + const onWsMessage = (event) => { + const jsonStr = event.data; + writeToScreen("onWsMessage接收到服务器的数据: ", jsonStr); + this.messageCallback(jsonStr); + }; + const onWsClose = (event) => { + writeToScreen("DISCONNECT"); + // e.code === 1000 表示正常关闭。 无论为何目的而创建, 该链接都已成功完成任务。 + // e.code !== 1000 表示非正常关闭。 + console.log("onclose event: ", event); + if (event && event.code !== 1000) { + writeToScreen("非正常关闭"); + this.errorCallback(event); + // 如果不是手动关闭,这里的重连会执行;如果调用了手动关闭函数,这里重连不会执行 + reconnect(); + } + }; + const onWsError = (event) => { + writeToScreen("onWsError: ", event.data); + this.errorCallback(event); + }; + + const writeToScreen = (massage) => { + console.log(massage); + }; + + // 重连函数 + const reconnect = () => { + if (this.lockReconnect) { + return; + } + writeToScreen("3秒后重连"); + this.lockReconnect = true; + // 没连接上会一直重连,设置延迟避免请求过多 + this.wsCreateHandler && clearTimeout(this.wsCreateHandler); + this.wsCreateHandler = setTimeout(() => { + writeToScreen("重连..." + this.wsUrl); + this.createWebSoket(); + this.lockReconnect = false; + writeToScreen("重连完成"); + }, 3000); + }; + + // 心跳检查(看看websocket是否还在正常连接中) + let heartCheck = { + timeout: 15000, + timeoutObj: null, + serverTimeoutObj: null, + // 重启 + reset() { + clearTimeout(this.timeoutObj); + clearTimeout(this.serverTimeoutObj); + this.start(); + }, + // 停止 + stop() { + clearTimeout(this.timeoutObj); + clearTimeout(this.serverTimeoutObj); + }, + // 开启定时器 + start() { + this.timeoutObj && clearTimeout(this.timeoutObj); + this.serverTimeoutObj && clearTimeout(this.serverTimeoutObj); + // 15s之内如果没有收到后台的消息,则认为是连接断开了,需要重连 + this.timeoutObj = setTimeout(() => { + writeToScreen("心跳检查,发送ping到后台"); + try { + const datas = { ping: true }; + this.wsObj.send(JSON.stringify(datas)); + } catch (err) { + writeToScreen("发送ping异常"); + } + console.log("内嵌定时器this.serverTimeoutObj: ", this.serverTimeoutObj); + // 内嵌定时器 + this.serverTimeoutObj = setTimeout(() => { + writeToScreen("没有收到后台的数据,重新连接"); + reconnect(); + }, this.timeout); + }, this.timeout); + }, + }; +} diff --git a/src/websocket/wsInterface.js b/src/websocket/wsInterface.js new file mode 100644 index 00000000..3572dc58 --- /dev/null +++ b/src/websocket/wsInterface.js @@ -0,0 +1,160 @@ +import { WsConnect } from './websocket' +import store from "@/store"; + +// 创建websocket链接 + +const timestr = new Date().getTime() +const dcsConn = new WsConnect( + // websocket地址 + 'ws://10.70.180.10:8081/xc-screen/websocket/dcsmsg'+timestr, + // 传递给后台的数据 + '', + (data) => { + // console.log('dcs成功的回调函数, 接收到的data数据: ', data) + let msgData = JSON.parse(data) + if (msgData == null) return; + switch (msgData?.type) { + case "FanFrequencyInfo": { + store.dispatch({type: "websocket/setFanFrequencyInfo", payload:msgData.data.FanFrequencyInfo}) + break; + } + case "KilnInfo": { + store.dispatch({type: "websocket/setKilnInfo", payload: msgData.data}) + break; + } + case "GasInfo": { + store.dispatch({type: "websocket/setGasInfo", payload: msgData.data}) + break; + } + case "SumGasInfo": { + store.dispatch({type: "websocket/setSumGasInfo", payload: msgData.data}) + break; + } + default: + } + }, + (err) => { + console.log('失败的回调函数', err) + } +) +const mesIsra = new WsConnect( + 'ws://10.70.2.2:8080/websocket/message?userId=KILN'+timestr, + '', + (data) => { + // console.log('mes ISRA成功的回调函数, 接收到的data数据: ', data) + let msgData = JSON.parse(data) + // console.log(msgData) + if (msgData == null) return; + switch (msgData?.type) { + case "israKiln": { + store.dispatch({type: "websocket/setIsraKiln", payload:msgData.detData.dayStatistic}) + break; + } + // case "KilnInfo": { + // // store.dispatch({type: "websocket/setKilnInfo", payload: msgData.data.kilnInfo}) + // break; + // } + default: + } + }, + (err) => { + console.log('失败的回调函数', err) + } +) + +// 原料 MA +const mesMA = new WsConnect( + 'ws://10.70.2.2:8080/websocket/message?userId=MA'+timestr, + '', + (data) => { + // console.log('mes 原料成功的回调函数, 接收到的data数据: ', data) + let msgData = JSON.parse(data) + if (msgData == null) return; + switch (msgData?.type) { + case "material": { + store.dispatch({type: "websocket/setMaterial", payload:msgData.data}) + break; + } + // case "KilnInfo": { + // // store.dispatch({type: "websocket/setKilnInfo", payload: msgData.data.kilnInfo}) + // break; + // } + default: + } + }, + (err) => { + console.log('失败的回调函数', err) + } +) +// 能耗 EN +const mesEN = new WsConnect( + // websocket地址 + 'ws://10.70.2.2:8080/websocket/message?userId=ENERGY'+timestr, + // 传递给后台的数据 + '', + // 成功拿到后台返回的数据的回调函数 + (data) => { + // console.log('mes 能耗成功的回调函数, 接收到的data数据: ', data) + let msgData = JSON.parse(data) + if (msgData == null) return; + switch (msgData?.type) { + case "EnergyInfo": { + store.dispatch({type: "websocket/setEnergyInfo", payload:msgData.data}) + break; + } + case "EnergyTrend": { + store.dispatch({type: "websocket/setEnergyTrend", payload:msgData.data}) + break; + } + default: + } + }, + // websocket连接失败的回调函数 + (err) => { + console.log('失败的回调函数', err) + } +) +// 烟气 GAS +const mesGAS = new WsConnect( + // websocket地址 + 'ws://10.70.2.2:8080/websocket/message?userId=GAS'+timestr, + // 传递给后台的数据 + '', + // 成功拿到后台返回的数据的回调函数 + (data) => { + // console.log('mes 烟气成功的回调函数, 接收到的data数据: ', data) + let msgData = JSON.parse(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, + }}) + break; + } + default: + } + }, + // websocket连接失败的回调函数 + (err) => { + console.log('失败的回调函数', err) + } +) +export const getDcsMsg = () => { + dcsConn.createWebSoket() + mesIsra.createWebSoket() + mesMA.createWebSoket() + mesEN.createWebSoket() + mesGAS.createWebSoket() +} +export const closeDcsMsg = () => { + dcsConn.closeWebsocket() + mesIsra.closeWebsocket() + mesMA.closeWebsocket() + mesEN.closeWebsocket() + mesGAS.closeWebsocket() +} \ No newline at end of file From 522910e4329cbffebb214a75b0e6fdb338140121 Mon Sep 17 00:00:00 2001 From: gtz <535262213@qq.com> Date: Thu, 4 Jan 2024 08:27:12 +0800 Subject: [PATCH 6/6] 'update_coldboard' --- .env.dev | 4 +- src/views/OperationalOverview/coldBoard.vue | 54 ++++++++++----------- 2 files changed, 29 insertions(+), 29 deletions(-) diff --git a/.env.dev b/.env.dev index 44f8ea48..5d905f0a 100644 --- a/.env.dev +++ b/.env.dev @@ -16,7 +16,7 @@ VUE_APP_TITLE = MES系统 # VUE_APP_BASE_API = 'http://192.168.0.33:48082' -# VUE_APP_BASE_API = 'http://10.70.2.2:8080' +VUE_APP_BASE_API = 'http://10.70.2.2:8080' # VUE_APP_BASE_API = 'http://192.168.4.173:48080' # VUE_APP_BASE_API = 'http://192.168.2.173:48080' @@ -28,7 +28,7 @@ VUE_APP_TITLE = MES系统 # VUE_APP_BASE_API = 'http://192.168.1.78:48082' -VUE_APP_BASE_API = 'http://100.64.0.23:48082' +# VUE_APP_BASE_API = 'http://100.64.0.23:48082' # 积木报表指向地址 VUE_APP_JIMU_API = 'http://10.70.2.22:8080' diff --git a/src/views/OperationalOverview/coldBoard.vue b/src/views/OperationalOverview/coldBoard.vue index 3a337e53..9449653c 100644 --- a/src/views/OperationalOverview/coldBoard.vue +++ b/src/views/OperationalOverview/coldBoard.vue @@ -518,32 +518,8 @@ export default { }) } this.annealFunList = arr - this.total3 = Math.ceil(arr.length / 9) - if ( this.page3 > this.total3) { - this.page3 = 1 - } - if (!this.firstContent3) { - setInterval(pageFun3 = () => { - if (this.page3 >= this.total3) { - this.page3 = 1 - } else { - this.page3 += 1 - } - }, 30000) - this.firstContent3 = true - } - } - if (this.funWsData.type === 'FanInfo') { - let arr = [] - for (let i in this.funWsData.data.fanInfo) { - arr.push({ - equipmentName: i, - status: this.funWsData.data.fanInfo[i] - }) - } - this.funList = arr this.total4 = Math.ceil(arr.length / 9) - if ( this.page4 > this.total4) { + if ( this.page4 >= this.total4) { this.page4 = 1 } if (!this.firstContent4) { @@ -557,6 +533,30 @@ export default { this.firstContent4 = true } } + if (this.funWsData.type === 'FanInfo') { + let arr = [] + for (let i in this.funWsData.data.fanInfo) { + arr.push({ + equipmentName: i, + status: this.funWsData.data.fanInfo[i] + }) + } + this.funList = arr + this.total3 = Math.ceil(arr.length / 9) + if ( this.page3 >= this.total3) { + this.page3 = 1 + } + if (!this.firstContent3) { + setInterval(pageFun3 = () => { + if (this.page3 >= this.total3) { + this.page3 = 1 + } else { + this.page3 += 1 + } + }, 30000) + this.firstContent3 = true + } + } }, cutWebsocketOnOpen() { console.log('socket连接成功') @@ -585,7 +585,7 @@ export default { // } }); this.total1 = Math.ceil(this.cutWsData?.productHourData?.length / 9) - if ( this.page1 > this.total1) { + if ( this.page1 >= this.total1) { this.page1 = 1 } if (!this.firstContent1) { @@ -648,7 +648,7 @@ export default { }); this.total2 = Math.ceil(this.SJGWsData?.detData?.length / 9) - if ( this.page2 > this.total2) { + if ( this.page2 >= this.total2) { this.page2 = 1 } if (!this.firstContent2) {