1
lzhe
2024-10-06 31f08375ddf2b7d0937fd222f9df4d2a6b3d9115
src/views/mdc/station-live.vue
@@ -2,7 +2,7 @@
 * @Author: lzhe lzhe@example.com
 * @Date: 2024-03-26 10:28:33
 * @LastEditors: lzhe lzhe@example.com
 * @LastEditTime: 2024-06-05 11:37:17
 * @LastEditTime: 2024-10-06 23:03:58
 * @FilePath: /smart-web/src/views/master/person/main/index.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
@@ -70,7 +70,7 @@
                           <div class="status-box" v-for="item in achievements"><div class="status-color" :style="{'background-color': item.color}"></div>{{ item.name }}</div>
                        </div>
                        <div class="status-wrap">
                           <el-checkbox v-model="checked1" label="人工反馈状态" size="large" />
                           <el-checkbox v-model="humanFeedback" label="人工反馈状态" size="large" />
                           <div class="status-con">
                              <div class="status-box" v-for="item in collectionstatus"><div class="status-color" :style="{'background-color': item.color}"></div>{{ item.name }}</div>
                           </div>
@@ -133,7 +133,7 @@
         return {
            achievements: [],
            collectionstatus: [],
            checked1: "",
            humanFeedback: "",
            alarmtotal: 0,
            alarmtableData: [],
            wcsDate: "",
@@ -336,7 +336,7 @@
         getrecord() {  //班次状态记录table
            var obj = {
               date: this.wcsDate,
               humanFeedback: true,
               humanFeedback: this.humanFeedback,
               workstationId: this.lastLevelId
            }
            this.$HTTP.post(`/api/blade-mdc/status-record/shift-index-status-record-table`,obj).then(res=> {
@@ -412,7 +412,7 @@
            var obj = {
               date: this.wcsDate,
               //date : "2024-05-15",
               humanFeedback: true,
               humanFeedback: this.humanFeedback,
               workstationId: this.lastLevelId
            }
            this.$HTTP.post(`/api/blade-mdc/status-record/shift-index-status-record-chart`,obj).then(res=> {
@@ -560,7 +560,7 @@
         getwscLvalue() {
            var obj = {
               date: this.wcsDate,
               humanFeedback: true,
               humanFeedback: this.humanFeedback,
               workstationId: this.lastLevelId
            }
            this.$HTTP.post(`/api/blade-mdc/status-record/time-distribution`,obj).then(res=> {
@@ -599,7 +599,7 @@
         getwcsR() {
            var obj = {
               date: this.wcsDate,
               humanFeedback: true,
               humanFeedback: this.humanFeedback,
               workstationId: this.lastLevelId
            }
            this.$HTTP.post(`/api/blade-mdc/status-record/equipment-efficiency`,obj).then(res=> {
@@ -644,8 +644,7 @@
            }
         },
         getdmp(lastLevelId,machineId) {
            console.log(lastLevelId,machineId)
            this.$HTTP.get(`/api/blade-cps/workstation/get-dmp-variables?machineId=${machineId}&workstationId=${lastLevelId}`).then(res=> {
            this.$HTTP.get(`/api/blade-cps/workstation/listDatapointsByWorkstationId?machineId=${machineId}&workstationId=${lastLevelId}`).then(res=> {
               if(res.code == 200) {
                  this.dmpList = [];
                  var that = this;
@@ -654,17 +653,21 @@
                     type: "realTimeData",
                     workstationIdList: [lastLevelId]
                  }
                  if(res.data.dpConfig == null || res.data.dpConfig.length == 0) return;  //没值不用循环
                  if(this.$TOOL.socket.websocket == null) {  //没有建立先建立
                     this.$TOOL.socket.connectToWebSocket(this.$TOOL.cookie.get("TOKEN")); 
                  }
                  console.log(obj,222333)
                  this.$TOOL.socket.sendDataToWebSocket(obj);  //发送
                  this.$TOOL.socket.websocket.onmessage = function(event) {  
                     if(res.data.length == 0) return;  //没值不用循环
                       res.data.forEach(item=> {  //第一步把v放到code里
                     var JSONData = JSON.parse(res.data.dpConfig);
                       JSONData.forEach((item,index)=> {  //第一步把v放到code里
                          var eventData = JSON.parse(event.data);
                         if(item.name == "DeviceStatus") {  //机器状态
                             item.code = eventData.data[item.name].v;
                             that.allwcs.forEach(item1=> {
                         if(item.dpName == "DeviceStatus") {  //机器状态
                           if(eventData.data[item.dpName]) {
                              item.code = eventData.data[item.dpName].v;
                           }
                             that.allwcs.forEach((item1)=> {
                                if(item.code == item1.code) {
                                   item.codeName = item1.name;    //第二步把v的code和运行对应
                                   if(item.code == "2") {
@@ -675,18 +678,32 @@
                                }
                             })
                         }else {
                            if(item.name == 'Alarm') {  //报警
                               var v = JSON.parse(eventData.data[item.name].v);
                               item.description = v.code;
                               item.codeName = v.msg;
                               item.color = "#370C0D";
                            if(item.dpName == 'Alarm') {  //报警
                              if(eventData.data[item.dpName]) {
                                 var v = JSON.parse(eventData.data[item.dpName].v);
                                 if(Array.isArray(v)) {  //如果是数组,不赋值
                                    if(v.length == 0) {
                                       JSONData.splice(index,1);
                                    }else {
                                       item.description = v[0].code;
                                       item.codeName = v[0].msg;
                                       item.color = "#370C0D";
                                    }
                                 }else {
                                    item.description = v.code;
                                    item.codeName = v.msg;
                                    item.color = "#370C0D";
                                 }
                              }
                            }else {
                               item.codeName = eventData.data[item.name].v;
                                item.color = "#75C0C0";
                              if(eventData.data[item.dpName]) {
                                 item.codeName = eventData.data[item.dpName].v;
                              }
                              item.color = "#75C0C0";
                            }
                         }
                     });
                     that.dmpList = res.data;
                     that.dmpList = JSONData;
                   };
               }
            })