From 13b17ba157aaaa3faffae53e581fc79be4555c94 Mon Sep 17 00:00:00 2001 From: helloxujingliang <3225043@qq.com> Date: Wed, 19 Nov 2025 16:10:41 +0800 Subject: [PATCH] merge --- .../Tasks/Tasks/TaskAssign/config.ts | 2 +- .../Tasks/Tasks/TaskAssign/index.vue | 162 ++++++++++++------ 2 files changed, 115 insertions(+), 49 deletions(-) diff --git a/src/packages/components/Tasks/Tasks/TaskAssign/config.ts b/src/packages/components/Tasks/Tasks/TaskAssign/config.ts index efe52f7..68021bc 100644 --- a/src/packages/components/Tasks/Tasks/TaskAssign/config.ts +++ b/src/packages/components/Tasks/Tasks/TaskAssign/config.ts @@ -9,7 +9,7 @@ export const option = { colors: ['#0C2411','#00611A','#FFFFFF'], text: '添加途经点', list: [ - '关闭线索','应急响应','关闭弹窗' + '关闭线索','应急响应','关闭弹窗' ], selectButton: '', } diff --git a/src/packages/components/Tasks/Tasks/TaskAssign/index.vue b/src/packages/components/Tasks/Tasks/TaskAssign/index.vue index 7121b79..473a376 100644 --- a/src/packages/components/Tasks/Tasks/TaskAssign/index.vue +++ b/src/packages/components/Tasks/Tasks/TaskAssign/index.vue @@ -101,7 +101,7 @@ -
+
无人机视频 @@ -602,6 +602,70 @@ airPortStoreVal.setProject(res.projectId); }); + + // mqtt连接 + if (!getClient() || !getClient().connected) { + createConnection(); + } + + setTimeout(() => { + getClient().on('message', (topic, message) => { + const rs = JSON.parse(message); + + if (rs.method === 'takeoff_to_point' && rs.bid == bid) { + if (rs.data.result == 0) { + createMessage.success('一键起飞成功'); + } else { + createMessage.error('一键起飞失败,' + errorName(rs.data.result)); + } + } + // 指点飞行 + if (rs.method == 'fly_to_point' && rs.bid == bid) { + if (rs.data.result == 0) { + createMessage.success('指点飞行成功'); + } else { + createMessage.error('指点飞行失败,' + errorName(rs.data.result)); + } + } + + if (rs.method == 'live_start_push' && rs.tid == startTid) { + if (rs.data.result == 0) { + createMessage.success('无人机开始直播成功'); + player.src(live_info.url + liveCode.value + '.flv'); + player.play(); + isUAVLive.value = false; + } else if (rs.data.result == 513003) { + createMessage.success('无人机直播已开启'); + + playVideo(); + return null; + player.src(live_info.url + liveCode.value + '.flv'); + player.play(); + isUAVLive.value = false; + } else { + createMessage.error('开始直播失败,' + errorName(rs.data.result)); + isUAVLive.value = true; + } + } + + console.log("message995",rs.method); + + console.log("message996",topic,rs.data.longitude); + + console.log("message998",airPortStoreVal.getUAV.sn); + // 更新位置 + // && topic=='thing/product/' + airPortStoreVal.getUAV.sn + '/osd' + if (rs.data.latitude && rs.data.longitude && topic == 'thing/product/' + airPortStoreVal.getUAV.sn + '/osd') { + console.log("messge999",rs.data.latitude,rs.data.longitude); + handlerUpdateUavPostion(rs.data.longitude,rs.data.latitude) + } + + }); + }, 5000); + + + + // 组件通信 EventBus.on(props.chartConfig.id + 'dataupdate', (data) => { return null; @@ -778,7 +842,7 @@ break; case "uav": - handlerUavVerify(item); + createUavConnection(); break; case "helicopter": @@ -1230,55 +1294,59 @@ const uavControllerShow = ref(false); const flyControlShow = ref(false); - - function createUavConnection(){ + // 获取无人机和可用状态 + async function createUavConnection(){ clueInfo.value.lng = clueInfo.value.lng; clueInfo.value.lat = clueInfo.value.lat; - listDronePort({ + await listDronePort({ lng: clueInfo.value.lng, lat: clueInfo.value.lat }).then((res) => { - console.log("res1123",res); + // 没有机场 if(res.length == 0){ - - return null; + ElMessage({ + message:"周边没有机场!", + type: 'error', + }) + return false; } + + airPortStoreVal.setAirPort('sn', res[0].droneportsn); airPortStoreVal.setUAV('sn', res[0].Sn); airPortStoreVal.setGateway(res[0].GateWay); + // 订阅无人机 + clientSubscribe("thing/product/"+res[0].Sn+"/osd",{ qos: 1 }); + applyDroneControl({ dronePortSn: res[0].droneportsn }).then((res) => { + // 状态被锁定 + if(res.code == 400){ + ElMessage({ + message:"无人机已被锁定!", + type: 'error', + }) + return false; + } droneData.value = res; + + // 进行无人机飞行和核查 + handlerUavVerify(); }); + // 建立连接 接收消息 setTimeout(() => { if (!getClient()) { createConnection(); } setTimeout(() => { - // 接收消息 - getClient().on("message",(topic,message)=>{ - console.log("连接成功!"); - }) - getClient().on('message', (topic, message) => { const rs = JSON.parse(message); if (rs.method === 'takeoff_to_point' && rs.bid == bid) { if (rs.data.result == 0) { createMessage.success('一键起飞成功'); - // 关联任务 - saveHandFlyTask({ - flightId: airPortStoreVal.getFlightId, - workspaceId: airPortStoreVal.getProject, - }).then((res) => { - if (res) { - setTimeout(() => { - airPortStoreVal.setTaskId(res.taskId); - }, 1000); - } - }); } else { createMessage.error('一键起飞失败,' + errorName(rs.data.result)); } @@ -1293,7 +1361,8 @@ } // 更新位置 - if (rs.data.latitude && rs.data.longitude) { + // && topic=='thing/product/' + airPortStoreVal.getUAV.sn + '/osd' + if (rs.data.latitude && rs.data.longitude && topic=='thing/product/' + airPortStoreVal.getUAV.sn + '/osd') { console.log("messge9998",JSON.stringify(rs.data)); handlerUpdateUavPostion(rs.data.longitude,rs.data.latitude) } @@ -1301,12 +1370,14 @@ }); }, 5000); }, 500); - }); + + return true; + }).catch((res)=>{ + return false; + }) } - function handlerUavVerify(item){ - // 创建无人机连接 - createUavConnection(); + function handlerUavVerify(){ clueInfo.value.lng = clueInfo.value.lng clueInfo.value.lat = clueInfo.value.lat; @@ -1318,13 +1389,9 @@ _alt:window.globalMap.getHeight([parseFloat(clueInfo.value.lng),parseFloat(clueInfo.value.lat)])+100 } - if(!droneData.value?.droneInDock){ - ElMessage({ - message:"周边没有机场!", - type: 'error', - }) - return null; - } + // if(!droneData.value?.droneInDock){ + // return null; + // } // 飞行 if (droneData.value.droneInDock == 1) { @@ -1398,7 +1465,6 @@ }); } } - // 更新无人机图标位置 let uavGraphicLayer:mars3d.layer.GraphicLayer; @@ -1442,13 +1508,8 @@ // 点击事件 graphic.on(mars3d.EventType.click, function (event: any) { var data = event.graphic.options.attr; - // 打开无人机视频 - uavControllerShow.value = true; - isUAVLive.value = false; - - setTimeout(function(){ - playVideo(); - },500); + playVideo(); + // startLiveFun(); }); uavGraphicLayer.addGraphic(graphic); @@ -2102,10 +2163,10 @@ tid: startTid, timestamp: new Date().getTime(), data: { - url_type: 1, // 0 = 自适应;如需 RTMP 改为 1;GB28181 为 3;WebRTC 为 4 - url: live_info.rtmp + liveCode.value, + url_type: 1, + url: live_info.rtmp + uav.sn, video_id: uav.video_id, - video_quality: 3, // 0=自适应,1=流畅,2=标清,3=高清,4=超清 + video_quality: 3, }, }; servicesTopic(querys); @@ -2115,6 +2176,11 @@ const liveCode = ref('7'); const playVideo = () => { + // 打开无人机视频 + uavControllerShow.value = true; + isUAVLive.value = false; + + alert(live_info.url + uav.sn + '.flv') player = TCPlayer('player-container-id-live', { sources: [ @@ -2124,7 +2190,7 @@ ], width:"396px", height:"280px", - licenseUrl: live_info.url + uav.sn + '.flv', // license 地址,必传。参考准备工作部分,在视立方控制台申请 license 后可获得 licenseUrl + licenseUrl: live_info.url + uav.sn + '.flv', // license 地址,必传。参考准备工作部分,在视立方控制台申请 license 后可获得 licenseUrl }); };