From 98c8e73c57f8f76e5720a066f155ebfff2a7cc5f Mon Sep 17 00:00:00 2001
From: rain <167982779@qq.com>
Date: Thu, 18 Apr 2024 20:05:48 +0800
Subject: [PATCH] 修改DB成果展示入库失败,增加TbfjEntity表的字段,无对应字段默认0.

---
 src/main/java/com/dji/sample/territory/service/impl/TbDkjbxxServiceImpl.java |   37 ++++++++++++++++++++++++-------------
 1 files changed, 24 insertions(+), 13 deletions(-)

diff --git a/src/main/java/com/dji/sample/territory/service/impl/TbDkjbxxServiceImpl.java b/src/main/java/com/dji/sample/territory/service/impl/TbDkjbxxServiceImpl.java
index c2ac1e0..f3c4b40 100644
--- a/src/main/java/com/dji/sample/territory/service/impl/TbDkjbxxServiceImpl.java
+++ b/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<>();
+        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);
-        }
     }
 }
\ No newline at end of file

--
Gitblit v1.9.3