From 9454821b6fd2373e96286a63bfc66b16158e0be8 Mon Sep 17 00:00:00 2001
From: zhongrj <646384940@qq.com>
Date: Wed, 27 Nov 2024 18:14:30 +0800
Subject: [PATCH] 固件升级优化调整,支持同时在线升级
---
src/views/device/fly.vue | 5 +
vite.config.mjs | 4
src/views/device/airport.vue | 115 ++++++++++++++++++++++++++++++++------
src/api/device/device.js | 7 ++
4 files changed, 111 insertions(+), 20 deletions(-)
diff --git a/src/api/device/device.js b/src/api/device/device.js
index cd9fd85..cd84c9a 100644
--- a/src/api/device/device.js
+++ b/src/api/device/device.js
@@ -122,4 +122,11 @@
ids
}
});
+};
+
+export const getDevices = (workspace_id,device_sn) => {
+ return request({
+ url: `/drone-yw/manage/api/v1/devices/${workspace_id}/devices/${device_sn}`,
+ method: 'get',
+ });
};
\ No newline at end of file
diff --git a/src/views/device/airport.vue b/src/views/device/airport.vue
index 8cc2b17..51aeeae 100644
--- a/src/views/device/airport.vue
+++ b/src/views/device/airport.vue
@@ -97,6 +97,15 @@
></el-progress>
</div>
</template>
+ <template #mode_code="{ row }">
+ <span
+ class="text"
+ v-if="row.domain == 3"
+ :style="row.mode_code != '-1' ? 'color: #00ee8b' : 'color: #de5e5e'"
+ >
+ {{ getDockModeText(row.mode_code) }}
+ </span>
+ </template>
<template #menu="scope">
<el-button
type="primary"
@@ -192,10 +201,11 @@
getDeviceUpgradeInfo,
ota,
getDeviceFirmwareList,
+ getDevices,
} from '@/api/device/device';
import { getLazyTree } from '@/api/base/region';
-
+import { EDockModeText, EDockModeCode } from '@/types/device';
import { mapGetters } from 'vuex';
import FirmwareManage from './components/firmwareManage.vue';
import DevicePerShare from './components/devicePerShare.vue';
@@ -477,6 +487,22 @@
},
],
},
+ {
+ label: '机场状态',
+ prop: 'mode_code',
+ addDisplay: false,
+ editDisplay: false,
+ labelWidth: 130,
+ slot: true,
+ width: 100,
+ rules: [
+ {
+ required: true,
+ message: '请输入机场状态',
+ trigger: 'blur',
+ },
+ ],
+ },
],
},
data: [],
@@ -522,6 +548,9 @@
});
},
methods: {
+ getDockModeText(value) {
+ return EDockModeText[value] || '';
+ },
// 关闭所有的webscoket
closeAllWebsoket() {
this.websocketMap.forEach((k, v) => {
@@ -576,6 +605,11 @@
});
},
init() {
+ this.page= {
+ pageSize: 10,
+ currentPage: 1,
+ total: 0,
+ },
this.onLoad(this.page);
},
// 打开权限分享页面
@@ -609,6 +643,16 @@
});
return;
}
+ // 如果是机场,查询飞机对应的信息
+ if (row.domain === 3) {
+ // 查询子设备名称
+ getDevices(row.workspace_id, row.child_sn).then(res => {
+ const data = res.data.data;
+ that.firmwareInfo['child_device_name'] = data.device_name;
+ that.firmwareInfo['child_version'] = data.firmware_version;
+ that.firmwareInfo['child_status'] = data.status;
+ });
+ }
var that = this;
this.rollFirmwareBox = true;
const param = {
@@ -631,6 +675,8 @@
// 3-普通升级,2-一致性升级;
that.firmwareInfo['firmware_upgrade_type'] = 3;
that.firmwareInfo['workspaceId'] = row.workspace_id;
+ that.firmwareInfo['firmware_version'] = row.firmware_version;
+ that.firmwareInfo['status'] = row.status;
// domain 0:飞机 3:机场
that.firmwareInfo['domain'] = row.domain;
that.firmwareInfo['child_sn'] = row.child_sn;
@@ -653,6 +699,7 @@
},
// 版本回退
rollFirmwareConfirm() {
+ // 无人机升级/回滚
if (this.rollFirmVersion == '') {
this.$message({
type: 'warning',
@@ -663,24 +710,56 @@
var that = this;
var arr = [];
that.firmwareInfo['product_version'] = this.rollFirmVersion;
- // 无人机升级/回滚
+ // 机场信息设置
arr.push(that.firmwareInfo);
- //判断是机场升级还是飞机升级,如果是机场升级则把无人机信息一起带过去
- // if (that.firmwareInfo.domain === 3) {
- // // 机场升级
- // arr.push(that.firmwareInfo);
- // // 比对当前版本和需要升级/回滚版本,如果是升级则一起升级,如果是降级就单个进行(一起降级时飞机有回滚机制会失败)
- // var verFlag = this.compare(this.rollFirmVersion, that.firmwareInfo.now_version);
- // if (verFlag == 1) {
- // // 升级
- // arr.push({
- // sn: that.firmwareInfo.child_sn,
- // product_version: this.rollFirmVersion,
- // firmware_upgrade_type: 3,
- // });
- // }
- // }
- // console.log(arr,888)
+ // 判断是机场升级还是飞机升级,如果是机场升级则把无人机信息一起带过去
+ if (that.firmwareInfo.domain === 3) {
+ // 判断当前机场和无人机固件版本是否一致
+ var dockFlag = this.compare(
+ this.firmwareInfo.firmware_version,
+ this.firmwareInfo.child_version
+ );
+ // 机场和无人机版本一致情况
+ if (dockFlag == 0) {
+ if (!this.firmwareInfo.status || !this.firmwareInfo.child_status) {
+ this.$message({
+ type: 'warning',
+ message: '请先更新无人机固件版本后再进行机场固件版本更新!',
+ });
+ return;
+ }
+ // 只有同时在线并且是升级才能操作
+ // 判断升级还是降级,不能降级
+ var upDownFlag = this.compare(this.rollFirmVersion, this.firmwareInfo.firmware_version);
+ if (upDownFlag == -1) {
+ this.$message({
+ type: 'warning',
+ message: '请先回滚无人机固件版本后再进行机场固件版本更新!',
+ });
+ return;
+ }
+ // 同时升级操作
+ // 无人机信息设置
+ arr.push({
+ device_name: that.firmwareInfo.child_device_name,
+ sn: that.firmwareInfo.child_sn,
+ product_version: this.rollFirmVersion,
+ firmware_upgrade_type: 3,
+ });
+ } else {
+ // 版本不一致情况
+ // 比对需要改变的版本号和无人机版本号是否一致,不一致提示不能操作
+ var verFlag = this.compare(this.rollFirmVersion, this.firmwareInfo.child_version);
+ if (verFlag == -1 || verFlag == 1) {
+ this.$message({
+ type: 'warning',
+ message: '更新版本与当前无人机固件版本不一致,请更新和无人机一致的版本!',
+ });
+ return;
+ }
+ // 需要改变的版本号和无人机版本号如果是一致,进行单独的机场升级/回滚操作
+ }
+ }
ota(that.firmwareInfo.workspaceId, arr).then(res => {
that.firmwareVersion = '';
that.firmwareInfo = {};
diff --git a/src/views/device/fly.vue b/src/views/device/fly.vue
index 62f527d..d307d09 100644
--- a/src/views/device/fly.vue
+++ b/src/views/device/fly.vue
@@ -377,6 +377,11 @@
})
},
init() {
+ this.page= {
+ pageSize: 10,
+ currentPage: 1,
+ total: 0,
+ },
this.onLoad(this.page);
},
rowSave(row, done, loading) {
diff --git a/vite.config.mjs b/vite.config.mjs
index df3da37..b610064 100644
--- a/vite.config.mjs
+++ b/vite.config.mjs
@@ -38,8 +38,8 @@
port: 2888,
proxy: {
'/api': {
- target: 'http://localhost',
- // target: 'https://wrj.shuixiongit.com/api',
+ // target: 'http://localhost',
+ target: 'https://wrj.shuixiongit.com/api',
changeOrigin: true,
rewrite: path => path.replace(/^\/api/, ''),
},
--
Gitblit v1.9.3