Browse Source

完善opc

hfxc226 2 years ago
parent
commit
a83ecfad3f

+ 33 - 0
src/api/remote/opc-log.js

@@ -81,6 +81,22 @@ export function queryRemoteOpcLog (parameter) {
   })
   })
 }
 }
 
 
+/**
+ * query list func
+ * parameter: { }
+ * @param parameter
+ * @returns {*}
+ */
+export function queryRemoteOpcLogByDTO (parameter) {
+  return axios({
+    url: '/remote/opc-logs/dto?' + stringify(parameter),
+    method: 'get',
+    headers: {
+      'Content-Type': 'application/json;charset=UTF-8'
+    }
+  })
+}
+
 /**
 /**
  * query list func
  * query list func
  * parameter: { }
  * parameter: { }
@@ -157,3 +173,20 @@ export function exportRemoteOpcLog (parameter) {
     responseType: 'blob'
     responseType: 'blob'
   })
   })
 }
 }
+
+/**
+ * export file
+ * parameter: { }
+ * @param parameter :
+  * @returns {*}
+ */
+export function exportRemoteOpcLogOneDay (parameter) {
+  return axios({
+    url: '/remote/opc-logs/export/oneDay?' + stringify(parameter),
+    method: 'get',
+    headers: {
+      'Content-Type': 'application/json;charset=UTF-8'
+    },
+    responseType: 'blob'
+  })
+}

+ 2 - 0
src/utils/tool.js

@@ -48,6 +48,8 @@ BaseTool.Date = {
   PICKER_NORM_YEAR: 'YYYY',
   PICKER_NORM_YEAR: 'YYYY',
   PICKER_NORM_MONTH: 'MM',
   PICKER_NORM_MONTH: 'MM',
   PICKER_NORM_MONTH_ONE: 'M',
   PICKER_NORM_MONTH_ONE: 'M',
+  PICKER_NORM_DAY: 'DD',
+  PICKER_NORM_DAY_ONE: 'D',
   PICKER_NORM_YEAR_MONTH: 'YYYY-MM',
   PICKER_NORM_YEAR_MONTH: 'YYYY-MM',
   PICKER_NORM_DATE_PATTERN: 'YYYY-MM-DD',
   PICKER_NORM_DATE_PATTERN: 'YYYY-MM-DD',
   PICKER_NORM_DATE_PATTERN_CHINESE: 'YYYY年MM月DD日',
   PICKER_NORM_DATE_PATTERN_CHINESE: 'YYYY年MM月DD日',

+ 7 - 8
src/views/opc/OpcInfo.vue

@@ -93,9 +93,8 @@
         <a-button v-for="item in list" :key="item.id" :disabled="positionId===item.id" @click="getOpcInfo(item.id)">{{ item.name }}</a-button>
         <a-button v-for="item in list" :key="item.id" :disabled="positionId===item.id" @click="getOpcInfo(item.id)">{{ item.name }}</a-button>
       </a-button-group>
       </a-button-group>
     </div>
     </div>
-    <BaseChartInfo ref="baseChartInfo" @ok="handleOk"/>
     <detail ref="detailModal" @ok="handleOk" />
     <detail ref="detailModal" @ok="handleOk" />
-
+    <detail-log ref="detailLogModal" @ok="handleOk" />
   </div>
   </div>
 </template>
 </template>
 
 
@@ -103,17 +102,17 @@
 import VueDragResize from 'vue-drag-resize'
 import VueDragResize from 'vue-drag-resize'
 import { getSbPositionTree, fetchSbPosition, querySbPosition } from '@/api/sb/position'
 import { getSbPositionTree, fetchSbPosition, querySbPosition } from '@/api/sb/position'
 import {
 import {
-  queryRemoteOpc, updateRemoteOpc,
+  updateRemoteOpc,
   fetchRemoteOpc, queryRemoteOpcFromRedis
   fetchRemoteOpc, queryRemoteOpcFromRedis
 } from '@/api/remote/opc'
 } from '@/api/remote/opc'
 import Detail from '@/views/remote/opc/modules/Detail.vue'
 import Detail from '@/views/remote/opc/modules/Detail.vue'
-import BaseChartInfo from './modules/BaseChartInfo.vue'
+import DetailLog from '@/views/remote/opc-log/modules/Detail.vue'
 export default {
 export default {
   name: 'Opc',
   name: 'Opc',
   components: {
   components: {
     VueDragResize,
     VueDragResize,
-    BaseChartInfo,
-    Detail
+    Detail,
+    DetailLog
   },
   },
   data () {
   data () {
     return {
     return {
@@ -209,8 +208,8 @@ export default {
       this.getImg()
       this.getImg()
     },
     },
     handleInfo (remoteOpc) {
     handleInfo (remoteOpc) {
-      const model = this.$refs.baseChartInfo
-      model.base(remoteOpc)
+      const model = this.$refs.detailLogModal
+      model.base(null, { positionNum: remoteOpc.positionNum })
     },
     },
     handleView (record) {
     handleView (record) {
       fetchRemoteOpc({ id: record.id }).then(res => {
       fetchRemoteOpc({ id: record.id }).then(res => {

+ 74 - 13
src/views/remote/opc-log/modules/Detail.vue

@@ -1,12 +1,31 @@
 <template>
 <template>
-  <a-card :bordered="false" v-show="visible" class="card" :title="modalTitle">
-    <a-row :gutter="48" slot="extra">
-      <a-col :md="48" :sm="48">
-        <span class="table-page-search-submitButtons" style="float: right">
-          <a-button style="margin-left: 8px" type="default" @click="handleCancel()">返回</a-button>
-        </span>
-      </a-col>
-    </a-row>
+  <a-modal
+    :title="modalTitle"
+    :width="1200"
+    :visible="visible"
+    :confirmLoading="confirmLoading"
+    class="ant-modal2"
+    @cancel="handleCancel"
+    :footer="null"
+  >
+    <div class="table-operator" style="margin-bottom: 8px;">
+      <a-row>
+        <a-col :md="16">
+          <a-date-picker
+            :format="BaseTool.Date.PICKER_NORM_DATE_PATTERN"
+            @change="onChange"
+            v-model="searchDay"/>
+          <a-button
+            style="margin-left: 8px"
+            v-if="$auth('remote-opc-logs-export')"
+            type="primary"
+            icon="download"
+            @click="doExport">导出
+          </a-button>
+        </a-col>
+      </a-row>
+    </div>
+    <a-divider>详情</a-divider>
     <detail-list title="" :col="2">
     <detail-list title="" :col="2">
       <detail-list-item term="点位id">{{ model.sbId }}</detail-list-item>
       <detail-list-item term="点位id">{{ model.sbId }}</detail-list-item>
       <detail-list-item term="点位名称">{{ model.sbName }}</detail-list-item>
       <detail-list-item term="点位名称">{{ model.sbName }}</detail-list-item>
@@ -25,9 +44,11 @@
       <detail-list-item term="更新人">{{ model.updateUserId }}</detail-list-item>
       <detail-list-item term="更新人">{{ model.updateUserId }}</detail-list-item>
       <detail-list-item term="更新日期">{{ model.updateTime }}</detail-list-item>-->
       <detail-list-item term="更新日期">{{ model.updateTime }}</detail-list-item>-->
     </detail-list>
     </detail-list>
+    <a-divider orientation="left">趋势图</a-divider>
     <div style="width: 100%">
     <div style="width: 100%">
       <div id="container"></div>
       <div id="container"></div>
     </div>
     </div>
+    <a-divider orientation="left">数组明细</a-divider>
     <div>
     <div>
       <a-table
       <a-table
         bordered
         bordered
@@ -39,11 +60,12 @@
 
 
       </a-table>
       </a-table>
     </div>
     </div>
-  </a-card>
+  </a-modal>
 </template>
 </template>
 
 
 <script>
 <script>
 import { Chart } from '@antv/g2'
 import { Chart } from '@antv/g2'
+import { exportRemoteOpcLogOneDay, queryRemoteOpcLogByDTO } from '@/api/remote/opc-log'
 import DetailList from '@/components/tools/DetailList'
 import DetailList from '@/components/tools/DetailList'
 const DetailListItem = DetailList.Item
 const DetailListItem = DetailList.Item
 
 
@@ -59,6 +81,7 @@ export default {
       confirmLoading: false,
       confirmLoading: false,
       mdl: {},
       mdl: {},
       modalTitle: null,
       modalTitle: null,
+      searchDay: null,
       map: {},
       map: {},
       visible: false,
       visible: false,
       // 下拉框map
       // 下拉框map
@@ -100,12 +123,28 @@ export default {
     this.map = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.REMOTE_OPC)
     this.map = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.REMOTE_OPC)
   },
   },
   methods: {
   methods: {
-    base (record) {
+    base (record, param) {
       this.visible = true
       this.visible = true
       this.modalTitle = '详情'
       this.modalTitle = '详情'
-      this.model = record
-      this.chartsData = JSON.parse(record.dataJsonStr)
-      this.getCharts(this.chartsData)
+      if (!this.BaseTool.Object.isBlank(record)) {
+        this.model = record
+        if (this.model.dataJsonStr == null) {
+          this.$message.info('无数据')
+        }
+        this.chartsData = JSON.parse(this.model.dataJsonStr)
+        this.getCharts(this.chartsData)
+      } else {
+        queryRemoteOpcLogByDTO(param).then((res) => {
+          this.model = res.data
+          if (this.model.dataJsonStr == null) {
+            this.$message.info('无数据')
+          }
+          this.chartsData = JSON.parse(this.model.dataJsonStr)
+          this.getCharts(this.chartsData)
+        }).catch(() => {
+          this.confirmLoading = false
+        })
+      }
     },
     },
     getCharts (data) {
     getCharts (data) {
       this.chart && this.chart.destroy()// 防止点击搜索按钮新增一个
       this.chart && this.chart.destroy()// 防止点击搜索按钮新增一个
@@ -151,6 +190,28 @@ export default {
       this.chart.point().position('time*value')
       this.chart.point().position('time*value')
       this.chart.render()
       this.chart.render()
     },
     },
+    onChange (date, dateString) {
+      const param = {}
+      param.positionNum = this.model.positionNum
+      param.year = date.format(this.BaseTool.Date.PICKER_NORM_YEAR)
+      param.month = date.format(this.BaseTool.Date.PICKER_NORM_MONTH_ONE)
+      param.day = date.format(this.BaseTool.Date.PICKER_NORM_DAY_ONE)
+      queryRemoteOpcLogByDTO(param).then((res) => {
+        this.model = res.data
+        if (this.model.dataJsonStr == null) {
+          this.$message.info('无数据')
+        }
+        this.chartsData = JSON.parse(this.model.dataJsonStr)
+        this.getCharts(this.chartsData)
+      }).catch(() => {
+        this.confirmLoading = false
+      })
+    },
+    doExport () {
+      exportRemoteOpcLogOneDay(this.model).then(file => {
+        this.BaseTool.UPLOAD.downLoadExportExcel(file)
+      })
+    },
     handleCancel () {
     handleCancel () {
       this.visible = false
       this.visible = false
       this.confirmLoading = false
       this.confirmLoading = false

+ 3 - 2
src/views/remote/opc/RemoteOpc.vue

@@ -151,6 +151,7 @@ import {
 } from '@/api/remote/opc'
 } from '@/api/remote/opc'
 
 
 import ImportFormAdd from './modules/ImportFormAdd'
 import ImportFormAdd from './modules/ImportFormAdd'
+import { exportSbInfo } from '@/api/sb/info'
 
 
 export default {
 export default {
   name: 'RemoteOpcList',
   name: 'RemoteOpcList',
@@ -382,8 +383,8 @@ export default {
       const parameter = {
       const parameter = {
         ...this.queryParam
         ...this.queryParam
       }
       }
-      exportRemoteOpc(parameter).then(file => {
-        this.BaseTool.Util.downLoadExportExcel(file)
+      exportSbInfo(parameter).then(file => {
+        this.BaseTool.UPLOAD.downLoadExportExcel(file)
       })
       })
     },
     },
     doImport () {
     doImport () {