Commit 74a45541 authored by Cai Wei's avatar Cai Wei

feat(*): 优化布袋监测

parent 4424540c
...@@ -70,21 +70,21 @@ ...@@ -70,21 +70,21 @@
<div class="time-controls"> <div class="time-controls">
<div class="time-desc"> <div class="time-desc">
<span class="icon"></span> <span class="icon"></span>
当前实时信号:{{ currentData.compartNo }}仓 / {{ currentData.row }}</div> 当前实时信号:{{ currentData.compartNo }}仓 / {{ currentData.row }}
</div>
<div> <div>
<el-button @click="navigateBackward"> <el-button @click="navigateBackward">
<el-icon><ArrowLeftBold />向前</el-icon> <el-icon><ArrowLeftBold />向前</el-icon>
</el-button> </el-button>
<el-button @click="navigateForward"> <el-button @click="navigateForward">
<el-icon><ArrowRightBold />向后</el-icon> <el-icon><ArrowRightBold />向后</el-icon>
</el-button> </el-button>
<span class="time-label">间隔</span> <span class="time-label">间隔</span>
<el-input v-model="timeInterval" class="time-input"></el-input> <el-input v-model="timeInterval" class="time-input"></el-input>
<span class="time-unit">分钟</span> <span class="time-unit">分钟</span>
<el-button @click="reset">重置</el-button> <el-button @click="reset">重置</el-button>
</div> </div>
</div> </div>
<table> <table>
...@@ -99,14 +99,20 @@ ...@@ -99,14 +99,20 @@
<tbody> <tbody>
<tr> <tr>
<td>峰值{{ currentData.row }}排_R</td> <td>峰值{{ currentData.row }}排_R</td>
<td v-for="(value, index) in tableData" :key="'r' + index" :class="{ 'online-style': value.compartNo === currentData.compartNo }"> <td
{{ value.peakValueR || "-" }} v-for="(value, index) in tableData"
:key="'r' + index"
:class="{
'online-style': value.compartNo === currentData.compartNo,
}"
>
{{ value.peakValueR }}
</td> </td>
</tr> </tr>
<tr> <tr>
<td>峰值_H</td> <td>峰值_H</td>
<td v-for="(value, index) in tableData" :key="'h' + index"> <td v-for="(value, index) in tableData" :key="'h' + index">
{{ value.peakValueH || "-" }} {{ value.peakValueH }}
</td> </td>
</tr> </tr>
<tr> <tr>
...@@ -122,13 +128,13 @@ ...@@ -122,13 +128,13 @@
<tr> <tr>
<td>反吹中</td> <td>反吹中</td>
<td v-for="(value, index) in tableData" :key="'b' + index"> <td v-for="(value, index) in tableData" :key="'b' + index">
{{ value.blowBack || "-" }} {{ value.blowBack }}
</td> </td>
</tr> </tr>
<tr> <tr>
<td>谷值</td> <td>谷值</td>
<td v-for="(value, index) in tableData" :key="'v' + index"> <td v-for="(value, index) in tableData" :key="'v' + index">
{{ value.valleyValue || "-" }} {{ value.valleyValue}}
</td> </td>
</tr> </tr>
</tbody> </tbody>
...@@ -245,7 +251,7 @@ const initChartData = () => { ...@@ -245,7 +251,7 @@ const initChartData = () => {
dusterNo: dusterNo.value, dusterNo: dusterNo.value,
deviceNo: selectedDevice.value, deviceNo: selectedDevice.value,
startTime: startTime, startTime: startTime,
endTime: endTime, // endTime: endTime,
}) })
.then((res) => { .then((res) => {
// 将data中的date和realData数据添加到chartData中,要求大数据量下速度快 // 将data中的date和realData数据添加到chartData中,要求大数据量下速度快
...@@ -295,65 +301,57 @@ const updateFunction = () => { ...@@ -295,65 +301,57 @@ const updateFunction = () => {
if (!dusterNo.value || !selectedDevice.value) return; if (!dusterNo.value || !selectedDevice.value) return;
// 从API获取实时数据 // 从API获取实时数据
if (showRealtimeDeviceStatus) {
getMonitorRealtime({
dusterNo: dusterNo.value,
deviceNo: selectedDevice.value,
})
.then((res) => {
if (res.data) {
// 更新数据面板
if (res.data.realtimeCompart) {
tableData.value = res.data.realtimeCompart;
}
if (res.data.realtimePanel) {
currentData.value = res.data.realtimePanel;
}
}
})
.catch((err) => {
console.error("获取实时数据失败:", err);
});
}
// 结束时间往后推一秒 getMonitorRealtime({
let endTime = moment(new Date(currentTime.value))
.add(1, "seconds")
.format("YYYY-MM-DD HH:mm:ss");
getMonitorToday({
dusterNo: dusterNo.value, dusterNo: dusterNo.value,
deviceNo: selectedDevice.value, deviceNo: selectedDevice.value,
startTime: currentTime.value, })
endTime: endTime, .then((res) => {
}).then((res) => { if (res.data) {
if (res.data && res.data.length > 0) { // 更新数据面板
const item = res.data[res.data.length - 1]; if (res.data.realtimeCompart) {
chartData.xData.push(item.date); tableData.value = res.data.realtimeCompart;
chartData.seriesData.push(item.realData || 0); }
if (res.data.realtimePanel) {
// 移除最旧的数据点以保持固定长度 currentData.value = res.data.realtimePanel;
if (chartData.xData.length > 301) { }
// 保持300秒的数据
chartData.xData.shift();
chartData.seriesData.shift();
} }
currentTime.value = endTime; })
// 更新图表 .catch((err) => {
updateChart(); console.error("获取实时数据失败:", err);
} });
});
};
// 停止实时更新 if (showRealtimeDeviceStatus) {
const stopRealTimeUpdates = () => { // 结束时间往后推一秒
if (updateTimer) { let endTime = moment(new Date(currentTime.value))
clearInterval(updateTimer); .add(1, "seconds")
updateTimer = null; .format("YYYY-MM-DD HH:mm:ss");
getMonitorToday({
dusterNo: dusterNo.value,
deviceNo: selectedDevice.value,
startTime: currentTime.value,
endTime: endTime,
}).then((res) => {
if (res.data && res.data.length > 0) {
const item = res.data[res.data.length - 1];
chartData.xData.push(item.date);
chartData.seriesData.push(item.realData || 0);
// 移除最旧的数据点以保持固定长度
if (chartData.xData.length > 301) {
// 保持300秒的数据
chartData.xData.shift();
chartData.seriesData.shift();
}
currentTime.value = endTime;
// 更新图表
updateChart();
}
});
} }
showRealtimeDeviceStatus = false;
}; };
// 向前导航(查看更早的数据) // 向前导航(查看更早的数据)
const navigateBackward = () => { const navigateBackward = () => {
// 不完全关闭轮询,只禁用实时设备状态获取 // 不完全关闭轮询,只禁用实时设备状态获取
...@@ -376,6 +374,7 @@ const navigateBackward = () => { ...@@ -376,6 +374,7 @@ const navigateBackward = () => {
const endTime = new Date(lastTimePoint.getTime() - intervalMs); const endTime = new Date(lastTimePoint.getTime() - intervalMs);
lastTimePoint = endTime; lastTimePoint = endTime;
// 重新生成数据 // 重新生成数据
generateHistoricalData(endTime, interval); generateHistoricalData(endTime, interval);
}; };
...@@ -399,18 +398,18 @@ const navigateForward = () => { ...@@ -399,18 +398,18 @@ const navigateForward = () => {
} }
// 计算新的时间范围 // 计算新的时间范围
const endTime = new Date(lastTimePoint.getTime() + intervalMs); let endTime = new Date(lastTimePoint.getTime() + intervalMs);
// 如果新的结束时间超过当前时间,则切换回实时模式 // // 如果新的结束时间超过当前时间,则切换回实时模式
const now = moment(); const now = moment();
if (endTime > now) { if (endTime > now) {
lastTimePoint = null; lastTimePoint = new Date(now);
showRealtimeDeviceStatus = true; endTime = new Date(now);
return; // // showRealtimeDeviceStatus = true;
// return;
} else {
lastTimePoint = endTime;
} }
lastTimePoint = endTime;
// 重新生成数据 // 重新生成数据
generateHistoricalData(endTime, interval); generateHistoricalData(endTime, interval);
}; };
...@@ -435,7 +434,10 @@ const reset = () => { ...@@ -435,7 +434,10 @@ const reset = () => {
// 开启实时更新(重置用) // 开启实时更新(重置用)
const startRealTimeUpdate = () => { const startRealTimeUpdate = () => {
// 确保之前的定时器已清除 // 确保之前的定时器已清除
stopRealTimeUpdates(); if (updateTimer) {
clearInterval(updateTimer);
updateTimer = null;
}
// 启动定时更新 // 启动定时更新
updateTimer = setInterval(() => { updateTimer = setInterval(() => {
updateFunction(); updateFunction();
...@@ -518,7 +520,6 @@ watch(dusterNo, (newVal) => { ...@@ -518,7 +520,6 @@ watch(dusterNo, (newVal) => {
}); });
onMounted(() => { onMounted(() => {
console.log("dusterNo", route);
if (dusterNo.value) { if (dusterNo.value) {
getDeviceList(); getDeviceList();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment