添加emqxUtil mqtt连接封装,首检,抛光,包装采用mqtt做数据同步,消息传递;
此次主要修改了包装完成时生成信息异常的问题,首检,抛光,包装四屏同步的问题,首检当前在检验通知消息传递功能。
This commit is contained in:
86
src/utils/mqtt/emqxUtil.js
Normal file
86
src/utils/mqtt/emqxUtil.js
Normal file
@@ -0,0 +1,86 @@
|
||||
import mqtt from '@/plugins/mqtt.min.js';
|
||||
export const title = "shgg_mes"
|
||||
// const mqtt = require('mqtt');
|
||||
// 云服务器环境
|
||||
// const url = 'wss://ff6bab7a.ala.cn-hangzhou.emqxsl.cn:8084/mqtt';
|
||||
// 本地环境
|
||||
// const url = 'ws://127.0.0.1:8083/mqtt';
|
||||
// 线上环境
|
||||
const url = 'ws://192.168.60.251:8083/mqtt';
|
||||
// 创建客户端实例
|
||||
const options = {
|
||||
clean: true,
|
||||
connectTimeout: 4000,
|
||||
clientId: 'emqx_test' + Math.random().toString(16).substring(2, 8),
|
||||
username: 'user',
|
||||
password: '123456'
|
||||
}
|
||||
// 首检topic
|
||||
export const firstFQCTopic = {
|
||||
// 累加值变动
|
||||
AccumulatorChange: title + '/firstFQC/AccumulatorChange',
|
||||
// 班组切换
|
||||
TeamChange: title + '/firstFQC/TeamChange',
|
||||
// 工单切换
|
||||
OrderChange: title + '/firstFQC/OrderChange',
|
||||
// 首检当前操作工单保留消息
|
||||
NowOrderRetain: title + '/firstFQC/NowOrderRetain'
|
||||
}
|
||||
|
||||
// 抛光topic
|
||||
export const againFQCTopic = {
|
||||
// 累加值变动
|
||||
AccumulatorChange: title + '/againFQC/AccumulatorChange',
|
||||
// 班组切换
|
||||
TeamChange: title + '/againFQC/TeamChange',
|
||||
// 工单切换
|
||||
OrderChange: title + '/againFQC/OrderChange'
|
||||
}
|
||||
|
||||
// 包装topic
|
||||
export const thirtyFQCTopic = {
|
||||
// 累加值变动
|
||||
AccumulatorChange: title + '/thirtyFQC/AccumulatorChange',
|
||||
// 班组切换
|
||||
TeamChange: title + '/thirtyFQC/TeamChange',
|
||||
// 工单切换
|
||||
OrderChange: title + '/thirtyFQC/OrderChange'
|
||||
}
|
||||
|
||||
export function createClient(clientId = null) {
|
||||
let _options = options;
|
||||
if (clientId !== null) {
|
||||
_options.clientId = clientId;
|
||||
}
|
||||
return mqtt.connect(url, options);
|
||||
}
|
||||
export function endClient(client) {
|
||||
if (client === null) {
|
||||
return;
|
||||
}
|
||||
if (client.connected) {
|
||||
client.end();
|
||||
}
|
||||
}
|
||||
export function parseJSON(jsonStr = '') {
|
||||
try {
|
||||
return JSON.parse(jsonStr);
|
||||
} catch (e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
export function stringJSON(object) {
|
||||
try {
|
||||
return JSON.stringify(object);
|
||||
} catch (e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
// 检查是否连接
|
||||
export function checkClient(client) {
|
||||
if (client === null) {
|
||||
return false;
|
||||
}
|
||||
return client.connected;
|
||||
}
|
||||
16
src/utils/view/viewUtil.js
Normal file
16
src/utils/view/viewUtil.js
Normal file
@@ -0,0 +1,16 @@
|
||||
// rem等比适配配置文件
|
||||
// 基准大小
|
||||
const baseSize = 16;
|
||||
// 设置 rem 函数
|
||||
function setRem() {
|
||||
// 当前页面屏幕分辨率相对于 1280宽的缩放比例,可根据自己需要修改
|
||||
const scale = document.documentElement.clientWidth / 1920;
|
||||
// 设置页面根节点字体大小(“Math.min(scale, 3)” 指最高放大比例为3,可根据实际业务需求调整)
|
||||
document.documentElement.style.fontSize = `${baseSize * Math.min(scale, 1)}px`;
|
||||
}
|
||||
// 初始化
|
||||
setRem();
|
||||
// 改变窗口大小时重新设置 rem
|
||||
window.onresize = () => {
|
||||
setRem();
|
||||
};
|
||||
Reference in New Issue
Block a user