From 9001e055d272ad7e0a3b60e2891939aeb29dc1ad Mon Sep 17 00:00:00 2001
From: Xiajijian <1176061145@qq.com>
Date: Fri, 12 Dec 2025 15:23:07 +0800
Subject: [PATCH] 1. 禁飞区修改。
---
ard-route/src/main/java/com/ard/route/service/impl/ArdRouteInfoServiceImpl.java | 99 ++++++++++++++++++++++++++++++++++++++++++-------
1 files changed, 85 insertions(+), 14 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 b48775c..1c9f028 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
@@ -12,6 +12,7 @@
import com.ard.data.noflyzone.domain.Vertex;
import com.ard.data.noflyzone.service.IArdNoFlyZoneService;
import com.ard.data.noflyzone.utils.NoFlyZoneUtils;
+import com.ard.framework.web.service.TokenService;
import com.ard.oss.model.MinioUploadResult;
import com.ard.oss.service.impl.OssServiceContext;
import com.ard.ossdock.service.impl.OssDockServiceContext;
@@ -29,12 +30,15 @@
import com.ard.work.domain.dto.state.PointData;
import com.ard.work.domain.dto.wayline.*;
import com.ard.work.service.ITyService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
+import static com.ard.route.util.InitializationUtils.divided_6;
import static com.ard.route.util.ToolUtils.*;
import static com.ard.route.util.UavRouteReqUtils.fileConversionEntity;
@@ -46,6 +50,8 @@
*/
@Service
public class ArdRouteInfoServiceImpl implements IArdRouteInfoService {
+
+ private static final Logger log = LoggerFactory.getLogger(TokenService.class);
@Autowired
private ArdRouteInfoMapper ardRouteInfoMapper;
@@ -81,6 +87,17 @@
} 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(89)){
+ for (ActionGroupReq actionGroupReq : routePointReq.getActionGroupList()) {
+ for (PointActionReq action : actionGroupReq.getActions()) {
+ action.setZoom(divided_6(action.getZoom()));
+ }
+ }
+ }
+ }
return ardRouteInfo;
}
@@ -97,6 +114,12 @@
}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);
}
@@ -115,7 +138,7 @@
ardRouteInfo.setGroupId("0");
}
ardRouteInfo.getUavRouteReq().setDroneType(subStringDroneType(ardRouteInfo.getAircraft()));
- KmzResultVo kmzResult = routeService.buildKmz(ardRouteInfo.getUavRouteReq(), ardRouteInfo.getName());
+ KmzResultVo kmzResult = routeService.buildKmz(ardRouteInfo.getUavRouteReq(),ardRouteInfo.getName());
ardRouteInfo.setPath(kmzResult.getPath());
ardRouteInfo.setReadOnly("0");
ardRouteInfoMapper.insertArdRouteInfo(dataProcessing(ardRouteInfo));
@@ -145,7 +168,6 @@
}
ardRouteInfo.setPath(kmzResult.getPath());
}
- ardRouteInfo.setReadOnly("0");
return ardRouteInfoMapper.updateArdRouteInfo(dataProcessing(ardRouteInfo));
}
@@ -221,29 +243,68 @@
@Override
public MinioUploadResult uploadArdRouteInfo(MultipartFile file) {
try {
- String url = ossService.upload("kmz",file);
- String urlDock = ossDockService.upload("kmz",file);
- ArdRouteInfo information = new ArdRouteInfo();
- information.setName(file.getOriginalFilename());
- information.setPath(url);
- information.setPath1(urlDock);
- information.setGroupId("0"); // 默认分组
- information.setReadOnly("1"); // 默认只读
// 增加航线实体类信息
UavRouteReq uavRouteReq = fileConversionEntity(file);
+ ArdRouteInfo ardRouteInfo = new ArdRouteInfo();
if (uavRouteReq != null){
- information.setUavRouteReq(uavRouteReq);
- information.setType(templateTypeData(uavRouteReq));
- information.setAircraft(droneTypeData(uavRouteReq));
+ ardRouteInfo.setUavRouteReq(uavRouteReq);
+ ardRouteInfo.setType(templateTypeData(uavRouteReq));
+ ardRouteInfo.setAircraft(droneTypeData(uavRouteReq));
}
- insertRouteInfomation(information);
+
+ // 判断禁飞区
+ try {
+ arrayWithinNoFlyZone(ardRouteInfo.getUavRouteReq().getRoutePointList());
+ } catch (ControlException e) {
+ // 返回包含禁飞区错误信息的特定结果
+ return MinioUploadResult.builder()
+ .originalFilename("禁飞区错误.航线航点在禁飞区!")
+ .build();
+ }
+
+ String url = ossService.upload("kmz",file);
+ String urlDock = ossDockService.upload("kmz",file);
+ ardRouteInfo.setName(file.getOriginalFilename());
+ ardRouteInfo.setPath(url);
+ ardRouteInfo.setPath1(urlDock);
+ ardRouteInfo.setGroupId("0"); // 默认分组
+ ardRouteInfo.setReadOnly("1"); // 默认只读
+ insertRouteInfomation(ardRouteInfo);
return MinioUploadResult.builder()
.url(url)
.newFileName(FileUtils.getName(url))
.originalFilename(file.getOriginalFilename())
.build();
}catch (Exception e){
+ log.error("上传航线文件失败", e);
return null;
+ }
+ }
+
+ /**
+ * 判断一组数组,是否包含禁飞区
+ */
+ private void arrayWithinNoFlyZone(List<RoutePointReq> routePointList) {
+ if (routePointList == null || routePointList.isEmpty()) {
+ return;
+ }
+ // 检查第一个航点
+ ArdNoflyDto firstDto = new ArdNoflyDto();
+ firstDto.setTarget(new Vertex(
+ routePointList.get(0).getLongitude(),
+ routePointList.get(0).getLatitude()));
+ verifyNoFlyZone(firstDto);
+
+ // 检查后续航点及与前一个航点的线段
+ for (int i = 1; i < routePointList.size(); i++) {
+ ArdNoflyDto dto = new ArdNoflyDto();
+ dto.setCurrent(new Vertex(
+ routePointList.get(i - 1).getLongitude(),
+ routePointList.get(i - 1).getLatitude()));
+ dto.setTarget(new Vertex(
+ routePointList.get(i).getLongitude(),
+ routePointList.get(i).getLatitude()));
+ verifyNoFlyZone(dto);
}
}
@@ -295,6 +356,16 @@
} catch (IOException | ClassNotFoundException e) {
throw new RuntimeException(e);
}
+
+ // 判断禁飞区
+ try {
+ arrayWithinNoFlyZone(route.getUavRouteReq().getRoutePointList());
+ } catch (ControlException e) {
+ log.error("禁飞区错误.航线航点在禁飞区!", e);
+ // 返回包含禁飞区错误信息的特定结果
+ return false;
+ }
+
// 1.2通过minio获取航线信息
// 2.将航线信息转换成对应实体类
WayLineUploadDTO wayLineUploadDTO = buildWayLineUploadDTO(route);
--
Gitblit v1.9.3