特殊棚添加
parent
4108e58459
commit
7f493da241
|
|
@ -0,0 +1,52 @@
|
||||||
|
import request from '@/utils/request'
|
||||||
|
|
||||||
|
// 查询无线传输线管数据列表
|
||||||
|
export function listSpecialData(query) {
|
||||||
|
return request({
|
||||||
|
url: '/data/specialData/list',
|
||||||
|
method: 'get',
|
||||||
|
params: query
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 查询无线传输线管数据详细
|
||||||
|
export function getSpecialData(id) {
|
||||||
|
return request({
|
||||||
|
url: '/data/specialData/' + id,
|
||||||
|
method: 'get'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 新增无线传输线管数据
|
||||||
|
export function addSpecialData(data) {
|
||||||
|
return request({
|
||||||
|
url: '/data/specialData',
|
||||||
|
method: 'post',
|
||||||
|
data: data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 修改无线传输线管数据
|
||||||
|
export function updateSpecialData(data) {
|
||||||
|
return request({
|
||||||
|
url: '/data/specialData',
|
||||||
|
method: 'put',
|
||||||
|
data: data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除无线传输线管数据
|
||||||
|
export function delSpecialData(id) {
|
||||||
|
return request({
|
||||||
|
url: '/data/specialData/' + id,
|
||||||
|
method: 'delete'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 取最新一条数据
|
||||||
|
export function getNewSpecialData() {
|
||||||
|
return request({
|
||||||
|
url: '/data/specialData/getNewSpecialData',
|
||||||
|
method: 'get'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
@ -46,7 +46,7 @@
|
||||||
</view>
|
</view>
|
||||||
</uni-section>
|
</uni-section>
|
||||||
|
|
||||||
<uni-section title="设备控制" titleFontSize="16px" type="line" v-if="value!== 1 && imei !=='862538065276939'">
|
<uni-section title="设备控制" titleFontSize="16px" type="line" v-if="value!== 1 && !['862538065276939','A','B','C'].includes(imei)">
|
||||||
<template v-slot:right >
|
<template v-slot:right >
|
||||||
{{ control }}
|
{{ control }}
|
||||||
</template>
|
</template>
|
||||||
|
|
@ -126,6 +126,8 @@ import mqttUtil from '@/utils/mqtt';
|
||||||
import UniNumberBox from "../../uni_modules/uni-number-box/components/uni-number-box/uni-number-box.vue";
|
import UniNumberBox from "../../uni_modules/uni-number-box/components/uni-number-box/uni-number-box.vue";
|
||||||
import {addLimit, getAgriByImei, updateLimit} from "../../api/system/assets/limit";
|
import {addLimit, getAgriByImei, updateLimit} from "../../api/system/assets/limit";
|
||||||
import {listAgri} from "../../api/system/assets/agri";
|
import {listAgri} from "../../api/system/assets/agri";
|
||||||
|
import {getNewSpecialData} from "../../api/data/specialData";
|
||||||
|
import store from "../../store";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
dicts: ['sys_data_map'],
|
dicts: ['sys_data_map'],
|
||||||
|
|
@ -262,6 +264,16 @@ export default {
|
||||||
this.clearAllTimers();
|
this.clearAllTimers();
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
|
||||||
|
getNewSpecialData() {
|
||||||
|
getNewSpecialData().then(response => {
|
||||||
|
if (response.code === 200 && response.data) {
|
||||||
|
this.makeSpecialData(response.data,false);
|
||||||
|
this.temp = "最后更新时间:"+response.data.time;
|
||||||
|
this.fontStyle = 'font-size:16px;'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
// 新增:清除所有定时器(防止内存泄漏)
|
// 新增:清除所有定时器(防止内存泄漏)
|
||||||
clearAllTimers() {
|
clearAllTimers() {
|
||||||
Object.keys(this.timers).forEach(type => {
|
Object.keys(this.timers).forEach(type => {
|
||||||
|
|
@ -273,14 +285,20 @@ export default {
|
||||||
},
|
},
|
||||||
change(e) {
|
change(e) {
|
||||||
this.imei = e;
|
this.imei = e;
|
||||||
// 优化:使用常量拼接MQTT主题
|
if ((e === 'A' || e==='B' || e==='C')
|
||||||
this.publishTopic = `dtu/${this.imei}${MQTT_TOPIC_SUFFIX.DOWN}`;
|
&& store.getters && store.getters.name === 'admin' ) {
|
||||||
this.mqttConfig.subscribeTopic = `dtu/${this.imei}${MQTT_TOPIC_SUFFIX.UP}`;
|
this.getNewSpecialData(e);
|
||||||
|
this.mqttConfig.subscribeTopic = `dtu/862538063921866${MQTT_TOPIC_SUFFIX.UP}`;
|
||||||
|
}
|
||||||
const selectedItem = this.range.find(item => item.value === e);
|
const selectedItem = this.range.find(item => item.value === e);
|
||||||
if (selectedItem) {
|
if (selectedItem) {
|
||||||
this.selectedText = selectedItem.text; // 获取展示文本
|
this.selectedText = selectedItem.text; // 获取展示文本
|
||||||
this.agriId = selectedItem.agriId;
|
this.agriId = selectedItem.agriId;
|
||||||
this.title= this.selectedText;
|
this.title= this.selectedText;
|
||||||
|
if (e !== 'A' && e!=='B' && e!=='C') {
|
||||||
|
// 优化:使用常量拼接MQTT主题
|
||||||
|
this.publishTopic = `dtu/${this.imei}${MQTT_TOPIC_SUFFIX.DOWN}`;
|
||||||
|
this.mqttConfig.subscribeTopic = `dtu/${this.imei}${MQTT_TOPIC_SUFFIX.UP}`;
|
||||||
var queryParams = {
|
var queryParams = {
|
||||||
imei: this.imei
|
imei: this.imei
|
||||||
}
|
}
|
||||||
|
|
@ -292,6 +310,7 @@ export default {
|
||||||
this.fontStyle = 'font-size:16px;'
|
this.fontStyle = 'font-size:16px;'
|
||||||
})
|
})
|
||||||
this.getAgriByImei();
|
this.getAgriByImei();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
this.selectedText = ''; // 无匹配项时清空
|
this.selectedText = ''; // 无匹配项时清空
|
||||||
this.title='';
|
this.title='';
|
||||||
|
|
@ -319,9 +338,51 @@ export default {
|
||||||
text: item.agriName,
|
text: item.agriName,
|
||||||
value: item.imei // 提取并改名
|
value: item.imei // 提取并改名
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
if (store.getters && store.getters.name === 'admin') {
|
||||||
|
this.range.push(
|
||||||
|
{
|
||||||
|
text:"八方南棚",
|
||||||
|
value:"A"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text:"九方春棚",
|
||||||
|
value:"B"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text:"十二方棚",
|
||||||
|
value:"C"
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
|
makeSpecialData(msgData, tag) {
|
||||||
|
const div10 = (v) => (v == null ? null : Math.round((Number(v)/10)*10)/10)
|
||||||
|
// 传感器键名映射表
|
||||||
|
const IMEI_SENSOR_MAP = {
|
||||||
|
A: SENSOR_MAP,
|
||||||
|
B: tag?{temp1:'205',humi1:'105',temp2:'206',humi2:'106',temp3:'207',humi3:'107',temp4:'208',humi4:'108'}
|
||||||
|
:{temp1:'temp5',humi1:'humi5',temp2:'temp6',humi2:'humi6',temp3:'temp7',humi3:'humi7',temp4:'temp8',humi4:'humi8'},
|
||||||
|
C: tag?{temp1:'209',humi1:'109',temp2:'210',humi2:'110',temp3:'211',humi3:'111',temp4:'212',humi4:'112'}
|
||||||
|
:{temp1:'temp9',humi1:'humi9',temp2:'temp10',humi2:'humi10',temp3:'temp11',humi3:'humi11',temp4:'temp12',humi4:'humi12'},
|
||||||
|
};
|
||||||
|
|
||||||
|
// 确定传感器键名
|
||||||
|
const isAdmin = store.getters?.name === 'admin';
|
||||||
|
const sensorKeys = (isAdmin && ['A','B','C'].includes(this.imei))
|
||||||
|
? IMEI_SENSOR_MAP[this.imei]
|
||||||
|
: IMEI_SENSOR_MAP.A;
|
||||||
|
// 批量生成liveData
|
||||||
|
this.liveData = Object.fromEntries(
|
||||||
|
Object.entries(sensorKeys).map(([key, sensorKey]) => [
|
||||||
|
key,
|
||||||
|
(tag?div10(msgData[sensorKey]):(this.imei==='A'?msgData[key]: msgData[sensorKey]))|| "已离线..."
|
||||||
|
])
|
||||||
|
);
|
||||||
|
},
|
||||||
reset() {
|
reset() {
|
||||||
Object.keys(this.show).forEach(key => {
|
Object.keys(this.show).forEach(key => {
|
||||||
this.show[key] = "暂停";
|
this.show[key] = "暂停";
|
||||||
|
|
@ -600,20 +661,10 @@ export default {
|
||||||
}
|
}
|
||||||
const allKeysNumeric2 = Object.keys(msgData).every(key => /^\d+$/.test(key));
|
const allKeysNumeric2 = Object.keys(msgData).every(key => /^\d+$/.test(key));
|
||||||
if (Object.keys(msgData).length > 0 && allKeysNumeric2) {
|
if (Object.keys(msgData).length > 0 && allKeysNumeric2) {
|
||||||
const div10 = (v) => (v == null ? null : Math.round((Number(v)/10)*10)/10)
|
|
||||||
// 优化:使用常量获取传感器数据
|
|
||||||
this.liveData = {
|
|
||||||
temp1: div10(msgData[SENSOR_MAP.temp1]) || "已离线...",
|
|
||||||
humi1: div10(msgData[SENSOR_MAP.humi1]) || "已离线...",
|
|
||||||
temp2: div10(msgData[SENSOR_MAP.temp2]) || "已离线...",
|
|
||||||
humi2: div10(msgData[SENSOR_MAP.humi2]) || "已离线...",
|
|
||||||
temp3: div10(msgData[SENSOR_MAP.temp3]) || "已离线...",
|
|
||||||
humi3: div10(msgData[SENSOR_MAP.humi3]) || "已离线...",
|
|
||||||
temp4: div10(msgData[SENSOR_MAP.temp4]) || "已离线...",
|
|
||||||
humi4: div10(msgData[SENSOR_MAP.humi4]) || "已离线...",
|
|
||||||
};
|
|
||||||
this.temp = "最后更新时间:" + this.getCurrentTime();
|
this.temp = "最后更新时间:" + this.getCurrentTime();
|
||||||
this.fontStyle = 'font-size:16px;'
|
this.fontStyle = 'font-size:16px;'
|
||||||
|
|
||||||
|
this.makeSpecialData(msgData, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -143,6 +143,10 @@
|
||||||
// 864536071808560 七方北棚
|
// 864536071808560 七方北棚
|
||||||
// 864865085008135 八方北棚
|
// 864865085008135 八方北棚
|
||||||
const subscribeList = [`dtu/864865085016294/up`, `dtu/864536071808560/up`,`dtu/864865085008135/up`,`dtu/862538065276939/up`]
|
const subscribeList = [`dtu/864865085016294/up`, `dtu/864536071808560/up`,`dtu/864865085008135/up`,`dtu/862538065276939/up`]
|
||||||
|
|
||||||
|
if (store.getters && store.getters.name === 'admin') {
|
||||||
|
subscribeList.push(`dtu/862538063921866/up`);
|
||||||
|
}
|
||||||
// 4. 调用App.vue的loginSuccess方法,初始化MQTT
|
// 4. 调用App.vue的loginSuccess方法,初始化MQTT
|
||||||
app.loginSuccess(token, subscribeList)
|
app.loginSuccess(token, subscribeList)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue