src/main/java/com/dji/sample/territory/service/impl/TbDkjbxxServiceImpl.java
@@ -75,24 +75,45 @@
        }
    }
    /**
     * 根据给定的工作空间ID、航线名称、机场纬度和经度,生成并返回一个包含航线文件的MultipartFile对象。
     *
     * @param workspaceId 工作空间ID,用于查询相关数据。
     * @param waylineName 航线名称,用于命名生成的文件。
     * @param airportLat  机场纬度,用于地理坐标转换和航迹点排序。
     * @param airportLon  机场经度,用于地理坐标转换和航迹点排序。
     * @return MultipartFile 对象,包含压缩后的航迹文件。
     * @throws IOException 如果文件操作失败,则抛出IOException。
     */
    public MultipartFile listFile(String workspaceId, String waylineName, double airportLat, double airportLon) throws IOException {
        List<TbDkjbxxEntity> list = mapper.selectList(null);
        List<LotInfo> info = dbConvertToEntity(list);
        Coordinate[] coordinates = GeoToolsUtil.getRoutePointOrder(info, airportLat, airportLon);
        // 创建XML模板模型
        XMLTemplateModel xmlModel = XMLTemplateModel.init(coordinates, info);
        CreateWaylineFileUtils.createWaylineFile(xmlModel, patchesConfigPojo.getTemplate(), patchesConfigPojo.getTargetTemplate(), patchesConfigPojo.getWaylines(), patchesConfigPojo.getTargetWaylines());
        // 压缩文件夹中的内容
        // 压缩文件夹中的内容到KMZ文件
        String destKMZFile = patchesConfigPojo.getDestKMZFile() + waylineName + ".kmz"; // 输出的KMZ文件路径
        zipFolder(patchesConfigPojo.getSourceDir(), destKMZFile);
        // 将压缩文件转换为MultipartFile对象
        MultipartFile multipartFile = convert(new File(destKMZFile));
        return multipartFile;
    }
    /**
     * 将TbDkjbxxEntity类型的列表转换为LotInfo类型的列表。
     *
     * @param list TbDkjbxxEntity类型的列表,表示数据库中的实体列表。
     * @return List<LotInfo>类型的列表,表示转换后的业务实体列表。
     */
    private List<LotInfo> dbConvertToEntity(List<TbDkjbxxEntity> list) {
        List<LotInfo> infos =new ArrayList<>();
        for (TbDkjbxxEntity file : list) {
            // 使用Builder模式构建LotInfo对象
            LotInfo.LotInfoBuilder builder = LotInfo.builder();
            if (file != null) {
                // 从TbDkjbxxEntity实体中提取信息,构建LotInfo对象
                builder.bsm(file.getBsm())
                        .bz(file.getBz())
                        .dkmj(file.getDkmj())
@@ -108,20 +129,10 @@
                        .kzxx(file.getKzxx())
                        .dklx(file.getDklx())
                        .build();
                // 将构建好的LotInfo对象添加到infos列表中
                infos.add(builder.build());
            }
        }
        return infos;
    }
    public void insert(List<LotInfo> list) {
        for (LotInfo lotInfo : list) {
            TbDkjbxxEntity entity = new TbDkjbxxEntity();
            entity.setBsm(lotInfo.getBsm());
            entity.setDkbh(lotInfo.getDkbh());
            entity.setXzb(lotInfo.getXzb());
            entity.setYzb(lotInfo.getYzb());
            entity.setDkfw(lotInfo.getDkfw());
            mapper.insert(entity);
        }
    }
}