From 58ae613c2b09dac3e34a617d5e6fbb256e339ebf Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=88=98=E5=A6=8D?= <1455167345@qq.com>
Date: Sat, 21 Jun 2025 14:58:23 +0800
Subject: [PATCH 1/2] =?UTF-8?q?=E7=9B=B4=E6=92=AD=E5=86=85=E5=AE=B9?=
=?UTF-8?q?=E6=94=B9=E6=88=90MQTT=E7=9A=84=EF=BC=8C=E9=A3=9E=E8=A1=8C?=
=?UTF-8?q?=E6=8E=A7=E5=88=B6=E3=80=81=E4=BA=91=E5=8F=B0=E7=9B=B8=E6=9C=BA?=
=?UTF-8?q?=E6=8E=A7=E5=88=B6?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/utils/debugging/events.ts | 10 +
src/utils/debugging/remote.ts | 9 +
src/utils/uuid.ts | 29 ++
.../workmanagement/flightoperation/index.ts | 1 +
.../workmanagement/flightoperation/index.vue | 20 +-
.../flightoperation/src/AirportLive.vue | 126 ++++++--
.../flightoperation/src/FlightControl.vue | 105 ++++++-
.../flightoperation/src/LivePreview.vue | 197 +++++++++---
.../flightoperation/src/LoadControl.vue | 78 +++--
.../flightoperation/src/TakeOffForm.vue | 289 ++++++++++++++++++
10 files changed, 750 insertions(+), 114 deletions(-)
create mode 100644 src/views/demo/workmanagement/flightoperation/src/TakeOffForm.vue
diff --git a/src/utils/debugging/events.ts b/src/utils/debugging/events.ts
index 696285d..d1ff28f 100644
--- a/src/utils/debugging/events.ts
+++ b/src/utils/debugging/events.ts
@@ -1,5 +1,15 @@
import { clientReizePublish, clientReizeSubscribe } from '@/utils/mqtt';
+export const return_home_status = {
+ canceled: '取消或终止',
+ failed: '失败',
+ in_progress: '执行中',
+ ok: '执行成功',
+ paused: '暂停',
+ rejected: '拒绝',
+ sent: '已下发',
+ timeout: '超时',
+};
export const eventsTopic = (data) => {
// 发送消息
clientReizePublish('thing/product/8UUXN5400A079H/events', data);
diff --git a/src/utils/debugging/remote.ts b/src/utils/debugging/remote.ts
index 6a27985..2340c06 100644
--- a/src/utils/debugging/remote.ts
+++ b/src/utils/debugging/remote.ts
@@ -29,3 +29,12 @@ export const services_replyTopic = () => {
// 订阅消息
clientSubscribe('thing/product/8UUXN5400A079H/services_reply');
};
+// 无人机
+export const servicesUAVTopic = (data) => {
+ // 发送消息
+ clientPublish('thing/product/1581F8HGX254V00A0BUY/services', data);
+};
+export const services_replyUAVTopic = () => {
+ // 订阅消息
+ clientSubscribe('thing/product/1581F8HGX254V00A0BUY/services_reply');
+};
diff --git a/src/utils/uuid.ts b/src/utils/uuid.ts
index 934b9f0..39eeaf5 100644
--- a/src/utils/uuid.ts
+++ b/src/utils/uuid.ts
@@ -40,3 +40,32 @@ export function buildShortUUID(prefix = ''): string {
unique++;
return prefix + '_' + random + unique + String(time);
}
+export function uuid(len, radix) {
+ const chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split('');
+ let uuid = [],
+ i;
+ radix = radix || chars.length;
+
+ if (len) {
+ // Compact form
+ for (i = 0; i < len; i++) uuid[i] = chars[0 | (Math.random() * radix)];
+ } else {
+ // rfc4122, version 4 form
+ let r;
+
+ // rfc4122 requires these characters
+ uuid[8] = uuid[13] = uuid[18] = uuid[23] = '-';
+ uuid[14] = '4';
+
+ // Fill in random data. At i==19 set the high bits of clock sequence as
+ // per rfc4122, sec. 4.1.5
+ for (i = 0; i < 36; i++) {
+ if (!uuid[i]) {
+ r = 0 | (Math.random() * 16);
+ uuid[i] = chars[i == 19 ? (r & 0x3) | 0x8 : r];
+ }
+ }
+ }
+
+ return uuid.join('');
+}
diff --git a/src/views/demo/workmanagement/flightoperation/index.ts b/src/views/demo/workmanagement/flightoperation/index.ts
index 106082a..e0e0c91 100644
--- a/src/views/demo/workmanagement/flightoperation/index.ts
+++ b/src/views/demo/workmanagement/flightoperation/index.ts
@@ -6,4 +6,5 @@ export { default as LivePreview } from './src/LivePreview.vue';
export { default as RemoteDebugging } from './src/RemoteDebugging.vue';
export { default as LoadControl } from './src/LoadControl.vue';
export { default as FlightControl } from './src/FlightControl.vue';
+export { default as TakeOffForm } from './src/TakeOffForm.vue';
export { default as Map } from '../workplan/components/map.vue';
diff --git a/src/views/demo/workmanagement/flightoperation/index.vue b/src/views/demo/workmanagement/flightoperation/index.vue
index 091e16d..0c66398 100644
--- a/src/views/demo/workmanagement/flightoperation/index.vue
+++ b/src/views/demo/workmanagement/flightoperation/index.vue
@@ -24,10 +24,14 @@
-
+
+
+
+
+
-
+
@@ -51,6 +55,7 @@
RemoteDebugging,
LoadControl,
FlightControl,
+ TakeOffForm,
} from './index';
import { useMessage } from '@/hooks/web/useMessage';
import { getClient, createConnection, clientSubscribe } from '@/utils/mqtt';
@@ -81,6 +86,8 @@
const loadControlVisible = ref(false);
// 飞行控制
const flightControlVisible = ref(false);
+ // 一键起飞表单
+ const takeOffFormVisible = ref(false);
const changeAirportLive = () => {
airportLiveVisible.value = !airportLiveVisible.value;
};
@@ -93,6 +100,13 @@
const changeFlightControl = () => {
flightControlVisible.value = !flightControlVisible.value;
};
+ const clickTakeOff = () => {
+ console.log('clickTakeOff');
+ takeOffFormVisible.value = true;
+ };
+ const changeTakeOffForm = () => {
+ takeOffFormVisible.value = false;
+ };
const msgData = ref();
const changeSelect = async (value?: any) => {
console.log(value);
diff --git a/src/views/demo/workmanagement/flightoperation/src/AirportLive.vue b/src/views/demo/workmanagement/flightoperation/src/AirportLive.vue
index 242063c..13daaac 100644
--- a/src/views/demo/workmanagement/flightoperation/src/AirportLive.vue
+++ b/src/views/demo/workmanagement/flightoperation/src/AirportLive.vue
@@ -4,8 +4,8 @@
机场直播
@@ -25,44 +25,116 @@
diff --git a/src/views/demo/workmanagement/flightoperation/src/LoadControl.vue b/src/views/demo/workmanagement/flightoperation/src/LoadControl.vue
index 0d4b5b0..1d51642 100644
--- a/src/views/demo/workmanagement/flightoperation/src/LoadControl.vue
+++ b/src/views/demo/workmanagement/flightoperation/src/LoadControl.vue
@@ -21,10 +21,22 @@

-
-
-
-
+
+
+
+
@@ -73,25 +85,30 @@
);
const obtain = () => {
- // 飞行控制权抢夺
- eventsTopic({
- bid: buildGUID(),
- method: 'flight_authority_grab',
- tid: buildGUID(),
- timestamp: new Date().getTime(),
- data: {},
- });
- // 负载控制权抢夺
- eventsTopic({
- bid: buildGUID(),
- method: 'payload_authority_grab',
- tid: buildGUID(),
- timestamp: new Date().getTime(),
- data: {
- payload_index: '99-0-0',
- },
- });
- events_replyTopic();
+ if (!getReizeClient()) {
+ createSeizeConnection();
+ }
+ setTimeout(() => {
+ // 飞行控制权抢夺
+ eventsTopic({
+ bid: buildGUID(),
+ method: 'flight_authority_grab',
+ tid: buildGUID(),
+ timestamp: new Date().getTime(),
+ data: {},
+ });
+ // 负载控制权抢夺
+ eventsTopic({
+ bid: buildGUID(),
+ method: 'payload_authority_grab',
+ tid: buildGUID(),
+ timestamp: new Date().getTime(),
+ data: {
+ payload_index: '99-0-0',
+ },
+ });
+ events_replyTopic();
+ }, 1000);
};
// 单拍
const singleShot = () => {
@@ -107,15 +124,11 @@
});
};
// 控制方向
- const changeDrc = (val) => {
- if (val == 'top') {
- drcVal.pitch = drcVal.pitch + 20;
- } else if (val == 'bottom') {
- drcVal.pitch = drcVal.pitch - 20;
- } else if (val == 'left') {
- drcVal.roll = drcVal.roll - 20;
- } else if (val == 'right') {
- drcVal.roll = drcVal.roll + 20;
+ const changeDrc = (type, val) => {
+ if (val == 'up') {
+ drcVal[type] = drcVal[type] + 20;
+ } else {
+ drcVal[type] = drcVal[type] - 20;
}
const querys = {
seq: 1,
@@ -125,7 +138,6 @@
drcDownTopic(querys);
};
onMounted(() => {
- // createSeizeConnection();
// // 接收消息
// getReizeClient().on('message', (topic, message) => {
// const rs = JSON.parse(message);
diff --git a/src/views/demo/workmanagement/flightoperation/src/TakeOffForm.vue b/src/views/demo/workmanagement/flightoperation/src/TakeOffForm.vue
new file mode 100644
index 0000000..1cac91b
--- /dev/null
+++ b/src/views/demo/workmanagement/flightoperation/src/TakeOffForm.vue
@@ -0,0 +1,289 @@
+
+
+
+
+
From e1d8e8e6b0a5902c9a8a03b38fa68a6ab8b1fbda Mon Sep 17 00:00:00 2001
From: zhufu <17863654727@163.com>
Date: Sun, 22 Jun 2025 09:02:00 +0800
Subject: [PATCH 2/2] =?UTF-8?q?=E8=AE=BE=E5=A4=87=E7=AE=A1=E7=90=86-?=
=?UTF-8?q?=E6=9C=BA=E5=9C=BA=E5=88=97=E8=A1=A8?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/api/demo/device.ts | 11 ++
src/utils/mqtt.ts | 25 +++-
.../workmanagement/device/Airport/index.vue | 108 +++++++++++++++---
.../workmanagement/device/Airport/utils.ts | 28 +----
.../demo/workmanagement/device/index.vue | 37 +++++-
5 files changed, 169 insertions(+), 40 deletions(-)
create mode 100644 src/api/demo/device.ts
diff --git a/src/api/demo/device.ts b/src/api/demo/device.ts
new file mode 100644
index 0000000..8941fa4
--- /dev/null
+++ b/src/api/demo/device.ts
@@ -0,0 +1,11 @@
+import { defHttp } from '@/utils/http/axios';
+enum Api {
+ GetDataList = '/api/Manage/GetDataList',
+}
+
+export function GetDataList(params) {
+ return defHttp.get({
+ url: Api.GetDataList,
+ params
+ });
+}
\ No newline at end of file
diff --git a/src/utils/mqtt.ts b/src/utils/mqtt.ts
index 5b704a7..324899a 100644
--- a/src/utils/mqtt.ts
+++ b/src/utils/mqtt.ts
@@ -13,7 +13,7 @@ const connection = {
connectTimeout: 30 * 1000, // ms
reconnectPeriod: 4000, // ms
// clientId: 'mqttx_' + Math.random().toString(16).substring(2, 8),
- clientId: 'mqtt_client_1581F8HGX254V00A0BUY',
+ clientId: `mqtt_${Math.random().toString(16).slice(2)}`,
// auth
username: 'sdhc',
password: '',
@@ -43,11 +43,23 @@ const handleOnReConnect = () => {
}
};
// 创建连接函数
-const createConnection = () => {
+const createConnection = (callback?) => {
try {
const { protocol, host, port, endpoint, ...options } = connection;
const connectUrl = `${protocol}://${host}:${port}${endpoint}`;
client = mqtt.connect(connectUrl, options);
+ client.on('connect', () => {
+ console.log('✅ 已连接');
+ if(callback){
+ callback()
+ }
+ });
+ client.on('close', () => {
+ console.log('❌ 连接已关闭');
+ });
+ client.on('error', (err) => {
+ console.error('❌ 出错了:', err);
+ });
if (client.on) {
}
} catch (error) {
@@ -95,6 +107,14 @@ const clientPublish = (topic: string, querys: any) => {
}
});
};
+// 获取连接状态
+const getConnectStatus = () => {
+ console.log('client',client)
+ if (!client.connected) {
+ return false
+ }
+ return true
+}
// on 事件
// connect 连接
// reconnect 重新连接
@@ -162,4 +182,5 @@ export {
getReizeClient,
clientReizeSubscribe,
clientReizePublish,
+ getConnectStatus,
};
diff --git a/src/views/demo/workmanagement/device/Airport/index.vue b/src/views/demo/workmanagement/device/Airport/index.vue
index defc52f..8d07b91 100644
--- a/src/views/demo/workmanagement/device/Airport/index.vue
+++ b/src/views/demo/workmanagement/device/Airport/index.vue
@@ -1,16 +1,29 @@
-
+
设备定损与反馈
设备绑定码
+
+ {{ props.projectList.find(item => item.value == record.workSpaceId)?.label }}
+
+
+ {{ record.first_power_on? dayjs(record.first_power_on).format('YYYY-MM-DD HH:mm:ss'): '' }}
+
+
+ {{ record.compatible_status? record.compatible_status == 0? "不需要一致性升级": "需要一致性升级": "" }}
+
+
+ {{ workStatus(record)}}
+
+
+
+