Browse Source

fix: bug修复

main
betaqi 2 months ago
parent
commit
ac90170f78
  1. 1
      global.types/components.d.ts
  2. 2
      src/api/module/transfer/index.ts
  3. 4
      src/stores/transferData.ts
  4. 2
      src/utils/zmqJsonWorker.ts
  5. 16
      src/views/firmwareUpload/index.vue
  6. 2
      src/views/layout/index.vue
  7. 2
      src/views/stationData/components/PointGroupTree.vue
  8. 33
      src/views/stationData/components/deviceDrawer.vue
  9. 12
      src/views/stationData/components/newDataChart.vue
  10. 2
      src/views/stationData/components/offTransferDlg.vue
  11. 2
      src/views/stationData/components/onLineTransferDlg.vue
  12. 2
      src/views/stationData/index.vue
  13. 52
      src/views/stationData/transferData.vue
  14. 2
      src/views/stationData/type.ts

1
global.types/components.d.ts vendored

@ -24,7 +24,6 @@ declare module 'vue' { @@ -24,7 +24,6 @@ declare module 'vue' {
ElDialog: typeof import('element-plus/es')['ElDialog']
ElDivider: typeof import('element-plus/es')['ElDivider']
ElDrawer: typeof import('element-plus/es')['ElDrawer']
ElEmpty: typeof import('element-plus/es')['ElEmpty']
ElHeader: typeof import('element-plus/es')['ElHeader']
ElInput: typeof import('element-plus/es')['ElInput']
ElMenu: typeof import('element-plus/es')['ElMenu']

2
src/api/module/transfer/index.ts

@ -22,7 +22,7 @@ export const getDeviceDetails = (params: IGetDeviceDataParams) => @@ -22,7 +22,7 @@ export const getDeviceDetails = (params: IGetDeviceDataParams) =>
export interface ISite {
id: string
name: string
export_time: string
create_time: string
last_modify_time: string
export_root_path: string
}

4
src/stores/transferData.ts

@ -35,7 +35,6 @@ export const useTransferDataStore = defineStore('transfer', () => { @@ -35,7 +35,6 @@ export const useTransferDataStore = defineStore('transfer', () => {
function getSubDevicesCb(msg: SubMsgData) {
const { feedback } = msg
const sn = feedback[1]
const hasDevice = devicesMap.get(sn)
if (hasDevice) {
hasDevice.lastUpdated = Date.now()
@ -45,7 +44,8 @@ export const useTransferDataStore = defineStore('transfer', () => { @@ -45,7 +44,8 @@ export const useTransferDataStore = defineStore('transfer', () => {
clientIp: feedback[0],
sn: sn,
site_id: feedback[2],
footprint: feedback[3] ?? '--',
versions: feedback[3] ?? '--',
footprint: feedback[4] ?? '--',
lastUpdated: Date.now(),
status: '在线', // 初始状态为在线
isChecked: false,

2
src/utils/zmqJsonWorker.ts

@ -5,7 +5,7 @@ import { WorkerCMD, ZmqCMD, type PublishMsg, type PubMsgData, } from './zmq' @@ -5,7 +5,7 @@ import { WorkerCMD, ZmqCMD, type PublishMsg, type PubMsgData, } from './zmq'
const HEARTBEAT_TOPIC = 'HEARTBEAT'
const HEARTBEAT_INTERVAL = 3000
const STATUS_CHECK_INTERVAL = 1000
let messageTimeout = 10000
let messageTimeout = 20000
let heartClient: ZmqClient | null, subClient: ZmqClient | null, pubClient: ZmqClient | null
let subHost = '', pubHost = ''

16
src/views/firmwareUpload/index.vue

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
<template>
<div class="flex justify-center items-center size-full">
<EdfsWrap title="固件上传" style="width: 50%; height: 50%">
<EdfsWrap :title="title" style="width: 50%; height: 50%">
<el-upload v-model:fileList="fileList" v-loading="loading" element-loading-text="上传中..." drag action=""
accept=".tar.gz" :limit="1" :on-exceed="handleExceed" :auto-upload="false" ref="uploadRef"
class="h-[calc(100%-30px)] w-full">
@ -19,7 +19,7 @@ @@ -19,7 +19,7 @@
</template>
<script setup lang="ts">
import { uploadFirmwareFile } from '@/api/module/firmware'
import { getFirmwarePath, uploadFirmwareFile } from '@/api/module/firmware'
import { useMessage } from '@/composables/useMessage'
import type {
UploadInstance,
@ -159,6 +159,18 @@ function onClone() { @@ -159,6 +159,18 @@ function onClone() {
}
clearData()
}
const firmwarePath = ref<string>()
const title = computed(() => {
return `固件上传(${firmwarePath.value ? `当前固件:${firmwarePath.value}` : '当前固件: 未上传'}`
})
onMounted(async () => {
const res = await getFirmwarePath()
if (res.code === 200 || res.code === 0) {
firmwarePath.value = res.data.path.split('/').at(-1)
}
})
</script>
<style lang="scss" scoped>

2
src/views/layout/index.vue

@ -76,7 +76,7 @@ const { theme } = useTheme() @@ -76,7 +76,7 @@ const { theme } = useTheme()
const menuList = computed<any[]>(() => {
let data = defaultRouter[0].children
if (env.VITE_APP_ENV !== 'local') {
data = data.filter(item => item.name === 'firmware-upload')
data = data.filter(item => item.name != 'firmware-upload')
}
return data
}

2
src/views/stationData/components/PointGroupTree.vue

@ -6,7 +6,7 @@ @@ -6,7 +6,7 @@
highlight-current @node-click="handleNodeClick" :default-expanded-keys="checkDefault">
<template #default="scope">
<div class="item">
<span class="label">{{ scope.data.name }}</span>
<span class="label">{{ scope.data?.cnName ?? '--' }}</span>
</div>
</template>
</el-tree>

33
src/views/stationData/components/deviceDrawer.vue

@ -1,5 +1,6 @@ @@ -1,5 +1,6 @@
<template>
<div class="fault-rule-drawer">
<el-drawer v-model="isShowDrawer" :title="title" direction="rtl" size="90%" modal-class="model-dev-opn"
:before-close="handleBeforeClose" @opened="onDrawerOpened">
<main class="wh-full flex">
@ -9,10 +10,9 @@ @@ -9,10 +10,9 @@
:isTransfer="props.isTransfer" :siteInfo="props.siteInfo" ref="pointGroupTreeRef" />
</EdfsWrap>
<div class="flex-1 p-4 h-full overflow-hidden">
<el-button class="mb-4" type="primary"
@click="loadChardData">查询数据</el-button>
<el-button class="mb-4" type="primary" @click="loadChardData">查询数据</el-button>
<NewDataChart v-if="isShowChart && !loading" :chart-datas="chartDatas" :legends="legends"
:axis-data="Array.from(axisData)" ref="chartRef" />
:axis-data="Array.from(axisData)" ref="chartRef" />
</div>
</main>
</el-drawer>
@ -70,7 +70,11 @@ async function open(device: IOfflineDevice | IOnlineDevice) { @@ -70,7 +70,11 @@ async function open(device: IOfflineDevice | IOnlineDevice) {
curDevice.value = device
await loadPointGroup()
.then(async () => {
props.isTransfer ? await loadDeviceDetails() : zmqImport(device as IOfflineDevice)
if (env.VITE_APP_ENV === 'local') {
props.isTransfer ? await loadDeviceDetails() : zmqImport(device as IOfflineDevice)
} else {
await loadDeviceDetails()
}
})
.catch(() => {
message.error('获取点位组数据失败')
@ -104,6 +108,7 @@ async function loadPoints() { @@ -104,6 +108,7 @@ async function loadPoints() {
pointList.value = data.map((i: any) => ({
label: i.cnName,
addr: i.addr,
unit: i.unit || '',
}))
pointList.value.push({
label: '时间',
@ -138,16 +143,16 @@ async function loadDeviceDetails() { @@ -138,16 +143,16 @@ async function loadDeviceDetails() {
}
const chartDatas = reactive(new Map<string, any[]>())
const axisData = new Set<string>()
const legends = ref<{ addr: string; label: string }[]>([])
const legends = ref<{ addr: string; label: string, unit: string }[]>([])
const loading = ref(false)
async function loadChardData(){
if(!columsParams.value.filter(i => i !== 'ts').length){
async function loadChardData() {
if (!columsParams.value.filter(i => i !== 'ts').length) {
message.error('请选择点位')
return
}
const params: IGetDeviceDataParams = {
columns: columsParams.value,
isLocal: props.isTransfer ? false : true,
@ -168,12 +173,13 @@ async function loadChardData(){ @@ -168,12 +173,13 @@ async function loadChardData(){
chartDatas.clear()
axisData.clear()
for (const addr of columsParams.value.filter(i => i !== 'ts')) {
const label = pointList.value.find(i => i.addr === addr)?.label || addr
const label = pointList.value.find(i => i.addr === addr)?.label || addr
const find = legends.value.find(i => i.addr === addr)
const unit = pointList.value.find(i => i.addr === addr)?.unit || ''
if (!find) {
legends.value.push({ addr, label })
}
}
legends.value.push({ addr, label, unit })
}
}
pointData.value.forEach((data: any[]) => {
const [ts, val, addr] = data
if (checkPointList.value.some(i => i.addr === addr)) {
@ -195,11 +201,11 @@ async function loadChardData(){ @@ -195,11 +201,11 @@ async function loadChardData(){
} else {
message.error('获取设备数据失败')
}
console.log(chartDatas, axisData, legends)
loading.value = false
}
function zmqImport(device: IOfflineDevice) {
console.log('object')
if (!device.sn || !props.siteInfo!.name) {
message.error('未找到站点或设备')
return
@ -234,6 +240,7 @@ function zmqTimeoutCb(msg: TimeoutMsg) { @@ -234,6 +240,7 @@ function zmqTimeoutCb(msg: TimeoutMsg) {
if (device && action === 'import') {
message.error(`设备${device.sn},查询信息超时,请稍后重试`)
pubIdWithDevice.delete(msg.timeoutId)
fullscreenLoading.value?.close()
}
}

12
src/views/stationData/components/newDataChart.vue

@ -32,6 +32,7 @@ const ZOOM_BOTTOM = 10 @@ -32,6 +32,7 @@ const ZOOM_BOTTOM = 10
type Legend = {
addr: string
label: string
unit?: string
}
const autoresize = {
@ -78,6 +79,7 @@ const chartOption = computed<EChartsOption>(() => { @@ -78,6 +79,7 @@ const chartOption = computed<EChartsOption>(() => {
const lineData: SeriesOption = {
name: legend.label,
type: 'line',
id: legend.addr,
// symbol: "none",
connectNulls: true,
data: entry,
@ -101,6 +103,16 @@ const chartOption = computed<EChartsOption>(() => { @@ -101,6 +103,16 @@ const chartOption = computed<EChartsOption>(() => {
trigger: 'axis',
confine: true,
appendToBody: true,
formatter: function (params: any) {
var relVal = params[0].name
for (var i = 0, l = params.length; i < l; i++) {
relVal += `<div style="display: flex; justify-content: space-between; gap: 30px;">
<div>${params[i].marker}${params[i].seriesName}:</div> <div">${params[i].value[1]}${props.legends.find(item => item.addr === params[i].seriesId)?.unit || ''}</div>
</div>`
}
return relVal
}
},
legend: {
type: 'scroll',

2
src/views/stationData/components/offTransferDlg.vue

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
<template>
<EdfsDialog :title="'数据迁移'" :is-show="visible" width="40%" @on-close="close" @on-save="onSave">
<EdfsDialog :title="'数据迁移'" :is-show="visible" width="50%" @on-close="close" @on-save="onSave">
<div class="flex-col gap-10 w-80% m-x-30px">
<el-row>
<div class="label">

2
src/views/stationData/components/onLineTransferDlg.vue

@ -2,7 +2,7 @@ @@ -2,7 +2,7 @@
<EdfsDialog
:title="isBatchTransfer ? '批量迁移' : '数据迁移'"
:is-show="visible"
width="40%"
width="50%"
@on-close="close"
@on-save="onSave"
>

2
src/views/stationData/index.vue

@ -61,7 +61,7 @@ @@ -61,7 +61,7 @@
<div class="item">
<div class="label">迁移时间:</div>
<div class="value">
{{ dayjs(item.export_time).format('YYYY-MM-DD HH:mm:ss') }}
{{ item.create_time }}
</div>
</div>
</div>

52
src/views/stationData/transferData.vue

@ -1,7 +1,7 @@ @@ -1,7 +1,7 @@
<template>
<div class="flex-col gap-16 wh-full">
<el-button type="primary" @click="onBack" class="w-150px">
<i class="i-line-md:arrow-left"></i>返回站点数据
<i class="i-line-md:arrow-left"></i>返回站点数据 {{ isonLineTransfer }}
</el-button>
<EdfsWrap title="设备列表" class="flex-1" useScrollBar>
<template #title-right>
@ -87,13 +87,19 @@ @@ -87,13 +87,19 @@
</template>
<div class="absolute l-0 t-0 w-full h-full z-10 bg-#FFF-90"
v-if="['updating', 'pending', 'rejected', 'timeout'].includes(item.upFirmware)">
<div class="i-material-symbols-light:close absolute-rt text-base text-gray-950 cursor-pointer"
v-if="['timeout', 'rejected'].includes(item.upFirmware)" @click="upFirmwareSucceed(item.sn)"></div>
<div class="i-material-symbols-light:close absolute-rt text-base text-gray-950 cursor-pointer" v-if="
['timeout', 'rejected', 'sc'].includes(item.upFirmware) ||
(item.upFirmwareStatus?.step === 4 && item.upFirmwareStatus?.progress === 100)"
@click="upFirmwareSucceed(item.sn)">
</div>
<template v-if="item.upFirmware === 'updating'">
<div class="device-item-body">
<div class="info-item">
<div>当前步骤:</div>
<div>{{ item.upFirmwareStatus?.step ?? '--' }}</div>
<div>{{item.upFirmwareStatus?.step === 4 && item.upFirmwareStatus?.progress === 100 ? '安装完成' :
upgradeProgressStatusMap.find(r => r.status === item.upFirmwareStatus?.step)?.text ??
'--'}}
</div>
</div>
<div class="info-item">
<div>当前进度:</div>
@ -180,7 +186,9 @@ @@ -180,7 +186,9 @@
<div class="text-16px font-500"> {{ !!onOffDeviceTransferStatus ? onOffDeviceTransferStatus ===
'progress'
? '数据导入中' : '数据导入完成' : '数据导入中' }}</div>
? '数据导入中' : `数据导入完成 (失败:${offLineTransferRes().error}个 超时:${offLineTransferRes().timeout}个) ` :
'数据导入中'
}}</div>
</el-progress>
</div>
@ -188,8 +196,8 @@ @@ -188,8 +196,8 @@
<div class="h-490 border-radius-8px bg-[#F9FAFB] p-10 flex-col">
<div class="text-16px font-500">迁移日志</div>
<el-scrollbar class="flex-1">
<div v-for="i in siteTransferLogList" :class="i.status === 'error' ? 'text-red-500' : ''"
class="text-gray-600">
<div v-for="i in siteTransferLogList"
:class="['error', 'timeout'].includes(i.status) ? 'text-red-500' : ''" class="text-gray-600">
{{ i.device.sn }}{{ i.msg }}
</div>
</el-scrollbar>
@ -390,13 +398,14 @@ function zmqTimeoutCb(msg: TimeoutMsg) { @@ -390,13 +398,14 @@ function zmqTimeoutCb(msg: TimeoutMsg) {
message.error(`迁移超时,请重新稍后尝试`)
exportPubDeviceMap.delete(msg.timeoutId)
closeTransferMask()
transferStatus.value === 'failed'
}
}
const onlineDeviceMap: Record<
keyof Omit<
IOnlineDevice,
'lastUpdated' | 'sn' | 'isChecked' | 'upFirmware' | 'upFirmwareStatus'
'lastUpdated' | 'sn' | 'isChecked' | 'upFirmware' | 'upFirmwareStatus' | 'versions'
>,
string
> = {
@ -594,7 +603,7 @@ function firmwareUpTimeoutCb(msg: TimeoutMsg) { @@ -594,7 +603,7 @@ function firmwareUpTimeoutCb(msg: TimeoutMsg) {
function zmqUpgradeCb(msg: PubMsgData) {
if (!isonLineTransfer.value) return
const status = msg.result
const status = msg.code
const deviceSn = msg.feedback[0]
const progressStatus = msg.feedback[1] as number
const progress = msg.feedback[2] || undefined
@ -602,16 +611,16 @@ function zmqUpgradeCb(msg: PubMsgData) { @@ -602,16 +611,16 @@ function zmqUpgradeCb(msg: PubMsgData) {
if (curentDevice && curentDevice.action === 'upgrade') {
const { device } = curentDevice
if (device) {
if (status === 'progress') {
if (status === ZmqMsgResultType.PROGRESS) {
upFirmwareStatus(deviceSn, msg.feedback)
if (progressStatus === 4 && progress === 100) {
upFirmwareSucceed(deviceSn)
}
}
}
if (status === 'success' || status === 'error') {
if (status === ZmqMsgResultType.SUCCESS || status === ZmqMsgResultType.ERROR) {
upFirmwareStatus(deviceSn, msg.feedback)
if (status === 'error') {
if (status === ZmqMsgResultType.ERROR) {
upFirmwareStatusReject(deviceSn, msg.feedback)
}
upgradeSnList.value = upgradeSnList.value.filter(item => item !== deviceSn)
@ -658,6 +667,23 @@ const siteTransferLogList = ref<Array<{ @@ -658,6 +667,23 @@ const siteTransferLogList = ref<Array<{
status: 'success' | 'timeout' | 'error'
}>>([])
const offLineTransferRes = () => {
let timeoutNum = 0
let errorNum = 0
const findTimeout = siteTransferLogList.value.filter(i => i.status === 'timeout')
const uniqueTimeoutSn = new Set(findTimeout.map(i => i.device.sn))
timeoutNum = uniqueTimeoutSn.size
const findError = siteTransferLogList.value.filter(i => i.status === 'error')
errorNum = new Set(findError.map(i => i.device.sn)).size
return {
timeout: timeoutNum,
error: errorNum,
}
}
const onOffDeviceTransferStatus = ref<'progress' | 'success' | undefined>()
function zmqImportCb(msg: PubMsgData) {
const { id, feedback, result, code } = msg
@ -698,7 +724,7 @@ function zmqImportTimeoutCb(msg: TimeoutMsg) { @@ -698,7 +724,7 @@ function zmqImportTimeoutCb(msg: TimeoutMsg) {
siteTransferLogList.value.push({
msg: `数据导入超时,请稍后重试`,
device: offDevice,
status: 'error'
status: 'timeout'
})
importQueue.value.shift()
isImporting.value = false

2
src/views/stationData/type.ts

@ -6,6 +6,7 @@ export interface IOnlineDevice { @@ -6,6 +6,7 @@ export interface IOnlineDevice {
lastUpdated: number // 新增字段,记录最后更新时间
status?: string
isChecked?: boolean
versions?: string
upFirmware?: 'updating' | 'pending' | 'fulfilled' | 'rejected' | 'timeout'
upFirmwareStatus?: IUpFirmwareStatus
}
@ -40,4 +41,5 @@ export interface IUpFirmwareStatus { @@ -40,4 +41,5 @@ export interface IUpFirmwareStatus {
export interface IMyPoint {
addr: string
label: string
unit?: string
}
Loading…
Cancel
Save