Xiajijian
2025-12-09 9ed2310f66ed267162e0891b7b53aafa43a3f7dc
ard-route/src/main/java/com/ard/route/service/impl/ArdRouteInfoServiceImpl.java
@@ -36,6 +36,7 @@
import javax.annotation.Resource;
import static com.ard.route.util.ToolUtils.*;
import static com.ard.route.util.UavRouteReqUtils.fileConversionEntity;
/**
 * 航线(kmz)Service业务层处理
@@ -116,6 +117,7 @@
        ardRouteInfo.getUavRouteReq().setDroneType(subStringDroneType(ardRouteInfo.getAircraft()));
        KmzResultVo kmzResult = routeService.buildKmz(ardRouteInfo.getUavRouteReq(), ardRouteInfo.getName());
        ardRouteInfo.setPath(kmzResult.getPath());
        ardRouteInfo.setReadOnly("0");
        ardRouteInfoMapper.insertArdRouteInfo(dataProcessing(ardRouteInfo));
        return kmzResult.getPath();
    }
@@ -143,28 +145,32 @@
            }
            ardRouteInfo.setPath(kmzResult.getPath());
        }
        ardRouteInfo.setReadOnly("0");
        return ardRouteInfoMapper.updateArdRouteInfo(dataProcessing(ardRouteInfo));
    }
    // 新增信息加工
    private ArdRouteInfo dataProcessing(ArdRouteInfo ardRouteInfo) {
        // 航线数据
        byte[] routeData;
        byte[] routeData = null;
        try {
            routeData = serialize(ardRouteInfo.getUavRouteReq());
            if (ardRouteInfo.getUavRouteReq() != null){
                routeData = serialize(ardRouteInfo.getUavRouteReq());
            }
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        ardRouteInfo.setRouteData(routeData);
        ardRouteInfo.setReadOnly("0");
        ardRouteInfo.setPointCount(getPointCount(ardRouteInfo));
        return ardRouteInfo;
    }
    // 获取行点总数
    private Integer getPointCount(ArdRouteInfo ardRouteInfo) {
        if (ardRouteInfo.getUavRouteReq().getRoutePointList() != null) {
            return ardRouteInfo.getUavRouteReq().getRoutePointList().size();
        if (ardRouteInfo.getUavRouteReq() != null){
            if (ardRouteInfo.getUavRouteReq().getRoutePointList() != null) {
                return ardRouteInfo.getUavRouteReq().getRoutePointList().size();
            }
        }
        return 0;
    }
@@ -215,18 +221,29 @@
    @Override
    public MinioUploadResult uploadArdRouteInfo(MultipartFile file) {
        try {
            // 增加航线实体类信息
            UavRouteReq uavRouteReq = fileConversionEntity(file);
            ArdRouteInfo ardRouteInfo = new ArdRouteInfo();
            if (uavRouteReq != null){
                ardRouteInfo.setUavRouteReq(uavRouteReq);
                ardRouteInfo.setType(templateTypeData(uavRouteReq));
                ardRouteInfo.setAircraft(droneTypeData(uavRouteReq));
            }
            // 判断禁飞区
            List<RoutePointReq> routePointList = ardRouteInfo.getUavRouteReq().getRoutePointList();
            for (RoutePointReq routePointReq : routePointList) {
                ArdNoflyDto ardNoflyDto = new ArdNoflyDto();
                ardNoflyDto.setCurrent(new Vertex(routePointReq.getLongitude(), routePointReq.getLatitude()));
                verifyNoFlyZone(ardNoflyDto);
            }
            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");   // 默认只读
            // 生成kmz文件实体类加工
            // 增加航线实体类信息
            insertRouteInfomation(information);
            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))
@@ -503,7 +520,7 @@
        ardRouteInfo.setId(IdUtils.simpleUUID());
        ardRouteInfo.setCreateTime(DateUtils.getNowDate());
        ardRouteInfo.setUpdateTime(DateUtils.getNowDate());
        ardRouteInfoMapper.insertArdRouteInfo(ardRouteInfo);
        ardRouteInfoMapper.insertArdRouteInfo(dataProcessing(ardRouteInfo));
    }
    /**