From df35513a888cd03f2a3e2eacdf9f1d9dc1f0c135 Mon Sep 17 00:00:00 2001
From: Xiajijian <1176061145@qq.com>
Date: Thu, 22 Jan 2026 09:41:06 +0800
Subject: [PATCH] 1. 修改航点编号名称。
---
ard-route/src/main/java/com/ard/route/service/impl/ArdRouteInfoServiceImpl.java | 153 +++++++++++++++++++++++++++++++++++++++-----------
1 files changed, 119 insertions(+), 34 deletions(-)
diff --git a/ard-route/src/main/java/com/ard/route/service/impl/ArdRouteInfoServiceImpl.java b/ard-route/src/main/java/com/ard/route/service/impl/ArdRouteInfoServiceImpl.java
index aa000dd..77cff7d 100644
--- a/ard-route/src/main/java/com/ard/route/service/impl/ArdRouteInfoServiceImpl.java
+++ b/ard-route/src/main/java/com/ard/route/service/impl/ArdRouteInfoServiceImpl.java
@@ -21,12 +21,16 @@
import com.ard.route.domain.djuav.UavRouteReq;
import com.ard.route.domain.dto.ArdNoflyDto;
import com.ard.route.domain.route.ArdRouteInfo;
+import com.ard.route.domain.route.ArdRouteMission;
import com.ard.route.domain.vo.KmzResultVo;
import com.ard.route.mapper.ArdRouteInfoMapper;
+import com.ard.route.mapper.ArdRouteMissionMapper;
import com.ard.route.service.IArdRouteInfoService;
import com.ard.route.service.UavRouteService;
+import com.ard.work.domain.cache.UavTelemetryDataCache;
import com.ard.work.domain.cache.UavWaylineCache;
import com.ard.work.domain.dto.state.PointData;
+import com.ard.work.domain.dto.telemetry.TelemetryData;
import com.ard.work.domain.dto.wayline.*;
import com.ard.work.service.ITyService;
import org.slf4j.Logger;
@@ -37,9 +41,9 @@
import javax.annotation.Resource;
+import static com.ard.common.utils.SecurityUtils.getUsername;
import static com.ard.route.enums.kml.DroneEnumValueEnums.M350_RTK;
import static com.ard.route.util.InitializationUtils.divided_23;
-import static com.ard.route.util.InitializationUtils.divided_6;
import static com.ard.route.util.ToolUtils.*;
import static com.ard.route.util.UavRouteReqUtils.fileConversionEntity;
@@ -60,9 +64,11 @@
@Autowired
private OssServiceContext ossService;
-
@Autowired
private UavRouteService routeService;
+
+ @Autowired
+ private ArdRouteMissionMapper ardRouteMissionMapper;
@Resource
private IArdNoFlyZoneService ardNoFlyZoneService;
@@ -80,26 +86,37 @@
public ArdRouteInfo selectArdRouteInfoById(String id) {
ArdRouteInfo ardRouteInfo = ardRouteInfoMapper.selectArdRouteInfoById(id);
try {
- if (ardRouteInfo.getRouteData() != null){
- ardRouteInfo.setUavRouteReq((UavRouteReq) deserialize(ardRouteInfo.getRouteData()));
+ if (ardRouteInfo != null) {
+ if (ardRouteInfo.getRouteData() != null){
+ ardRouteInfo.setUavRouteReq((UavRouteReq) deserialize(ardRouteInfo.getRouteData()));
+ }
}
} catch (IOException | ClassNotFoundException e) {
throw new RuntimeException(e);
}
- for (RoutePointReq routePointReq : ardRouteInfo.getUavRouteReq().getRoutePointList()) {
- routePointReq.setHeight(routePointReq.getHeight() + getDoublePoint(ardRouteInfo.getUavRouteReq().getTakeOffRefPoint(),"alt"));
- // 判断无人机类型
- if (ardRouteInfo.getUavRouteReq().getDroneType().equals(M350_RTK.getValue())){
- for (ActionGroupReq actionGroupReq : routePointReq.getActionGroupList()) {
- for (PointActionReq action : actionGroupReq.getActions()) {
- if (action.getZoom() != null || action.getZoom() != 0){
- action.setZoom(divided_23(action.getZoom()));
- }
- }
- }
+
+ // 如果参考起飞点不为空,将每个航点高度进行加工。
+ if (ardRouteInfo.getUavRouteReq().getTakeOffRefPoint() != null){
+
+ double altitudeOffset = getDoublePoint(ardRouteInfo.getUavRouteReq().getTakeOffRefPoint(), "alt");
+
+ for (RoutePointReq routePointReq : ardRouteInfo.getUavRouteReq().getRoutePointList()) {
+ // 调整每个航点高度
+ adjustRoutePointHeight(routePointReq, altitudeOffset);
}
+ }else {
+ // 如果没有设置参考起飞点,将第一个航点设置为参考起飞点。
+ ardRouteInfo.getUavRouteReq().setTakeOffRefPoint(
+ ardRouteInfo.getUavRouteReq().getRoutePointList().get(0).getLatitude().toString() +"," +
+ ardRouteInfo.getUavRouteReq().getRoutePointList().get(0).getLongitude().toString()+","+
+ ardRouteInfo.getUavRouteReq().getRoutePointList().get(0).getHeight().toString());
}
+
return ardRouteInfo;
+ }
+
+ private void adjustRoutePointHeight(RoutePointReq routePointReq, double altitudeOffset) {
+ routePointReq.setHeight(routePointReq.getHeight() + altitudeOffset);
}
/**
@@ -115,12 +132,6 @@
}else if ("0".equals(ardRouteInfo.getOrderByTime())) {
ardRouteInfo.setOrderByTime("ASC");
}
-// List<ArdRouteInfo> list = ardRouteInfoMapper.selectArdRouteInfoList(ardRouteInfo);
-// for (ArdRouteInfo routeInfo : list) {
-// for (RoutePointReq routePointReq : routeInfo.getUavRouteReq().getRoutePointList()) {
-// routePointReq.setHeight(routePointReq.getHeight() + getDoublePoint(ardRouteInfo.getUavRouteReq().getTakeOffRefPoint(),"alt"));
-// }
-// }
return ardRouteInfoMapper.selectArdRouteInfoList(ardRouteInfo);
}
@@ -132,6 +143,7 @@
*/
@Override
public String insertArdRouteInfo(ArdRouteInfo ardRouteInfo) {
+ processRouteMission(ardRouteInfo);
ardRouteInfo.setId(IdUtils.simpleUUID());
ardRouteInfo.setCreateTime(DateUtils.getNowDate());
ardRouteInfo.setUpdateTime(DateUtils.getNowDate()); // 修改时间,用于排序
@@ -140,10 +152,24 @@
}
ardRouteInfo.getUavRouteReq().setDroneType(subStringDroneType(ardRouteInfo.getAircraft()));
KmzResultVo kmzResult = routeService.buildKmz(ardRouteInfo.getUavRouteReq(),ardRouteInfo.getName());
+ zoomProcessing(ardRouteInfo);
ardRouteInfo.setPath(kmzResult.getPath());
ardRouteInfo.setReadOnly("0");
ardRouteInfoMapper.insertArdRouteInfo(dataProcessing(ardRouteInfo));
return kmzResult.getPath();
+ }
+
+ // 航线任务数据加工校验
+ private void processRouteMission(ArdRouteInfo ardRouteInfo){
+ if ("3".equals(ardRouteInfo.getType())) {
+ ArdRouteMission ardRouteMission = ardRouteMissionMapper.selectArdRouteMissionById(ardRouteInfo.getMissionId());
+ if ("0".equals(ardRouteMission.getRouteId())) {
+ ardRouteMission.setRouteId(ardRouteInfo.getId());
+ ardRouteMissionMapper.updateArdRouteMission(ardRouteMission);
+ }else {
+ throw new RuntimeException("航线任务下已绑定航线,不可创建新航线信息!!!");
+ }
+ }
}
/**
@@ -163,6 +189,8 @@
// 先删除航线
delOssService(route);
// 再生成航线
+ ardRouteInfo.getUavRouteReq().setDroneType(subStringDroneType(ardRouteInfo.getAircraft()));
+ zoomProcessing(ardRouteInfo);
kmzResult = routeService.buildKmz(ardRouteInfo.getUavRouteReq(), ardRouteInfo.getName());
if ("更新航线kmz文件失败".equals(kmzResult.getData())) {
return 0;
@@ -170,6 +198,22 @@
ardRouteInfo.setPath(kmzResult.getPath());
}
return ardRouteInfoMapper.updateArdRouteInfo(dataProcessing(ardRouteInfo));
+ }
+
+ // 变倍加工方法
+ private void zoomProcessing(ArdRouteInfo ardRouteInfo) {
+ if (M350_RTK.getValue().equals(ardRouteInfo.getUavRouteReq().getDroneType())) {
+ // 变焦数值加工
+ for (RoutePointReq routePointReq : ardRouteInfo.getUavRouteReq().getRoutePointList()) {
+ for (ActionGroupReq actionGroupReq : routePointReq.getActionGroupList()) {
+ for (PointActionReq action : actionGroupReq.getActions()) {
+ if (action.getZoom() != null){
+ action.setZoom(divided_23(action.getZoom()));
+ }
+ }
+ }
+ }
+ }
}
// 新增信息加工
@@ -229,6 +273,9 @@
*/
@Override
public int deleteArdRouteInfoById(String id) {
+ // 删除航线(kmz)文件
+ ArdRouteInfo information = ardRouteInfoMapper.selectArdRouteInfoById(id);
+ delOssService(information);
return ardRouteInfoMapper.deleteArdRouteInfoById(id);
}
@@ -249,17 +296,6 @@
ardRouteInfo.setType(templateTypeData(uavRouteReq));
ardRouteInfo.setAircraft(droneTypeData(uavRouteReq));
}
-
- // 判断禁飞区
- try {
- arrayWithinNoFlyZone(ardRouteInfo.getUavRouteReq().getRoutePointList());
- } catch (ControlException e) {
- // 返回包含禁飞区错误信息的特定结果
- return MinioUploadResult.builder()
- .originalFilename("禁飞区错误.航线航点在禁飞区!")
- .build();
- }
-
String url = ossService.upload("kmz",file);
ardRouteInfo.setName(file.getOriginalFilename());
ardRouteInfo.setPath(url);
@@ -338,7 +374,6 @@
/**
* 上传航线到边缘服务器
- *
* ardNoflyDto
* @return 结果
*/
@@ -352,6 +387,36 @@
} catch (IOException | ClassNotFoundException e) {
throw new RuntimeException(e);
}
+
+ // 获取第一个点
+ double firstPointLng = route.getUavRouteReq().getRoutePointList().get(0).getLongitude();
+ double firstPointLat = route.getUavRouteReq().getRoutePointList().get(0).getLatitude();
+
+ // 获取最后一个点
+ double lastPointLng = route.getUavRouteReq().getRoutePointList().get(route.getUavRouteReq().getRoutePointList().size()-1).getLongitude();
+ double lastPointLat = route.getUavRouteReq().getRoutePointList().get(route.getUavRouteReq().getRoutePointList().size()-1).getLatitude();
+
+ // 无人机遥测数据,用于校验真实起飞点和第一个点是否在禁飞区
+ TelemetryData telemetryData = UavTelemetryDataCache.get(boxSn);
+ double telemetryDataLng = 0;
+ double telemetryDataLat = 0;
+ if (telemetryData != null){
+ telemetryDataLng = telemetryData.getLng();
+ telemetryDataLat = telemetryData.getLat();
+ }
+
+ ArdNoflyDto dto1 = new ArdNoflyDto();
+ dto1.setCurrent(new Vertex(telemetryDataLng,telemetryDataLat));
+ dto1.setTarget(new Vertex(firstPointLng,firstPointLat));
+ verifyNoFlyZone(dto1);
+
+ ArdNoflyDto dto2 = new ArdNoflyDto();
+ dto2.setCurrent(new Vertex(lastPointLng,lastPointLat));
+ dto2.setTarget(new Vertex(telemetryDataLng,telemetryDataLat));
+ verifyNoFlyZone(dto2);
+
+ // 判断禁飞区
+ arrayWithinNoFlyZone(route.getUavRouteReq().getRoutePointList());
// 1.2通过minio获取航线信息
// 2.将航线信息转换成对应实体类
WayLineUploadDTO wayLineUploadDTO = buildWayLineUploadDTO(route);
@@ -373,12 +438,32 @@
* @return 结果
*/
@Override
- public Boolean routeBegins(String boxSn) {
+ public Boolean routeBegins(String id,String boxSn) {
+ ArdRouteInfo route = ardRouteInfoMapper.selectArdRouteInfoById(id);
+ // 判断是否循环航线
+ if (null != route && "0".equals(route.getIsLoop())){
+ deleteArdRouteInfoById(id);
+ updateMissionStatus(route);
+ }
WayLineBeginDTO wayLineBeginDTO = new WayLineBeginDTO(boxSn);
tyService.wayLineBegin(wayLineBeginDTO);
return true;
}
+ // 执行航线的时候修改航线任务表执行状态
+ private void updateMissionStatus(ArdRouteInfo route){
+ if ("3".equals(route.getType())) {
+ ArdRouteMission ardRouteMission = ardRouteMissionMapper.selectArdRouteMissionById(route.getMissionId());
+ if ("0".equals(ardRouteMission.getExecuteStatus())) {
+ ardRouteMission.setExecuteStatus("1");
+ ardRouteMission.setExecuteBy(getUsername());
+ ardRouteMission.setExecuteTime(DateUtils.getNowDate());
+ ardRouteMission.setUpdateTime(DateUtils.getNowDate());
+ ardRouteMissionMapper.updateArdRouteMission(ardRouteMission);
+ }
+ }
+ }
+
/**
* 暂停航线
*
--
Gitblit v1.9.3