| | |
| | | <!-- |
| | | * @Date: 2024-04-09 22:11:21 |
| | | * @LastEditors: lzhe lzhe@example.com |
| | | * @LastEditTime: 2024-06-18 16:42:07 |
| | | * @LastEditTime: 2024-06-19 13:44:36 |
| | | * @FilePath: /belleson-frontend/Users/mache/Documents/demo/cps-web/src/views/mdc/realtime-status/index.vue |
| | | 实时看板 |
| | | --> |
| | |
| | | mounted() { |
| | | this.getstationlabelList(); //获取标签视图下的list |
| | | this.setIntervalTime(); //十秒增加时间 |
| | | this.getSetting(); //设置几行几列 ==》获取顶部title=》获取颜色,获取机器=》ws |
| | | this.getprocess(); //获取颜色==》获取顶部title==》设置几行几列==》ws |
| | | }, |
| | | methods: { |
| | | getSetting() { |
| | |
| | | this.column = paramValue.column; |
| | | this.current = "1"; |
| | | this.size = this.line * this.column; |
| | | this.getdevicestatus(); //获取顶部title/具体数据 |
| | | this.gettimestatus(); //ws |
| | | } |
| | | }) |
| | | }, |
| | |
| | | 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(); //获取几行几列 |
| | | } |
| | | }) |
| | | }, |
| | |
| | | this.timestatus = []; |
| | | this.$HTTP.post(`/api/blade-cps/workstation/real-time-status?current=${this.current}&size=${this.size}`,obj).then(res=> { |
| | | if(res.code == 200) { |
| | | this.timestatus = res.data.records; |
| | | 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; |
| | | //发送websocket |
| | | var obj = { |
| | |
| | | this.$TOOL.socket.websocket.onmessage = function(event) { |
| | | num ++; |
| | | var eventData = JSON.parse(event.data); |
| | | console.log(eventData,1234) |
| | | 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 = "--"; |
| | | } |
| | | console.log(that.timestatus,2333) |
| | | if(that.timestatus.length == 0) return; //没值不用循环 |
| | | that.timestatus.forEach((item,index)=> { //第一步把v放到code里 |
| | | if(eventData.id == item.id) { |
| | |
| | | item.properties = []; |
| | | return; |
| | | } |
| | | item.time = diffTime; |
| | | 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 { |
| | | item1.name = v[0].code; |
| | | item1.code = v[0].msg; |
| | | item1.color = "#370C0D"; |
| | | that.allwcs.forEach(item2=> { |
| | | if(item2.name == "报警") { |
| | | item1.color = item2.color; |
| | | } |
| | | }) |
| | | } |
| | | }else { |
| | | item1.name = v.code; |
| | | item1.code = v.msg; |
| | | item1.color = "#370C0D"; |
| | | that.allwcs.forEach(item2=> { |
| | | if(item2.name == "报警") { |
| | | item1.color = item2.color; |
| | | } |
| | | }) |
| | | } |
| | | } |
| | | }else { |
| | |
| | | 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(); //获取颜色,获取机器 |
| | | } |
| | | }) |
| | | } |