-
+
+
diff --git a/src/views/databoard/kiln/LeftFour.vue b/src/views/databoard/kiln/LeftFour.vue
index 14028e92..3dc26580 100644
--- a/src/views/databoard/kiln/LeftFour.vue
+++ b/src/views/databoard/kiln/LeftFour.vue
@@ -12,7 +12,7 @@
display: grid;
gap: 16px;
grid-template-columns: 1fr 1fr;
- grid-template-rows: 1fr 1fr;
+ grid-template-rows: 462px 462px;
">
@@ -25,7 +25,7 @@
import MaterialCost from './MaterialCost.vue';
import FanSequence from './FanSequence.vue';
import IsraCheck from './IsraCheck.vue';
-import EnergeCost from './EnergeCost.vue';
+import EnergeCost from './EnergeCost';
export default {
name: 'LeftFour',
components: { MaterialCost, EnergeCost, IsraCheck, FanSequence },
diff --git a/src/views/databoard/kiln/MaterialCost.vue b/src/views/databoard/kiln/MaterialCost.vue
index 319dab01..3ce4ddde 100644
--- a/src/views/databoard/kiln/MaterialCost.vue
+++ b/src/views/databoard/kiln/MaterialCost.vue
@@ -7,41 +7,71 @@
-
-
-
-
- 234
-
-
- - 原料1/吨 -
-
-
-
+
+
+
+
+
+ {{item.materialUsed}}
+
+
+ - {{item.materialName}}/kg-
+
+
+
+
+
+
+
+
+ {{item.materialUsed}}
+
+
+ - {{item.materialName}}/kg-
+
+
+
+
+
diff --git a/src/views/databoard/kiln/RightTwo.vue b/src/views/databoard/kiln/RightTwo.vue
index 001e7116..78c3b150 100644
--- a/src/views/databoard/kiln/RightTwo.vue
+++ b/src/views/databoard/kiln/RightTwo.vue
@@ -8,18 +8,22 @@
+ style="
+ display: grid;
+ gap: 16px;
+ grid-template-rows: 320px 605px;
+ ">
@@ -66,5 +144,6 @@ export default {
background: url(../assets/bg.png) no-repeat;
background-size: cover;
background-position: 0 0;
+ overflow: auto;
}
diff --git a/src/views/databoard/mixins/resize.js b/src/views/databoard/mixins/resize.js
new file mode 100644
index 00000000..234953b1
--- /dev/null
+++ b/src/views/databoard/mixins/resize.js
@@ -0,0 +1,55 @@
+import { debounce } from '@/utils'
+
+export default {
+ data() {
+ return {
+ $_sidebarElm: null,
+ $_resizeHandler: null
+ }
+ },
+ mounted() {
+ this.$_resizeHandler = debounce(() => {
+ if (this.chart) {
+ this.chart.resize()
+ }
+ }, 100)
+ this.$_initResizeEvent()
+ this.$_initSidebarResizeEvent()
+ },
+ beforeDestroy() {
+ this.$_destroyResizeEvent()
+ this.$_destroySidebarResizeEvent()
+ },
+ // to fixed bug when cached by keep-alive
+ // https://github.com/PanJiaChen/vue-element-admin/issues/2116
+ activated() {
+ this.$_initResizeEvent()
+ this.$_initSidebarResizeEvent()
+ },
+ deactivated() {
+ this.$_destroyResizeEvent()
+ this.$_destroySidebarResizeEvent()
+ },
+ methods: {
+ // use $_ for mixins properties
+ // https://vuejs.org/v2/style-guide/index.html#Private-property-names-essential
+ $_initResizeEvent() {
+ window.addEventListener('resize', this.$_resizeHandler)
+ },
+ $_destroyResizeEvent() {
+ window.removeEventListener('resize', this.$_resizeHandler)
+ },
+ $_sidebarResizeHandler(e) {
+ if (e.propertyName === 'width') {
+ this.$_resizeHandler()
+ }
+ },
+ $_initSidebarResizeEvent() {
+ this.$_sidebarElm = document.getElementsByClassName('sidebar-container')[0]
+ this.$_sidebarElm && this.$_sidebarElm.addEventListener('transitionend', this.$_sidebarResizeHandler)
+ },
+ $_destroySidebarResizeEvent() {
+ this.$_sidebarElm && this.$_sidebarElm.removeEventListener('transitionend', this.$_sidebarResizeHandler)
+ }
+ }
+}
diff --git a/src/views/databoard/utils/websocket.js b/src/views/databoard/utils/websocket.js
new file mode 100644
index 00000000..52fbd44b
--- /dev/null
+++ b/src/views/databoard/utils/websocket.js
@@ -0,0 +1,204 @@
+// websocket实例
+let wsObj = null;
+// ws连接地址
+let wsUrl = null;
+// let userId = null;
+// 是否执行重连 true/不执行 ; false/执行
+let lockReconnect = false;
+// 重连定时器
+let wsCreateHandler = null;
+// 连接成功,执行回调函数
+let messageCallback = null;
+// 连接失败,执行回调函数
+let errorCallback = null;
+// 发送给后台的数据
+let sendDatas = {};
+
+
+/**
+ * 发起websocket请求函数
+ * @param {string} url ws连接地址
+ * @param {Object} agentData 传给后台的参数
+ * @param {function} successCallback 接收到ws数据,对数据进行处理的回调函数
+ * @param {function} errCallback ws连接错误的回调函数
+ */
+export const connectWebsocket = (url, agentData, successCallback, errCallback) => {
+ wsUrl = url;
+ createWebSoket();
+ messageCallback = successCallback;
+ errorCallback = errCallback;
+ sendDatas = agentData;
+}
+
+// 手动关闭websocket (这里手动关闭会执行onclose事件)
+export const closeWebsocket = () => {
+ if (wsObj) {
+ writeToScreen('手动关闭websocket');
+ wsObj.close() // 关闭websocket
+ // wsObj.onclose() // 关闭websocket(如果上面的关闭不生效就加上这一条)
+ // 关闭重连
+ lockReconnect = true;
+ wsCreateHandler && clearTimeout(wsCreateHandler);
+ // 关闭心跳检查
+ heartCheck.stop();
+ }
+}
+
+// 创建ws函数
+const createWebSoket = () => {
+ if (typeof (WebSocket) === 'undefined') {
+ writeToScreen("您的浏览器不支持WebSocket,无法获取数据");
+ return false
+ }
+ // const host = window.location.host;
+ // userId = GetQueryString("userId");
+ // wsUrl = "ws://" + host + "/websoket" + userId;
+
+ try {
+ wsObj = new WebSocket(wsUrl);
+ initWsEventHandle();
+ } catch (e) {
+ writeToScreen("连接异常,开始重连");
+ reconnect();
+ }
+}
+
+const initWsEventHandle = () => {
+ try {
+ // 连接成功
+ wsObj.onopen = (event) => {
+ onWsOpen(event);
+ heartCheck.start();
+ }
+
+ // 监听服务器端返回的信息
+ wsObj.onmessage = (event) => {
+ onWsMessage(event);
+ heartCheck.start();
+ }
+
+ wsObj.onclose = (event) => {
+ writeToScreen('onclose执行关闭事件');
+ onWsClose(event);
+ }
+
+ wsObj.onerror = (event) => {
+ writeToScreen('onerror执行error事件,开始重连');
+ onWsError(event);
+ reconnect();
+ }
+ } catch (err) {
+ writeToScreen('绑定事件没有成功,开始重连');
+ reconnect();
+ }
+}
+
+const onWsOpen = (event) => {
+ writeToScreen('CONNECT');
+ // // 客户端与服务器端通信
+ // wsObj.send('我发送消息给服务端');
+ // 添加状态判断,当为OPEN时,发送消息
+ if (wsObj.readyState === wsObj.OPEN) { // wsObj.OPEN = 1
+ // 发给后端的数据需要字符串化
+ wsObj.send(JSON.stringify(sendDatas));
+ }
+ if (wsObj.readyState === wsObj.CLOSED) { // wsObj.CLOSED = 3
+ writeToScreen('wsObj.readyState=3, ws连接异常,开始重连');
+ reconnect();
+ errorCallback(event);
+ }
+}
+const onWsMessage = (event) => {
+ const jsonStr = event.data;
+ writeToScreen('onWsMessage接收到服务器的数据: ', jsonStr);
+ messageCallback(jsonStr);
+}
+const onWsClose = (event) => {
+ writeToScreen('DISCONNECT');
+ // e.code === 1000 表示正常关闭。 无论为何目的而创建, 该链接都已成功完成任务。
+ // e.code !== 1000 表示非正常关闭。
+ console.log('onclose event: ', event)
+ if (event && event.code !== 1000) {
+ writeToScreen('非正常关闭');
+ errorCallback(event);
+ // 如果不是手动关闭,这里的重连会执行;如果调用了手动关闭函数,这里重连不会执行
+ reconnect();
+ }
+}
+const onWsError = (event) => {
+ writeToScreen('onWsError: ', event.data);
+ errorCallback(event);
+}
+
+const writeToScreen = (massage) => {
+ console.log(massage);
+}
+
+// 重连函数
+const reconnect = () => {
+ if (lockReconnect) {
+ return;
+ }
+ writeToScreen('3秒后重连');
+ lockReconnect = true;
+ // 没连接上会一直重连,设置延迟避免请求过多
+ wsCreateHandler && clearTimeout(wsCreateHandler);
+ wsCreateHandler = setTimeout(() => {
+ writeToScreen('重连...' + wsUrl);
+ createWebSoket();
+ lockReconnect = false;
+ writeToScreen('重连完成');
+ }, 3000);
+}
+
+// 从浏览器地址中获取对应参数
+const GetQueryString = (name) => {
+ let reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
+ // 获取url中 ? 符后的字符串并正则匹配
+ let r = window.location.search.substr(1).match(reg);
+ let context = "";
+ r && (context = r[2]);
+ reg = null;
+ r = null;
+ return context;
+}
+
+
+// 心跳检查(看看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 };
+ wsObj.send(JSON.stringify(datas));
+ } catch (err) {
+ writeToScreen("发送ping异常");
+ }
+ console.log("内嵌定时器this.serverTimeoutObj: ", this.serverTimeoutObj)
+ // 内嵌定时器
+ this.serverTimeoutObj = setTimeout(() => {
+ writeToScreen("没有收到后台的数据,重新连接");
+ reconnect();
+ }, this.timeout)
+ }, this.timeout)
+ }
+}
\ No newline at end of file
diff --git a/src/views/databoard/utils/wsInterface.js b/src/views/databoard/utils/wsInterface.js
new file mode 100644
index 00000000..66001a87
--- /dev/null
+++ b/src/views/databoard/utils/wsInterface.js
@@ -0,0 +1,160 @@
+import { connectWebsocket, closeWebsocket } from './websocket'
+import store from "@/store";
+
+// 创建dcs链接
+export const getDcsMsg = () => {
+ const userId = 'dcsmsg' + new Date().getTime()
+ connectWebsocket(
+ // 测试地址
+ 'ws://10.70.180.10:8081/xc-screen/websocket/'+userId,
+ // 传递给后台的数据
+ '',
+ // 成功拿到后台返回的数据的回调函数
+ (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.kilnInfo})
+ break;
+ }
+ case "GasInfo": {
+ store.dispatch({type: "websocket/setGasInfo", payload: msgData.data})
+ break;
+ }
+ case "SumGasInfo": {
+ store.dispatch({type: "websocket/setSumGasInfo", payload: msgData.data})
+ break;
+ }
+ default:
+ }
+ },
+ // websocket连接失败的回调函数
+ (err) => {
+ console.log('失败的回调函数', err)
+ }
+ )
+}
+
+// 创建mes链接
+export const getMesMsg = () => {
+ const sj = new Date().getTime()
+ // ISRA
+ // connectWebsocket(
+ // // 测试地址
+ // 'ws://10.70.2.2:8080/websocket/message?userId=KI'+sj,
+ // // 传递给后台的数据
+ // '',
+ // // 成功拿到后台返回的数据的回调函数
+ // (data) => {
+ // console.log('mes ISRA成功的回调函数, 接收到的data数据: ', data)
+ // let msgData = JSON.parse(data)
+ // 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:
+ // }
+ // },
+ // // websocket连接失败的回调函数
+ // (err) => {
+ // console.log('失败的回调函数', err)
+ // }
+ // )
+
+ // // 原料 MA
+ // connectWebsocket(
+ // // 测试地址
+ // 'ws://10.70.2.2:8080/websocket/message?userId=MA'+sj,
+ // // 传递给后台的数据
+ // '',
+ // // 成功拿到后台返回的数据的回调函数
+ // (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:
+ // }
+ // },
+ // // websocket连接失败的回调函数
+ // (err) => {
+ // console.log('失败的回调函数', err)
+ // }
+ // )
+
+ // 能耗 EN
+ // connectWebsocket(
+ // // 测试地址
+ // 'ws://10.70.2.2:8080/websocket/message?userId=ENERGY'+sj,
+ // // 传递给后台的数据
+ // '',
+ // // 成功拿到后台返回的数据的回调函数
+ // (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;
+ // }
+ // default:
+ // }
+ // },
+ // // websocket连接失败的回调函数
+ // (err) => {
+ // console.log('失败的回调函数', err)
+ // }
+ // )
+
+ // 烟气 GAS
+ connectWebsocket(
+ // 测试地址
+ 'ws://10.70.2.2:8080/websocket/message?userId=GAS'+sj,
+ // 传递给后台的数据
+ '',
+ // 成功拿到后台返回的数据的回调函数
+ (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)
+ }
+ )
+}
\ No newline at end of file
diff --git a/src/views/databoard/wholePlant/DefectClass.vue b/src/views/databoard/wholePlant/DefectClass.vue
new file mode 100644
index 00000000..28546c7f
--- /dev/null
+++ b/src/views/databoard/wholePlant/DefectClass.vue
@@ -0,0 +1,38 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/src/views/databoard/wholePlant/DefectStatistics.vue b/src/views/databoard/wholePlant/DefectStatistics.vue
new file mode 100644
index 00000000..cc96c75c
--- /dev/null
+++ b/src/views/databoard/wholePlant/DefectStatistics.vue
@@ -0,0 +1,38 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/src/views/databoard/wholePlant/LeftTwo.vue b/src/views/databoard/wholePlant/LeftTwo.vue
new file mode 100644
index 00000000..f3f1a075
--- /dev/null
+++ b/src/views/databoard/wholePlant/LeftTwo.vue
@@ -0,0 +1,29 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/src/views/databoard/wholePlant/MiddleTwo.vue b/src/views/databoard/wholePlant/MiddleTwo.vue
new file mode 100644
index 00000000..3c974b92
--- /dev/null
+++ b/src/views/databoard/wholePlant/MiddleTwo.vue
@@ -0,0 +1,29 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/src/views/databoard/wholePlant/OrderStatus.vue b/src/views/databoard/wholePlant/OrderStatus.vue
new file mode 100644
index 00000000..3962c613
--- /dev/null
+++ b/src/views/databoard/wholePlant/OrderStatus.vue
@@ -0,0 +1,43 @@
+
+
+
+
\ No newline at end of file
diff --git a/src/views/databoard/wholePlant/RightTwo.vue b/src/views/databoard/wholePlant/RightTwo.vue
new file mode 100644
index 00000000..3ce64ba2
--- /dev/null
+++ b/src/views/databoard/wholePlant/RightTwo.vue
@@ -0,0 +1,29 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/src/views/databoard/wholePlant/YieldRate.vue b/src/views/databoard/wholePlant/YieldRate.vue
new file mode 100644
index 00000000..6c82ae63
--- /dev/null
+++ b/src/views/databoard/wholePlant/YieldRate.vue
@@ -0,0 +1,45 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/views/databoard/wholePlant/index.vue b/src/views/databoard/wholePlant/index.vue
new file mode 100644
index 00000000..dd9cdf37
--- /dev/null
+++ b/src/views/databoard/wholePlant/index.vue
@@ -0,0 +1,146 @@
+
+
+
+
+
+
+
diff --git a/src/views/login.vue b/src/views/login.vue
index baa1dd27..453819d6 100644
--- a/src/views/login.vue
+++ b/src/views/login.vue
@@ -47,7 +47,7 @@
向世界先进水平挑战,为人类社会文明做贡献
-
+ "> -->
diff --git a/src/views/specialEquipment/basic/FireFighthing.vue b/src/views/specialEquipment/basic/FireFighthing.vue
index 9f925444..2bd3409e 100644
--- a/src/views/specialEquipment/basic/FireFighthing.vue
+++ b/src/views/specialEquipment/basic/FireFighthing.vue
@@ -170,7 +170,12 @@ export default {
{ width: 256, prop: 'code', label: '设备编码' },
{ prop: 'location', label: '位置' },
{ prop: 'responsiblePeopleName', label: '负责人' },
- { prop: 'dueTime', label: '有效期至' },
+ {
+ prop: 'dueDate',
+ label: '有效期至',
+ filter: (val) =>
+ val != null ? moment(val).format('yyyy-MM-DD HH:mm:ss') : '--',
+ },
{ prop: 'remark', label: '备注' },
],
searchBarFormConfig: [
@@ -250,8 +255,8 @@ export default {
[
{
datetime: true,
- label: '有效期至',
- prop: 'dueTime',
+ label: '有效期',
+ prop: 'dueDate',
bind: { clearable: true },
},
{},
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 =
diff --git a/src/websocket/websocket.js b/src/websocket/websocket.js
new file mode 100644
index 00000000..531abdbd
--- /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..6e2d708b
--- /dev/null
+++ b/src/websocket/wsInterface.js
@@ -0,0 +1,232 @@
+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)
+ }
+)
+// ISRA
+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;
+ }
+ case "EnergyMonitoring": {
+ store.dispatch({type: "websocket/setEnergyMonitoring", 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)
+ }
+)
+
+// 缺陷分类/统计 IS
+const mesIS = new WsConnect(
+ // websocket地址
+ 'ws://10.70.2.2:8080/websocket/message?userId=IS'+timestr,
+ // 传递给后台的数据
+ '',
+ // 成功拿到后台返回的数据的回调函数
+ (data) => {
+ // console.log('mes 缺陷成功的回调函数, 接收到的data数据: ', data)
+ let msgData = JSON.parse(data)
+ if (msgData == null) return;
+ switch (msgData?.type) {
+ case "isra": {
+ store.dispatch({type: "websocket/setDefectChart", payload:{
+ dayStatistic: msgData.detData.dayStatistic,
+ weekStatistic: msgData.detData.weekStatistic,
+ monthStatistic: msgData.detData.monthStatistic,
+ yearStatistic: msgData.detData.yearStatistic,
+ }})
+ break;
+ }
+ default:
+ }
+ },
+ // websocket连接失败的回调函数
+ (err) => {
+ console.log('失败的回调函数', err)
+ }
+)
+
+// 深加工生产运行驾驶舱(除能源) SJG
+const mesSJG = new WsConnect(
+ // websocket地址
+ // 'ws://10.70.2.2:8080/websocket/message?userId=SJG'+timestr,
+ // 'ws://192.168.0.33:48082/websocket/message?userId=SJG'+timestr,
+ 'ws://192.168.1.62:48082/websocket/message?userId=SJG'+timestr,
+ // 传递给后台的数据
+ '',
+ // 成功拿到后台返回的数据的回调函数
+ (data) => {
+ // console.log('mes 产线产量及良品率成功的回调函数, 接收到的data数据: ', data)
+ let msgData = JSON.parse(data)
+ if (msgData == null) return;
+ switch (msgData?.type) {
+ case "productline": {
+ store.dispatch({type: "websocket/setProductline", payload:msgData.detData})
+ break;
+ }
+ case "equipment": {
+ store.dispatch({type: "websocket/setSJGEq", payload:msgData.detData})
+ break;
+ }
+ default:
+ }
+ },
+ // websocket连接失败的回调函数
+ (err) => {
+ console.log('失败的回调函数', err)
+ }
+)
+
+
+export const getDcsMsg = () => {
+ dcsConn.createWebSoket()
+ mesIsra.createWebSoket()
+ mesMA.createWebSoket()
+ mesEN.createWebSoket()
+ mesGAS.createWebSoket()
+ mesIS.createWebSoket()
+ mesSJG.createWebSoket()
+}
+export const closeDcsMsg = () => {
+ dcsConn.closeWebsocket()
+ mesIsra.closeWebsocket()
+ mesMA.closeWebsocket()
+ mesEN.closeWebsocket()
+ mesGAS.closeWebsocket()
+ mesIS.closeWebsocket()
+ mesSJG.closeWebsocket()
+}
\ No newline at end of file
diff --git a/yarn.lock b/yarn.lock
index 031dc711..f16d0367 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -1119,6 +1119,51 @@
"cssnano-preset-default" "^4.0.0"
"postcss" "^7.0.0"
+"@jiaminghi/bezier-curve@*":
+ "integrity" "sha512-u9xJPOEl6Dri2E9FfmJoGxYQY7vYJkURNX04Vj64tdi535tPrpkuf9Sm0lNr3QTKdHQh0DdNRsaa62FLQNQEEw=="
+ "resolved" "https://registry.npmmirror.com/@jiaminghi/bezier-curve/-/bezier-curve-0.0.9.tgz"
+ "version" "0.0.9"
+ dependencies:
+ "@babel/runtime" "^7.5.5"
+
+"@jiaminghi/c-render@^0.4.3":
+ "integrity" "sha512-FJfzj5hGj7MLqqqI2D7vEzHKbQ1Ynnn7PJKgzsjXaZpJzTqs2Yw5OSeZnm6l7Qj7jyPAP53lFvEQNH4o4j6s+Q=="
+ "resolved" "https://registry.npmmirror.com/@jiaminghi/c-render/-/c-render-0.4.3.tgz"
+ "version" "0.4.3"
+ dependencies:
+ "@babel/runtime" "^7.5.5"
+ "@jiaminghi/bezier-curve" "*"
+ "@jiaminghi/color" "*"
+ "@jiaminghi/transition" "*"
+
+"@jiaminghi/charts@*":
+ "integrity" "sha512-K+HXaOOeWG9OOY1VG6M4mBreeeIAPhb9X+khG651AbnwEwL6G2UtcAQ8GWCq6GzhczcLwwhIhuaHqRygwHC0sA=="
+ "resolved" "https://registry.npmmirror.com/@jiaminghi/charts/-/charts-0.2.18.tgz"
+ "version" "0.2.18"
+ dependencies:
+ "@babel/runtime" "^7.5.5"
+ "@jiaminghi/c-render" "^0.4.3"
+
+"@jiaminghi/color@*":
+ "integrity" "sha512-ZY3hdorgODk4OSTbxyXBPxAxHPIVf9rPlKJyK1C1db46a50J0reFKpAvfZG8zMG3lvM60IR7Qawgcu4ZDO3+Hg=="
+ "resolved" "https://registry.npmmirror.com/@jiaminghi/color/-/color-1.1.3.tgz"
+ "version" "1.1.3"
+
+"@jiaminghi/data-view@^2.10.0":
+ "integrity" "sha512-Cud2MTiMcqc5k2KWabR/svuVQmXHANqURo+yj40370/LdI/gyUJ6LG203hWXEnT1nMCeiv/SLVmxv3PXLScCeA=="
+ "resolved" "https://registry.npmmirror.com/@jiaminghi/data-view/-/data-view-2.10.0.tgz"
+ "version" "2.10.0"
+ dependencies:
+ "@babel/runtime" "^7.5.5"
+ "@jiaminghi/charts" "*"
+
+"@jiaminghi/transition@*":
+ "integrity" "sha512-owBggipoHMikDHHDW5Gc7RZYlVuvxHADiU4bxfjBVkHDAmmck+fCkm46n2JzC3j33hWvP9nSCAeh37t6stgWeg=="
+ "resolved" "https://registry.npmmirror.com/@jiaminghi/transition/-/transition-1.1.11.tgz"
+ "version" "1.1.11"
+ dependencies:
+ "@babel/runtime" "^7.5.5"
+
"@jridgewell/gen-mapping@^0.3.0", "@jridgewell/gen-mapping@^0.3.2":
"integrity" "sha512-HLhSWOLRi875zjjMG/r+Nv0oCW8umGb0BgEhyX3dDX3egwZtB8PqLnjz3yedt8R5StBrzcg4aBpnh8UA9D1BoQ=="
"resolved" "https://registry.npmmirror.com/@jridgewell/gen-mapping/-/gen-mapping-0.3.3.tgz"
@@ -3507,6 +3552,11 @@
"safe-buffer" "5.1.2"
"vary" "~1.1.2"
+"comutils@^1.1.9":
+ "integrity" "sha512-JxXB67juILiwhdLwOsYyjUqwWEhHdObI0EClOPk+JDtEuTbac59s0pxGpfCBnNNQ5JommifmcMGneW/4Cg7YWw=="
+ "resolved" "https://registry.npmmirror.com/comutils/-/comutils-1.1.19.tgz"
+ "version" "1.1.19"
+
"concat-map@0.0.1":
"integrity" "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg=="
"resolved" "https://registry.npmmirror.com/concat-map/-/concat-map-0.0.1.tgz"
@@ -11378,6 +11428,13 @@
"resolved" "https://registry.npmmirror.com/vue-router/-/vue-router-3.4.9.tgz"
"version" "3.4.9"
+"vue-seamless-scroll@^1.1.23":
+ "integrity" "sha512-HBjUub8WwsKJzbFCrwKPDrZn4e+SSbkKgwWtjKtfLwesiFGwSsVxP44/Z6d3kpXy94qIFOiflJH6l0/9pj7SGA=="
+ "resolved" "https://registry.npmmirror.com/vue-seamless-scroll/-/vue-seamless-scroll-1.1.23.tgz"
+ "version" "1.1.23"
+ dependencies:
+ "comutils" "^1.1.9"
+
"vue-style-loader@^4.1.0", "vue-style-loader@^4.1.2":
"integrity" "sha512-sFuh0xfbtpRlKfm39ss/ikqs9AbKCoXZBpHeVZ8Tx650o0k0q/YCM7FRvigtxpACezfq6af+a7JeqVTWvncqDg=="
"resolved" "https://registry.npmmirror.com/vue-style-loader/-/vue-style-loader-4.1.3.tgz"