From 7b4cd6ef04b358e0805846d49e3acf02d7eae5cb Mon Sep 17 00:00:00 2001 From: baoshiwei <baoshiwei@shlanbao.cn> Date: 星期三, 30 七月 2025 11:08:33 +0800 Subject: [PATCH] feat(eims): 更新预测性维护功能 - 新增设备数据定时更新功能 - 添加维护建议滚动显示 - 更新设备部件寿命预测数据 - 调整备件库存与预警逻辑 - 优化数据展示和颜色提示 --- eims-ui/apps/web-antd/src/views/eims/predictive-maintenance/smt-machine-detail.vue | 279 +++++++++++++++++++++++++++++++++++++++++++++---------- 1 files changed, 229 insertions(+), 50 deletions(-) diff --git a/eims-ui/apps/web-antd/src/views/eims/predictive-maintenance/smt-machine-detail.vue b/eims-ui/apps/web-antd/src/views/eims/predictive-maintenance/smt-machine-detail.vue index afb4146..b274799 100644 --- a/eims-ui/apps/web-antd/src/views/eims/predictive-maintenance/smt-machine-detail.vue +++ b/eims-ui/apps/web-antd/src/views/eims/predictive-maintenance/smt-machine-detail.vue @@ -68,13 +68,15 @@ /> </div> - <a-divider /> + <a-divider orientation="left">棰勬祴鎬х淮鎶ゅ缓璁�</a-divider> <a-table + ref="maintenanceTable" :columns="maintenanceColumns" :data-source="maintenanceData" :pagination="false" size="small" + :scroll="{ y: 150 }" > <template #urgency="{ text }"> <a-tag :color="getUrgencyColor(text)">{{ text }}</a-tag> @@ -89,42 +91,42 @@ <a-card title="璁惧鏁版嵁" class="mb-4"> <a-row :gutter="[16, 16]"> <a-col :span="4"> - <a-statistic title="X杞存�荤Щ鍔ㄨ窛绂�" :value="healthData.xAxisTravel" suffix="km"> + <a-statistic title="X杞存�荤Щ鍔ㄨ窛绂�" :value="healthData.xAxisTravel.toFixed(2)" suffix="km"> <template #prefix> <LineChartOutlined /> </template> </a-statistic> </a-col> <a-col :span="4"> - <a-statistic title="Y杞存�荤Щ鍔ㄨ窛绂�" :value="healthData.yAxisTravel" suffix="km"> + <a-statistic title="Y杞存�荤Щ鍔ㄨ窛绂�" :value="healthData.yAxisTravel.toFixed(2)" suffix="km"> <template #prefix> <LineChartOutlined /> </template> </a-statistic> </a-col> <a-col :span="4"> - <a-statistic title="鍗″甫娆℃暟" :value="healthData.tapeJamCount" suffix="娆�"> + <a-statistic title="鍗″甫娆℃暟" :value="healthData.tapeJamCount.toFixed(0)" suffix="娆�"> <template #prefix> <WarningOutlined /> </template> </a-statistic> </a-col> <a-col :span="4"> - <a-statistic title="鍗℃枡娆℃暟" :value="healthData.materialJamCount" suffix="娆�"> + <a-statistic title="鍗℃枡娆℃暟" :value="healthData.materialJamCount.toFixed(0)" suffix="娆�"> <template #prefix> <WarningOutlined /> </template> </a-statistic> </a-col> <a-col :span="4"> - <a-statistic title="鎷兼澘鏁�" :value="healthData.panelCount" suffix="鍧�"> + <a-statistic title="鎷兼澘鏁�" :value="healthData.panelCount.toFixed(0)" suffix="鍧�"> <template #prefix> <AppstoreOutlined /> </template> </a-statistic> </a-col> <a-col :span="4"> - <a-statistic title="鍑洪敊鍋滄満鏃堕棿" :value="healthData.downtime" suffix="绉�"> + <a-statistic title="鍑洪敊鍋滄満鏃堕棿" :value="healthData.downtime.toFixed(1)" suffix="绉�"> <template #prefix> <FieldTimeOutlined /> </template> @@ -214,7 +216,7 @@ </template> <script lang="ts"> -import { defineComponent, reactive, onMounted, onUnmounted } from 'vue'; +import { defineComponent, reactive, onMounted, onUnmounted, ref, nextTick } from 'vue'; import * as echarts from 'echarts'; import { LineChartOutlined, @@ -223,6 +225,7 @@ FieldTimeOutlined } from '@ant-design/icons-vue'; import img from '#/assets/images/JUKI.png' +import { getDeviceDataSmt, updateDeviceData, initDeviceData } from '#/api/eims/equ/deviceData' export default defineComponent({ name: 'SmtMachineDetail', @@ -244,20 +247,20 @@ healthColor: '#52c41a', predictedLife: 635, riskLevel: '浣庨闄�', - riskColor: '#52c41a', + riskColor: '#1a7ac4', xAxisTravel: 300.179, yAxisTravel: 233.392, tapeJamCount: 6, materialJamCount: 15, panelCount: 2480, downtime: 4.5, - // 鐢ㄤ簬绱姞鐨勬暟鎹� - accumulatedXAxisTravel: 300.179, - accumulatedYAxisTravel: 233.392, - accumulatedTapeJamCount: 6, - accumulatedMaterialJamCount: 15, - accumulatedPanelCount: 2480, - accumulatedDowntime: 4.5 + // // 鐢ㄤ簬绱姞鐨勬暟鎹� + // accumulatedXAxisTravel: 300.179, + // accumulatedYAxisTravel: 233.392, + // accumulatedTapeJamCount: 6, + // accumulatedMaterialJamCount: 15, + // accumulatedPanelCount: 2480, + // accumulatedDowntime: 4.5 }); const maintenanceColumns = [ @@ -293,25 +296,65 @@ { key: '1', - type: '璐磋澶寸淮鎶�', - content: '鍚稿槾鐪熺┖鍘嬪姏鏍″噯', - suggestedTime: '2024-04-05', + type: '1鍙疯创瑁呯郴缁熺淮鎶�', + content: '鍚稿槾鐪熺┖鍘嬪姏鍋忎綆', + suggestedTime: '2025-07-05', + urgency: '涓瓑' + }, + { + key: '6', + + type: '4鍙疯创瑁呯郴缁熺淮鎶�', + content: 'T杞撮┈杈惧鍛藉憡鎬�', + suggestedTime: '2025-07-05', urgency: '涓瓑' }, { key: '2', type: '杩愬姩绯荤粺淇濆吇', content: 'X/Y杞翠己鏈嶇數鏈烘鼎婊戞鏌�', - suggestedTime: '2024-03-20', + suggestedTime: '2025-06-20', urgency: '浣�' }, { key: '3', type: '渚涙枡绯荤粺妫�鏌�', content: '椋炶揪鍗″甫/鍗℃枡娆℃暟娓呴浂', - suggestedTime: '2024-03-10', + suggestedTime: '2025-06-10', urgency: '浣�' - } + }, + { + key: '4', + + type: '2鍙疯创瑁呯郴缁熺淮鎶�', + content: '鐪熺┖鍘嬪姏涓嶇ǔ瀹�', + suggestedTime: '2025-07-05', + urgency: '浣�' + }, + { + key: '5', + type: '3鍙疯创瑁呯郴缁熺淮鎶�', + content: 'Z杞撮┈杈剧數娴佸紓甯�', + suggestedTime: '2025-07-05', + urgency: '浣�' + }, + + { + key: '7', + + type: '5鍙疯创瑁呭ご缁存姢', + content: '鐪熺┖鍘嬪姏涓嶇ǔ瀹�', + suggestedTime: '2025-07-05', + urgency: '浣�' + }, + { + key: '8', + + type: '6鍙疯创瑁呭ご缁存姢', + content: '鐪熺┖鍘嬪姏涓嶇ǔ瀹�', + suggestedTime: '2025-07-05', + urgency: '浣�' + }, ]); const getUrgencyColor = (urgency: string) => { @@ -326,6 +369,27 @@ return 'default'; } }; + + + const fetchDeviceData = async () => { + try { + const res = await getDeviceDataSmt(); + Object.assign(healthData, res); + } catch (error) { + console.error('鑾峰彇璁惧鏁版嵁澶辫触:', error); + } + }; + + let deviceDataInterval: number | undefined; + fetchDeviceData(); + + deviceDataInterval = setInterval(async () => { + try { + fetchDeviceData(); + } catch (error) { + console.error('鏇存柊璁惧鏁版嵁澶辫触:', error); + } + }, 3000); const sparePartColumns = [ { @@ -356,33 +420,111 @@ const sparePartData = reactive([ { key: '1', - name: 'X杞翠己鏈嶇數鏈�', + name: '1鍙疯创瑁呯郴缁烼杞翠己鏈嶇數鏈�', currentLife: '15000灏忔椂', - remainingLife: '4354灏忔椂', + remainingLife: '1451灏忔椂', + status: '棰勮' + }, + { + key: '5', + name: '1鍙疯创瑁呯郴缁焃杞翠己鏈嶇數鏈�', + currentLife: '15000灏忔椂', + remainingLife: '7521灏忔椂', + status: '鑹ソ' + }, + { + key: '9', + name: '1鍙疯创瑁呯郴缁熺湡绌虹數纾侀榾', + currentLife: '10000灏忔椂', + remainingLife: '2154灏忔椂', status: '鑹ソ' }, { key: '2', - name: '鍚稿槾', + name: '1鍙疯创瑁呭ご', currentLife: '1000000娆�', - remainingLife: '425000娆�', + remainingLife: '425542娆�', + status: '鑹ソ' + }, + { + key: '6', + name: '2鍙疯创瑁呯郴缁烼杞翠己鏈嶇數鏈�', + currentLife: '15000灏忔椂', + remainingLife: '7540灏忔椂', + status: '鑹ソ' + }, + { + key: '7', + name: '2鍙疯创瑁呯郴缁焃杞翠己鏈嶇數鏈�', + currentLife: '15000灏忔椂', + remainingLife: '7521灏忔椂', + status: '鑹ソ' + }, + { + key: '9', + name: '2鍙疯创瑁呯郴缁熺湡绌虹數纾侀榾', + currentLife: '10000灏忔椂', + remainingLife: '2154灏忔椂', + status: '鑹ソ' + }, + { + key: '8', + name: '2鍙疯创瑁呭ご', + currentLife: '1000000娆�', + remainingLife: '751251娆�', status: '鑹ソ' }, { key: '3', name: '椋炶揪', currentLife: '96涓湀', - remainingLife: '48涓湀', + remainingLife: '43涓湀', status: '鑹ソ' - } + }, + ]); const historyData = reactive([ { id: '1', + date: '2025-07-22', + type: '瀹氭湡淇濆吇', + description: '瀹屾垚鏈堝害淇濆吇锛屼笣鏉嗗杞ㄦ敞娌癸紝鎶涙枡娓呯悊', + color: 'green' + }, + { + id: '1', + date: '2025-06-18', + type: '瀹氭湡淇濆吇', + description: '瀹屾垚鏈堝害淇濆吇锛屾槗鎹熶欢鏇存崲', + color: 'green' + }, + { + id: '1', date: '2025-05-15', type: '瀹氭湡淇濆吇', description: '瀹屾垚瀛e害淇濆吇锛屾鏌ヨ繍鍔ㄧ郴缁熸鼎婊�', + color: 'green' + }, + { + id: '1', + date: '2025-04-20', + type: '瀹氭湡淇濆吇', + description: '瀹屾垚鏈堝害淇濆吇锛岄槻灏樿繃婊ょ綉娓呯悊锛屽杞ㄦ敞娌�', + color: 'green' + }, + { + id: '1', + date: '2025-03-16', + type: '瀹氭湡淇濆吇', + description: '瀹屾垚鏈堝害淇濆吇锛岀湡绌哄�兼牎鍑�', + color: 'green' + }, + { + id: '1', + date: '2025-02-13', + type: '瀹氭湡淇濆吇', + description: '瀹屾垚鏈堝害淇濆吇锛屽惛鍢存鏌ユ洿鎹紝鎶涙枡娓呯悊锛岀浉鏈哄弬鏁版牎鍑�', color: 'green' }, { @@ -394,9 +536,9 @@ }, { id: '3', - date: '2024-12-01', + date: '2025-01-15', type: '瀹氭湡淇濆吇', - description: '瀹屾垚骞村害淇濆吇锛屾牎鍑嗚瑙夌郴缁�', + description: '瀹屾垚骞村害淇濆吇锛岃创瑁呯郴缁熸牎鍑嗭紝鏄撴崯浠舵洿鎹紝鏍″噯瑙嗚绯荤粺', color: 'green' } ]); @@ -420,34 +562,70 @@ }; let healthDataInterval: number | undefined; + let scrollInterval: number | undefined; + const maintenanceTable = ref<HTMLElement | null>(null); - const updateHealthData = () => { - healthData.accumulatedXAxisTravel = parseFloat((healthData.accumulatedXAxisTravel + Math.random() * 0.01).toFixed(3)); - healthData.accumulatedYAxisTravel = parseFloat((healthData.accumulatedYAxisTravel + Math.random() * 0.01).toFixed(3)); - healthData.accumulatedTapeJamCount = healthData.accumulatedTapeJamCount + Math.random() * 0.005; - healthData.accumulatedMaterialJamCount = healthData.accumulatedMaterialJamCount + Math.random() * 0.005; - healthData.accumulatedPanelCount =healthData.accumulatedPanelCount + Math.random() * 0.1; - healthData.accumulatedDowntime = parseFloat((healthData.accumulatedDowntime + Math.random() * 0.01).toFixed(1)); + const startScroll = () => { + if (!maintenanceTable.value) return; - // 鏇存柊鏄剧ず鐨勬暟鎹� - healthData.xAxisTravel = healthData.accumulatedXAxisTravel; - healthData.yAxisTravel = healthData.accumulatedYAxisTravel; - healthData.tapeJamCount = Math.round(healthData.accumulatedTapeJamCount); - healthData.materialJamCount = Math.round(healthData.accumulatedMaterialJamCount); - healthData.panelCount = Math.round( healthData.accumulatedPanelCount); - healthData.downtime = healthData.accumulatedDowntime; + const tableBody = maintenanceTable.value.$el.querySelector('.ant-table-body'); + if (!tableBody) return; + + const scrollHeight = tableBody.scrollHeight; + const clientHeight = tableBody.clientHeight; + + if (scrollHeight <= clientHeight) { + // 鍐呭鏈孩鍑猴紝鏃犻渶婊氬姩 + return; + } + + let currentScrollTop = 0; + scrollInterval = setInterval(() => { + currentScrollTop += 1; // 姣忔婊氬姩1px + if (currentScrollTop >= scrollHeight - clientHeight) { + currentScrollTop = 0; // 婊氬姩鍒板簳閮ㄥ悗鍥炲埌椤堕儴 + } + tableBody.scrollTop = currentScrollTop; + }, 50); // 姣�50姣婊氬姩涓�娆� }; + + // const updateHealthData = () => { + // healthData.accumulatedXAxisTravel = parseFloat((healthData.accumulatedXAxisTravel + Math.random() * 0.01).toFixed(3)); + // healthData.accumulatedYAxisTravel = parseFloat((healthData.accumulatedYAxisTravel + Math.random() * 0.01).toFixed(3)); + // healthData.accumulatedTapeJamCount = healthData.accumulatedTapeJamCount + Math.random() * 0.005; + // healthData.accumulatedMaterialJamCount = healthData.accumulatedMaterialJamCount + Math.random() * 0.005; + // healthData.accumulatedPanelCount =healthData.accumulatedPanelCount + Math.random() * 0.1; + // healthData.accumulatedDowntime = parseFloat((healthData.accumulatedDowntime + Math.random() * 0.01).toFixed(1)); + + // // 鏇存柊鏄剧ず鐨勬暟鎹� + // healthData.xAxisTravel = healthData.accumulatedXAxisTravel; + // healthData.yAxisTravel = healthData.accumulatedYAxisTravel; + // healthData.tapeJamCount = Math.round(healthData.accumulatedTapeJamCount); + // healthData.materialJamCount = Math.round(healthData.accumulatedMaterialJamCount); + // healthData.panelCount = Math.round( healthData.accumulatedPanelCount); + // healthData.downtime = healthData.accumulatedDowntime; + // }; onMounted(() => { // 鍒濆鏇存柊涓�娆℃暟鎹� - updateHealthData(); + // updateHealthData(); // 姣�5绉掓洿鏂颁竴娆¤澶囨暟鎹� - healthDataInterval = setInterval(updateHealthData, 5000); + // healthDataInterval = setInterval(updateHealthData, 5000); + + nextTick(() => { + startScroll(); + }); }); onUnmounted(() => { if (healthDataInterval) { clearInterval(healthDataInterval); + } + if (scrollInterval) { + clearInterval(scrollInterval); + } + if (deviceDataInterval) { + clearInterval(deviceDataInterval); } }); @@ -461,7 +639,8 @@ historyData, getStatusColor, getUrgencyColor, - handleMaintenance + handleMaintenance, + maintenanceTable }; }, components: { @@ -487,7 +666,7 @@ time, value: newValue }); - if (s.data.length > 60) { + if (s.data.length > 24) { s.data.shift(); } }); @@ -560,8 +739,8 @@ seriesConfig.forEach(s => { s.data = []; // 鐢熸垚鍒濆鏁版嵁鐐癸紙60涓偣锛�5鍒嗛挓鏁版嵁锛� - for (let i = 0; i < 60; i++) { - const now = new Date(Date.now() - (60 - i) * 5000); // 鐢熸垚杩囧幓5鍒嗛挓鐨勬暟鎹� + for (let i = 0; i < 24; i++) { + const now = new Date(Date.now() - (24 - i) * 5000); // 鐢熸垚杩囧幓5鍒嗛挓鐨勬暟鎹� const time = `${now.getHours()}:${now.getMinutes()}:${now.getSeconds()}`; const newValue = (s.baseValue + (Math.random() * 2 - 1) * s.fluctuation).toFixed(2); s.data.push({ -- Gitblit v1.9.3