Browse Source

opc历史数据

hfxc226 2 years ago
parent
commit
bc8bd4f3b4

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

@@ -23,7 +23,7 @@
           <template slot="title">
             {{ item.positionNum }}
           </template>
-          <div class="info" @click="handleInfo"> {{ item.positionNum }}</div>
+          <div class="info" @click="handleInfo(item)"> {{ item.positionNum }}</div>
         </a-tooltip>
       </VueDragResize>
     </div>
@@ -151,9 +151,9 @@ export default {
         this.treeData = res.data
       })
     },
-    handleInfo () {
+    handleInfo (remoteOpc) {
       const model = this.$refs.baseChartInfo
-      model.base()
+      model.base(remoteOpc)
     },
     handleOk () {
 

+ 46 - 12
src/views/opc/modules/BaseChartInfo.vue

@@ -4,7 +4,7 @@
     :visible="visible"
     :confirm-loading="confirmLoading"
     :footer="null"
-    :width="800"
+    :width="1200"
     @cancel="handleCancel"
   >
     <div class="chart">
@@ -13,17 +13,28 @@
           <a-form :form="form">
             <a-row type="flex" justify="end">
               <a-col :span="10">
-                <a-form-item label="开始时间" :labelCol="BaseTool.Constant.labelCol" :wrapperCol="BaseTool.Constant.wrapperCol">
+                <a-form-item label="查询时间" :labelCol="BaseTool.Constant.labelCol" :wrapperCol="BaseTool.Constant.wrapperCol">
                   <a-date-picker
                     :format="BaseTool.Date.PICKER_NORM_DATETIME_PATTERN"
-                    v-model="queryParam.searchStartTime" />
+                    v-model="queryParam.createdTimeEnd" />
                 </a-form-item>
               </a-col>
               <a-col :span="10">
-                <a-form-item label="结束时间" :labelCol="BaseTool.Constant.labelCol" :wrapperCol="BaseTool.Constant.wrapperCol">
-                  <a-date-picker
-                    :format="BaseTool.Date.PICKER_NORM_DATETIME_PATTERN"
-                    v-model="queryParam.searchEndTime" />
+                <a-form-item label="时间跨度" :labelCol="BaseTool.Constant.labelCol" :wrapperCol="BaseTool.Constant.wrapperCol">
+                  <a-select default-value="1" v-model="queryParam.searchType" style="width: 120px">
+                    <a-select-option value="1">
+                      10分钟
+                    </a-select-option>
+                    <a-select-option value="2">
+                      20分钟
+                    </a-select-option>
+                    <a-select-option value="3">
+                      30分钟
+                    </a-select-option>
+                    <a-select-option value="4">
+                      60分钟
+                    </a-select-option>
+                  </a-select>
                 </a-form-item>
               </a-col>
               <a-col :span="3">
@@ -44,6 +55,7 @@
 
 <script>
 import { Chart } from '@antv/g2'
+import { queryRemoteOpcLog } from '@/api/remote/opc-log'
 
 export default {
   data () {
@@ -52,8 +64,9 @@ export default {
       visible: false,
       confirmLoading: false,
       queryParam: {},
+      remoteOpc: null,
+      positionNum: null,
       chart1: null,
-      dataList1: [],
       dataList: [
         { time: '2009/7/20 0:00', value: 32, type: 'aa' },
         { time: '2009/7/20 1:00', value: 8, type: 'bb' },
@@ -74,14 +87,35 @@ export default {
 
   },
   methods: {
-    base () {
+    base (remoteOpc) {
       this.visible = true
-      this.$nextTick(() => {
+      this.remoteOpc = remoteOpc
+      /* this.$nextTick(() => {
         this.createChart(this.dataList)
-      })
+      }) */
     },
     getInfo () {
-
+      this.queryParam.createdTimeEnd = this.queryParam.createdTimeEnd ? this.BaseTool.Date.formatter(this.queryParam.createdTimeEnd, this.BaseTool.Date.PICKER_NORM_DATETIME_PATTERN) : null
+      this.queryParam.positionNum = this.remoteOpc.positionNum
+      if (this.queryParam.createdTimeEnd == null) {
+        this.$message.error('请选择查询时间')
+        return
+      }
+      if (this.queryParam.searchType == null) {
+        this.$message.error('请选择时间跨度')
+        return
+      }
+      queryRemoteOpcLog(this.queryParam)
+        .then((res) => {
+          if (res.data == null || res.data.length === 0) {
+            this.$message.error('无数据')
+            return
+          }
+          const data = []
+          res.data.filter(item => data.push({ time: item.createdTime, value: item.result, type: this.remoteOpc.sbName }))
+          this.dataList = data
+          this.createChart(this.dataList)
+        })
     },
     createChart (data) {
       this.chart1 && this.chart1.destroy()

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

@@ -211,8 +211,12 @@ export default {
           }
         },
         {
-          title: '实时数值',
-          dataIndex: 'result'
+          title: '量程下限',
+          dataIndex: 'low'
+        },
+        {
+          title: '量程上限',
+          dataIndex: 'high'
         },
         {
           title: '单位',

+ 32 - 0
src/views/remote/opc/modules/BaseForm.vue

@@ -192,6 +192,36 @@
               v-decorator="['result', {rules: [{required: false, message: '实时数值不能为空'}]}]"/>
           </a-form-item>
         </row-item>-->
+        <row-item>
+
+          <a-form-item
+            label="量程下限"
+            :labelCol="BaseTool.Constant.labelCol"
+            :wrapperCol="BaseTool.Constant.wrapperCol"
+          >
+            <a-input-number
+              style="width: 100%"
+              :min="0"
+              :formatter="BaseTool.Amount.formatter"
+              :parser="BaseTool.Amount.parser"
+              v-decorator="['low', {rules: [{required: false, message: '量程下限不能为空'}]}]"/>
+          </a-form-item>
+        </row-item>
+        <row-item>
+
+          <a-form-item
+            label="量程上限"
+            :labelCol="BaseTool.Constant.labelCol"
+            :wrapperCol="BaseTool.Constant.wrapperCol"
+          >
+            <a-input-number
+              style="width: 100%"
+              :min="0"
+              :formatter="BaseTool.Amount.formatter"
+              :parser="BaseTool.Amount.parser"
+              v-decorator="['high', {rules: [{required: false, message: '量程上限不能为空'}]}]"/>
+          </a-form-item>
+        </row-item>
         <row-item>
 
           <a-form-item
@@ -288,6 +318,8 @@ export default {
           'description',
           'result',
           'ratio',
+          'low',
+          'high',
           'xPosition',
           'yPosition',
           'width',

+ 4 - 0
src/views/remote/opc/modules/Detail.vue

@@ -18,6 +18,8 @@
       <detail-list-item term="opc页面是否已经配置">{{ BaseTool.Object.getField(yesNoMap,model.positionFlag) }}</detail-list-item>
       <detail-list-item term="描述">{{ model.description }}</detail-list-item>
       <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.ratio }}</detail-list-item>
       <detail-list-item term="单位">{{ model.unit }}</detail-list-item>
       <detail-list-item term="x轴位置">{{ model.xPosition }}</detail-list-item>
@@ -65,6 +67,8 @@ export default {
         'yPosition': null,
         'width': null,
         'height': null,
+        'low': null,
+        'high': null,
         'unit': null,
         'remark': null,
         'positionFlag': null,

+ 6 - 2
src/views/remote/opc/modules/RemoteOpcSelectModal.vue

@@ -140,8 +140,12 @@ export default {
           }
         },
         {
-          title: '实时数值',
-          dataIndex: 'result'
+          title: '量程下限',
+          dataIndex: 'low'
+        },
+        {
+          title: '量程上限',
+          dataIndex: 'high'
         },
         {
           title: '单位',