From f61c1902e30b0ab54e833960df7d2d79c8b62120 Mon Sep 17 00:00:00 2001
From: guoshilong <123456>
Date: Thu, 12 Oct 2023 17:11:05 +0800
Subject: [PATCH] 执行时间
---
src/main/java/com/dji/sample/wayline/service/impl/WaylineFileServiceImpl.java | 19 ++++++++++---------
1 files changed, 10 insertions(+), 9 deletions(-)
diff --git a/src/main/java/com/dji/sample/wayline/service/impl/WaylineFileServiceImpl.java b/src/main/java/com/dji/sample/wayline/service/impl/WaylineFileServiceImpl.java
index bcea104..8267a90 100644
--- a/src/main/java/com/dji/sample/wayline/service/impl/WaylineFileServiceImpl.java
+++ b/src/main/java/com/dji/sample/wayline/service/impl/WaylineFileServiceImpl.java
@@ -93,7 +93,7 @@
public URL getObjectUrl(String workspaceId, String waylineId) throws SQLException {
Optional<WaylineFileDTO> waylineOpt = this.getWaylineByWaylineId(workspaceId, waylineId);
if (waylineOpt.isEmpty()) {
- throw new SQLException(waylineId + " does not exist.");
+ throw new SQLException(waylineId + " 不存在");
}
return ossService.getObjectUrl(OssConfiguration.bucket, waylineOpt.get().getObjectKey());
}
@@ -107,8 +107,8 @@
if (!StringUtils.hasText(file.getSign())) {
try (InputStream object = ossService.getObject(OssConfiguration.bucket, metadata.getObjectKey())) {
if (object.available() == 0) {
- throw new RuntimeException("The file " + metadata.getObjectKey() +
- " does not exist in the bucket[" + OssConfiguration.bucket + "].");
+ throw new RuntimeException("文件" + metadata.getObjectKey() +
+ " 在空间中不存在[" + OssConfiguration.bucket + "].");
}
file.setSign(DigestUtils.md5DigestAsHex(object));
} catch (IOException e) {
@@ -164,7 +164,7 @@
public void importKmzFile(MultipartFile file, String workspaceId, String creator) {
Optional<WaylineFileDTO> waylineFileOpt = validKmzFile(file);
if (waylineFileOpt.isEmpty()) {
- throw new RuntimeException("The file format is incorrect.");
+ throw new RuntimeException("文件格式错误");
}
try {
@@ -182,7 +182,7 @@
private Optional<WaylineFileDTO> validKmzFile(MultipartFile file) {
String filename = file.getOriginalFilename();
if (Objects.nonNull(filename) && !filename.endsWith(WAYLINE_FILE_SUFFIX)) {
- throw new RuntimeException("The file format is incorrect.");
+ throw new RuntimeException("文件格式错误");
}
try (ZipInputStream unzipFile = new ZipInputStream(file.getInputStream(), StandardCharsets.UTF_8)) {
@@ -196,13 +196,13 @@
SAXReader reader = new SAXReader();
Document document = reader.read(unzipFile);
if (!StandardCharsets.UTF_8.name().equals(document.getXMLEncoding())) {
- throw new RuntimeException("The file encoding format is incorrect.");
+ throw new RuntimeException("文件编码格式错误");
}
Node droneNode = document.selectSingleNode("//" + KmzFileProperties.TAG_WPML_PREFIX + KmzFileProperties.TAG_DRONE_INFO);
Node payloadNode = document.selectSingleNode("//" + KmzFileProperties.TAG_WPML_PREFIX + KmzFileProperties.TAG_PAYLOAD_INFO);
if (Objects.isNull(droneNode) || Objects.isNull(payloadNode)) {
- throw new RuntimeException("The file format is incorrect.");
+ throw new RuntimeException("文件格式错误");
}
String type = droneNode.valueOf(KmzFileProperties.TAG_WPML_PREFIX + KmzFileProperties.TAG_DRONE_ENUM_VALUE);
@@ -214,13 +214,14 @@
if (!StringUtils.hasText(type) || !StringUtils.hasText(subType) ||
!StringUtils.hasText(payloadSubType) || !StringUtils.hasText(payloadType) ||
!StringUtils.hasText(templateType)) {
- throw new RuntimeException("The file format is incorrect.");
+ throw new RuntimeException("文件格式错误");
}
return Optional.of(WaylineFileDTO.builder()
.droneModelKey(String.format("%s-%s-%s", DeviceDomainEnum.SUB_DEVICE.getVal(), type, subType))
.payloadModelKeys(List.of(String.format("%s-%s-%s",DeviceDomainEnum.PAYLOAD.getVal(), payloadType, payloadSubType)))
- .objectKey(OssConfiguration.objectDirPrefix + File.separator + filename)
+// .objectKey(OssConfiguration.objectDirPrefix + File.separator + filename)
+ .objectKey(OssConfiguration.objectDirPrefix + "/" + filename)
.name(filename.substring(0, filename.lastIndexOf(WAYLINE_FILE_SUFFIX)))
.sign(DigestUtils.md5DigestAsHex(file.getInputStream()))
.templateTypes(List.of(WaylineTemplateTypeEnum.find(templateType).map(WaylineTemplateTypeEnum::getVal).orElse(-1)))
--
Gitblit v1.9.3