瀏覽代碼

dcs数据保存到influxDB

hfxc226 2 年之前
父節點
當前提交
25951c0364
共有 2 個文件被更改,包括 158 次插入0 次删除
  1. 127 0
      src/api/influxDB/influxDB.js
  2. 31 0
      src/views/remote/opc/RemoteOpc.vue

+ 127 - 0
src/api/influxDB/influxDB.js

@@ -0,0 +1,127 @@
+import { axios } from '@/utils/request'
+import { stringify } from 'qs'
+
+/**
+ * page func
+ * parameter: { }
+ * @param parameter
+ * @returns {*}
+ */
+export function getInfluxDBPage (parameter) {
+  return axios({
+    url: '/influxDB/page?' + stringify(parameter),
+    method: 'get',
+    headers: {
+      'Content-Type': 'application/json;charset=UTF-8'
+    }
+  })
+}
+
+/**
+ * add func
+ * parameter: { }
+ * @param parameter
+ * @returns {*}
+ */
+export function addInfluxDB (parameter) {
+  return axios({
+    url: '/influxDB',
+    method: 'POST',
+    headers: {
+      'Accept': 'application/json',
+      'Content-Type': 'application/json;charset=UTF-8'
+    },
+    data: parameter
+  })
+}
+
+/**
+ * update func
+ * parameter: { }
+ * @param parameter
+ * @returns {*}
+ */
+export function updateInfluxDB (parameter) {
+  return axios({
+    url: '/influxDB/' + parameter.id,
+    method: 'PUT',
+    data: parameter
+  })
+}
+
+/**
+ * fetch single func
+ * parameter: { }
+ * @param parameter
+ * @returns {*}
+ */
+export function fetchInfluxDB (parameter) {
+  return axios({
+    url: '/influxDB/' + parameter.id,
+    method: 'get',
+    headers: {
+      'Content-Type': 'application/json;charset=UTF-8'
+    }
+  })
+}
+
+/**
+ * query list func
+ * parameter: { }
+ * @param parameter
+ * @returns {*}
+ */
+export function queryInfluxDB (parameter) {
+  return axios({
+    url: '/influxDB?' + stringify(parameter),
+    method: 'get',
+    headers: {
+      'Content-Type': 'application/json;charset=UTF-8'
+    }
+  })
+}
+
+/**
+ * delete batch func
+ * parameter: { }
+ * @param parameter
+ * @returns {*}
+ */
+export function deleteInfluxDBs (parameter) {
+  return axios({
+    url: '/influxDB',
+    method: 'DELETE',
+    data: parameter
+  })
+}
+
+/**
+ * delete single func
+ * parameter: { }
+ * @param parameter
+ * @returns {*}
+ */
+export function deleteInfluxDB (parameter) {
+  return axios({
+    url: '/influxDB/' + parameter.id,
+    method: 'DELETE',
+    data: parameter
+  })
+}
+
+/**
+ * export file
+ * parameter: { }
+ * @param parameter :
+ * @returns {*}
+ */
+export function exportInfluxDB (parameter) {
+  return axios({
+    url: '/influxDB/export?' + stringify(parameter),
+    method: 'get',
+    headers: {
+      'Content-Type': 'application/json;charset=UTF-8'
+    },
+    responseType: 'blob'
+  })
+}

+ 31 - 0
src/views/remote/opc/RemoteOpc.vue

@@ -71,6 +71,18 @@
               icon="download"
               @click="doAddAll">全部采集
             </a-button>
+<!--            <a-button
+              style="margin-left: 8px"
+              type="primary"
+              icon="download"
+              @click="doTestAdd">测试写入
+            </a-button>
+            <a-button
+              style="margin-left: 8px"
+              type="primary"
+              icon="download"
+              @click="doTestSelect">测试查询
+            </a-button>-->
             <a-dropdown v-action:edit v-if="selectedRowKeys.length > 0 && $auth('remote-opcs-del')">
               <a-menu slot="overlay">
                 <a-popconfirm title="是否要删除所选数据?" @confirm="batchDelete()">
@@ -159,6 +171,7 @@ import {
 } from '@/api/remote/opc'
 
 import ImportFormAdd from './modules/ImportFormAdd'
+import { addInfluxDB, queryInfluxDB } from '@/api/influxDB/influxDB'
 
 export default {
   name: 'RemoteOpcList',
@@ -368,6 +381,24 @@ export default {
         this.$message.info('已添加,100秒后自动采集')
       })
     },
+    doTestAdd () {
+      const parameter = {
+        ...this.queryParam,
+        sbIds: this.selectedRowKeys
+      }
+      addInfluxDB(parameter).then(res => {
+        this.$message.info('已添加')
+      })
+    },
+    doTestSelect () {
+      const parameter = {
+        ...this.queryParam,
+        sbIds: this.selectedRowKeys
+      }
+      queryInfluxDB(parameter).then(res => {
+        this.$message.info('已查询')
+      })
+    },
     handleEdit (record) {
       fetchRemoteOpc({ id: record.id }).then(res => {
         const modal = this.$refs.baseModal