dongjh 1 год назад
Родитель
Сommit
4bf3c984cf
2 измененных файлов с 81 добавлено и 128 удалено
  1. 1 1
      src/utils/request.js
  2. 80 127
      src/views/module_tpm/equipmentRunStatis/realtime.vue

+ 1 - 1
src/utils/request.js

@@ -17,7 +17,7 @@ let apiBaseUrl = window._CONFIG['domianURL'] || "/jeecg-boot";
 const service = axios.create({
   //baseURL: '/jeecg-boot',
   baseURL: apiBaseUrl, // api base_url
-  timeout: 9000 // 请求超时时间
+  timeout: 30000 // 请求超时时间
 })
 
 const err = (error) => {

+ 80 - 127
src/views/module_tpm/equipmentRunStatis/realtime.vue

@@ -10,12 +10,12 @@
           </a-col>
           <a-col :xl="4" :lg="7" :md="8" :sm="24">
             <a-form-item label="参数类型">
-              <j-dict-select-tag  v-model="queryParam.tagtype"  placeholder="请输入优先级" dictCode="tpm_tag_type"/>
+              <j-dict-select-tag v-model="queryParams.tagtype"  placeholder="请输入优先级" dictCode="tpm_tag_type"/>
             </a-form-item>
           </a-col>
           <a-col :xl="6" :lg="7" :md="8" :sm="24">
             <span style="float: left; overflow: hidden" class="table-page-search-submitButtons">
-              <a-button type="primary" @click="handleQuery" icon="search">查询</a-button>
+              <a-button type="primary" @click="loadData" icon="search">查询</a-button>
             </span>
           </a-col>
         </a-row>
@@ -30,7 +30,7 @@
         size="middle"
         :scroll="{ x: true }"
         bordered
-        rowKey="equipmentid"
+        rowKey="id"
         :columns="columns"
         :dataSource="dataSource"
         :pagination="ipagination"
@@ -77,34 +77,24 @@ export default {
     return {
       loading: true,
       dataSource: [],
+      dataInfo: null,
+      times: [],
+      myChart: null,
       echartsHeight: window.innerHeight - 350,
       // 查询参数
       queryParams: {
         pageNum: 1,
-        pageSize: 1000,
-        equipmentid: '300889957007361',
+        pageSize: 10,
+        equipmentid: '301156882513921',
         day: null,
-        tagtype: null,
+        tagtype: "5",
       },
       url: {
-        list: '/equipmentOnoffSection/equipmentOnoffSection/listtransverse',
-        list1: '/emsStatistics/searchEquipmentDetail',
+        list: '/equipmentStatistics/equipmentStatistics/listday',
+        listinfo: '/equipmentStatistics/equipmentStatistics/listdayinfo',
       },
       // 时间
       timeList: [],
-      // 类型
-      tageTypeList: {
-        temp: '温度',
-        humi: '湿度',
-        curr: '电流',
-        volt: '电压',
-        power: '功率',
-        speed: '转速',
-        vacu: '真空度',
-        pres: '压力',
-        flow: "流量",
-        ph: "PH计",
-      },
       // 表头
       columns: [
         {
@@ -118,49 +108,31 @@ export default {
           },
         },
         {
-          title: '时间',
-          align: 'center',
-          dataIndex: 'equipmentid_dictText',
-        },
-        {
-          title: 'A相电压',
+          title: '点位名称',
           align: 'center',
-          dataIndex: 'equipmentcode',
+          dataIndex: 'tagname',
         },
         {
-          title: 'B相电压',
+          title: '时间',
           align: 'center',
-          dataIndex: 'day',
+          dataIndex: 'logtime',
         },
         {
-          title: 'C相电压',
+          title: '',
           align: 'center',
-          dataIndex: 'duration',
+          dataIndex: 'tagvalue',
         },
       ],
     }
   },
   created() {},
   mounted() {
+    var now = this.dateformat(new Date()).substring(0, 10)
+    this.queryParams.day = now
     this.$nextTick(() => {
-      var now = this.dateformat(new Date()).substring(0, 10)
-      this.queryParams.day = now
-      this.handleQuery()
-      setTimeout(() => {
-        this.getTest()
-      }, 1000)
     })
   },
   methods: {
-    // 后端好了需要删掉
-    getTest() {
-      this.moniparamData = emsdata.moniparamData
-      this.initEcharts()
-    },
-    /** 重置按钮操作 */
-    resetQuery() {
-      this.handleQuery()
-    },
     dateformat(date) {
       var year = date.getFullYear()
       var month = date.getMonth() + 1
@@ -178,19 +150,41 @@ export default {
     },
     /** 查询设备运行状态时间段列表 */
     loadData(arg) {
+      var _this = this;
       if (!this.url.list) {
         this.$message.error('请设置url.list属性!')
         return
       }
+      if (!this.queryParams.equipmentid) {
+        return
+      }
       //加载数据 若传入参数1则加载第一页的内容
       if (arg === 1) {
         this.ipagination.current = 1
       }
+      console.log("tagtype", this.queryParams.tagtype)
       var params = this.getQueryParams() //查询条件
-      params.equipmentid = !params.equipmentid ? '' : params.equipmentid
-      params.day_begin = !params.day_begin ? '' : params.day_begin
-      params.day_end = !params.day_end ? '' : params.day_end
+      params.equipmentid = !this.queryParams.equipmentid ? '' : this.queryParams.equipmentid
+      params.day = !this.queryParams.day ? '' : this.queryParams.day
+      params.tagtype = !this.queryParams.tagtype ? '' : this.queryParams.tagtype
       this.loading = true
+
+      // 获取图表信息
+      getAction(_this.url.listinfo, params).then((res) => {
+        if (res.success) {
+          _this.dataInfo = res.result.records || res.result;
+          _this.getList(params);
+          _this.initEcharts();
+        } else {
+          this.$message.warning(res.message)
+        }
+      });
+
+      this.loading = false
+    },
+    
+    // 获取表格信息
+    getList(params) {
       getAction(this.url.list, params).then((res) => {
         if (res.success) {
           //update-begin---author:zhangyafei    Date:20201118  for:适配不分页的数据列表------------
@@ -204,37 +198,45 @@ export default {
         } else {
           this.$message.warning(res.message)
         }
-
-        this.loading = false
-      })
-    },
-    handleQuery() {
-      var _this = this
-      _this.loading = true
-      getAction(this.url.list, _this.queryParams).then((response) => {
-        _this.tpmequiponoffsectionList = response.result
-        // Generate mock data
-        _this.equipments = []
-        _this.onduration = []
-        _this.pauseduration = []
-        _this.offduration = []
-        _this.tpmequiponoffsectionList.forEach(function (equipment, key) {
-          _this.equipments.push(equipment.equipmentid_dictText + '[' + equipment.equipmentcode + ']')
-          _this.onduration.push(equipment.onduration)
-          _this.pauseduration.push(equipment.pauseduration)
-          _this.offduration.push(equipment.offduration)
-        })
-
-        this.loading = false
-
-        this.initEcharts()
       })
     },
     initEcharts() {
       var _this = this
-      var chartDom = _this.$refs.echarts
+      var chartDom = _this.$refs.trendCharts;
+      _this.myChart && _this.myChart.dispose();
       _this.myChart = echarts.init(chartDom)
 
+      var legends = [];
+      var seriess = [];
+      _this.times = [];
+      var rec = 0;
+      _this.dataInfo.tag.forEach(item => {
+        legends.push(item.tagname);
+        var realdatas = [];
+        _this.dataInfo.list[rec].forEach(realdata => {
+          realdatas.push(realdata.tagvalue);
+        });
+        seriess.push({
+          name: item.tagname,
+          type: 'line',
+          symbol: 'none',
+          sampling: 'lttb',
+          markPoint: {
+            data: [
+              { type: 'max', name: 'Max' },
+              { type: 'min', name: 'Min' },
+            ],
+          },
+          data: realdatas,
+        });
+        console.log(rec, seriess);
+        rec++;
+      });
+
+      _this.dataInfo.list[0].forEach(item => {
+        _this.times.push(item.logtime);
+      });
+
       var option = {
         tooltip: {
           trigger: 'axis',
@@ -247,12 +249,12 @@ export default {
           text: '实时数据',
         },
         legend: {
-          data: ['A相', 'B相', 'C相'],
+          data: legends,
         },
         xAxis: {
           type: 'category',
           boundaryGap: false,
-          data: _this.moniparamData.times,
+          data: _this.times,
         },
         yAxis: {
           type: 'value',
@@ -278,56 +280,7 @@ export default {
             right: "7%",
           },
         ],
-        series: [
-          {
-            name: 'A相',
-            type: 'line',
-            symbol: 'none',
-            sampling: 'lttb',
-            // itemStyle: {
-            //   color: '#91CC75',
-            // },
-            markPoint: {
-              data: [
-                { type: 'max', name: 'Max' },
-                { type: 'min', name: 'Min' },
-              ],
-            },
-            data: _this.moniparamData.result.Pa,
-          },
-          {
-            name: 'B相',
-            type: 'line',
-            symbol: 'none',
-            sampling: 'lttb',
-            // itemStyle: {
-            //   color: '#EE6666',
-            // },
-            markPoint: {
-              data: [
-                { type: 'max', name: 'Max' },
-                { type: 'min', name: 'Min' },
-              ],
-            },
-            data: _this.moniparamData.result.Pb,
-          },
-          {
-            name: 'C相',
-            type: 'line',
-            symbol: 'none',
-            sampling: 'lttb',
-            // itemStyle: {
-            //   color: '#FAAD14',
-            // },
-            markPoint: {
-              data: [
-                { type: 'max', name: 'Max' },
-                { type: 'min', name: 'Min' },
-              ],
-            },
-            data: _this.moniparamData.result.Pc,
-          },
-        ],
+        series: seriess,
       }
 
       option && _this.myChart.setOption(option)