Browse Source

fix: 属性聚合

lvkun 2 years ago
parent
commit
b217b9e570
9 changed files with 16244 additions and 336 deletions
  1. 6 3
      config/proxy.ts
  2. 15852 1
      package-lock.json
  3. 1 1
      src/controller/iot/device.ts
  4. 4 4
      src/hooks/effect.ts
  5. 58 11
      src/pages/Iot/device/analysis.vue
  6. 2 0
      src/router/index.ts
  7. 1 1
      src/service/request.ts
  8. 1 1
      vue.config.js
  9. 319 314
      yarn.lock

+ 6 - 3
config/proxy.ts

@@ -8,21 +8,24 @@ module.exports = {
     '/user': {
       // target: 'http://120.223.238.91:8888',
       // target: 'http://124.222.113.37:9999',
-      target: 'http://124.222.113.37:9999',
+      // target: 'http://124.222.113.37:9999',
+      target: 'http://101.126.68.200:18081',
       changeOrigin: true,
       pathRewrite: { '^/user': '' }
     },
     '/cvss': {
       // target: 'http://120.223.238.91:6666',
       // target: 'http://172.28.0.3:18082',
-      target: 'http://124.222.113.37:8080',
+      // target: 'http://124.222.113.37:8080',
+      target: 'http://101.126.68.200:18081',
       changeOrigin: true,
       pathRewrite: { '^/cvss': '' }
     },
     '/iot': {
       // target: 'http://120.223.238.91:8888',
       // target: 'http://120.223.238.91:8888',
-      target: 'http://124.222.113.37:8888',
+      // target: 'http://124.222.113.37:8888',
+      target: 'http://101.126.68.200:18081',
       changeOrigin: true,
       pathRewrite: { '^/iot': '' }
     },

File diff suppressed because it is too large
+ 15852 - 1
package-lock.json


+ 1 - 1
src/controller/iot/device.ts

@@ -307,7 +307,7 @@ export class DeviceContriller {
     }
   }
 
-  static async getAttr (params: {deviceId: string, start: number, end: number, attributeKey: string}) {
+  static async getAttr (params: any) {
     return await getDeviceAttributes(params)
   }
 

+ 4 - 4
src/hooks/effect.ts

@@ -53,13 +53,13 @@ export const useSchedulerOnce = (callback: () => void, delay: number) => {
 
 export const usePort = (title: string) => {
   if (title === '物联网') {
-    setBaseUrl('http://localhost:10800/iot')
+    setBaseUrl('/iot')
   } else if (title === '视联网') {
-    setBaseUrl('http://localhost:10800/cvss')
+    setBaseUrl('/cvss')
   } else if (title === '用户群组') {
-    setBaseUrl('http://localhost:10800/user')
+    setBaseUrl('/user')
   } else if (title === '数据中台') {
-    setBaseUrl('http://localhost:10800/datacenter')
+    setBaseUrl('/datacenter')
   }
 }
 

+ 58 - 11
src/pages/Iot/device/analysis.vue

@@ -1,8 +1,8 @@
 <template>
-  <statistics-template
+  <!-- <statistics-template
     title="上下线统计"
     :list="[{value: 20, color: 'green', label: '上线次数'}, {value: 20, color: 'red', label: '下线次数'}]"
-  />
+  /> -->
   <a-card
     style="margin-top: 20px;"
     title="设备分析"
@@ -36,7 +36,7 @@
               </a-select>
             </a-spin>
             <a-select
-                v-if="activeTabKey === 'attr'"
+                v-if="activeTabKey === 'attr' || activeTabKey ===  'poly'"
                 v-model:value="state.attributeKey"
                 placeholder="请选择属性"
                 style="width: 170px"
@@ -49,6 +49,21 @@
                   :value="item.key"
                 >{{item.keyLabel}}</a-select-option>
               </a-select>
+            <!-- 聚合函数参数 -->
+            <a-select v-if="activeTabKey ===  'poly'" placeholder="聚合函数只对数字类型有效"  style="width: 220px" v-model:value="state.aggregationFunc" >
+              <a-select-option v-for="item in aggregationFunc" :key="item.key">
+                {{item.title}}
+              </a-select-option>
+            </a-select>
+            <a-input v-if="activeTabKey ===  'poly'" v-model:value="state.period">
+              <template #addonAfter>
+                <a-select v-model:value="state.periodUnit" style="width: 80px">
+                  <a-select-option value="d">天</a-select-option>
+                  <a-select-option value="h">小时</a-select-option>
+                  <a-select-option value="m">分钟</a-select-option>
+                </a-select>
+              </template>
+            </a-input>
             <a-range-picker :show-time="{ format: 'HH:mm' }" v-model:value="times" @change="changeRangePicker"  />
           </a-space>
         </a-col>
@@ -96,11 +111,40 @@ const tabListNoTitle = [{
 {
   key: 'attr',
   tab: '属性分析'
+},
+{
+  key: 'poly',
+  tab: '属性聚合分析'
 }]
 
+// MIN,MAX,SUM,AVG,COUNT
+// 聚合函数
+const aggregationFunc = [
+  {
+    key: 'MIN',
+    title: '最小值'
+  },
+  {
+    key: 'MAX',
+    title: '最大值'
+  },
+  {
+    key: 'SUM',
+    title: '求和'
+  },
+  {
+    key: 'AVG',
+    title: '平均值'
+  },
+  {
+    key: 'COUNT',
+    title: '统计值'
+  }
+]
+
 const route = useRoute()
 
-const activeTabKey = ref<'session' | 'attr'>('session')
+const activeTabKey = ref<'session' | 'attr' | 'poly'>('session')
 
 const emptyCondition = computed(() => activeTabKey.value === 'session' ? state.dataSource.length === 0 : state.attrSource.length === 0)
 
@@ -129,7 +173,10 @@ const state = reactive<{
   spinning: false,
   onlineNum: 0,
   offlineNum: 0,
-  attributeKey: null
+  attributeKey: null,
+  aggregationFunc: null,
+  period: '',
+  periodUnit: 'd'
 })
 
 const times = ref([dayjs().subtract(30, 'minute'), dayjs()])
@@ -143,7 +190,7 @@ watch(
   () => activeTabKey.value,
   () => {
     state.deviceId = null
-    state.searchDeviceLabel = null
+    // state.searchDeviceLabel = null
     state.attributeKey = null
   }
 )
@@ -187,7 +234,6 @@ watch(
       if (activeTabKey.value === 'session') {
         const chartDom = document.getElementById('device-session')
         const chartDomScatter = document.getElementById('device-session-scatter')
-        console.log('chartDom:', chartDom)
 
         const myChart = echarts.init(chartDom!)
         const chartDomScatterChart = echarts.init(chartDomScatter!)
@@ -262,12 +308,13 @@ const getDeviceSession = async () => {
 const getDeviceAttr = async () => {
   if (!state.deviceId) return
   state.loading = true
-  // .format('YYYY/MM/DD HH:mm:ss')
   const { data } = await DeviceContriller.getAttr({
     deviceId: state.deviceId,
-    start: 1,
-    end: new Date().getTime(),
-    attributeKey: state.attributeKey
+    start: dayjs(times.value[0]).unix() * 1000,
+    end: dayjs(times.value[1]).unix() * 1000,
+    attributeKey: state.attributeKey,
+    aggregationFunc: state.aggregationFunc,
+    period: state.period + state.periodUnit
   })
   state.attrSource = data
 }

+ 2 - 0
src/router/index.ts

@@ -484,6 +484,8 @@ const microRouter = useIsMicro()
     ]
   : routes
 
+console.log('window.__POWERED_BY_QIANKUN__:', window.__POWERED_BY_QIANKUN__)
+
 const baseUri = window.__POWERED_BY_QIANKUN__ ? '/cloudlink/' : process.env.NODE_ENV === 'development' ? './' : '/child/cloudlink/'
 
 const router = createRouter({

+ 1 - 1
src/service/request.ts

@@ -5,7 +5,7 @@ import { useModule } from '@/hooks'
 import { useUserStore } from '@/store'
 
 export const instance = axios.create({
-  baseURL: '',
+  baseURL: './',
   timeout: 100000
 })
 

+ 1 - 1
vue.config.js

@@ -7,7 +7,7 @@ const packageName = require('./package.json').name
 
 module.exports = defineConfig({
   // publicPath: process.env.NODE_ENV === 'development' ? '' : '',
-  publicPath: process.env.NODE_ENV === 'development' ? './' : '/child/cloudlink/',
+  publicPath: process.env.NODE_ENV === 'development' ? '/' : '/child/cloudlink/',
   transpileDependencies: true,
   devServer: {
     proxy: proxy.dev,

File diff suppressed because it is too large
+ 319 - 314
yarn.lock


Some files were not shown because too many files changed in this diff