From fdb97cca1f302db3fe07cc700130a085d991d682 Mon Sep 17 00:00:00 2001 From: lzhe <lzhe@example.com> Date: 星期三, 19 六月 2024 22:41:49 +0800 Subject: [PATCH] 1 --- src/views/mdc/realtime-status/index.vue | 172 +++++++++++++++++++++++++++++++++++++-------------------- 1 files changed, 112 insertions(+), 60 deletions(-) diff --git a/src/views/mdc/realtime-status/index.vue b/src/views/mdc/realtime-status/index.vue index ec686cb..fa3ee1a 100644 --- a/src/views/mdc/realtime-status/index.vue +++ b/src/views/mdc/realtime-status/index.vue @@ -1,7 +1,7 @@ <!-- * @Date: 2024-04-09 22:11:21 - * @LastEditors: Sneed - * @LastEditTime: 2024-04-09 22:12:14 + * @LastEditors: lzhe lzhe@example.com + * @LastEditTime: 2024-06-19 13:44:36 * @FilePath: /belleson-frontend/Users/mache/Documents/demo/cps-web/src/views/mdc/realtime-status/index.vue 瀹炴椂鐪嬫澘 --> @@ -36,7 +36,7 @@ <div class="status-next" @click="next"> <el-icon><ArrowRight /></el-icon> </div> - <div class="status-content-cardp" v-for="item in timestatus" style="width: 33.3333%; height: 50%;"> + <div class="status-content-cardp" v-for="item in timestatus" :style="{'width': (100/column) + '%'}"> <div class="status-card-box" style="border-color: #ccc;"> <div class="status-card-top"> <div class="status-card-detail"> @@ -104,22 +104,37 @@ stationlabel: "", stationlabelList: [], current: "1", + size: "9", total: 0, deviceStatus: [], - workStationGroupIdList: [] + workStationGroupIdList: [], + line: "", + column: "" } }, mounted() { - this.getdevicestatus(); //鑾峰彇椤堕儴title this.getstationlabelList(); //鑾峰彇鏍囩瑙嗗浘涓嬬殑list this.setIntervalTime(); //鍗佺澧炲姞鏃堕棿 + this.getprocess(); //鑾峰彇棰滆壊==銆嬭幏鍙栭《閮╰itle==銆嬭缃嚑琛屽嚑鍒�==銆媤s }, methods: { + getSetting() { + this.$HTTP.get(`/api/blade-system/param/detail?paramKey=mdc.realtime.setting`).then(res=> { + if(res.code == 200) { + var paramValue = JSON.parse(res.data.paramValue); + this.line = paramValue.line==0?1:paramValue.line; + this.column = paramValue.column; + this.current = "1"; + this.size = this.line * this.column; + this.gettimestatus(); //ws + } + }) + }, setIntervalTime() { function addTime(timeStr) { var increaseByMilliseconds = 10 * 1000; // 10绉掕浆鎹负姣 // 瑙f瀽鏃堕棿瀛楃涓蹭负澶╂暟銆佸皬鏃躲�佸垎閽熷拰绉� - if(timeStr != undefined) { + if(timeStr != undefined && timeStr != "--") { var parts = timeStr.match(/(\d+)澶�(\d+)鏃�(\d+)鍒�(\d+)绉�/); var days = parseInt(parts[1], 10) * 24 * 60 * 60 * 1000; // 澶╂暟杞崲涓烘绉� var hours = parseInt(parts[2], 10) * 60 * 60 * 1000; // 灏忔椂杞崲涓烘绉� @@ -205,9 +220,10 @@ this.gettimestatus(); }, next() { - if((this.total/9 - this.current) < 0) return; - this.current = Number(this.current) + 1; - this.gettimestatus(); + if((this.current * this.line) < this.total/this.column) { + this.current = Number(this.current) + 1; + this.gettimestatus(); + } }, goSet() { this.$router.push('/mdc/configuration'); @@ -216,10 +232,11 @@ this.$router.push('/mdc/station-live?code='+item.id); }, getprocess() { //棰滆壊鐘舵�� - this.$HTTP.get(`/api/blade-cps/global_wcs/wcs-achievements`).then(res=> { + this.$HTTP.get(`/api/blade-cps/global_wcs/list?code=&name=`).then(res=> { if(res.code == 200) { this.allwcs = res.data; - this.gettimestatus(); + this.getdevicestatus(); //鑾峰彇椤堕儴title/鍏蜂綋鏁版嵁 + this.getSetting(); //鑾峰彇鍑犺鍑犲垪 } }) }, @@ -246,26 +263,28 @@ workStationGroupIdList: this.workStationGroupIdList } this.timestatus = []; - this.$HTTP.post(`/api/blade-cps/workstation/real-time-status?current=${this.current}&size=9`,obj).then(res=> { + this.$HTTP.post(`/api/blade-cps/workstation/real-time-status?current=${this.current}&size=${this.size}`,obj).then(res=> { if(res.code == 200) { var ids = []; + console.log(this.allwcs,res.data) res.data.records.forEach(item=> { - item.statusName = "鏈煡"; - item.statusStyle = '#ccc'; ids.push(item.id); - if(item.properties != null) { + if(item.properties != null && item.properties.length!=0) { item.properties.forEach(item1=> { - this.devicestatus.forEach(item2=> { - if(item2.status == item1.value) { - item.statusName = item2.statusName; - item1.statusName = item2.statusName; - item.statusStyle = item2.color; - } - }) + if(item1.key == "DeviceStatus") { + this.allwcs.forEach(item2=> { + if(item2.code == item1.value) { + item1.color = item2.color; + } + }) + } }) + }else { + item.statusName = "鏈煡"; + item.statusStyle = '#ccc'; } - }) + this.timestatus = res.data.records; this.total = res.data.total; //鍙戦�亀ebsocket var obj = { @@ -286,51 +305,85 @@ this.$TOOL.socket.websocket.onmessage = function(event) { num ++; var eventData = JSON.parse(event.data); - if(eventData.data.DeviceStatus != undefined) { - var time = moment(eventData.data.DeviceStatus.t).format('YYYY-MM-DD HH:mm:ss'); - var diffTime = that.changeTime(time); //杞崲鎴愬樊鍊硷紙鏃跺垎绉掞級 - }else { - var diffTime = "--"; - } - if(res.data.records.length == 0) return; //娌″�间笉鐢ㄥ惊鐜� - res.data.records.forEach(item=> { //绗竴姝ユ妸v鏀惧埌code閲� + if(that.timestatus.length == 0) return; //娌″�间笉鐢ㄥ惊鐜� + that.timestatus.forEach((item,index)=> { //绗竴姝ユ妸v鏀惧埌code閲� if(eventData.id == item.id) { if(item.properties == null) { item.properties = []; return; } - item.time = diffTime; - item.properties.forEach(item1=> { + if(eventData.data.DeviceStatus) { + var time = moment(eventData.data.DeviceStatus.t).format('YYYY-MM-DD HH:mm:ss'); + var diffTime = that.changeTime(time); //杞崲鎴愬樊鍊硷紙鏃跺垎绉掞級 + item.time = diffTime; + that.allwcs.forEach(item1=> { + if(item1.code == eventData.data.DeviceStatus.v) { + item.statusName = item1.name; + item.statusStyle = item1.color; + } + }) + }else{ + if(item.time == undefined || item.time == "--") { + var diffTime = "--"; + item.time = diffTime; + } + } + item.properties.forEach((item1,index1)=> { if(item1.key == "DeviceStatus") { //鏈哄櫒鐘舵�� - //item1.code = eventData.data[item1.key].v; if(item1.value == "2") { - item1.color = "#73D13D"; - item1.code = "杩愯"; + that.allwcs.forEach(item2=> { + if(item2.code == item1.value) { + item1.color = item2.color; + item1.code = item2.name; + } + }) }else { item1.color = "#75C0C0"; } }else { if(item1.key == 'Alarm') { //鎶ヨ - var v = JSON.parse(eventData.data[item1.key].v); - item1.name = v.code; - item1.code = v.msg; - item1.color = "#370C0D"; + if(eventData.data[item1.key]) { + var v = JSON.parse(eventData.data[item1.key].v); + if(Array.isArray(v)) { //濡傛灉鏄暟缁勶紝涓嶈祴鍊� + if(v.length == 0) { + res.data.records[index].properties.splice(index1,1); + }else { + item1.name = v[0].code; + item1.code = v[0].msg; + that.allwcs.forEach(item2=> { + if(item2.name == "鎶ヨ") { + item1.color = item2.color; + } + }) + } + }else { + item1.name = v.code; + item1.code = v.msg; + that.allwcs.forEach(item2=> { + if(item2.name == "鎶ヨ") { + item1.color = item2.color; + } + }) + } + } }else { - item1.code = eventData.data[item1.key].v; - item1.color = "#75C0C0"; + if(eventData.data[item1.key]) { + item1.code = eventData.data[item1.key].v; + item1.color = "#75C0C0"; + } } } }) } }); }; - var len = res.data.records.length; - intervalId = setInterval(function() { - if (num === len) { - clearInterval(intervalId); - that.timestatus = res.data.records; //绛夋墍鏈塻ocket鍥炴潵浠ュ悗璧嬪�� - } - }, 500); + // var len = res.data.records.length; + // intervalId = setInterval(function() { + // if (num === len) { + // clearInterval(intervalId); + // that.timestatus = res.data.records; //绛夋墍鏈塻ocket鍥炴潵浠ュ悗璧嬪�� + // } + // }, 500); } }) }, @@ -339,19 +392,18 @@ if(res.code == 200) { res.data.forEach(item=> { item.active = false; + this.allwcs.forEach(item1=> { + if(item.status == item1.code) { + item.color = item1.color; + } + }) }) - res.data[0].color = "#73D13D"; - res.data[1].color = "#370C0D"; - res.data[2].color = "#FFC53D"; - res.data[3].color = "#595959"; - res.data[4].color = "#40A9FF"; res.data[0].icon = "Position"; - res.data[1].icon = "Loading"; - res.data[2].icon = "Clock"; - res.data[3].icon = "Warning"; - res.data[4].icon = "Odometer"; + res.data[1].icon = "Loading"; + res.data[2].icon = "Clock"; + res.data[3].icon = "Warning"; + res.data[4].icon = "Odometer"; this.devicestatus = res.data; - this.getprocess(); //鑾峰彇棰滆壊锛岃幏鍙栨満鍣� } }) } @@ -422,7 +474,7 @@ display: block; } .status-content-cardp { - min-width: 266px; + height: 50%; min-height: 170px; margin: 0; padding: 4px; -- Gitblit v1.9.3