From 831cfa4c439c6d073d706a82d2a439f8b1818498 Mon Sep 17 00:00:00 2001
From: yangys <y_ys79@sina.com>
Date: 星期二, 18 十一月 2025 16:59:50 +0800
Subject: [PATCH] Merge branch 'new' of http://www.beijingsoft.cn:9090/r/smart-web into new
---
src/views/mdc/realtime-status/index.vue | 261 ++++++++++++++++++++++++---------------------------
1 files changed, 123 insertions(+), 138 deletions(-)
diff --git a/src/views/mdc/realtime-status/index.vue b/src/views/mdc/realtime-status/index.vue
index 9d8daee..22b38f8 100644
--- a/src/views/mdc/realtime-status/index.vue
+++ b/src/views/mdc/realtime-status/index.vue
@@ -1,8 +1,8 @@
<!--
* @Date: 2024-04-09 22:11:21
- * @LastEditors: lzhe lzhe@example.com
- * @LastEditTime: 2024-10-09 11:40:18
- * @FilePath: /mdc/Users/mache/Documents/demo/cps-web/src/views/mdc/realtime-status/index.vue
+ * @LastEditors: 鏉庡枂(寮�鍙戠粍) lzhe@yxqiche.com
+ * @LastEditTime: 2025-05-28 13:45:33
+ * @FilePath: /cps-web/src/views/mdc/realtime-status/index.vue
瀹炴椂鐪嬫澘
-->
<template>
@@ -44,22 +44,23 @@
<ArrowRight />
</el-icon>
</div>
- <div class="status-content-cardp" v-for="(item,index) in timestatus" :style="{ 'width': (100 / column) + '%' }">
+ <div class="status-content-cardp" v-for="(item, index) 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">
- <div title="461" class="status-card-detail-name">{{ item.code }}</div>
+ <div class="status-card-detail-name" :title="item.name">{{ item.name }}</div>
<div class="status-card-detail-status">
<div class="status-card-detail-point" :style="{ 'background-color': item.statusStyle }">
</div>{{ item.statusName }}
- <div class="status-card-detail-time" :style="{ 'color': item.statusStyle }">{{ item.time
- }}
+ <div class="status-card-detail-time" :style="{ 'color': item.statusStyle }">{{ item.time }}
</div>
</div>
</div>
<div class="status-card-machine" style="border-color: #ccc;">
<div class="status-card-machine-img">
- <img src="./station.png" width="68" height="68">
+ <img :src="item.avatar" width="68" height="68">
+
</div>
<div class="status-card-machine-mesg">
<div class="status-card-machine-mesg-form">
@@ -70,7 +71,7 @@
</div>
</div>
<div class="status-card-bottom">
- <div class="status-card-bottom-realtime" @click="showvisible(item,index)"><i
+ <div class="status-card-bottom-realtime" @click="showvisible(item, index)"><i
class="iconfont saber-xiangqing status-card-bottom-icon"></i> 瀹炴椂鏁版嵁</div>
<div class="status-card-bottom-detail" @click="gostatus(item)"><i
class="iconfont saber-shuju status-card-bottom-icon"></i> 宸ヤ綅璇︽儏</div>
@@ -78,20 +79,20 @@
</div>
</div>
</div>
- <el-dialog :title="titleMap" v-model="visible" :width="740">
+ <el-dialog :title="titleMap" v-model="visible" :width="740" v-if="visible">
<div class="dialogstyle">
- <div class="realtime-analysis-card" v-for="item in timestatus[clickIndex].properties">
- <div class="card-name" :style="{ 'background-color': item.color }">{{ item.name }}</div>
- <div class="card-value"
- :class="{ 'card-value': true, 'card-value-bg1': item.key != 'Alarm', 'card-value-bg2': item.key == 'Alarm' }">
- {{ item.code }}</div>
- </div>
+ <el-table :data="timestatus[clickIndex].properties" style="width: 100%" border>
+ <el-table-column prop="name" label="鏁版嵁鐐�"></el-table-column>
+ <el-table-column prop="code" label="鍊�"></el-table-column>
+ <el-table-column prop="moment" label="閲囬泦鏃堕棿"></el-table-column>
+ </el-table>
</div>
</el-dialog>
</div>
</template>
<script>
+import station from "./station1.jpg";
import moment from 'moment';
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
let icons = []
@@ -104,6 +105,7 @@
},
data() {
return {
+ station: station,
clickIndex: 0,
allwcs: [],
statusStyle: "#ccc",
@@ -124,9 +126,13 @@
}
},
mounted() {
- this.deviceStatus = this.$route.query.currentTag?[...this.$route.query.currentTag]:[];
+ this.deviceStatus = this.$route.query.currentTag ? [...this.$route.query.currentTag] : [];
this.getstationlabelList(); //鑾峰彇鏍囩瑙嗗浘涓嬬殑list
this.getprocess(); //鑾峰彇棰滆壊==銆嬭幏鍙栭《閮╰itle==銆嬭缃嚑琛屽嚑鍒�==銆媤s
+ //姣忎竴鍒嗛挓鎵ц涓�娆�
+ var intervalId = setInterval(() => {
+ this.getdevicestatus();
+ }, 60000);
},
methods: {
getSetting() {
@@ -141,42 +147,6 @@
}
})
},
- setIntervalTime() {
- function addTime(timeStr) {
- var increaseByMilliseconds = 10 * 1000; // 10绉掕浆鎹负姣
- // 瑙f瀽鏃堕棿瀛楃涓蹭负澶╂暟銆佸皬鏃躲�佸垎閽熷拰绉�
- 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; // 灏忔椂杞崲涓烘绉�
- var minutes = parseInt(parts[3], 10) * 60 * 1000; // 鍒嗛挓杞崲涓烘绉�
- var seconds = parseInt(parts[4], 10) * 1000; // 绉掕浆鎹负姣
- // 鍒涘缓涓�涓狹oment.js鐨勬寔缁椂闂村璞�
- var duration = moment.duration(days + hours + minutes + seconds);
- // 澧炲姞鏃堕棿
- duration.add(increaseByMilliseconds); // 澧炲姞10绉�
- // 灏嗘寔缁椂闂磋浆鎹㈠洖澶╂暟銆佸皬鏃躲�佸垎閽熷拰绉掞紙娉ㄦ剰杩欓噷鍙兘涓嶅畬鍏ㄧ簿纭紝鍥犱负澶╂暟鍙兘涓嶆槸鏁存暟锛�
- var totalMilliseconds = duration.asMilliseconds();
- var totalDays = Math.floor(totalMilliseconds / (1000 * 60 * 60 * 24));
- var remainingMilliseconds = totalMilliseconds % (1000 * 60 * 60 * 24);
- var totalHours = Math.floor(remainingMilliseconds / (1000 * 60 * 60));
- remainingMilliseconds %= (1000 * 60 * 60);
- var totalMinutes = Math.floor(remainingMilliseconds / (1000 * 60));
- remainingMilliseconds %= (1000 * 60);
- var totalSeconds = Math.floor(remainingMilliseconds / 1000);
- return `${totalDays}澶�${totalHours}鏃�${totalMinutes}鍒�${totalSeconds}绉抈;
- } else {
- return timeStr;
- }
- }
- setInterval(() => {
- if (this.timestatus.length != 0) {
- this.timestatus.forEach(item => {
- item.time = addTime(item.time);
- })
- }
- }, 1000 * 10)
- },
changestationlabel(name) {
this.stationlabel = name;
this.stationlabelList.forEach(item => {
@@ -187,17 +157,17 @@
this.gettimestatus(); //鏌ヨ鍒楄〃
},
getstationlabelList() {
- this.$HTTP.get("/api/blade-cps/group/get-mdc-group").then(res => {
+ this.$HTTP.get("/api/smis/group/get-mdc-group").then(res => {
if (res.code == 200) {
this.stationlabelList = res.data;
- if(res.data.length != 0) {
+ if (res.data.length != 0) {
this.stationlabel = res.data[0].groupName;
}
}
})
},
changestatus(name) {
- if(this.stationlabelList.length == 0) {
+ if (this.stationlabelList.length == 0) {
this.station = "鐘舵�佽鍥�";
this.$message.error('鏈�夊畾瀹炴椂鐪嬫澘鏌ヨ缁勶紝璇峰埌"鍒嗘瀽璁剧疆 -> 瀹炴椂鐪嬫澘鏌ヨ缁勮缃�"涓�夋嫨宸ヤ綅缁�');
return;
@@ -209,21 +179,18 @@
this.stationlabel = this.stationlabelList[0].groupName;
this.workStationGroupIdList = [this.stationlabelList[0].groupId];
}
+ this.clickIndex = 0;
this.gettimestatus(); //鏌ヨ鍒楄〃
},
- showvisible(item,index) {
- //clickIndex
+ showvisible(item, index) {
+ if(item.properties.length == 0) {
+ this.$message({
+ message: '璇ュ伐浣嶆病鏈夐厤缃暟鎹偣',
+ type: 'warning'
+ });
+ return;
+ }
this.clickIndex = index;
- // if (item.properties == null || item.properties.length == 0) {
- // this.$message({
- // message: '璇烽厤缃噰闆嗛」',
- // type: 'warning'
- // });
- // return;
- // }
- // var visibleList = JSON.parse(JSON.stringify(item.properties));
- // this.titleMap = "瀹炴椂鏁版嵁(" + item.code + ")";
- // this.visibleList = visibleList;
this.visible = true;
},
searchstatus(item, index) {
@@ -231,7 +198,12 @@
item.active = false;
})
this.devicestatus[index].active = true;
- this.deviceStatus = [item.status];
+ if(item.status == 10) { //鍏ㄩ儴
+ this.deviceStatus = [];
+ }else {
+ this.deviceStatus = [item.status];
+ }
+ this.current = "1";
this.gettimestatus();
},
prev() {
@@ -240,20 +212,20 @@
this.gettimestatus();
},
next() {
+
if ((this.current * this.line) < this.total / this.column) {
this.current = Number(this.current) + 1;
this.gettimestatus();
}
},
goSet() {
- //console.log(this.$TOOL.data.get("MENU"));name == "閰嶇疆涓績"
- this.$router.push('/mdc/configuration'); //鍒嗘瀽璁剧疆
+ this.$router.push('/mdc/configuration?isShowSearch=1'); //鍒嗘瀽璁剧疆(isShowSearch琛ㄧず鍗虫椂淇℃伅鏉�)
},
gostatus(item) {
this.$router.push('/mdc/station-live?code=' + item.id);
},
getprocess() { //棰滆壊鐘舵��
- this.$HTTP.get(`/api/blade-cps/global_wcs/list?code=&name=`).then(res => {
+ this.$HTTP.get(`/api/smis/global_wcs/list?code=&name=`).then(res => {
if (res.code == 200) {
this.allwcs = res.data;
this.getdevicestatus(); //鑾峰彇椤堕儴title/鍏蜂綋鏁版嵁
@@ -261,12 +233,12 @@
}
})
},
- changeTime(time) {
+ changeTime(time,diffTime) {
// 浣跨敤Moment.js瑙f瀽杩欎袱涓棩鏈熷瓧绗︿覆
var date1 = moment(time);
- var date2 = moment(moment().format('YYYY-MM-DD HH:mm:ss'));
+ var date2 = moment(diffTime);
// 璁$畻涓や釜鏃ユ湡涔嬮棿鐨勫樊寮傦紙姣锛�
- var differenceInMilliseconds = date2.diff(date1); // 娉ㄦ剰锛歞ate2 - date1 缁欏嚭姝f暟宸紓
+ var differenceInMilliseconds = date1.diff(date2); // 娉ㄦ剰锛歞ate1 - date2 缁欏嚭姝f暟宸紓
// 浣跨敤duration瀵硅薄灏嗗樊寮傝浆鎹负鏇存槗浜庡鐞嗙殑鍗曚綅
var duration = moment.duration(differenceInMilliseconds);
// 鎻愬彇澶╂暟銆佸皬鏃舵暟銆佸垎閽熸暟鍜岀鏁�
@@ -284,25 +256,14 @@
workStationGroupIdList: this.workStationGroupIdList
}
this.timestatus = [];
- this.$HTTP.post(`/api/blade-cps/workstation/real-time-status?current=${this.current || 0}&size=${this.size || 6}`, obj).then(res => {
+ this.$HTTP.post(`/api/smis/workstation/real-time-status?current=${this.current || 0}&size=${this.size || 6}`, obj).then(res => {
if (res.code == 200) {
var ids = [];
res.data.records.forEach(item => {
- ids.push(item.id);
- if (item.properties != null && item.properties.length != 0) {
- item.properties.forEach(item1 => {
- if (item1.key == "DeviceStatus") {
- this.allwcs.forEach(item2 => {
- if (item2.code == item1.value) {
- item1.color = item2.color;
- }
- })
- }
- })
- } else {
- item.statusName = "鏈煡";
- item.statusStyle = '#ccc';
+ if(item.avatar == "") {
+ item.avatar = station;
}
+ ids.push(item.id);
})
this.timestatus = res.data.records;
this.total = res.data.total;
@@ -320,12 +281,8 @@
that.$TOOL.socket.sendDataToWebSocket(obj); //鍙戦��
}
}, 500);
- //var num = 0;
- var intervalId;
this.$TOOL.socket.websocket.onmessage = function (event) {
- //num++;
var eventData = JSON.parse(event.data);
- if(Object.keys(eventData.data).length == 0) return;
if (that.timestatus.length == 0) return; //娌″�间笉鐢ㄥ惊鐜�
that.timestatus.forEach((item, index) => { //绗竴姝ユ妸v鏀惧埌code閲�
if (eventData.id == item.id) {
@@ -335,8 +292,10 @@
}
if (eventData.data.DeviceStatus) {
var time = moment(eventData.data.DeviceStatus.t).format('YYYY-MM-DD HH:mm:ss');
- var diffTime = that.changeTime(time); //杞崲鎴愬樊鍊硷紙鏃跺垎绉掞級
- that.setIntervalTime(); //鍗佺澧炲姞鏃堕棿
+ var preT = moment(eventData.data.DeviceStatus.preT).format('YYYY-MM-DD HH:mm:ss');
+ //console.log('time='+time+",preT="+preT);
+ var diffTime = that.changeTime(time,preT); //杞崲鎴愬樊鍊硷紙鏃跺垎绉掞級
+ var diffTime = diffTime;
item.time = diffTime;
that.allwcs.forEach(item1 => {
if (item1.code == eventData.data.DeviceStatus.v) {
@@ -346,63 +305,68 @@
})
} else {
if (item.time == undefined || item.time == "--") {
- var diffTime = "--";
- item.time = diffTime;
+ item.time = "--";
+ item.statusName = "鏈煡";
+ item.statusStyle = '#ccc';
}
}
item.properties.forEach((item1, index1) => {
if (item1.key == "DeviceStatus") { //鏈哄櫒鐘舵��
that.allwcs.forEach(item2 => {
- if (item2.code == eventData.data.DeviceStatus.v) {
+ if(eventData.data.DeviceStatus && item2.code == eventData.data.DeviceStatus.v) {
item1.value = item2.code;
- item1.color = item2.color;
item1.code = item2.name;
+ item1.moment = that.timestampChangeTime(eventData.data[item1.key].t); //鏃堕棿鎴宠浆鍖栨垚鏃ユ湡
}
})
+ if (Object.keys(eventData.data).length == 0) { //ws娌℃湁data鏁版嵁锛岀粰榛樿鍊�
+ item1.code = "";
+ item1.moment = "";
+ };
} else {
- if (item1.key == 'Alarm') { //鎶ヨ
- 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;
- }
- } else {
- item1.name = v.code;
- item1.code = v.msg;
+ if(eventData.data[item1.key]) {
+ if(item1.key == "Alarm") {
+ try {
+ var vJson = JSON.parse(eventData.data[item1.key].v);
+ item1.code = JSON.stringify(vJson[0]);
+ } catch (e) {
+ item1.code = eventData.data[item1.key].v;
}
- }
- } else {
- if (eventData.data[item1.key]) {
+ }else {
item1.code = eventData.data[item1.key].v;
}
+ item1.moment = that.timestampChangeTime(eventData.data[item1.key].t); //鏃堕棿鎴宠浆鍖栨垚鏃ユ湡
+ }else {
+ item1.code = "";
+ item1.moment = "";
}
- that.allwcs.forEach(item2 => {
- if (item2.name == "鎶ヨ") {
- item1.color = item2.color;
- }
- })
}
+
})
}
});
};
- // var len = res.data.records.length;
- // intervalId = setInterval(function() {
- // if (num === len) {
- // clearInterval(intervalId);
- // that.timestatus = res.data.records; //绛夋墍鏈塻ocket鍥炴潵浠ュ悗璧嬪��
- // }
- // }, 500);
}
})
},
+ timestampChangeTime(timestamp) { //鏃堕棿鎴宠浆鎹㈡垚鏃堕棿
+ var date = new Date(timestamp);
+ //鎻愬彇骞存湀鏃ュ皬鏃跺垎閽熺
+ var year = date.getFullYear();
+ var month = date.getMonth() + 1; // 鏈堜唤浠�0寮�濮嬶紝鎵�浠ヨ鍔�1
+ var day = date.getDate();
+ var hours = date.getHours();
+ var minutes = date.getMinutes();
+ var seconds = date.getSeconds();
+ // 鏍煎紡鍖栨棩鏈熷瓧绗︿覆
+ var formattedDate = `${year}-${month < 10 ? '0' : ''}${month}-${day < 10 ? '0' : ''}${day} ${hours < 10 ? '0' : ''}${hours}:${minutes < 10 ? '0' : ''}${minutes}:${seconds < 10 ? '0' : ''}${seconds}`;
+ return formattedDate;
+ },
getdevicestatus() {
- this.$HTTP.get(`/api/blade-mdc/work-station-analysis/device-status-statistics`).then(res => {
+ this.$HTTP.get(`/api/mdc/work-station-analysis/device-status-statistics`).then(res => {
if (res.code == 200) {
+ var deviceNumAll = 0;
+ var newResData = [];
res.data.forEach(item => {
item.active = false;
this.allwcs.forEach(item1 => {
@@ -413,13 +377,32 @@
if (this.$route.query.currentTag == item.status) {
item.active = true;
}
+ deviceNumAll += item.deviceNum;
+ /*
+ //璋冭瘯 鍚庣鏁版嵁宸茬粡鍙栨秷
+ if(item.statusName != '璋冭瘯') {
+
+ }*/
+ newResData.push(item);
+ if(item.statusName == '鎶ヨ') {
+ item.icon = "Position";
+ }else if(item.statusName == '寰呮満') {
+ item.icon = "Loading";
+ }else if(item.statusName == '绂荤嚎') {
+ item.icon = "Clock";
+ }else {
+ item.icon = "Odometer";
+ }
})
- 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";
- this.devicestatus = res.data;
+ newResData.push({
+ active: false,
+ color: "#08f1f4",
+ deviceNum: deviceNumAll,
+ icon: "price-tag",
+ status: "10",
+ statusName: "鍏ㄩ儴",
+ })
+ this.devicestatus = newResData;
}
})
}
@@ -532,7 +515,7 @@
font-weight: 700;
font-size: 16px;
color: #333;
- width: 26%;
+ max-width: 37%;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
@@ -548,12 +531,12 @@
width: 12px;
height: 12px;
border-radius: 6px;
- margin-right: 8px;
+ margin-right: 2px;
}
.status-card-detail-time {
line-height: 12px;
- margin-left: 16px;
+ margin-left: 2px;
}
.status-card-machine {
@@ -617,6 +600,7 @@
display: flex;
align-items: center;
justify-content: center;
+ cursor: pointer;
}
.status-card-bottom-detail,
@@ -625,6 +609,7 @@
display: flex;
align-items: center;
justify-content: center;
+ cursor: pointer;
}
.status-card-bottom-icon {
--
Gitblit v1.9.3