From fa89f5c4b746a41efee0362bd3a42ea2c97e2cff Mon Sep 17 00:00:00 2001
From: rain <167982779@qq.com>
Date: Mon, 22 Apr 2024 18:13:46 +0800
Subject: [PATCH] 在加水印前对文件进行音视频处理,分别执行不同方法。增加图片压缩、视频压缩方法。
---
src/main/java/com/dji/sample/territory/service/impl/TbDkjbxxServiceImpl.java | 41 +++++++++++++++++++++++++++--------------
1 files changed, 27 insertions(+), 14 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..82ec6a2 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
@@ -18,6 +18,7 @@
import org.locationtech.jts.geom.Coordinate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.FileCopyUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.multipart.MultipartFile;
@@ -38,7 +39,7 @@
* @DATE: 2024/4/10 11:19
*/
@Service
-@DS("sqlite")
+@DS("sqlite-resource")
public class TbDkjbxxServiceImpl extends ServiceImpl<ITbDkjbxxMapper, TbDkjbxxEntity> implements ITbDkjbxxService {
private static final String RESOURCE_FILE_PATH = "DB/resource_db.db";
@Autowired
@@ -75,24 +76,46 @@
}
}
+
+ /**
+ * 根据给定的工作空间ID、航线名称、机场纬度和经度,生成并返回一个包含航线文件的MultipartFile对象。
+ *
+ * @param workspaceId 工作空间ID,用于查询相关数据。
+ * @param waylineName 航线名称,用于命名生成的文件。
+ * @param airportLat 机场纬度,用于地理坐标转换和航迹点排序。
+ * @param airportLon 机场经度,用于地理坐标转换和航迹点排序。
+ * @return MultipartFile 对象,包含压缩后的航迹文件。
+ * @throws IOException 如果文件操作失败,则抛出IOException。
+ */
+ @Transactional
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 +131,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