Эх сурвалжийг харах

Merge remote-tracking branch 'origin/demo_' into demo_

2 жил өмнө
parent
commit
b9ab90942c

+ 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
  * parameter: { }
@@ -157,3 +173,20 @@ export function exportRemoteOpcLog (parameter) {
     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'
+  })
+}

+ 16 - 0
src/api/remote/opc.js

@@ -123,6 +123,22 @@ export function queryRemoteOpc (parameter) {
   })
 }
 
+/**
+ * query list func
+ * parameter: { }
+ * @param parameter
+ * @returns {*}
+ */
+export function queryRemoteOpcFromRedis (parameter) {
+  return axios({
+    url: '/remote/opcs/redis?' + stringify(parameter),
+    method: 'get',
+    headers: {
+      'Content-Type': 'application/json;charset=UTF-8'
+    }
+  })
+}
+
 /**
  * update func
  * parameter: { }

+ 2 - 0
src/utils/tool.js

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

+ 2 - 2
src/views/opc/Opc.vue

@@ -255,9 +255,9 @@ export default {
   position: relative;
 }
 .info{
-  font-size: 13px;
+  font-size: 14px;
   font-weight: bold;
-  color: rgba(127, 125, 119, 0.27);
+  color: black;
   // transform: scale(0.5);
 }
 .icon{

+ 35 - 18
src/views/opc/OpcInfo.vue

@@ -20,14 +20,14 @@
         >
           <a-tooltip>
             <template slot="title">
-              {{ item.description }}
+              {{ item.description + '(' + item.time + ')' }}
             </template>
             <div class="info" @click="handleInfo(item)" @click.right.prevent="handleView(item)">
-              <span :style="{'color':item.warnFirstColor}" v-if="(+item.result)<=item.warnFirst&&item.warnFirst!==null">{{ item.result + item.unit }}</span>
-              <span :style="{'color':item.warnSecondColor}" v-else-if="item.warnFirst<(+item.result)&&(+item.result)<item.warnSecond">{{ item.result + item.unit }}</span>
-              <span :style="{'color':item.warnThirdColor}" v-else-if="item.warnThird<(+item.result)&&(+item.result)<item.warnFour">{{ item.result + item.unit }}</span>
-              <span :style="{'color':item.warnFourColor}" v-else-if="(+item.result)>=item.warnFour&&item.warnFirst!==null">{{ item.result + item.unit }}</span>
-              <span v-else>{{ item.result + item.unit }}</span>
+              <span :style="{'color':item.warnFirstColor}" v-if="(+item.result)<=item.warnFirst&&item.warnFirst!==null">{{ item.result }}</span>
+              <span :style="{'color':item.warnSecondColor}" v-else-if="item.warnFirst<(+item.result)&&(+item.result)<item.warnSecond">{{ item.result }}</span>
+              <span :style="{'color':item.warnThirdColor}" v-else-if="item.warnThird<(+item.result)&&(+item.result)<item.warnFour">{{ item.result }}</span>
+              <span :style="{'color':item.warnFourColor}" v-else-if="(+item.result)>=item.warnFour&&item.warnFirst!==null">{{ item.result }}</span>
+              <span v-else>{{ item.result }}</span>
             </div>
           </a-tooltip>
         </VueDragResize>
@@ -93,26 +93,26 @@
         <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>
     </div>
-    <BaseChartInfo ref="baseChartInfo" @ok="handleOk"/>
     <detail ref="detailModal" @ok="handleOk" />
-
+    <detail-log ref="detailLogModal" @ok="handleOk" />
   </div>
 </template>
 
 <script>
 import VueDragResize from 'vue-drag-resize'
 import { getSbPositionTree, fetchSbPosition, querySbPosition } from '@/api/sb/position'
-import { queryRemoteOpc, updateRemoteOpc,
-  fetchRemoteOpc
+import {
+  updateRemoteOpc,
+  fetchRemoteOpc, queryRemoteOpc, queryRemoteOpcFromRedis
 } from '@/api/remote/opc'
 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 {
   name: 'Opc',
   components: {
     VueDragResize,
-    BaseChartInfo,
-    Detail
+    Detail,
+    DetailLog
   },
   data () {
     return {
@@ -145,13 +145,14 @@ export default {
     this.getOpcInfo(this.positionId)
     querySbPosition({ parentId: this.parentId }).then(res => {
       this.list = res.data
+      this.getOpcInfoFromRedis(this.positionId)
     })
     this.getImg()
     getSbPositionTree({ opcFlag: 1 }).then(res => {
       this.treeData = res.data
     })
     this.timer = setInterval(() => {
-      this.getOpcInfo(this.positionId)
+      this.getOpcInfoFromRedis(this.positionId)
     }, 5000)
   },
   destroyed () {
@@ -198,6 +199,22 @@ export default {
         })
       this.getImg()
     },
+    getOpcInfoFromRedis (positionId) {
+      this.positionId = positionId
+      queryRemoteOpcFromRedis({ line: this.positionId })
+        .then((res) => {
+          this.dotList.forEach(item => {
+            item.isActive = false
+            res.data.forEach(data => {
+              if (item.positionNum === data.positionNum) {
+                item.result = data.result
+                item.time = data.time
+              }
+            })
+          })
+        })
+      this.getImg()
+    },
     getImg () {
       fetchSbPosition({ id: this.positionId }).then(res => {
         this.imgUrl = res.data.opcImg
@@ -208,8 +225,8 @@ export default {
       this.getImg()
     },
     handleInfo (remoteOpc) {
-      const model = this.$refs.baseChartInfo
-      model.base(remoteOpc)
+      const model = this.$refs.detailLogModal
+      model.base(null, { positionNum: remoteOpc.positionNum })
     },
     handleView (record) {
       fetchRemoteOpc({ id: record.id }).then(res => {
@@ -229,9 +246,9 @@ export default {
   position: relative;
 }
 .info{
-  font-size: 13px;
+  font-size: 14px;
   font-weight: bold;
-  color: rgba(127, 125, 119, 0.27);
+  color: black;
   padding:0 2px;
   // transform: scale(0.5);
 }

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

@@ -1,12 +1,32 @@
 <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"
+            :loading="confirmLoading"
+            @click="doExport">导出
+          </a-button>
+        </a-col>
+      </a-row>
+    </div>
+    <a-divider>详情</a-divider>
     <detail-list title="" :col="2">
       <detail-list-item term="点位id">{{ model.sbId }}</detail-list-item>
       <detail-list-item term="点位名称">{{ model.sbName }}</detail-list-item>
@@ -25,9 +45,11 @@
       <detail-list-item term="更新人">{{ model.updateUserId }}</detail-list-item>
       <detail-list-item term="更新日期">{{ model.updateTime }}</detail-list-item>-->
     </detail-list>
+    <a-divider orientation="left">趋势图</a-divider>
     <div style="width: 100%">
       <div id="container"></div>
     </div>
+    <a-divider orientation="left">数组明细</a-divider>
     <div>
       <a-table
         bordered
@@ -39,11 +61,12 @@
 
       </a-table>
     </div>
-  </a-card>
+  </a-modal>
 </template>
 
 <script>
 import { Chart } from '@antv/g2'
+import { exportRemoteOpcLogOneDay, queryRemoteOpcLogByDTO } from '@/api/remote/opc-log'
 import DetailList from '@/components/tools/DetailList'
 const DetailListItem = DetailList.Item
 
@@ -59,6 +82,7 @@ export default {
       confirmLoading: false,
       mdl: {},
       modalTitle: null,
+      searchDay: null,
       map: {},
       visible: false,
       // 下拉框map
@@ -100,12 +124,31 @@ export default {
     this.map = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.REMOTE_OPC)
   },
   methods: {
-    base (record) {
+    base (record, param) {
       this.visible = true
+      this.confirmLoading = true
       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)
+        this.confirmLoading = false
+      } 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)
+          this.confirmLoading = false
+        }).catch(() => {
+          this.confirmLoading = false
+        })
+      }
     },
     getCharts (data) {
       this.chart && this.chart.destroy()// 防止点击搜索按钮新增一个
@@ -151,9 +194,38 @@ export default {
       this.chart.point().position('time*value')
       this.chart.render()
     },
+    onChange (date, dateString) {
+      this.confirmLoading = true
+      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)
+        this.confirmLoading = false
+      }).catch(() => {
+        this.confirmLoading = false
+      })
+    },
+    doExport () {
+      this.confirmLoading = true
+      exportRemoteOpcLogOneDay(this.model).then(file => {
+        this.BaseTool.UPLOAD.downLoadExportExcel(file)
+        this.confirmLoading = false
+      })
+    },
     handleCancel () {
       this.visible = false
       this.confirmLoading = false
+      this.searchDay = null
+      this.chart = null
+      this.chartsData = []
       this.$emit('ok')
     }
   }

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

@@ -253,7 +253,7 @@ export default {
           ...this.queryParam,
           dataScope: {
             sortBy: 'desc',
-            sortName: 'update_time'
+            sortName: 'created_time'
           }
         }
         return getRemoteOpcPage(Object.assign(parameter, this.queryParam))
@@ -383,7 +383,7 @@ export default {
         ...this.queryParam
       }
       exportRemoteOpc(parameter).then(file => {
-        this.BaseTool.Util.downLoadExportExcel(file)
+        this.BaseTool.UPLOAD.downLoadExportExcel(file)
       })
     },
     doImport () {

+ 14 - 12
src/views/remote/opc/modules/BaseForm.vue

@@ -256,10 +256,11 @@
               v-decorator="['high', {initialValue:100,rules: [{required: false, message: '量程上限不能为空'}]}]"/>
           </a-form-item>
         </row-item>
+
         <row-item>
 
           <a-form-item
-            label="最低阈值"
+            label="报警高高限"
             :labelCol="BaseTool.Constant.labelCol"
             :wrapperCol="BaseTool.Constant.wrapperCol"
           >
@@ -268,8 +269,8 @@
               :min="0.01"
               :formatter="BaseTool.Amount.formatter"
               :parser="BaseTool.Amount.parser"
-              v-decorator="['warnFirst', {rules: [{required: false, message: '最低阈值不能为空'}]}]"/>
-            <a-tag style="line-height:30px;margin-left: 10px;" :color="colors.warnFirstColor" @click="handleSelectColor('warnFirstColor')">
+              v-decorator="['warnFour', {rules: [{required: false, message: '高高限不能为空'}]}]"/>
+            <a-tag style="line-height:30px;margin-left: 10px;" :color="colors.warnFourColor" @click="handleSelectColor('warnFourColor')">
               选择颜色
             </a-tag>
           </a-form-item>
@@ -277,7 +278,7 @@
         <row-item>
 
           <a-form-item
-            label="低阈值"
+            label="报警高限值"
             :labelCol="BaseTool.Constant.labelCol"
             :wrapperCol="BaseTool.Constant.wrapperCol"
           >
@@ -286,8 +287,8 @@
               :min="0.01"
               :formatter="BaseTool.Amount.formatter"
               :parser="BaseTool.Amount.parser"
-              v-decorator="['warnSecond', {rules: [{required: false, message: '低阈值不能为空'}]}]"/>
-            <a-tag style="line-height:30px;margin-left: 10px;" :color="colors.warnSecondColor" @click="handleSelectColor('warnSecondColor')">
+              v-decorator="['warnThird', {rules: [{required: false, message: '高限不能为空'}]}]"/>
+            <a-tag style="line-height:30px;margin-left: 10px;" :color="colors.warnThirdColor" @click="handleSelectColor('warnThirdColor')">
               选择颜色
             </a-tag>
           </a-form-item>
@@ -295,7 +296,7 @@
         <row-item>
 
           <a-form-item
-            label="高阈值"
+            label="报警低限"
             :labelCol="BaseTool.Constant.labelCol"
             :wrapperCol="BaseTool.Constant.wrapperCol"
           >
@@ -304,8 +305,8 @@
               :min="0.01"
               :formatter="BaseTool.Amount.formatter"
               :parser="BaseTool.Amount.parser"
-              v-decorator="['warnThird', {rules: [{required: false, message: '高阈值不能为空'}]}]"/>
-            <a-tag style="line-height:30px;margin-left: 10px;" :color="colors.warnThirdColor" @click="handleSelectColor('warnThirdColor')">
+              v-decorator="['warnSecond', {rules: [{required: false, message: '低限不能为空'}]}]"/>
+            <a-tag style="line-height:30px;margin-left: 10px;" :color="colors.warnSecondColor" @click="handleSelectColor('warnSecondColor')">
               选择颜色
             </a-tag>
           </a-form-item>
@@ -313,7 +314,7 @@
         <row-item>
 
           <a-form-item
-            label="最高阈值"
+            label="报警低低限"
             :labelCol="BaseTool.Constant.labelCol"
             :wrapperCol="BaseTool.Constant.wrapperCol"
           >
@@ -322,12 +323,13 @@
               :min="0.01"
               :formatter="BaseTool.Amount.formatter"
               :parser="BaseTool.Amount.parser"
-              v-decorator="['warnFour', {rules: [{required: false, message: '最高阈值不能为空'}]}]"/>
-            <a-tag style="line-height:30px;margin-left: 10px;" :color="colors.warnFourColor" @click="handleSelectColor('warnFourColor')">
+              v-decorator="['warnFirst', {rules: [{required: false, message: '低低限不能为空'}]}]"/>
+            <a-tag style="line-height:30px;margin-left: 10px;" :color="colors.warnFirstColor" @click="handleSelectColor('warnFirstColor')">
               选择颜色
             </a-tag>
           </a-form-item>
         </row-item>
+
         <row-item>
 
           <a-form-item

+ 8 - 8
src/views/remote/opc/modules/Detail.vue

@@ -29,14 +29,14 @@
       <detail-list-item term="实时数值">{{ model.result }}</detail-list-item>
       <detail-list-item term="量程下限">{{ model.low }}</detail-list-item>
       <detail-list-item term="量程上限">{{ model.high }}</detail-list-item>
-      <detail-list-item term="最低阈值">{{ model.warnFirst }}</detail-list-item>
-      <detail-list-item term="最低阈值颜色">{{ model.warnFirstColor }}</detail-list-item>
-      <detail-list-item term="低阈值">{{ model.warnSecond }}</detail-list-item>
-      <detail-list-item term="低阈值颜色">{{ model.warnSecondColor }}</detail-list-item>
-      <detail-list-item term="高阈值">{{ model.warnThird }}</detail-list-item>
-      <detail-list-item term="高阈值颜色">{{ model.warnThirdColor }}</detail-list-item>
-      <detail-list-item term="最高阈值">{{ model.warnFour }}</detail-list-item>
-      <detail-list-item term="最高阈值颜色">{{ model.warnFourColor }}</detail-list-item>
+      <detail-list-item term="低低限">{{ model.warnFirst }}</detail-list-item>
+      <detail-list-item term="低低限颜色">{{ model.warnFirstColor }}</detail-list-item>
+      <detail-list-item term="低">{{ model.warnSecond }}</detail-list-item>
+      <detail-list-item term="低颜色">{{ model.warnSecondColor }}</detail-list-item>
+      <detail-list-item term="高">{{ model.warnThird }}</detail-list-item>
+      <detail-list-item term="高颜色">{{ model.warnThirdColor }}</detail-list-item>
+      <detail-list-item term="高高限">{{ model.warnFour }}</detail-list-item>
+      <detail-list-item term="高高限颜色">{{ model.warnFourColor }}</detail-list-item>
       <detail-list-item term="系数">{{ model.ratio }}</detail-list-item>
       <detail-list-item term="单位">{{ model.unit }}</detail-list-item>
       <detail-list-item term="x轴位置">{{ model.xPosition }}</detail-list-item>