Compare commits

...

4 Commits

  1. 3
      web/src/api/gas/tdengine/index.ts
  2. 5
      web/src/utils/formatter.ts
  3. 234
      web/src/views/HandDevice/Home/components/HistoricalCurve.vue
  4. 1
      web/src/views/HandDevice/Home/components/services/popup.service.ts
  5. 4
      web/src/views/HandDevice/Home/index.vue
  6. 13
      web/src/views/gas/tdengine/index.vue

3
web/src/api/gas/tdengine/index.ts

@ -17,6 +17,9 @@ export interface tdStruct {
latitude?: number // 纬度 latitude?: number // 纬度
ts: number // 更新时间 ts: number // 更新时间
name?: string // 持有人姓名 name?: string // 持有人姓名
mem?: number|null,
sig?: string|null,
boot?: number|null,
} }
/** 原始数据 */ /** 原始数据 */

5
web/src/utils/formatter.ts

@ -5,3 +5,8 @@ import { floatToFixed2 } from '@/utils'
export const fenToYuanFormat = (_, __, cellValue: any, ___) => { export const fenToYuanFormat = (_, __, cellValue: any, ___) => {
return `${floatToFixed2(cellValue)}` return `${floatToFixed2(cellValue)}`
} }
// 格式化内存【字节转MB】
export const formatByte = (_, __, cellValue: any, ___) => {
return `${floatToFixed2(cellValue / 1024 )}`
}

234
web/src/views/HandDevice/Home/components/HistoricalCurve.vue

@ -5,7 +5,7 @@
:before-close="handleClose" :before-close="handleClose"
:destroy-on-close="true" :destroy-on-close="true"
resizable resizable
size="550px"
size="480px"
> >
<template #header> <template #header>
<h4 <h4
@ -31,8 +31,11 @@
</div> </div>
</div> </div>
<div v-if="drawer && !loading"> <div v-if="drawer && !loading">
<Echart :options="gasLineOptions" :height="400" />
<Echart :options="gasLineOptions" :height="325" />
</div> </div>
<!-- <div v-if="drawer && !loading">
<Echart :options="gasSigLineOptions" :height="325" />
</div> -->
</div> </div>
<!-- <div> <!-- <div>
<div class="flex items-center justify-between"> <div class="flex items-center justify-between">
@ -138,6 +141,12 @@ const handleDateChange = () => {
const gas = computed(() => { const gas = computed(() => {
var value: (number | null)[] = [] var value: (number | null)[] = []
var battery: (number | null)[] = [] var battery: (number | null)[] = []
var mem: (number | null)[] = []
var rssi: (number | null)[] = []
var rsrp: (number | null)[] = []
var rsrq: (number | null)[] = []
var sinr: (number | null)[] = []
var time: string[] = [] var time: string[] = []
historicalData.value historicalData.value
// .filter((item) => typeof item.value === 'number') // .filter((item) => typeof item.value === 'number')
@ -152,6 +161,32 @@ const gas = computed(() => {
} else { } else {
value.push(null) value.push(null)
} }
if (item.mem) {
mem.push(item.mem / 1024)
} else {
mem.push(null)
}
if (item.sig) {
try {
let sig = JSON.parse(item.sig)
if (sig.length == 5) {
rssi.push(sig[0])
rsrp.push(sig[1])
rsrq.push(sig[2])
sinr.push(sig[4])
}
} catch {
rssi.push(null)
rsrp.push(null)
rsrq.push(null)
sinr.push(null)
}
} else {
rssi.push(null)
rsrp.push(null)
rsrq.push(null)
sinr.push(null)
}
time.push(item.timeStr) time.push(item.timeStr)
}) })
@ -159,6 +194,11 @@ const gas = computed(() => {
return { return {
value, value,
battery, battery,
mem,
rssi,
rsrp,
rsrq,
sinr,
time time
} }
}) })
@ -219,6 +259,64 @@ const gasLineOptions = computed<EChartsOption>(() => {
data: gas.value.battery, data: gas.value.battery,
animationDuration: 2800, animationDuration: 2800,
animationEasing: 'cubicInOut' animationEasing: 'cubicInOut'
},
{
name: '内存占用',
smooth: true,
type: 'line',
yAxisIndex: 1,
symbol: 'none',
data: gas.value.mem,
animationDuration: 2800,
animationEasing: 'cubicInOut',
tooltip: {
valueFormatter: function (value) {
if (value === null || value === undefined || isNaN(value)) {
return '-'
}
return Number(value).toFixed(3) + 'KB' //
}
}
},
{
name: 'RSSI',
smooth: true,
type: 'line',
yAxisIndex: 0,
symbol: 'none',
data: gas.value.rssi,
animationDuration: 2800,
animationEasing: 'cubicInOut'
},
{
name: 'RSRP',
smooth: true,
type: 'line',
yAxisIndex: 0,
symbol: 'none',
data: gas.value.rsrp,
animationDuration: 2800,
animationEasing: 'cubicInOut'
},
{
name: 'RSRQ',
smooth: true,
type: 'line',
yAxisIndex: 0,
symbol: 'none',
data: gas.value.rsrq,
animationDuration: 2800,
animationEasing: 'cubicInOut'
},
{
name: 'SINR',
smooth: true,
type: 'line',
yAxisIndex: 0,
symbol: 'none',
data: gas.value.sinr,
animationDuration: 2800,
animationEasing: 'cubicInOut'
} }
] ]
} }
@ -254,6 +352,138 @@ const gasLineOptions = computed<EChartsOption>(() => {
return option return option
}) })
// const gasSigLineOptions = computed<EChartsOption>(() => {
// const option: EChartsOption = {
// title: {
// text: '',
// left: 'center'
// },
// xAxis: {
// data: gas.value.time,
// boundaryGap: false,
// axisTick: {
// show: false
// }
// },
// tooltip: {
// trigger: 'axis',
// axisPointer: {
// type: 'cross'
// },
// padding: [5, 10]
// },
// yAxis: [
// {
// axisTick: {
// show: false
// }
// },
// {
// axisTick: {
// show: false
// }
// }
// ],
// legend: {
// // data: [],
// top: 50
// },
// series: [
// {
// name: '',
// smooth: true,
// type: 'line',
// yAxisIndex: 1,
// symbol: 'none',
// data: gas.value.battery,
// animationDuration: 2800,
// animationEasing: 'cubicInOut'
// },
// {
// name: '',
// smooth: true,
// type: 'line',
// yAxisIndex: 1,
// symbol: 'none',
// data: gas.value.mem,
// animationDuration: 2800,
// animationEasing: 'cubicInOut'
// },
// {
// name: 'RSSI',
// smooth: true,
// type: 'line',
// yAxisIndex: 0,
// symbol: 'none',
// data: gas.value.rssi,
// animationDuration: 2800,
// animationEasing: 'cubicInOut'
// },
// {
// name: 'RSRP',
// smooth: true,
// type: 'line',
// yAxisIndex: 0,
// symbol: 'none',
// data: gas.value.rsrp,
// animationDuration: 2800,
// animationEasing: 'cubicInOut'
// },
// {
// name: 'RSRQ',
// smooth: true,
// type: 'line',
// yAxisIndex: 0,
// symbol: 'none',
// data: gas.value.rsrq,
// animationDuration: 2800,
// animationEasing: 'cubicInOut'
// },
// {
// name: 'SINR',
// smooth: true,
// type: 'line',
// yAxisIndex: 0,
// symbol: 'none',
// data: gas.value.sinr,
// animationDuration: 2800,
// animationEasing: 'cubicInOut'
// }
// ]
// }
// const grid = {
// left: 20,
// right: 20,
// bottom: 10,
// top: 80,
// containLabel: true
// }
// if (gas.value.time.length >= 100) {
// grid.bottom = 50
// //
// option.dataZoom = [
// {
// type: 'slider',
// xAxisIndex: [0],
// bottom: 10,
// start: 0,
// end: 100
// },
// {
// type: 'inside',
// xAxisIndex: [0],
// start: 0,
// end: 100
// }
// ]
// } else {
// }
// option.grid = grid
// return option
// })
defineExpose({ defineExpose({
openDrawer openDrawer

1
web/src/views/HandDevice/Home/components/services/popup.service.ts

@ -51,6 +51,7 @@ export class PopupService {
<div>${markerData.gasChemical}</div> <div>${markerData.gasChemical}</div>
<div>${markerData.value} ${markerData.unit ? markerData.unit : ''}</div> <div>${markerData.value} ${markerData.unit ? markerData.unit : ''}</div>
<div>${markerData.sig||''}</div>
<div>${markerData.timeStr ? markerData.timeStr : '-'} </div> <div>${markerData.timeStr ? markerData.timeStr : '-'} </div>
<div> <div>
${markerData.coordinates[0].toFixed(6)}, ${markerData.coordinates[1].toFixed(6)}/${markerData.gpsType===0?"GPS":"基站"} ${markerData.coordinates[0].toFixed(6)}, ${markerData.coordinates[1].toFixed(6)}/${markerData.gpsType===0?"GPS":"基站"}

4
web/src/views/HandDevice/Home/index.vue

@ -55,6 +55,9 @@
<div><span>电量</span>{{ item.battery }}</div> <div><span>电量</span>{{ item.battery }}</div>
<div><span>数值</span>{{ item.value }} {{ item.unit }}</div> <div><span>数值</span>{{ item.value }} {{ item.unit }}</div>
<div><span>信号</span>{{ item.sig||'' }}</div>
<div><span>时间</span>{{ item.timeStr }}</div> <div><span>时间</span>{{ item.timeStr }}</div>
<div style="margin-top: 10px"> <div style="margin-top: 10px">
@ -263,6 +266,7 @@ const getMarkers = async () => {
}) // }) //
return { return {
...i, ...i,
sig: i.sig?i.sig.replace(/,255/, ''):'',
coordinates: [i.longitude || 0, i.latitude || 0] as [number, number], coordinates: [i.longitude || 0, i.latitude || 0] as [number, number],
timeStr: i.time ? dayjs(i.time).format('YYYY-MM-DD HH:mm:ss') : '', timeStr: i.time ? dayjs(i.time).format('YYYY-MM-DD HH:mm:ss') : '',

13
web/src/views/gas/tdengine/index.vue

@ -118,8 +118,8 @@
<!-- 列表 --> <!-- 列表 -->
<ContentWrap> <ContentWrap>
<el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
<el-table-column type="selection" width="55" />
<el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="false">
<!-- <el-table-column type="selection" width="55" /> -->
<el-table-column label="持有人" align="center" prop="name"> <el-table-column label="持有人" align="center" prop="name">
<!-- <template #default="scope"> <!-- <template #default="scope">
{{ {{
@ -128,11 +128,14 @@
}} }}
</template> --> </template> -->
</el-table-column> </el-table-column>
<el-table-column label="设备编号" align="center" prop="sn" />
<el-table-column label="设备编号" align="center" prop="sn" width="150"/>
<el-table-column label="经度" align="center" prop="longitude" /> <el-table-column label="经度" align="center" prop="longitude" />
<el-table-column label="纬度" align="center" prop="latitude" /> <el-table-column label="纬度" align="center" prop="latitude" />
<el-table-column label="气体数值" align="center" prop="value" /> <el-table-column label="气体数值" align="center" prop="value" />
<el-table-column label="电量" align="center" prop="battery" /> <el-table-column label="电量" align="center" prop="battery" />
<el-table-column label="信号" align="center" prop="sig" width="160"/>
<el-table-column label="内存(KB)" align="center" prop="mem" :formatter="formatByte" width="90" />
<el-table-column label="开机(秒)" align="center" prop="boot" width="90" />
<!-- <el-table-column label="气体类型" align="center" prop="gasType"></el-table-column> --> <!-- <el-table-column label="气体类型" align="center" prop="gasType"></el-table-column> -->
<!-- <el-table-column label="首报值" align="center" prop="vAlarmFirst" /> <!-- <el-table-column label="首报值" align="center" prop="vAlarmFirst" />
@ -157,7 +160,7 @@
align="center" align="center"
prop="ts" prop="ts"
:formatter="dateFormatter" :formatter="dateFormatter"
width="180px"
width="160px"
/> />
</el-table> </el-table>
<!-- 分页 --> <!-- 分页 -->
@ -181,6 +184,8 @@
<script setup lang="ts"> <script setup lang="ts">
import { dateFormatter } from '@/utils/formatTime' import { dateFormatter } from '@/utils/formatTime'
import { formatByte } from '@/utils/formatter'
import { tdengineApi, tdStruct, tdQuery } from '@/api/gas/tdengine/index' import { tdengineApi, tdStruct, tdQuery } from '@/api/gas/tdengine/index'
// import HandAlarmForm from './HandAlarmForm.vue' // import HandAlarmForm from './HandAlarmForm.vue'

Loading…
Cancel
Save